function loadjscssfile(filename,filetype){if(filetype=="js"){var fileref=document.createElement("script");fileref.setAttribute("type","text/javascript");fileref.setAttribute("src",filename)}else{if(filetype=="css"){var fileref=document.createElement("link");fileref.setAttribute("rel","stylesheet");fileref.setAttribute("type","text/css");fileref.setAttribute("href",filename)}}if(typeof fileref!="undefined"){document.getElementsByTagName("head")[0].appendChild(fileref)}};
$('span.gocal').live('click', function() {
loadjscssfile("/js/jquery.pickmeup.min.js", "js");
loadjscssfile("/css/pickmeup.min.css", "css");
$('span.gocalact').pickmeup({
flat : true
});
});
function loadComboboxPlugin() {
if(!$.fn.combobox){ // if not loaded yet
$('head').append('<link rel="stylesheet" href="/style/class/css/bootstrap-combobox-plugin.css" type="text/css" />');
$('head').append('<script src="/style/class/js/bootstrap-combobox-plugin.js" type="text/javascript"></script>');
}
$('select.combobox').combobox() // convert 'select.combobox'
}
if($('.combobox').exists()) {
loadComboboxPlugin()
}
function loadScript(src,_timeout) {
return new Promise(function(resolve, reject){
if(!src){
reject(new TypeError("filename is missing"));
return;
}
var script=document.createElement("script"),
timer,
head=document.getElementsByTagName("head")[0];
head.appendChild(script);
function leanup(){
clearTimeout(timer);
timer=null;
script.onerror=script.onreadystatechange=script.onload=null;
}
function onload(){
leanup();
if(!script.onreadystatechange||(script.readyState&&script.readyState=="complete")){
resolve(script);
}
}
script.onerror=function(error){
leanup();
head.removeChild(script);
script=null;
reject(new Error("network"));
};
if (script.onreadystatechange === undefined) {
script.onload = onload;
} else {
script.onreadystatechange = onload;
}
timer=setTimeout(script.onerror,_timeout||30000);
script.setAttribute("type", "text/javascript");
script.setAttribute("src", src);
});
}
function loadCSS(src, _timeout) {
var css = document.createElement('link'), c = 1000;
document.getElementsByTagName('head')[0].appendChild(css);
css.setAttribute("rel", "stylesheet");
css.setAttribute("type", "text/css");
return new Promise(function(resolve, reject){
var c=(_timeout||10)*100;
if(src) {
css.onerror = function (error) {
if(timer)clearInterval(timer);
timer = null;
reject(new Error("network"));
};
var sheet, cssRules, timer;
if ('sheet' in css) {
sheet = 'sheet';
cssRules = 'cssRules';
}
else {
sheet = 'styleSheet';
cssRules = 'rules';
}
timer = setInterval(function(){
try {
if (css[sheet] && css[sheet][cssRules].length) {
clearInterval(timer);
timer = null;
resolve(css);
return;
}
}catch(e){}
if(c--<0){
clearInterval(timer);
timer = null;
reject(new Error("timeout"));
}
}, 10);
css.setAttribute("href", src);
}else{
reject(new TypeError("filename is missing"));
}
});
}
loadScript("/engine/classes/js/jquery.pickmeup.min.js").then(function(){
console.log("js ready");
},function(error){
console.log(error);
})
loadCSS("/engine/classes/css/pickmeup.min.css").then(function(){
console.log("css ready");
},function(error){
console.log(error);
})