add js
This commit is contained in:
parent
5536cb7f58
commit
fa0bc4e240
45
rcmd.js
Normal file
45
rcmd.js
Normal file
@ -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("无法再向下翻页了。")
|
||||
}
|
||||
}
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user