mirror of
https://github.com/syssecfsu/witty.git
synced 2024-11-01 09:39:26 +01:00
wip
This commit is contained in:
parent
b458da4414
commit
4cc5f72d13
@ -65,6 +65,10 @@
|
|||||||
},
|
},
|
||||||
function (percent) {
|
function (percent) {
|
||||||
rc.value = percent
|
rc.value = percent
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
icon.src = "/assets/play.svg"
|
||||||
|
rc.value = 0
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
icon.src = "/assets/play.svg"
|
icon.src = "/assets/play.svg"
|
||||||
|
@ -54,18 +54,18 @@ function _sleep(ms) {
|
|||||||
// we could sleep for a long time
|
// we could sleep for a long time
|
||||||
// periodically check if we need to end replay.
|
// periodically check if we need to end replay.
|
||||||
// This is pretty ugly but the callback mess otherwise
|
// This is pretty ugly but the callback mess otherwise
|
||||||
async function sleep(ms, end) {
|
async function sleep(ms, paused) {
|
||||||
var loop_cnt = parseInt(ms / 20) + 1
|
var loop_cnt = parseInt(ms / 20) + 1
|
||||||
|
|
||||||
for (i = 0; i < loop_cnt; i++) {
|
for (i = 0; i < loop_cnt; i++) {
|
||||||
if (end()) {
|
if (paused()) {
|
||||||
return end()
|
return paused()
|
||||||
}
|
}
|
||||||
|
|
||||||
await _sleep(20)
|
await _sleep(20)
|
||||||
}
|
}
|
||||||
|
|
||||||
return end()
|
return paused()
|
||||||
}
|
}
|
||||||
// convert data to uint8array, we cannot convert it to string as
|
// convert data to uint8array, we cannot convert it to string as
|
||||||
// it will mess up special characters
|
// it will mess up special characters
|
||||||
@ -84,7 +84,7 @@ function base64ToUint8array(base64) {
|
|||||||
// term: xterm, path: session file to replay,
|
// term: xterm, path: session file to replay,
|
||||||
// start: start position to replay in percentile, range 0-100
|
// start: start position to replay in percentile, range 0-100
|
||||||
// callback to update the progress bar
|
// callback to update the progress bar
|
||||||
async function replay_session(term, path, start, end, prog) {
|
async function replay_session(term, path, start, paused, prog, end) {
|
||||||
var session
|
var session
|
||||||
|
|
||||||
// read file from server
|
// read file from server
|
||||||
@ -112,7 +112,7 @@ async function replay_session(term, path, start, end, prog) {
|
|||||||
|
|
||||||
// we will blast through the beginning of the session
|
// we will blast through the beginning of the session
|
||||||
if (cur >= start) {
|
if (cur >= start) {
|
||||||
if (await sleep(item.Duration, end) == true) {
|
if (await sleep(item.Duration, paused) == true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,6 +123,8 @@ async function replay_session(term, path, start, end, prog) {
|
|||||||
|
|
||||||
term.write(base64ToUint8array(item.Data))
|
term.write(base64ToUint8array(item.Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end()
|
||||||
}
|
}
|
||||||
|
|
||||||
function Init() {
|
function Init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user