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 unique_keys(array) { | |
var values = {}; | |
for(var i = 0; i < array.length; i++) { | |
values[array[i]] = null; | |
} | |
return Object.keys(values); | |
} |
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
{"status":"error","error":{"msg":"\u6b64\u997f\u5355\u5df2\u6295\u8bc9","code":23}} |
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 parser = function(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
var search = function(search) { | |
if(!search) return {}; | |
var ret = {}; | |
search = search.slice(1).split('&'); | |
for(var i = 0, arr; i < search.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
$.fn.ciao = function() { | |
console.log('没事爱瞎bb'); | |
return this; | |
}; | |
// 这样执行 | |
$().ciao().ciao().ciao(); |
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
angular.$ = angular.element; | |
// jqLite `.parent([selector])` 支持 selector | |
angular.$.prototype.parent = function(sel) { | |
if(!sel) return angular.$(this[0].parentNode); | |
var list = [].slice.call(document.querySelectorAll(sel)) | |
, currentNode = this[0] | |
, ret; | |
while(currentNode.nodeName !== 'HTML') { |
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 girl_said = 'Girl: 不爱理你' | |
, programmer_s_prattle = 'Programmer: 我喜欢... 你'; | |
console.log(girl_said); | |
girl_said = girl_said.replace(/(?:with\_love)?(不|理)/g, function(ignore) { | |
// said in heart | |
console.log(programmer_s_prattle); | |
return ignore = ''; | |
}) |
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 names = [], emails = [], result = []; | |
var value = function(nodeList, target){ | |
[].slice.call(nodeList).forEach(function(item){ | |
target.push(item.textContent); | |
}); | |
return target.slice(1); | |
}; | |
var select = function(selector){ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
// firefox 和 chrome 是 [1024, 6, 5, 3, 2, 1] | |
// safari 中顺序没变 | |
[1,3,2,5,6,1024].sort(function(a, b) { | |
return b > a; | |
}); | |
// 在各中浏览器工作一致的方法 | |
// 用正负和零来排序,而不是 true/false | |
[1,3,2,5,6,1024].sort(function(a, b) { |