diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-18 09:26:04 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-18 09:26:04 +0000 |
commit | f9a3f400d04a4d0c8d8dccc42028a56181a8c9d5 (patch) | |
tree | d95e6243d484a6d64f3c45d81d7170899dc65d34 | |
parent | 6565e14d2459b81961e5a605b2691ea54cbe7256 (diff) | |
download | sariulclocks-f9a3f400d04a4d0c8d8dccc42028a56181a8c9d5.tar.gz |
implement lucky number
-rw-r--r-- | assets/js/main.js | 3 | ||||
-rw-r--r-- | src/Types/Session.hs | 12 | ||||
-rw-r--r-- | src/sariulclocks.hs | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/assets/js/main.js b/assets/js/main.js index b79de74..04dee03 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -178,7 +178,8 @@ toggleDateStyle(); function luckyNumber() { - alert("not yet"); + var students = parseInt(readCookie("ss_cookie")); + alert(getRandomInt(1, students)); } // toggle the count-down and count-up clocks diff --git a/src/Types/Session.hs b/src/Types/Session.hs index a4dba93..5d037a4 100644 --- a/src/Types/Session.hs +++ b/src/Types/Session.hs @@ -41,6 +41,18 @@ makeClockCookie now session = , cookiePath = Nothing , cookieSecure = False} +makeSsCookie :: ClockTime -> Session -> Cookie +makeSsCookie now session = + Cookie { cookieName = "ss_cookie" + , cookieValue = + case currentClass session of + Nothing -> "0" + Just c -> show $ numberOfSs c + , cookieExpires = Just $ endOfSchoolDay now + , cookieDomain = Nothing + , cookiePath = Nothing + , cookieSecure = False} + endOfSchoolDay :: ClockTime -> CalendarTime endOfSchoolDay now = (toUTCTime . addToClockTime noTimeDiff { tdHour = hoursTilEndOfDay }) now where diff --git a/src/sariulclocks.hs b/src/sariulclocks.hs index e3ac20e..74ae00c 100644 --- a/src/sariulclocks.hs +++ b/src/sariulclocks.hs @@ -173,6 +173,7 @@ cgiMain = do setCookie $ makeClassCookie clockTime newSession setCookie $ makeClockCookie clockTime newSession + setCookie $ makeSsCookie clockTime newSession -- let html' = html +++ show points' +++ show timeWasted' |