Files
schauausgmbh 9d00039e5e timetracker.html initial commit
First working version of the Gitea time tracker.
2026-10-25 14:51:38 +00:00

89 lines
3.6 KiB
HTML

<!DOCTYPE html>
<html>
<!--
This software is licensed under the This software is licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 (EUPL-1.2).
It is provided as is and no warrenties taken!
(c) 2026 - SCHAUAUS Gesellschaft m.b.H. - https://schauaus.at
-->
<header>
<title>Gitea tracked time parser</title>
<script>
var debug = false
function parseInput() {
if(debug) console.log(JSONinput.value)
let parsedData = JSON.parse(JSONinput.value)
if(debug) console.log( parsedData )
let trackedSeconds = 0
for(i=0; i < parsedData.length; i++) {
if(debug) console.log(parsedData[i].time)
trackedSeconds += parsedData[i].time
}
let trackedMinutes = Math.floor(trackedSeconds / 60)
let trackedHours = Math.floor(trackedMinutes / 60)
let trackedDays = Math.floor(trackedHours / 8)
let secondsLeft = trackedSeconds - trackedMinutes * 60
let minutesLeft = trackedMinutes - trackedHours * 60
let hoursLeft = trackedHours - trackedDays * 8
let trackedSecondsText = "Total time: " + trackedSeconds + " seconds"
if(debug) console.log(trackedSecondsText)
let totalTimeHoursText = "Total time: " + trackedHours + " hours " + minutesLeft + " minutes " + secondsLeft + " seconds"
if(debug) console.log(totalTimeHoursText)
let totalTimeText = "Total time: " + trackedDays + " working days (8 hours each) " + hoursLeft + " hours " + minutesLeft + " minutes " + secondsLeft + " seconds"
if(debug) console.log(totalTimeText)
let costPerHour = parseFloat( document.getElementById("costPerHour").value )
if(debug) console.log("cost per hour: " + costPerHour)
let totalCost = trackedSeconds * costPerHour / 3600
let totalCostText = "Total cost: " + Math.floor(totalCost * 100 + 0.5) / 100 + " &euro;"
if(debug) console.log(totalCostText)
document.getElementById("trackedSeconds").innerHTML = trackedSecondsText
document.getElementById("totalTimeHours").innerHTML = totalTimeHoursText
document.getElementById("totalTime").innerHTML = totalTimeText
document.getElementById("totalCost").innerHTML = totalCostText
document.getElementById("resultForm").style.display = "block"
document.getElementById("inputForm").style.display = "none"
}
</script>
</header>
<body>
<h1 style="text-align: center;">Gitea tracked time parser</h1>
<div id="inputForm">
<div style="margin: 0px auto 20px; text-align: center; width: 820px">
Input the JSON text from Gitea's API in the text area below.<br>
You can query the JSON text by calling your servers API:<br>
https://your-gitea-server/api/v1/repos/{ownerName}/{repoName}/times/{userName}?access_token={apiAccessToken}
</div>
<div style="margin: 0 auto; text-align: center;">
<label for="costPerHour">Cost per hour: </label><input id="costPerHour" name="costPerHour" type="text" value="50.0" size="5"> &euro;<br>
<br>
<textarea cols="100" id="JSONinput" rows=40></textarea><br>
<br>
<input type="button" onclick="parseInput()" value="Parse">
</div>
</div>
<div id="resultForm" style="margin: 0 auto; text-align: center; display:none">
<h2>total time</h2>
<span id="trackedSeconds"></span><br>
<span id="totalTimeHours"></span><br>
<span id="totalTime"></span><br>
<span id="totalCost"></span>
</div>
<br>
</body>
<footer style="text-align: center; font-size: small;">
<a href="https://git.schauaus.at/IT-tools/Gitea-time-tracker">Gitea time tracker by SCHAUAUS Gesellschaft m.b.H.</a>
</footer>
</html>