diff options
| author | Arman <[email protected]> | 2018-08-02 18:58:39 -0700 |
|---|---|---|
| committer | Arman <[email protected]> | 2018-08-02 18:58:39 -0700 |
| commit | eb8d225fe90871bca5431fcede62c942cdfd20ac (patch) | |
| tree | 90e04e518135f0ac1ebcfb504dcef1905249bdee /addWindow.html | |
| parent | inital commit (diff) | |
| download | launcher-eb8d225fe90871bca5431fcede62c942cdfd20ac.tar.xz launcher-eb8d225fe90871bca5431fcede62c942cdfd20ac.zip | |
Add custom path
Diffstat (limited to 'addWindow.html')
| -rw-r--r-- | addWindow.html | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/addWindow.html b/addWindow.html index 747c53c..12a26b8 100644 --- a/addWindow.html +++ b/addWindow.html @@ -1,23 +1,82 @@ <!DOCTYPE html> <html lang="en"> <head> - <title>Add Shopping List Item</title> + <title>Specify Path</title> + <link rel="stylesheet" href="login.css"> + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg"> </head> <body> - <div class="container"> - <form> - <div> - <label>Enter Item</label> - <input type="text" id="item" autofocus> - </div> - <button class="btn waves-effect waves-light" type="submit">Add Item</button> - </form> + <div class="controls"></div> + <div class="path-container"> + <h1>Game Path</h1> + <p>Specify the path to your 'Wizard101' folder</p> + <input type="text" id="game-path" class="keyBox"/> + <button id="browse">Browse</button> + <div class="buttons"> + <div class="roundBtn is-light-gray" id="save"><i class="far fa-save"></i> +Save</div> + <div class="roundBtn is-red" id="reset"><i class="fas fa-sync-alt"></i> +Reset</div> + </div> + + </div> <script> const electron = require('electron'); const {ipcRenderer} = electron; + const { remote } = require('electron') + + const browseBtn = document.getElementById('browse'); + const pathInput = document.getElementById('game-path'); + const save = document.getElementById('save'); + const reset = document.getElementById('reset'); + + let resetPath = "N/A"; + let currentPath = "N/A"; + + // Request some stuff from the main process when window loads + document.addEventListener('DOMContentLoaded', function () { + ipcRenderer.send('request:reset'); + ipcRenderer.send('request:current'); + }); + + // Get original path for reset + ipcRenderer.on('reset:path', function(e, path) { + resetPath = path; + }); + // Get current path + ipcRenderer.on('current:path', function(e, path) { + currentPath = path; + pathInput.value = currentPath; + }); + + browseBtn.addEventListener('click', function(e) { + e.preventDefault(); + const pathArray = remote.dialog.showOpenDialog({ properties: ['openDirectory'] }) + pathInput.value = pathArray; + }); + + save.addEventListener('click', function(e) { + const newPath = pathInput.value; + if (newPath.length == 0) { + alert("Path is empty"); + } + else { + ipcRenderer.send('path:change', newPath); + let notif = new Notification('Configuration Updated', { + body: 'New game path successfully saved', + icon: 'https://i.imgur.com/FQNnvrd.png', + image: 'https://i.imgur.com/FQNnvrd.png' + }); + } + }); + + reset.addEventListener('click', function(e) { + pathInput.value = resetPath; + }); + const form = document.querySelector('form'); form.addEventListener('submit', submitForm); |