2017-11-29 22:40:56 -08:00
|
|
|
/**
|
|
|
|
* Core UI functions are initialized in this file. This prevents
|
2017-12-02 19:41:47 -08:00
|
|
|
* unexpected errors from breaking the core features. Specifically,
|
|
|
|
* actions in this file should not require the usage of any internal
|
|
|
|
* modules, excluding dependencies.
|
2017-11-29 22:40:56 -08:00
|
|
|
*/
|
|
|
|
const $ = require('jquery');
|
2018-04-12 15:13:09 -07:00
|
|
|
const {remote, shell, webFrame} = require('electron')
|
|
|
|
|
|
|
|
// Disable zoom, needed for darwin.
|
2018-04-12 15:39:31 -07:00
|
|
|
webFrame.setZoomLevel(0)
|
2018-04-12 15:13:09 -07:00
|
|
|
webFrame.setVisualZoomLevelLimits(1, 1)
|
|
|
|
webFrame.setLayoutZoomLevelLimits(0, 0)
|
2017-11-29 22:40:56 -08:00
|
|
|
|
|
|
|
/* jQuery Example
|
|
|
|
$(function(){
|
|
|
|
console.log('UICore Initialized');
|
|
|
|
})*/
|
|
|
|
|
2017-11-30 00:00:06 -08:00
|
|
|
document.addEventListener('readystatechange', function () {
|
|
|
|
if (document.readyState === 'interactive'){
|
2017-11-29 22:40:56 -08:00
|
|
|
console.log('UICore Initializing..');
|
|
|
|
|
|
|
|
// Bind close button.
|
2018-04-14 13:54:10 -07:00
|
|
|
Array.from(document.getElementsByClassName('fCb')).map((val) => {
|
|
|
|
val.addEventListener('click', e => {
|
|
|
|
const window = remote.getCurrentWindow()
|
|
|
|
window.close()
|
|
|
|
})
|
2017-11-29 22:40:56 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
// Bind restore down button.
|
2018-04-14 13:54:10 -07:00
|
|
|
Array.from(document.getElementsByClassName('fRb')).map((val) => {
|
|
|
|
val.addEventListener('click', e => {
|
|
|
|
const window = remote.getCurrentWindow()
|
|
|
|
if(window.isMaximized()){
|
|
|
|
window.unmaximize()
|
|
|
|
} else {
|
|
|
|
window.maximize()
|
|
|
|
}
|
|
|
|
document.activeElement.blur()
|
|
|
|
})
|
2017-11-29 22:40:56 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
// Bind minimize button.
|
2018-04-14 13:54:10 -07:00
|
|
|
Array.from(document.getElementsByClassName('fMb')).map((val) => {
|
|
|
|
val.addEventListener('click', e => {
|
|
|
|
const window = remote.getCurrentWindow()
|
|
|
|
window.minimize()
|
|
|
|
document.activeElement.blur()
|
|
|
|
})
|
2017-11-29 22:40:56 -08:00
|
|
|
})
|
|
|
|
|
2017-11-30 00:00:06 -08:00
|
|
|
} else if(document.readyState === 'complete'){
|
|
|
|
|
2018-04-02 15:40:32 -07:00
|
|
|
//266.01
|
|
|
|
//170.8
|
|
|
|
//53.21
|
2017-11-29 22:40:56 -08:00
|
|
|
// Bind progress bar length to length of bot wrapper
|
2018-04-02 15:40:32 -07:00
|
|
|
//const targetWidth = document.getElementById("launch_content").getBoundingClientRect().width
|
|
|
|
//const targetWidth2 = document.getElementById("server_selection").getBoundingClientRect().width
|
|
|
|
//const targetWidth3 = document.getElementById("launch_button").getBoundingClientRect().width
|
|
|
|
|
|
|
|
document.getElementById("launch_details").style.maxWidth = 266.01
|
|
|
|
document.getElementById("launch_progress").style.width = 170.8
|
|
|
|
document.getElementById("launch_details_right").style.maxWidth = 170.8
|
|
|
|
document.getElementById("launch_progress_label").style.width = 53.21
|
2017-11-30 00:00:06 -08:00
|
|
|
|
2017-11-29 22:40:56 -08:00
|
|
|
}
|
2017-11-30 00:00:06 -08:00
|
|
|
|
|
|
|
}, false)
|
2017-11-29 22:40:56 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open web links in the user's default browser.
|
|
|
|
*/
|
|
|
|
$(document).on('click', 'a[href^="http"]', function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
//console.log(os.homedir())
|
|
|
|
shell.openExternal(this.href)
|
|
|
|
})
|
|
|
|
|
|
|
|
/**
|
2018-01-18 20:37:59 -08:00
|
|
|
* Opens DevTools window if you hold (ctrl + shift + i).
|
2017-11-29 22:40:56 -08:00
|
|
|
* This will crash the program if you are using multiple
|
|
|
|
* DevTools, for example the chrome debugger in VS Code.
|
|
|
|
*/
|
|
|
|
document.addEventListener('keydown', function (e) {
|
2018-01-18 20:37:59 -08:00
|
|
|
if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
|
|
|
|
let window = remote.getCurrentWindow()
|
2017-11-29 22:40:56 -08:00
|
|
|
window.toggleDevTools()
|
|
|
|
}
|
|
|
|
})
|