Add files via upload

This commit is contained in:
Daniel Bulant 2019-06-22 21:12:51 +02:00 committed by GitHub
parent 785a6345fe
commit bfb88afe14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 456 additions and 0 deletions

133
index.html Normal file
View file

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="cs" dir="ltr">
<head>
<meta charset="utf-8">
<title>Console hub</title>
</head>
<body onload="onLoad();">
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
<iframe disablewebsecurity id="frame" style="display: none; " src="" width="100%" height="100%" frameborder="0"></iframe>
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="jquery.min.js"></script>
<script>if (window.module) module = window.module;</script>
<script>
var wifi, wifiQuality;
var loaded = false;
function onLoad(){
$.ajax("https://console.danbulant.eu")
.done((function (){
loaded = true;
$(".lds-ellipsis").hide();
$('#frame').attr('src', 'https://console.danbulant.eu')
$('#frame').show();
}))
.fail((function (){
$('#frame').attr('src', 'html/index.html');
$('.lds-ellipsis').hide();
$('#frame').show();
}))
}
function showOnline(){
if(!loaded){
if(navigator.online){
$('#frame').attr('src', 'https://console.danbulant.eu');
}
}
}
window.addEventListener('online', showOnline);
// In renderer process (web page).
const { ipcRenderer } = require('electron')
ipcRenderer.on('wifi', (event, arg) => {
wifi = arg;
document.getElementById('frame').contentWindow.wifi = wifi;
})
ipcRenderer.on('wifiQuality', (event, arg) => {
wifiQuality = arg;
document.getElementById("frame").contentWindow.wifiQuality = wifiQuality;
})
ipcRenderer.on('fullscreen', (event, arg) => {
console.log("Fullscreen now " + arg);
document.getElementById("frame").contentWindow.settingMenuItemValues[0] = arg;
})
function sendFullscreen(bool){
console.log("Sending fullscreen " + bool);
ipcRenderer.send('fullscreen', bool);
}
ipcRenderer.send('get-data', 'wifi');
ipcRenderer.send('get-data', 'wifiQuality');
</script>
<style>
html, body, iframe, webview{
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: white;
overflow: hidden;
}
.lds-ellipsis {
margin: auto;
display: block;
position: fixed;
top: 47%;
left: 47%;
width: 64px;
height: 64px;
}
.lds-ellipsis div {
position: absolute;
top: 27px;
width: 11px;
height: 11px;
border-radius: 50%;
background: #c4c4c4;
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.lds-ellipsis div:nth-child(1) {
left: 6px;
animation: lds-ellipsis1 0.6s infinite;
}
.lds-ellipsis div:nth-child(2) {
left: 6px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(3) {
left: 26px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(4) {
left: 45px;
animation: lds-ellipsis3 0.6s infinite;
}
@keyframes lds-ellipsis1 {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes lds-ellipsis3 {
0% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
@keyframes lds-ellipsis2 {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(19px, 0);
}
}
</style>
</body>
</html>

2
jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

186
main.js Normal file
View file

@ -0,0 +1,186 @@
const { dialog, Menu, app, BrowserWindow } = require('electron')
var wifi = require('node-wifi');
let win
wifi.init({
iface : null
});
var wifiConnected, wifiQuality;
wifi.getCurrentConnections(function(err, currentConnections) {
if (err) {
console.log(err);
}
if(currentConnections.length > 0){
wifiConnected = true;
wifiQuality = currentConnections[0]['quality'];
console.log(wifiQuality + '% wifi');
} else {
wifiConnected = false;
}
})
var menu;
function createWindow () {
win = new BrowserWindow({
width: 800,
height: 600,
frame: true,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
webSecurity: false
}
})
win.setTitle('Console hub (ALPHA) DEV');
win.setProgressBar(1.1);
win.setFullScreenable(true);
var template = [{
label: "Application",
submenu: [{
label: "About Application",
selector: "orderFrontStandardAboutPanel:",
click: function(){
var options = {
type: 'info',
buttons: ['ok'],
title: 'About app',
message: 'Console hub (ALPHA) dev version.',
detail: 'Nightly developer version, alpha stage. Accounts disabled.\n(c) Daniel Bulant',
};
dialog.showMessageBox(null, options, (response) => {
});
}
}, {
type: "separator"
}, {
label: "Quit",
accelerator: "f4",
click: function() {
app.quit();
}
}, {
label: 'Fullscreen',
accelerator: "f11",
click: function(){
win.setFullScreen(!win.isFullScreen());
if(win.isFullScreen()){
win.setMenuBarVisibility(false)
} else {
win.setMenuBarVisibility(true)
}
}
}]
}, {
label: "Edit",
submenu: [{
label: "Undo",
accelerator: "CmdOrCtrl+Z",
selector: "undo:"
}, {
label: "Redo",
accelerator: "Shift+CmdOrCtrl+Z",
selector: "redo:"
}, {
type: "separator"
}, {
label: "Cut",
accelerator: "CmdOrCtrl+X",
selector: "cut:"
}, {
label: "Copy",
accelerator: "CmdOrCtrl+C",
selector: "copy:"
}, {
label: "Paste",
accelerator: "CmdOrCtrl+V",
selector: "paste:"
}, {
label: "Select All",
accelerator: "CmdOrCtrl+A",
selector: "selectAll:"
}]
}, {
label: 'Dev',
submenu: [
{
label: 'Open devTools',
accelerator: "CmdOrCtrl+Shift+I",
click: function(){
win.webContents.openDevTools()
}
}, {
label: 'Refresh',
accelerator: "CmdOrCtrl+R",
click: function(){
win.reload();
}
}
]
}];
const menu = Menu.buildFromTemplate(template);
win.setAutoHideMenuBar(true);
Menu.setApplicationMenu(menu);
win.loadFile('html/index.html')
win.webContents.once('dom-ready', () => {
// win.webContents.openDevTools() //debug tools
win.setProgressBar(0);
})
win.maximize();
win.on('enter-full-screen', () => {
console.log('Entered fullscreen');
win.webContents.send('fullscreen', true);
win.setMenuBarVisibility(false)
})
win.on('enter-full-html-screen', () => {
console.log('Entered html fullscreen');
win.webContents.send('fullscreen', true);
win.setMenuBarVisibility(false)
})
win.on('leave-full-screen', () => {
console.log('Leaved fullscreen');
win.webContents.send('fullscreen', false);
win.setMenuBarVisibility(true)
})
win.on('leave-full-html-screen', () => {
console.log('Leaved html fullscreen');
win.webContents.send('fullscreen', false);
win.setMenuBarVisibility(true)
})
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
const { ipcMain } = require('electron')
ipcMain.on('get-data', (event, arg) => {
if(arg == 'wifi'){
event.reply('wifi', wifiConnected);
}
if(arg == 'wifiQuality'){
event.reply('wifiQuality', wifiQuality);
}
})
ipcMain.on('set-load', (event, arg) => {
win.setProgressBar(arg);
})
ipcMain.on('fullscreen', (event, arg) => {
console.log('Setting to fullscreen ' + arg);
win.setFullScreen(arg);
})
app.setAppUserModelId(process.execPath)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})

114
offline.html Normal file
View file

@ -0,0 +1,114 @@
<!DOCTYPE html>
<html lang="cs" dir="ltr">
<head>
<meta charset="utf-8">
<title>Console hub - offline</title>
</head>
<body>
<h1>
You appear to be offline
</h1>
<p>Checking connection...</p>
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
<style>
@font-face {
font-family: 'Gilroy-bold';
src: url('Gilroy-ExtraBold.otf');
}
@font-face {
font-family: 'Open sans';
src: url('open-sans/OpenSans-Regular.ttf');
}
html, body{
width: 100%;
height: 100%;
}
body {
margin: 0;
overflow: hidden;
background: #5d75ad;
background: linear-gradient(190deg, rgba(108, 138, 207, 1) 0%, rgba(58,55,102,1) 100%);
}
p {
font-family: 'Open sans';
color: white;
position: fixed;
top: 50%;
left: 50%;
width: 180px;
height: 20px;
margin-top: -20px;
margin-left: -90px;
}
h1 {
position: fixed;
width: 360px;
height: 30px;
margin-top: -65px;
margin-left: -180px;
left: 50%;
top: 50%;
font-family: 'Gilroy-bold', sans-serif;
color: white;
}
.lds-ellipsis {
margin: auto;
display: block;
position: fixed;
top: 47%;
left: 47%;
width: 64px;
height: 64px;
}
.lds-ellipsis div {
position: absolute;
top: 27px;
width: 11px;
height: 11px;
border-radius: 50%;
background: #c4c4c4;
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.lds-ellipsis div:nth-child(1) {
left: 6px;
animation: lds-ellipsis1 0.6s infinite;
}
.lds-ellipsis div:nth-child(2) {
left: 6px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(3) {
left: 26px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(4) {
left: 45px;
animation: lds-ellipsis3 0.6s infinite;
}
@keyframes lds-ellipsis1 {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes lds-ellipsis3 {
0% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
@keyframes lds-ellipsis2 {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(19px, 0);
}
}
</style>
</body>
</html>

21
package.json Normal file
View file

@ -0,0 +1,21 @@
{
"name": "console-hub",
"version": "0.0.1",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"pkg": {
"assets": "index.html"
},
"description": "Console hub application",
"author": "Daniel Bulant",
"license": "AGPL-3.0-or-later",
"devDependencies": {
"electron": "^5.0.4",
"electron-packager": "^14.0.0"
},
"dependencies": {
"node-wifi": "^2.0.5"
}
}