PageSourceSearch

https://www.georisques.gouv.fr/themes/custom/georisques/assets/dist/js/georisques_commun/app.js?tlugul

js georisques.gouv.fr collected 2026-09-24 09:02:51 UTC 7,161 bytes, 207 lines download raw bytes

1(function ($) {
2    wsUrl = function() {
3        var properties = {};
4
5        $.ajaxSetup({
6            async: false
7        });
8
9        $.getJSON("/themes/custom/georisques/assets/dist/js/georisques_commun/web-service-urls.json", function (data) {
10            properties = data;
11        });
12
13        $.ajaxSetup({
14            async: true
15        });
16
17        return properties.BASE;
18    }
19
20    $.extend(Sammy.Application.prototype, {
21        departements: null,
22        communes: {},
23        wsUrl: wsUrl(),
24        pageSize: 10,
25
26
27        initDptSelect: function (dpt, cb) {
28            var sel = $("#departement");
29            var that = this;
30            sel.find("option:gt(0)").remove();
31
32            function init(dpts) {
33                that.departements = dpts;
34                $.each(dpts, function (i, dpt) {
35                    sel.append($("<option>").text(dpt.nom).val(dpt.id));
36                });
37
38                sel.val(dpt || "");
39                sel.change(function() {
40                    $("#commune").val('');
41                    that.locationChanged();
42                });
43
44                if (cb) {
45                    cb();
46                }
47            }
48
49            if (this.departements) {
50                init(this.departements);
51            } else {
52                $.getJSON(
53                    this.wsUrl + "/departements.json",
54
55                    function (dpts) {
56                        init(dpts.results);
57                    }
58                );
59            }
60        },
61
62
63        initComSelect: function (dpt, commune, cb) {
64            var sel = $('#commune');
65            var that = this;
66
67            sel.find("option:gt(0)").remove();
68
69            if (dpt) {
70                function init(coms) {
71                    that.communes[dpt] = coms;
72                    $.each(coms, function (i, com) {
73                        sel.append($("<option>").text(com.nom).val(com.numero));
74                    });
75
76                    sel.val(commune || "");
77                    sel.change(function() {
78                        that.locationChanged();
79                    });
80
81                    if (cb) {
82                        cb();
83                    }
84                }
85
86                if (this.communes[dpt]) {
87                    init(this.communes[dpt]);
88                } else {
89                    $.getJSON(
90                        this.wsUrl + ("/departements/{id}/communes.json".replace('{id}', dpt)),
91                        function (coms) {
92                            init(coms.results);
93                        }
94                    )
95                }
96            }
97        },
98
99
100        locationChanged: function () {
101            var dpt = $('#departement').val();
102            var com = $('#commune').val();
103            var location;
104
105            if (dpt) {
106                location = com ? '#/data/dpt/{dpt}/com/{com}' : '#/data/dpt/{dpt}';
107            } else {
108                location = '#/data';
109            }
110
111            this.setLocation(location.replace('{dpt}', dpt).replace('{com}', com));
112        },
113
114
115        getQueryStringValues: function() {
116            var values = {};
117
118            $.each(location.search.substr(1).split("&"), function (i, kv) {
119                if (kv === "") return;
120                var parts = kv.split("=");
121                values[parts[0]] = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, " "));
122            });
123
124            return values;
125        },
126
127
128        paginate: function(page, count) {
129            var nbPages = Math.ceil(count / this.pageSize);
130            var pages = [];
131
132            if (nbPages > 1) {
133                for (i = 0; i < nbPages; i++) {
134                    pages.push({
135                        "number": i + 1,
136                        "class": i + 1 == page ? "current" : ""
137                    });
138                }
139            }
140
141            return pages;
142        },
143
144
145        centerMap: function(bbox) {
146            bbox.uuid = uuid;
147            bbox.srid = bbox.srid || 'EPSG:4326';
148
149            var url = 'https://' + document.domain + '/viewer/LoadContext.do?' + $.param(bbox);
150
151            $('#carte-th').attr('src', url);
152        },
153
154
155        loadMap: function (url, bbox, srid) {
156            $(function () {
157                Proj4js.defs["EPSG:2154"] = "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
158                Proj4js.defs["EPSG:27572"] = "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ";
159                Proj4js.defs["EPSG:3857"] = "+title= Google Mercator EPSG:3857 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";
160                Proj4js.defs["EPSG:4559"] = "+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
161                Proj4js.defs["EPSG:2972"] = "+proj=utm +zone=22 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
162                Proj4js.defs["EPSG:2975"] = "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
163                Proj4js.defs["EPSG:4471"] = "+proj=utm +zone=38 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
164                Proj4js.defs["EPSG:4326"] = "+proj=longlat +datum=WGS84 +no_defs";
165                Proj4js.defs["WGS84"] = "+proj=longlat +datum=WGS84 +no_defs";
166
167                var src = url || $('#carte-th').attr('src');
168                var transformedBbox = (Array.isArray(bbox) ? OpenLayers.Bounds.fromArray(bbox) : OpenLayers.Bounds.fromString(bbox))
169
170                if (srid) {
171                    var source = new Proj4js.Proj(srid);
172                    var dest = new Proj4js.Proj("WGS84");
173                    var min = new Proj4js.Point(transformedBbox.left,transformedBbox.bottom);
174                    var max = new Proj4js.Point(transformedBbox.right,transformedBbox.top);
175
176                    Proj4js.transform(source, dest, min);
177                    Proj4js.transform(source, dest, max);
178                    transformedBbox = {
179                        left: min.x,
180                        bottom: min.y,
181                        right: max.x,
182                        top: max.y
183                    };
184                }
185
186                src += '?bbox=' + transformedBbox.left + ',' + transformedBbox.bottom + ',' + transformedBbox.right + ',' + transformedBbox.top;
187                $('#carte-th').attr('src', src);
188                var carte = $('#carte-p').html();
189                $('#carte-p').html("");
190                $('#carte-p').html(carte);
191            });
192        },
193
194
195        loadMapLatLon: function (url, zoom, lat, lon) {
196            $(function () {
197                var src = url || $('#carte-th').attr('src');
198
199                src += '?marker=' + lon + ',' + lat + '&zoom=' + zoom;
200                $('#carte-th').attr('src', src);
201                var carte = $('#carte-p').html();
202                $('#carte-p').html("");
203                $('#carte-p').html(carte);
204            });
205        }
206    });
207})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.