Last active
August 29, 2015 13:56
-
-
Save sinky/9246518 to your computer and use it in GitHub Desktop.
The way i load JS on my my-azur.de/blog/ (used in: https://my-azur.de/blog/javascript-hier-im-blog/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pfad zum Wordpress Theme | |
var stylesheet_directory = "//my-azur.de/blog/wp-content/themes/azur"; | |
// Existiert auf dieser Seite die gewünschte Tabelle | |
if($('.cinematiclist').length) { | |
// dann lade Script und führe Funktion aus | |
loadScript(stylesheet_directory+"/lib/jquery.tablePagination.js", function() { | |
$('.cinematiclist').tablePagination(); | |
}); | |
} | |
function loadScript(src, callback, errorcallback) { | |
var script = document.createElement('script'), | |
loaded, | |
timer; | |
script.setAttribute('src', src); | |
script.onreadystatechange = script.onload = function() { | |
if (!loaded) { | |
if (callback) { | |
callback(); | |
} | |
} | |
loaded = true; | |
clearTimeout(timer); | |
}; | |
script.onerror = function(){ | |
if(errorcallback){ errorcallback(); clearTimeout(timer); } | |
}; | |
// 30 seconds timeout... | |
timer = setTimeout(function(){ | |
if(errorcallback){ errorcallback(); } | |
},30000); | |
document.getElementsByTagName('head')[0].appendChild(script); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment