-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
109 lines (100 loc) · 3.6 KB
/
app.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
(function(app) {
ng.core.enableProdMode();
app.CaucusCalculator =
ng.core.Component({
selector: 'caucus-calculator',
template: '<div class="row form-group">' +
'<div class="col-sm-9">' +
'<h2>Precinct Results Calculator</h2>' +
'</div>' +
'</div>' +
'<div class="row form-group">' +
'<label class="col-sm-3 form-control-label" for="delegates">Total Delegates</label>' +
'<div class="col-sm-3">' +
'<input class="form-control" type="tel" id="delegates" [(ngModel)]="delegates" />' +
'</div>' +
'</div>' +
'<div class="row form-group">' +
' <label class="col-sm-3 form-control-label" for="attendees">All Attendees</label>' +
' <div class="col-sm-3">' +
' <input class="form-control" type="tel" id="attendees" [(ngModel)]="attendees" />' +
' </div>' +
' <div class="col-sm-3">' +
' <span>{{viability()}} needed for viability</span>' +
' </div>' +
'</div>' +
'<div class="row form-group">' +
' <label class="col-sm-3 form-control-label" for="clinton">Clinton Preference Group</label>' +
' <div class="col-sm-3">' +
' <input class="form-control" type="tel" id="clinton" [(ngModel)]="clinton" />' +
' </div>' +
' <div class="col-sm-3">' +
' <span>{{clintonDelegates()}} Delegates earned</span>' +
' </div>' +
'</div>' +
'<div class="row form-group">' +
' <label class="col-sm-3 form-control-label" for="omalley">O'Malley Preference Group</label>' +
' <div class="col-sm-3">' +
' <input class="form-control" type="tel" id="omalley" [(ngModel)]="omalley" />' +
' </div>' +
' <div class="col-sm-3">' +
' <span>{{omalleyDelegates()}} Delegates earned</span>' +
' </div>' +
'</div>' +
'<div class="row form-group">' +
' <label class="col-sm-3 form-control-label" for="sanders">Sanders Preference Group</label>' +
' <div class="col-sm-3" >' +
' <input class="form-control" type="tel" id="sanders" [(ngModel)]="sanders" />' +
' </div>' +
' <div class="col-sm-3" >' +
' <span>{{sandersDelegates()}} Delegates earned</span>' +
' </div>' +
'</div>' +
'<div class="row form-group">' +
' <label class="col-sm-3 form-control-label" for="uncommitted">Uncommitted Preference Group</label>' +
' <div class="col-sm-3">' +
' <span>{{uncommitted()}}</span>' +
' </div>' +
' <div>' +
' <span class="col-sm-3">{{uncommittedDelegates()}} Delegates earned</span>' +
' </div>' +
'</div>'
})
.Class({
constructor: function() {
var that = this;
that.delegates = 8;
that.attendees = 100;
that.clinton = 25;
that.omalley = 25;
that.sanders = 25;
that.uncommitted = function() {
return (parseInt(that.attendees,10) || 0) - (parseInt(that.clinton,10) || 0) - (parseInt(that.omalley,10) || 0) - (parseInt(that.sanders,10) || 0);
};
var calcDelegates = function() {
return app.calcDelegates(parseInt(that.delegates,10), parseInt(that.attendees,10),
[
parseInt(that.clinton,10),
parseInt(that.omalley,10),
parseInt(that.sanders,10),
parseInt(that.uncommitted(),10)
]);
}
that.clintonDelegates = function() {
return calcDelegates()[0];
}
that.omalleyDelegates = function() {
return calcDelegates()[1];
}
that.sandersDelegates = function() {
return calcDelegates()[2];
}
that.uncommittedDelegates = function() {
return calcDelegates()[3];
}
that.viability = function() {
return app.calcViability(parseInt(that.delegates,10), parseInt(that.attendees,10));
}
}
});
})(window.app || (window.app = {}));