Created
December 4, 2013 12:47
-
-
Save GreatPotato/7786948 to your computer and use it in GitHub Desktop.
Deploys and ebook into your page
This file contains hidden or 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
| var ebook_deploy = { | |
| _cdn: '/', | |
| _container: 'ebook', | |
| _head: document.getElementsByTagName('head')[0], | |
| _host: (("https:" == document.location.protocol) ? "https:" : "http:"), | |
| init: function(container, cdn) { | |
| var self = this; | |
| self._cdn = cdn; | |
| self._container = container; | |
| if (typeof jQuery == 'undefined') { | |
| var scripts = new Array({ | |
| src: this._host + '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' | |
| }) | |
| this.load_scripts(scripts); | |
| } | |
| var jquery_loaded = function() { | |
| if(typeof jQuery !== "undefined"){ | |
| clearTimeout(interval); | |
| self.jquery_ready(container); | |
| } | |
| } | |
| var interval = setInterval(jquery_loaded,1000); | |
| }, | |
| jquery_ready: function() { | |
| var self = this; | |
| $( document ).ready(function() { | |
| var scripts = new Array( | |
| { | |
| src: self._cdn + 'plugins.min.js' | |
| }, | |
| { | |
| src: self._cdn + 'script.min.js' | |
| } | |
| ) | |
| var stylesheets = new Array( | |
| { | |
| href: self._cdn + 'style.css' | |
| } | |
| ) | |
| self.load_scripts(scripts); | |
| self.load_stylesheets(stylesheets); | |
| self.insert_content(); | |
| }); | |
| }, | |
| load_scripts: function(scripts) { | |
| for(var i = 0; i < scripts.length; i++) { | |
| scripts[i].script = document.createElement('script'); | |
| scripts[i].script.src = scripts[i].src; | |
| scripts[i].script.type = 'text/javascript'; | |
| scripts[i].script.onload = scripts[i].script.onreadystatechange = function() { | |
| //if ((!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { | |
| //}; | |
| }; | |
| this._head.appendChild(scripts[i].script); | |
| } | |
| }, | |
| load_stylesheets: function(stylesheets) { | |
| for(var i = 0; i < stylesheets.length; i++) { | |
| stylesheets[i].link = document.createElement('link'); | |
| stylesheets[i].link.href = stylesheets[i].href; | |
| stylesheets[i].link.type = 'text/css'; | |
| stylesheets[i].link.rel = 'stylesheet'; | |
| stylesheets[i].link.onload = stylesheets[i].link.onreadystatechange = function() { | |
| //if ((!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { | |
| //}; | |
| }; | |
| this._head.appendChild(stylesheets[i].link); | |
| } | |
| }, | |
| insert_content: function(container) { | |
| var self = this; | |
| var content = " .. enter your ebook html here .. "; | |
| var container = document.getElementById(this._container); | |
| container.innerHTML = content; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment