Compare commits
No commits in common. "0ca39da0327d9383acd83f12ad1bb3d905a5322a" and "ba580d9b1e05c00a23793b36bb7720ba1163f930" have entirely different histories.
0ca39da032
...
ba580d9b1e
@ -95,10 +95,7 @@ $config_data = json_decode($raw_json_config, false);
|
||||
<div class="header">
|
||||
<img src="<?php print($config_data->logo->image_path ?? "OWE_Logo.png"); ?>" style="width: 10%; float: left;">
|
||||
<h3 style="padding: 30px;"><?php print($config_data->headline ?? "One Word Each Seite"); ?></h3>
|
||||
<button onclick="toggleArchives();" id="sidebar_button">
|
||||
<?php
|
||||
print(isset($config_data->archive) ? ("<img id='archive_image' src='".$config_data->archive->logo_path_closed."' width='64'>") : "<i class='fas fa-bars'></i>");
|
||||
?></button>
|
||||
<button onclick="toggleArchives();" id="sidebar_button"><i class="fas fa-bars"></i></button>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
|
||||
17
owe.js
17
owe.js
@ -2,15 +2,13 @@ var previousTextLength;
|
||||
var config_data;
|
||||
var unread_words = 0;
|
||||
|
||||
function loadSentences(alertIfNew = false, increaseUnread = true) {
|
||||
function loadSentences(alertIfNew = false) {
|
||||
fetch("./data/sentences.txt", {headers: {"Cache-Control": "no-cache, no-store"}})
|
||||
.then((response) => {
|
||||
return response.text().then((text) => {
|
||||
document.querySelector(".sentences").innerHTML = text;
|
||||
if (text.length > previousTextLength) {
|
||||
if (increaseUnread) {
|
||||
document.getElementsByTagName("title")[0].innerText = "(" + ++unread_words + ") " + (config_data.title ? config_data.title : "One Word Each") ;
|
||||
}
|
||||
document.getElementsByTagName("title")[0].innerText = (config_data.title ? config_data.title : "One Word Each") + " (" + ++unread_words + ")";
|
||||
if (alertIfNew) {
|
||||
var newtxt = text.substring(previousTextLength, text.length);
|
||||
//var parser = new DOMParser();
|
||||
@ -43,7 +41,6 @@ function loadConfig() {
|
||||
fetch("./data/config.json").then((response) => {
|
||||
return response.text().then((text) => {
|
||||
config_data = JSON.parse(text);
|
||||
setInterval(loadSentences, 5000, ((typeof config_data.notifications !== "undefined") ? config_data.notifications : true));
|
||||
});
|
||||
}).catch(() => {
|
||||
config_data = Object(); // leave empty
|
||||
@ -65,8 +62,7 @@ function sendWord() {
|
||||
Http.open('POST', '.');
|
||||
Http.onreadystatechange=(e)=>{
|
||||
document.getElementById("wordinput").value = "";
|
||||
loadSentences(false, false);
|
||||
resetUnread();
|
||||
loadSentences();
|
||||
}
|
||||
Http.send(data);
|
||||
}
|
||||
@ -85,15 +81,9 @@ function toggleArchives() {
|
||||
|
||||
if (archives.style.display == "none") {
|
||||
archives.style.display = "flex";
|
||||
if (config_data.archive) {
|
||||
document.getElementById("archive_image").src = config_data.archive.logo_path_open
|
||||
}
|
||||
return;
|
||||
}
|
||||
archives.style.display = "none";
|
||||
if (config_data.archive) {
|
||||
document.getElementById("archive_image").src = config_data.archive.logo_path_closed
|
||||
}
|
||||
}
|
||||
|
||||
function resetUnread() {
|
||||
@ -106,6 +96,7 @@ window.onfocus = resetUnread;
|
||||
//setTimeout(loadSentences, 500);
|
||||
loadConfig();
|
||||
loadSentences();
|
||||
setInterval(loadSentences, 5000, true);
|
||||
|
||||
var input = document.getElementById("wordinput");
|
||||
input.focus();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user