Skip to content

Commit

Permalink
Remove common.js (fix #99)
Browse files Browse the repository at this point in the history
  • Loading branch information
steff393 committed Nov 26, 2023
1 parent 638b5a3 commit 31e8acb
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 43 deletions.
1 change: 0 additions & 1 deletion data/cfg.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

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

<meta name="theme-color" content="#6a6a6a">
Expand Down
30 changes: 29 additions & 1 deletion data/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,35 @@
// Parameter werden nicht hier geändert.
// ----------------------------------------------------------------------------------

import {initNavBar} from './common.js';
// ----------------------------- COMMON SECTION: START ------------------------------
function initNavBar() {
for (const element of document.querySelectorAll('[top-nav-link]')) {
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
}
}

function assignValuesToHtml(values) {
let valueContainerElements = document.querySelectorAll('[data-value]');
for (const element of valueContainerElements) {
const key = element.getAttribute('data-value');
if (values[key] !== undefined) {
element.innerHTML = values[key].toLocaleString('de-DE');
}
}
}

function setClass(element, className, state) {
if (state) {
element.classList.add(className)
} else {
element.classList.remove(className)
}
}

function setSectionVisibility(sectionId, isVisible) {
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
}
// ----------------------------- COMMON SECTION: END ------------------------------

// Default settings 22.05.2023
const defaultObj = JSON.parse(
Expand Down
31 changes: 0 additions & 31 deletions data/common.js

This file was deleted.

1 change: 0 additions & 1 deletion data/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

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

<meta name="theme-color" content="#6a6a6a">
Expand Down
30 changes: 29 additions & 1 deletion data/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
// Copyright (c) 2023 steff393, MIT license

import {initNavBar} from './common.js';
// ----------------------------- COMMON SECTION: START ------------------------------
function initNavBar() {
for (const element of document.querySelectorAll('[top-nav-link]')) {
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
}
}

function assignValuesToHtml(values) {
let valueContainerElements = document.querySelectorAll('[data-value]');
for (const element of valueContainerElements) {
const key = element.getAttribute('data-value');
if (values[key] !== undefined) {
element.innerHTML = values[key].toLocaleString('de-DE');
}
}
}

function setClass(element, className, state) {
if (state) {
element.classList.add(className)
} else {
element.classList.remove(className)
}
}

function setSectionVisibility(sectionId, isVisible) {
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
}
// ----------------------------- COMMON SECTION: END ------------------------------

window.addEventListener('DOMContentLoaded', () => {
let tableHeaders = document.querySelectorAll('.table-head');
Expand Down
1 change: 0 additions & 1 deletion data/time.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="web.css">
<script src="common.js" type="module"></script>
<script src="time.js" type="module"></script>

<meta name="theme-color" content="#6a6a6a">
Expand Down
30 changes: 29 additions & 1 deletion data/time.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
// Copyright (c) 2023 steff393

import {initNavBar, assignValuesToHtml, setSectionVisibility} from './common.js';
// ----------------------------- COMMON SECTION: START ------------------------------
function initNavBar() {
for (const element of document.querySelectorAll('[top-nav-link]')) {
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
}
}

function assignValuesToHtml(values) {
let valueContainerElements = document.querySelectorAll('[data-value]');
for (const element of valueContainerElements) {
const key = element.getAttribute('data-value');
if (values[key] !== undefined) {
element.innerHTML = values[key].toLocaleString('de-DE');
}
}
}

function setClass(element, className, state) {
if (state) {
element.classList.add(className)
} else {
element.classList.remove(className)
}
}

function setSectionVisibility(sectionId, isVisible) {
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
}
// ----------------------------- COMMON SECTION: END ------------------------------

window.addEventListener('DOMContentLoaded', () => {
// Adjustable values -----
Expand Down
3 changes: 1 addition & 2 deletions data/web.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="web.css">
<script src="common.js" type="module"></script>
<script src="web.js" type="module"></script>

<meta name="theme-color" content="#6a6a6a">
Expand Down Expand Up @@ -59,7 +58,7 @@ <h3 class="box-header">
<svg class="flash"><use xlink:href="#flash"></use></svg>&nbsp;<span>Ladestrom</span>
</h3>
<div class="box-content">
<label for="slideCurr" class="value">max <span data-value="currLim">-</span> A (<span data-value="powerLim"></span> kW)</label>
<label for="slideCurr" class="value">max <span data-value="currLim">-</span> A</label>
<div class="slider-wrapper">
<span class="slider-min">0A</span>
<input type="range" min="0" max="160" value="60" class="slider" id="slideCurr">
Expand Down
33 changes: 29 additions & 4 deletions data/web.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
// Copyright (c) 2023 steff393, MIT license

import {initNavBar, assignValuesToHtml, setSectionVisibility} from './common.js';
// ----------------------------- COMMON SECTION: START ------------------------------
function initNavBar() {
for (const element of document.querySelectorAll('[top-nav-link]')) {
element.addEventListener('click', function() {window.location.href = element.getAttribute('top-nav-link')});
}
}

function assignValuesToHtml(values) {
let valueContainerElements = document.querySelectorAll('[data-value]');
for (const element of valueContainerElements) {
const key = element.getAttribute('data-value');
if (values[key] !== undefined) {
element.innerHTML = values[key].toLocaleString('de-DE');
}
}
}

function setClass(element, className, state) {
if (state) {
element.classList.add(className)
} else {
element.classList.remove(className)
}
}

function setSectionVisibility(sectionId, isVisible) {
setClass(document.getElementById(sectionId), 'not-available', !isVisible);
}
// ----------------------------- COMMON SECTION: END ------------------------------

window.addEventListener('DOMContentLoaded', () => {
// Adjustable values -----
Expand Down Expand Up @@ -45,7 +73,6 @@ window.addEventListener('DOMContentLoaded', () => {

assignValuesToHtml({
currLim: val / 10,
powerLim: val * 23 * phases / 1000,
})
}

Expand Down Expand Up @@ -93,7 +120,6 @@ window.addEventListener('DOMContentLoaded', () => {
if (!sliderSliding) {
assignValuesToHtml({
currLim: message.currLim,
powerLim: message.currLim * 230 * phases / 1000,
});
elementCurrentSlider.value = message.currLim * 10;
}
Expand All @@ -117,7 +143,6 @@ window.addEventListener('DOMContentLoaded', () => {
energyI: '-',
energyC: '-',
currLim: '-',
powerLim:'-',
watt: '-',
timeNow: '-',
})
Expand Down

0 comments on commit 31e8acb

Please sign in to comment.