1
0
mirror of https://github.com/meineerde/holgerjust.de.git synced 2025-10-17 17:01:01 +00:00

Load javascript with domready from https://github.com/ded/domready

The library was imported (with small updates) from
d71121bf70/ready.js
This commit is contained in:
Holger Just 2017-03-09 22:17:13 +01:00
parent 14f01a1ab6
commit 66d644edd9
4 changed files with 66 additions and 32 deletions

View File

@ -1,2 +1,4 @@
#= require domready
#= require casper
#= require obfuscate

View File

@ -1,5 +1,5 @@
(function() {
(function() {
domready(function () {
document.querySelectorAll('.menu-button, .nav-cover, .nav-close').forEach(function(element) {
element.addEventListener('click', function(event) {
event.preventDefault();
@ -12,7 +12,7 @@
document.body.className = body_classes.join(' ');
});
});
})();
});
// slightly adapted from http://stackoverflow.com/a/26798337/421705
window.requestAnimFrame = (function(){
@ -74,7 +74,7 @@
tick();
}
(function() {
domready(function () {
document.querySelectorAll('.scroll-down').forEach(function(element) {
element.addEventListener('click', function(event) {
event.preventDefault();
@ -97,5 +97,5 @@
}
});
});
})();
});
})();

View File

@ -0,0 +1,30 @@
/*!
* domready (c) Dustin Diaz 2014 - License MIT
*/
!function (name, definition) {
if (typeof module != 'undefined') module.exports = definition()
else if (typeof define == 'function' && typeof define.amd == 'object') define(definition)
else this[name] = definition()
}('domready', function () {
var fns = [], listener
, doc = document
, hack = doc.documentElement.doScroll
, domContentLoaded = 'DOMContentLoaded'
, loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState)
if (!loaded)
doc.addEventListener(domContentLoaded, listener = function () {
doc.removeEventListener(domContentLoaded, listener)
loaded = 1
while (listener = fns.shift()) listener()
});
return function (fn) {
loaded ? setTimeout(fn, 0) : fns.push(fn)
}
});

View File

@ -1,33 +1,35 @@
(function() {
function decodeHTMLEntities(str) {
if(str && typeof str === 'string') {
var e = document.createElement('div');
e.innerHTML = str;
str = e.innerHTML;
e.remove();
domready(function () {
function decodeHTMLEntities(str) {
if(str && typeof str === 'string') {
var e = document.createElement('div');
e.innerHTML = str;
str = e.innerHTML;
e.remove();
}
return str;
}
return str;
}
function encodeHTMLEntities(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
}
return buf.join('');
};
function encodeHTMLEntities(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
}
return buf.join('');
};
(function() {
var elements = document.getElementsByClassName("hidden-email");
Array.prototype.forEach.call(elements, function(element){
var encoded = element.getAttribute("data-email");
var plain_encoded = decodeHTMLEntities(encoded)
var plain_decoded = plain_encoded.replace(/[!-~]/g,function(c){
return String.fromCharCode(126>=(c=c.charCodeAt(0)+47)?c:c-94);
(function() {
var elements = document.getElementsByClassName("hidden-email");
Array.prototype.forEach.call(elements, function(element){
var encoded = element.getAttribute("data-email");
var plain_encoded = decodeHTMLEntities(encoded)
var plain_decoded = plain_encoded.replace(/[!-~]/g,function(c){
return String.fromCharCode(126>=(c=c.charCodeAt(0)+47)?c:c-94);
});
var decoded = encodeHTMLEntities(plain_decoded);
var link = "<" + "a h" + "ref=\"mai" + "lto:" + decoded + "\">" + decoded + "</" + "a>";
element.innerHTML = link;
});
var decoded = encodeHTMLEntities(plain_decoded);
var link = "<" + "a h" + "ref=\"mai" + "lto:" + decoded + "\">" + decoded + "</" + "a>";
element.innerHTML = link;
});
})();
})();
});
})();