forked from Lundalogik/hackday-sparta-bootstrap-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (35 loc) · 1.5 KB
/
app.js
File metadata and controls
49 lines (35 loc) · 1.5 KB
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
lbs.apploader.register('sparta', function () {
var self = this;
//config
this.config = {
dataSources: [
],
resources: {
scripts: [],
styles: ['app.css'],
libs: ['json2xml.js']
}
},
//initialize
this.initialize = function (node, viewModel) {
//Use this method to setup you app.
//
//The data you requested along with activeInspector are delivered in the variable viewModel.
//You may make any modifications you please to it or replace is with a entirely new one before returning it.
//The returned viewmodel will be used to build your app.
//Get users competitions
//TODO: grab the current_user (this is hard coded to James)
getCompsURL = "https://api.spartasales.com/1/users/2/competitions/ongoing";
var result = lbs.common.executeVba('SpartaModule.GetSparta,' + getCompsURL + ',GET');
//lbs.log.info(result);
var json = JSON.parse(result);
viewModel.competitionName = json.response[0].name; //TODO: This grabs the first comp in the list - handle multiple Competitions
viewModel.compid = json.response[0].id;
//Get info about the above competition competition
getInfoAboutComp = "https//api.spartasales.com/1/competition_members/cm";
var result2 = lbs.common.executeVba('SpartaModule.GetSparta,' + getInfoAboutComp + ',GET' + json.response[0].id, '2');
lbs.log.info(result2);
//Get rank for user + competition
return viewModel;
}
});