Last active
August 29, 2015 14:26
-
-
Save g8up/3eabe158e9f5618ab15e to your computer and use it in GitHub Desktop.
这个 React.js 教程的视频专辑竟然没有排序!
This file contains 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
/** | |
* 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