46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
// 远程演示文稿
|
|
|
|
const device_id = "test";
|
|
const server_url =
|
|
"https://ivampiresp.com/wp-content/rCMD/sse.php?device=" + device_id;
|
|
|
|
var eventSource = new EventSource(server_url);
|
|
|
|
eventSource.onmessage = function (event) {
|
|
const eventData = JSON.parse(event.data);
|
|
|
|
if (eventData.cmd == "" || eventData.param == "") {
|
|
return
|
|
}
|
|
|
|
if (eventData.cmd != 'press') {
|
|
console.warn("此窗口接收到了意外的请求: " + eventData.cmd + ",为了安全,将不会处理。")
|
|
return
|
|
}
|
|
|
|
console.log(eventData)
|
|
|
|
const availableRoutes = Reveal.availableRoutes();
|
|
|
|
if (eventData.param == 'up') {
|
|
if (availableRoutes.up) {
|
|
Reveal.up();
|
|
} else if (availableRoutes.left) {
|
|
Reveal.left();
|
|
} else {
|
|
console.warn("无法再向上翻页了。")
|
|
}
|
|
}
|
|
|
|
if (eventData.param == 'down') {
|
|
if (availableRoutes.down) {
|
|
Reveal.down();
|
|
} else if (availableRoutes.right) {
|
|
Reveal.right();
|
|
} else {
|
|
console.warn("无法再向下翻页了。")
|
|
}
|
|
}
|
|
|
|
};
|