2022-01-17 21:20:18 +01:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<meta name="description" content="">
|
|
|
|
<meta name="author" content="">
|
|
|
|
|
|
|
|
<!-- automatically refresh the page every 30 seconds -->
|
|
|
|
<!-- <meta http-equiv="refresh" content="30"> -->
|
|
|
|
|
|
|
|
<title>Web Terminal</title>
|
|
|
|
|
|
|
|
<!-- Bootstrap core CSS -->
|
|
|
|
<script src="/assets/external/bootstrap.min.js"></script>
|
|
|
|
<link href="/assets/external/bootstrap.min.css" rel="stylesheet">
|
|
|
|
<link href="/assets/main.css" rel="stylesheet">
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<header>
|
|
|
|
<nav class="navbar navbar-dark bg-dark shadow-sm navbar-xs">
|
|
|
|
<div class="container-fluid">
|
|
|
|
<a class="navbar-brand mx-auto" href="https://github.com/syssecfsu/witty" target="_blank">
|
|
|
|
<img src="/assets/img/logo.svg" style="margin-right: 0.5rem;" height="32"
|
|
|
|
class="d-inline-block align-text-top">
|
|
|
|
WiTTY: Web-based interactive TTY
|
|
|
|
</a>
|
2022-01-21 15:36:31 +01:00
|
|
|
<div class="btn-toolbar float-end" role="toolbar" aria-label="top buttons">
|
2022-01-23 00:21:59 +01:00
|
|
|
<form action="/new" method="post" target="_blank" onsubmit="setTimeout(function(){refresh(true)}, 1000)">
|
|
|
|
{{.csrfField}}
|
|
|
|
<button class="btn btn-primary btn-sm m-1" type="submit">New Session</button>
|
|
|
|
</form>
|
|
|
|
|
2022-01-22 03:42:22 +01:00
|
|
|
<a class="btn btn-primary btn-sm m-1 {{.disabled}}" href="/logout" role="button">
|
2022-01-21 15:36:31 +01:00
|
|
|
Logout
|
|
|
|
</a>
|
|
|
|
</div>
|
2022-01-17 21:20:18 +01:00
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
|
2022-01-26 03:36:19 +01:00
|
|
|
<!-- A modal to rename file -->
|
|
|
|
<div class="modal" id="renameModal" tabindex="-1" aria-labelledby="renameModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-body bg-light">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="new_name"><strong>Rename</strong></label>
|
|
|
|
<label for="new_name" class="col-form-label"></label>
|
|
|
|
<input type="text" class="form-control" id="new_name">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer bg-light">
|
|
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
|
|
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="rename_btn()">Rename</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-01-17 21:20:18 +01:00
|
|
|
<main>
|
|
|
|
<div class="container-fluid" style="margin-top:1em;">
|
|
|
|
<ul class="nav nav-tabs" id="js_sucks" role="tablist">
|
|
|
|
<li class="nav-item" role="presentation">
|
|
|
|
<button class="nav-link bg-light active" id="interactive-tab" data-bs-toggle="tab"
|
|
|
|
data-bs-target="#interactive-cnt" type="button" role="tab" aria-controls="interactive-cnt"
|
2022-01-18 14:21:37 +01:00
|
|
|
aria-selected="true"><img src="/assets/img/keyboard.svg" style="margin-right: 0.5rem;" height="18px">Live
|
|
|
|
Sessions</button>
|
2022-01-17 21:20:18 +01:00
|
|
|
</li>
|
|
|
|
<li class="nav-item" role="presentation">
|
|
|
|
<button class="nav-link bg-light" id="saved-tab" data-bs-toggle="tab" data-bs-target="#saved-cnt"
|
2022-01-18 14:21:37 +01:00
|
|
|
type="button" role="tab" aria-controls="saved-cnt" aria-selected="false"><img src="/assets/img/record.svg"
|
2022-01-18 14:25:21 +01:00
|
|
|
style="margin-right: 0.5rem;" height="18px">Recorded Sessions</button>
|
2022-01-17 21:20:18 +01:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2022-01-17 21:32:55 +01:00
|
|
|
<div class="tab-content bg-light border border-info rounded-bottom" id="nav-tabContent">
|
2022-01-17 21:20:18 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var active_tab = 0
|
|
|
|
|
|
|
|
function del_btn(path) {
|
2022-01-23 00:21:59 +01:00
|
|
|
let formData = new FormData()
|
|
|
|
formData.append('gorilla.csrf.Token', {{.csrfToken}})
|
|
|
|
|
|
|
|
fetch("/delete/" + path, {
|
|
|
|
method: "POST",
|
|
|
|
body: formData,
|
|
|
|
})
|
2022-01-17 21:20:18 +01:00
|
|
|
setTimeout(function () {
|
|
|
|
refresh(true)
|
2022-01-17 21:23:02 +01:00
|
|
|
}, 20);
|
2022-01-17 21:20:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// fresh the page every 10 seconds, in case active sessions are closed.
|
|
|
|
function refresh(once) {
|
|
|
|
tabs = document.getElementById("nav-tabContent")
|
|
|
|
fetch("/update/" + active_tab)
|
|
|
|
.then((response) => {
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then((result) => {
|
|
|
|
tabs.innerHTML = result;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (once == false) {
|
|
|
|
setTimeout(function () {
|
|
|
|
refresh(false)
|
2022-01-17 21:24:18 +01:00
|
|
|
}, 8000);
|
2022-01-17 21:20:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
refresh(false)
|
|
|
|
|
|
|
|
var itab = document.querySelector('#interactive-tab')
|
|
|
|
itab.addEventListener('shown.bs.tab', function (event) {
|
|
|
|
active_tab = 0
|
|
|
|
})
|
|
|
|
|
|
|
|
var stab = document.querySelector('#saved-tab')
|
|
|
|
stab.addEventListener('shown.bs.tab', function (event) {
|
|
|
|
active_tab = 1
|
|
|
|
})
|
2022-01-26 03:36:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
var renameModal = document.getElementById('renameModal')
|
|
|
|
|
|
|
|
renameModal.addEventListener('show.bs.modal', function (event) {
|
|
|
|
var button = event.relatedTarget // which button lunched this modal
|
|
|
|
var file = button.getAttribute('data-bs-whatever')
|
|
|
|
var modalTitle = renameModal.querySelector('.col-form-label')
|
|
|
|
modalTitle.textContent = file
|
|
|
|
})
|
|
|
|
|
|
|
|
function rename_btn() {
|
|
|
|
var modalTitle = renameModal.querySelector('.col-form-label')
|
|
|
|
var modalInput = renameModal.querySelector('.form-control')
|
|
|
|
var newName = modalInput.value.trim()
|
|
|
|
|
|
|
|
if (newName == "") {
|
|
|
|
console.log("New name is empty, ignore request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
path = "/rename/" + modalTitle.textContent + "/" + newName
|
|
|
|
|
|
|
|
let formData = new FormData()
|
|
|
|
formData.append('gorilla.csrf.Token', {{.csrfToken}})
|
|
|
|
|
|
|
|
fetch(path, {
|
|
|
|
method: "POST",
|
|
|
|
body: formData,
|
|
|
|
})
|
|
|
|
setTimeout(function () {
|
|
|
|
refresh(true)
|
|
|
|
}, 20);
|
|
|
|
}
|
|
|
|
|
2022-01-17 21:20:18 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|