From 700a5c50cff30d8b1a0640b4d4fc37f3339d698f Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sun, 27 Aug 2017 02:24:04 -0400 Subject: [PATCH] Added handlers to the frame buttons. --- README.md | 4 +-- app/assets/css/launcher.css | 28 ++++++++++++++--- app/assets/js/script.js | 63 +++++++++++++++++-------------------- app/frame.ejs | 9 +++--- 4 files changed, 58 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 34b9242a..2b60bfaf 100644 --- a/README.md +++ b/README.md @@ -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", diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index 32cf016c..e9a890b6 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -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; } \ No newline at end of file diff --git a/app/assets/js/script.js b/app/assets/js/script.js index 49d71bdc..463ffdf8 100644 --- a/app/assets/js/script.js +++ b/app/assets/js/script.js @@ -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('' + timestamp() + ' [Debug] - ' + Array.prototype.slice.call(arguments).join(' ') + "" + os.EOL) - } - console.debug = function(){ - $('#launcher-log').append('' + timestamp() + ' [Error] - ' + Array.prototype.slice.call(arguments).join(' ') + "" + 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')) diff --git a/app/frame.ejs b/app/frame.ejs index ff417240..e3cadf5d 100644 --- a/app/frame.ejs +++ b/app/frame.ejs @@ -1,8 +1,7 @@ -
-
- - - +
+ + +
\ No newline at end of file