-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadCommon.js
71 lines (61 loc) · 1.63 KB
/
loadCommon.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
$(document).ready(function($){
/**
* Load html
*/
loadHTML = function(html, callback){
$("#header").load(html, callback);
}
/**
* function to load a given css file
*/
loadCSS = function(href) {
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("head").append(cssLink);
};
/**
* function to load a given js file
*/
loadScript = function(src, 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{
//other browsers
script.onload=function(){
callback();
};
}
script.src=src;
document.getElementsByTagName('head')[0].appendChild(script);
};
/**
* function to load diagram
*/
loadDiagram = function(src) {
var diagram = $('<script>require(["/scripts/' + src + '"], function () {})</script>');
$("body").append(diagram);
};
/**
* Load markdown
*/
loadMarkDown = function(mkd, callback){
$("#markdown").load(mkd, callback);
}
// load jQuery first
loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js',function(){
var filename = "d3-cheat-sheet.md"
loadMarkDown("./"+filename,function(){})
// load the css file
loadCSS("./strapdown.css",function(){})
// load the js file
loadScript("./bootstrap.min.js",function(){});
loadScript("./strapdown.js",function(){});
});
});