-
Notifications
You must be signed in to change notification settings - Fork 0
/
org.js
63 lines (46 loc) · 1.34 KB
/
org.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
// SPDX-License-Identifier: Apache-2.0
'use strict';
var app = angular.module('application', []);
// Angular Controller
app.controller('appController', function($scope, appFactory){
$("#success_holder").hide();
$("#success_create").hide();
$("#error_holder").hide();
$("#error_query").hide();
$scope.findEvents = function(){
appFactory.findEvents(function(data){
var array = [];
for (var i = 0; i < data.length; i++){
parseInt(data[i].Key);
data[i].Record.Key = parseInt(data[i].Key);
array.push(data[i].Record);
}
array.sort(function(a, b) {
return parseFloat(a.Key) - parseFloat(b.Key);
});
$scope.all_time = array;
});
}
$scope.recordEvent = function(){
appFactory.recordEvent($scope.event, function(data){
$scope.create_event = data;
$("#success_create").show();
});
}
});
// Angular Factory
app.factory('appFactory', function($http){
var factory = {};
factory.findEvents = function(callback){
$http.get('/get_all_events/').success(function(output){
callback(output)
});
}
factory.recordEvent = function(data, callback){
var event = data.id + "-" + data.name + "-" + data.event + "-" + data.country + "-" + data.state + "-" + data.area + "-" + data.target;
$http.get('/add_event/'+event).success(function(output){
callback(output)
});
}
return factory;
});