Compare commits

...

65 Commits

Author SHA1 Message Date
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
8 changed files with 319 additions and 127 deletions

3
SQL/Queries.sql Normal file
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'

View File

@ -1,3 +1,73 @@
.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;
}
.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;
}

Binary file not shown.

View File

@ -1,5 +1,6 @@
<?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,
@ -13,43 +14,62 @@ function objectToArray($object, $fullJSON) {
$object -> countWatchD];
}
function findRowIndex($id, $data) {
$rowCounter = -1;
foreach ($data as $row) {
$rowCounter ++;
if($row[0] == $id) {
return $rowCounter;
}
$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 $rowCounter + 1;
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') {
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." ";
}
if(! ($entityBodyObject->countWatchM + $entityBodyObject->countWatchW + $entityBodyObject->countWatchD === 0)){
saveToDatabase(objectToArray($entityBodyObject, $entityBody), $conn);
echo "<br>Data saved.<br>";
}
$rowIndex = findRowIndex($entityBodyObject->id, $data);
$data[$rowIndex] = objectToArray($entityBodyObject, $entityBody);
write_xlsxFile($fileName, $data);
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();

View File

@ -0,0 +1,10 @@
<?php
function getDatabaseConnection() {
$databaseAddress = "127.0.0.1";
$databasePort = "3306";
$databaseName = "u517357132_genderwatchpro";
$databaseUser = "u517357132_genderwatchpro";
$databasePassword = "zU!7gRHA6x";
return new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
}

View File

@ -1,130 +1,193 @@
<html lang="de">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/custom.css">
<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.1">
<link rel="stylesheet" href="css/bootstrap.css">
<title>Genderwatch-protocol</title>
</head>
<body>
<section>
<div class="container">
<h1>Genderwatch-protocol</h1>
<a href="data/data.xlsx">Anonyme Daten herunterladen</a>
<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>
<!-- <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">-->
</div>
<!-- <li class="nav-item active"> <a class="nav-link" href="index.html">Home</a> </li>-->
<div class="container">
<!-- <li class="nav-item"> <a class="nav-link" href="beschreibung.php">Über uns</a> </li>-->
<H2>Abgeschlossene Themen</H2>
<button class="" onclick="buttonDeleteAllClosedTopics()">alle Löschen</button>
<table class="table-bordered">
<thead>
<!-- </ul>-->
<!-- <form class="form-inline my-2 my-lg-0">-->
<!-- </form>-->
<!-- </div>-->
<!-- </nav>-->
<div class="wrapper">
<section>
<div class="container">
<h1>Genderwatch-protocol</h1>
<a href="dataCollector/dataCollector.php">Alle Daten herunterladen (anonymisiert)</a>
<h2>Aktuelles Thema</h2>
<table class="table-bordered">
<tr>
<th style="min-width: 100px;">
Thema
</th>
<th style="min-width: 100px;">
<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>
M
</th>
<th style="min-width: 100px;">
<th>
W
</th>
<th style="min-width: 100px;">
<th>
D
</th>
</tr>
</thead>
<tbody id="closedTopicsTable">
</tbody>
<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>
<table class="table-bordered">
<thead>
<tr>
<th class="tableHeader">
Thema
</th>
<th class="tableHeader">
M
</th>
<th class="tableHeader">
W
</th>
<th class="tableHeader">
D
</th>
</tr>
</thead>
<tbody id="closedTopicsTable">
</tbody>
</table>
</table>
</div>
</section>
<div class="push"></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>
Maurus Pfalzgraf<br>
<a href="mailto:info@genderwatchprotocol.com">info@genderwatchprotocol.com</a></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>
</section>
</footer>
<script src="js/functions.js"></script>
<script>
closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
try {
closedTopics = JSON.parse(localStorage.getItem("closedTopics"))
} catch (e) {
closedTopics = []
}
if(!closedTopics) {
closedTopics = []
}
actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
try{
actualTopic = JSON.parse(localStorage.getItem("actualTopic"))
} catch (e) {
initializeNewTopic()
}
if(!actualTopic) {
initializeNewTopic()
}

View File

@ -138,9 +138,9 @@ function refreshWatch(watchIndex) {
let timeCell = document.getElementById("time-" + watchIndex)
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("active")
timeCell.classList.add("activeWatch")
} else {
timeCell.classList.remove("active")
timeCell.classList.remove("activeWatch")
}
let countCell = document.getElementById("count-" + watchIndex)
countCell.textContent = countForWatch(actualTopic.watches[watchIndex]) + " Wortmeldungen"
@ -192,10 +192,26 @@ function saveActualTopicName() {
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 saveClosedTopics() {
//save it to LocalStorage
localStorage.setItem("closedTopics", JSON.stringify(closedTopics))
}

View File

@ -1,6 +1,7 @@
<?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)) {
@ -17,3 +18,12 @@ 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");
}