1/* 2 * common function and variables used for all pages 3 * @author: BRe, 2017 4 */ 5 6// page status flags and values 7// must already be set in the page specific js 8var states = states === undefined ? {} : states; 9 10// page back pressed indicator 11// back button support (skip intermediate # location changes) 12pageToLeave = null; 13 14//go back to last page 15function pageBack() { 16 //backPressed = true; 17 pageToLeave = window.location.pathname; 18 window.history.back(); 19} 20// step back until we leave the page (step over visited #anchors) 21window.addEventListener('popstate', function(event) { 22 // The popstate event is fired each time when the current history entry changes. 23 if (pageToLeave === window.location.pathname) { 24 window.history.back(); 25 } 26 27}, false); 28 29// change of the state values of the page 30function setState(state, mode) { 31 states[state] = mode; 32 setDisplay(); 33} 34 35//change of the state values of the page 36function setStateDelay(state, mode) { 37 setTimeout(function(){ 38 states[state] = mode; 39 setDisplay(); 40 }, 1000); 41} 42 43// smooth scroll to a given position 44// to: anchor 45// offset: offset from anchor 46function smoothScroll(to, offset) { 47 $('html, body').animate({ 48 scrollTop: $(to).offset().top + offset 49 }, 1000); 50} 51 52// set display status according to the current state value (open|close boxes, scroll position, ...) 53// depending on the state value (true|false) change the display css property for css classes <state>-hide, <state>-show 54function setDisplay() { 55 //debugger; 56 for (state in states) { 57 if (state === 'offs') { 58 // ignore as it is processed together with 'id' 59 } 60 if (state === 'pos' && $.isNumeric(states[state]) && states[state] !== 0) { 61 // set position 62 setTimeout(function() { 63 $('html, body').animate({scrollTop: states.pos}, 1000); 64 // reset position 65 states.pos = 0; 66 }, 100); 67 } else if (state === 'id' && states[state] !== 0) { 68 var id = states[state]; 69 // set offset 70 var offset = 0; 71 if (states['offs'] !== undefined && $.isNumeric(states['offs'])) { 72 offset = Number(states['offs']); 73 } 74 // goto id 75 var idPos = $('#' + id).offset().top; 76 $('html, body').scrollTop(idPos); 77 // animated scroll offset 78 setTimeout(function() { 79 $('html, body').animate({scrollTop: idPos + offset}, 500); 80 }, 100); 81 } else if (states[state]) { 82 // hide .<state>-hide class & show .<state>-show class 83 $('.'+state+'-show').css('display', 'block'); 84 $('.'+state+'-hide').css('display', 'none'); 85 } else { 86 // show .<state>-hide class & hide .<state>-show class 87 $('.'+state+'-hide').css('display', 'block'); 88 $('.'+state+'-show').css('display', 'none'); 89 } 90// $('#vision-container').slideUp(500).delay(500).css('display', 'none'); 91 } 92} 93 94// update the state values from URL parameters if any 95var updateStatesFromUrlParams = function(params) { 96 var search = window.location.search.substring(1); 97 var params = search.split('&'); 98 for (var i = 0; i < params.length; i++) { 99 var param = params[i].split('='); 100 //if (params[param[0]] !== undefined) { 101 states[param[0]] = param[1] === undefined ? true : param[1]; 102 //} 103 } 104}; 105 106// goto another page 107// put the 'back' url to the history stack to remember state and position when use goto 108function gotoPage(link) { 109 // set back state 110 states.back = true; 111 // remember current scroll position 112 states.pos = parseInt(document.documentElement.scrollTop || document.body.scrollTop , 10); 113 // remember current states (ignore state values equals false 114 var params = ''; 115 for (state in states) { 116 if (states[state] !== false) { 117 params += params.length === 0 ? '?' : '&'; 118 params += states[state] === true ? state : (state + '=' + states[state]); 119 } 120 } 121 122 var location = window.location; 123 // back url 124 var backUrl = location.origin + location.pathname + params; 125 // check if state object is supported by all browsers 126 var stateObj = states; 127 window.history.pushState(stateObj, "felicicon", backUrl); 128 // base url 129 var baseUrl = location.href.substring(0, location.href.lastIndexOf('/') + 1); 130// console.log('GotoUrl: ' + backUrl); 131// console.log('BackUrl: ' + baseUrl + link); 132 // goto page; 133 //debugger; 134 location.assign(baseUrl + link); 135} 136 137// page ready 138// restore state and update display 139$(document).ready(function() { 140 // update states from url params 141 updateStatesFromUrlParams (states); 142 // update display 143 setDisplay(); 144 145 // set current date in footer 146 $("#year").text(new Date().getFullYear()); 147});
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.