-
Notifications
You must be signed in to change notification settings - Fork 11
/
fluorine_select.js
57 lines (44 loc) · 1.38 KB
/
fluorine_select.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
"use strict";
const ipcRenderer = require("electron").ipcRenderer;
let webUtils = require("electron").webUtils; // Needed from Electron v32 since can't access .path:
const get_path_for_file = (webUtils && webUtils.getPathForFile) ? webUtils.getPathForFile : file => file.path;
// Event to focus input in the actual box...
ipcRenderer.on("focus_input", () => {
document.getElementById("sid").focus();
});
// Setup return key on input box...
document.getElementById("sid").onkeydown = function(event) {
if (event.keyCode == 13) {
let input_sid = document.getElementById("sid");
let sid = parseInt(input_sid.value, 10);
input_sid.value = "";
if (!Number.isNaN(sid)) {
ipcRenderer.send("relay", {
receiver: "renderer",
channel: "stop_autoplay",
content: null,
});
ipcRenderer.send("relay", {
receiver: "renderer",
channel: "select_sid",
content: sid,
});
}
ipcRenderer.send("show_window", "renderer"); // Renderer to front.
ipcRenderer.send("hide_window", "selector");
}
};
// Setup drag-and-drop...
window.ondragover = () => false;
window.ondragleave = () => false;
window.ondragend = () => false;
window.ondrop = (event) => {
event.preventDefault();
ipcRenderer.send("relay", {
receiver: "renderer",
channel: "open",
content: get_path_for_file(event.dataTransfer.files[0]),
});
ipcRenderer.send("stop_monitoring", null);
return false;
};