script_wev8.js
2.57 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
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
/* Author: ZengDongPing*/
var config={
clientServer:"http://mdev.e-cology.cn/client.do?", /* Mobile Core服务器地址*/
newListPageSize:0 /* 新闻列表页面每次加载条数 */
}
var util={
/*
* para
* {
* "loadingTarget":"",//显示Loading的目标地址
* "url":"",//得数据的URL
* "callback":function(){} //success回调
* }
*
*
* passobj //所需要传递的json object
* {
*
* }
*
* */
getData:function(para,passobj){
jQuery.ajax({
type: "post",
url: "/mobile/plugin/cowork/CoworkOperation.jsp?" + para.paras,
data:para.datas,
dataType: "json",
contentType : "application/x-www-form-urlencoded;charset=UTF-8",
complete: function(){
//if(para.loadingTarget!=null) jQuery(para.loadingTarget).hideLoading();
},
error:function (XMLHttpRequest, textStatus, errorThrown) {
//alert(errorThrown);
} ,
success:function (data, textStatus) {
if (data == undefined || data == null) {
alert("服务器运行出错!\n请联系系统管理员!");
return;
} else {
para.callback.call(this,data,passobj);
}
}
});
},
/*
* 当且仅当data为非空的字符串时返回false,其他情况返回true
* @param data: 目标字符串
* @return 当且仅当data为非空的字符串时返回false,其他情况返回true
* */
isNullOrEmpty: function (data) {
if (data == undefined || data == null || data == "") {
return true;
}
return false;
},
/*
* 指定格式的当前日期字符串
* @param format 格式化字符串
* @return 指定格式的当前日期字符串
*/
getCurrentDate4Format : function (formatstring) {
var testDate = new Date();
var testStr = testDate.format(formatstring);
return testStr;
}
}
/**
* 为日期增加格式化方法
* @param format 格式化字符串
* @return 指定格式的字符串
*/
Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
}