-
-
Save yanivkalfa/b443582b1ced537b7612 to your computer and use it in GitHub Desktop.
Just a part of my bookmarklet
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
/* creating loading and appending include files for the bookmarklet*/ | |
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) { | |
var done = false; | |
var jquery_load = document.createElement("script"); | |
jquery_load.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js"; | |
jquery_load.setAttribute('id', 'yk_bookmarklet_jquery'); | |
jquery_load.onload = jquery_load.onreadystatechange = function(){ | |
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { | |
loaded_headers++; | |
console.log("Next1"); // <-- is being printed to console | |
if(loaded_headers >= total_headers){ | |
done = true; | |
$.getJSON("xxxx", | |
function(data){ | |
/* more variables*/ | |
window.mbm = false; | |
initMyBookmarklet(); // function that has the bookmarklet info. | |
}); | |
} | |
} | |
}; | |
var CssScript = document.createElement("link"); | |
CssScript.href = "http://www.shopsavr.com/css/yk_bookmarklet.css"; | |
CssScript.setAttribute('type', 'text/css'); | |
CssScript.setAttribute('rel', 'stylesheet'); | |
CssScript.setAttribute('media', 'all'); | |
CssScript.setAttribute('id', 'yk_bookmarklet_css'); | |
CssScript.onload = CssScript.onreadystatechange = function(){ | |
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { | |
loaded_headers++; | |
console.log('Next2');// <-- DOES NOT print to console | |
if(loaded_headers >= total_headers){ | |
done = true; | |
$.getJSON("xxxx", | |
function(data){ | |
/* more variables*/ | |
window.mbm = false; | |
initMyBookmarklet(); // function that has the bookmarklet info. | |
}); | |
} | |
} | |
}; | |
/*appending the created elements*/ | |
document.getElementsByTagName("head")[0].appendChild(jquery_load); | |
document.getElementsByTagName("head")[0].appendChild(yk_bookmarklet); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment