display current player
This commit is contained in:
parent
bbcb9830e3
commit
58b24e702c
@ -37,7 +37,9 @@ if (array_key_exists("submitted", $_REQUEST)) {
|
||||
}
|
||||
|
||||
$sentences = fopen("./data/sentences.txt", "a") or die("unable to open sentences file");
|
||||
$content = "<span style='";
|
||||
$content = "<span data-user='";
|
||||
$content .= $_REQUEST["user"];
|
||||
$content .= "' style='";
|
||||
|
||||
if ($botrequest) {
|
||||
$content .= "background-color: darksalmon; color: white;'>";
|
||||
@ -122,6 +124,8 @@ $config_data = json_decode($raw_json_config, false);
|
||||
</div>
|
||||
<button onclick="onReloadClicked()" id="but-reload">aktualisieren</button>
|
||||
<br>
|
||||
<div id="login_area">
|
||||
</div>
|
||||
<div class="word_input_area">
|
||||
<input type="text" name="submitted" id="wordinput" placeholder="Nächstes Wort" autocomplete="off"> <button id="sendbut" class="send_button" onclick="sendWord()">
|
||||
<?php
|
||||
|
||||
20
owe.js
20
owe.js
@ -35,6 +35,8 @@ function loadSentences(alertIfNew = false, increaseUnread = true) {
|
||||
var histurnspan = spans[spans.length - 3];
|
||||
//console.log(histurnspan.getAttribute("style"));
|
||||
document.getElementById("wordinput").setAttribute("style", histurnspan.getAttribute("style"));
|
||||
|
||||
initializeLoginArea();
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -61,6 +63,7 @@ function onReloadClicked() {
|
||||
function sendWord() {
|
||||
var data = new FormData();
|
||||
data.append('submitted', encodeURI(document.getElementById("wordinput").value));
|
||||
data.append('user', getNextPlayer());
|
||||
const Http = new XMLHttpRequest();
|
||||
Http.open('POST', '.');
|
||||
Http.onreadystatechange=(e)=>{
|
||||
@ -101,6 +104,21 @@ function resetUnread() {
|
||||
document.getElementsByTagName("title")[0].innerText = (config_data.title ? config_data.title : "One Word Each");
|
||||
}
|
||||
|
||||
function getNextPlayer() {
|
||||
var spans = document.querySelector(".sentences").getElementsByTagName("span");
|
||||
var lastspan = spans[spans.length - 1];
|
||||
var lastplayer = lastspan.dataset.user;
|
||||
var idx_next = (config_data.users.indexOf(lastplayer) + 1) % config_data.users.length;
|
||||
return config_data.users[idx_next];
|
||||
}
|
||||
|
||||
function initializeLoginArea() {
|
||||
var loginArea = document.getElementById('login_area');
|
||||
//loginArea.innerHTML = "Eingeloggt als NOCH NICHT IMPLEMENTIERT";
|
||||
loginArea.innerHTML = ""; // first clear it out
|
||||
loginArea.innerHTML += getNextPlayer() + " ist dran!";
|
||||
}
|
||||
|
||||
window.onfocus = resetUnread;
|
||||
|
||||
//setTimeout(loadSentences, 500);
|
||||
@ -118,7 +136,7 @@ input.addEventListener("keyup", function(event) {
|
||||
// Trigger the button element with a click
|
||||
document.getElementById("sendbut").click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user