global.js
2.85 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
119
120
121
122
123
var CODE_SUCCESS = 200;
//html页面之间用来传递参数的对象
var paramObject = {};
var adminPortalUrl = null;
$.ajaxSetup({
cache : false,
dataType : "json",
type : "POST",
complete : function(XMLHttpRequest, textStatus) {
$.messager.progress("close");
var status = XMLHttpRequest.status;
if (status == 200) {
return;
}
var dialog = $("<div>").appendTo($(document.body));
if (status == 900) {
//数据库超时
//$.messageAlert("错误", "查询超时了");
$(dialog).myDialog({
modal : true,
width : 200,
height : 150,
title : "错误",
content : "查询超时了!",
buttons : [{
text : "关闭",
iconCls : "icon-no",
handler : function() {
$(dialog).myDialog("destroy");
}
}]
});
} else if (status == 901) {
//session超时
$(dialog).myDialog({
modal : true,
width : 200,
height : 150,
title : "错误",
content : "登录超时了!",
buttons : [{
text : "重新登录",
iconCls : "icon-no",
handler : function() {
window.top.location.href = "http://java-ufo-platform.test3.ingress.dev.yohocorp.com/ufoPlatform/html/login.html";
}
}]
});
} else {
$(dialog).myDialog({
modal : true,
width : 200,
height : 150,
title : "错误",
content : "操作失败了!",
buttons : [{
text : "关闭",
iconCls : "icon-no",
handler : function() {
$(dialog).myDialog("destroy");
}
}]
});
}
}
});
//通用的LoadFilter
function defaultLoadFilter(data) {
if (!data || data.code != 200) {
return [];
}
return data.data;
}
function utf16to8(str) {
debugger
var out, i, len, c;
out = "";
len = str.length;
for(i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out += str.charAt(i);
} else if (c > 0x07FF) {
out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
} else {
out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
}
}
return out;}
function addHead(title1, title2) {
var str = "<div class='pageheader'>";
str += "<div class='media'>";
str += "<div class='pageicon pull-left'>";
str += "<i class='fa fa-th-list'></i>";
str += "</div>";
str += "<div class='media-body' style=\"font-family: 'microsoft yahei'\">";
str += "<ul class='breadcrumb'>";
str += "<li><a href=''><i class='glyphicon glyphicon-home'></i></a></li>";
str += "<li><a href=''>"+ title1 +"</a></li>";
str += "<li>"+ title2 +"</li>";
str += "</ul>";
str += "<div style='margin-top: 4px'>";
str += "<h4 style='line-height: 30px;font-size: 24px'>";
str += title2;
str += "</h4>";
str += "</div>";
str += "</div>";
str += "</div>";
str += "</div>";
return str;
}