PageSourceSearch

https://www-actus.univ-ubs.fr/skins/Chroniques-UBS/resources/js/history.js

js univ-ubs.fr collected 2026-09-24 09:14:43 UTC 2,902 bytes, 116 lines download raw bytes

1/*
2 *  Copyright 2012 Anyware Services
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 */
16
17if (typeof window.ART_HISTORY == 'undefined') window.ART_HISTORY = { };
18
19ART_HISTORY = {
20	limit : 6,
21	cookieName : 'ametys-zone-history'
22};
23
24if (!Array.indexOf) 
25{
26	Array.prototype.indexOf = function (obj, start) 
27	{
28		for (var i = (start || 0); i < this.length; i++) 
29		{
30			if (this[i] == obj) 
31			{
32				return i;
33			}
34		}
35		return -1;
36	}
37}
38
39
40function navigationHistory(template, zonetitle) 
41{
42	/* get title and url */
43	var title = document.title.split('-');
44	
45	var url = location.href;
46	var anchor = (url).indexOf('#');
47	var queryString = (url).indexOf('?');
48	
49	if (anchor != -1)
50	{
51		url = url.substring(0, anchor);
52	}
53	
54	if (queryString != -1)
55	{
56		url = url.substring(0, queryString);
57	}
58	
59	var fieldArray = $j.trim(title[0])+';' + url;
60	 
61	/* get cookie */
62	var cookieHistory = new Array();
63	
64	if ($j.cookie(ART_HISTORY.cookieName)) 
65	{
66		cookieHistory = $j.cookie(ART_HISTORY.cookieName).split('|');
67	}
68	else
69	{
70		$j.cookie(ART_HISTORY.cookieName, cookieHistory.join('|'), {'path' : contextPath});
71	}
72	
73	/* add title and url in cookie */
74	var fieldIndex = cookieHistory.indexOf(fieldArray);
75	if (fieldIndex == -1) 
76	{
77		if (cookieHistory.length > ART_HISTORY.limit)
78		{
79			cookieHistory.pop();
80		}
81	}
82	else 
83	{
84		cookieHistory.splice(fieldIndex, 1);
85	}
86	
87	/* Display History*/
88	if (cookieHistory.length > 0) 
89	{
90		var historyListWrapper = $j(document.createElement('div'));
91		var historyList = $j(document.createElement('ul'));
92		historyListWrapper.append(historyList);
93		
94		$j.each(cookieHistory, function(i, value) {
95			if (i < cookieHistory.length)
96			{
97				var el = value.split(';');
98				var anchor = $j(document.createElement('a')).append(el[0]);
99				anchor.attr('href', el[1]);
100				$j(document.createElement('li')).append(anchor).appendTo(historyList);
101			}
102		});
103		
104		var content = historyList.dom;
105		
106		var value = template.replace(/!!!([^@]|@[^@]|@@[^@])+@@@/g, "").replace("@AMETYSHISTORYTITLEMARKER@", zonetitle).replace("@AMETYSHISTORYCONTENTMARKER@", historyListWrapper.html());
107		document.write(value);
108	}
109	
110	/* Add History*/
111	
112	cookieHistory.unshift(fieldArray);
113	$j.cookie(ART_HISTORY.cookieName, cookieHistory.join('|'), {'path' : contextPath});
114
115}
116

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.