2022-01-15 13:14:17 +01:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
|
|
|
|
<script src="/assets/external/xterm.js"></script>
|
|
|
|
<script src="/assets/external/xterm-addon-attach.js"></script>
|
|
|
|
<script src="/assets/external/xterm-addon-fit.js"></script>
|
|
|
|
<script src="/assets/external/xterm-addon-web-links.js"></script>
|
|
|
|
|
|
|
|
<script src="/assets/replay.js"></script>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="/assets/external/xterm.css" />
|
|
|
|
<link href="/assets/external/bootstrap.min.css" rel="stylesheet">
|
|
|
|
<link rel="stylesheet" href="/assets/main.css" />
|
|
|
|
|
|
|
|
<title>Replay</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<header>
|
2022-01-17 12:52:09 +01:00
|
|
|
<nav class="navbar navbar-light bg-light shadow-sm navbar-xs">
|
2022-01-15 13:14:17 +01:00
|
|
|
<div class="container-fluid">
|
|
|
|
<a class="navbar-brand mx-auto" href="https://github.com/syssecfsu/witty" target="_blank">
|
2022-01-18 14:43:10 +01:00
|
|
|
<img src="/assets/img/record.svg" style="margin-right: 0.5rem;" height="32"
|
2022-01-15 13:14:17 +01:00
|
|
|
class="d-inline-block align-text-top">
|
|
|
|
replay terminal
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="d-flex flex-column align-items-center" style="margin-top: 2rem;">
|
|
|
|
<div id="terminal">
|
|
|
|
<div id="terminal_view"></div>
|
|
|
|
</div>
|
|
|
|
<div class="d-flex align-items-center">
|
2022-01-16 00:54:15 +01:00
|
|
|
<button type="button" class="btn btn-primary btn-sm" style="margin-right: 3px;" onclick="playbtn()">
|
2022-01-17 12:52:09 +01:00
|
|
|
<img src="/assets/img/play.svg" id="play-btn" height="18px">
|
2022-01-15 13:14:17 +01:00
|
|
|
</button>
|
2022-01-18 20:52:04 +01:00
|
|
|
<input type="range" class="form-range" min="0" max="100" id="replay-control" onchange="seek(this.value)">
|
2022-01-15 13:14:17 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2022-01-16 00:54:15 +01:00
|
|
|
term = Init()
|
|
|
|
|
|
|
|
var rc = document.querySelector("#replay-control")
|
|
|
|
rc.value = 0
|
|
|
|
|
|
|
|
var icon = document.getElementById("play-btn")
|
|
|
|
var pause = false
|
2022-01-18 20:52:04 +01:00
|
|
|
|
|
|
|
var records
|
|
|
|
var total_dur
|
|
|
|
|
|
|
|
// return values are not reliable with async functions
|
|
|
|
fetchAndParse("/records/{{.fname}}",
|
|
|
|
function (v1, v2) {
|
|
|
|
records = v1
|
|
|
|
total_dur = v2
|
|
|
|
})
|
2022-01-16 00:54:15 +01:00
|
|
|
|
|
|
|
function playbtn() {
|
|
|
|
if (icon.src.includes("play")) {
|
2022-01-17 12:52:09 +01:00
|
|
|
icon.src = "/assets/img/pause.svg"
|
2022-01-16 00:54:15 +01:00
|
|
|
pause = false
|
2022-01-18 20:52:04 +01:00
|
|
|
replay_session(term, records, total_dur, rc.value,
|
2022-01-16 00:54:15 +01:00
|
|
|
function () {
|
|
|
|
return pause
|
|
|
|
},
|
|
|
|
function (percent) {
|
|
|
|
rc.value = percent
|
2022-01-16 03:17:03 +01:00
|
|
|
},
|
|
|
|
function () {
|
2022-01-17 12:52:09 +01:00
|
|
|
icon.src = "/assets/img/play.svg"
|
2022-01-16 03:17:03 +01:00
|
|
|
rc.value = 0
|
2022-01-16 00:54:15 +01:00
|
|
|
})
|
|
|
|
} else {
|
2022-01-17 12:52:09 +01:00
|
|
|
icon.src = "/assets/img/play.svg"
|
2022-01-16 00:54:15 +01:00
|
|
|
pause = true
|
|
|
|
}
|
2022-01-15 13:14:17 +01:00
|
|
|
}
|
2022-01-18 20:52:04 +01:00
|
|
|
|
|
|
|
function seek(end) {
|
|
|
|
// pause the play if it is currently playing
|
|
|
|
if (!icon.src.includes("play")) {
|
|
|
|
playbtn()
|
|
|
|
}
|
|
|
|
|
|
|
|
forwardScreen(term, records, end)
|
|
|
|
}
|
2022-01-15 13:14:17 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|