Fixed offset problem with teachers
This commit is contained in:
parent
1ab02bc6ae
commit
46992803e1
|
@ -13,9 +13,10 @@ div.schedule
|
||||||
each hour in day
|
each hour in day
|
||||||
if hour.teacher != 'vrij\r'
|
if hour.teacher != 'vrij\r'
|
||||||
div.hour(class=hour.changed == 'true' ? 'changed' : '')
|
div.hour(class=hour.changed == 'true' ? 'changed' : '')
|
||||||
span.teacher= hour.teacher
|
each subhour in hour.teacher
|
||||||
span.chamber= hour.chamber
|
span.teacher(class='sub_' + hour.teacher.length)= hour.teacher[hour.teacher.indexOf(subhour)]
|
||||||
span.course= hour.course
|
span.chamber(class='sub_' + hour.teacher.length)= hour.chamber[hour.teacher.indexOf(subhour)]
|
||||||
|
span.course(class='sub_' + hour.teacher.length)= hour.course[hour.teacher.indexOf(subhour)]
|
||||||
|
|
||||||
if match.json.indexOf(day) == 0
|
if match.json.indexOf(day) == 0
|
||||||
span.time= times[match.json[0].indexOf(hour)]
|
span.time= times[match.json[0].indexOf(hour)]
|
||||||
|
|
|
@ -73,6 +73,11 @@ div.schedule {
|
||||||
span {
|
span {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 33%;
|
width: 33%;
|
||||||
|
|
||||||
|
&.sub_2 {
|
||||||
|
position: relative;
|
||||||
|
top: -15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.teacher {
|
.teacher {
|
||||||
|
|
|
@ -29,18 +29,21 @@ function get(url, callback) {
|
||||||
//Function for converting the page into a json dataset.
|
//Function for converting the page into a json dataset.
|
||||||
function to_json(page) {
|
function to_json(page) {
|
||||||
var result = cheerio('td:nth-child(3) table', page);
|
var result = cheerio('td:nth-child(3) table', page);
|
||||||
|
var is_teacher = cheerio(cheerio(page).find('tr.CoreDark').find('td')[3]).find('a').html() == null;
|
||||||
var amount_of_days = cheerio(result).find('tr.AccentDark').find('td').length - 1;
|
var amount_of_days = cheerio(result).find('tr.AccentDark').find('td').length - 1;
|
||||||
var amount_of_hours = config().amount_of_hours;
|
var amount_of_hours = config().amount_of_hours;
|
||||||
|
|
||||||
var schedule_data = [];
|
var schedule_data = [];
|
||||||
|
|
||||||
|
var offset = is_teacher ? 5 : 6;
|
||||||
|
|
||||||
//Looping for amount of days
|
//Looping for amount of days
|
||||||
for (day = 0; day < amount_of_days; day++) {
|
for (day = 0; day < amount_of_days; day++) {
|
||||||
schedule_data[day] = [];
|
schedule_data[day] = [];
|
||||||
|
|
||||||
//Looping for amount of hours
|
//Looping for amount of hours
|
||||||
for (hour = 0; hour < amount_of_hours; hour++) {
|
for (hour = 0; hour < amount_of_hours; hour++) {
|
||||||
var schedule = cheerio('tr:nth-child('+ (6 + hour) +')', result);
|
var schedule = cheerio('tr:nth-child('+ (offset + hour) +')', result);
|
||||||
|
|
||||||
//Looping for (optional) specialhours
|
//Looping for (optional) specialhours
|
||||||
var amount_of_special_hours = schedule.find('table').eq(day).children().length;
|
var amount_of_special_hours = schedule.find('table').eq(day).children().length;
|
||||||
|
|
Loading…
Reference in a new issue