-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.js
39 lines (30 loc) · 972 Bytes
/
loader.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
jQuery(function() {
//does not need jwuery on its own
function loadPortals(username) {
//load from file -> single pattern
const loadPlainTextPortals = function(username) {
const file = "website.json";
const placeHolder = "USER";
const json = loadJSONFile(file);
for(let index=0; index<json.length; index++) {
const generalUrl = json[index]['generalUrl'];
const portalName = json[index]['portalName'];
const successCondition = json[index]['successCondition'];
const specificUrl = generalUrl.replace(placeHolder,username);
portals.push(new PlainTextPortal(specificUrl, portalName, successCondition));
}
}
//main loading
var portals = [];
//load any
loadPlainTextPortals(username);
return portals;
}
//jquery needed here
function loadJSONFile(name) {
return jQuery.getJSON(name);
}
//put function created within jquery to global namespace
window.loadspace = window.loadspace || {};
window.loadspace.loadPortals = loadPortals;
});