move timesince to lib folder

This commit is contained in:
b1ek 2023-02-21 19:59:31 +10:00
parent 3f8d2c60bf
commit 16a80bf80c
3 changed files with 33 additions and 30 deletions

View File

@ -1,34 +1,7 @@
extends layout/main.pug
block root
- var title = 'Guestbook'
-
function TimeSince(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var interval = seconds / 31536000;
if (interval > 1) {
return Math.floor(interval) + " years";
}
interval = seconds / 2592000;
if (interval > 1) {
return Math.floor(interval) + " months";
}
interval = seconds / 86400;
if (interval > 1) {
return Math.floor(interval) + " days";
}
interval = seconds / 3600;
if (interval > 1) {
return Math.floor(interval) + " hours";
}
interval = seconds / 60;
if (interval > 1) {
return Math.floor(interval) + " minutes";
}
return Math.floor(seconds) + " seconds";
}
include lib/since.pug
block head
<link rel='stylesheet' href='/static/ui/send_button.css'>
<link rel='stylesheet' href='/static/ui/gb_ui.css'>

28
view/lib/since.pug Normal file
View File

@ -0,0 +1,28 @@
-
function TimeSince(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var interval = seconds / 31536000;
if (interval > 1) {
return Math.floor(interval) + " years";
}
interval = seconds / 2592000;
if (interval > 1) {
return Math.floor(interval) + " months";
}
interval = seconds / 86400;
if (interval > 1) {
return Math.floor(interval) + " days";
}
interval = seconds / 3600;
if (interval > 1) {
return Math.floor(interval) + " hours";
}
interval = seconds / 60;
if (interval > 1) {
return Math.floor(interval) + " minutes";
}
return Math.floor(seconds) + " seconds";
}

View File

@ -1,6 +1,7 @@
extends ../layout/project.pug
block root
- var title = 'blek! Bin'
include ../lib/since.pug
block append content
h2 blek! Bin
@ -17,5 +18,6 @@ block append content
a(href='https://github.com/hnhx/librebin') Librebin
| , which is built on bare PHP and the code is barely readable or maintainable.
br
| Also, Librebin has only 8 commits and the last commit was on May 30 2022 (at this moment).
| Also, Librebin has only 8 commits and the last commit was on May 30 2022 (at this moment), or
span(style='background:#30303010;padding:2px 4px;border:1px solid #c2c4c2;font-size:10pt;border-radius:8px')
| #{TimeSince(new Date(2022, 6, 30))} ago