-
Notifications
You must be signed in to change notification settings - Fork 1
/
GComp.js
61 lines (53 loc) · 1.74 KB
/
GComp.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
if (typeof(console) == 'undefined') {
console = {};
console.log = function(msg) { alert(msg) }
console.debug = function(msg) { alert(msg) }
console.warn = function(msg) { alert(msg) }
};
GComp = {
initialize: function() {
// Find base path
scriptName = 'GComp.js';
var s = (document.getElementsByTagName("script"));
for (i=0; i<s.length; i++) {
if (s[i].src && s[i].src.match(/GComp\.js/)) {
s = s[i];
break;
}
}
this.basePath = s.src.replace(/GComp\.js(\?.*)?$/,'');
this.includeCss();
this.includeScripts();
},
includeScripts: function() {
var filenames = [
'include/scriptaculous/lib/prototype.js',
'include/scriptaculous/src/scriptaculous.js',
'GBase.js',
'GChordPosition.js',
'GChord.js',
'GChordManager.js'
];
for (i=0; i < filenames.length; i++) {
document.write('<script type="text/javascript" src="' + this.basePath + filenames[i] +'"></script>');
}
},
includeCss: function() {
var filenames = [
'css/GChord.css',
'css/GChordManager.css',
];
for (i=0; i < filenames.length; i++) {
document.write('<link rel="stylesheet" type="text/css" href="' + this.basePath + filenames[i] +'" />');
}
},
// TODO: ,make this work
getTemplate: function(filename) {
var url = this.basePath + 'templates/' + filename; console.log(url);
new Ajax.Request(url);
},
injectTemplate: function(filename, domEl) {
Ajax.Updater(domEl, this.basePath + 'templates/' + filename);
}
}
GComp.initialize();