3 function callVtoy(p1
, p2
, p3
) {
4 var url
= '/vtoy/json';
6 var func = function(data
) {};
8 if (typeof(p1
) === 'string') {
10 } else if (typeof(p1
) === 'object') {
13 if (typeof(p2
) === 'object') {
15 } else if (typeof(p2
) === 'function') {
18 if (typeof(p3
) === 'function') {
22 //vtoy.debug('callVtoy:\t\t\t\t' + JSON.stringify(data));
28 data: JSON
.stringify(data
),
30 error: function(xmlHttpRequest
, textStatus
, errorThrown
) {
32 if(undefined === errorThrown
)
34 Message
.error(vtoy_cur_language
.STR_WEB_REMOTE_ABNORMAL
);
36 else if(undefined === errorThrown
.length
)
40 else if('' == errorThrown
.trim())
49 Message
.error(vtoy_cur_language
.STR_WEB_REQUEST_TIMEOUT
);
52 case 'Service Unavailable':
54 Message
.error(vtoy_cur_language
.STR_WEB_SERVICE_UNAVAILABLE
);
63 Message
.error(vtoy_cur_language
.STR_WEB_COMMUNICATION_ERR
+ errorThrown
);
69 complete: function(data
) {
70 //vtoy.debug('callVtoy\'s resp:\t\t' + data.responseText);
75 function callVtoyASyncTimeout(time
, data
, func
) {
83 data: JSON
.stringify(data
),
85 error: function(xmlHttpRequest
, textStatus
, errorThrown
) {
86 if(undefined === errorThrown
)
89 else if(undefined === errorThrown
.length
)
93 else if('' == errorThrown
.trim())
102 callVtoyASyncTimeout(time
, data
, func
);
105 case 'Service Unavailable':
120 complete: function(data
) {
121 //vtoy.debug('callVtoyASyncTimeout\'s resp:\t' + JSON.stringify(data));
126 function callVtoySync(data
, func
) {
127 //vtoy.debug('callVtoySync:\t\t\t' + JSON.stringify(data));
134 data: JSON
.stringify(data
),
135 success: function VtoyCallFuncWrapper(data
) {
136 if (data
.result
=== 'tokenerror') {
137 var titlestr
= '<span class="fa fa-minus-circle" style="color:#dd4b39; font-weight:bold;"> ' + vtoy_cur_language
.STR_ERROR
+ '</span>';
138 var msgstr
= '<span style="font-size:14px; font-weight:bold;"> ' + vtoy_cur_language
.STR_WEB_TOKEN_MISMATCH
+ '</span>';
140 Modal
.alert({title:titlestr
, msg:msgstr
, btnok:vtoy_cur_language
.STR_BTN_OK
}).on(function(e
) {
141 window
.location
.reload(true);
144 else if (data
.result
=== 'busy') {
145 var titlestr
= '<span class="fa fa-check-circle" style="color:green; font-weight:bold;"> ' + vtoy_cur_language
.STR_INFO
+ '</span>';
146 var msgstr
= '<span style="font-size:14px; font-weight:bold;"> ' + vtoy_cur_language
.STR_WEB_SERVICE_BUSY
+ '</span>';
147 Modal
.alert({title:titlestr
, msg:msgstr
, btnok:vtoy_cur_language
.STR_BTN_OK
});
152 error: function(xmlHttpRequest
, textStatus
, errorThrown
) {
153 if(undefined === errorThrown
)
155 Message
.error(vtoy_cur_language
.STR_WEB_REMOTE_ABNORMAL
);
157 else if(undefined === errorThrown
.length
)
161 else if('' == errorThrown
.trim())
170 Message
.error(vtoy_cur_language
.STR_WEB_REQUEST_TIMEOUT
);
173 case 'Service Unavailable':
175 Message
.error(vtoy_cur_language
.STR_WEB_SERVICE_UNAVAILABLE
);
184 Message
.error(vtoy_cur_language
.STR_WEB_COMMUNICATION_ERR
+ errorThrown
);
190 complete: function(data
) {
191 //vtoy.debug('callVtoySync\'s resp:\t' + JSON.stringify(data));
206 String
.prototype.endsWith = function(str
) {
207 if (str
== null || str
== "" || this.length
== 0 || str
.length
> this.length
)
209 if (this.substring(this.length
- str
.length
) == str
)
215 window
.Message = function() {
216 var _showMsg = function(type
, msg
, time
) {
217 var o
= {type : type
, msg : msg
};
224 var _show = function(options
) {
230 $.extend(ops
, options
);
232 var msg_class
= 'alert-success';
233 if('S' === ops
.type
|| 's' === ops
.type
) {
234 msg_class
= 'alert-success';
235 } else if ('E' === ops
.type
|| 'e' === ops
.type
) {
236 msg_class
= 'alert-danger';
237 } else if ('W' === ops
.type
|| 'w' === ops
.type
) {
238 msg_class
= 'alert-warning';
239 } else if ('I' === ops
.type
|| 'i' === ops
.type
) {
240 msg_class
= 'alert-info';
242 alert("未知的类型,请使用: w-警告;s-成功;e-失败;i-提示");
245 var $messageContainer
= $("#fcss_message");
246 if($messageContainer
.length
=== 0) {
247 $messageContainer
= $('<div id="fcss_message" style="position:fixed; left: 20%; right: 20%; top:0px; z-index:99999999"></div>');
248 $messageContainer
.appendTo($('body'));
250 var $div
= $('<div class="alert ' + msg_class
+ ' alert-dismissible fade in" role="alert" style="margin-bottom: 0; padding-top:10px; padding-bottom: 10px;"></div>');
251 var $btn
= $('<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>');
252 $div
.append($btn
).append(ops
.msg
).appendTo($messageContainer
);
253 setTimeout(function() {
258 var _success = function(msg
, time
) {
259 _showMsg('s', msg
, time
);
261 var _error = function(msg
, time
) {
262 _showMsg('e', msg
, time
|| 5000);
264 var _warn = function(msg
, time
) {
265 _showMsg('w', msg
, time
);
267 var _info = function(msg
, time
) {
268 _showMsg('i', msg
, time
);