-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadMore.js
71 lines (47 loc) · 1.8 KB
/
loadMore.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
var dictionary = function (key, value) {
this.url = key;
this.pageLength = value;
};
var dicArr = new Array();
var notPresent = true;
angular.module('loadMoreMod', [])
.factory("queryData", function ($http) {
return {
q:function(options)
{
//check whether in dic if not then add
if (!options.jsonData)
options.jsonData = new Object();
if (dicArr.length === 0) {
options.jsonData.pageLength = 0;
dicArr.push(new dictionary(options.url, 0));
}
else {
$.each(dicArr, function (idx, elem) {
if (elem.url === options.url) {
options.jsonData.pageLength = elem.pageLength++;
notPresent = false;
}
});
if (notPresent) {
options.jsonData.pageLength = 0;
dicArr.push(new dictionary(options.url, 0));
}
}
return $http({
url: options.url,
method: options.method || 'POST',
data: options.jsonData===undefined? {} : JSON.stringify(options.jsonData),
headers:options.headers || { 'Content-Type': 'application/json; charset=utf-8' }
}).then(function (dataRet) {
if (dataRet !== undefined) {
return dataRet.data.d;
}
else
return null;
}, function () {
return null;
});
}
}
});