juggl/juggl-server/index.html

125 lines
No EOL
3.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Juggl</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" type="image/ico" href="/assets/logo.ico" />
<link href="https://fonts.googleapis.com/css2?family=Karla:ital,wght@0,400;0,700;1,400;1,700&display=swap"
rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/umbrella.min.js"></script>
<script src="js/statehandler.js"></script>
<script src="js/auth.js"></script>
<script src="js/api.js"></script>
<script src="js/helper.js"></script>
<script>
var intervallId = undefined;
window.onblur = () => {
stopBackgroundUpdates();
}
window.onfocus = () => {
startBackgroundUpdates();
}
window.onload = () => {
// Create Callbacks
callbacks.entering[States.RECORDING] = () => {
updateProgess();
loadRecordTags();
};
callbacks.entering[States.IDLE] = () => {
loadProjectList().then(() => {
checkForUpdate();
});
};
initState();
updateVisibility();
updateAuthBtnText();
startBackgroundUpdates();
}
function checkForUpdate() {
if (currentRecord !== undefined) {
updateProgess();
} else {
initRunningRecords().then(() => {
if (currentRecord !== undefined) {
setState(States.RECORDING);
}
});
}
}
function updateProgess () {
if (currentRecord === undefined) {
return;
}
updateCurrentRecord().then((record) => {
if (record.end_time != null) {
currentRecord = undefined;
setState(States.IDLE);
return;
}
u("#current-project-name").text(currentProject.name);
u("#current-record-duration").text((parseInt(record.duration) / 60).toFixed(1) + " min.");
});
}
function startBackgroundUpdates () {
if (intervallId !== undefined) return;
intervallId = setInterval(checkForUpdate, 30000);
checkForUpdate();
}
function stopBackgroundUpdates () {
clearInterval(intervallId);
intervallId = undefined;
}
</script>
</head>
<body>
<header>
<ul id="header-container">
<li>
<img src="assets/logo_title.png">
</li>
<li style="float: right">
<input id="user-id" class="public hidden" type="text" placeholder="User ID" />
<input id="api-key" class="public hidden" type="password" placeholder="API Key" />
<button id="auth-btn" onclick="handleAuthBtn()">Log In</button>
</li>
</ul>
</header>
<main>
<div class="recording hidden" style="text-align: center;">
<h1>
Currently Tracking
</h1>
<div id="tracking-list">
</div>
</div>
<div class="idle recording hidden" style="text-align: center;">
<h1>
Select project to track
</h1>
<div id="project-list">
</div>
</div>
<div class="idle recording hidden" style="text-align: center;">
<h1>
Records
</h1>
<div id="record-list">
</div>
</div>
</main>
</body>
</html>