-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_ngstorage.js
72 lines (63 loc) · 3.49 KB
/
http_ngstorage.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
/*
Service that issues cancellable get requests if no matching records is stored on sessionStorage
*/
.factory('HotSpotInfo',['$http','SelectionService','$sessionStorage',function($http,SelectionService,$sessionStorage){
var ss=$sessionStorage;
var stash={
getGeoSig:function(hid,b,scb,fcb,skipExists){
if(ss['hotspot_'+hid+'_geosig']){
if(skipExists){
return true;
}
scb(JSON.parse(ss['hotspot_'+hid+'_geosig']))
return true
}
$http.get('api/hotspotinfo/'+hid+'/geosig',{params:b,timeout:SelectionService.hsRequestHandler.promise}).success(function(data){
ss['hotspot_'+hid+'_geosig']=JSON.stringify(data.data)
scb(data.data);
}).error(function(){fcb({error:1});});
return false;
},
getContributions:function(hid,b,scb,fcb){
if(ss['hotspot_'+hid+'_contrib']){
scb(JSON.parse(ss['hotspot_'+hid+'_contrib']))
return
}
$http.get('api/hotspotinfo/'+hid+'/contributors?call[]='+SelectionService.actualSystems.join('&call[]='),{params:b,timeout:SelectionService.hsRequestHandler.promise}).success(function(data){
ss['hotspot_'+hid+'_contrib']=JSON.stringify(data)
scb(data);
}).error(function(){fcb({error:1});});
},
getAmenities:function(hid,b,scb,fcb){
if(ss['hotspot_'+hid+'_amenities']){
scb(JSON.parse(ss['hotspot_'+hid+'_amenities']))
return
}
$http.get('api/hotspotinfo/'+hid+'/amenities',{timeout:SelectionService.hsRequestHandler.promise}).success(function(data){
ss['hotspot_'+hid+'_amenities']=JSON.stringify(data)
scb(data);
}).error(function(){fcb({error:1});});
},
getIndexes:function(hid,b,scb,fcb){
if(ss['hotspot_'+hid+'_indexes']){
scb(JSON.parse(ss['hotspot_'+hid+'_indexes']))
return
}
$http.get('api/hotspotinfo/'+hid+'/indexes',{timeout:SelectionService.hsRequestHandler.promise}).success(function(data){
ss['hotspot_'+hid+'_indexes']=JSON.stringify(data.data[0].hotspot_index_api)
scb(data.data[0].hotspot_index_api);
}).error(function(){fcb({error:1});});
},
getDivision:function(hid,b,scb,fcb){
if(ss['hotspot_'+hid+'_division']){
scb(JSON.parse(ss['hotspot_'+hid+'_division']))
return
}
$http.get('api/hotspotinfo/'+hid+'/division',{params:b,timeout:SelectionService.hsRequestHandler.promise}).success(function(data){
ss['hotspot_'+hid+'_division']=JSON.stringify(data.data[0].hotspot_political_api)
scb(data.data[0].hotspot_political_api);
}).error(function(){fcb({error:1});});
}
}
return stash;
}])