Compare commits
2 Commits
ba580d9b1e
...
0ca39da032
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ca39da032 | |||
| a9f2c9f8b9 |
@ -95,7 +95,10 @@ $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"><i class="fas fa-bars"></i></button>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
|
||||
17
owe.js
17
owe.js
@ -2,13 +2,15 @@ var previousTextLength;
|
||||
var config_data;
|
||||
var unread_words = 0;
|
||||
|
||||
function loadSentences(alertIfNew = false) {
|
||||
function loadSentences(alertIfNew = false, increaseUnread = true) {
|
||||
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) {
|
||||
document.getElementsByTagName("title")[0].innerText = (config_data.title ? config_data.title : "One Word Each") + " (" + ++unread_words + ")";
|
||||
if (increaseUnread) {
|
||||
document.getElementsByTagName("title")[0].innerText = "(" + ++unread_words + ") " + (config_data.title ? config_data.title : "One Word Each") ;
|
||||
}
|
||||
if (alertIfNew) {
|
||||
var newtxt = text.substring(previousTextLength, text.length);
|
||||
//var parser = new DOMParser();
|
||||
@ -41,6 +43,7 @@ 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
|
||||
@ -62,7 +65,8 @@ function sendWord() {
|
||||
Http.open('POST', '.');
|
||||
Http.onreadystatechange=(e)=>{
|
||||
document.getElementById("wordinput").value = "";
|
||||
loadSentences();
|
||||
loadSentences(false, false);
|
||||
resetUnread();
|
||||
}
|
||||
Http.send(data);
|
||||
}
|
||||
@ -81,9 +85,15 @@ 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() {
|
||||
@ -96,7 +106,6 @@ 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