Remove interval once the website loads
This commit is contained in:
parent
ae54c490d5
commit
f3398708ee
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
/node_modules/
|
||||
/static/
|
||||
/.log/
|
||||
/yarn-error.log
|
||||
|
|
|
@ -83,6 +83,7 @@ prepare_firefox(){
|
|||
keycombo Shift_L F5 #profiler
|
||||
grab "after shift-c F5"
|
||||
keycombo Control_L Shift_L e
|
||||
sleep 5 # it needs some time
|
||||
}
|
||||
|
||||
load_website(){
|
||||
|
|
23
index.js
23
index.js
|
@ -32,23 +32,12 @@ function attach(docker_id, output_stream) {
|
|||
output_stream.push(d);
|
||||
});
|
||||
task.on("close", () => {
|
||||
const check = spawn("docker", ["ps", "--filter", `id=${docker_id}`]);
|
||||
let output = "";
|
||||
check.on("data", (data) => {
|
||||
output += data;
|
||||
});
|
||||
check.on("close", () => {
|
||||
console.log("CHECK", output);
|
||||
output_stream.push("</pre>");
|
||||
output_stream.push(/* HTML */ `<script>
|
||||
clearInterval(window.interval);
|
||||
</script>`);
|
||||
clearInterval(interval);
|
||||
});
|
||||
check.on("error", (error) => {
|
||||
console.error("error", error);
|
||||
clearInterval(interval);
|
||||
});
|
||||
check.on("exit", (error) => {
|
||||
console.error("exit", error);
|
||||
clearInterval(interval);
|
||||
});
|
||||
output_stream.push(null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,7 +53,7 @@ router.get("/", async (ctx) => {
|
|||
`<img id="preview" width="1080" height="608" src="/static/${id}/preview.png?id=0"/><br/>`
|
||||
);
|
||||
ctx.body.push(/* HTML */ `<script>
|
||||
setInterval(() => (preview.src = preview.src + "0"), 500);
|
||||
window.interval = setInterval(() => (preview.src = preview.src + "0"), 500);
|
||||
</script>`);
|
||||
const params = qs.parse(ctx.querystring);
|
||||
s.push(`Got request to screenshot ${params.url}<pre>`);
|
||||
|
|
Loading…
Reference in New Issue
Block a user