Add prev and next button in timetable
This commit is contained in:
parent
f3ac6e4b7e
commit
ee0a094e3d
3 changed files with 30 additions and 2 deletions
|
@ -48,7 +48,11 @@ router.get("/Default/123456/Lekcja(\.mvc|)/PlanLekcji", (req, res) => {
|
||||||
res.render("opiekun/plan-lekcji", {
|
res.render("opiekun/plan-lekcji", {
|
||||||
title: "Witryna ucznia i rodzica – Paln Lekcji",
|
title: "Witryna ucznia i rodzica – Paln Lekcji",
|
||||||
data: require("../../data/opiekun/plan-lekcji.json"),
|
data: require("../../data/opiekun/plan-lekcji.json"),
|
||||||
weekDays: converter.getWeekDaysFrom(req.query.data)
|
weekDays: converter.getWeekDaysFrom(req.query.data),
|
||||||
|
tics: {
|
||||||
|
prev: converter.getPrevTick(req.query.data),
|
||||||
|
next: converter.getNextTick(req.query.data)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const WEEK_TICK = 6048000000000;
|
||||||
|
|
||||||
function getDateFromTick(tick) {
|
function getDateFromTick(tick) {
|
||||||
if (tick === '' || tick === undefined) {
|
if (tick === '' || tick === undefined) {
|
||||||
return getMonday(new Date());
|
return getMonday(new Date());
|
||||||
|
@ -6,6 +8,10 @@ function getDateFromTick(tick) {
|
||||||
return new Date((tick - 621355968000000000) / 10000);
|
return new Date((tick - 621355968000000000) / 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTickFromDate(date) {
|
||||||
|
return (date.getTime() * 10000) + 621355968000000000;
|
||||||
|
}
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
return date.getDate() + "." + (date.getMonth() + 1) + "." + date.getFullYear();
|
return date.getDate() + "." + (date.getMonth() + 1) + "." + date.getFullYear();
|
||||||
}
|
}
|
||||||
|
@ -35,5 +41,17 @@ function getWeekDaysFrom(tick) {
|
||||||
return days;
|
return days;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPrevTick(tick) {
|
||||||
|
tick = tick ? tick : getTickFromDate(new Date());
|
||||||
|
return parseInt(tick) - WEEK_TICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNextTick(tick) {
|
||||||
|
tick = tick ? tick : getTickFromDate(new Date());
|
||||||
|
return parseInt(tick) + WEEK_TICK;
|
||||||
|
}
|
||||||
|
|
||||||
exports.getDateString = getDateFromTick;
|
exports.getDateString = getDateFromTick;
|
||||||
exports.getWeekDaysFrom = getWeekDaysFrom;
|
exports.getWeekDaysFrom = getWeekDaysFrom;
|
||||||
|
exports.getPrevTick = getPrevTick;
|
||||||
|
exports.getNextTick = getNextTick;
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
extends layout
|
extends layout
|
||||||
|
|
||||||
|
mixin nav
|
||||||
|
.navigation
|
||||||
|
a.button-prev(href="/Default/123456/Lekcja.mvc/PlanLekcji?data=" + tics.prev) Poprzedni tydzień
|
||||||
|
a.button-next(href="/Default/123456/Lekcja.mvc/PlanLekcji?data=" + tics.next) Następny tydzień
|
||||||
|
|
||||||
append content
|
append content
|
||||||
main.mainContainer
|
main.mainContainer
|
||||||
h1 Plan lekcji
|
h1 Plan lekcji
|
||||||
|
+nav
|
||||||
div
|
div
|
||||||
table.presentData
|
table.presentData
|
||||||
thead
|
thead
|
||||||
|
@ -91,7 +97,7 @@ append content
|
||||||
span
|
span
|
||||||
span= day.teacher
|
span= day.teacher
|
||||||
span= day.room
|
span= day.room
|
||||||
|
+nav
|
||||||
|
|
||||||
.description
|
.description
|
||||||
div
|
div
|
||||||
|
|
Loading…
Reference in a new issue