HeliosLauncher/app/assets/js/uicore.js
Daniel Scalzi 5c7e0c3c8a
Various additions and fixes to the launch controller.
Fixed an issue with concurrency when there are no downloads queued on launch. Added support for static function execution in AssetExec. Fixed a binding issue in uicore.js caused by delayed div loading. For now the solution is just hard coding in the value, will probably switch these two a css file later on. Included the launcher's x64 runtime directory in Java scans.
2018-04-02 18:40:32 -04:00

79 lines
2.7 KiB
JavaScript

/**
* Core UI functions are initialized in this file. This prevents
* unexpected errors from breaking the core features. Specifically,
* actions in this file should not require the usage of any internal
* modules, excluding dependencies.
*/
const $ = require('jquery');
const {remote, shell} = require('electron')
/* jQuery Example
$(function(){
console.log('UICore Initialized');
})*/
document.addEventListener('readystatechange', function () {
if (document.readyState === 'interactive'){
console.log('UICore Initializing..');
// Bind close button.
document.getElementById("frame_btn_close").addEventListener("click", function (e) {
const window = remote.getCurrentWindow()
window.close()
})
// Bind restore down button.
document.getElementById("frame_btn_restoredown").addEventListener("click", function (e) {
const window = remote.getCurrentWindow()
if(window.isMaximized()){
window.unmaximize();
} else {
window.maximize()
}
})
// Bind minimize button.
document.getElementById("frame_btn_minimize").addEventListener("click", function (e) {
const window = remote.getCurrentWindow()
window.minimize()
})
} else if(document.readyState === 'complete'){
//266.01
//170.8
//53.21
// Bind progress bar length to length of bot wrapper
//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
}
}, false)
/**
* 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)
})
/**
* Opens DevTools window if you hold (ctrl + shift + i).
* This will crash the program if you are using multiple
* DevTools, for example the chrome debugger in VS Code.
*/
document.addEventListener('keydown', function (e) {
if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
let window = remote.getCurrentWindow()
window.toggleDevTools()
}
})