/*!* * @filename include.jquery.js * @name jQuery Include File * @type jQuery * @projectDescription Include a file (css and js) in a head of the document and execute * @date 08/07/2008 * @version 1.0 * @cat Ajax * @require * @author Alex * @param required none url String|Array The address of the plugin that will be inserted. * You can pass a indexed array of url * @param optional none callback Function The function to be executed after the file has loaded * @example * $.include('/foo/test/file.js'); * @desc load the current script * @example * var files = ['test.js','another.js','onemore.js']; * $.include(files,function(){ * //execute some code after all scripts are completed * }); * @desc load all the script inside the array * @return false | Element (object) */ (function($) { $.extend({ // You can change the base path to be applied in all imports ImportBasePath: '', // Associative array storing wating tasks and their callback __WaitingTasks: new Object(), // Called when a single file is loaded successfully - update and check WaitingTasks to see if it's ok to load callback __loadedSuccessfully: function(taskId){ if (taskId in $.__WaitingTasks){ if (($.__WaitingTasks[taskId].loading -= 1) < 1){ var callback = $.__WaitingTasks[taskId].task; if (typeof callback == 'function') { callback(); } delete $.__WaitingTasks[taskId]; } } }, //pass a file name and return a array with file name and extension fileinfo: function(data){ data = data.replace(/^\s|\s$/g, ""); var m; if (/\.\w+$/.test(data)) { m = data.match(/([^\/\\]+)\.(\w+)$/); if (m) { if (m[2] == 'js') { return { filename: m[1], ext: m[2], tag: 'script' }; } else if (m[2] == 'css') { return { filename: m[1], ext: m[2], tag: 'link' }; } else { return { filename: m[1], ext: m[2], tag: null }; } } else { return { filename: null, ext: null }; } } else { m = data.match(/([^\/\\]+)$/); if (m) { return { filename: m[1], ext: null, tag: null }; } else { return { filename: null, ext: null, tag: null }; } } }, //Check if the file that is been included already exist and return a Boolean value fileExist: function(filename,filetype,attrCheck) { var elementsArray = document.getElementsByTagName(filetype); for(var i=0;i