Last active
February 18, 2016 12:07
-
-
Save foysalit/74fa7da35655bcf0196a to your computer and use it in GitHub Desktop.
polito libretto parser.
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
(function() { | |
var $table = jQuery('#portlet_container').find('.col-md-12').eq(6).find('table'); | |
var $rows = $table.find('tr'); | |
var Data = []; | |
function buildDate (date) { | |
var parts = date.split("/"); | |
var dt = new Date(parseInt(parts[2], 10), | |
parseInt(parts[1], 10) - 1, | |
parseInt(parts[0], 10)); | |
return dt; | |
} | |
function parser (i, el){ | |
if (i==0 || i>=$rows.length-1) | |
return; | |
var $cols = jQuery(el).find('td'); | |
var marks = $cols.eq(2).text(); | |
var date = buildDate($cols.eq(3).text()); | |
Data.push({ | |
timestamp: date.getTime(), | |
subject: $cols.eq(0).text(), | |
published: date, | |
marks: marks=='superato' ? 30 : parseInt(marks), | |
credits: parseInt($cols.eq(1).text()) | |
}); | |
} | |
$rows.each(parser); | |
console.table(Data); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment