/
modSDR.js
158 lines (123 loc) · 4.98 KB
/
modSDR.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
var currentVersion = ".009 Experimental";
console.log(currentVersion);
function loadfile(filename, filetype){
if (filetype=="js"){ //if filename is a external JavaScript file
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if (filetype=="css"){ //if filename is an external CSS file
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
console.log("loading file " + filename + " of type " + filetype);
console.log("fileref exists? " + fileref);
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
}
loadfile("//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js", "js");
loadfile('https://raw2.github.com/foo-/UTwente-Usability/master/events.js', "js");
loadfile('//code.jquery.com/jquery-1.10.2.js', "js");
loadfile('//code.jquery.com/ui/1.10.4/jquery-ui.js', "js");
loadfile('//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css', "css");
function whenAvailable(name, callback) {
var interval = 10; // ms
window.setTimeout(function() {
if (window[name]) {
callback(window[name]);
} else {
window.setTimeout(arguments.callee, interval);
}
}, interval);
}
function whenJQueryUIAvailable(callback) {
var interval = 10; // ms
window.setTimeout(function() {
if (jQuery.ui) {
callback(window[name]);
} else {
window.setTimeout(arguments.callee, interval);
}
}, interval);
}
whenAvailable("jQuery", function(t){
// Hide Logbook
jQuery("div.ctl").eq(7).hide()
jQuery("div.ctl").eq(8).hide()
//Move saved frequencies if there is enough vertical space
if(window.screen.availWidth >= 1600)
{
jQuery("form[name='freqform']").appendTo("#test");
jQuery("form[name='freqform']").css({"left":"1050px","position":"absolute"});
jQuery("form[name='freqform']").appendTo("#test");
//jQuery("div.ctl").eq(2).appendTo("#test")
//jQuery("div.ctl").eq(2).removeAttr("style")
//jQuery("div.ctl").eq(2).css({"left":"1050px","position":"absolute"});
jQuery("#wfcdiv0").css({"width":"1050px"});
}
// Move the user frequency control to the bottom
jQuery("form[name='form1']").insertAfter("#chatboxspan");
jQuery("p").hide();
// Add new irc chatbox & hide existing nonfunctional chatbox
if(!jQuery.ui){
loadfile('//code.jquery.com/ui/1.10.4/jquery-ui.js', "js");
loadfile('//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css', "css");
}
whenJQueryUIAvailable( function(t){
console.log('Waiting for jQueryUI. Loaded? ' + jQuery.ui);
var ircPanel = jQuery('<div id="collapse"><h3>IRC Chat</h3><div><iframe id="chatframe" width="99%" height="250" src ="http://webchat.freenode.net/?channels=#INSMA" /></div></div>')
ircPanel.insertBefore("form[name='form1']");
jQuery("#collapse").accordion({
collapsible: true,
active: false
});
jQuery("div.ctl").draggable();
//jQuery("#collapse").draggable();
jQuery(".ui-accordion-content").css("padding","0px");
jQuery("#collapse").accordion({active: 0});
jQuery("#time").insertBefore("#collapse");
});
console.log('jQuery.ui loaded? ' + jQuery.ui);
//jQuery('<iframe id="chatframe" width="100%" height="250"/>').attr('src', 'http://webchat.freenode.net/?channels=#INSMA').insertBefore("form[name='form1']");
jQuery('#chatboxspan').hide();
//jQuery('<iframe id="chatframe" width="550" height="350" scrolling="no" />').attr('src', 'http://widget00.mibbit.com/?&server=irc.Mibbit.Net&channel=%23bung_test').appendTo('body');
jQuery(document).ready(function() {
setcompactview(true);
jQuery("#compactviewcheckbox").prop('checked', true);
jQuery("hr").hide();
});
whenAvailable("parseEvents", function(t){
// Get ENIGMA calendar events
var events = parseEvents();
// Add UTC time above chatbox
jQuery("<DIV id=time>TIME</div>").insertBefore("#collapse")
//jQuery("#chatboxspan").prepend("<DIV id=time>TIME</div>");
setInterval(function(){jQuery("#time").html(new Date().toUTCString() + " Next Event: " + getNextEvent(events))},1000);
});
});
// Hijack chatbox
/*
function hijack(method, cb){
// A function needs to be passed or there will be hell to pay
if(Object.prototype.toString.call(cb) !== "[object Function]"){
throw new Error('An anonymous function must be passed as the second parameter!');
}
return function(){
// Turn arguments into a true array
var args = Array.prototype.slice.call(arguments);
// Call the copied method and pass it some 'tampered' arguments from our callback
return method.apply(this, cb.call(this, args) || args);
};
}
chatnewline = hijack(chatnewline , function(user_args){
// Now store the arguments passed in by the user
var args = user_args;
// Mess with the arguments passed in
//if(args[0]){args[0] = 'TEST:' + args[0]};
// Put some stuff in here to update our new chatbox
// Return the args that we may have messed with
return args;
});
*/