forked from nisaacson/jquery-imacros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (25 loc) · 796 Bytes
/
index.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
module.exports = function(inputURL) {
iimPlay('CODE: CLEAR');
if ($ !== undefined) {
// jquery already loaded
return true;
}
var jqueryURL = inputURL || 'http://code.jquery.com/jquery.min.js'
var result = loadScriptAtURL(jqueryURL);
return result;
}
function loadScriptAtURL(url) {
var request = new XMLHttpRequest();
var async = false;
request.open('GET', url, async);
request.send();
// because of "false" above, will block until the request is done and status
// is available. Not recommended, however it works for simple cases.
if (request.status !== 200) {
var message = 'an error occurred while loading script at url: ' + url +', status: ' + request.status;
iimDisplay(message);
return false;
}
eval(request.response);
return true;
}