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
/** | |
* 根据 rangeNum 过滤掉超出的平均值的数值 | |
* @param arr | |
* @param rangeNum | |
* @returns Array | |
*/ | |
function clearMean (arr, rangeNum) { | |
arr = arr.concat().sort(); | |
var middleNum = arr[Math.ceil(arr.length / 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
/** | |
* 给url额外添加参数 | |
* @param url | |
* @param {object} params 要添加的参数 | |
* @returns {*|Element} | |
*/ | |
function patchUrlParams (url, params) { | |
var a = document.createElement('a'); | |
var _params = {}; |
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 script = document.createElement('script'); | |
var p1 = encodeURIComponent("$('#data_list tr').find('td:eq(2) a')"); | |
var p2 = encodeURIComponent('.intro img'); | |
script.src = `https://rawgit.com/think2011/53fe08923ced04f10ca0/raw/4bad14cd67c835306d93a01b5ea377fe354081d1/previewPic.js?${p1}&${p2}`; | |
document.body.appendChild(script); | |
*/ | |
jsReady(() => { |
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
/** | |
* 替换换行为XX | |
* @param str | |
* @param replaceStr | |
* @returns String | |
*/ | |
function replaceNewLine (str, replaceStr) { | |
return str.replace(/(\r\n|\r|\n)/g, replaceStr); | |
} |
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
/** | |
* 反转义HTML | |
* @param str | |
* @returns {string} | |
*/ | |
function decodeHtml (str) { | |
var temp = document.createElement('div'); | |
temp.innerHTML = str; | |
return temp.innerText; |
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
// by value | |
var list = {"you": 100, "me": 75, "foo": 116, "bar": 15}; | |
var keysSorted = Object.keys(list).sort(function (a, b) { | |
return list[a] - list[b] | |
}); | |
console.log(keysSorted); | |
// by key | |
var list = {100: "you", 75: "me", 116: "foo", 15: "bar"}; |
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
/** | |
* 转换为整数 | |
* @returns {this} | |
*/ | |
Number.prototype.toInt = function () { | |
return isNaN(this) ? 0 : parseInt(this); | |
}; |
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
/** | |
* 触发事件 | |
* @param element | |
* @param event | |
* @returns {boolean} | |
*/ | |
function fireEvent (element, event) { | |
var evt; | |
if (document.createEventObject) { |
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
/** | |
* 从全局捕获错误 | |
* @param errMsg | |
* @param scriptURI | |
* @param lineNumber | |
* @param columnNumber | |
* @param errorObj | |
* @return | |
*/ | |
window.onerror = function (errMsg, scriptURI, lineNumber, columnNumber, errorObj) { |