#!/bin/bash

echo "Download dependencies"
mkdir -p js css fonts

wget "https://code.jquery.com/jquery-3.6.0.min.js" -O "js/jquery.min.js"

wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/js/metro.min.js" -O "js/metro.min.js"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/css/metro.min.css" -O "css/metro.min.css"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/css/metro-schemes.min.css" -O "css/metro-schemes.min.css"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/css/metro-rtl.min.css" -O "css/metro-rtl.min.css"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/css/metro-rtl.min.css" -O "css/metro-rtl.min.css"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/css/metro-responsive.min.css" -O "css/metro-responsive.min.css"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/css/metro-icons.min.css" -O "css/metro-icons.min.css"
wget "https://github.com/olton/Metro-UI-CSS-3/raw/master/build/fonts/metro.eot" -O "fonts/metro.eot"
wget "https://github.com/olton/Metro-UI-CSS-3/raw/master/build/fonts/metro.svg" -O "fonts/metro.svg"
wget "https://github.com/olton/Metro-UI-CSS-3/raw/master/build/fonts/metro.woff" -O "fonts/metro.woff"
wget "https://github.com/olton/Metro-UI-CSS-3/raw/master/build/fonts/metro.ttf" -O "fonts/metro.ttf"
wget "https://raw.githubusercontent.com/olton/Metro-UI-CSS-3/master/build/fonts/selection.json" -O "fonts/selection.json"

sed -i 's/https:\/\/themes.googleusercontent.com\/static//g' css/metro.min.css

wget "http://cdn.leafletjs.com/leaflet/v1.7.1/leaflet.zip" -O "/tmp/leaflet.zip"
rm -rf /tmp/leaflet
mkdir -p /tmp/leaflet
unzip /tmp/leaflet.zip -d /tmp/leaflet
cp /tmp/leaflet/leaflet.js js/leaflet.js
cp /tmp/leaflet/leaflet.js.map js/leaflet.js.map
cp /tmp/leaflet/leaflet.css css/leaflet.css
cp -r /tmp/leaflet/images css/

wget "https://github.com/makinacorpus/Leaflet.GeometryUtil/archive/refs/tags/v0.9.1.zip" -O "/tmp/Leaflet.GeometryUtil.zip"
rm -rf /tmp/Leaflet.GeometryUtil
mkdir -p /tmp/Leaflet.GeometryUtil
unzip /tmp/Leaflet.GeometryUtil.zip -d /tmp/Leaflet.GeometryUtil
cp /tmp/Leaflet.GeometryUtil/Leaflet.GeometryUtil-0.9.1/src/leaflet.geometryutil.js "js/leaflet.geometryutil.js"
rm -rf /tmp/Leaflet.GeometryUtil

wget "https://github.com/Leaflet/Leaflet.markercluster/archive/refs/tags/v1.4.1.zip" -O "/tmp/Leaflet.markercluster.zip"
rm -rf /tmp/Leaflet.markercluster
mkdir -p /tmp/Leaflet.markercluster
unzip /tmp/Leaflet.markercluster.zip -d /tmp/Leaflet.markercluster/
cp /tmp/Leaflet.markercluster/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js "js/leaflet.markercluster.js"
cp /tmp/Leaflet.markercluster/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js.map "js/leaflet.markercluster.js.map"
cp /tmp/Leaflet.markercluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.css "css/MarkerCluster.css"
cp /tmp/Leaflet.markercluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.Default.css "css/MarkerCluster.Default.css"

wget "https://raw.githubusercontent.com/ewoken/Leaflet.MovingMarker/master/MovingMarker.js" -O "js/Leaflet.MovingMarker.js" 

wget "https://raw.githubusercontent.com/komoot/leaflet.photon/master/leaflet.photon.js" -O "js/leaflet.photon.js"
wget "https://raw.githubusercontent.com/komoot/leaflet.photon/master/leaflet.photon.css" -O "css/leaflet.photon.css"

wget "https://raw.githubusercontent.com/moment/moment/master/min/moment.min.js" -O "js/moment.min.js"
wget "https://raw.githubusercontent.com/moment/moment/master/min/moment.min.js.map" -O "js/moment.min.js.map"

wget "https://raw.githubusercontent.com/jashkenas/underscore/master/underscore-min.js" -O "js/underscore.min.js"

wget "https://raw.githubusercontent.com/hgoebl/mobile-detect.js/master/mobile-detect.min.js" -O "js/mobile-detect.min.js"

wget "https://raw.githubusercontent.com/kimmobrunfeldt/progressbar.js/master/dist/progressbar.min.js" -O "js/progressbar.min.js"
wget "https://raw.githubusercontent.com/kimmobrunfeldt/progressbar.js/master/dist/progressbar.min.js.map" -O  "js/progressbar.min.js.map"

wget "https://data.explore.star.fr/api/datasets/1.0/img-illustrations-modes-dm/attachments/picto_modes_zip" -O /tmp/picto_modes.zip

unzip -o /tmp/picto_modes.zip -d /tmp/picto/
mv /tmp/picto/*/Bus*.png images/
mv /tmp/picto/*/Metro*.png images/

wget "https://raw.githubusercontent.com/pimterry/loglevel/master/dist/loglevel.min.js" -O "js/loglevel.min.js"

wget "https://cdn.jsdelivr.net/npm/marked/marked.min.js" -O "js/marked.min.js"
