PageSourceSearch

https://www.finferries.fi/media/layout/js/font-size-control.js?_=1591875623

js finferries.fi collected 2026-09-24 09:49:34 UTC 3,009 bytes, 112 lines download raw bytes

1"use strict";
2
3var $container = $('.site-main');
4var $downsizeTextButton = $('.js-downsize-text-btn');
5var $enlargeTextButton = $('.js-enlarge-text-btn');
6
7function setCookie(cname, cvalue, exdays) {
8	var d = new Date();
9	d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
10	var expires = "expires=".concat(d.toUTCString());
11	document.cookie = "".concat(cname, "=").concat(cvalue, ";").concat(expires, ";path=/");
12}
13
14function getCookie(cname) {
15	var name = "".concat(cname, "=");
16	var decodedCookie = decodeURIComponent(document.cookie);
17	var ca = decodedCookie.split(';');
18
19	for (var i = 0; i < ca.length; i += 1) {
20		var c = ca[i];
21
22		while (c.charAt(0) === ' ') {
23			c = c.substring(1);
24		}
25
26		if (c.indexOf(name) === 0) {
27			return c.substring(name.length, c.length);
28		}
29	}
30
31	return '';
32}
33/** On page load, check is there cookie already set. */
34
35
36function checkCookie() {
37	var fontSize = getCookie('fontSize');
38
39	if (fontSize !== '') {
40		/** Put cookie to container's class. */
41		$container.attr('data-fontsize', fontSize);
42		$container.addClass(fontSize);
43	}
44	/** Remove fontsize control button disabling, if necessary. */
45
46
47	if (fontSize === 'font-size-150') {
48		$downsizeTextButton.removeAttr('disabled');
49	} else if (fontSize === 'font-size-200') {
50		$downsizeTextButton.removeAttr('disabled');
51		$enlargeTextButton.attr('disabled', 'disabled');
52	}
53}
54/** Called when fontsize control button is pressed. */
55
56
57function getAndSetNewFontsize() {
58	var fontSize = getCookie('fontSize');
59	fontSize = document.getElementsByClassName('site-main')[0].getAttribute('data-fontsize');
60
61	if (fontSize !== '' && fontSize != null) {
62		setCookie('fontSize', fontSize, 1);
63	}
64}
65/** When enlarge button is pressed. */
66
67
68function enlargeText() {
69	var $button = $(this);
70
71	if ($container.hasClass('font-size-150')) {
72		/** Enlarging text to 200 %. */
73		$container.addClass('font-size-200');
74		$container.attr('data-fontsize', 'font-size-200');
75		$container.removeClass('font-size-150');
76		$button.attr('disabled', 'disabled');
77	} else {
78		/** Enlarging text to 150 %. */
79		$container.addClass('font-size-150');
80		$container.attr('data-fontsize', 'font-size-150');
81		$button.removeAttr('disabled');
82		$downsizeTextButton.removeAttr('disabled');
83		$container.removeClass('font-size-100');
84	}
85
86	getAndSetNewFontsize();
87}
88/** When downsize button is pressed. */
89
90
91function downsizeText() {
92	$enlargeTextButton.removeAttr('disabled');
93
94	if ($container.hasClass('font-size-150')) {
95		/** Downsizing text to 100 %. */
96		$container.removeClass('font-size-150');
97		$container.addClass('font-size-100');
98		$container.attr('data-fontsize', 'font-size-100');
99		$downsizeTextButton.attr('disabled', 'disabled');
100	} else {
101		/** Downsizing text to 150 %. */
102		$container.removeClass('font-size-200');
103		$container.addClass('font-size-150');
104		$container.attr('data-fontsize', 'font-size-150');
105	}
106
107	getAndSetNewFontsize();
108}
109
110$enlargeTextButton.on('click', enlargeText);
111$downsizeTextButton.on('click', downsizeText);
112checkCookie();

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.