Skip to content

Commit

Permalink
Bunch of fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 committed May 2, 2019
1 parent ea1d78d commit 7ee5ee8
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 264 deletions.
374 changes: 151 additions & 223 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "thorium-kiosk",
"version": "2.0.1",
"version": "2.0.6",
"description": "A client application for Thorium",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron .",
"pack": "electron-builder -mwl",
"dist": "electron-builder -mwl -p always",
"postinstall": "electron-builder install-app-deps"
"postinstall": "electron-builder install-app-deps && npm run rebuild",
"rebuild": "npm rebuild --runtime=electron --target=4.1.4 --disturl=https://atom.io/download/atom-shell --abi=69"
},
"repository": {
"type": "git",
Expand All @@ -24,8 +25,8 @@
},
"homepage": "https://github.com/Thorium-Sim/thorium-kiosk#readme",
"devDependencies": {
"electron": "^3.0.10",
"electron-builder": "^20.39.0"
"electron": "^4.1.4",
"electron-builder": "^20.40.2"
},
"build": {
"appId": "us.fyreworks.thorium",
Expand All @@ -52,7 +53,7 @@
"dependencies": {
"bonjour": "^3.5.0",
"electron-settings": "^3.2.0",
"electron-updater": "^4.0.4",
"electron-updater": "^4.0.6",
"power-off": "^1.1.2",
"sleep-mode": "^1.1.0",
"uuid": "^3.3.2"
Expand Down
7 changes: 3 additions & 4 deletions src/helpers/freakout.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// var robot = require("robotjs");
// //console.log(process.version);
// module.exports = function() {
// // Speed up the mouse.
// robot.setMouseDelay(2);

// var twoPI = Math.PI * 2.0;
// var screenSize = robot.getScreenSize();
// var height = screenSize.height;
// var width = screenSize.width;
// var counter = 0;

// // Speed up the mouse.
// robot.setMouseDelay(2);

// moveMouse();
// function moveMouse() {
// counter++;
Expand Down
17 changes: 10 additions & 7 deletions src/helpers/hotkeys.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { app, globalShortcut, BrowserWindow } = require("electron");
const { windows } = require("./multiWindow");
const { clearMenubar, setMenubar } = require("./setMenubar");

module.exports = () => {
// Create the browser window.
Expand All @@ -8,15 +9,15 @@ module.exports = () => {
mainWindow.webContents.openDevTools();
});

globalShortcut.register("CommandOrControl+Q", function() {
// Do nothing.
});
// globalShortcut.register("CommandOrControl+Q", function() {
// // Do nothing.
// });

globalShortcut.register("CommandOrControl+W", function() {
// Do nothing.
});
// globalShortcut.register("CommandOrControl+W", function() {
// // Do nothing.
// });

globalShortcut.register("CommandOrControl+R", function() {
globalShortcut.register("CommandOrControl+Alt+R", function() {
windows.forEach(mainWindow => {
mainWindow && mainWindow.reload();
});
Expand All @@ -31,9 +32,11 @@ module.exports = () => {
windows.forEach(mainWindow => {
mainWindow.setKiosk(false);
});
setMenubar();
} else {
windows.forEach(mainWindow => {
mainWindow.setKiosk(true);
clearMenubar();
});
}
});
Expand Down
17 changes: 9 additions & 8 deletions src/helpers/loadPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ const { clearMenubar, setMenubar } = require("./setMenubar");
const { windows } = require("./multiWindow");
const { setLoadedUrl } = require("./loadedUrl");

module.exports = function loadPage(uri) {
module.exports = function loadPage(uri, kiosk) {
return new Promise((resolve, reject) => {
const url = uri
.replace("https://", "")
.replace("http://", "")
.replace("/client", "");
http
.get(`http://${url}/client`, res => {
if (res.statusCode !== 200) {
setMenubar();
return reject();
}
// if (res.statusCode !== 200) {
// setMenubar();
// return reject();
// }
setLoadedUrl(`http://${url}/client`);
windows.forEach(mainWindow => {
mainWindow && mainWindow.loadURL(`http://${url}/client`);
triggerWindow(mainWindow);
triggerWindow(mainWindow, kiosk);
});

clearMenubar();
if (kiosk) {
clearMenubar();
}
return resolve();
})
.on("error", e => {
Expand Down
22 changes: 15 additions & 7 deletions src/helpers/menuTemplate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { BrowserWindow, app } = require("electron");
const { windows, addWindow } = require("./multiWindow");
const { getLoadedUrl } = require("./loadedUrl");
const { clearMenubar, setMenubar } = require("./setMenubar");

module.exports = function() {
var template = [
Expand All @@ -11,6 +12,18 @@ module.exports = function() {
label: "About Application",
selector: "orderFrontStandardAboutPanel:"
},
{
label: "Quit",
accelerator: "CmdOrCtrl+Alt+Q",
click: function() {
app.quit();
}
}
]
},
{
label: "File",
submenu: [
{
label: "New Window",
accelerator: "CmdOrCtrl+N",
Expand All @@ -35,10 +48,12 @@ module.exports = function() {
if (windows[0] && windows[0].isKiosk()) {
windows.forEach(mainWindow => {
mainWindow.setKiosk(false);
setMenubar();
});
} else {
windows.forEach(mainWindow => {
mainWindow.setKiosk(true);
clearMenubar();
});
}
}
Expand All @@ -50,13 +65,6 @@ module.exports = function() {
const focused = BrowserWindow.getFocusedWindow();
focused && focused.webContents.openDevTools();
}
},
{
label: "Quit",
accelerator: "CmdOrCtrl+Alt+Q",
click: function() {
app.quit();
}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/multiWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function addWindow({ main, x, y, loadedUrl }) {
const config = {
backgroundColor: "#2e2c29",
width: 800,
height: 600,
height: 700,
x,
y,
kiosk: false,
Expand Down
12 changes: 11 additions & 1 deletion src/helpers/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@ function getClientList() {
return clientList;
}

document.addEventListener("DOMContentLoaded", function() {
if (localStorage.getItem("thorium_startKiosked") !== "false") {
if (document.getElementById("start-kiosked")) {
document.getElementById("start-kiosked").checked = true;
}
}
});

window.loadPage = function loadPage(url) {
let auto = false;
if (document.getElementById("remember-client").checked) auto = true;
ipcRenderer.send("loadPage", { url, auto });
let kiosk = document.getElementById("start-kiosked").checked;
localStorage.setItem("thorium_startKiosked", kiosk);
ipcRenderer.send("loadPage", { url, auto, kiosk });
return;
};
window.openBrowser = function openBrowser() {
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/setMenubar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const { Menu } = require("electron");
const templateFunc = require("./menuTemplate");
const { windows } = require("./multiWindow");

module.exports.setMenubar = function setMenubar() {
const template = templateFunc();
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
windows.forEach(w => {
w.setMenuBarVisibility(true);
w.setAutoHideMenuBar(false);
});
};

module.exports.clearMenubar = function clearMenubar() {
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/startApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ module.exports = () => {
}).length;
});
ipcMain.on("loadPage", function(evt, data) {
const { url: loadUrl, auto } = data;
const { url: loadUrl, auto, kiosk } = data;
if (auto) {
settings.set("autostart", loadUrl);
}
loadPage(loadUrl).catch(() => {
loadPage(loadUrl, kiosk).catch(() => {
settings.set("autostart", null);
bonjour.start();
});
Expand All @@ -35,7 +35,7 @@ module.exports = () => {
// Check to see if the page will work.
const loadUrl = settings.get("autostart");
// Do a fetch
loadPage(loadUrl).catch(() => {
loadPage(loadUrl, true).catch(() => {
settings.set("autostart", null);
bonjour.start();
});
Expand Down
8 changes: 5 additions & 3 deletions src/helpers/triggerWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ const initHotkeys = require("./hotkeys");
const initRemote = require("./remote");
const { app } = require("electron");

module.exports = function triggerWindow(mainWindow) {
mainWindow.setKiosk(true);
initHotkeys();
module.exports = function triggerWindow(mainWindow, kiosk) {
if (kiosk) {
mainWindow.setKiosk(true);
initHotkeys();
}
initRemote();

mainWindow.on("closed", function() {
Expand Down
13 changes: 11 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
padding: 5px 10px;
width: 100%;
}
input[type="checkbox"] {
float: left;
width: auto;
margin: 3px 0.5ex;
}
</style>
</head>

Expand Down Expand Up @@ -354,8 +359,8 @@ <h4>Select a server:</h4>
<div id="serverList"></div>
<label>
<input type="checkbox" id="remember-client" /> Auto-connect to
server on Open</label
>
server on Open
</label>
<div>
<small
>Make sure your server is on before starting the client.</small
Expand All @@ -371,6 +376,10 @@ <h4>Select a server:</h4>
Connect to Server
</button>
</p>
<label>
<input type="checkbox" id="start-kiosked" /> Start the client in
kiosk-mode.
</label>
</div>
</div>
<script>
Expand Down

0 comments on commit 7ee5ee8

Please sign in to comment.