-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
60 lines (51 loc) · 1.85 KB
/
script.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
angular.module('ionicApp', ['ionic', 'ngResource'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('eventmenu', {
url: "/event",
abstract: true,
templateUrl: "templates/event-menu.html"
})
.state('eventmenu.home', {
url: "/home",
views: {
'menuContent': {
templateUrl: "templates/home.html",
controller: "MainCtrl"
}
}
});
$urlRouterProvider.otherwise("/event/home");
})
.run(function($rootScope, $http) {
let ii=0, jj=0, newRS=0, hh=0, tS01={};
// global variables $rootScope
var tS00 = {"Team":"--", "Scores":[0,0,0,0,0,0,0,0,0], "Putts":[0,0,0,0,0,0,0,0,0] };
$rootScope.Teams = [];
// alert($rootScope.rawS.length);
$http.get('https://api.airtable.com/v0/app0hohtq4b1nM0Kb/Skins?api_key=key66fQg5IghIIQmb')
.success(function (jData) {
$rootScope.rawS = JSON.parse(JSON.stringify(jData.records));
for (ii = 0; ii < $rootScope.rawS.length; ii++) {
newRS = -1;
for (jj = 0; jj < $rootScope.Teams.length; jj++) {
if ($rootScope.Teams[jj].Team === $rootScope.rawS[ii].fields.Team) {
newRS = jj; hh = $rootScope.rawS[ii].fields.Hole - 1;
$rootScope.Teams[jj].Scores[hh] = $rootScope.rawS[ii].fields.Score;
$rootScope.Teams[jj].Putts[hh] = $rootScope.rawS[ii].fields.Putts;
}
}
if (newRS < 0) {
tS01 = JSON.parse(JSON.stringify(tS00));
tS01.Team = $rootScope.rawS[ii].fields.Team;
hh = $rootScope.rawS[ii].fields.Hole - 1;
tS01.Scores[hh] = $rootScope.rawS[ii].fields.Score;
tS01.Putts[hh] = $rootScope.rawS[ii].fields.Putts;
$rootScope.Teams.push(JSON.parse(JSON.stringify(tS01)));
}
}
});
})
.controller('MainCtrl', function($rootScope, $scope, $http) {
});
// More code goes here ...