generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.ts
244 lines (218 loc) · 9.44 KB
/
settings.ts
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import uuhimsyPlugin from "main";
import {App, Notice, Platform, PluginSettingTab, Setting, normalizePath } from "obsidian";
export class uuhimsySettingsTab extends PluginSettingTab {
plugin: uuhimsyPlugin;
constructor(app: App, plugin: uuhimsyPlugin){
super(app,plugin);
this.plugin = plugin;
}
display(){
let { containerEl } = this;
containerEl.empty();
new Setting(containerEl)
.setName("OBS WebSocket Server")
.setHeading()
.setDesc("Set the OBS Websocket Server Settings")
new Setting(containerEl)
.setName("IP")
.setDesc("Enter the IP address or 'localhost'")
.addText((item) => {
item.setValue(this.plugin.settings.websocketIP_Text).onChange(
(value) => {
this.plugin.settings.websocketIP_Text = value;
this.plugin.saveSettings()
refresh_websocketDetailsJS(this)
})
});
new Setting(containerEl)
.setName("PORT")
.addText((item) => {
item.setValue(this.plugin.settings.websocketPort_Text).onChange(
(value) => {
this.plugin.settings.websocketPort_Text = value;
this.plugin.saveSettings()
refresh_websocketDetailsJS(this)
})
});
new Setting(containerEl)
.setName("Password")
.addText((item) => {
item.setValue(this.plugin.settings.websocketPW_Text).onChange(
(value) => {
this.plugin.settings.websocketPW_Text = value;
this.plugin.saveSettings()
refresh_websocketDetailsJS(this)
})
});
new Setting(containerEl)
.setName("OBS Launch Parameters")
.setHeading()
.setDesc("Open OBS with these options.")
if(Platform.isMacOS){
new Setting(containerEl)
.setName("Name")
.setDesc("Enter 'OBS' or a custom name")
.addText((item) => {
item.setValue(this.plugin.settings.obsAppName_Text).onChange(
(value) => {
this.plugin.settings.obsAppName_Text = value;
this.plugin.saveSettings()
})
});
}
if(Platform.isWin){
new Setting(containerEl)
.setName("Name")
.setDesc("Enter 'obs64.exe' or a custom name")
.addText((item) => {
item.setValue(this.plugin.settings.obsAppName_Text).onChange(
(value) => {
this.plugin.settings.obsAppName_Text = value;
this.plugin.saveSettings()
})
});
new Setting(containerEl)
.setName("Path to OBS app")
.addText((item) => {
item.setValue(this.plugin.settings.obsAppPath_Text).onChange(
(value) => {
this.plugin.settings.obsAppPath_Text = value;
this.plugin.saveSettings()
})
});
}
new Setting(containerEl)
.setName("Collection")
.addText((item) => {
item.setValue(this.plugin.settings.obsCollection_Text).onChange(
(value) => {
this.plugin.settings.obsCollection_Text = value;
this.plugin.saveSettings()
})
});
new Setting(containerEl)
.setName("OBS Browser Source Debug Port")
.setDesc("Enter a Port for the Remote Debugger, or leave blank to skip this option")
.addText((item) => {
item.setValue(this.plugin.settings.obsDebugPort_Text).onChange(
(value) => {
this.plugin.settings.obsDebugPort_Text = value;
this.plugin.saveSettings()
})
});
new Setting(containerEl)
.setName("OSC Server")
.setHeading()
new Setting(containerEl)
.setName("IP")
.setDesc("Enter the IP address or 'localhost'")
.addText((item) => {
item.setValue(this.plugin.settings.oscIP_Text).onChange(
(value) => {
this.plugin.settings.oscIP_Text = value;
this.plugin.saveSettings()
})
});
new Setting(containerEl)
.setName("Incoming Message PORT")
.addText((item) => {
item.setValue(this.plugin.settings.oscInPort_Text).onChange(
(value) => {
this.plugin.settings.oscInPort_Text = value;
this.plugin.saveSettings()
})
});
new Setting(containerEl)
.setName("Outgoing Message PORT")
.addText((item) => {
item.setValue(this.plugin.settings.oscOutPort_Text).onChange(
(value) => {
this.plugin.settings.oscOutPort_Text = value;
this.plugin.saveSettings()
})
});
new Setting(containerEl)
.setName("Add UUhimsy scripts to Slides Extended Template")
.setHeading()
.setDesc("UUhimsy scripts will be included when exporting Slides Extended slides")
.addButton((button) => {
button
.setButtonText("Add UUhimsy scripts to Slides Extended Template")
.setTooltip("UUhimsy scripts are included when exporting from Slides Extended")
.setCta()
.onClick(async ()=>{
const fileName = `${this.app.vault.configDir}/plugins/slides-extended/template/reveal.html`;
const existing = await this.app.vault.adapter.exists(normalizePath(`${fileName}`));
if (existing) {
let file = await this.app.vault.adapter.read(normalizePath(`${fileName}`))
if(file.includes(`<script src="/_browser_Sources/js/revealSlideControls.js"></script>`)){
new Notice('template already includes uuhimsy scripts')
}
else{
new Notice('adding UUhimsy scripts to Slides Extended Template')
return await this.app.vault.adapter.process(normalizePath(`${fileName}`), (data) =>{
return data.replace('</body>',` <script src="/_browser_Sources/obs_webSocket_details/websocketDetails.js"></script>
<script src="/_browser_Sources/obs_webSocket_details/obs-ws.js"></script>
<script src="/_browser_Sources/obs_webSocket_details/obsConnect.js"></script>
<script src="/_browser_Sources/obs_webSocket_details/startConnection.js"></script>
<script src="/_browser_Sources/js/revealSlideControls.js"></script>
</body>`)
})
}
}
})
// this.plugin.settings.oscOutPort_Text).onChange(
// (value) => {
// this.plugin.settings.oscOutPort_Text = value;
// this.plugin.saveSettings()
// })
});
if(Platform.isMacOS){
new Setting(containerEl)
.setName("UVC-Util")
.setHeading()
.setDesc(`USB Video Class (UVC) control management utility for Mac OS X`)
.addButton((button) =>{
button
.setButtonText("Learn More")
.onClick(() => {window.open("https://github.com/jtfrey/uvc-util")})
})
.addButton((button) =>{
button
.setCta()
.setButtonText("Download")
.onClick(() => {window.open("https://github.com/UUoocl/UUhimsy/tree/main/UUhimsy_Demo_Vault/_uvc-util")})
})
new Setting(containerEl)
.setName("Path to UVC-util")
.setDesc("save 'uvc-util' to a folder in this vault")
.addText((item) => {
item.setValue(this.plugin.settings.uvcUtil_folder).onChange(
(value) => {
this.plugin.settings.uvcUtil_folder = value;
this.plugin.saveSettings()
})
});
}
async function refresh_websocketDetailsJS(obsidian){
const fileName = `_browser_Sources/obs_webSocket_details/websocketDetails.js`;
const existing = await obsidian.app.vault.adapter.exists(normalizePath(`${fileName}`));
if (!existing) {
await obsidian.app.vault.create(`${fileName}`,
`var wssDetails = {
"IP":"${obsidian.plugin.settings.websocketIP_Text}",
"PORT":"${obsidian.plugin.settings.websocketPort_Text}",
"PW":"${obsidian.plugin.settings.websocketPW_Text}"
};`,);
} else{
await obsidian.app.vault.delete(obsidian.app.vault.getFileByPath(fileName));
await obsidian.app.vault.create(`${fileName}`,
`var wssDetails = {
"IP":"${obsidian.plugin.settings.websocketIP_Text}",
"PORT":"${obsidian.plugin.settings.websocketPort_Text}",
"PW":"${obsidian.plugin.settings.websocketPW_Text}"
};`,);
}
}
}
}