1// get the time slots json object 2var timeSlots = JSON.parse('{"0": {"start": 0.0, "end": 23.59, "mode": "app"}, "1": {"start": 9.0, "end": 18.0, "mode": "call"}, "2": {"start": 9.0, "end": 18.0, "mode": "call"}, "3": {"start": 9.0, "end": 18.0, "mode": "call"}, "4": {"start": 9.0, "end": 18.0, "mode": "call"}, "5": {"start": 9.0, "end": 17.0, "mode": "call"}, "6": {"start": 0.0, "end": 23.59, "mode": "app"}}'); 3 4var dateObj = new Date(); 5var currentHour = dateObj.getHours() + (dateObj.getUTCMinutes() / 100); 6 7var APP = 'app'; 8var CALL = 'call'; 9 10var modes = {}; 11modes[APP] = "call-closed"; 12modes[CALL] = "call-opened"; 13 14var mode = APP; 15 16if (document.URL.indexOf('mode=' + APP) !== -1) { 17 mode = APP; 18} else if (document.URL.indexOf('mode=' + CALL) !== -1) { 19 mode = CALL; 20} else if (timeSlots !== null) { 21 var modesKeys = Object.keys(modes); 22 var timeSlot = timeSlots[dateObj.getUTCDay()]; 23 24 // get the current mode 25 var timeSlotMode = timeSlot['mode']; 26 var theOtherMode = modesKeys[(modesKeys.indexOf(timeSlot['mode']) + 1) % modesKeys.length]; 27 mode = currentHour >= timeSlot['start'] && currentHour <= timeSlot['end'] ? timeSlotMode : theOtherMode; 28} 29 30if (mode == APP) { 31 body = document.getElementById('body') 32 // remove the default call mode 33 body.classList.remove(modes[CALL]); 34 body.classList.add(modes[mode]); 35} 36 37// Set timeSlots on ppn-input-scheduler if element exists on the page 38document.addEventListener("DOMContentLoaded", () => { 39 const el_scheduler = document.querySelector('ppn-input-scheduler'); 40 if (!el_scheduler) { 41 console.warn('ppn-input-scheduler not found on the page'); 42 return; 43 } 44 el_scheduler.setAttribute('timeslots', JSON.stringify(timeSlots)); 45})
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.