From 280645d5482a06e84178078f40bf13fd0425a6d4 Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Sun, 21 Jun 2015 17:06:45 +0200 Subject: [PATCH] Added a way to select different tabs. --- resources/jade/schedule.jade | 5 ++++ resources/less/style.less | 44 ++++++++++++++++++++++++++++++++++++ schedule.js | 15 +++++++++--- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/resources/jade/schedule.jade b/resources/jade/schedule.jade index 9ff1739..66b8754 100644 --- a/resources/jade/schedule.jade +++ b/resources/jade/schedule.jade @@ -6,6 +6,11 @@ include search - var days = ['Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag', 'Zondag']; div.schedule + ul + each type in match.json.types + li + span=type.letter + a(href='?tab=' + type.tab)=type.value each day in match.json div.day div.hour.title diff --git a/resources/less/style.less b/resources/less/style.less index 9bf1d9d..fcb4129 100644 --- a/resources/less/style.less +++ b/resources/less/style.less @@ -58,6 +58,50 @@ div.schedule { border: solid 1px #e1e1e1; font-family: Open Sans; + ul { + margin: 0; + padding: 0; + list-style: none; + text-align: right; + background-color: #e1e1e1; + + li { + width: 25px; + height: 25px; + color: #FFF; + font-family: Oswald; + text-align: center; + display: inline-block; + overflow: hidden; + -webkit-transition: 1s ease; + + &:hover { + -webkit-transition: 1s ease; + width: 160px; + } + + &:first-child span { + background-color: #0C5489; + } + + &:last-child span { + background-color: #C41824; + } + + span { + width: 25px; + height: 25px; + display: inline-block; + background-color: #96aa48; + } + + a { + text-decoration: none; + color: #000; + } + } + } + div.day { float: left; diff --git a/schedule.js b/schedule.js index 69e8e23..4ab6552 100644 --- a/schedule.js +++ b/schedule.js @@ -28,13 +28,20 @@ function get(url, callback) { function schedule_types(page) { var extract = cheerio('table tr td[valign="bottom"] table tr td b, table tr td[valign="bottom"] table tr td a', page).text().split(/\s\s/); + var tab = 0; var types = []; for (element of extract) { - element != '' ? types.push(element) : null; + element != '' ? types.push({ + 'letter': element.substr(0, 1), + 'value' : element.match(/.*(?:rooster)|t\/m|\d\d\s\w{3}/g).join(' ').slice(1).replace(/rooster/, ''), + 'tab': tab++ + }) : null; } - - return types + + console.log(types); + + return types; } //Function for converting the page into a json dataset. @@ -72,6 +79,8 @@ function to_json(page) { } } + schedule_data.types = types; + return schedule_data; }