window.loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'; langCodes = { 'en': 'engelska', 'la': 'latin', 'da': 'danska', 'no': 'norska' } fadeIntoDark = function(img) { img.src='/img/' + (window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'default') + '.png'; } function research(text) { if (document.getElementById('search-text').value == text) { document.getElementById('search-text').focus(); alert('Det står redan "' + text + '" i sökfältet 😅'); } else { document.getElementById('search-text').value = text; window.instantsearch(document.getElementById('search-text')); document.getElementById('search-text').focus() } } // https://stackoverflow.com/questions/1345722/calling-jquery-function-from-javascript function toggle(button) { if (button.target) { button = button.target; } if (button.classList.contains('untoggle')) { button.classList.remove('untoggle'); button.innerText = button.innerText.replace(/Implodera/i, 'Expandera'); button.setAttribute('aria-expanded', 'false'); button.nextElementSibling.classList.add('hide'); button.nextElementSibling.classList.remove('show'); } else { button.classList.add('untoggle'); button.innerText = button.innerText.replace(/Expandera/i, 'Implodera'); button.setAttribute('aria-expanded', 'true'); button.nextElementSibling.classList.add('show'); button.nextElementSibling.classList.remove('hide'); } } window.onfocus = function() { document.body.classList.add('activated'); document.body.classList.remove('deactivated'); } window.onblur = function() { document.body.classList.remove('activated'); document.body.classList.add('deactivated'); } window.ononline = function() { if (window.onlinelink) { if (confirm('Den senaste länken som du tryckte på när du var offline var ' + (window.onlinelink['text'] ? '"' + window.onlinelink['text'] + '" (' + window.onlinelink['href'] + ')' : '"' + window.onlinelink['href'] + '"') + '. Vill du gå till den nu?')) { window.location = window.onlinelink; } } } window.onhashchange = function(event) { // event.preventDefault(); alert(JSON.stringify(new URL(event.newURL).pathname)); return false; if (document.activeElement && document.activeElement.tagName == 'A') { window.location = document.activeElement.getAttribute('href'); } else { window.scrollTo(0, window.pageYOffset - 75 - 14); event.preventDefault(); } } window.addEventListener('load', function() { if (document.querySelector('table.colors')) { document.querySelector('table.colors').onclick = function(event) { document.body.style.background = event.target.style.background; document.querySelector('#content').style.background = 'transparent'; } } }); // document.onclick = function(event) { window.onclick = function(event) { /* if () { alert(event.target.tagName + ':' + event.currentTarget.tagName); // + ':' + event.tElement.tagName); } */ if (event.target.tagName == 'A') { if (event.target.hash) { window.location = window.location.pathname + event.target.hash; //event.preventDefault(); // alert('Detta är en hashtag'); } else if (event.target.classList.contains('toggle')) { // alert('Expandera'); toggle(event.target); } else if (event.target.hasAttribute('href') && event.target.getAttribute('href').length == 0) { event.preventDefault(); if (confirm('"' + event.target.innerText + '" verkar sakna webbadress 😟 Vill du söka på det istället?')) { if (document.body.classList.contains('admin')) { window.location = '//google.com/search?q=' + encodeURIComponent(event.target.innerText); } else { window.location = '/search/?q=' + encodeURIComponent(event.target.innerText); } } } else { if (!navigator.onLine) { event.preventDefault(); // Du har förlorat internet ✈️ // Du har tappat din internet-anslutning if (confirm('Det går inte att gå till sidor utan att vara ansluten till internet 🌐 Vill du att jag ska fråga om du vill gå till sidan "' + event.target.innerText + '" när du är ansluten till internet igen?')) { alert('OK'); window.onlinelink = { 'href': event.target.innerText, 'text': event.target.getAttribute('href') } } } else if (event.target.href.indexOf('.wikipedia.') != -1) { // alert('Redirecting to Wikipedia: ' + event.target.href.indexOf('wikipedia')); event.preventDefault(); answer = confirm('Gå till mobil webbplats av Wikipedia för sidan "' + decodeURI(event.target.href).replace(/.*wikipedia\.org\/wiki\//i, '').replace(/_/g, ' ') + '"? 📱'); if (answer) { // https://en.m.wikipedia.org/wiki/Semigraphics //alert('Går till mobil webbplats: ' + event.target.href.replace(/(\w{2})\.wikipedia\.org/i, '$1.m.wikipedia.org')); window.location = event.target.href.replace(/(\w{2})\.wikipedia\.org/i, '$1.m.wikipedia.org'); } else { //alert('Går till vanlig webbplats: ' + event.target.href.replace(/m\.wikipedia\.org/i, 'wikipedia.org')); window.location = event.target.href.replace(/m\.wikipedia\.org/i, 'wikipedia.org'); } } else if (event.target.closest('a').classList.contains('clipboard')) { closeA = event.target.closest('a'); // alert(event.target.parentNode.innerHTML.replace(/(<.+?>)/gi, '')); // // alert(event.target.tagName + ':' + event.target.closest('a').tagName); copyText = closeA.previousElementSibling.hasAttribute('data-copy') ? closeA.previousElementSibling.dataset.copy : (closeA.previousElementSibling.previousElementSibling && closeA.previousElementSibling.previousElementSibling.tagName == 'H2' ? closeA.previousElementSibling.previousElementSibling.innerText : (closeA.previousElementSibling.previousSibling && closeA.parentElement.firstChild.nodeType != Node.TEXT_NODE ? 'Kod för ikonen "' + closeA.previousElementSibling.previousSibling.textContent + '"' : null)); copy(closeA.previousElementSibling.innerText, (copyText ? copyText : '')); // } else { // alert(event.target.tagName); // alert(event.target.classList.contains('toggle') ? 'Toggla' : 'Inte toggle: ' + event.target.classList); } } // event.target.parentNode.previousElementSibling.tagName == 'H2' && } else if (0) { //event.target?.parentNode?.previousElementSibling.tagName == 'H2' && event.target?.parentNode.tagName == 'UL' && event.target?.parentNode.contains(event.target?.parentNode.querySelector('time'))) { alert('Snart kommer du få mer information om filmer som du trycker på 🎬\n\n' + event.target.innerText.split('(')[0] + '\n\n' + (event.target.parentNode.querySelector('time').innerText ? 'Filmen kom år ' + event.target.parentNode.querySelector('time').innerText : 'Vet inte vilket år filmen kom') + '\n\nDen verkar vara på ' + (event.target.parentNode.contains(event.target.querySelector('dfn')) ? langCodes[event.target.parentNode.querySelector('dfn').getAttribute('lang')] : 'svenska')); } else if (event.target.tagName == 'ABBR') { event.stopImmediatePropagation(); event.preventDefault(); if (event.target.getAttribute('title')) { //alert(event.target.getAttribute('title')); // https://stackoverflow.com/questions/29223502/how-to-get-href-of-anchor-when-the-event-target-is-htmlimageelement /* event = event || window.event; var target = event.target || event.srcElement; while (target) { if (target instanceof HTMLAnchorElement) { console.log(target.getAttribute('href')); break; } target = target.parentNode; */ if (confirm('Vill du gå till "' + event.target.innerHTML + '"? Det betyder "' + event.target.getAttribute('title') + '"?')) { link = event.target.closest('a'); if (link) { window.location = link.getAttribute('href'); } else { alert('Det finns ingen länk att gå till'); } } /*}*/ } else { xhr = new XMLHttpRequest(); xhr.onloadend = function() { if (xhr.status == 200) { alert((event.target.getAttribute('title') == '' ? 'Jag är inte helt säker på vad "' + event.target.innerText + '" betyder, men jag tror att det står för ' : (event.target.innerText + (JSON.parse(xhr.response).total.hits > 1 ? ' kan betyda lite olika saker' : ' betyder'))) + '\n\n• ' + JSON.parse(xhr.response).hits.join('\n• ') + '\n\nJag kan ' + (JSON.parse(xhr.response).total.number-1) + ' fler förkortningar'); } else { alert('Jag vet inte vad ' + event.target.innerText + ' är förkortning för 😳' + '\n\nVi har ' + (JSON.parse(xhr.response).total.number-1) + ' andra förkortningar'); } } xhr.open('GET', 'https://api.omnum.se/abbr/?q=' + event.target.innerText); xhr.send(); } } if (event.target.classList.contains('blur') || event.target.classList.contains('unblur')) { event.target.classList.toggle('blur'); event.target.classList.toggle('unblur'); if (event.target.tagName == 'A') { event.stopPropagation(); if (confirm('Vill du följa länken?')) { window.location = event.target.getAttribute('href'); } // // return false; } } if (event.target?.parentNode?.parentNode.classList.contains('current')) { event.target.parentNode.parentNode.querySelectorAll('a').forEach(function(el) { el.classList.remove('current'); }); event.target.classList.add('current'); } if (document.getElementById('instant-search')) { if (!document.getElementById('topmenu').contains(document.activeElement)) { document.getElementById('instant-search').style.display = 'none'; } } } /* function printa() { if (window.print) { window.print(); } else { alert('Stöd för att skriva ut saknas i din webbläsare'); } } */ function notify() { // notifyMe() // Let's check if the browser supports notifications if (!('Notification' in window)) { alert('Stöd för notifikationer saknas i din webbläsare'); // This browser does not support desktop notification } // Let's check whether notification permissions have already been granted else if (Notification.permission === 'granted') { // If it's okay let's create a notification var notification = new Notification('Omnification', { body: 'This is a link to the latest page', icon: '/img/avatar/admin.jpg' }); notification.onclick = function() { window.open('/latest/', '_blank'); } } // Otherwise, we need to ask the user for permission else if (Notification.permission !== 'denied') { Notification.requestPermission(function (permission) { // If the user accepts, let's create a notification if (permission === 'granted') { var notification = new Notification('Omnification', { body: 'This is a link to the latest page', icon: 'http:///omnum.se/img/avatar/admin.jpg' }); notification.onclick = function() { window.open('/latest/', '_blank'); } } else { alert(permission); } }); } // At last, if the user has denied notifications, and you // want to be respectful there is no need to bother them any more. } // http://stackoverflow.com/questions/5045053/set-cookie-wih-js-read-with-php-problem // document.cookie = 'ppkcookie1=testcookie; expires=Thu, 2 Aug 2001 20:47:11 UTC; path=/; ;domain=.example.com' function createCookie(name, value, minutes) { if (minutes) { var date = new Date(); date.setTime(date.getTime()+(minutes*60*1000)); var expires = '; expires=' + date.toGMTString(); } else { var expires = ''; } document.cookie = name + '=' + value + expires + '; path=/;'; } /* options = { enableHighAccuracy: true, timeout: 10000, maximumAge: 0 }; // Register for location changes var watchId = navigator.geolocation.watchPosition(scrollMap, handleError, options); // The error callback should take a PositionError object as the parameter as in: function handleError(error) { // Update a div element with the error message document.getElementById('errorlatlng').innerHTML = (error.code + ":" + error.message + "(" + JSON.stringify(error) + ")") + '

