Created
December 28, 2011 03:37
-
-
Save yuanchuan/1526075 to your computer and use it in GitHub Desktop.
get spark list
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
//bad | |
var sequence = (function(data, temp){ | |
var len = data.length - 1; | |
for (var i = 0; i < len; ++i) { | |
temp.push(data[i+1] - data[i]); | |
} | |
return temp.join(','); | |
})((function(all, buf, user){ | |
var len = all.length; | |
while (user = all[--len]) { | |
buf.push(~~user.innerHTML.split('<br>')[2].split(':')[1]); | |
} | |
return buf.sort(function(a,b){ | |
return a-b | |
}); | |
}(document.getElementsByTagName('li'), [])), []); |
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
// good | |
var sequence = (function(i, len) { | |
var list = [].slice.call( | |
document.getElementsByTagName('li') | |
), | |
buf = [], | |
seq = []; | |
for (i = 0, len = list.length; i < len; ++i) { | |
buf.push(~~list[i].innerHTML.split('<br>')[2].split(':')[1]); | |
}; | |
buf = buf.sort(function(a,b){ | |
return a - b; | |
}); | |
for (i = 0, len = buf.length-1; i < len; ++i) { | |
seq.push(buf[i+1] - buf[i]); | |
} | |
return seq.toString(); | |
}()); |
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
"2,1,1,1,1,1,1,2,1,5,1,1,1,3,1,1,1,1,1,2,1,2,3,4,2,2,1,3,1,1,1,1,3,4,4,4,1,1,1,1,1,1,1,6,1,1,1,3,5,1,1,4,2,8,4,3,2,1,3,1,4,3,8,6,1,2,6,2,1,2,1,2,3,1,7,4,5,3,4,2,3,2,1,1,1,21,1,6,4,2,2,2,1,1,2,7,2,1,3,2,2,1,1,1,1,1,1,1,1,1,5,1,2,3,2,2,2,1,1,2,2,2,2,1,3,2,1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment