96 Commits
Author SHA1 Message Date
jonathan_schlegel c53cfdf45d index.html aktualisiert 2026-03-25 09:41:40 +01:00
jonathan_schlegel 4273392600 index.html aktualisiert 2026-02-04 10:19:49 +01:00
jonathan_schlegel e2977ff3e8 index.html aktualisiert 2026-02-04 10:18:40 +01:00
jonathan_schlegel 1f6c08b923 index.html aktualisiert 2026-02-04 10:17:16 +01:00
jonathan_schlegel a1c9faf4da css/custom.css aktualisiert 2026-02-04 10:13:33 +01:00
jonathan_schlegel 1429e3fea2 index.html aktualisiert 2026-02-04 10:12:51 +01:00
jonathan_schlegel 7295f912db index.html aktualisiert 2026-02-04 10:08:39 +01:00
jonathan_schlegel 20c870f640 css/custom.css aktualisiert 2026-02-04 09:58:12 +01:00
jonathan_schlegel b0fd43a16f css/custom.css aktualisiert 2026-02-04 09:55:43 +01:00
jonathan_schlegel 51596e0722 css/custom.css aktualisiert 2026-02-04 09:51:46 +01:00
jonathan_schlegel 577d05cad0 index.html aktualisiert 2026-02-04 09:48:07 +01:00
jonathan_schlegel c552731692 index.html aktualisiert 2026-02-04 09:46:38 +01:00
jonathan_schlegel e3ca2a71cb revert 1f2c012475
revert index.html aktualisiert
2026-02-04 09:45:43 +01:00
jonathan_schlegel 329cbe6b70 index.html aktualisiert 2026-02-04 09:43:13 +01:00
jonathan_schlegel 1f2c012475 index.html aktualisiert 2026-02-04 09:41:47 +01:00
jonathan_schlegel a6b598f738 index.html aktualisiert 2026-02-04 09:41:04 +01:00
jonathan_schlegel 2b6ed22805 index.html aktualisiert 2026-02-04 09:40:21 +01:00
jonathan_schlegel cf3b330006 README.md aktualisiert 2026-02-04 09:37:50 +01:00
Roman_Schenk 7170ee4015 Update databaseConnection/databaseConnection.php 2026-02-03 11:11:02 +01:00
Roman_Schenk a2ec8bdfa5 Update databaseConnection/databaseConnection.php 2026-02-03 11:08:36 +01:00
Roman_Schenk 8d84b0959d Update databaseConnection/databaseConnection.php 2026-02-03 10:58:57 +01:00
jonathan_schlegel 08a888e270 index.html aktualisiert 2026-02-03 09:43:02 +01:00
Roman_Schenk 26699e0e06 Update js/functions.js 2026-01-16 12:32:21 +01:00
silisio 19b8252a6b Update index.html 2026-01-15 21:17:41 +01:00
silisio 806cd9de6b Update index.html 2026-01-15 21:15:21 +01:00
silisio 78d3e2edec Update databaseConnection/databaseConnection.php 2026-01-15 15:42:20 +01:00
schrom01 b7c01aa46b removed not working donation functionality 2023-08-16 18:33:22 +02:00
schrom01 ba39872b9e removed not working donation functionality 2023-08-16 18:31:46 +02:00
schrom01 3866e62e72 donations.php
cleanup
2023-02-16 21:11:38 +01:00
schrom01 c14dc6978e donations.php
cleanup
2023-02-16 21:07:33 +01:00
schrom01 6aa0eb362d donations.php
cleanup
2023-02-16 21:03:06 +01:00
schrom01 32df2cde0a donations.php
cleanup
2023-02-16 20:51:20 +01:00
schrom01 e506a864bf donations.php
cleanup
2023-02-16 20:48:27 +01:00
schrom01 456afc6a12 donations.php
cleanup
2023-02-16 20:46:12 +01:00
schrom01 f0a1149558 donations.php
cleanup
2023-02-16 20:14:11 +01:00
schrom01 ec71770847 donations.php
fix actual Date
2023-02-16 20:03:25 +01:00
schrom01 9cc8fb405c donations.php
fix actual Date
2023-02-16 19:48:17 +01:00
schrom01 bb33e4b319 donations.php
fix actual Date
2023-02-16 19:47:25 +01:00
schrom01 5cf7dc2e89 donations.php 2023-02-16 19:43:16 +01:00
schrom01 e6c89a06d3 donations.php 2023-02-16 19:41:27 +01:00
schrom01 c3f787f14a donations.php 2023-02-16 19:29:41 +01:00
schrom01 5fca34c303 donations.php 2023-02-16 15:06:31 +01:00
schrom01 d1768eec8b donations.php 2023-02-16 15:04:59 +01:00
schrom01 0f5c96cffc donations.php 2023-02-16 15:02:46 +01:00
schrom01 987f2138b4 donations.php 2023-02-16 14:52:26 +01:00
schrom01 1a44a68894 donations.php 2023-02-16 14:51:56 +01:00
schrom01 a085556519 donations.php 2023-02-16 14:45:36 +01:00
schrom01 3c9dd63f71 donations.php 2023-02-16 14:38:15 +01:00
schrom01 3995f8af9f donations.php 2023-02-16 14:36:53 +01:00
schrom01 de0d09f9c8 donations.php 2023-02-16 14:27:36 +01:00
schrom01 80ea8c84f9 donations.php 2023-02-16 14:25:14 +01:00
schrom01 d788e22471 Styling 2023-02-16 13:01:49 +01:00
schrom01 3ecbade48d Styling 2023-02-16 12:58:23 +01:00
schrom01 0e656e1f6b Styling 2023-02-16 12:55:52 +01:00
schrom01 5aba2420f8 Styling 2023-02-16 12:54:11 +01:00
schrom01 170e258b6e Styling 2023-02-16 12:44:42 +01:00
schrom01 1c22109df7 Styling 2023-02-16 12:44:01 +01:00
schrom01 7ee78f7f5c DataDownload 2023-02-15 17:28:23 +01:00
schrom01 f459f4d4a1 DataDownload 2023-02-15 17:26:23 +01:00
schrom01 9501370fae DataDownload 2023-02-15 17:12:23 +01:00
schrom01 8e2e2ecb61 change to SQL 2023-02-15 17:00:11 +01:00
schrom01 5c8dcb4ca4 change to SQL 2023-02-15 16:50:32 +01:00
schrom01 46021df0e5 change to SQL 2023-02-15 14:44:27 +01:00
schrom01 90cf02939f change to SQL 2023-02-15 14:40:55 +01:00
schrom01 ad99e62609 change to SQL 2023-02-15 14:37:50 +01:00
schrom01 610546c3bd change to SQL 2023-02-15 14:35:51 +01:00
schrom01 5642867c93 change to SQL 2023-02-15 14:34:11 +01:00
schrom01 856d5a41db change to SQL 2023-02-15 14:33:20 +01:00
schrom01 8b2796d00a change to SQL 2023-02-15 14:32:25 +01:00
schrom01 41d160b8dc change to SQL 2023-02-15 14:30:51 +01:00
schrom01 5a56668c93 change to SQL 2023-02-15 14:29:38 +01:00
schrom01 0dccb4bab2 change to SQL 2023-02-15 14:27:19 +01:00
schrom01 d044804cbb change to SQL 2023-02-15 14:18:54 +01:00
schrom01 59eb7aa3ae change to SQL 2023-02-15 14:06:27 +01:00
schrom01 6eb32f2b5b change to SQL 2023-02-15 14:05:52 +01:00
schrom01 cad39e5adb change to SQL 2023-02-15 14:05:00 +01:00
schrom01 c4795fe336 change to SQL 2023-02-15 14:03:40 +01:00
schrom01 6ef5a86477 change to SQL 2023-02-15 13:59:59 +01:00
schrom01 f66bfa7d51 change to SQL 2023-02-15 13:55:01 +01:00
schrom01 e797580812 change to SQL 2023-02-15 13:53:57 +01:00
schrom01 973e5da155 change to SQL 2023-02-15 13:50:12 +01:00
schrom01 0e5864370f change to SQL 2023-02-15 13:46:05 +01:00
schrom01 8251d3d97f change to SQL 2023-02-15 13:41:11 +01:00
schrom01 4d50ad03bf change to SQL 2023-02-15 13:40:09 +01:00
schrom01 cc604420f3 change to SQL 2023-02-15 13:32:50 +01:00
schrom01 67c5550de6 change to SQL 2023-02-15 13:31:48 +01:00
schrom01 20618367e0 Download Link 2023-02-15 00:38:26 +01:00
schrom01 21bf206458 changed Data Template 2023-02-15 00:33:04 +01:00
schrom01 cc4f6d97c0 fixed Request Method 2023-02-15 00:28:12 +01:00
schrom01 fbbd126cd6 error handling with local Storage 2023-02-15 00:17:44 +01:00
schrom01 a9cad34e71 send Data to Server 2023-02-15 00:06:36 +01:00
schrom01 8a1a7d19b5 data Download Link 2023-02-14 23:49:23 +01:00
schrom01 c3fd986144 php functions to Store data 2023-02-14 23:47:03 +01:00
schrom01 930bd7de4b php functions to Store data 2023-02-14 23:20:53 +01:00
schrom01 a945fca764 php functions to Store data 2023-02-14 19:56:51 +01:00
schrom01 403099ebd6 refactoring 2023-02-14 12:42:31 +01:00
11 changed files with 2773 additions and 176 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# genderwatchprotocol
für Maurus Pfalzgraf
für Maurus Pfalzgraf / Die Feministen
Trello Link
https://trello.com/b/RvSEhupx/some
+3
View File
@@ -0,0 +1,3 @@
CREATE TABLE `u517357132_genderwatchpro`.`topics` ( `id` VARCHAR(8) CHARACTER SET ascii COLLATE ascii_bin NOT NULL , `lastSave` INT NULL DEFAULT CURRENT_TIMESTAMP , `fullJSON` JSON NOT NULL , `timeWatchM` INT NOT NULL , `timeWatchW` INT NOT NULL , `timeWatchD` INT NOT NULL , `countWatchM` INT NOT NULL , `countWatchW` INT NOT NULL , `countWatchD` INT NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
INSERT INTO `topics` (`id`, `lastSave`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ('test', 2014, '{}', 10, 10, 10, 10, 40, 10) ON DUPLICATE KEY UPDATE `id` = 'test'
+80 -1
View File
@@ -1,3 +1,82 @@
.active {
.activeWatch {
background-color: lightgray;
}
h2 {
margin-left: 10px;
margin-top: 25px !important;
}
.table-bordered {
width: 100%;
table-layout: fixed;
text-align: center;
/*border: 1px solid #0e0017 !important;*/
}
td {
overflow-wrap: break-word;
}
button {
/*background-color: lightgray;*/
/*border: none;*/
/*color: white;*/
padding: 1% 5%;
text-align: center;
text-decoration: none;
display: inline-block;
/*font-size: 16px;*/
border-radius: 20px;
}
button, .form-group{
margin: 5px !important;
}
input {
text-align: center;
}
.stopButton, .resetButton {
width: 98% !important;
}
.form-group {
width: 98%;
}
.tableHeader {
min-width: 100px;
}
html, body {
height: 100%;
margin: 0;
}
body {
background-color: #FAF2E9 !important;
}
.wrapper {
min-height: 100%;
/* Equal to height of footer */
/* But also accounting for potential margin-bottom of last child */
margin-bottom: -200px;
}
footer,
.push {
height: 200px;
}
.footer {
vertical-align: top;
text-align: left;
}
BIN
View File
Binary file not shown.
+75
View File
@@ -0,0 +1,75 @@
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/read_write_xlsx.php';
require $_SERVER['DOCUMENT_ROOT'] . '/databaseConnection/databaseConnection.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];
}
$conn = getDatabaseConnection();
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
echo "connection sucessful<br>";
}
function saveToDatabase($contentArray, $conn) {
echo "sending Query to Database<br>";
$sql1 = "SELECT * FROM `topics` WHERE id='".$contentArray[0]."'";
$result1 = $conn->query($sql1);
echo "Select Query sent<br>";
if($result1->num_rows === 0) {
$sql = "INSERT INTO `topics` (`id`, `lastSave`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ('".$contentArray[0]."', ".$contentArray[1]." , '".$contentArray[2]."', ".$contentArray[3].", ".$contentArray[4].", ".$contentArray[5].", ".$contentArray[6].", ".$contentArray[7].", ".$contentArray[8].") ON DUPLICATE KEY UPDATE `id` = '".$contentArray[0]."'";
$result = $conn->query($sql);
echo "Insert Query sent<br> Result: " . $result;
} else {
$sql = "UPDATE `topics` SET `id`='".$contentArray[0]."',`lastSave`='".$contentArray[1]."',`fullJSON`='".$contentArray[2]."',`timeWatchM`='".$contentArray[3]."',`timeWatchW`='".$contentArray[4]."',`timeWatchD`='".$contentArray[5]."',`countWatchM`='".$contentArray[6]."',`countWatchW`='".$contentArray[7]."',`countWatchD`='".$contentArray[8]."' WHERE `id` = '".$contentArray[0]."'";
$result = $conn->query($sql);
echo "Update Query sent<br> Result: " . $result;
}
return;
}
function getFromDatabase($conn) {
$sql = "SELECT `id`, `firstSave`, `lastSave`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD` FROM `topics`";
$result = $conn->query($sql);
$dataArray = Array();
while($row = $result->fetch_assoc()) {
array_push($dataArray, [$row["id"],$row["firstSave"],$row["lastSave"],$row["fullJSON"],$row["timeWatchM"],$row["timeWatchW"],$row["timeWatchD"],$row["countWatchM"],$row["countWatchW"],$row["countWatchD"]]);
}
return $dataArray;
}
$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")) {
if(! ($entityBodyObject->countWatchM + $entityBodyObject->countWatchW + $entityBodyObject->countWatchD === 0)){
saveToDatabase(objectToArray($entityBodyObject, $entityBody), $conn);
echo "<br>Data saved.<br>";
}
}
} elseif($_SERVER['REQUEST_METHOD'] === 'GET') {
download_xlsxFile(getFromDatabase($conn));
} else {
echo "invalid Request.<br> Type: ".$_SERVER['REQUEST_METHOD'];
}
$conn->close();
+62
View File
@@ -0,0 +1,62 @@
<?php
// Lädt die .env Datei einen Ordner über dieser Datei
function loadEnv(): void
{
$envPath = dirname(__DIR__, 1) . '/.env';
if (!file_exists($envPath)) {
throw new RuntimeException('.env file not found at: ' . $envPath);
}
$lines = file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || str_starts_with($line, '#')) {
continue;
}
[$key, $value] = array_pad(explode('=', $line, 2), 2, '');
$key = trim($key);
$value = trim($value);
$_ENV[$key] = $value;
putenv("$key=$value");
}
}
// .env einmal laden
loadEnv();
function env(string $key, $default = null)
{
return $_ENV[$key] ?? getenv($key) ?? $default;
}
function getDatabaseConnection(): mysqli
{
$databaseAddress = env('DB_HOST', '127.0.0.1');
$databasePort = env('DB_PORT', '3306');
$databaseName = env('DB_NAME');
$databaseUser = env('DB_USER');
$databasePassword = env('DB_PASS');
$mysqli = new mysqli(
$databaseAddress,
$databaseUser,
$databasePassword,
$databaseName,
(int) $databasePort
);
if ($mysqli->connect_error) {
throw new RuntimeException(
'Database connection failed: ' . $mysqli->connect_error
);
}
return $mysqli;
}
+223 -140
View File
@@ -1,140 +1,223 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/custom.css">
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<section>
<div class="container">
<h1>Genderwatch-protocol</h1>
<h2 style="margin-left: 10px;">Aktuelles Thema</h2>
<table class="table-bordered">
<tr>
<td colspan="2">
<input class="form-control" type="text" id="topicInput" placeholder="Thema hier eingeben">
</td>
<td>
<button class="" onclick="closeTopic()">
Thema abschliessen
</button>
</td>
</tr>
<tr>
<th>
M
</th>
<th>
W
</th>
<th>
D
</th>
</tr>
<tr>
<td id="time-0">
0
</td>
<td id="time-1">
0
</td>
<td id="time-2">
0
</td>
</tr>
<tr>
<td id="count-0">
0
</td>
<td id="count-1">
0
</td>
<td id="count-2">
0
</td>
</tr>
<tr>
<td>
<button class="" onclick="start(0)">Beginnt zu Reden</button>
</td>
<td>
<button class="" onclick="start(1)">Beginnt zu Reden</button>
</td>
<td>
<button class="" onclick="start(2)">Beginnt zu Reden</button>
</td>
</tr>
<tr>
<td colspan="3">
<button class="" style="width: 98%;" onclick="stop()">Hört auf zu Reden, -> Stille</button>
</td>
</tr>
<tr>
<td colspan="3">
<button class="" style="width: 98%;" onclick="resetButton()">Reset</button>
</td>
</tr>
</table>
</div>
<div class="container">
<H2>Abgeschlossene Themen</H2>
<button class="" onclick="buttonDeleteAllClosedTopics()">alle Löschen</button>
<table class="table-bordered">
<thead>
<tr>
<th style="min-width: 100px;">
Thema
</th>
<th style="min-width: 100px;">
M
</th>
<th style="min-width: 100px;">
W
</th>
<th style="min-width: 100px;">
D
</th>
</tr>
</thead>
<tbody id="closedTopicsTable">
</tbody>
</table>
</div>
</section>
<script src="js/functions.js"></script>
<script>
closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
if(!closedTopics) {
closedTopics = []
}
watches = JSON.parse(localStorage.getItem("watches"))
if(!watches){
reset()
}
document.getElementById("topicInput").value = localStorage.getItem("actualTopic")
document.getElementById("topicInput").addEventListener('keyup', saveActualTopicToLocalStorage);
refreshClosedTopics()
setInterval(() => {
refreshWatch(0)
refreshWatch(1)
refreshWatch(2)
}, 100);
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/custom.css?v=1.2">
<link rel="stylesheet" href="css/bootstrap.css">
<title>Gender Watch Protocol</title>
</head>
<body>
<!-- <nav class="navbar navbar-expand-lg navbar-light bg-light">-->
<!-- <a class="navbar-brand" href="index.html">Genderwatch-protocol&nbsp;</a>-->
<!-- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="true" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>-->
<!-- <div class="navbar-collapse collapse show" id="navbarSupportedContent">-->
<!-- <ul class="navbar-nav mr-auto">-->
<!-- <li class="nav-item active"> <a class="nav-link" href="index.html">Home</a> </li>-->
<!-- <li class="nav-item"> <a class="nav-link" href="beschreibung.php">Über uns</a> </li>-->
<!-- </ul>-->
<!-- <form class="form-inline my-2 my-lg-0">-->
<!-- </form>-->
<!-- </div>-->
<!-- </nav>-->
<div class="wrapper">
<section>
<div class="container">
<h1>Gender Watch Protocol</h1>
Mit diesem Tool kannst du die Redezeit in einer Diskussionsrunde oder Sitzung nach Geschlecht stoppen. So kannst du sicherstellen, dass Männer nicht am meisten Sprechzeit beanspruchen.
<h2>Aktuelles Thema</h2>
<table class="table-bordered">
<tr>
<td colspan="2">
<div class="form-group">
<input class="form-control" type="text" id="topicInput" placeholder="Thema hier eingeben">
</div>
</td>
<td>
<button class="" onclick="closeTopic()">
Thema abschliessen
</button>
</td>
</tr>
<tr>
<th>
Mann
</th>
<th>
Frau
</th>
<th>
Divers
</th>
</tr>
<tr>
<td id="time-0">
0
</td>
<td id="time-1">
0
</td>
<td id="time-2">
0
</td>
</tr>
<tr>
<td id="count-0">
0
</td>
<td id="count-1">
0
</td>
<td id="count-2">
0
</td>
</tr>
<tr>
<td>
<button class="" onclick="start(0)">Beginnt zu reden</button>
</td>
<td>
<button class="" onclick="start(1)">Beginnt zu reden</button>
</td>
<td>
<button class="" onclick="start(2)">Beginnt zu reden</button>
</td>
</tr>
<tr>
<td colspan="3">
<button class="stopButton" onclick="stop()">Hört auf zu reden, -> Stille</button>
</td>
</tr>
<tr>
<td colspan="3">
<button class="resetButton" onclick="resetButton()">Reset</button>
</td>
</tr>
</table>
</div>
<div class="container">
<H2>Abgeschlossene Themen</H2>
<button class="" onclick="buttonDeleteAllClosedTopics()">alle löschen</button>
<a href="dataCollector/dataCollector.php">Alle Daten herunterladen (anonymisiert)</a>
<table class="table-bordered">
<thead>
<tr>
<th class="tableHeader">
Thema
</th>
<th class="tableHeader">
Mann
</th>
<th class="tableHeader">
Frau
</th>
<th class="tableHeader">
Divers
</th>
</tr>
</thead>
<tbody id="closedTopicsTable">
</tbody>
</table>
</div>
</section>
<div class="push"></div>
</div>
</div>
<footer class="text-center">
<div class="container footer">
<div class="row">
<table>
<tr>
<td class="footer">
<div class="col-12">
<p><span><b>Impressum</b></span><br>
Die Feministen<br>
3000 Bern<br>
<a href="https://feministen.ch/" target="_blank" rel="noopener">www.feministen.ch</a><br>
</p>
</div>
</td>
<td class="footer">
<div class="col-12">
<p><span><b>Erstellt durch</b></span><br>
Silias KLG<br>
Toggenburgstrasse 31<br>
8245 Feuerthalen<br>
<a href="https://www.silias.ch" target="_blank">www.silias.ch</a><br>
<a href="mailto:info@silias.ch">info@silias.ch</a><br>
<a href="https://gitea.silias.ch/Silias-Public/genderwatchprotocol">Projekt Repository</a>
</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</footer>
<script src="js/functions.js"></script>
<script>
try {
closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
} catch (e) {
closedTopics = []
}
if(!closedTopics) {
closedTopics = []
}
try{
actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
} catch (e) {
initializeNewTopic()
}
if(!actualTopic) {
initializeNewTopic()
}
document.getElementById("topicInput").value = actualTopic.name
document.getElementById("topicInput").addEventListener('keyup', saveActualTopicName);
refreshClosedTopics()
setInterval(() => {
refreshWatch(0)
refreshWatch(1)
refreshWatch(2)
}, 100);
</script>
</body>
</html>
+65 -34
View File
@@ -1,10 +1,16 @@
function initializeNewTopic() {
actualTopic = {"name": "", "id": randomId()}
reset()
document.getElementById("topicInput").value = actualTopic.name
}
function reset() {
actualTopic.watches = [{"actions": []}, {"actions": []}, {"actions": []}]
saveWatchesToLocalStorage()
saveActualTopic()
}
function resetButton() {
if(confirm("Soll die Zähler zurückgesetzt werden?")){
if(confirm("Sollen die Zähler zurückgesetzt werden?")){
reset()
}
}
@@ -12,7 +18,7 @@ function resetButton() {
function buttonDeleteAllClosedTopics() {
if(confirm("Sollen alle abgeschlossenen Themen gelöscht werden?")) {
closedTopics = []
saveClosedTopicsToLocalStorage()
saveClosedTopics()
refreshClosedTopics()
}
}
@@ -24,8 +30,9 @@ function buttonDeleteClosedTopic(topicIndex) {
}
function closeTopic() {
stop()
let defaultname = "Thema"
let name = document.getElementById("topicInput").value
let name = actualTopic.name
let nameLessCounter = 1
while(!name){
let foundName = false
@@ -40,53 +47,50 @@ function closeTopic() {
name = defaultname + nameLessCounter
}
}
closedTopics.push({"name": name, "watches": watches})
stop()
reset()
document.getElementById("topicInput").value = ""
saveActualTopicToLocalStorage()
saveClosedTopicsToLocalStorage()
actualTopic.name = name
closedTopics.push(actualTopic)
saveClosedTopics()
refreshClosedTopics()
initializeNewTopic()
}
function deleteTopic(topicIndex) {
closedTopics = closedTopics.slice(0, topicIndex).concat(closedTopics.slice(topicIndex+1))
saveClosedTopicsToLocalStorage()
saveClosedTopics()
refreshClosedTopics()
}
function reopenTopic(topicIndex) {
if(watches[0]["actions"]["length"] > 0 || watches[1]["actions"]["length"] > 0 ||watches[2]["actions"]["length"] > 0 || document.getElementById("topicInput").value != "") {
if(actualTopic.watches[0]["actions"]["length"] > 0 || actualTopic.watches[1]["actions"]["length"] > 0 ||actualTopic.watches[2]["actions"]["length"] > 0 || actualTopic.name !== "") {
closeTopic()
}
watches = closedTopics[topicIndex]["watches"]
document.getElementById("topicInput").value = closedTopics[topicIndex]["name"]
actualTopic = closedTopics[topicIndex]
document.getElementById("topicInput").value = actualTopic.name
deleteTopic(topicIndex)
saveWatchesToLocalStorage()
saveActualTopicToLocalStorage()
saveClosedTopics()
saveActualTopic()
}
function start(watchIndex) {
stop()
watches[watchIndex].actions.push({"type": "start", "time": new Date().getTime()})
saveWatchesToLocalStorage()
actualTopic.watches[watchIndex].actions.push({"type": "start", "time": new Date().getTime()})
saveActualTopic()
}
function stop() {
watches.forEach(watch => {
actualTopic.watches.forEach(watch => {
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()})
}
}
});
saveWatchesToLocalStorage()
saveActualTopic()
}
function calcPercForWatch(watchIndex, topic) {
let sumAll = sumAllwatches(topic)
if(sumAll == 0) {
if(sumAll === 0) {
return 0
}
return Math.round(sumForWatch(topic.watches[watchIndex]) / sumAllwatches(topic) * 100)
@@ -112,7 +116,7 @@ function countForWatch(watch) {
function calcPercCountForWatch(watchindex, topic) {
let sumAll = sumCountAllWatches(topic)
if(sumAll == 0) {
if(sumAll === 0) {
return 0
}
return Math.round(countForWatch(topic.watches[watchindex]) / sumAll * 100)
@@ -132,14 +136,14 @@ function timeToISO(time){
function refreshWatch(watchIndex) {
let timeCell = document.getElementById("time-" + watchIndex)
timeCell.textContent = timeToISO(sumForWatch(watches[watchIndex]))
if(watches[watchIndex]["actions"].length != 0 && watches[watchIndex]["actions"].slice(-1)[0]["type"] == "start"){
timeCell.classList.add("active")
timeCell.textContent = timeToISO(sumForWatch(actualTopic.watches[watchIndex]))
if(actualTopic.watches[watchIndex]["actions"].length !== 0 && actualTopic.watches[watchIndex]["actions"].slice(-1)[0]["type"] === "start"){
timeCell.classList.add("activeWatch")
} else {
timeCell.classList.remove("active")
timeCell.classList.remove("activeWatch")
}
let countCell = document.getElementById("count-" + watchIndex)
countCell.textContent = countForWatch(watches[watchIndex]) + " Wortmeldungen"
countCell.textContent = countForWatch(actualTopic.watches[watchIndex]) + " Wortmeldungen"
}
function refreshClosedTopics() {
@@ -178,15 +182,36 @@ function refreshClosedTopics() {
}
}
function saveWatchesToLocalStorage() {
localStorage.setItem("watches", JSON.stringify(watches))
function saveActualTopicName() {
actualTopic.name = document.getElementById("topicInput").value
saveActualTopic()
}
function saveActualTopicToLocalStorage() {
localStorage.setItem("actualTopic", document.getElementById("topicInput").value)
function saveActualTopic() {
//save it to LocalStorage
localStorage.setItem("actualTopic", JSON.stringify(actualTopic))
//save it to Server
fetch(document.URL + "dataCollector/dataCollector.php", {
method: 'POST',
headers: { 'Content-type': 'application/json' },
body: JSON.stringify({
"lastSave": new Date().getTime(),
"timeWatchM": sumForWatch(actualTopic.watches[0]),
"timeWatchW": sumForWatch(actualTopic.watches[1]),
"timeWatchD": sumForWatch(actualTopic.watches[2]),
"countWatchM": countForWatch(actualTopic.watches[0]),
"countWatchW": countForWatch(actualTopic.watches[1]),
"countWatchD": countForWatch(actualTopic.watches[2]),
"id": actualTopic.id,
"watches": actualTopic.watches
})
});
}
function saveClosedTopicsToLocalStorage() {
function saveClosedTopics() {
localStorage.setItem("closedTopics", JSON.stringify(closedTopics))
}
@@ -202,4 +227,10 @@ function elt (type, attrs, ...children) {
else node.appendChild(document.createTextNode(child))
}
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
+29
View File
@@ -0,0 +1,29 @@
<?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);
}
function download_xlsxFile($data) {
$xlsxArray = read_xls_file($_SERVER['DOCUMENT_ROOT'] ."/data/data.xlsx");
foreach ($data as $row) {
array_push($xlsxArray, $row);
}
$xlsx = SimpleXLSXGen::fromArray($xlsxArray);
$xlsx->downloadAs("data.xlsx");
}