Skip to content

Commit

Permalink
7.0.8
Browse files Browse the repository at this point in the history
Technical changes only
  • Loading branch information
RandomPerson3465 committed Aug 24, 2024
1 parent ee666e2 commit e40fef8
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 57 deletions.
7 changes: 1 addition & 6 deletions counter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})

const LCEDIT = {
saveVersion: 3,
versionName: "7.0.7",
versionName: "7.0.8",
util: {
clamp: (input, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) => {
if (isNaN(input)) input = 0;
Expand Down
101 changes: 101 additions & 0 deletions drawMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
function drawMenu(data, tabListDiv, tabContentDiv) {
try {
for (i = 0; i < data.tabs.length; i++) {
tabListDiv.innerHTML += `<button id="tab-link-${i}" class="tab-link" onclick="openTab(event, 'tabs-${i}')">${data.tabs[i].title}</button>`;
let resultHTML = `<div class="tab-content" id="tabs-${i}">`;
if (data.tabs[i].leadingHTML) {
resultHTML += data.tabs[i].leadingHTML.join("");
}
if (data.tabs[i].forms) {
for (j = 0; j < data.tabs[i].forms.length; j++) {
const form = data.tabs[i].forms[j];
resultHTML += `<form class="${form.class}" id="${form.id}">`;
for (k = 0; k < form.elements.length; k++) {
if (form.elements[k].type === "html") {
resultHTML += form.elements[k].elements.join("");
} else {
const isCheckbox = form.elements[k].type === "checkbox";
const elementClass = form.elements[k].class ? " " + form.elements[k].class : "";
if (isCheckbox) {
resultHTML += `<div class="form-check mb-3${elementClass}">`
} else {
resultHTML += `<div class="mb-3${elementClass}">`
}
for (l = 0; l < form.elements[k].elements.length; l++) {
let labelHTML = "", inputHTML = "", linkHTML = "";
const element = form.elements[k].elements[l];
if (element.label) {
labelHTML = `<span><label class=${isCheckbox ? "form-check-label" : "form-label"} for="${element.id}">${element.label}</label>${element.info ? (' <i class="fa fa-info-circle" data-bs-toggle="tooltip" title="' + element.info + '"></i>') : ""}</span>`;
}
if (element.link) {
linkHTML = `<br><a href="${element.link[0]}">${element.link[1]}</a>`;
}
if (element.type === "checkbox") {
inputHTML = `<input class="form-check-input" type="checkbox" id="${element.id}" name="${element.id}">`
} else {
if (element.tag === "input") {
inputHTML = `<input class="form-control${element.inputType === "color" ? " form-control-color" : ""}" id="${element.id}" name="${element.id}" type="${element.inputType}"`;
if (element.inputNumberMin !== undefined) {
inputHTML += ` min="${element.inputNumberMin}"`;
}
if (element.inputNumberMax !== undefined) {
inputHTML += ` max="${element.inputNumberMax}"`;
}
if (element.inputNumberStep) {
inputHTML += ` step="${element.inputNumberStep}"`;
}
if (element.inputFileAccept) {
inputHTML += ` accept="${element.inputFileAccept}"`;
}
if (element.placeholder) {
inputHTML += ` placeholder="${element.placeholder}"`;
}
if (element.inputRequired) {
inputHTML += " required";
}
inputHTML += ">";
}
if (element.tag === "textarea") {
inputHTML = `<textarea class="form-control" id="${element.id}" name="${element.id}"`;
if (element.placeholder) {
inputHTML += ` placeholder="${element.placeholder}"`;
}
if (element.inputRequired) {
inputHTML += " required";
}
inputHTML += "></textarea>";
}
if (element.tag === "select") {
inputHTML += `<select class="form-control" id="${element.id}" name="${element.id}"`
if (element.inputRequired) {
inputHTML += " required";
}
inputHTML += ">"
for (m = 0; m < element.selectOptions.length; m++) {
inputHTML += `<option value="${element.selectOptions[m][0]}">${element.selectOptions[m][1]}</option>`;
}
inputHTML += "</select>";
}
}
if (isCheckbox) {
resultHTML += (inputHTML + labelHTML + linkHTML);
} else {
resultHTML += (labelHTML + linkHTML + inputHTML);
}
}
resultHTML += "</div>"
}
}
resultHTML += "</form>"
}
}
if (data.tabs[i].trailingHTML) {
resultHTML += data.tabs[i].trailingHTML.join("");
}
tabContentDiv.innerHTML += (resultHTML + "</div>")
}
} catch (error) {
console.error(error);
alert("There was an error when loading the options menu.");
}
}
2 changes: 1 addition & 1 deletion livecountsedit/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ body {
padding: 0px 12px;
border: 1px solid var(--border-color, #ddd);
border-left: none;
width: 30%;
width: 30vw;
height: 100%;
border-radius: 15px;
overflow-y: scroll;
Expand Down
20 changes: 14 additions & 6 deletions livecountsedit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
<body>
<div class="lcedit-container">
<div class="tabs">
<button id="tab-link-0" class="tab-link" onclick="openTab(event, 'tabs-0')">General</button>
<button id="tab-link-1" class="tab-link" onclick="openTab(event, 'tabs-1')">Counter</button>
<button id="tab-link-2" class="tab-link" onclick="openTab(event, 'tabs-2')">Styles</button>
<button id="tab-link-3" class="tab-link" onclick="openTab(event, 'tabs-3')">Advanced Settings</button>
<button id="tab-link-4" class="tab-link" onclick="openTab(event, 'tabs-4')">API Updates</button>
<div class="tab-buttons">
<!--
<button id="tab-link-0" class="tab-link" onclick="openTab(event, 'tabs-0')">General</button>
<button id="tab-link-1" class="tab-link" onclick="openTab(event, 'tabs-1')">Counter</button>
<button id="tab-link-2" class="tab-link" onclick="openTab(event, 'tabs-2')">Styles</button>
<button id="tab-link-3" class="tab-link" onclick="openTab(event, 'tabs-3')">Advanced Settings</button>
<button id="tab-link-4" class="tab-link" onclick="openTab(event, 'tabs-4')">API Updates</button>
-->
</div>
<button class="btn btn-primary" onclick="submit()">Save settings</button><br>
<button class="btn btn-primary" onclick="refreshCount()">Refresh count</button>
<button class="btn btn-danger" onclick="reset()">Reset</button><br>
Expand All @@ -46,6 +50,8 @@
<input type="file" class="file-import" id="import-data-v7" accept=".json">

</div>
<div class="tab-stuff"></div>
<!--
<div class="tab-content" id="tabs-0">
<form class="counter-form" id="settingsForm-0">
<div class="mb-3">
Expand Down Expand Up @@ -245,6 +251,7 @@
<h5>Note: API settings are saved separately from the other settings.</h5><br>
<h5>Status indicator: <span id="apiStatusIndicator">--</span></h5>
</div>
-->
<div class="counter-content">
<div class="counter-container">
<img class="banner" src="../default_banner.png" id="counter-banner">
Expand All @@ -258,11 +265,12 @@ <h5>Status indicator: <span id="apiStatusIndicator">--</span></h5>
</div>
</div>
<div class="page-footer">
<span>Version 7.0.7 - <a href="../index.html">Back to main page</a> - <a href="https://github.com/livecountsedit/livecountsedit.github.io/wiki/New-Updates-Not-Working%3F">Not working?</a> - <a href="../about/discord.html">Join the Livecountsedit Discord Server.</a> This site is a parody of popular realtime counters.</span>
<span>Version 7.0.8 - <a href="../index.html">Back to main page</a> - <a href="https://github.com/livecountsedit/livecountsedit.github.io/wiki/New-Updates-Not-Working%3F">Not working?</a> - <a href="../about/discord.html">Join the Livecountsedit Discord Server.</a> This site is a parody of popular realtime counters.</span>
</div>
<script src="../odometer/odometer.js"></script>
<script src="../highstock.js"></script>
<script src="../jquery.js"></script>
<script src="../drawMenu.js"></script>
<script src="../bootstrap.js"></script>
<script src="../counter.js"></script>
<script src="./lcedit.js"></script>
Expand Down
28 changes: 21 additions & 7 deletions livecountsedit/lcedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,31 @@ saveData.counters.push(new Counter(1))
counter = saveData.counters[0];

window.onload = function () {
if (document.getElementById('tab-link-0')) document.getElementById('tab-link-0').click();
chart = new Highcharts.chart(getChartOptions());
if (localStorage.getItem('lcedit-lcedit')) {
importFromJSON(localStorage.getItem('lcedit-lcedit'), true)
}
fillForms()
updateGainType(counter.settings.gainType)
updateStuff()
async function initMenu() {
const r = await fetch("./lcedit.json");
const data = await r.json();
drawMenu(data, document.querySelector(".tab-buttons"), document.querySelector(".tab-stuff"));
}
initMenu().then(() => {
if (document.getElementById('tab-link-0')) document.getElementById('tab-link-0').click();
fillForms();
updateGainType(counter.settings.gainType);
document.querySelector('#gainType').addEventListener('input', event => {
updateGainType(event.target.value);
})
let tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
let tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
})
updateStuff();
}).catch(error => {
console.error(error);
alert("There was an error when loading the options menu.");
})
}

document.querySelector('#import-data-v7').addEventListener('input', () => {
Expand Down Expand Up @@ -249,9 +266,6 @@ function updateGainType(v) {
}
}

document.querySelector('#gainType').addEventListener('input', event => {
updateGainType(event.target.value)
})

function setPaused(paused) {
if (paused) {
Expand Down
Loading

0 comments on commit e40fef8

Please sign in to comment.