-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSB.js
75 lines (66 loc) · 2.27 KB
/
SB.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Load script function needed to make sure that script is loaded before execute the code
function loadScript(url, callback){
var script = document.createElement("script");
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
callback();
}
};
} else { //Others
script.onload = function(){
callback();
};
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
loadScript('https://code.jquery.com/jquery-2.2.4.min.js', function(){
$.extend({
getManyCss: function(urls, callback, nocache){
if (typeof nocache=='undefined') nocache=false; // default don't refresh
$.when(
$.each(urls, function(i, url){
if (nocache) url += '?_ts=' + new Date().getTime(); // refresh?
$.get(url, function(){
$('<link>', {rel:'stylesheet', type:'text/css', 'href':url}).appendTo('head');
});
})
).then(function(){
if (typeof callback=='function') callback();
});
},
});
$.getMultiScripts = function(arr, path) {
var _arr = $.map(arr, function(scr) {
return $.getScript( (path||"") + scr );
});
_arr.push($.Deferred(function( deferred ){
$( deferred.resolve );
}));
return $.when.apply($, _arr);
}
var cssfiles=[
'https://aliyusuf95.github.io/UOB-Schedule-Organizer/sweetalert.css'
];
var scriptfiles = [
'https://aliyusuf95.github.io/UOB-Schedule-Organizer/sweetalert.min.js'
];
$.getMultiScripts(scriptfiles, '').done(function() {
console.log('all js loaded');
$.getManyCss(cssfiles, function(){
console.log('all css loaded');
ScheduleBuilder();
});
});
});
function ScheduleBuilder (){
swal({
title: "HTML <small>Title</small>!",
text: "A custom <span style='color:#F8BB86'>html<span> message.",
html: true
});
}