'; } function scrollMap(position) { // Scroll the map to center position //alert(JSON.stringify(position)); latitude = position.coords.latitude; longitude = position.coords.longitude; if (document.getElementById('latlng')) { document.getElementById('errorlatlng').innerHTML = ""; document.getElementById('latlng').innerHTML = ("latitude: " + latitude + "
longitude: " + longitude); } } */ // Renamed "functionalService" 2024-01-24 function locator() { if (navigator.cookieEnabled) { getLocation(); } else { document.getElementById('location-status').innerHTML = 'Du har valt att inte använda kakor 🍪 Vi använder det för att kunna hämta din nuvarande plats'; //console.log(error); locationButtonIcon = document.querySelector('#location-wrapper .button i'); document.querySelector('#location-wrapper .button').text = 'Försök igen'; document.querySelector('#location-wrapper .button').prepend(locationButtonIcon); locationButtonIcon.classList.remove('fa-map-marker'); locationButtonIcon.classList.add('fa-refresh'); locationButtonIcon.classList.remove('fa-spin'); document.querySelector('#location-wrapper .button').addEventListener('click', function() {locationButtonIcon.classList.add('fa-spin')}); } } function getLocation() { options = { enableHighAccuracy: true, maximumAge: 30000 } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, notShowPosition, options); } else { alert('Stöd för geolocation saknas i din webbläsare'); // Geolocation is not supported by this browser } } function notShowPosition(error) { if (document.getElementById('location-header')) { document.getElementById('location-header').innerHTML = 'Du har valt att inte dela din plats 🫢'; document.getElementById('location-p').innerHTML = '

