xref: /dokuwiki/lib/scripts/jquery/update.sh (revision 920904359a7088e3cf3885a96c03c453aa9e4095)
1#!/bin/sh
2#
3# This script loads the latest jQuery and jQuery-UI 1.* versions from jQuery's CDN
4#
5# It also loads the 'smoothness' jQuery-UI theme and all referenced images.
6#
7# @author Andreas Gohr <andi@splitbrain.org>
8# @author Stefan Grönke <stefan@gronke.net>
9# @link   http://code.jquery.com/
10
11# Adjust version for jQuery-UI here - there's no good latest link
12JQUI_VERSION='1.12.1'
13JQUI_HOST="https://code.jquery.com/ui/$JQUI_VERSION"
14JQUI_GIT="https://raw.githubusercontent.com/jquery/jquery-ui/$JQUI_VERSION/ui"
15
16# Adjust version for jQuery here - latest updates slowly
17JQ_VERSION='3.1.1'
18
19# Adjust version for jQuery Migrate
20JQM_VERSION='3.0.0'
21
22# load jQuery
23wget -nv http://code.jquery.com/jquery-${JQ_VERSION}.min.js      -O jquery.min.js
24wget -nv http://code.jquery.com/jquery-${JQ_VERSION}.js          -O jquery.js
25
26# load jQuery-UI
27wget -nv "$JQUI_HOST/jquery-ui.min.js" -O jquery-ui.min.js
28wget -nv "$JQUI_HOST/jquery-ui.js"     -O jquery-ui.js
29
30# load jQuery Migrate
31wget -nv http://code.jquery.com/jquery-migrate-${JQM_VERSION}.min.js      -O jquery-migrate.min.js
32wget -nv http://code.jquery.com/jquery-migrate-${JQM_VERSION}.js          -O jquery-migrate.js
33
34# load the smoothness theme
35mkdir -p jquery-ui-theme/images
36wget -nv -qO- "$JQUI_HOST/themes/smoothness/jquery-ui.css" | sed "s/font-family:[^;]*;//" > jquery-ui-theme/smoothness.css
37images=`gawk 'match($0, /url\("?(images\/[^\)"]+)"?\)/, m) { print m[1] }' jquery-ui-theme/smoothness.css`
38for img in $images
39do
40    wget -nv "$JQUI_HOST/themes/smoothness/$img" -O jquery-ui-theme/$img
41done
42
43# load the localization data for jquery ui
44for LNG in ../../../inc/lang/*
45do
46    CODE=`basename $LNG`
47    wget -nv "$JQUI_GIT/i18n/datepicker-$CODE.js" -O $LNG/jquery.ui.datepicker.js
48    if [ ! -s "$LNG/jquery.ui.datepicker.js" ]; then
49        rm -f $LNG/jquery.ui.datepicker.js
50    fi
51done
52
53# some custom language codes
54wget -nv "$JQUI_GIT/i18n/datepicker-de.js" -O ../../../inc/lang/de-informal/jquery.ui.datepicker.js
55wget -nv "$JQUI_GIT/i18n/datepicker-pt-BR.js" -O ../../../inc/lang/pt-br/jquery.ui.datepicker.js
56wget -nv "$JQUI_GIT/i18n/datepicker-zh-CN.js" -O ../../../inc/lang/zh/jquery.ui.datepicker.js
57wget -nv "$JQUI_GIT/i18n/datepicker-zh-TW.js" -O ../../../inc/lang/zh-tw/jquery.ui.datepicker.js
58wget -nv "$JQUI_GIT/i18n/datepicker-cy-GB.js" -O ../../../inc/lang/cy/jquery.ui.datepicker.js
59
60# strip source maps
61sed -i '/sourceMappingURL/d' *.min.js
62