This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 判断对象类型 | |
| * string number array | |
| * object function | |
| * htmldocument | |
| * undefined null | |
| */ | |
| function TypeOf(obj) { | |
| return Object.prototype.toString.call(obj).match(/\s(\w+)/)[1].toLowerCase(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 检测是否为数字 | |
| * 兼容字符类数字 '23' | |
| */ | |
| function isNum(ipt){ | |
| return (ipt !== '') && (ipt == +ipt) ? true : false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 遍历数组 | |
| * | |
| */ | |
| function each(arr,fn){ | |
| //检测输入的值 | |
| if(typeof(arr) == 'object' && typeof(fn) == 'function'){ | |
| var Length = arr.length; | |
| if(Length && Length == +Length){ | |
| for(var i=0;i<Length;i++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isJSON( input ){ | |
| var returns = true; | |
| try{ | |
| JSON.stringify( input ) | |
| } catch ( e ){ | |
| returns = false; | |
| } | |
| return returns; | |
| } | |
| function isSameObj( objA, objB ){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 判断输入值是否为NaN | |
| function isNaN( input ){ | |
| return input !== input; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 加载JS | |
| */ | |
| function LoadScript(url, callback){ | |
| var urls = typeof url === 'string' ? [url] : url; | |
| if (!Array.isArray(urls)){ | |
| throw 'argument type error'; | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //GCJ-02转换BD-09 | |
| function GCJTobaidu($lat, $lng){ | |
| var $v = Math.PI * 3000.0 / 180.0; | |
| var $x = $lng; | |
| var $y = $lat; | |
| var $z = Math.sqrt($x * $x + $y * $y) + 0.00002 * Math.sin($y * $v); | |
| var $t = Math.atan2($y, $x) + 0.000003 * Math.cos($x * $v); | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var randomFlag = (new Date().getTime()*100000 + Math.ceil( Math.random() * 100000 )).toString(36); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 移动数组中指定索引的位置 | |
| function moveItems(arr, indexFrom, indexTo) { | |
| arr.splice(indexTo, 0, arr.splice(indexFrom, 1)[0]); | |
| return arr; | |
| } | |
| moveItems([0,1,2,3,4,5,6,7,8,9],0,7); |
OlderNewer