forked from alairon/SwitchRP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-legacy.js
106 lines (92 loc) · 3.62 KB
/
index-legacy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/** index.js
* Functions used to by the client-side window.
* Includes functions used by both electron and HTML.
*/
/* eslint-disable */
/* IPC */
const { ipcRenderer } = require('electron');
/* JSON containing game titles */
const gameList = require('./titles.json');
/* Add functionality to the 'Update Status' button */
const updateStatus = document.getElementById('updateStatus');
updateStatus.addEventListener('click', () => {
const gameObjectData = Object.values(gameList)[document.getElementById('titleName').value];
ipcRenderer.send('updateStat', gameObjectData);
});
// Read from titles.json and insert them into the dropdown
document.addEventListener('DOMContentLoaded', () => {
const dropdownDiv = document.createDocumentFragment();
for (let x = 0; x < Object.keys(gameList).length; x++) {
const gameItem = document.createElement('button');
const listObj = Object.values(gameList)[x];
gameItem.setAttribute('class', 'dropdown-item');
gameItem.setAttribute('type', 'button');
gameItem.setAttribute('onclick', `setTitle("${listObj.id}")`);
gameItem.setAttribute('value', listObj.id);
gameItem.innerHTML = listObj.longName;
dropdownDiv.appendChild(gameItem);
}
document.getElementById('gameList').appendChild(dropdownDiv);
});
/* Toggles between light and dark themes */
function toggleScheme() {
const core = document.getElementById('bodyMain');
const color = document.getElementById('lightToggle');
const button = document.getElementById('reset-btn');
if (color.value == '0') {
color.value = '1';
color.innerHTML = '<i class="fas fa-lightbulb"></i>';
core.classList.add('body-dark');
core.classList.remove('body-light');
button.classList.add('btn-outline-light');
button.classList.remove('btn-outline-dark');
} else {
color.value = '0';
color.innerHTML = '<i class="far fa-lightbulb"></i>';
core.classList.add('body-light');
core.classList.remove('body-dark');
button.classList.add('btn-outline-dark');
button.classList.remove('btn-outline-light');
}
}
function readMail(){
const mail = document.getElementById('noticesButton');
const notice = document.getElementById('notices');
switch (mail.value) {
//Open unread message
case('0'):
mail.value = '1';
mail.classList.add('btn-light');
mail.classList.remove('btn-warning');
mail.innerHTML = '<i class="fas fa-envelope-open-text"></i>';
notice.setAttribute ('style', 'display:block');
break;
//Close read message
case('1'):
mail.value = '2';
mail.innerHTML = '<i class="fas fa-envelope"></i>';
notice.setAttribute ('style', 'display:none');
break;
//Open read message
default:
mail.value = '1';
mail.innerHTML = '<i class="fas fa-envelope-open-text"></i>';
notice.setAttribute ('style', 'display:block');
}
}
// Sets the text of the dropdown menu to what the user selected
function setTitle(id) {
const titleName = document.getElementById('titleName');
const listObj = Object.values(gameList)[id];
document.getElementById('gameName').value = listObj.longName;
document.getElementById('gameID').value = listObj.clientAppID;
titleName.value = listObj.clientAppID;
titleName.innerHTML = '<i class="fas fa-check"></i> Game selected';
}
// Restores the initial values on the form
function resetValues() {
document.getElementById('titleName').innerHTML = '<i class="fas fa-gamepad"></i> Select your game';
document.getElementById('gameName').value = '';
document.getElementById('gameID').value = '';
document.getElementById('gameDetails').value = '';
}