|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Zhurnal</title>
|
|
<style>
|
|
body { background: black; color: white; font-family: sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
|
.container { width: 80%; max-width: 600px; text-align: center; }
|
|
input { width: 100%; background: #333; color: white; border: none; padding: 10px; border-radius: 5px; box-sizing: border-box; }
|
|
button { margin-top: 10px; background: #555; color: white; border: none; padding: 10px; border-radius: 5px; cursor: pointer; }
|
|
#updates { text-align: left; margin-top: 20px; list-style: none; padding: 0; overflow: auto; max-height: 200px; }
|
|
#updates li { margin-bottom: 5px; }
|
|
@media (min-width: 320px) { .container { width: 90%; } }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Zhurnal</h1>
|
|
<p>Enter repository URL (supports https://, http://, Gitea, GitLab, auth like https://user:pass@domain/repo)</p>
|
|
<form id="form">
|
|
<input id="repo_url" name="repo_url" placeholder="Repository URL" required>
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
<ul id="updates"></ul>
|
|
</div>
|
|
<script>
|
|
document.getElementById('form').addEventListener('submit', async e => {
|
|
e.preventDefault();
|
|
const formData = new FormData(e.target);
|
|
const res = await fetch('/submit', { method: 'POST', body: formData });
|
|
if (!res.ok) {
|
|
const err = await res.text();
|
|
addUpdate(err);
|
|
return;
|
|
}
|
|
const { hash } = await res.json();
|
|
const protocol = location.protocol === 'https:' ? 'wss://' : 'ws://';
|
|
const ws = new WebSocket(`${protocol}${location.host}/ws/${hash}`);
|
|
ws.onmessage = evt => {
|
|
const data = JSON.parse(evt.data);
|
|
if (data.type === 'message') addUpdate(data.content);
|
|
else if (data.type === 'redirect') location.href = data.url;
|
|
else if (data.type === 'error') addUpdate(`Error: ${data.content}`);
|
|
};
|
|
});
|
|
function addUpdate(content) {
|
|
const li = document.createElement('li');
|
|
li.textContent = content;
|
|
document.getElementById('updates').appendChild(li);
|
|
window.scrollTo(0, document.body.scrollHeight);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|