Skip to content

Instantly share code, notes, and snippets.

@g8up
Last active August 29, 2015 14:26
Show Gist options
  • Save g8up/3eabe158e9f5618ab15e to your computer and use it in GitHub Desktop.
Save g8up/3eabe158e9f5618ab15e to your computer and use it in GitHub Desktop.
这个 React.js 教程的视频专辑竟然没有排序!
/**
* http://www.tudou.com/plcover/ah20h1-t4V4/
* 这个 React.js 教程的视频专辑竟然没有排序!
* @Sigma
*/
JSON.stringify([].slice.call($('h6.caption>a'),0).map(function(a){
var title = $(a).text();
var _match = title.match(/\d+\./);
if( _match && _match.length ){
var index = title.match(/(\d+)\./)[1];
}else{
console.log('title',title);
index = null;
}
var href = a.href;
return {
name: title,
index: index,
href: href
};
}).sort(function(a,b){
return a.index - b.index;
}), null, '\t');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment