From fa0bc4e2402ad14060477737bbea879a94f6eccb Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Mon, 27 Nov 2023 20:03:04 +0800 Subject: [PATCH] add js --- rcmd.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 rcmd.js diff --git a/rcmd.js b/rcmd.js new file mode 100644 index 0000000..46d7a63 --- /dev/null +++ b/rcmd.js @@ -0,0 +1,45 @@ +// 远程演示文稿 + +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("无法再向下翻页了。") + } + } + +};