From e59a1c40215c3c6b109d355799e1f23f7fed5b32 Mon Sep 17 00:00:00 2001 From: Max Lipsky Date: Mon, 15 Aug 2016 11:27:53 +0300 Subject: [PATCH 1/8] Extend hours limit up to 24 twenty-four hours --- app/scripts/plugin.js | 8 ++++---- dist/scripts/timetable.js | 8 ++++---- dist/scripts/timetable.min.js | 2 +- test/spec/plugin.js | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/scripts/plugin.js b/app/scripts/plugin.js index c7ecb6a..296600f 100644 --- a/app/scripts/plugin.js +++ b/app/scripts/plugin.js @@ -29,7 +29,7 @@ Timetable.Renderer = function(tt) { return number === parseInt(number, 10); } function isInHourRange(number) { - return number >= 0 && number < 24; + return number >= 0 && number < 25; } function locationExistsIn(loc, locs) { return locs.indexOf(loc) !== -1; @@ -40,7 +40,7 @@ Timetable.Renderer = function(tt) { return correctTypes && correctOrder; } function getDurationHours(startHour, endHour) { - return endHour >= startHour ? endHour - startHour : 24 + endHour - startHour; + return endHour >= startHour ? endHour - startHour : 25 + endHour - startHour; } Timetable.prototype = { @@ -49,7 +49,7 @@ Timetable.Renderer = function(tt) { this.scope.hourStart = start; this.scope.hourEnd = end; } else { - throw new RangeError('Timetable scope should consist of (start, end) in whole hours from 0 to 23'); + throw new RangeError('Timetable scope should consist of (start, end) in whole hours from 0 to 24'); } return this; @@ -150,7 +150,7 @@ Timetable.Renderer = function(tt) { if (hour === timetable.scope.hourEnd && (timetable.scope.hourStart !== timetable.scope.hourEnd || looped)) { completed = true; } - if (++hour === 24) { + if (++hour === 25) { hour = 0; looped = true; } diff --git a/dist/scripts/timetable.js b/dist/scripts/timetable.js index c7ecb6a..296600f 100644 --- a/dist/scripts/timetable.js +++ b/dist/scripts/timetable.js @@ -29,7 +29,7 @@ Timetable.Renderer = function(tt) { return number === parseInt(number, 10); } function isInHourRange(number) { - return number >= 0 && number < 24; + return number >= 0 && number < 25; } function locationExistsIn(loc, locs) { return locs.indexOf(loc) !== -1; @@ -40,7 +40,7 @@ Timetable.Renderer = function(tt) { return correctTypes && correctOrder; } function getDurationHours(startHour, endHour) { - return endHour >= startHour ? endHour - startHour : 24 + endHour - startHour; + return endHour >= startHour ? endHour - startHour : 25 + endHour - startHour; } Timetable.prototype = { @@ -49,7 +49,7 @@ Timetable.Renderer = function(tt) { this.scope.hourStart = start; this.scope.hourEnd = end; } else { - throw new RangeError('Timetable scope should consist of (start, end) in whole hours from 0 to 23'); + throw new RangeError('Timetable scope should consist of (start, end) in whole hours from 0 to 24'); } return this; @@ -150,7 +150,7 @@ Timetable.Renderer = function(tt) { if (hour === timetable.scope.hourEnd && (timetable.scope.hourStart !== timetable.scope.hourEnd || looped)) { completed = true; } - if (++hour === 24) { + if (++hour === 25) { hour = 0; looped = true; } diff --git a/dist/scripts/timetable.min.js b/dist/scripts/timetable.min.js index 8ee4fab..88022e9 100644 --- a/dist/scripts/timetable.min.js +++ b/dist/scripts/timetable.min.js @@ -1 +1 @@ -"use strict";var Timetable=function(){this.scope={hourStart:9,hourEnd:17},this.locations=[],this.events=[]};Timetable.Renderer=function(t){if(!(t instanceof Timetable))throw new Error("Initialize renderer using a Timetable");this.timetable=t},function(){function t(t,n){return e(t)&&e(n)}function e(t){return n(t)&&o(t)}function n(t){return t===parseInt(t,10)}function o(t){return t>=0&&t<24}function r(t,e){return e.indexOf(t)!==-1}function i(t,e){var n=t instanceof Date&&e instanceof Date,o=t=t?e-t:24+e-t}function c(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function s(t){var e=t<10?"0":"";return e+t+":00"}Timetable.prototype={setScope:function(e,n){if(!t(e,n))throw new RangeError("Timetable scope should consist of (start, end) in whole hours from 0 to 23");return this.scope.hourStart=e,this.scope.hourEnd=n,this},addLocations:function(t){function e(){return t instanceof Array}var n=this.locations;if(!e())throw new Error("Tried to add locations in wrong format");return t.forEach(function(t){if(r(t,n))throw new Error("Location already exists");n.push(t)}),this},addEvent:function(t,e,n,o,a){if(!r(e,this.locations))throw new Error("Unknown location");if(!i(n,o))throw new Error("Invalid time range: "+JSON.stringify([n,o]));var c="[object Object]"===Object.prototype.toString.call(a);return this.events.push({name:t,location:e,startDate:n,endDate:o,options:c?a:void 0}),this}},Timetable.Renderer.prototype={draw:function(t){function e(t){if(null===t)throw new Error("Timetable container not found")}function n(t){var e=t.appendChild(document.createElement("aside")),n=e.appendChild(document.createElement("ul"));o(n)}function o(t){for(var e=0;e=0&&t<25}function r(t,e){return e.indexOf(t)!==-1}function i(t,e){var n=t instanceof Date&&e instanceof Date,o=t=t?e-t:25+e-t}function c(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function s(t){var e=t<10?"0":"";return e+t+":00"}Timetable.prototype={setScope:function(e,n){if(!t(e,n))throw new RangeError("Timetable scope should consist of (start, end) in whole hours from 0 to 24");return this.scope.hourStart=e,this.scope.hourEnd=n,this},addLocations:function(t){function e(){return t instanceof Array}var n=this.locations;if(!e())throw new Error("Tried to add locations in wrong format");return t.forEach(function(t){if(r(t,n))throw new Error("Location already exists");n.push(t)}),this},addEvent:function(t,e,n,o,a){if(!r(e,this.locations))throw new Error("Unknown location");if(!i(n,o))throw new Error("Invalid time range: "+JSON.stringify([n,o]));var c="[object Object]"===Object.prototype.toString.call(a);return this.events.push({name:t,location:e,startDate:n,endDate:o,options:c?a:void 0}),this}},Timetable.Renderer.prototype={draw:function(t){function e(t){if(null===t)throw new Error("Timetable container not found")}function n(t){var e=t.appendChild(document.createElement("aside")),n=e.appendChild(document.createElement("ul"));o(n)}function o(t){for(var e=0;e Date: Mon, 15 Aug 2016 16:35:46 +0300 Subject: [PATCH 2/8] Remove whitespace, add tabs --- app/styles/demo.sass | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/styles/demo.sass b/app/styles/demo.sass index a56cfca..ffac001 100644 --- a/app/styles/demo.sass +++ b/app/styles/demo.sass @@ -1,8 +1,8 @@ body - background: #fcfcfc - font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif - color: #333 - font-size: 15px + background: #fcfcfc + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif + color: #333 + font-size: 15px a text-decoration: none From 707214459a59b66ec9caf8fc0ac49b80115394de Mon Sep 17 00:00:00 2001 From: Max Lipsky Date: Mon, 15 Aug 2016 16:37:12 +0300 Subject: [PATCH 3/8] Change .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 09b97a6..e15288e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ bower_components #Icon? ehthumbs.db Thumbs.db +app/styles/*.css +app/styles/*.css.map \ No newline at end of file From c8158425476d4b8411b17562c0f29f68116f36b2 Mon Sep 17 00:00:00 2001 From: Max Lipsky Date: Mon, 15 Aug 2016 16:39:39 +0300 Subject: [PATCH 4/8] Extend Locations Header --- app/demo.html | 14 ++++++++++++-- app/scripts/plugin.js | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/demo.html b/app/demo.html index 197ae0c..0ae8da2 100644 --- a/app/demo.html +++ b/app/demo.html @@ -28,9 +28,19 @@

Timetable.js demo