Added handlers to the frame buttons.

This commit is contained in:
Daniel Scalzi 2017-08-27 02:24:04 -04:00
parent 582ea96dfe
commit 700a5c50cf
4 changed files with 58 additions and 46 deletions

View File

@ -1,7 +1,7 @@
# Getting Started #
System Requirements:
* [Node.js](https://nodejs.org/en/) v7.9.0+
* [Node.js](https://nodejs.org/en/) v8.4.0+
This repository is dedicated to the development of the new custom launcher for the [WesterosCraft](http://www.westeroscraft.com/) server. This project is developed primarily with [Node.js](https://nodejs.org/en/) and the [Electron](https://electron.atom.io/) framework. For further reference you may view [the repository of the new launcher written in JavaFX/Java](https://gitlab.com/westeroscraft/WesteroscraftNewLauncher) which was discontinued. You may also view the repository of the [current launcher](https://gitlab.com/westeroscraft/westeroscraftlaunchercore), a modified fork of MCUpdater.
@ -48,7 +48,7 @@ If you use VS Code, you can run this directly from the IDE. Copy the following c
},
"program": "${workspaceRoot}\\index.js",
"console": "integratedTerminal",
"protocol": "legacy"
"protocol": "inspector"
},
{
"name": "Debug Renderer Process",

View File

@ -17,26 +17,44 @@ body {
align-items: center;
}
#button_dock {
#frame_btn_dock {
margin-left: 2px;
}
.frame_button {
.frame_btn {
height: 12px;
width: 12px;
border-radius: 50%;
border: 0px;
margin-left: 5px;
-webkit-app-region: no-drag !important;
cursor: pointer;
}
#frame_button_close {
.frame_btn:focus {
outline: 0px;
}
#frame_btn_close {
background-color: #e74c32;
}
#frame_button_restoredown {
#frame_btn_close:hover {
background-color: #FF9A8A;
}
#frame_btn_restoredown {
background-color: #fed045;
}
#frame_button_minimize {
#frame_btn_restoredown:hover {
background-color: #FFE9A9;
}
#frame_btn_minimize {
background-color: #96e734;
}
#frame_btn_minimize:hover {
background-color: #D6FFA6;
}

View File

@ -1,53 +1,48 @@
var $ = require('jQuery');
const $ = require('jquery');
const remote = require('electron').remote
const shell = require('electron').shell
const path = require('path')
const os = require('os');
const ag = require(path.join(__dirname, 'assets', 'js', 'assetguard.js'))
function timestamp(){
let date = new Date();
const month = date.getMonth() < 9 ? '0'.concat((date.getMonth()+1)) : date.getMonth()
const day = date.getDate() < 10 ? '0'.concat(date.getDate()) : date.getDate();
let hour = date.getHours() > 12 ? date.getHours() - 12 : date.getHours();
hour = hour < 10 ? '0'.concat(hour) : hour
const min = date.getMinutes() < 10 ? '0'.concat(date.getMinutes()) : date.getMinutes();
const sec = date.getSeconds() < 10 ? '0'.concat(date.getSeconds()) : date.getSeconds();
return '[' + month + '/' + day + '/' + date.getFullYear() + ' ' + hour + ':' + min + ':' + sec + ']'
}
console.log($);
$(document).on('ready', function(){
$(".toggle-btn input[type=radio]").addClass("visuallyhidden");
$(".toggle-btn input[type=radio]").change(function() {
if($(this).attr("name")) {
$(this).parent().addClass("success").siblings().removeClass("success")
} else {
$(this).parent().toggleClass("success")
}
})
/*console.log = function(){
$('#launcher-log').append(timestamp() + ' [Log] - ' + Array.prototype.slice.call(arguments).join(' ') + os.EOL)
}
console.error = function(){
$('#launcher-log').append('<span class="log_debug">' + timestamp() + ' [Debug] - ' + Array.prototype.slice.call(arguments).join(' ') + "</span>" + os.EOL)
}
console.debug = function(){
$('#launcher-log').append('<span class="log_debug">' + timestamp() + ' [Error] - ' + Array.prototype.slice.call(arguments).join(' ') + "</span>" + os.EOL)
}
console.log('test')
console.debug('test')*/
console.log('okay');
})
document.onreadystatechange = function () {
if (document.readyState == "complete") {
document.getElementById("frame_btn_close").addEventListener("click", function (e) {
const window = remote.getCurrentWindow()
window.close()
})
document.getElementById("frame_btn_restoredown").addEventListener("click", function (e) {
const window = remote.getCurrentWindow()
if(window.isMaximized()){
window.unmaximize();
} else {
window.maximize()
}
})
document.getElementById("frame_btn_minimize").addEventListener("click", function (e) {
const window = remote.getCurrentWindow()
window.minimize()
})
}
}
/* Open web links in the user's default browser. */
$(document).on('click', 'a[href^="http"]', function(event) {
event.preventDefault();
testdownloads()
//console.log(os.homedir())
//shell.openExternal(this.href)
});
})
testdownloads = async function(){
const lp = require(path.join(__dirname, 'assets', 'js', 'launchprocess.js'))

View File

@ -1,8 +1,7 @@
<div id="frame_bar">
<div id="button_dock">
<button class="frame_button" id="frame_button_close"></button>
<button class="frame_button" id="frame_button_restoredown"></button>
<button class="frame_button" id="frame_button_minimize"></button>
<div id="frame_btn_dock">
<button class="frame_btn" id="frame_btn_close"></button>
<button class="frame_btn" id="frame_btn_restoredown"></button>
<button class="frame_btn" id="frame_btn_minimize"></button>
</div>
</div>