Einheiten dazu - WIP **

This commit is contained in:
rxf
2023-05-14 13:23:22 +02:00
parent 61763de397
commit c51fc0ea0a
5 changed files with 50 additions and 9 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "Spritzschema",
"version": "0.0.1",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "Spritzschema",
"version": "0.0.1",
"version": "1.0.0",
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",

View File

@@ -1,7 +1,7 @@
{
"name": "Spritzschema",
"version": "1.0.0",
"date": "2023-05-07",
"version": "1.1.0",
"date": "2023-05-13",
"private": true,
"scripts": {
"start": "node ./bin/www >>/var/log/spritzschema.log 2>&1"

View File

@@ -2,6 +2,9 @@ document.addEventListener('DOMContentLoaded', async function () {
const DateTime = luxon.DateTime
const DEFEINHEIT = 8
let curEinheit = 0
if (sysParams.doinit) {
await initSchema('2023-05-01')
}
@@ -11,6 +14,7 @@ document.addEventListener('DOMContentLoaded', async function () {
fillSchema(schema)
document.querySelector('#sptab').addEventListener('click', markField);
document.querySelector('#einheiten').addEventListener('change', enterEinheit);
async function markField (e) {
let field = e.target;
@@ -26,6 +30,22 @@ document.addEventListener('DOMContentLoaded', async function () {
}
}
async function enterEinheit (e) {
let field = e.target;
let d = schema.data[34].day
schema.data[parseInt(field.id.slice(2))-1].einheit = field.value
await storeData(schema)
}
function buildCellHtml(day, einheit) {
let x = `${day.toFormat('d')}
<div id="lowline" class="small">
<div>${day.setLocale('de').toFormat('ccc')}</div>
<div>${einheit !== 0 ? einheit : ''}</div>
</div>`
return x
}
function fillSchema(schema) {
const setArray = schema.data
let months = ''
@@ -43,9 +63,7 @@ document.addEventListener('DOMContentLoaded', async function () {
let sel = '#bt'+(i+1)
let day = DateTime.fromISO(setArray[i].day)
if (setArray[i].day !== '') {
let x = `${day.toFormat('d')}
<br /><span class="small">${day.setLocale('de').toFormat('ccc')}</span>`
document.querySelector(sel).innerHTML = x
document.querySelector(sel).innerHTML = buildCellHtml(day, setArray[i].einheit)
if (setArray[i].status) {
document.querySelector(sel).setAttribute('aria-label', 'x')
document.querySelector(sel).setAttribute('disabled', 'disabled')
@@ -56,6 +74,9 @@ document.addEventListener('DOMContentLoaded', async function () {
} else {
document.querySelector(sel).setAttribute('disabled', 'disabled')
}
if(setArray[i].einheit !== 0) {
document.getElementById("einheiten").value = setArray[i].einheit
}
}
}
@@ -84,6 +105,7 @@ document.addEventListener('DOMContentLoaded', async function () {
let k = 0
for(let i = 0; i < 35; i++) {
let elem = {status: false}
elem.einheit = curEinheit
if (i === 17) {
elem.day = ''
} else {

View File

@@ -50,6 +50,17 @@ a {
color: gray;
}
#infeld {
width: 91vmin;
margin: auto;
font-size: 200%;
}
#einheiten {
font-size: 130%;
margin-left: 30px;
}
footer {
width: 91vmin;
margin: auto;
@@ -58,3 +69,8 @@ footer {
text-align: right;
margin-top: 30px;
}
#lowline {
display: flex;
justify-content: space-between;
}

View File

@@ -44,3 +44,6 @@ block content
button#bt33
button#bt34
button#bt35
#infeld
label(for="einheiten") Einheiten:
input#einheiten(type="number" min="0" max="100" value="0")