Created
August 26, 2015 10:55
-
-
Save LeonardoCiaccio/2ad67f046aa18291e7d7 to your computer and use it in GitHub Desktop.
Load sincro scripts
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
( function( tools, libs ){ | |
// Iterator | |
var require = function( scripts, onEnd ){ | |
onEnd = onEnd || function(){}; | |
if( !scripts || scripts.length < 1 )return onEnd(); | |
var src = scripts.splice( 0, 1), | |
script = document.createElement( "script" ); | |
script.setAttribute( "src", src ); | |
tools.addEvent( "load", script, function(){ | |
require( scripts, onEnd ); | |
} ); | |
document.getElementsByTagName( "head" )[ 0 ].appendChild( script ); | |
}; | |
// Install all scripts with a copy of scripts | |
require( libs.slice(), function(){ | |
alert( "Enjoy :)" ); | |
} ); | |
// Timeout information | |
var ti = setTimeout( function(){ | |
if( !window.jQuery || !Window.jQuery.ui )alert( "Timeout !" ); | |
clearTimeout( ti ); | |
}, 5000 ); | |
} )( | |
{ // Tools | |
addEvent : function( evnt, elem, func ){ | |
try{ | |
if( elem.addEventListener ){ | |
elem.addEventListener( evnt, func, false ); | |
}else if( elem.attachEvent ){ | |
var r = elem.attachEvent( "on" + evnt, func ); | |
} | |
return true; | |
}catch( e ){ | |
return false; | |
} | |
} | |
}, | |
[ // Scripts | |
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js", | |
"https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" | |
] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment