Skip to content

Instantly share code, notes, and snippets.

@abhisekp
Last active October 22, 2015 13:46
Show Gist options
  • Save abhisekp/5b1ae052cf9105b3f2ff to your computer and use it in GitHub Desktop.
Save abhisekp/5b1ae052cf9105b3f2ff to your computer and use it in GitHub Desktop.
Sitepoint Courses - URL Generator
function URL(url, title) {
this.url = url;
this.title = title || url;
}
var contents = $('.Contents');
// console.log(contents);
var contentRow = contents.children('.Contents_row');
var urls = [];
contentRow.each(function (ind, row) {
// console.log(row);
var title = $(row).children('.Contents_title').html().trim();
var url = $(row).children('.Contents_actions').children('.Contents_button');
//console.log(url);
if(url && url[0]) {
//console.log(url[0]);
url = url[0].getAttribute('href');
//url = url[0].getAttribute('href');
urls.push(new URL(url, title));
}
});
urls.forEach(function (url) {
console.log(url.url);
});
urls.forEach(function (url) {
console.log(url.title);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment