Compare commits
No commits in common. "8a1a7d19b557fa9628a6fb7985fbfacfc435ad55" and "5e0793c7fcaebc863af89bee980cdde37692916e" have entirely different histories.
8a1a7d19b5
...
5e0793c7fc
BIN
data/data.xlsx
BIN
data/data.xlsx
Binary file not shown.
|
@ -1,55 +0,0 @@
|
||||||
<?php
|
|
||||||
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/read_write_xlsx.php';
|
|
||||||
$fileName = $_SERVER['DOCUMENT_ROOT'] . '/data/data.xlsx';
|
|
||||||
function objectToArray($object, $fullJSON) {
|
|
||||||
return [$object -> id,
|
|
||||||
$object -> lastSave,
|
|
||||||
$fullJSON,
|
|
||||||
$object -> timeWatchM,
|
|
||||||
$object -> timeWatchW,
|
|
||||||
$object -> timeWatchD,
|
|
||||||
$object -> countWatchM,
|
|
||||||
$object -> countWatchW,
|
|
||||||
$object -> countWatchD];
|
|
||||||
}
|
|
||||||
|
|
||||||
function findRowIndex($id, $data) {
|
|
||||||
$rowCounter = -1;
|
|
||||||
foreach ($data as $row) {
|
|
||||||
$rowCounter ++;
|
|
||||||
if($row[0] == $id) {
|
|
||||||
return $rowCounter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $rowCounter + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$entityBody = '{"lastSave": 0, "timeWatchM": 0, "timeWatchW": 0, "timeWatchD": 0, "countWatchM": 0, "countWatchW": 0, "countWatchD": 0, "id":"test","watches":[{"actions":[]},{"actions":[]},{"actions":[]}]}';
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
||||||
$entityBody = file_get_contents('php://input');
|
|
||||||
$entityBodyObject = json_decode($entityBody);
|
|
||||||
|
|
||||||
echo "POST Request received.<br>";
|
|
||||||
|
|
||||||
if(property_exists($entityBodyObject, "id")) {
|
|
||||||
$data = read_xls_file($fileName);
|
|
||||||
|
|
||||||
foreach ($data as $row) {
|
|
||||||
echo "new Row: <br>";
|
|
||||||
foreach ($row as $cell) {
|
|
||||||
echo $cell." ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowIndex = findRowIndex($entityBodyObject->id, $data);
|
|
||||||
$data[$rowIndex] = objectToArray($entityBodyObject, $entityBody);
|
|
||||||
write_xlsxFile($fileName, $data);
|
|
||||||
echo "<br>Data saved.<br>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
14
index.html
14
index.html
|
@ -1,16 +1,14 @@
|
||||||
<html lang="de">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="css/custom.css">
|
<link rel="stylesheet" href="css/custom.css">
|
||||||
<link rel="stylesheet" href="css/bootstrap.css">
|
<link rel="stylesheet" href="css/bootstrap.css">
|
||||||
<title>Genderwatch-protocol</title>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<section>
|
<section>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Genderwatch-protocol</h1>
|
<h1>Genderwatch-protocol</h1>
|
||||||
<a href="data/data.xlsx">Anonyme Daten herunterladen</a>
|
|
||||||
<h2 style="margin-left: 10px;">Aktuelles Thema</h2>
|
<h2 style="margin-left: 10px;">Aktuelles Thema</h2>
|
||||||
<table class="table-bordered">
|
<table class="table-bordered">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -124,13 +122,13 @@
|
||||||
closedTopics = []
|
closedTopics = []
|
||||||
}
|
}
|
||||||
|
|
||||||
actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
|
watches = JSON.parse(localStorage.getItem("watches"))
|
||||||
if(!actualTopic) {
|
if(!watches){
|
||||||
initializeNewTopic()
|
reset()
|
||||||
}
|
}
|
||||||
document.getElementById("topicInput").value = actualTopic.name
|
|
||||||
|
|
||||||
document.getElementById("topicInput").addEventListener('keyup', saveActualTopicName);
|
document.getElementById("topicInput").value = localStorage.getItem("actualTopic")
|
||||||
|
document.getElementById("topicInput").addEventListener('keyup', saveActualTopicToLocalStorage);
|
||||||
refreshClosedTopics()
|
refreshClosedTopics()
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
refreshWatch(0)
|
refreshWatch(0)
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
function initializeNewTopic() {
|
|
||||||
actualTopic = {"name": "", "id": randomId()}
|
|
||||||
reset()
|
|
||||||
document.getElementById("topicInput").value = actualTopic.name
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
actualTopic.watches = [{"actions": []}, {"actions": []}, {"actions": []}]
|
actualTopic.watches = [{"actions": []}, {"actions": []}, {"actions": []}]
|
||||||
saveActualTopic()
|
saveWatchesToLocalStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetButton() {
|
function resetButton() {
|
||||||
|
@ -18,7 +12,7 @@ function resetButton() {
|
||||||
function buttonDeleteAllClosedTopics() {
|
function buttonDeleteAllClosedTopics() {
|
||||||
if(confirm("Sollen alle abgeschlossenen Themen gelöscht werden?")) {
|
if(confirm("Sollen alle abgeschlossenen Themen gelöscht werden?")) {
|
||||||
closedTopics = []
|
closedTopics = []
|
||||||
saveClosedTopics()
|
saveClosedTopicsToLocalStorage()
|
||||||
refreshClosedTopics()
|
refreshClosedTopics()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +24,8 @@ function buttonDeleteClosedTopic(topicIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeTopic() {
|
function closeTopic() {
|
||||||
stop()
|
|
||||||
let defaultname = "Thema"
|
let defaultname = "Thema"
|
||||||
let name = actualTopic.name
|
let name = document.getElementById("topicInput").value
|
||||||
let nameLessCounter = 1
|
let nameLessCounter = 1
|
||||||
while(!name){
|
while(!name){
|
||||||
let foundName = false
|
let foundName = false
|
||||||
|
@ -47,50 +40,53 @@ function closeTopic() {
|
||||||
name = defaultname + nameLessCounter
|
name = defaultname + nameLessCounter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actualTopic.name = name
|
|
||||||
closedTopics.push(actualTopic)
|
closedTopics.push({"name": name, "watches": watches})
|
||||||
saveClosedTopics()
|
stop()
|
||||||
|
reset()
|
||||||
|
document.getElementById("topicInput").value = ""
|
||||||
|
saveActualTopicToLocalStorage()
|
||||||
|
saveClosedTopicsToLocalStorage()
|
||||||
refreshClosedTopics()
|
refreshClosedTopics()
|
||||||
initializeNewTopic()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTopic(topicIndex) {
|
function deleteTopic(topicIndex) {
|
||||||
closedTopics = closedTopics.slice(0, topicIndex).concat(closedTopics.slice(topicIndex+1))
|
closedTopics = closedTopics.slice(0, topicIndex).concat(closedTopics.slice(topicIndex+1))
|
||||||
saveClosedTopics()
|
saveClosedTopicsToLocalStorage()
|
||||||
refreshClosedTopics()
|
refreshClosedTopics()
|
||||||
}
|
}
|
||||||
|
|
||||||
function reopenTopic(topicIndex) {
|
function reopenTopic(topicIndex) {
|
||||||
if(actualTopic.watches[0]["actions"]["length"] > 0 || actualTopic.watches[1]["actions"]["length"] > 0 ||actualTopic.watches[2]["actions"]["length"] > 0 || actualTopic.name !== "") {
|
if(watches[0]["actions"]["length"] > 0 || watches[1]["actions"]["length"] > 0 ||watches[2]["actions"]["length"] > 0 || document.getElementById("topicInput").value != "") {
|
||||||
closeTopic()
|
closeTopic()
|
||||||
}
|
}
|
||||||
actualTopic = closedTopics[topicIndex]
|
watches = closedTopics[topicIndex]["watches"]
|
||||||
document.getElementById("topicInput").value = actualTopic.name
|
document.getElementById("topicInput").value = closedTopics[topicIndex]["name"]
|
||||||
deleteTopic(topicIndex)
|
deleteTopic(topicIndex)
|
||||||
saveClosedTopics()
|
saveWatchesToLocalStorage()
|
||||||
saveActualTopic()
|
saveActualTopicToLocalStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
function start(watchIndex) {
|
function start(watchIndex) {
|
||||||
stop()
|
stop()
|
||||||
actualTopic.watches[watchIndex].actions.push({"type": "start", "time": new Date().getTime()})
|
watches[watchIndex].actions.push({"type": "start", "time": new Date().getTime()})
|
||||||
saveActualTopic()
|
saveWatchesToLocalStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop() {
|
function stop() {
|
||||||
actualTopic.watches.forEach(watch => {
|
watches.forEach(watch => {
|
||||||
if(watch["actions"]["length"] > 0) {
|
if(watch["actions"]["length"] > 0) {
|
||||||
if(watch["actions"]["length"] % 2 === 1){
|
if(watch["actions"]["length"] % 2 == 1){
|
||||||
watch["actions"].push({"type": "stop", "time": new Date().getTime()})
|
watch["actions"].push({"type": "stop", "time": new Date().getTime()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
saveActualTopic()
|
saveWatchesToLocalStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcPercForWatch(watchIndex, topic) {
|
function calcPercForWatch(watchIndex, topic) {
|
||||||
let sumAll = sumAllwatches(topic)
|
let sumAll = sumAllwatches(topic)
|
||||||
if(sumAll === 0) {
|
if(sumAll == 0) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return Math.round(sumForWatch(topic.watches[watchIndex]) / sumAllwatches(topic) * 100)
|
return Math.round(sumForWatch(topic.watches[watchIndex]) / sumAllwatches(topic) * 100)
|
||||||
|
@ -116,7 +112,7 @@ function countForWatch(watch) {
|
||||||
|
|
||||||
function calcPercCountForWatch(watchindex, topic) {
|
function calcPercCountForWatch(watchindex, topic) {
|
||||||
let sumAll = sumCountAllWatches(topic)
|
let sumAll = sumCountAllWatches(topic)
|
||||||
if(sumAll === 0) {
|
if(sumAll == 0) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return Math.round(countForWatch(topic.watches[watchindex]) / sumAll * 100)
|
return Math.round(countForWatch(topic.watches[watchindex]) / sumAll * 100)
|
||||||
|
@ -136,14 +132,14 @@ function timeToISO(time){
|
||||||
|
|
||||||
function refreshWatch(watchIndex) {
|
function refreshWatch(watchIndex) {
|
||||||
let timeCell = document.getElementById("time-" + watchIndex)
|
let timeCell = document.getElementById("time-" + watchIndex)
|
||||||
timeCell.textContent = timeToISO(sumForWatch(actualTopic.watches[watchIndex]))
|
timeCell.textContent = timeToISO(sumForWatch(watches[watchIndex]))
|
||||||
if(actualTopic.watches[watchIndex]["actions"].length !== 0 && actualTopic.watches[watchIndex]["actions"].slice(-1)[0]["type"] === "start"){
|
if(watches[watchIndex]["actions"].length != 0 && watches[watchIndex]["actions"].slice(-1)[0]["type"] == "start"){
|
||||||
timeCell.classList.add("active")
|
timeCell.classList.add("active")
|
||||||
} else {
|
} else {
|
||||||
timeCell.classList.remove("active")
|
timeCell.classList.remove("active")
|
||||||
}
|
}
|
||||||
let countCell = document.getElementById("count-" + watchIndex)
|
let countCell = document.getElementById("count-" + watchIndex)
|
||||||
countCell.textContent = countForWatch(actualTopic.watches[watchIndex]) + " Wortmeldungen"
|
countCell.textContent = countForWatch(watches[watchIndex]) + " Wortmeldungen"
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshClosedTopics() {
|
function refreshClosedTopics() {
|
||||||
|
@ -182,20 +178,15 @@ function refreshClosedTopics() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveActualTopicName() {
|
function saveWatchesToLocalStorage() {
|
||||||
actualTopic.name = document.getElementById("topicInput").value
|
localStorage.setItem("watches", JSON.stringify(watches))
|
||||||
saveActualTopic()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveActualTopicToLocalStorage() {
|
||||||
|
localStorage.setItem("actualTopic", document.getElementById("topicInput").value)
|
||||||
function saveActualTopic() {
|
|
||||||
//save it to LocalStorage
|
|
||||||
localStorage.setItem("actualTopic", JSON.stringify(actualTopic))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveClosedTopics() {
|
function saveClosedTopicsToLocalStorage() {
|
||||||
//save it to LocalStorage
|
|
||||||
localStorage.setItem("closedTopics", JSON.stringify(closedTopics))
|
localStorage.setItem("closedTopics", JSON.stringify(closedTopics))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,9 +203,3 @@ function elt (type, attrs, ...children) {
|
||||||
}
|
}
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
// random.ts
|
|
||||||
function randomId() {
|
|
||||||
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
|
|
||||||
return uint32.toString(16);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +0,0 @@
|
||||||
<?php
|
|
||||||
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/SimpleXLSX.php';
|
|
||||||
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/SimpleXLSXGen.php';
|
|
||||||
function read_xls_file($filename){
|
|
||||||
$fileContent = [];
|
|
||||||
if ($xlsx = SimpleXLSX::parse($filename)) {
|
|
||||||
$fileContent = ($xlsx->rows());
|
|
||||||
} else {
|
|
||||||
echo SimpleXLSX::parseError();
|
|
||||||
}
|
|
||||||
return $fileContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function write_xlsxFile($filename, $data) {
|
|
||||||
$xlsx = SimpleXLSXGen::fromArray($data);
|
|
||||||
$xlsx->saveAs($filename);
|
|
||||||
}
|
|
Loading…
Reference in New Issue