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
/** | |
* 反转义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
/** | |
* 替换换行为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
/* | |
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
/** | |
* 给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
/** | |
* 根据 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
var s = '123456'; | |
function reverse (s) { | |
let _s = [...s]; | |
return s ? _s.pop() + reverse(_s.join('')) : ''; | |
} | |
reverse(s); |
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
export default angular.module('dtcloud.directive.pager', []) | |
.factory('Pager', PagerFactory) | |
.directive('pager', PagerDirective) | |
/** | |
* 生成一个适用于 PagerDirective 的对象结构 | |
* @returns {Pager} | |
* @constructor | |
*/ |
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
/** | |
* 根据obj的path获得数据 | |
* @param obj {Object} | |
* @param path {String} | |
* @returns {*} | |
*/ | |
function getValueOfPath(obj, path) { | |
var pathArray = path.split('.') | |
var currentPath = pathArray.shift() |