From 78a51aa7f5e7bd8b16020ace4d471b745cd65604 Mon Sep 17 00:00:00 2001
From: fuchengshen <men883234@gmail.com>
Date: 星期二, 14 六月 2022 11:28:15 +0800
Subject: [PATCH] 更改厂区模型
---
public/hn3d/lib/hao/haoutil-src.js | 1394 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 694 insertions(+), 700 deletions(-)
diff --git a/public/hn3d/lib/hao/haoutil-src.js b/public/hn3d/lib/hao/haoutil-src.js
index 9261fae..2723ef3 100644
--- a/public/hn3d/lib/hao/haoutil-src.js
+++ b/public/hn3d/lib/hao/haoutil-src.js
@@ -1,17 +1,11 @@
-/**
-* JS甯哥敤闈欐�佹柟娉曠被搴�
-* 婧愮爜鍦板潃锛歨ttps://github.com/muyao1987/haoutil
-* 鐗堟湰淇℃伅锛歷2.5.4
-* 缂栬瘧鏃ユ湡锛�2021-10-22 19:40:50
-* 鐗堟潈鎵�鏈夛細Copyright by 鐏槦绉戞妧 鏈ㄩ仴 http://marsgis.cn
-*/
+
var haoutil = haoutil || {};
-if(typeof exports === 'object'){
- exports.haoutil = haoutil
+if (typeof exports === 'object') {
+ exports.haoutil = haoutil
}
-else{
- window.haoutil = haoutil
+else {
+ window.haoutil = haoutil
}
@@ -19,90 +13,90 @@
haoutil.name = "鏈ㄩ仴 閫氱敤甯哥敤JS鏂规硶绫诲簱";
haoutil.author = "鏈ㄩ仴 , 寰俊: http://marsgis.cn/weixin.html";
haoutil.update = "2021-10-19";
-haoutil.website ='https://github.com/muyao1987/haoutil'
+haoutil.website = 'https://github.com/muyao1987/haoutil'
haoutil.msg = function (msg) {
- if(haoutil.isutil.isNull(msg)){
- msg = "鏈煡";
+ if (haoutil.isutil.isNull(msg)) {
+ msg = "鏈煡";
+ }
+ else {
+ if (typeof msg == 'object') {
+ msg = JSON.stringify(msg);
}
- else{
- if(typeof msg == 'object'){
- msg = JSON.stringify(msg);
- }
- }
- if (window.toastr)//姝ゆ柟娉曢渶瑕佸紩鐢╰oastr
- toastr.info(msg);
- else if (window.layer)
- layer.msg(msg);//姝ゆ柟娉曢渶瑕佸紩鐢╨ayer.js
- else
- alert(msg);
+ }
+ if (window.toastr)//姝ゆ柟娉曢渶瑕佸紩鐢╰oastr
+ toastr.info(msg);
+ else if (window.layer)
+ layer.msg(msg);//姝ゆ柟娉曢渶瑕佸紩鐢╨ayer.js
+ else
+ alert(msg);
};
haoutil.tip = haoutil.msg;
haoutil.oneMsg = function (msg, key) {
- if (!haoutil.storage.get(key)) {
- haoutil.msg(msg);
- haoutil.storage.add(key, true);
- }
+ if (!haoutil.storage.get(key)) {
+ haoutil.msg(msg);
+ haoutil.storage.add(key, true);
+ }
}
haoutil.alert = function (msg, title) {
- if(haoutil.isutil.isNull(msg)){
- msg = "鏈煡";
+ if (haoutil.isutil.isNull(msg)) {
+ msg = "鏈煡";
+ }
+ else {
+ if (typeof msg == 'object') {
+ msg = JSON.stringify(msg);
}
- else{
- if(typeof msg == 'object'){
- msg = JSON.stringify(msg);
- }
- }
- if (window.layer)//姝ゆ柟娉曢渶瑕佸紩鐢╨ayer.js
- layer.alert(msg, {
- title: title || '鎻愮ず',
- skin: 'layui-layer-lan layer-mars-dialog',
- closeBtn: 0,
- anim: 0
- });
- else
- alert(msg);
+ }
+ if (window.layer)//姝ゆ柟娉曢渶瑕佸紩鐢╨ayer.js
+ layer.alert(msg, {
+ title: title || '鎻愮ず',
+ skin: 'layui-layer-lan layer-mars-dialog',
+ closeBtn: 0,
+ anim: 0
+ });
+ else
+ alert(msg);
};
haoutil.loading = {
- index: -1,
- show: function (param) {
- this.close();
+ index: -1,
+ show: function (param) {
+ this.close();
- if (window.NProgress) {//姝ゆ柟娉曢渶瑕佸紩鐢∟Progress
- param = param || {};
- if (param.color) {
- param.template = '<div class="bar ' + (param.className || '') + '" style="background-color:' + param.color + ';" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>';
- }
- else {
- param.template = '<div class="bar ' + (param.className || '') + '" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>';
- }
+ if (window.NProgress) {//姝ゆ柟娉曢渶瑕佸紩鐢∟Progress
+ param = param || {};
+ if (param.color) {
+ param.template = '<div class="bar ' + (param.className || '') + '" style="background-color:' + param.color + ';" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>';
+ }
+ else {
+ param.template = '<div class="bar ' + (param.className || '') + '" role="bar"></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>';
+ }
- NProgress.configure(param);
- NProgress.start();
- }
- else if (window.layer) {//姝ゆ柟娉曢渶瑕佸紩鐢╨ayer.js
- this.index = layer.load(2, { shade: [0.3, '#000000'] });
- }
- },
- hide: function () {
- this.close();
- },
- close: function () {
- if (window.NProgress) {
- NProgress.done(true);
- }
- else if (window.layer) {
- if (this.index != -1)
- layer.close(this.index);
- this.index = -1;
- }
+ NProgress.configure(param);
+ NProgress.start();
}
+ else if (window.layer) {//姝ゆ柟娉曢渶瑕佸紩鐢╨ayer.js
+ this.index = layer.load(2, { shade: [0.3, '#000000'] });
+ }
+ },
+ hide: function () {
+ this.close();
+ },
+ close: function () {
+ if (window.NProgress) {
+ NProgress.done(true);
+ }
+ else if (window.layer) {
+ if (this.index != -1)
+ layer.close(this.index);
+ this.index = -1;
+ }
+ }
};
//js鍘熺敓瀵硅薄鎵╁睍
@@ -130,17 +124,17 @@
// // };
// }
-
+
String.prototype.startsWith = String.prototype.startsWith || function (str) {
- return this.slice(0, str.length) == str;
-};
+ return this.slice(0, str.length) == str;
+};
//鍒ゆ柇褰撳墠瀛楃涓叉槸鍚︿互str缁撴潫
String.prototype.endsWith = String.prototype.endsWith || function (str) {
- return this.slice(-str.length) == str;
+ return this.slice(-str.length) == str;
};
String.prototype.replaceAll = String.prototype.replaceAll || function (oldstring, newstring) {
- return this.replace(new RegExp(oldstring, "gm"), newstring);
+ return this.replace(new RegExp(oldstring, "gm"), newstring);
}
/**
@@ -157,49 +151,49 @@
* (new Date()).format("yyyy-MM-dd EEE hh:mm:ss") ==> 2016-03-10 鏄熸湡浜� 08:09:04
*/
Date.prototype.format = function (fmt) {
- var o = {
- "M+": this.getMonth() + 1, //鏈堜唤
- "d+": this.getDate(), //鏃�
- "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //灏忔椂
- "H+": this.getHours(), //灏忔椂
- "m+": this.getMinutes(), //鍒�
- "s+": this.getSeconds(), //绉�
- "q+": Math.floor((this.getMonth() + 3) / 3), //瀛e害
- "S": this.getMilliseconds() //姣
- };
- var week = {
- "0": "\u65e5",
- "1": "\u4e00",
- "2": "\u4e8c",
- "3": "\u4e09",
- "4": "\u56db",
- "5": "\u4e94",
- "6": "\u516d"
- };
- if (/(y+)/.test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+ var o = {
+ "M+": this.getMonth() + 1, //鏈堜唤
+ "d+": this.getDate(), //鏃�
+ "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //灏忔椂
+ "H+": this.getHours(), //灏忔椂
+ "m+": this.getMinutes(), //鍒�
+ "s+": this.getSeconds(), //绉�
+ "q+": Math.floor((this.getMonth() + 3) / 3), //瀛e害
+ "S": this.getMilliseconds() //姣
+ };
+ var week = {
+ "0": "\u65e5",
+ "1": "\u4e00",
+ "2": "\u4e8c",
+ "3": "\u4e09",
+ "4": "\u56db",
+ "5": "\u4e94",
+ "6": "\u516d"
+ };
+ if (/(y+)/.test(fmt)) {
+ fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+ }
+ if (/(E+)/.test(fmt)) {
+ fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
+ }
+ for (var k in o) {
+ if (new RegExp("(" + k + ")").test(fmt)) {
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
- if (/(E+)/.test(fmt)) {
- fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
- }
- for (var k in o) {
- if (new RegExp("(" + k + ")").test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- }
- }
- return fmt;
+ }
+ return fmt;
};
/* 2017-10-27 08:39:39 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
-haoutil.array = (function () {
+haoutil.array = (function () {
//============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- function indexOf(arr,val) {
+ function indexOf (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == val) return i;
}
return -1;
}
- function remove(arr,val) {
+ function remove (arr, val) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == val) {
arr.splice(i, 1);
@@ -207,7 +201,7 @@
}
}
}
- function insert(arr,item, index) {
+ function insert (arr, item, index) {
if (index == null) index = 0;
arr.splice(index, 0, item);
}
@@ -216,689 +210,689 @@
return {
indexOf: indexOf,
remove: remove,
- insert: insert,
+ insert: insert,
};
})();
/* 2017-12-8 09:39:39 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.color = (function () {
- // "棰滆壊 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
-
+ // "棰滆壊 鐩稿叧鎿嶄綔绫�";
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- //闅忔満棰滆壊
- function random() {
- return '#' +
- (function (color) {
+ //闅忔満棰滆壊
+ function random () {
+ return '#' +
- return (color += '0123456789abcdef'[Math.floor(Math.random() * 16)]) && (color.length == 6) ? color : arguments.callee(color);
+ (function (color) {
- })('');
- }
+ return (color += '0123456789abcdef'[Math.floor(Math.random() * 16)]) && (color.length == 6) ? color : arguments.callee(color);
-
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- random: random
- };
+ })('');
+ }
+
+
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ random: random
+ };
})();
/* 2017-10-10 13:32:56 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.cookie = (function () {
- //"cookie 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- var _isH5Mobile;
- function isH5Mobile(value) {
- _isH5Mobile = value;
+ //"cookie 鐩稿叧鎿嶄綔绫�";
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
+ var _isH5Mobile;
+ function isH5Mobile (value) {
+ _isH5Mobile = value;
+ }
+
+ //娣诲姞cookie
+ function add (name, value, days) {
+
+ //鍒ゆ柇鏄惁璁剧疆杩囨湡鏃堕棿,0浠h〃鍏抽棴娴忚鍣ㄦ椂澶辨晥
+ var date;
+ if (days > 0) {
+ date = new Date();
+ date.setTime(date.getTime + days * 24 * 60 * 60 * 1000); //鍗曚綅鏄ぉ鍚庡け鏁�
+ }
+ else {
+ date = new Date(0x7fffffff * 1e3);
+ }
+ var cookieString = name + "=" + escape(value) + "; expires=" + date.toGMTString();
+
+ if (_isH5Mobile && window['plus'] != null) {
+ plus.navigator.setCookie(name, cookieString);
+ } else {
+ document.cookie = cookieString;
+ }
+ }
+
+ //鑾峰彇cookie
+ function get (name) {
+ var strCookie
+ if (_isH5Mobile && window['plus'] != null) {
+ strCookie = plus.navigator.getCookie(name);
+ if (strCookie == null) return null;
+
+ } else {
+ strCookie = document.cookie;
}
- //娣诲姞cookie
- function add(name, value, days) {
- //鍒ゆ柇鏄惁璁剧疆杩囨湡鏃堕棿,0浠h〃鍏抽棴娴忚鍣ㄦ椂澶辨晥
- var date;
- if (days > 0) {
- date = new Date();
- date.setTime(date.getTime + days * 24 * 60 * 60 * 1000); //鍗曚綅鏄ぉ鍚庡け鏁�
- }
- else {
- date = new Date(0x7fffffff * 1e3);
- }
- var cookieString = name + "=" + escape(value) + "; expires=" + date.toGMTString();
-
- if (_isH5Mobile && window['plus'] != null) {
- plus.navigator.setCookie(name, cookieString);
- } else {
- document.cookie = cookieString;
- }
+ var arrCookie = strCookie.split("; ");
+ for (var i = 0; i < arrCookie.length; i++) {
+ var arr = arrCookie[i].split("=");
+ if (arr[0] == name) {
+ return unescape(arr[1]);
+ }
}
+ return null;
+ }
- //鑾峰彇cookie
- function get(name) {
- var strCookie
- if (_isH5Mobile && window['plus'] != null) {
- strCookie = plus.navigator.getCookie(name);
- if (strCookie == null) return null;
-
- } else {
- strCookie = document.cookie;
- }
-
-
- var arrCookie = strCookie.split("; ");
- for (var i = 0; i < arrCookie.length; i++) {
- var arr = arrCookie[i].split("=");
- if (arr[0] == name) {
- return unescape(arr[1]);
- }
- }
- return null;
+ //鍒犻櫎cookie
+ function del (name) {
+ if (_isH5Mobile && window['plus'] != null) {
+ plus.navigator.removeCookie(name);
}
-
- //鍒犻櫎cookie
- function del(name) {
- if (_isH5Mobile && window['plus'] != null) {
- plus.navigator.removeCookie(name);
- }
- else {
- var date = new Date();
- date.setTime(date.getTime() - 10000); //璁惧畾涓�涓繃鍘荤殑鏃堕棿鍗冲彲
- document.cookie = name + "=v; expires=" + date.toGMTString();
- }
+ else {
+ var date = new Date();
+ date.setTime(date.getTime() - 10000); //璁惧畾涓�涓繃鍘荤殑鏃堕棿鍗冲彲
+ document.cookie = name + "=v; expires=" + date.toGMTString();
}
+ }
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- isH5Mobile: isH5Mobile,
- add: add,
- get: get,
- del: del
- };
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ isH5Mobile: isH5Mobile,
+ add: add,
+ get: get,
+ del: del
+ };
})();
/* 2017-8-31 17:26:30 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.file = (function () {
- //"鏂囦欢 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
+ //"鏂囦欢 鐩稿叧鎿嶄綔绫�";
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- function _download(fileName, blob) {
- var aLink = document.createElement('a');
- aLink.download = fileName;
- aLink.href = URL.createObjectURL(blob);
- document.body.appendChild(aLink);
- aLink.click();
- document.body.removeChild(aLink);
+ function _download (fileName, blob) {
+ var aLink = document.createElement('a');
+ aLink.download = fileName;
+ aLink.href = URL.createObjectURL(blob);
+ document.body.appendChild(aLink);
+ aLink.click();
+ document.body.removeChild(aLink);
+ }
+
+
+ //涓嬭浇淇濆瓨鏂囦欢
+ function downloadFile (fileName, string) {
+ var blob = new Blob([string]);
+ _download(fileName, blob);
+ }
+
+
+ //涓嬭浇瀵煎嚭鍥剧墖
+ function downloadImage (name, canvas) {
+ var base64 = canvas.toDataURL("image/png");
+ var blob = base64Img2Blob(base64);
+ _download(name + '.png', blob);
+ }
+
+ //涓嬭浇瀵煎嚭鍥剧墖
+ function downloadBase64Image (name, base64) {
+ var blob = base64Img2Blob(base64);
+ _download(name + '.png', blob);
+ }
+
+
+ function base64Img2Blob (code) {
+ var parts = code.split(';base64,');
+ var contentType = parts[0].split(':')[1];
+ var raw = window.atob(parts[1]);
+ var rawLength = raw.length;
+
+ var uInt8Array = new Uint8Array(rawLength);
+ for (var i = 0; i < rawLength; ++i) {
+ uInt8Array[i] = raw.charCodeAt(i);
}
+ return new Blob([uInt8Array], { type: contentType });
+ }
- //涓嬭浇淇濆瓨鏂囦欢
- function downloadFile(fileName, string) {
- var blob = new Blob([string]);
- _download(fileName, blob);
- }
-
-
- //涓嬭浇瀵煎嚭鍥剧墖
- function downloadImage(name, canvas) {
- var base64 = canvas.toDataURL("image/png");
- var blob = base64Img2Blob(base64);
- _download(name + '.png', blob);
- }
-
- //涓嬭浇瀵煎嚭鍥剧墖
- function downloadBase64Image(name, base64) {
- var blob = base64Img2Blob(base64);
- _download(name + '.png', blob);
- }
-
-
- function base64Img2Blob(code) {
- var parts = code.split(';base64,');
- var contentType = parts[0].split(':')[1];
- var raw = window.atob(parts[1]);
- var rawLength = raw.length;
-
- var uInt8Array = new Uint8Array(rawLength);
- for (var i = 0; i < rawLength; ++i) {
- uInt8Array[i] = raw.charCodeAt(i);
- }
- return new Blob([uInt8Array], { type: contentType });
- }
-
-
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- download: _download,
- downloadFile: downloadFile,
- downloadImage: downloadImage,
- downloadBase64Image: downloadBase64Image,
- base64Img2Blob: base64Img2Blob
- };
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ download: _download,
+ downloadFile: downloadFile,
+ downloadImage: downloadImage,
+ downloadBase64Image: downloadBase64Image,
+ base64Img2Blob: base64Img2Blob
+ };
})();
/* 2017-12-5 13:38:32 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.isutil = (function () {
- // "鍒ゆ柇 鐩稿叧鎿嶄綔绫�";
+ // "鍒ゆ柇 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- function isArray(obj) {
- if (typeof Array.isArray === "function") {
- return Array.isArray(obj);
- } else {
- return Object.prototype.toString.call(obj) === "[object Array]";
- }
- }
-
- function isString(str) {
- return (typeof str == 'string') && str.constructor == String;
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
+ function isArray (obj) {
+ if (typeof Array.isArray === "function") {
+ return Array.isArray(obj);
+ } else {
+ return Object.prototype.toString.call(obj) === "[object Array]";
}
+ }
- function isNumber(obj) {
- return (typeof obj == 'number') && obj.constructor == Number;
- }
+ function isString (str) {
+ return (typeof str == 'string') && str.constructor == String;
+ }
- function isDate(obj) {
- return (typeof obj == 'object') && obj.constructor == Date;
- }
+ function isNumber (obj) {
+ return (typeof obj == 'number') && obj.constructor == Number;
+ }
- function isFunction(obj) {
- return (typeof obj == 'function') && obj.constructor == Function;
- }
+ function isDate (obj) {
+ return (typeof obj == 'object') && obj.constructor == Date;
+ }
- function isObject(obj) {
- return Object.prototype.toString.call(obj) === "[object Object]";
- }
+ function isFunction (obj) {
+ return (typeof obj == 'function') && obj.constructor == Function;
+ }
+
+ function isObject (obj) {
+ return Object.prototype.toString.call(obj) === "[object Object]";
+ }
- function isNull(value) {
- if (value == null) return true;
- if (isString(value) && value == "") return true;
- if (isNumber(value) && isNaN(value)) return true;
+ function isNull (value) {
+ if (value == null) return true;
+ if (isString(value) && value == "") return true;
+ if (isNumber(value) && isNaN(value)) return true;
- return false;
- }
+ return false;
+ }
- function isNotNull(value) {
- return !isNull(value);
- }
+ function isNotNull (value) {
+ return !isNull(value);
+ }
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- isNull: isNull,
- isNotNull: isNotNull,
- isArray: isArray,
- isString: isString,
- isNumber: isNumber,
- isDate: isDate,
- isFunction: isFunction,
- isObject: isObject
- };
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ isNull: isNull,
+ isNotNull: isNotNull,
+ isArray: isArray,
+ isString: isString,
+ isNumber: isNumber,
+ isDate: isDate,
+ isFunction: isFunction,
+ isObject: isObject
+ };
})();
/* 2017-8-10 13:50:49 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.math = (function () {
- // "鏁板 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
+ // "鏁板 鐩稿叧鎿嶄綔绫�";
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- function random(min, max) {
- return Math.floor(Math.random() * (max - min + 1) + min);
+ function random (min, max) {
+ return Math.floor(Math.random() * (max - min + 1) + min);
+ }
+
+
+ //闅忔満鏁扮粍涓殢鏈哄彇1涓厓绱�
+ function getArrayRandomOne (arr) {
+ var n = random(0, arr.length - 1);
+ return arr[n];
+ }
+
+ //琛ラ浂padLeft0
+ function padLeft0 (numStr, len) {
+ numStr = String(numStr);
+ var len = numStr.length;
+ while (len < n) {
+ numStr = "0" + numStr;
+ len++;
}
+ return numStr;
+ }
-
- //闅忔満鏁扮粍涓殢鏈哄彇1涓厓绱�
- function getArrayRandomOne(arr) {
- var n = random(0, arr.length - 1);
- return arr[n];
- }
-
- //琛ラ浂padLeft0
- function padLeft0(numStr, len) {
- numStr = String(numStr);
- var len = numStr.length;
- while (len < n) {
- numStr = "0" + numStr;
- len++;
- }
- return numStr;
- }
-
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- getArrayRandomOne: getArrayRandomOne,
- random: random,
- padLeft0: padLeft0
- };
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ getArrayRandomOne: getArrayRandomOne,
+ random: random,
+ padLeft0: padLeft0
+ };
})();
haoutil.storage = (function () {
- //"localStorage 鐩稿叧鎿嶄綔绫�";
- var _storage;
+ //"localStorage 鐩稿叧鎿嶄綔绫�";
+ var _storage;
- //娣诲姞
- function add(name, data) {
- _storage = window.localStorage;
- if (_storage == null) return;
- _storage.setItem(name, data);
- }
+ //娣诲姞
+ function add (name, data) {
+ _storage = window.localStorage;
+ if (_storage == null) return;
+ _storage.setItem(name, data);
+ }
- //鑾峰彇cookie
- function get(name) {
- _storage = window.localStorage;
- if (_storage == null) return;
- var data = _storage.getItem(name);
- return data;
- }
- function del(name) {
- _storage = window.localStorage;
- if (_storage == null) return;
- _storage.removeItem(name);
- }
+ //鑾峰彇cookie
+ function get (name) {
+ _storage = window.localStorage;
+ if (_storage == null) return;
+ var data = _storage.getItem(name);
+ return data;
+ }
+ function del (name) {
+ _storage = window.localStorage;
+ if (_storage == null) return;
+ _storage.removeItem(name);
+ }
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- add: add,
- get: get,
- del: del
- };
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ add: add,
+ get: get,
+ del: del
+ };
})();
/* 2017-10-27 08:39:39 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.str = (function () {
- // "瀛楃涓� 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
+ // "瀛楃涓� 鐩稿叧鎿嶄綔绫�";
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- //鍒ゆ柇瀛楃鏄惁鏄腑鏂囧瓧绗�
- function isChinese(s) {
- var patrn = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
- if (!patrn.exec(s)) {
- return false;
- } else {
- return true;
- }
+ //鍒ゆ柇瀛楃鏄惁鏄腑鏂囧瓧绗�
+ function isChinese (s) {
+ var patrn = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
+ if (!patrn.exec(s)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+
+ /** 鍗曚綅鎹㈢畻锛屾牸寮忓寲鏄剧ず闀垮害 */
+ function formatLength (val, unit) {
+ if (val == null) return "";
+ val = Number(val);
+
+ if (unit == null || unit == "auto") {
+ if (val < 1000)
+ unit = "m";
+ else
+ unit = "km";
}
+ var valstr = "";
+ switch (unit) {
+ default:
+ case "m":
+ valstr = val.toFixed(2) + '绫�';
+ break;
+ case "km":
+ valstr = (val * 0.001).toFixed(2) + '鍏噷';
+ break;
+ case "mile":
+ valstr = (val * 0.00054).toFixed(2) + '娴烽噷';
+ break;
+ case "zhang":
+ valstr = (val * 0.3).toFixed(2) + '涓�';
+ break;
+ }
+ return valstr;
+ }
- /** 鍗曚綅鎹㈢畻锛屾牸寮忓寲鏄剧ず闀垮害 */
- function formatLength(val, unit) {
- if (val == null) return "";
- val = Number(val);
- if (unit == null || unit == "auto") {
- if (val < 1000)
- unit = "m";
- else
- unit = "km";
- }
- var valstr = "";
- switch (unit) {
- default:
- case "m":
- valstr = val.toFixed(2) + '绫�';
- break;
- case "km":
- valstr = (val * 0.001).toFixed(2) + '鍏噷';
- break;
- case "mile":
- valstr = (val * 0.00054).toFixed(2) + '娴烽噷';
- break;
- case "zhang":
- valstr = (val * 0.3).toFixed(2) + '涓�';
- break;
- }
- return valstr;
+
+ /** 杩涜鍗曚綅鎹㈢畻锛屾牸寮忓寲鏄剧ず闈㈢Н */
+ function formatArea (val, unit) {
+ if (val == null) return "";
+ val = Number(val);
+
+ if (unit == null || unit == "auto") {
+ if (val < 1000000)
+ unit = "m";
+ else
+ unit = "km";
}
-
-
-
- /** 杩涜鍗曚綅鎹㈢畻锛屾牸寮忓寲鏄剧ず闈㈢Н */
- function formatArea(val, unit) {
- if (val == null) return "";
- val = Number(val);
-
- if (unit == null || unit == "auto") {
- if (val < 1000000)
- unit = "m";
- else
- unit = "km";
- }
-
- var valstr = "";
- switch (unit) {
- default:
- case "m":
- valstr = val.toFixed(2) + '骞虫柟绫�';
- break;
- case "km":
- valstr = (val / 1000000).toFixed(2) + '骞虫柟鍏噷';
- break;
- case "mu":
- valstr = (val * 0.0015).toFixed(2) + '浜�';
- break;
- case "ha":
- valstr = (val * 0.0001).toFixed(2) + '鍏》';
- break;
- }
-
- return valstr;
+ var valstr = "";
+ switch (unit) {
+ default:
+ case "m":
+ valstr = val.toFixed(2) + '骞虫柟绫�';
+ break;
+ case "km":
+ valstr = (val / 1000000).toFixed(2) + '骞虫柟鍏噷';
+ break;
+ case "mu":
+ valstr = (val * 0.0015).toFixed(2) + '浜�';
+ break;
+ case "ha":
+ valstr = (val * 0.0001).toFixed(2) + '鍏》';
+ break;
}
+ return valstr;
+ }
- //鏍煎紡鍖栨椂闂�
- function formatTime(strtime) {
- strtime = Number(strtime)||0;
- if (strtime < 60)
- return strtime.toFixed(0) + "绉�";
- else if (strtime >= 60 && strtime < 3600) {
- var miao = Math.floor(strtime % 60);
- return Math.floor(strtime / 60) + "鍒嗛挓" + (miao != 0 ? (miao + "绉�") : "");
- }
- else {
- strtime = Math.floor(strtime / 60); //绉掕浆鍒嗛挓
- return Math.floor(strtime / 60) + "灏忔椂" + Math.floor(strtime % 60) + "鍒嗛挓";
- }
+ //鏍煎紡鍖栨椂闂�
+ function formatTime (strtime) {
+ strtime = Number(strtime) || 0;
+
+ if (strtime < 60)
+ return strtime.toFixed(0) + "绉�";
+ else if (strtime >= 60 && strtime < 3600) {
+ var miao = Math.floor(strtime % 60);
+ return Math.floor(strtime / 60) + "鍒嗛挓" + (miao != 0 ? (miao + "绉�") : "");
}
-
-
-
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); //绱㈠紩琛�
-
- /**
- 聽聽聽* @description 灏嗕簩杩涘埗搴忓垪杞崲涓築ase64缂栫爜
- 聽聽聽* @param {String}
- 聽聽聽* @return {String}
- 聽聽聽*/
- function binToBase64(bitString) {
- var result = "";
- var tail = bitString.length % 6;
- var bitStringTemp1 = bitString.substr(0, bitString.length - tail);
- var bitStringTemp2 = bitString.substr(bitString.length - tail, tail);
- for (var i = 0; i < bitStringTemp1.length; i += 6) {
- var index = parseInt(bitStringTemp1.substr(i, 6), 2);
- result += code[index];
- }
- bitStringTemp2 += new Array(7 - tail).join("0");
- if (tail) {
- result += code[parseInt(bitStringTemp2, 2)];
- result += new Array((6 - tail) / 2 + 1).join("=");
- }
- return result;
+ else {
+ strtime = Math.floor(strtime / 60); //绉掕浆鍒嗛挓
+ return Math.floor(strtime / 60) + "灏忔椂" + Math.floor(strtime % 60) + "鍒嗛挓";
}
+ }
- /**
- 聽聽聽* @description 灏哹ase64缂栫爜杞崲涓轰簩杩涘埗搴忓垪
- 聽聽聽* @param {String}
- 聽聽聽* @return {String}
- 聽聽聽*/
- function base64ToBin(str) {
- var bitString = "";
- var tail = 0;
- for (var i = 0; i < str.length; i++) {
- if (str[i] != "=") {
- var decode = code.indexOf(str[i]).toString(2);
- bitString += (new Array(7 - decode.length)).join("0") + decode;
- } else {
- tail++;
- }
- }
- return bitString.substr(0, bitString.length - tail * 2);
+
+
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); //绱㈠紩琛�
+
+ /**
+ * @description 灏嗕簩杩涘埗搴忓垪杞崲涓築ase64缂栫爜
+ * @param {String}
+ * @return {String}
+ */
+ function binToBase64 (bitString) {
+ var result = "";
+ var tail = bitString.length % 6;
+ var bitStringTemp1 = bitString.substr(0, bitString.length - tail);
+ var bitStringTemp2 = bitString.substr(bitString.length - tail, tail);
+ for (var i = 0; i < bitStringTemp1.length; i += 6) {
+ var index = parseInt(bitStringTemp1.substr(i, 6), 2);
+ result += code[index];
}
-
- /**
- 聽聽聽* @description 灏嗗瓧绗﹁浆鎹负浜岃繘鍒跺簭鍒�
- 聽聽聽* @param {String} str
- 聽聽聽* @return {String}聽
- 聽聽聽*/
- function stringToBin(str) {
- var result = "";
- for (var i = 0; i < str.length; i++) {
- var charCode = str.charCodeAt(i).toString(2);
- result += (new Array(9 - charCode.length).join("0") + charCode);
- }
- return result;
+ bitStringTemp2 += new Array(7 - tail).join("0");
+ if (tail) {
+ result += code[parseInt(bitStringTemp2, 2)];
+ result += new Array((6 - tail) / 2 + 1).join("=");
}
+ return result;
+ }
- /**
- 聽聽聽* @description 灏嗕簩杩涘埗搴忓垪杞崲涓哄瓧绗︿覆
- 聽聽聽* @param {String} Bin
- 聽聽聽*/
- function BinToStr(Bin) {
- var result = "";
- for (var i = 0; i < Bin.length; i += 8) {
- result += String.fromCharCode(parseInt(Bin.substr(i, 8), 2));
- }
- return result;
+ /**
+ * @description 灏哹ase64缂栫爜杞崲涓轰簩杩涘埗搴忓垪
+ * @param {String}
+ * @return {String}
+ */
+ function base64ToBin (str) {
+ var bitString = "";
+ var tail = 0;
+ for (var i = 0; i < str.length; i++) {
+ if (str[i] != "=") {
+ var decode = code.indexOf(str[i]).toString(2);
+ bitString += (new Array(7 - decode.length)).join("0") + decode;
+ } else {
+ tail++;
+ }
}
- function base64(str) {
- return binToBase64(stringToBin(str));
+ return bitString.substr(0, bitString.length - tail * 2);
+ }
+
+ /**
+ * @description 灏嗗瓧绗﹁浆鎹负浜岃繘鍒跺簭鍒�
+ * @param {String} str
+ * @return {String}聽
+ */
+ function stringToBin (str) {
+ var result = "";
+ for (var i = 0; i < str.length; i++) {
+ var charCode = str.charCodeAt(i).toString(2);
+ result += (new Array(9 - charCode.length).join("0") + charCode);
}
+ return result;
+ }
- function decodeBase64(str) {
- return BinToStr(base64ToBin(str));
+ /**
+ * @description 灏嗕簩杩涘埗搴忓垪杞崲涓哄瓧绗︿覆
+ * @param {String} Bin
+ */
+ function BinToStr (Bin) {
+ var result = "";
+ for (var i = 0; i < Bin.length; i += 8) {
+ result += String.fromCharCode(parseInt(Bin.substr(i, 8), 2));
}
+ return result;
+ }
+ function base64 (str) {
+ return binToBase64(stringToBin(str));
+ }
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- isChinese: isChinese,
- formatLength: formatLength,
- formatArea: formatArea,
- formatTime: formatTime,
- base64: base64,
- decodeBase64: decodeBase64
+ function decodeBase64 (str) {
+ return BinToStr(base64ToBin(str));
+ }
- };
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ isChinese: isChinese,
+ formatLength: formatLength,
+ formatArea: formatArea,
+ formatTime: formatTime,
+ base64: base64,
+ decodeBase64: decodeBase64
+
+ };
})();
/* 2017-10-27 08:31:05 | 淇敼 鏈ㄩ仴锛堝井淇�: http://marsgis.cn/weixin.html锛� */
haoutil.system = (function () {
- // 绯荤粺绾� 鎴� 娴忚鍣� 鐩稿叧鎿嶄綔绫�";
- //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
+ // 绯荤粺绾� 鎴� 娴忚鍣� 鐩稿叧鎿嶄綔绫�";
+ //============鍐呴儴绉佹湁灞炴�у強鏂规硶============
- //url鍙傛暟鑾峰彇
- function getRequest(target) {
- var theRequest = new Object();
- try {//灞忚斀璺ㄥ煙鏃舵姤閿�
- target = target || window;
- var url = target.location.search; //鑾峰彇url涓�"?"绗﹀悗鐨勫瓧涓�
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- var strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
- }
- }
- } catch (e) { }
- return theRequest;
+ //url鍙傛暟鑾峰彇
+ function getRequest (target) {
+ var theRequest = new Object();
+ try {//灞忚斀璺ㄥ煙鏃舵姤閿�
+ target = target || window;
+ var url = target.location.search; //鑾峰彇url涓�"?"绗﹀悗鐨勫瓧涓�
+ if (url.indexOf("?") != -1) {
+ var str = url.substr(1);
+ var strs = str.split("&");
+ for (var i = 0; i < strs.length; i++) {
+ theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
+ }
+ }
+ } catch (e) { }
+ return theRequest;
+ }
+ function getRequestByName (name, defval, target) {
+ try {
+ target = target || window;
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+ var r = target.location.search.substr(1).match(reg);
+ if (r != null) return decodeURI(r[2]);
+
+ } catch (e) { }
+ return defval;
+ }
+
+ function getWindowSize () {
+ if (typeof window.innerWidth != 'undefined') {
+ return {
+ width: window.innerWidth,
+ height: window.innerHeight
+ }
+ } else {
+ return {
+ width: document.documentElement.clientWidth,
+ height: document.documentElement.clientHeight
+ }
}
- function getRequestByName(name, defval, target) {
- try {
- target = target || window;
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = target.location.search.substr(1).match(reg);
- if (r != null) return decodeURI(r[2]);
+ }
- } catch (e) { }
- return defval;
+ //鑾峰彇娴忚鍣ㄧ被鍨嬪強鐗堟湰
+ function getExplorerInfo () {
+ var explorer = window.navigator.userAgent.toLowerCase();
+ //ie
+ if (explorer.indexOf("msie") >= 0) {
+ var ver = Number(explorer.match(/msie ([\d]+)/)[1]);
+ return { type: "IE", version: ver };
+ }
+ //firefox
+ else if (explorer.indexOf("firefox") >= 0) {
+ var ver = Number(explorer.match(/firefox\/([\d]+)/)[1]);
+ return { type: "Firefox", version: ver };
+ }
+ //Chrome
+ else if (explorer.indexOf("chrome") >= 0) {
+ var ver = Number(explorer.match(/chrome\/([\d]+)/)[1]);
+ return { type: "Chrome", version: ver };
+ }
+ //Opera
+ else if (explorer.indexOf("opera") >= 0) {
+ var ver = Number(explorer.match(/opera.([\d]+)/)[1]);
+ return { type: "Opera", version: ver };
+ }
+ //Safari
+ else if (explorer.indexOf("Safari") >= 0) {
+ var ver = Number(explorer.match(/version\/([\d]+)/)[1]);
+ return { type: "Safari", version: ver };
+ }
+ return { type: explorer, version: -1 };
+ }
+
+
+ //娴忚鍣�
+ function isPCBroswer () {
+ var sUserAgent = navigator.userAgent.toLowerCase();
+
+ var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
+ var bIsIphoneOs = sUserAgent.match(/iphone/i) == "iphone";
+ var bIsMidp = sUserAgent.match(/midp/i) == "midp";
+ var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
+ var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
+ var bIsAndroid = sUserAgent.match(/android/i) == "android";
+ var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
+ var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
+ if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+
+ function clone (obj, removeKeys, level) {
+ if (level == null) level = 9; //閬垮厤姝诲惊鐜紝鎷疯礉鐨勫眰绾ф渶澶ф繁搴�
+ if (removeKeys == null) removeKeys = ["_layer"];
+
+ if (null == obj || "object" != typeof obj) return obj;
+
+ // Handle Date
+ if (haoutil.isutil.isDate(obj)) {
+ var copy = new Date();
+ copy.setTime(obj.getTime());
+ return copy;
}
- function getWindowSize() {
- if (typeof window.innerWidth != 'undefined') {
- return {
- width: window.innerWidth,
- height: window.innerHeight
- }
- } else {
- return {
- width: document.documentElement.clientWidth,
- height: document.documentElement.clientHeight
- }
- }
+ // Handle Array
+ if (haoutil.isutil.isArray(obj) && level >= 0) {
+ var copy = [];
+ for (var i = 0, len = obj.length; i < len; ++i) {
+ copy[i] = clone(obj[i], removeKeys, level - 1);
+ }
+ return copy;
}
- //鑾峰彇娴忚鍣ㄧ被鍨嬪強鐗堟湰
- function getExplorerInfo() {
- var explorer = window.navigator.userAgent.toLowerCase();
- //ie
- if (explorer.indexOf("msie") >= 0) {
- var ver = Number(explorer.match(/msie ([\d]+)/)[1]);
- return { type: "IE", version: ver };
+ // Handle Object
+ if (typeof obj === 'object' && level >= 0) {
+ try {
+ var copy = {};
+ for (var attr in obj) {
+ if (typeof attr === 'function') continue;
+ if (removeKeys.indexOf(attr) != -1) continue;
+
+ if (obj.hasOwnProperty(attr))
+ copy[attr] = clone(obj[attr], removeKeys, level - 1);
}
- //firefox
- else if (explorer.indexOf("firefox") >= 0) {
- var ver = Number(explorer.match(/firefox\/([\d]+)/)[1]);
- return { type: "Firefox", version: ver };
- }
- //Chrome
- else if (explorer.indexOf("chrome") >= 0) {
- var ver = Number(explorer.match(/chrome\/([\d]+)/)[1]);
- return { type: "Chrome", version: ver };
- }
- //Opera
- else if (explorer.indexOf("opera") >= 0) {
- var ver = Number(explorer.match(/opera.([\d]+)/)[1]);
- return { type: "Opera", version: ver };
- }
- //Safari
- else if (explorer.indexOf("Safari") >= 0) {
- var ver = Number(explorer.match(/version\/([\d]+)/)[1]);
- return { type: "Safari", version: ver };
- }
- return { type: explorer, version: -1 };
+ return copy;
+ }
+ catch (e) { console.log(e); }
}
+ return obj;
+ }
-
- //娴忚鍣�
- function isPCBroswer() {
- var sUserAgent = navigator.userAgent.toLowerCase();
-
- var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
- var bIsIphoneOs = sUserAgent.match(/iphone/i) == "iphone";
- var bIsMidp = sUserAgent.match(/midp/i) == "midp";
- var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
- var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
- var bIsAndroid = sUserAgent.match(/android/i) == "android";
- var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
- var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
- if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
- return false;
- } else {
- return true;
- }
- }
-
-
- function clone(obj, removeKeys, level) {
- if (level == null) level = 9; //閬垮厤姝诲惊鐜紝鎷疯礉鐨勫眰绾ф渶澶ф繁搴�
- if (removeKeys == null) removeKeys = ["_layer"];
-
- if (null == obj || "object" != typeof obj) return obj;
-
- // Handle Date
- if (haoutil.isutil.isDate(obj)) {
- var copy = new Date();
- copy.setTime(obj.getTime());
- return copy;
- }
-
- // Handle Array
- if (haoutil.isutil.isArray(obj) && level >= 0) {
- var copy = [];
- for (var i = 0, len = obj.length; i < len; ++i) {
- copy[i] = clone(obj[i], removeKeys, level - 1);
- }
- return copy;
- }
-
- // Handle Object
- if (typeof obj === 'object' && level >= 0) {
- try {
- var copy = {};
- for (var attr in obj) {
- if (typeof attr === 'function') continue;
- if (removeKeys.indexOf(attr) != -1) continue;
-
- if (obj.hasOwnProperty(attr))
- copy[attr] = clone(obj[attr], removeKeys, level - 1);
- }
- return copy;
- }
- catch (e) { console.log(e); }
- }
- return obj;
- }
-
- function jsonp(url, data, callback) {
- var jsonp = function (url, data, callback) {
- var fnSuffix = Math.random().toString().replace('.', '');
- var cbFuncName = 'my_json_cb_' + fnSuffix;
- // 涓嶆帹鑽�
- window[cbFuncName] = callback;
- var querystring = url.indexOf('?') == -1 ? '?' : '&';
- for (var key in data) {
- querystring += key + '=' + data[key] + '&';
- }
- querystring += 'callback=' + cbFuncName;
- var scriptElement = document.createElement('script');
- scriptElement.src = url + querystring;
- document.body.appendChild(scriptElement);
- };
- window.$jsonp = jsonp;
- }
-
- //鍏叡鏂规硶
- function getHtml(url, callback) {
- $.ajax({
- url: url,
- type: "GET",
- dataType: 'html',
- timeout: 0, //姘镐笉瓒呮椂
- success: function (data) {
- callback(data);
- }
- });
- }
-
- var nHead = document.head || document.getElementsByTagName('head')[0];
- // loadCss 鐢ㄤ簬杞藉叆css璧勬簮
- function loadCss(url, async) {
- var node = document.createElement('link');
- node.rel = 'stylesheet';
- node.async = async;
- node.href = url;
- nHead.appendChild(node);
- }
-
- // loadJs 鐢ㄤ簬杞藉叆js璧勬簮
- function loadJs(url, async) {
- var node = document.createElement('script');
- node.charset = 'utf-8';
- node.async = async;
- node.src = url;
- nHead.appendChild(node);
- }
-
- var cssExpr = new RegExp('\\.css');
- function loadResource(url, async) {
- if (cssExpr.test(url)) {
- loadCss(url, async);
- } else {
- loadJs(url, async);
- }
- }
-
- //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
- return {
- getRequest: getRequest,
- getRequestByName: getRequestByName,
- getExplorerInfo: getExplorerInfo,
- isPCBroswer: isPCBroswer,
- clone: clone,
- jsonp: jsonp,
- getWindowSize: getWindowSize,
- getHtml: getHtml,
- loadCss: loadCss,
- loadJs: loadJs,
- loadResource: loadResource
+ function jsonp (url, data, callback) {
+ var jsonp = function (url, data, callback) {
+ var fnSuffix = Math.random().toString().replace('.', '');
+ var cbFuncName = 'my_json_cb_' + fnSuffix;
+ // 涓嶆帹鑽�
+ window[cbFuncName] = callback;
+ var querystring = url.indexOf('?') == -1 ? '?' : '&';
+ for (var key in data) {
+ querystring += key + '=' + data[key] + '&';
+ }
+ querystring += 'callback=' + cbFuncName;
+ var scriptElement = document.createElement('script');
+ scriptElement.src = url + querystring;
+ document.body.appendChild(scriptElement);
};
+ window.$jsonp = jsonp;
+ }
+
+ //鍏叡鏂规硶
+ function getHtml (url, callback) {
+ $.ajax({
+ url: url,
+ type: "GET",
+ dataType: 'html',
+ timeout: 0, //姘镐笉瓒呮椂
+ success: function (data) {
+ callback(data);
+ }
+ });
+ }
+
+ var nHead = document.head || document.getElementsByTagName('head')[0];
+ // loadCss 鐢ㄤ簬杞藉叆css璧勬簮
+ function loadCss (url, async) {
+ var node = document.createElement('link');
+ node.rel = 'stylesheet';
+ node.async = async;
+ node.href = url;
+ nHead.appendChild(node);
+ }
+
+ // loadJs 鐢ㄤ簬杞藉叆js璧勬簮
+ function loadJs (url, async) {
+ var node = document.createElement('script');
+ node.charset = 'utf-8';
+ node.async = async;
+ node.src = url;
+ nHead.appendChild(node);
+ }
+
+ var cssExpr = new RegExp('\\.css');
+ function loadResource (url, async) {
+ if (cssExpr.test(url)) {
+ loadCss(url, async);
+ } else {
+ loadJs(url, async);
+ }
+ }
+
+ //===========瀵瑰鍏紑鐨勫睘鎬у強鏂规硶=========
+ return {
+ getRequest: getRequest,
+ getRequestByName: getRequestByName,
+ getExplorerInfo: getExplorerInfo,
+ isPCBroswer: isPCBroswer,
+ clone: clone,
+ jsonp: jsonp,
+ getWindowSize: getWindowSize,
+ getHtml: getHtml,
+ loadCss: loadCss,
+ loadJs: loadJs,
+ loadResource: loadResource
+ };
})();
\ No newline at end of file
--
Gitblit v1.9.1