PageSourceSearch

https://www.bison-fute.gouv.fr/extensions/cartographie/_js/bfref-min-2.62.0-J11-RC1.js

js bison-fute.gouv.fr collected 2026-09-24 09:11:45 UTC 13,276 bytes, 425 lines download raw bytes

1var bisonfute = bisonfute || {};
2
3bisonfute.env = {
4		/**
5		 * configuration partagé entre la page d'accueil et trafic.
6		 */
7		rootPath: '/data',
8		cookies : {
9			name : 'bisonfutemap',
10		},
11		geolocalisation: {
12			timeout : 5000
13		},
14		interval: 180000
15};if (!bisonfute) {
16	var bisonfute = {};
17}
18bisonfute.utils = function() {};
19
20bisonfute.utils.prototype = {
21
22		getFormatedDate : function(d,format) {
23			var date = new Date(d);
24			var o = {
25					"M+" : date.getMonth()+1, //month
26					"d+" : date.getDate(),    //day
27					"h+" : date.getHours(),   //hour
28					"m+" : date.getMinutes(), //minute
29					"s+" : date.getSeconds(), //second
30					"q+" : Math.floor((date.getMonth()+3)/3),  //quarter
31					"S" : date.getMilliseconds() //millisecond
32			}
33
34			if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
35					(date.getFullYear()+"").substr(4 - RegExp.$1.length));
36			for(var k in o)if(new RegExp("("+ k +")").test(format))
37				format = format.replace(RegExp.$1,
38						RegExp.$1.length==1 ? o[k] :
39							("00"+ o[k]).substr((""+ o[k]).length));
40			return format; 
41		}
42
43};
44
45
46bisonfute.utils.INSTANCE = new bisonfute.utils();
47if (!bisonfute) {
48	var bisonfute = {};
49}
50bisonfute.core = function() {
51	this.init();
52};
53/**
54 * @class
55 * @constructor
56 */
57bisonfute.core.prototype = {
58		/**
59		 * 
60		 * @param {}
61		 * Initialisation
62		 */
63		init : function() {
64			// Récupération du rootPath
65			this.rootPath = bisonfute.env.rootPath;
66
67			
68			// Valeur par défaut des url d'accès aux sites bison futé
69			this.urlsAccess = {'mobile':'./webapp',
70							'desktop':'./index.html'};
71			
72			// Récupération du fichier de confugration des API 
73			this.configuration = [];
74			this.getJsonConfiguration();
75
76			// récupération Timer
77			this.getTimer();
78
79			// Initialisation de l'objet horodate
80			this.horodate =	{'date':null,
81							 'folder':null};
82
83							 
84			this.getLastIteration();
85			
86			// Initialisation du timer
87			this.setRefreshTimer();
88		},
89		/**
90		 * 
91		 * @param {}
92		 *      Initialisation du timer de rafrachissement
93		 */
94		setRefreshTimer : function (){
95			if(this.timer){
96				window.clearTimeout(this.timer);
97			}
98			var interval = this.refreshTimer;
99			if(interval && typeof interval === "number" && 
100					interval > 0) {
101				var self  = this;
102				this.timer = window.setInterval(function(){ self.getData();},interval);
103			}
104		},
105		/**
106		 * 
107		 * @param {Object}
108		 *            Action click feature
109		 */
110		getHorodate : function() {
111			return this.horodate;
112		},
113		/**
114		 * 
115		 * @param {}
116		 *  retourne URL du json horodate
117		 */
118		getHorodateIteration : function() {
119			return [this.rootPath,'iteration/date.json'].join('/');  
120		},
121
122		/**
123		 * 
124		 * @param {}
125		 *   retourne l'objet configuration
126		 */
127		getConfiguration: function(){
128			return this.configuration;
129		},
130		/**
131		 * 
132		 * @param {}
133		 *   retourne l'objet urlsAccess
134		 */
135		getUrls: function(){
136			return this.urlsAccess;
137		},
138		/**
139		 * 
140		 * @param {}
141		 *   met à jour les urls d'accès aux sites
142		 */
143		updateUrlsAccess : function(){
144			var urls = this.configuration.urlAccess;
145			if(urls){
146				if(urls.mobile && urls.mobile !== ""){
147					this.urlsAccess.mobile = urls.mobile;					
148				}
149				if(urls.desktop && urls.desktop !== ""){					
150					this.urlsAccess.desktop = urls.desktop;
151				}
152			}
153		},
154		
155		/**
156		 * 
157		 * @param {}
158		 *   retourne l'objet configuration
159		 */
160		getTimer: function(){
161			// Récupération de l'interval de rafraichisement des documents et pour la carto
162			if(this.configuration.olMapOptions){
163				this.refreshTimer = this.configuration.olMapOptions.refreshInterval;
164			} else {
165				this.refreshTimer = bisonfute.env.interval;				
166			}
167			
168		},
169		/**
170		 * 
171		 * @param {}
172		 *   Lors du timer
173		 */
174		getData: function(){
175			this.getLastIteration();
176			// à décommenter pour tests sans extracteur : $(this).trigger("dataserverupdate");
177			this.getJsonConfiguration();
178			this.getTimer();
179			this.setRefreshTimer();
180			
181		},
182		/**
183		 * 
184		 * @param {}
185		 *     tentative de récupération du fichier json horodate
186		 */
187		getLastIteration : function (){
188			var self = this;
189			$.ajax({type:'GET',
190				url: this.getHorodateIteration(),
191				dataType: 'json',
192				async: false,
193				context: this,
194				success: function(lastIteration){
195					var currentHorodate = jQuery.extend(true, {}, self.horodate);
196					self.horodate.date = lastIteration[0];
197					var formatedDate = bisonfute.utils.INSTANCE.getFormatedDate(lastIteration[0],'yyyyMMdd-hhmmss');
198					self.horodate.folder = ['data',formatedDate].join('-');
199					// Si nouvelle itération disponible alors on informe les adonné
199s
200					if(currentHorodate.date !=  self.horodate.date){
201						$(this).trigger("dataserverupdate");
202					}
203				},
204				error: function(){
205					// Erreur gérée par les différents modules
206				}
207			});
208		},
209
210		/**
211		 * 
212		 * @param {}
213		 *         tentative de récupération du fichier json de configuration
214		 */
215		getJsonConfiguration : function(){
216			var self = this;
217			$.ajax({
218				type : 'get',
219				url : '/configuration/config.json',
220				async : false,
221				dataType: 'json',
222
223				success : function(config, textStatus, XMLHttpRequest) {
224					if(config.olMapOptions) {
225						self.configuration = config;
226						self.updateUrlsAccess();
227					} else {
228						self.configuration = [];
229					}
230				},
231				error : function(xhr, ajaxOptions, thrownError) {
232					self.configuration = [];
233				}
234			});
235		}
236};
237
238bisonfute.core.INSTANCE = new bisonfute.core();
239
240if(!bisonfute) {var bisonfute = {};}
241
242bisonfute.labels = {"departements":[["01","Ain"],["02","Aisne"],["03","Allier"],["04","Alpes-de-Haute-Provence"],["06","Alpes-Maritimes"],["07","Ardèche"],["08","Ardennes"],["09","Ariège"],["10","Aube"],["11","Aude"],["12","Aveyron"],["67","Bas-Rhin"],["13","Bouches-du-Rhône"],["14","Calvados"],["15","Cantal"],["16","Charente"],["17","Charente-Maritime"],["18","Cher"],["19","Corrèze"],["2A","Corse-du-Sud"],["21","Côte-d'Or"],["22","Côtes-d'Armor"],["23","Creuse"],["79","Deux-Sèvres"],["24","Dordogne"],["25","Doubs"],["26","Drôme"],["91","Essonne"],["27","Eure"],["28","Eure-et-Loir"],["29","Finistère"],["30","Gard"],["32","Gers"],["33","Gironde"],["2B","Haute-Corse"],["31","Haute-Garonne"],["43","Haute-Loire"],["52","Haute-Marne"],["05","Hautes-Alpes"],["70","Haute-Saône"],["74","Haute-Savoie"],["65","Hautes-Pyrénées"],["87","Haute-Vienne"],["68","Haut-Rhin"],["92","Hauts-de-Seine"],["34","Hérault"],["35","Ille-et-Vilaine"],["36","Indre"],["37","Indre-et-Loire"],["38","Isère"],["39","Jura"],["40","Landes"],["42","Loire"],["44","Loire-Atlantique"],["45","Loiret"],["41","Loir-et-Cher"],["46","Lot"],["47","Lot-et-Garonne"],["48","Lozère"],["49","Maine-et-Loire"],["50","Manche"],["51","Marne"],["53","Mayenne"],["54","Meurthe-et-Moselle"],["55","Meuse"],["56","Morbihan"],["57","Moselle"],["58","Nièvre"],["59","Nord"],["60","Oise"],["61","Orne"],["75","Paris"],["62","Pas-de-Calais"],["63","Puy-de-Dôme"],["64","Pyrénées-Atlantiques"],["66","Pyrénées-Orientales"],["69","Rhône"],["71","Saône-et-Loire"],["72","Sarthe"],["73","Savoie"],["77","Seine-et-Marne"],["76","Seine-Maritime"],["93","Seine-Saint-Denis"],["80","Somme"],["81","Tarn"],["82","Tarn-et-Garonne"],["90","Territoire de Belfort"],["94","Val-de-Marne"],["95","Val-d'Oise"],["83","Var"],["84","Vaucluse"],["85","Vendée"],["86","Vienne"],["88","Vosges"],["89","Yonne"],["78","Yvelines"]],"regions":[["84","Auvergne-Rhône-Alpes"],["27","Bourgogne-Franche-Comté"],["53","Bretagne"],["24","Centre-Val de Loire"],["94","Corse"],["44","Grand Est"],["32","Hauts-de-France"],["11","Île-de-France"],["28","Normandie"],["75","Nouvelle-Aquitaine"],["76","Occitanie"],["52","Pays de la Loire"],["93","Provence-Alpes-Côte d'Azur"]],"zones":[["1","Île-de-France"],["2","Ouest"],["3","Nord"],["4","Est"],["5","Sud-Est"],["6","Sud"],["7","Sud-Ouest"]]};
243if (!bisonfute) {
244	var bisonfute = {};
245}
246bisonfute.refadmin = function() {};
247
248bisonfute.refadmin.prototype = {
249		
250		getDepartements : function() {
251			return bisonfute.labels.departements; 
252		},
253		
254		getRegions : function() {
255			return bisonfute.labels.regions; 
256		},
257};
258
259bisonfute.refadmin.INSTANCE = new bisonfute.refadmin();if (!bisonfute) {
260    var bisonfute = {};
261}
262bisonfute.urls = function () {
263    this.init();
264};
265/**
266 * 15/9/2016 Hugues: Internationalisation zoommaintenat.html et zoomhiver.html
267 *    ajout méthode getUrlWithLanguage: récupère la langue via la balise html.lang
268 */
269
270
271bisonfute.urls.prototype = {
272
273    init: function () {
274        this.horodate = {
275            'date': null,
276            'folder': null
277        };
278        this.rootPath = bisonfute.env.rootPath;
279        // Appel du core pour récupérér le fichier l'horodate
280        this.core = bisonfute.core.INSTANCE;
281        $(this.core).bind("dataserverupdate", jQuery.proxy(this.updateHorodate, this));
282        this.updateHorodate();
283    },
284
285    getFlash: function () {
286        return [this.rootPath, this.horodate.folder, 'accueil/flash/flash.json'].join('/');
287    },
288    getConditionsCirculations: function () {
289        return [this.rootPath, this.horodate.folder, 'documents/cc.json'].join('/');
290    },
291    getPrevisionsCirculations: function () {
292        return [this.rootPath, this.horodate.folder, 'documents/pc.json'].join('/');
293    },
294    getWeekendColore: function () {
295        return [this.rootPath, this.horodate.folder, 'documents/wk.json'].join('/');
296    },
297    getCarteAccueil: function (id) {
298        var path = [this.rootPath, '/', this.horodate.folder, '/accueil/cartes/', id, '.png'];
299        return path.join('');
300    },
301    getArrete: function (idZone) {
302        var path = [this.rootPath, '/', this.horodate.folder, '/transporteurs/', idZone];
303        return path.join('');
304    },
305    getChantiersLongueDuree: function (direction) {
306        var path = [this.rootPath, '/', this.horodate.folder, '/cld/', direction];
307        return path.join('');
308    },
309    getHorodateIteration: function () {
310        return [this.rootPath, 'iteration/date.json'].join('/');
311    },
312    getCurrentHorodate: function () {
313        return this.horodate;
314    },
315    updateHorodate: function () {
316        this.horodate = jQuery.extend(true, {}, this.core.getHorodate());
317    },
318    getUrlWithLanguage: function (baseURLSansHtml) {
319        var lang = $("html").prop("lang");
320        if (lang != undefined && lang != "fr") {
321            //zoommaintenant,langen.html
322            return baseURLSansHtml + ",lang" + lang + ".html";
323        } else {
324            return baseURLSansHtml + ".html";
325        }
326    },
327    getRoutePath(routeName, params) {
328        let routePath = bisonfute.ApiRoutes.baseUrl + bisonfute.ApiRoutes[routeName];
329		if (params) {
330            routePath = routePath.replace(/:(\w|-|_)+/gi, (value) => {
331                const result = params[value.replace(':', '')];
332                return result || result === 0 ? result : value;
333            });
334        }
335        return routePath;
336    },
337};
338
339
340bisonfute.urls.INSTANCE = new bisonfute.urls();
341if (!bisonfute) {
342	var bisonfute = {};
343}
344bisonfute.recherche = function() {
345	this.init();
346};
347
348bisonfute.recherche.prototype = {
349		init : function() {
350			// Appel du core pour récupérér le fichier l'horodate
351			this.core = bisonfute.core.INSTANCE;
352			$(this.core).bind("dataserverupdate",jQuery.proxy(this.updateHorodate,this));
353			this.updateHorodate();
354
355			this.rootPath = bisonfute.env.rootPath;
356			this.directory = this._getPathDirectory();
357
358			this.regions = 'regions';
359			this.departements = 'departements';
360			this.urlServer = '/recherche?fq=id:[https://www.bison-fute.gouv.fr%20TO%20https://www.bison-fute.gouv.frzzzz]&q=';
361		},
362
363		getUrlJsonDpt : function(paramRecherche) {
364			var date = paramRecherche.date;
365			var d1 = (paramRecherche.c1 < 10) ? '0' + paramRecherche.c1 : paramRecherche.c1; // On rajoute le '0' pour les départements < 10
366			var p = paramRecherche.page || null;
367			var tab = [this.directory,date,this.departements];
368			var tabDpt = [d1];
369			if(p !== null){
370				tabDpt.push(p);
371			} else {
372				tabDpt.push(1);
373			}
374			tab = tab.concat(tabDpt);
375			var path = tab.join('/');
376			var url = [path,'.json'];
377			return url.join('');
378
379		},
380
381		getUrlJsonRg : function(paramRecherche) {
382			var date = paramRecherche.date;
383			var r1 = paramRecherche.c1;
384			var p = paramRecherche.page || null;
385			var tab = [this.directory,date,this.regions];
386			var tabRg = [r1];
387			if(p !== null){
388				tabRg.push(p);
389			} else {
390				tabRg.push(1);
391			}
392			tab = tab.concat(tabRg);
393			var path = tab.join('/');
394			var url = [path,'.json'];
395			return url.join('');
396		},
397
398		_getPathDirectory: function(){
399			return [this.rootPath,this.horodate.folder,'trafic/autre'].join('/');
400		},
401
402		updateHorodate: function(){
403			this.horodate = jQuery.extend(true, {}, this.core.getHorodate());
404			this.directory = this._getPathDirectory();
405		},
406
407		getResults : function(callback,args,scope) {
408			const motsclef = args.motsclef;
409			const page = args.page;
410			const offset = 10;
411			const url = [this.urlServer,motsclef,'&start=',(page-1)*offset, '&rows=',offset].join('');
412			$.ajax({type:'GET',
413				url: url,
414				dataType: 'json',
415				success: function(json){
416					callback(json);
417				},
418				error: function(){
419					return "error";
420				}
421			});
422		}
423};
424
425bisonfute.recherche.INSTANCE = new bisonfute.recherche();

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.