Skip to content

Commit 31e8acb

Browse files
committed
Remove common.js (fix #99)
1 parent 638b5a3 commit 31e8acb

File tree

9 files changed

+117
-43
lines changed

9 files changed

+117
-43
lines changed

data/cfg.html

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
<meta name="viewport" content="width=device-width, initial-scale=1">
1010
<link rel="stylesheet" href="web.css">
11-
<script src="common.js" type="module"></script>
1211
<script src="cfg.js" type="module"></script>
1312

1413
<meta name="theme-color" content="#6a6a6a">

data/cfg.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,35 @@
77
// Parameter werden nicht hier geändert.
88
// ----------------------------------------------------------------------------------
99

10-
import {initNavBar} from './common.js';
10+
// ----------------------------- COMMON SECTION: START ------------------------------
11+
function initNavBar() {
12+
for (const element of document.querySelectorAll('[top-nav-link]')) {
13+
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
14+
}
15+
}
16+
17+
function assignValuesToHtml(values) {
18+
let valueContainerElements = document.querySelectorAll('[data-value]');
19+
for (const element of valueContainerElements) {
20+
const key = element.getAttribute('data-value');
21+
if (values[key] !== undefined) {
22+
element.innerHTML = values[key].toLocaleString('de-DE');
23+
}
24+
}
25+
}
26+
27+
function setClass(element, className, state) {
28+
if (state) {
29+
element.classList.add(className)
30+
} else {
31+
element.classList.remove(className)
32+
}
33+
}
34+
35+
function setSectionVisibility(sectionId, isVisible) {
36+
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
37+
}
38+
// ----------------------------- COMMON SECTION: END ------------------------------
1139

1240
// Default settings 22.05.2023
1341
const defaultObj = JSON.parse(

data/common.js

-31
This file was deleted.

data/log.html

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
<meta name="viewport" content="width=device-width, initial-scale=1">
1010
<link rel="stylesheet" href="web.css">
11-
<script src="common.js" type="module"></script>
1211
<script src="log.js" type="module"></script>
1312

1413
<meta name="theme-color" content="#6a6a6a">

data/log.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
// Copyright (c) 2023 steff393, MIT license
22

3-
import {initNavBar} from './common.js';
3+
// ----------------------------- COMMON SECTION: START ------------------------------
4+
function initNavBar() {
5+
for (const element of document.querySelectorAll('[top-nav-link]')) {
6+
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
7+
}
8+
}
9+
10+
function assignValuesToHtml(values) {
11+
let valueContainerElements = document.querySelectorAll('[data-value]');
12+
for (const element of valueContainerElements) {
13+
const key = element.getAttribute('data-value');
14+
if (values[key] !== undefined) {
15+
element.innerHTML = values[key].toLocaleString('de-DE');
16+
}
17+
}
18+
}
19+
20+
function setClass(element, className, state) {
21+
if (state) {
22+
element.classList.add(className)
23+
} else {
24+
element.classList.remove(className)
25+
}
26+
}
27+
28+
function setSectionVisibility(sectionId, isVisible) {
29+
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
30+
}
31+
// ----------------------------- COMMON SECTION: END ------------------------------
432

533
window.addEventListener('DOMContentLoaded', () => {
634
let tableHeaders = document.querySelectorAll('.table-head');

data/time.html

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<meta name="viewport" content="width=device-width, initial-scale=1">
1010
<meta name="apple-mobile-web-app-capable" content="yes">
1111
<link rel="stylesheet" href="web.css">
12-
<script src="common.js" type="module"></script>
1312
<script src="time.js" type="module"></script>
1413

1514
<meta name="theme-color" content="#6a6a6a">

data/time.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
// Copyright (c) 2023 steff393
22

3-
import {initNavBar, assignValuesToHtml, setSectionVisibility} from './common.js';
3+
// ----------------------------- COMMON SECTION: START ------------------------------
4+
function initNavBar() {
5+
for (const element of document.querySelectorAll('[top-nav-link]')) {
6+
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
7+
}
8+
}
9+
10+
function assignValuesToHtml(values) {
11+
let valueContainerElements = document.querySelectorAll('[data-value]');
12+
for (const element of valueContainerElements) {
13+
const key = element.getAttribute('data-value');
14+
if (values[key] !== undefined) {
15+
element.innerHTML = values[key].toLocaleString('de-DE');
16+
}
17+
}
18+
}
19+
20+
function setClass(element, className, state) {
21+
if (state) {
22+
element.classList.add(className)
23+
} else {
24+
element.classList.remove(className)
25+
}
26+
}
27+
28+
function setSectionVisibility(sectionId, isVisible) {
29+
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
30+
}
31+
// ----------------------------- COMMON SECTION: END ------------------------------
432

533
window.addEventListener('DOMContentLoaded', () => {
634
// Adjustable values -----

data/web.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<meta name="viewport" content="width=device-width, initial-scale=1">
1010
<meta name="apple-mobile-web-app-capable" content="yes">
1111
<link rel="stylesheet" href="web.css">
12-
<script src="common.js" type="module"></script>
1312
<script src="web.js" type="module"></script>
1413

1514
<meta name="theme-color" content="#6a6a6a">
@@ -59,7 +58,7 @@ <h3 class="box-header">
5958
<svg class="flash"><use xlink:href="#flash"></use></svg>&nbsp;<span>Ladestrom</span>
6059
</h3>
6160
<div class="box-content">
62-
<label for="slideCurr" class="value">max <span data-value="currLim">-</span> A (<span data-value="powerLim"></span> kW)</label>
61+
<label for="slideCurr" class="value">max <span data-value="currLim">-</span> A</label>
6362
<div class="slider-wrapper">
6463
<span class="slider-min">0A</span>
6564
<input type="range" min="0" max="160" value="60" class="slider" id="slideCurr">

data/web.js

+29-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
// Copyright (c) 2023 steff393, MIT license
22

3-
import {initNavBar, assignValuesToHtml, setSectionVisibility} from './common.js';
3+
// ----------------------------- COMMON SECTION: START ------------------------------
4+
function initNavBar() {
5+
for (const element of document.querySelectorAll('[top-nav-link]')) {
6+
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
7+
}
8+
}
9+
10+
function assignValuesToHtml(values) {
11+
let valueContainerElements = document.querySelectorAll('[data-value]');
12+
for (const element of valueContainerElements) {
13+
const key = element.getAttribute('data-value');
14+
if (values[key] !== undefined) {
15+
element.innerHTML = values[key].toLocaleString('de-DE');
16+
}
17+
}
18+
}
19+
20+
function setClass(element, className, state) {
21+
if (state) {
22+
element.classList.add(className)
23+
} else {
24+
element.classList.remove(className)
25+
}
26+
}
27+
28+
function setSectionVisibility(sectionId, isVisible) {
29+
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
30+
}
31+
// ----------------------------- COMMON SECTION: END ------------------------------
432

533
window.addEventListener('DOMContentLoaded', () => {
634
// Adjustable values -----
@@ -45,7 +73,6 @@ window.addEventListener('DOMContentLoaded', () => {
4573

4674
assignValuesToHtml({
4775
currLim: val / 10,
48-
powerLim: val * 23 * phases / 1000,
4976
})
5077
}
5178

@@ -93,7 +120,6 @@ window.addEventListener('DOMContentLoaded', () => {
93120
if (!sliderSliding) {
94121
assignValuesToHtml({
95122
currLim: message.currLim,
96-
powerLim: message.currLim * 230 * phases / 1000,
97123
});
98124
elementCurrentSlider.value = message.currLim * 10;
99125
}
@@ -117,7 +143,6 @@ window.addEventListener('DOMContentLoaded', () => {
117143
energyI: '-',
118144
energyC: '-',
119145
currLim: '-',
120-
powerLim:'-',
121146
watt: '-',
122147
timeNow: '-',
123148
})

0 commit comments

Comments
 (0)