-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
53 lines (44 loc) · 1.34 KB
/
start.js
File metadata and controls
53 lines (44 loc) · 1.34 KB
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
const { ipcRenderer, remote } = require("electron");
const $ = require("jquery");
const io = require("socket.io-client");
const axios = require("axios");
let data = {};
$(".server-login").hide();
$(".loading").hide();
$(".info").hide();
$("#form-login").submit(e => {
e.preventDefault();
data.login = document.getElementById("login").value;
window.open("index.html");
ipcRenderer.send("socketCredentials", data);
});
$("#form").submit(e => {
e.preventDefault();
$(".loading").show();
data.addr = document.getElementById("addr").value;
let conn = io(data.addr);
let timer = 1;
if (!data.addr.includes("http://") && !data.addr.includes("https://")) {
data.addr = `http://${data.addr}`;
}
axios
.get(`${data.addr}/status`)
.then(res => {
if (res.status == 200 && res.data.status == 1) {
// server running
$(".server-login").show();
$(".server-connect").hide();
$(".loading").hide();
$(".info").hide();
} else {
// server not running..
$(".info").show();
$(".loading").hide();
}
})
.catch(err => {
// server not running..
$(".info").show();
$(".loading").hide();
});
});