Last active
December 20, 2015 12:24
-
-
Save rzymek/06a766f5778b0136eb4d to your computer and use it in GitHub Desktop.
merge all lessons in lnotes
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
$('#words-table tbody tr').remove() | |
var lessons = $('a[href*="/studentView/"]').map((idx,it)=>{return {name:$(it).text(), link:it.href}}).toArray().reverse(); | |
$('.footer').html('') | |
var words=[]; | |
var left=lessons.length | |
lessons.forEach((lesson,idx)=>{ | |
$.get(lesson.link, data => { | |
$('.footer').html(`<div id="fetched_${idx}">${data}</div>`) | |
words[idx]=$(`#fetched_${idx} #words-table tbody tr`).toArray() | |
//.filter(tr => $(tr).find('td').length === 3) | |
.map(tr => tr.outerHTML).join('\n') | |
left--; | |
$(`#fetched_${idx}`).remove(); | |
console.log(`${Math.round(100 - left*100/lessons.length)}%`) | |
if(left===0){ | |
console.log('Merging...') | |
words.forEach((row,idx) => $('#words-table').first() | |
.append(`<tr><th colspan="3">${lessons[idx].name}</th></tr>`) | |
.append(row)); | |
$('.well').remove() | |
$('#words-table tr th:nth-child(3)').remove() | |
$('#words-table tr td:last-child').remove() | |
words=null | |
} | |
}) | |
}); | |
$('ul.nav').remove() | |
$('.page-header').remove() | |
//$('.tabbable').parent().get(0).style.width='100%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment