mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 03:13:48 +08:00
33d5cfc393
date: 2025-12-18T23:23:16 master commit: 3cdee7b54718ee14bd85befd6c5bad3d699c5479
28 lines
975 B
JavaScript
28 lines
975 B
JavaScript
import { handleKeyX, executePlan } from "./controls.js";
|
|
import { start, stop, lastChannelMessageTime, playSoundRequest } from "./webrtc.js";
|
|
|
|
export var pc = null;
|
|
export var dc = null;
|
|
|
|
document.addEventListener('keydown', (e)=>(handleKeyX(e.key.toLowerCase(), 1)));
|
|
document.addEventListener('keyup', (e)=>(handleKeyX(e.key.toLowerCase(), 0)));
|
|
$(".keys").bind("mousedown touchstart", (e)=>handleKeyX($(e.target).attr('id').replace('key-', ''), 1));
|
|
$(".keys").bind("mouseup touchend", (e)=>handleKeyX($(e.target).attr('id').replace('key-', ''), 0));
|
|
$("#plan-button").click(executePlan);
|
|
$(".sound").click((e)=>{
|
|
const sound = $(e.target).attr('id').replace('sound-', '')
|
|
return playSoundRequest(sound);
|
|
});
|
|
|
|
setInterval( () => {
|
|
const dt = new Date().getTime();
|
|
if ((dt - lastChannelMessageTime) > 1000) {
|
|
$(".pre-blob").removeClass('blob');
|
|
$("#battery").text("-");
|
|
$("#ping-time").text('-');
|
|
$("video")[0].load();
|
|
}
|
|
}, 5000);
|
|
|
|
start(pc, dc);
|