Vi använder plats-information för att visa platser i närheten som kan vara intressanta för dig. Vänta en liten stund och försök igen, du kan även prova att ladda om sidan.

' + '' + `${error.code}: ${error.message}` + '.'; //console.log(error); locationButtonIcon = document.querySelector('#location-wrapper .button i'); document.querySelector('#location-wrapper .button').text = 'Försök igen'; document.querySelector('#location-wrapper .button').prepend(locationButtonIcon); locationButtonIcon.classList.remove('fa-map-marker'); locationButtonIcon.classList.add('fa-refresh'); locationButtonIcon.classList.remove('fa-spin'); document.querySelector('#location-wrapper .button').addEventListener('click', function() {locationButtonIcon.classList.add('fa-spin')}); hungryPeopleWaited = 0; hungryAndStillWaiting = setInterval(function() { hungryPeopleWaited++; if (hungryPeopleWaited == 30) { document.getElementById('location-header').innerHTML = 'Visste du att du även kan söka på den typ av mat eller en restaurang som du letar efter? 😉'; //console.log('hungryPeopleWaited',hungryPeopleWaited); clearTimeout(hungryAndStillWaiting); } }, 1000); } } function showPosition(positions) { hungryPeopleWaited = 0; hungryAndStillWaiting = setInterval(function() { hungryPeopleWaited++; if (hungryPeopleWaited == 5) { document.getElementById('location-header').innerHTML = 'Visste du att du även kan söka på den typ av mat eller en restaurang som du letar efter? 😉'; console.log('hungryPeopleWaited',hungryPeopleWaited); clearTimeout(hungryAndStillWaiting); } }, 1000); //x.innerHTML="Latitude: " + position.coords.latitude + "
Longitude: " + position.coords.longitude; //window.location.href = '/places/?ll=' + position.coords.latitude + ',' + position.coords.longitude; //localStorage.setItem('ll', position.coords.latitude + ',' + position.coords.longitude); // localStorage.getItem //document.cookie = 'll' + '=' + position.coords.latitude + ',' + position.coords.longitude + '; path=/;'; console.log('position', positions); createCookie('ll', positions.coords.latitude + ',' + positions.coords.longitude, 3); if (document.getElementById('location-header')) { document.getElementById('location-header').innerHTML = 'Vänta lite…'; //document.getElementById('location-status-text').innerHTML = 'Vi håller på att räkna ut vilka platser som är närmast just dig 😍'; document.querySelector('.fa-circle').style.color = 'var(--slack-white)'; document.querySelector('.fa-exclamation-triangle').style.color = 'rgba(0,0,0,0.45)'; document.querySelector('.fa-exclamation-triangle').style.lineHeight = 1; document.querySelector('.fa-exclamation-triangle').style.margin = 'auto'; document.querySelector('.fa-exclamation-triangle').style.top = 0; document.querySelector('.fa-exclamation-triangle').style.bottom = 0; document.querySelector('.fa-exclamation-triangle').classList.add('fa-spinner'); document.querySelector('.fa-exclamation-triangle').classList.add('fa-pulse'); // previously fa-spin document.querySelector('.fa-exclamation-triangle').classList.remove('fa-exclamation-triangle'); //document.getElementById('geolocation-alt').remove(); } window.location.reload(); } window.addEventListener('message', receiveMessage, false); function receiveMessage(event) { if (event.origin == 'https://sökmotorm.se' || event.origin == 'https://xn--skmotorn-n4a.se' || event.origin == 'https://omnum.se' || event.origin == 'https://omnum-se.loopiasecure.com' || event.origin == 'https://igbg.se' || event.origin == 'https://isthlm.se') { jsonMessage = JSON.parse(event.data); showPosition(jsonMessage); } } function begynnelseNolla(tid) { return tid.toString().slice(-2).length == 2 ? tid.toString().slice(-2) : '0' + tid.toString().slice(-2); } window.addEventListener('appearance-changed', function(e) { switch (window.appearance) { case 'light': { alert('Light'); } break; case 'dark': { alert('Dark'); } break; } }); window.onbeforeunload = function(event) { if (navigator.onLine == 'offline') { alert('Du har inget nät'); event.preventDefault(); } else { alert('Du har nät'); } } /* 2024-01-30 window.addEventListener('load', function() { */ document.addEventListener('DOMContentLoaded', function() { styleForInstantSearch = document.createElement('link'); styleForInstantSearch.setAttribute('rel', 'stylesheet'); styleForInstantSearch.setAttribute('href', '/style/search.css'); document.getElementsByTagName('head')[0].appendChild(styleForInstantSearch); /* 2024-01-15 */ if (document.body.classList.contains('admin') && document.querySelector('#content > img:first-of-type')) { // alert(document.querySelector('#content > img:first-of-type')); document.querySelector('#content > img:first-of-type').onload = function() { // alert('Laddar in "' + this.getAttribute('alt') + '" (' + this.tagName + ')'); } document.querySelector('#content > img:first-of-type').onerror = function() { if (confirm('"' + this.getAttribute('alt') + '" kunde inte laddas in. Vill du bild-söka på det?')) { window.location = '//google.com/search?q=' + encodeURIComponent(this.getAttribute('alt')) + '&tbm=isch'; } // alert('"' + this.getAttribute('alt') + '" kunde dessvärre inte laddas in (' + this.tagName + ')'); } document.querySelector('#content > img:first-of-type').onsuccess = function() { alert('"' + this.getAttribute('alt') + '" kunde laddas in (' + this.tagName + ')'); } } /* 2024-01-15 */ document.getElementById('search-form').onsubmit = function(event) { /* 2024-04-15 */ if ('?q=' + encodeURIComponent(document.querySelector('[type="search"]').value) == window.location.search) { event.preventDefault(); alert('Du har redan sökt på detta. Ändra i sök-fältet om du vill utföra en ny sökning.'); } if (!navigator.onLine) { event.preventDefault(); alert(event.target.innerText); formData = new FormData(document.getElementById('search-form')); formParams = new URLSearchParams(formData); formQuery = formParams.toString(); //alert('Försöker gå till "' + document.getElementById('search-form').getAttribute('action') + '?' + formQuery) + '"'; if (confirm('Det går inte att söka utan att vara ansluten till internet 🌐 Vill du att jag ska fråga om du vill söka på "' + document.getElementById('search-text').value + '" när du är ansluten till internet igen?')) { alert('OK'); window.onlinelink = { 'href': document.getElementById('search-form').getAttribute('action') + '?' + formQuery, 'text': document.getElementById('search-text').value } } } else { if (!document.getElementById('search-text').value) { event.preventDefault(); if (document.forms[1].id == 'save' || document.forms[1].id == 'edit') { document.forms[1].submit(); // Det ska gå att använda .requestSubmit() istället 2024-01-29 } else { alert('Det går att söka på nästan allt. Testa att skriva något! 😉'); // Det går inte att göra en tom sökning 😱' } } } } document.getElementById('column-layout').onsubmit = function(event) { if (!document.querySelector('[name=user]').value) { event.preventDefault(); alert('Information om användar-namn eller mail-adress saknas'); } } /* 2024-01-15 */ if (document.querySelector('.horizontal-menu ul')) { document.querySelector('.horizontal-menu ul').style.width = ([...document.querySelector('.horizontal-menu ul').children].reduce((total, index) => total + parseInt(window.getComputedStyle(index).width), 0) + 14) + 'px'; window.onresize = function() { document.querySelector('.horizontal-menu ul').style.width = ([...document.querySelector('.horizontal-menu ul').children].reduce((total, index) => total + parseInt(window.getComputedStyle(index).width), 0) + 14) + 'px'; } } if (document.contains(document.getElementById('tecken'))) { document.querySelector('[name=content]').oninput = function() { document.getElementById('tecken').innerHTML = document.querySelector('[name=content]').value.length; // document.querySelector('[name=content]').value.length; document.getElementById('rader').innerHTML = document.querySelector('[name=content]').value.match(/\n/g).length; } } var status = document.getElementById('flightmode'); status.innerHTML = '✈️Utan internet'; function updateOnlineStatus(event) { if (navigator.onLine == 'offline') { status.style.display = 'block'; document.body.classList.add('aeroplane-mode'); window.datum = new Date(); if (document.getElementById('no-internet-since')) { var noInternetSince = document.getElementById("no-internet-since"); } else { noInternetSince = document.createElement('span'); noInternetSince.id = 'no-internet-since'; document.getElementById("flightmode").append(noInternetSince); } noInternetSince.innerHTML = ' sedan '; window.noInternet = setInterval(function() { hours = Math.floor((new Date().getTime() - datum.getTime()) / 1000 / 60 / 60); minutes = Math.floor((new Date().getTime() - datum.getTime()) / 1000 / 60) - hours*60*60; seconds = Math.floor((new Date().getTime() - datum.getTime()) / 1000) - hours*60*60 - minutes*60; document.getElementById('duration-without-internet').innerHTML = ' ()'; }, 1000); } else { clearInterval(window.noInternet); status.style.display = 'none'; document.body.classList.remove('aeroplane-mode'); } //console.log("Event: " + event.type + "; Status: " + navigator.onLine); } window.addEventListener('online', updateOnlineStatus); window.addEventListener('offline', updateOnlineStatus); document.addEventListener('keydown', function(event) { if (event.keyCode == 9) { moveToActive = 1; } }); document.addEventListener('focusin', function() { if (typeof moveToActive !== 'undefined') { if (!topmenu.contains(document.activeElement)) { if (document.activeElement.previousElementSibling && document.activeElement.previousElementSibling.previousElementSibling && document.activeElement.previousElementSibling.previousElementSibling.tagName == 'H2') { window.scrollTo(0, window.scrollY + document.activeElement.previousElementSibling.previousElementSibling.getBoundingClientRect().top - parseInt(window.getComputedStyle(topmenu).height) - 4); } else if (document.activeElement.previousElementSibling && document.activeElement.previousElementSibling.tagName == 'H2') { window.scrollTo(0, window.scrollY + document.activeElement.previousElementSibling.getBoundingClientRect().top - parseInt(window.getComputedStyle(topmenu).height) - 4); } else { window.scrollTo(0, window.scrollY + document.activeElement.getBoundingClientRect().top - parseInt(window.getComputedStyle(topmenu).height) - 4); } } } delete(moveToActive); if (document.getElementById('instant-search')) { if (!document.getElementById('topmenu').contains(document.activeElement)) { document.getElementById('instant-search').style.display = 'none'; } } }); /* 2024-01-05 document.body.firstChild.id.indexOf('google') > 0 || "undefined is not an object (evaluating 'document.body.firstChild.id.indexOf')" */ if (window.location.host === 'webcache.googleusercontent.com') { document.body.classList.add('cache'); document.getElementById('topmenu').style.position = 'sticky'; document.getElementById('wrapper').style.marginTop = 0; alert(document.body.firstChild.firstChild.innerHTML.match(/\d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2}( GMT)?/)[0]); } if (document.body.classList.contains('admin')) { experimental = 0; [...document.querySelector('.experimental ul').children].forEach(function(el) { experimental += parseInt(window.getComputedStyle(el).width) + 1; }); document.querySelector('.experimental ul').style.width = experimental + 'px'; } }); window.onresize = function() { if (document.body.classList.contains('admin')) { experimental = 0; [...document.querySelector('.experimental ul').children].forEach(function(el) { experimental += parseInt(window.getComputedStyle(el).width) + 1; }); document.querySelector('.experimental ul').style.width = experimental + 'px'; } } setInterval(function() { //document.getElementById('p-wrapper').childNodes.forEach(function(el) { document.querySelectorAll('progress, .indicator, ul#cardline > li, ul#usp-big > li, ul#usp > li, ul.bigger li').forEach(function(el) { //if (window.pageYOffset <= el.getBoundingClientRect().top && el.getBoundingClientRect().top < (window.pageYOffset + window.innerHeight*1)) { if (el.getBoundingClientRect().top > -1 && el.getBoundingClientRect().top <= window.innerHeight || el.getBoundingClientRect().top + el.clientHeight > -1 && el.getBoundingClientRect().top + el.clientHeight <= window.innerHeight) { if (!el.classList.contains('inview')) { el.classList.add('inview'); } } else { el.classList.remove('inview'); } //console.log('TOPP: ' + window.pageYOffset + '\nELEM: ' + el.getBoundingClientRect().top + '\nBOTTOM: ' + (window.pageYOffset + window.innerHeight*1)) }); }, 1000); if (document.contains(document.getElementById("uploadBtn"))) { /* document.getElementById("uploadBtn").onchange = function () { document.getElementById("uploadFile").value = this.value; } */ document.querySelector('input[type="file"]').addEventListener('change', function(e) { document.getElementById('file-path').value = e.target.value.split( '\\' ).pop(); }); } function openWndCentered(newURL, newName, width, height, scroll, resize) { var winl = (screen.width - width) / 2; var wint = (screen.height - height) / 2; winprops = 'height=' + height + ',width=' + width + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable=' + resize; var win = window.open(newURL, newName, winprops); if (win) win.focus(); }