From 6a082e41560cde7a643574e94676eb0d0d52667b Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Thu, 13 Aug 2015 21:32:02 +0200 Subject: [PATCH] Added module for giving the time to the system. --- resources/jade/header.jade | 7 +++---- time.js | 17 +++++++++++++++++ web.js | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 time.js diff --git a/resources/jade/header.jade b/resources/jade/header.jade index 44385b4..5fa16e5 100644 --- a/resources/jade/header.jade +++ b/resources/jade/header.jade @@ -13,7 +13,7 @@ html script(type="text/javascript", src="/js/script.js") script(type="text/javascript"). (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-46880644-1', 'werkmanrooster.nl');ga('send', 'pageview');ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; - body + body(class=app.locals.time.get() > 20.5 ? 'night' : '') div.bar if headers.user ul.left @@ -26,15 +26,14 @@ html li | li a(href="/klassenlijst/#{headers.user.group}") Jouw Klassenlijst - + ul.right li a(href="/logout") Logout li | li a(href="http://git.werkmanrooster.nl/werkmanrooster/rooster-io.git", target="_blank") Recente ontwikkelingen - - + else ul li diff --git a/time.js b/time.js new file mode 100644 index 0000000..43f232d --- /dev/null +++ b/time.js @@ -0,0 +1,17 @@ +//time.js + +//Function for getting the time, with minutes as a fracture. +function get() { + var time = new Date(); + return time.getHours() + (time.getMinutes() / 60); +} + +//Function for parsing and checking if the currrent time is within the parsed string. +function within_timespan(timespan) { + +} + +module.exports = { + 'get': get, + 'within_timespan': within_timespan +} diff --git a/web.js b/web.js index f82b406..9b141ee 100644 --- a/web.js +++ b/web.js @@ -10,6 +10,7 @@ var lookup = require('./lookup'); var schedule = require('./schedule'); var auth = require('./auth'); var redirecter = require('./redirecter'); +var time = require('./time'); var app = express(); @@ -21,6 +22,7 @@ app.set('views', __dirname + '/resources/jade'); //Give the app some configuration information app.locals.linkbar = config().linkbar; app.locals.hour_times = config().hour_times; +app.locals.time = time; //Set up all static directories for getting resources. app.use('/css', less(__dirname + '/resources/less'));