-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
151 lines (150 loc) · 4.57 KB
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { LoStatus, PresentationStatus} from './types.js'
export function getActionDefinitions(self) {
return {
start: {
name: 'Start Presentation',
options: [
{
type: 'number',
id: 'slide',
label: 'Slide:',
tooltip: 'Slide to start the presentation (0 for current Slide)',
default: 0,
useVariables: true,
}
],
callback: async (action) => {
if (self.socket == undefined || !self.socket.isConnected) {
self.log('debug', 'Socket not connected :(')
return
}
if (self.connectionStatus != LoStatus.Paired) {
self.log('debug', 'Libre Office Impress not paired')
return
} else if (self.presentationStatus == PresentationStatus.Stopped) {
const sendBuf = Buffer.from("presentation_start\n\n\n", 'latin1')
self.socket.send(sendBuf)
self.log('debug', '-> presentation_start')
}
let slide = Number(await self.parseVariablesInString(action.options.slide))
if (slide != 0) {
const sendBuf = Buffer.from("goto_slide\n" + (slide-1) + "\n\n", 'latin1')
self.log('debug', "-> " + sendBuf)
self.socket.send(sendBuf)
}
},
},
goto: {
name: 'Goto Slide',
options: [
{
type: 'number',
id: 'slide',
label: 'Slide:',
tooltip: 'Slide to go to',
default: 1,
useVariables: true,
}
],
callback: async (action) => {
if (self.socket == undefined || !self.socket.isConnected) {
self.log('debug', 'Socket not connected :(')
return
}
if (self.connectionStatus != LoStatus.Paired) {
self.log('debug', 'Libre Office Impress not paired')
return
} else if (self.presentationStatus == PresentationStatus.Stopped) {
self.log('debug', 'Presentation not running')
return
}
let slide = Number(await self.parseVariablesInString(action.options.slide))
if (slide != 0) {
const sendBuf = Buffer.from("goto_slide\n" + (slide-1) + "\n\n", 'latin1')
self.log('debug', "-> " + sendBuf)
self.socket.send(sendBuf)
}
},
},
next: {
name: 'Next Step',
options: [],
callback: async (action) => {
if (self.socket == undefined || !self.socket.isConnected) {
self.log('debug', 'Socket not connected :(')
return
}
if (self.connectionStatus != LoStatus.Paired) {
self.log('debug', 'Libre Office Impress not paired')
return
} else if (self.presentationStatus == PresentationStatus.Stopped) {
self.log('debug', 'Impress Presentation not running')
return
}
const sendBuf = Buffer.from("transition_next\n\n", 'latin1')
self.log('debug', "-> " + sendBuf)
self.socket.send(sendBuf)
},
},
previous: {
name: 'Previous Step',
options: [],
callback: async (action) => {
if (self.socket == undefined || !self.socket.isConnected) {
self.log('debug', 'Socket not connected :(')
return
}
if (self.connectionStatus != LoStatus.Paired) {
self.log('debug', 'Libre Office Impress not paired '+self.connectionStatus)
return
} else if (self.presentationStatus == PresentationStatus.Stopped) {
self.log('debug', 'Impress Presentation not running')
return
}
const sendBuf = Buffer.from("transition_previous\n\n", 'latin1')
self.log('debug', "-> " + sendBuf)
self.socket.send(sendBuf)
},
},
black: {
name: 'Black Screen',
options: [],
callback: async (action) => {
if (self.socket == undefined || !self.socket.isConnected) {
self.log('debug', 'Socket not connected :(')
return
}
if (self.connectionStatus != LoStatus.Paired) {
self.log('debug', 'Libre Office Impress not paired '+self.connectionStatus)
return
} else if (self.presentationStatus == PresentationStatus.Stopped) {
self.log('debug', 'Impress Presentation not running')
return
}
const sendBuf = Buffer.from("presentation_blank_screen\n\n", 'latin1')
self.log('debug', "-> " + sendBuf)
self.socket.send(sendBuf)
},
},
continue: {
name: 'Reset Black Screen',
options: [],
callback: async (action) => {
if (self.socket == undefined || !self.socket.isConnected) {
self.log('debug', 'Socket not connected :(')
return
}
if (self.connectionStatus != LoStatus.Paired) {
self.log('debug', 'Libre Office Impress not paired '+self.connectionStatus)
return
} else if (self.presentationStatus == PresentationStatus.Stopped) {
self.log('debug', 'Impress Presentation not running')
return
}
const sendBuf = Buffer.from("presentation_resume\n\n", 'latin1')
self.log('debug', "-> " + sendBuf)
self.socket.send(sendBuf)
},
},
}
}