2 * Copyright 2016-2017, CMCC Technologies Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 var commonUtil = {};
\r
18 commonUtil.sendSynRequest = function(url){
\r
25 success: function (resp) {
\r
29 error: function(XMLHttpRequest, textStatus, errorThrown){
\r
34 commonUtil.strToJson = function(str){
\r
35 var json = eval('(' + str + ')');
\r
39 commonUtil.arrayRemove = function(aryInstance, index){
\r
40 if (aryInstance == undefined || aryInstance == null) {
\r
43 for (var i = 0, n = 0; i < aryInstance.length; i++) {
\r
44 if (aryInstance[i] != aryInstance[dx]) {
\r
45 aryInstance[n++] = aryInstance[i];
\r
48 aryInstance.length -= 1;
\r
51 // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
\r
52 // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
\r
53 commonUtil.parseDate = function(dateObj, format){
\r
55 "M+": dateObj.getMonth() + 1,
\r
56 "d+": dateObj.getDate(),
\r
57 "h+": dateObj.getHours(),
\r
58 "m+": dateObj.getMinutes(),
\r
59 "s+": dateObj.getSeconds(),
\r
60 "q+": Math.floor((dateObj.getMonth() + 3) / 3),
\r
61 "S": dateObj.getMilliseconds()
\r
63 if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
\r
64 (dateObj.getFullYear() + "").substr(4 - RegExp.$1.length));
\r
66 if (new RegExp("(" + k + ")").test(format))
\r
67 format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] :
\r
68 ("00" + o[k]).substr(("" + o[k]).length));
\r
72 commonUtil.strToJson = function(str){
\r
73 var json = eval('(' + str + ')');
\r