From d7521e5ac5bce8350c448ae28fb869004ba3222c Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Fri, 21 Nov 2014 18:53:45 +0300 Subject: [PATCH] schedule fixes --- assets/style/schedule.scss | 1 + client/pages/schedule.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/assets/style/schedule.scss b/assets/style/schedule.scss index 77cd169b..a1de5537 100644 --- a/assets/style/schedule.scss +++ b/assets/style/schedule.scss @@ -12,6 +12,7 @@ .schedule{ position: relative; margin: 30px auto 0 auto; + padding-bottom: 50px; text-align: center; table{ diff --git a/client/pages/schedule.js b/client/pages/schedule.js index 268c60ef..2fc0b0b9 100644 --- a/client/pages/schedule.js +++ b/client/pages/schedule.js @@ -4,8 +4,7 @@ const course = require("../../models/course"); module.exports = function (app) { app.controller("ScheduleController", function ($scope, schedule, team) { var now = new Date(); - var day = now.getDay(); - var dates = getDates(day); + var dates = getDates(now); var sem = "late"; $scope.sem = [["early", "весеннего"], ["late", "осеннего"]].reduce(function (s, word) { @@ -67,16 +66,13 @@ function range(start, num, step) { // return new Date(d.setDate(diff)); //} -function getDates(day) { - var dates = []; - var prev = day == 0 ? 0 : day - 1; - var next = 6 - prev; - var dayMask = range(-1, prev, -1).concat([0]).concat(range(1, next, 1)); - - dayMask.forEach(function (m) { - var time = Date.now() + (1000 * 60 * 60 * 24) * m; +function getDates(start) { + var day = start.getDay(); + return range(0, 6, 1).reduce(function (dates, weekDay) { + var d = 1 + weekDay - day; + var time = start.getTime() + (1000 * 60 * 60 * 24) * d; var date = new Date(time); dates.push(date.getDate()); - }); - return dates; + return dates; + }, []); } \ No newline at end of file