PageSourceSearch

https://arenaskovde.se/Templates/Knowit/UX/Script/vizzit.access.js

js arenaskovde.se collected 2026-09-26 16:24:15 UTC 16,185 bytes, 389 lines download raw bytes

1/*!
2 * Joseph Myer's md5() algorithm wrapped in a self-invoked function to prevent
3 * global namespace polution, modified to hash unicode characters as UTF-8.
4 *  
5 * Copyright 1999-2010, Joseph Myers, Paul Johnston, Greg Holt, Will Bond <[email protected]>
6 * http://www.myersdaily.org/joseph/javascript/md5-text.html
7 * http://pajhome.org.uk/crypt/md5
8 * 
9 * Released under the BSD license
10 * http://www.opensource.org/licenses/bsd-license
11 */
12(function(){function c(n,p){var o=n[0],m=n[1],r=n[2],q=n[3];o=a(o,m,r,q,p[0],7,-680876936);q=a(q,o,m,r,p[1],12,-389564586);r=a(r,q,o,m,p[2],17,606105819);m=a(m,r,q,o,p[3],22,-1044525330);o=a(o,m,r,q,p[4],7,-176418897);q=a(q,o,m,r,p[5],12,1200080426);r=a(r,q,o,m,p[6],17,-1473231341);m=a(m,r,q,o,p[7],22,-45705983);o=a(o,m,r,q,p[8],7,1770035416);q=a(q,o,m,r,p[9],12,-1958414417);r=a(r,q,o,m,p[10],17,-42063);m=a(m,r,q,o,p[11],22,-1990404162);o=a(o,m,r,q,p[12],7,1804603682);q=a(q,o,m,r,p[13],12,-40341101);r=a(r,q,o,m,p[14],17,-1502002290);m=a(m,r,q,o,p[15],22,1236535329);o=h(o,m,r,q,p[1],5,-165796510);q=h(q,o,m,r,p[6],9,-1069501632);r=h(r,q,o,m,p[11],14,643717713);m=h(m,r,q,o,p[0],20,-373897302);o=h(o,m,r,q,p[5],5,-701558691);q=h(q,o,m,r,p[10],9,38016083);r=h(r,q,o,m,p[15],14,-660478335);m=h(m,r,q,o,p[4],20,-405537848);o=h(o,m,r,q,p[9],5,568446438);q=h(q,o,m,r,p[14],9,-1019803690);r=h(r,q,o,m,p[3],14,-187363961);m=h(m,r,q,o,p[8],20,1163531501);o=h(o,m,r,q,p[13],5,-1444681467);q=h(q,o,m,r,p[2],9,-51403784);r=h(r,q,o,m,p[7],14,1735328473);m=h(m,r,q,o,p[12],20,-1926607734);o=e(o,m,r,q,p[5],4,-378558);q=e(q,o,m,r,p[8],11,-2022574463);r=e(r,q,o,m,p[11],16,1839030562);m=e(m,r,q,o,p[14],23,-35309556);o=e(o,m,r,q,p[1],4,-1530992060);q=e(q,o,m,r,p[4],11,1272893353);r=e(r,q,o,m,p[7],16,-155497632);m=e(m,r,q,o,p[10],23,-1094730640);o=e(o,m,r,q,p[13],4,681279174);q=e(q,o,m,r,p[0],11,-358537222);r=e(r,q,o,m,p[3],16,-722521979);m=e(m,r,q,o,p[6],23,76029189);o=e(o,m,r,q,p[9],4,-640364487);q=e(q,o,m,r,p[12],11,-421815835);r=e(r,q,o,m,p[15],16,530742520);m=e(m,r,q,o,p[2],23,-995338651);o=k(o,m,r,q,p[0],6,-198630844);q=k(q,o,m,r,p[7],10,1126891415);r=k(r,q,o,m,p[14],15,-1416354905);m=k(m,r,q,o,p[5],21,-57434055);o=k(o,m,r,q,p[12],6,1700485571);q=k(q,o,m,r,p[3],10,-1894986606);r=k(r,q,o,m,p[10],15,-1051523);m=k(m,r,q,o,p[1],21,-2054922799);o=k(o,m,r,q,p[8],6,1873313359);q=k(q,o,m,r,p[15],10,-30611744);r=k(r,q,o,m,p[6],15,-1560198380);m=k(m,r,q,o,p[13],21,1309151649);o=k(o,m,r,q,p[4],6,-145523070);q=k(q,o,m,r,p[11],10,-1120210379);r=k(r,q,o,m,p[2],15,718787259);m=k(m,r,q,o,p[9],21,-343485551);n[0]=d(o,n[0]);n[1]=d(m,n[1]);n[2]=d(r,n[2]);n[3]=d(q,n[3])}function j(u,o,n,m,r,p){o=d(d(o,u),d(m,p));return d((o<<r)|(o>>>(32-r)),n)}function a(o,n,u,r,m,q,p){return j((n&u)|((~n)&r),o,n,m,q,p)}function h(o,n,u,r,m,q,p){return j((n&r)|(u&(~r)),o,n,m,q,p)}function e(o,n,u,r,m,q,p){return j(n^u^r,o,n,m,q,p)}function k(o,n,u,r,m,q,p){return j(u^(n|(~r)),o,n,m,q,p)}function i(p){if(/[\x80-\xFF]/.test(p)){p=unescape(encodeURI(p))}txt="";var r=p.length,q=[1732584193,-271733879,-1732584194,271733878],o;for(o=64;o<=p.length;o+=64){c(q,l(p.substring(o-64,o)))}p=p.substring(o-64);var m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(o=0;o<p.length;o++){m[o>>2]|=p.charCodeAt(o)<<((o%4)<<3)}m[o>>2]|=128<<((o%4)<<3);if(o>55){c(q,m);for(o=0;o<16;o++){m[o]=0}}m[14]=r*8;c(q,m);return q}function l(n){var o=[],m;for(m=0;m<64;m+=4){o[m>>2]=n.charCodeAt(m)+(n.charCodeAt(m+1)<<8)+(n.charCodeAt(m+2)<<16)+(n.charCodeAt(m+3)<<24)}return o}var g="0123456789abcdef".split("");function f(p){var o="",m=0;for(;m<4;m++){o+=g[(p>>(m*8+4))&15]+g[(p>>(m*8))&15]}return o}function b(m){for(var n=0;n<m.length;n++){m[n]=f(m[n])}return m.join("")}md5=function(m){return b(i(m))};function d(n,m){return(n+m)&4294967295}if(md5("hello")!="5d41402abc4b2a76b9719d911017c592"){function d(m,p){var o=(m&65535)+(p&65535),n=(m>>16)+(p>>16)+(o>>16);return(n<<16)|(o&65535)}}})();/**
13 * Vizzit overlay EPiServer
14 */
15function VizzitEPiServerOverlay()
16{
17	var self = this;
18	this.customer = 'd4DRG5lLo3Y46EgDhPe8PQ==';
19	this.useEncryption = false;
20	this.removeDomain = false;
21	this.version = 0;
22	this.editLink = '';
23	this.pageId = '';
24	this.username = '';
25	this.login = '//www.vizzit.se/portal/';
26	this.html = '<div id="vizzit-episerver-overlay" class="pos-bot"><div class="vizzit-main-item"><div class="main-item-image"></div><div class="main-item-text">Vizzit</div></div><div class="vizzit-dropdown"><div class="vizzit-dropdown-item"><span id="vizzitLinkPortal">My Vizzit</span></div><div class="vizzit-dropdown-item"><span id="vizzitLinkThisPage">This page</span></div><div id="vizzitMoveButton" class="vizzit-dropdown-item">Move button</div></div></div>';
27	this.position = null;
28	this.mainWindow = window.top;
29	this.mainDocument = window.top.document;
30	this.pageId = null;
31
32	this.init = function()
33	{
34		// Attach event
35		self.window();
36	};
37
38	this.run = function()
39	{
40		// Check if we're in the edit mode or not
41		if(!self.isEditMode())
42			return false;
43
44		// Fetch pageId and username
45		self.pageId = self.getPageId();
46		self.username = self.getUsername();
47
48		// Since EPiServer only loads this JavaScript in edit mode we can safely always render the overlay
49		self.render();
50	};
51
52	/**
53	 * Fetches the page Id for the current page
54	 * @return int/bool
55	 */
56	this.getPageId = function()
57	{
58		// Check if the frames exist
59		if(typeof(window.top.frames[1]) !== 'undefined')
60			var startPage = window.top.frames[1].StartPage;
61
62		// Set default value as the startpage
63		if(self.pageId === null && self.version === 6)
64		{
65			self.pageId = (typeof startPage !== 'undefined') ? startPage : null;
66			return self.pageId;
67		}
68
69		var urlString = {
70			6: self.getEPi6EditFrameUrl(),
71			9: self.mainWindow.location.href,
72			11: self.mainWindow.location.href
73		};
74		var idString = {
75			6: '?id=',
76			9: 'context=epi.cms.contentdata:///',
77			11: 'context=epi.cms.contentdata:///'
78		};
79		var url = urlString[self.version];
80		var stringIndex = url.indexOf(idString[self.version]);
81
82		// Id string was not found, therefore return false
83		if(stringIndex === -1)
84			return false;
85
86		// Calculate the start and stop index of the ID and fetch that id
87		var startIndex = stringIndex + idString[self.version].length;
88		var endIndex = url.indexOf('&', startIndex);
89
90		// Could not find '&' sign, so set the end index as the final length of the string
91		if(endIndex === -1)
92			endIndex = url.length;
93
94		self.pageId = parseInt(url.substring(startIndex, endIndex));
95		return self.pageId;
96	};
97
98	/**
99	 * Fetches the name of the current user
100	 * @return string
101	 */
102	this.getUsername = function()
103	{
104		var aTags = self.mainDocument.getElementsByTagName('a');
105		var username = "vizzit-default";
106
107		if(self.version === 11)							
108		{
109			// Find the topbar element and its buttons
110			var navContainer = self.mainDocument.getElementById('epi-navigation-root');
111			var navButtons = navContainer.querySelectorAll('button');
112
113			for (var j = 0; j < navButtons.length; ++j) {
114				// Skip if element not has attribute title
115				if(!navButtons[j].hasAttribute('title'))
116					continue;
117				// Skip if value is edit or search
118				if(navButtons[j].getAttribute('title') === 'Help' || navButtons[j].getAttribute('title') === 'Hjälp' || navButtons[j].getAttribute('title') === 'Hjelp' || navButtons[j].getAttribute('title') === 'Ohje' || navButtons[j].getAttribute('title') === 'Hjælp' || navButtons[j].getAttribute('title') === 'Search' || navButtons[j].getAttribute('title') === 'Sök' || navButtons[j].getAttribute('title') === 'Søk' || navButtons[j].getAttribute('title') === 'Etsi' || navButtons[j].getAttribute('title') === 'Søg')
119					continue;
120				username = navButtons[j].getAttribute('title');
121			}			
122		}
123		else
124		{
125			// Loop through all <a> tags and look for the one with the user-name class
126			// when it's found store the text in the "title" parameter, which is the name
127			for(var i = 0; i <= aTags.length; i++)
128			{
129				var tag = aTags[i];
130				if(tag.className === 'epi-navigation-global_user ')
131				{
132					username = tag.title;
133					break;
134				}
135			}
136		}
137
138		// If they wish to remove the domain from the username using the format
139		// Domain\Username, split by the backslash and use what's after it
140		if(self.removeDomain === true)
141			username = username.split('\\')[1];
142
143		// If they should use encryption, return the MD5-hash of the username
144		if(self.useEncryption === true)
145			return md5(username);
146
147		return username;
148	};
149
150	this.render = function()
151	{
152		// Check if there is already an overlay rendered, then remove that one
153		var overlay = self.mainDocument.getElementById('vizzit-episerver-overlay-holder');
154		if(overlay != null)
155			overlay.parentNode.removeChild(overlay);
156
157		// Create the initial holder element and render it
158		var holder = self.mainDocument.createElement('div');
159		holder.id = 'vizzit-episerver-overlay-holder';
160		holder.innerHTML = self.html;
161		self.mainDocument.body.insertBefore(holder, self.mainDocument.body.firstChild);
162
163		// Always load the stylesheet
164		self.loadStyleSheet();
165
166		// Store the overlay HTML element
167		var overlay = self.mainDocument.getElementById('vizzit-episerver-overlay');
168		self.position = self.getLastPos();
169		overlay.className = self.position;
170
171		// Set up click method
172		var clickMethod = function(link)
173		{
174			window.open(self.makeLoginLink(link));
175			return false;
176		};
177
178		// We need to set events on these because it's a span tag,
179		// Because unfortunately when using an "a" tag with href,
180		// episerver's edit.js blocks them saying "invalid local url"
181		var portal = self.mainDocument.getElementById('vizzitLinkPortal');
182		var thispage = self.mainDocument.getElementById('vizzitLinkThisPage');
183		var moveButton = self.mainDocument.getElementById('vizzitMoveButton');
184		if(window.addEventListener) // W3C DOM
185		{
186			portal.addEventListener('click', function(){ clickMethod('portal'); }, false);
187			thispage.addEventListener('click', function(){ clickMethod('thispage'); }, false);
188			moveButton.addEventListener('click', function(){ self.moveOverlay(); }, false);
189		}
190		else if(window.attachEvent) // IE DOM
191		{
192			portal.attachEvent('onclick', function(){ clickMethod('portal'); });
193			thispage.attachEvent('onclick', function(){ clickMethod('thispage'); });
194			moveButton.attachEvent('onclick', function(){ self.moveOverlay(); });
195		}
196	};
197
198	/**
199	 * Window onload event
200	 * @return void
201	 */
202	this.window = function()
203	{
204		if(document.readyState === 'complete') // DOM is already complete
205			self.run();
206		else if(window.addEventListener) // W3C DOM
207			window.addEventListener('load', self.run, false);
208		else if(window.attachEvent) // IE DOM
209			window.attachEvent("onload", self.run);
210	};
211
212	/**
213	 * Toggles the positions of the overlay
214	 * @return void
215	 */
216	this.moveOverlay = function()
217	{
218		// Store the html element
219		var overlay = self.mainDocument.getElementById('vizzit-episerver-overlay');
220
221		// It's on top, move to bottom
222		if(overlay.className === 'pos-top')
223			overlay.className = 'pos-bot';
224
225		// It's on bottom, move to top
226		else if(overlay.className === 'pos-bot')
227			overlay.className = 'pos-top';
228
229		// It's neither, set default position as bot
230		else
231			overlay.className = 'pos-bot';
232
233		// Store the new position in the variable and cookie
234		self.position = overlay.className;
235		var cookie = "pos=" + self.position;
236		cookie += ";expires=" + self.getExpireDate();
237		self.mainDocument.cookie = cookie;
238	};
239
240	/**
241	 * Make login link
242	 * @param string tool
243	 * @return string
244	 */
245	this.makeLoginLink = function(tool)
246	{
247		var href = this.login;
248		href += '?user=' + this.getUsername();
249		href += '&data1=' + this.customer;
250		href += '&p=' + this.getPageId();
251		href += '&t=' + tool;
252		href += '&epi';
253		return href;
254	};
255
256	/**
257	 * Gets the last position of the overlay (pos-top, pos-bot, the latter being default value)
258	 * @return string position
259	 */
260	this.getLastPos = function()
261	{
262		// Split the cookies into an array
263		var cookies = self.mainDocument.cookie.split(';');
264
265		// Loop through each cookie, when we find our cookie we'll return its value
266		for(var i = 0; i < cookies.length; i++)
267			if(cookies[i].indexOf('pos=') >= 0)
268				return cookies[i].substr(cookies[i].indexOf('=') + 1);
269
270		// Our cookie wasn't found, return the default value
271		return 'pos-bot';
272	};
273
274	/**
275	 * Check if we're currently in the edit mode or not
276	 * and while we're at it, store the current CMS version
277	 * @return bool
278	 */
279	this.isEditMode = function()
280	{
281		// Used to store the class names for the edit button in various CMSes.
282		// This also works to show which EPiServer CMSes we support
283		var editButtonClassNames = {
284			6: '.epi-navigation-global_cms_edit',
285			9: '.epi-navigation-global_cms_Home',
286			11: 'epi-navigation-root'
287		};
288
289		// Loop through each class name, with respective version to see if we can find the elements
290		// When we find them we'll have "version" and "editButton" to use later in the code
291		for(var version in editButtonClassNames)
292		{
293			// For Epi 11
294			if(version === '11')
295			{
296				// Find navigation container
297				var navContainer = self.mainDocument.getElementById(editButtonClassNames[version]);
298				if(navContainer === null)
299					continue;
300
301				// Check for attribute data-epi-section and if it has value (Edit)
302				if(!navContainer.hasAttribute('data-epi-section'))
303					continue;
304				if(navContainer.getAttribute('data-epi-section') !== 'Edit' 
305					&& navContainer.getAttribute('data-epi-section') !== 'Redigera' 
306					&& navContainer.getAttribute('data-epi-section') !== 'Rediger'
307					&& navContainer.getAttribute('data-epi-section') !== 'Muokkaus')
308					continue;
309
310				// Flagged as in edit mode as we found all the correct elements
311				// Store the version
312				self.version = parseInt(version);
313			}
314			else
315			{
316				// Find the element by class name, if more or fewer than one element is found continue the loop
317				var editButton = self.mainDocument.querySelectorAll(editButtonClassNames[version]);
318
319				// Edit button wasn't found, we're not in the edit mode
320				if(editButton.length !== 1)
321					continue;
322
323				// Store parent element classnames for further checks
324				var parent = editButton[0].parentElement.className;
325
326				// There's an "epi-navigation-util" element above the button, ignore it
327				if(parent.indexOf('epi-navigation-util') !== -1)
328					continue;
329			
330				// The parent doens't have the class "epi-navigation-selected",
331				// we need to continue looping through the elements
332				if(parent.indexOf('epi-navigation-selected') === -1)
333					continue;
334				
335				// Flagged as in edit mode as we found all the correct elements
336				// Store the version and the edit link
337				self.version = parseInt(version);
338				self.editLink = editButton.href;
339			}
340			return true;
341		}
342		// We cannot find any elements to confirm edit mode, return false
343		return false;
344	};
345
346	/**
347	 * Fetches the URL off of the EPiServer 6 edit iFrame
348	 * @return string
349	 */
350	this.getEPi6EditFrameUrl = function()
351	{
352		// Wrong version, return null string
353		if(self.version !== 6)
354			return '';
355		// Store the edit iFrame element from the HTML
356		var iFrameElement = self.mainDocument.getElementById('ctl00_ctl00_FullRegion_EditPanelDiv');
357		// Check store the window object from either contentWindow or contentDocument
358		if(iFrameElement == null)
359			return '';
360		var iFrameWindowObject = (iFrameElement.contentDocument || iFrameElement.contentWindow);
361		// Finally return the URL
362		return iFrameWindowObject.location.href;
363	};
364
365	/**
366	 * Loads the stylesheet into the document by appending a <link> element to the body
367	 * @return void
368	 */
369	this.loadStyleSheet = function()
370	{
371		var linkElement = self.mainDocument.createElement('link');
372		linkElement.rel = 'stylesheet';
373		linkElement.type = 'text/css';
374		linkElement.href = '//www.vizzit.se/overlay/episerver/css/overlay.css';
375		self.mainDocument.body.insertBefore(linkElement, self.mainDocument.body.firstChild);
376	};
377
378	/**
379	 * Returns a dateobject with the expire date which is one year into the future
380	 * @return Date-object
381	 */
382	this.getExpireDate = function()
383	{
384		return new Date(new Date().setFullYear(new Date().getFullYear() + 1));
385	};
386};
387
388var VizzitEPiServerOverlayObject = new VizzitEPiServerOverlay();
389VizzitEPiServerOverlayObject.init();

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.