-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.js
More file actions
60 lines (58 loc) · 1.31 KB
/
global.js
File metadata and controls
60 lines (58 loc) · 1.31 KB
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
/**
* Created by sanjay on 02-Oct-16.
*/
transformRequest = function(obj){
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}
count = function(obj) {
var count=0;
for(var prop in obj) {
if (obj.hasOwnProperty(prop)) {
++count;
}
}
return count;
}
function addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
getMessageFromResponse = function(obj){
var msgArray=[];
var msgString='';
var separater = '\n';
if(obj.data && isArray(obj.data)){
msgArray = obj.data;
}else if(obj.error && isArray(obj.error)){
msgArray = obj.error;
}else if(obj.error && obj.error.message){
msgString = obj.error.message;
}else if(obj.error && obj.error){
msgString = obj.error;
}
if(msgArray && msgArray.length>=1)
msgArray.forEach(function(message)
{
if (msgString == '')
separater = '';
else
separater = '\n';
msgString = msgString + separater + message
})
return msgString;
}
function isArray(object)
{
if (object.constructor === Array) return true;
else return false;
}
function ParseDate(s) {
var dt = Date.parse(s);
console.log(dt);
return dt;
}