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 getImgContainToRectConfig (outerWidth, outerHeight, imgWidth, imgHeight) => { | |
| let newWidth = outerWidth; | |
| let newHeight = outerWidth * imgHeight / imgWidth; | |
| if (newHeight > outerHeight) { | |
| newHeight = outerHeight; | |
| newWidth = outerHeight * imgWidth / imgHeight; | |
| } | |
| return { | |
| top: (outerHeight - newHeight) / 2, | |
| left: (outerWidth - newWidth) / 2, |
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 preventDefault (event) { | |
| window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty() | |
| event.preventDefault && event.preventDefault() | |
| event.stopPropagation && event.stopPropagation() | |
| } | |
| function getParam(clientX, clientY, startX, startY) { | |
| let xOffset = clientX - startX | |
| let yOffset = clientY - startY | |
| 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
| function escapeHtml(code) { | |
| var escapeMap = { | |
| "&": "&", | |
| "<": "<", | |
| ">": ">", | |
| '"': """, | |
| "'": "'", | |
| "`": "`" | |
| }; | |
| var escaper = function (match) { |
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 isMobile(agent) { | |
| return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent); | |
| }; |
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); |
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
| //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
| /** | |
| * 加载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
| // 判断输入值是否为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
| function isJSON( input ){ | |
| var returns = true; | |
| try{ | |
| JSON.stringify( input ) | |
| } catch ( e ){ | |
| returns = false; | |
| } | |
| return returns; | |
| } | |
| function isSameObj( objA, objB ){ |
NewerOlder