aboutsummaryrefslogtreecommitdiffstats
path: root/templates/web/base/common_scripts.html
blob: f94b3d464ba4401ebfb3ecbb4919de096c768c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
[%

USE date;
USE Math;

scripts = [];

scripts.push(
    start _ "/js/translation_strings." _ lang_code _ ".js?" _ Math.int( date.now / 3600 ),
);

IF bodyclass.match('frontpage');
    scripts.push(
        version('/js/front.js'),
        version('/js/geolocation.js'),
    );
ELSIF bodyclass.match('alertpage');
    scripts.push(
        version('/js/geolocation.js'),
    );
ELSIF bodyclass.match('offlinepage');
ELSE;
    scripts.push(
        version('/js/validation_rules.js'),
        version('/jslib/jquery-1.7.2.min.js'),
        version('/vendor/jquery.multi-select.min.js'),
        version('/vendor/jquery.validate.min.js'),
        version('/cobrands/fixmystreet/fixmystreet.js'),
    );
END;

FOR script IN extra_js;
    scripts.push(script);
END;

IF c.user_exists AND (c.user.from_body OR c.user.is_superuser);
    scripts.push(
        version('/js/geolocation.js'),
        version('/jslib/jquery-1.7.2.min.js'),
        version('/cobrands/fixmystreet/staff.js')
    );
    IF bodyclass.match('mappage') AND c.cobrand.suggest_duplicates AND NOT login_success AND NOT oauth_need_email;
        scripts.push(
            version('/js/duplicates.js')
        );
    END;
    IF c.user.has_body_permission_to('planned_reports');
        scripts.push(
            'https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js',
            version('/cobrands/fixmystreet/offline.js'),
        );
    END;
END;

IF bodyclass.match('mappage');
    FOR script IN map_js.merge(c.cobrand.call_hook('map_js_extra'));
        IF script.match('^/');
            scripts.push(version(script));
        ELSE;
            scripts.push(script);
        END;
    END;
    scripts.push(
        version('/cobrands/fixmystreet/map.js'),
        version('/vendor/dropzone.min.js'),
        version('/vendor/fancybox/jquery.fancybox-1.3.4.pack.js'),
    );
ELSE;
    scripts.push(
        version('/cobrands/fixmystreet/prefetch-polyfill.js'),
    );
END;

IF admin;
    scripts.push(
        version('/cobrands/fixmystreet/admin.js'),
        version('/vendor/html5sortable.min.js'),
    );
END;

TRY;
    PROCESS 'footer_extra_js.html';
CATCH file;
END;

~%]