锘縱ar whir = window.whir || {}; whir.ajax = { get: function (url, data, callback) { $.get(url, data, function (result) { callback(result); }); }, getXML: function (url, data, callback) { $.get(url, data, function (result) { callback(result); }); }, htmlEncode: function (text) { var value = text; try { value = value.replace(/ /g, " "); value = value.replace(/&/, "&"); value = value.replace(//g, ">"); value = value.replace(/'/g, "'"); value = value.replace(/"/g, """); } catch (e) { var span = $(''); span.html(value); value = span.html(); value = value.replace(/&/, "&"); value = value.replace(//g, ">"); value = value.replace(/'/g, "'"); value = value.replace(/"/g, """); } return value; }, post: function (url, params) { var defaultParms = { url: url, data: { }, dataType: 'json', type: 'POST', success: function (response) { } }; var settings = $.extend(defaultParms, params); settings.data['__RequestVerificationToken'] = $('[name="__RequestVerificationToken"]').val() || ''; whir.loading.show(); $.ajax(settings); }, fixJsonDate: function (jsonDate, format) {// 鍙戠幇瀹炰綋杞崲鐨勬棩鏈熶細澶氫簡8涓皬鏃讹紝浣跨敤璇ユ柟娉曚細淇杩?涓皬鏃 if (!jsonDate) { return ""; } jsonDate = jsonDate.replace("鏄熸湡涓€", "").replace("鏄熸湡浜?, "").replace("鏄熸湡涓?, "").replace("鏄熸湡鍥?, "").replace("鏄熸湡浜?, "").replace("鏄熸湡鍏?, "").replace("鏄熸湡鏃?, ""); var date = null; if (jsonDate.toLowerCase().lastIndexOf("/date(")>=0) { if (jsonDate) { var strDate = jsonDate.toLowerCase().replace("/date(", "").replace(")/", ""); try { date = new Date(parseInt(strDate) - (8 * 3600 * 1000)); } catch (ex) { } } } else { if (jsonDate.lastIndexOf("-") >= 0) jsonDate = jsonDate.replace(/-/g, "/"); //涓轰簡鍏煎鑻规灉娴忚鍣ㄥ彧鏀寔/ date = new Date(jsonDate); } if (!date) { return ""; } date = { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate(), hour: date.getHours(), minutes: date.getMinutes(),seconds:date.getSeconds() }; switch (format) { case '-': return date.year + '-' + fixTime(date.month) + '-' + fixTime(date.day); case 'zh': return date.year + '骞? + fixTime(date.month) + '鏈? + fixTime(date.day) + '鏃?; default: return date.year + '-' + fixTime(date.month) + '-' + fixTime(date.day) + ' ' + fixTime(date.hour) + ':' + fixTime(date.minutes) + ':' + fixTime(date.seconds); } function fixTime(value) { return value.toString().length > 1 ? value : "0" + value; } }, subString: function (data, subLenth) { if (data != "" && data != null) { data = data.replace(/<[^>]+>/g, ""); if (data.length > subLenth) { return data.substring(0, subLenth) + "..."; } } return data; } };