Skip to content

Instantly share code, notes, and snippets.

@micromaomao
Last active August 29, 2015 14:22
Show Gist options
  • Save micromaomao/d1bebaee2e3443550144 to your computer and use it in GitHub Desktop.
Save micromaomao/d1bebaee2e3443550144 to your computer and use it in GitHub Desktop.
loadJQueryStar
(function(){
if(!window.brainfucktapeAlertStyleLoaded){
var dcd = document.createElement('style');
dcd.innerHTML = ".dh-alert{z-index:999;box-shadow:0 0 32px rgba(0,0,0,.6),0 0 260px"+
" #000;font-size:110%;position:fixed;left:40px;right:40px;top:40%;height:auto;padding:"+
"16px;background-color:#fff;text-align:center}.dh-alert-close{font-size:80%;color:#bbb;"+
"font-weight:700;cursor:pointer;margin:2px}.dh-alert-close:hover{color:#888}"+
".dh-alert-bg{background-color:rgba(0,0,0,.1);position:fixed;top:0;right:0;bottom:0;left:0;z-index:998}";
document.body.appendChild(dcd);
window.brainfucktapeAlertStyleLoaded = true;
}
var alert = function(ale){
var dI = document.createElement('div');
dI.className = "dh-alert";
dI.textContent = ale;
var clo = document.createElement('div');
clo.className = "dh-alert-close";
clo.innerHTML = "Close";
dI.appendChild(clo);
document.body.appendChild(dI);
var dB = document.createElement('div');
dB.className = "dh-alert-bg";
document.body.appendChild(dB);
clo.addEventListener('click', function(){
dI.remove();
dB.remove();
});
};
if(window.jQuery){
alert("JQuery alerady loaded.");
return;
}
var script = document.createElement("script");
script.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.head.appendChild(script);
script.onload = function(){
alert("JQuery loaded.");
}
if(window.location == "about:blank"){
document.title = "jsBin - use F12 to play";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment