feat: Add showseconds=false URL parameter.
This commit is contained in:
24
main.js
24
main.js
@@ -1,6 +1,7 @@
|
|||||||
let scrolling = false;
|
let scrolling = false;
|
||||||
let primaryAnimation, secondaryAnimation;
|
let primaryAnimation, secondaryAnimation;
|
||||||
let focusing = {};
|
let focusing = {};
|
||||||
|
let showseconds = true;
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
importStyles();
|
importStyles();
|
||||||
@@ -102,6 +103,8 @@ class ReconnectingWebSocket {
|
|||||||
function communicate(websocket) {
|
function communicate(websocket) {
|
||||||
console.log("Communicating");
|
console.log("Communicating");
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
showseconds = !(params.get('showseconds') === 'false');
|
||||||
|
|
||||||
|
|
||||||
websocket.onopen = () => {
|
websocket.onopen = () => {
|
||||||
websocket.send(
|
websocket.send(
|
||||||
@@ -109,7 +112,7 @@ function communicate(websocket) {
|
|||||||
{
|
{
|
||||||
type: "init",
|
type: "init",
|
||||||
channel: "HyperFocus",
|
channel: "HyperFocus",
|
||||||
community: params.get('community')
|
community: "1"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -176,8 +179,8 @@ function renderList() {
|
|||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
let infos = Object.values(focusing);
|
let infos = Object.values(focusing);
|
||||||
infos.sort((info1, info2) => (info2.end_at - info1.end_at));
|
infos.sort((info1, info2) => (info2.end_at - info1.end_at));
|
||||||
console.log(infos);
|
// console.log(infos);
|
||||||
console.log(focusing);
|
// console.log(focusing);
|
||||||
|
|
||||||
containers.forEach(function (tasklist) {
|
containers.forEach(function (tasklist) {
|
||||||
tasklist.innerHTML = "";
|
tasklist.innerHTML = "";
|
||||||
@@ -233,11 +236,16 @@ function formatDur(duration) {
|
|||||||
var hours = Math.floor(minutes / 60);
|
var hours = Math.floor(minutes / 60);
|
||||||
minutes = minutes - 60 * hours;
|
minutes = minutes - 60 * hours;
|
||||||
|
|
||||||
if (hours > 0) {
|
var hrstr = String(hours).padStart(2, '0');
|
||||||
return String(hours).padStart(2, '0') + ':' + String(minutes).padStart(2, '0') + ':' + String(seconds).padStart(2, '0')
|
var minstr = String(minutes).padStart(2, '0');
|
||||||
} else {
|
var secstr = String(seconds).padStart(2, '0');
|
||||||
return String(minutes).padStart(2, '0') + ':' + String(seconds).padStart(2, '0')
|
|
||||||
}
|
let parts = [];
|
||||||
|
(!showseconds || hours > 0) && parts.push(hrstr);
|
||||||
|
parts.push(minstr);
|
||||||
|
(showseconds) && parts.push(secstr);
|
||||||
|
|
||||||
|
return parts.join(':')
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTimers() {
|
function updateTimers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user