1/*global window, localStorage, fontSizeTitle, bigger, reset, smaller, biggerTitle, resetTitle, smallerTitle, Cookie */ 2var prefsLoaded = false; 3var defaultFontSize = 100; 4var currentFontSize = defaultFontSize; 5var fontSizeTitle; 6var bigger; 7var smaller; 8var reset; 9var biggerTitle; 10var smallerTitle; 11var resetTitle; 12 13Object.append(Browser.Features, { 14 localstorage: (function() { 15 return ('localStorage' in window) && window.localStorage !== null; 16 })() 17}); 18 19function setFontSize(fontSize) { 20 document.body.style.fontSize = fontSize + '%'; 21} 22 23function changeFontSize(sizeDifference) { 24 currentFontSize = parseInt(currentFontSize, 10) + parseInt(sizeDifference * 5, 10); 25 if (currentFontSize > 180) { 26 currentFontSize = 180; 27 } else if (currentFontSize < 60) { 28 currentFontSize = 60; 29 } 30 setFontSize(currentFontSize); 31} 32 33function revertStyles() { 34 currentFontSize = defaultFontSize; 35 changeFontSize(0); 36} 37 38function writeFontSize(value) { 39 if (Browser.Features.localstorage) { 40 localStorage.fontSize = value; 41 } else { 42 Cookie.write("fontSize", value, {duration: 180}); 43 } 44} 45 46function readFontSize() { 47 if (Browser.Features.localstorage) { 48 return localStorage.fontSize; 49 } else { 50 return Cookie.read("fontSize"); 51 } 52} 53 54function setUserOptions() { 55 if (!prefsLoaded) { 56 var size = readFontSize(); 57 currentFontSize = size ? size : defaultFontSize; 58 setFontSize(currentFontSize); 59 prefsLoaded = true; 60 } 61} 62 63function addControls() { 64 var container = document.id('fontsize'); 65 var content = '<h3>'+ fontSizeTitle +'</h3><p><a title="'+ biggerTitle +'" href="#" onclick="changeFontSize(2); return false">'+ bigger +'</a><span class="unseen">.</span><a href="#" title="'+resetTitle+'" onclick="revertStyles(); return false">'+ reset +'</a><span class="unseen">.</span><a href="#" title="'+ smallerTitle +'" onclick="changeFontSize(-2); return false">'+ smaller +'</a></p>'; 66 container.set('html', content); 67} 68 69function saveSettings() { 70 writeFontSize(currentFontSize); 71} 72 73window.addEvent('domready', setUserOptions); 74window.addEvent('domready', addControls); 75window.addEvent('unload', saveSettings);
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.