main.js
3.01 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*********************************************/
/* Trim the both side blank of the string */
/*********************************************/
function trim(s)
{
return trimRight(trimLeft(s));
}
/****************************************/
/* Trim the left blank of the string */
/****************************************/
function trimLeft(s) {
while (s.charAt(0) ==" " ||s.charAt(0) =="" ){
s = s.substr(1,s.length-1);
}
return s;
}
/*****************************************/
/* Trim the right blank of the string */
/*****************************************/
function trimRight(s) {
while (s.charAt(s.length-1) == " " || s.charAt(s.length-1) == "") {
s = s.substr(0,s.length-1);
}
return s;
}
/**
* 获取窗体高度
*/
function getWindowHeight() {
var windowHeight = 0;
if (typeof (window.innerHeight) == "number") {
windowHeight = window.innerHeight;
} else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
} else {
if (document.body && document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}
/**
* 获取窗体宽度
*/
function getWindowWidth() {
var windowWidth = 0;
if (typeof (window.innerWidth) == "number") {
windowWidth = window.innerWidth;
} else {
if (document.documentElement && document.documentElement.clientWidth) {
windowWidth = document.documentElement.clientWidth;
} else {
if (document.body && document.body.clientWidth) {
windowWidth = document.body.clientWidth;
}
}
}
return windowWidth;
}
/************************ jquery **************************/
/**
* 使用ajax提交数据
*/
function ajax_post(the_url,the_param,succ_callback){
jQuery.ajax({
type:'POST',
url:the_url,
data:the_param,
success:succ_callback,
error:function(html){
var flag = (typeof console != 'undefined');
if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!");
//alert("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!");
}
});
}
/**
* 避免传递空""值过来value时判断为是取值操作而不是赋值操作
*/
function jqName(name,value){
if(value === undefined) {
return jQuery(":input[name='"+name+"']").val()||'';
}else{
return jQuery(":input[name='"+name+"']").val(value);
}
}
/************************** form处理 *****************************/
/**
* 重置表单
*/
function resetForm(){
$(".tableSearch input:not(.btn1)").val("");
$(".tableSearch select").val("-1");
}
function console_log(str){
var flag = (typeof console != 'undefined');
if(flag) console.log('flyfox--> '+str);
}
/////////////////////////bootstrap 扩展////////////////////////////
var modal = {
iframe:function (url,height,title){
title = title || '信息';
height = height || '450';
$('#modal-iframe').attr("src",url);
$('#modal-iframe').height(height);
$('.modal #myModalLabel').html(title);
$('#myModal').modal('show');
}
};