-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.js
154 lines (148 loc) · 6.66 KB
/
data.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
var data;
var data2;
var newgeo = geo;
$.ajax({
url: "/data.csv",
async: false,
success: function (csvd) {
data = $.csv.toArrays(csvd);
},
dataType: "text",
complete: function () {
// call a function on complete
}
});
$.ajax({
url: "/data2.csv",
async: false,
success: function (csvd) {
data2 = $.csv.toArrays(csvd);
},
dataType: "text",
complete: function () {
// call a function on complete
}
});
var i, n;
for(i = 0; i < geo.features.length; i++) {
for(n = 0; n < data.length; n++) {
if (geo.features[i].properties.name == data[n][1]) {
if(!(data[n][4] == "") && data[n][4].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.pendingStartYear == undefined){
newgeo.features[i].properties.pendingStartYear = parseInt(data[n][4]);
} else {
newgeo.features[i].properties.pendingStartYear += parseInt(data[n][4]);
}
} else {
if(newgeo.features[i].properties.pendingStartYear == undefined){
newgeo.features[i].properties.pendingStartYear = 0;
}
}
if(!(data[n][6] == "") && data[n][6].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.applied == undefined){
newgeo.features[i].properties.applied = parseInt(data[n][6]);
} else {
newgeo.features[i].properties.applied += parseInt(data[n][6]);
}
} else {
if(newgeo.features[i].properties.applied == undefined){
newgeo.features[i].properties.applied = 0;
}
}
if(!(data[n][7] == "") && data[n][7].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.recognized == undefined){
newgeo.features[i].properties.recognized = parseInt(data[n][7]);
} else {
newgeo.features[i].properties.recognized += parseInt(data[n][7]);
}
} else {
if(newgeo.features[i].properties.recognized == undefined){
newgeo.features[i].properties.recognized = 0;
}
}
if(!(data[n][9] == "") && data[n][9].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.rejected == undefined){
newgeo.features[i].properties.rejected = parseInt(data[n][9]);
} else {
newgeo.features[i].properties.rejected += parseInt(data[n][9]);
}
} else {
if(newgeo.features[i].properties.rejected == undefined){
newgeo.features[i].properties.rejected = 0;
}
}
if(!(data[n][10] == "") && data[n][10].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.otherwiseClosed == undefined){
newgeo.features[i].properties.otherwiseClosed = parseInt(data[n][10]);
} else {
newgeo.features[i].properties.otherwiseClosed += parseInt(data[n][10]);
}
} else {
if(newgeo.features[i].properties.otherwiseClosed == undefined){
newgeo.features[i].properties.otherwiseClosed = 0;
}
}
if(!(data[n][12] == "") && data[n][12].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.pendingEndYear == undefined){
newgeo.features[i].properties.pendingEndYear = parseInt(data[n][12]);
} else {
newgeo.features[i].properties.pendingEndYear += parseInt(data[n][12]);
}
} else {
if(newgeo.features[i].properties.pendingEndYear == undefined){
newgeo.features[i].properties.pendingEndYear = 0;
}
}
if(!(data[n][11] == "") && data[n][11].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.decisions == undefined){
newgeo.features[i].properties.decisions = parseInt(data[n][11]);
} else {
newgeo.features[i].properties.decisions += parseInt(data[n][11]);
}
} else {
if(newgeo.features[i].properties.decisions == undefined){
newgeo.features[i].properties.decisions = 0;
}
}
if(!(data[n][13] == "") && data[n][13].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.UNHCRassisted == undefined){
newgeo.features[i].properties.UNHCRassisted = parseInt(data[n][13]);
} else {
newgeo.features[i].properties.UNHCRassisted += parseInt(data[n][13]);
}
} else {
if(newgeo.features[i].properties.UNHCRassisted == undefined){
newgeo.features[i].properties.UNHCRassisted = 0;
}
}
}
}
}
var i, n;
for(i = 0; i < geo.features.length; i++) {
for(n = 0; n < data2.length; n++) {
if (geo.features[i].properties.name == data2[n][1]) {
if(!(data2[n][10] == "") && data2[n][10].indexOf("*") < 0 ) {
if(newgeo.features[i].properties.totalRefugees == undefined){
newgeo.features[i].properties.totalRefugees = parseInt(data2[n][10]);
} else {
newgeo.features[i].properties.totalRefugees += parseInt(data2[n][10]);
}
} else {
if(newgeo.features[i].properties.totalRefugees == undefined){
newgeo.features[i].properties.totalRefugees = 0;
}
}
}
}
}
//calculated values for the graph
var i, n;
for(i = 0; i < geo.features.length; i++) {
newgeo.features[i].properties.recSeek = parseInt(newgeo.features[i].properties.applied / newgeo.features[i].properties.recognized);
newgeo.features[i].properties.rejSeek = parseInt(newgeo.features[i].properties.applied / newgeo.features[i].properties.rejected);
newgeo.features[i].properties.seekPer = parseInt(newgeo.features[i].properties.pop_est / newgeo.features[i].properties.applied);
newgeo.features[i].properties.seekGDP = parseInt(newgeo.features[i].properties.gdp_md_est / newgeo.features[i].properties.applied);
newgeo.features[i].properties.totalPer = parseInt(newgeo.features[i].properties.pop_est / newgeo.features[i].properties.totalRefugees);
newgeo.features[i].properties.totalGDP = parseInt(newgeo.features[i].properties.gdp_md_est / newgeo.features[i].properties.totalRefugees);
}