forked from realdevon/SwitchRPC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
228 lines (203 loc) · 5.93 KB
/
index.html
File metadata and controls
228 lines (203 loc) · 5.93 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SwitchRPC</title>
<style>
/*Header*/
.header-container {
position: fixed;
background-color: #23272A;
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
height: 30px;
-webkit-app-region: drag;
}
.right-window {
-webkit-app-region: no-drag;
display: flex;
flex-direction: row;
margin-top:5px;
}
.left-window {
-webkit-app-region: no-drag;
display: flex;
flex-direction: row;
margin-top:5px;
}
#min, #max, #x, #icon {
background-color: #23272A;
transition: background-color 0.2s;
height: 20px;
width: 20px;
}
#min img, #max img, #x img, #icon img {
height: 20px;
}
#min:hover, #max:hover {
background-color: #3F3F3F;
cursor: pointer;
}
#x:hover {
background-color: red;
cursor: pointer;
}
/*Body*/
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
background-color:#40444b;
color: white;
}
input[type=submit] {
width: 100%;
background-color: #34363c;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
font-size: 1.25em;
transition: background-color 0.2s;
}
input[type=submit]:hover {
background-color: #393c42;
}
body {
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, "sans-serif";
justify-content: center;
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
background-color: #2f3136;
color: white;
height: 100%;
width: 100%;
}
.main {
margin: 20px 0;
display: flex;
flex-direction: row;
justify-content: space-evenly;
width: 100%;
height: calc(100vh - 40px);
}
.left-side {
width: 50%;
display: flex;
align-items: center;
}
.right-side {
width: 30%;
height: 100%;
margin-bottom: 20px;
}
#title-container {
background-color: #393c42;
overflow-x: hidden;
overflow-y: scroll;
padding: 0 10px;
height: 80%;
}
</style>
</head>
<body>
<div class="header">
<div class="header-container">
<div class="left-window">
<span style="margin: 0 3px"></span>
<div class="window-item" id="icon">
<img src="assets/icons/icon.png">
</div>
</div>
<div class="right-window">
<div class="window-item" id="min">
<img src="assets/min.png">
</div>
<span style="margin: 0 5px"></span>
<div class="window-item" id="max">
<img src="assets/max.png">
</div>
<span style="margin: 0 5px"></span>
<div class="window-item" id="x">
<img src="assets/x.png">
</div>
<span style="margin: 0 2px"></span></div>
</div>
</div>
</div>
<div class="main">
<div class="left-side">
<div class="left-container">
<label><b>Click on an item in the scroll box to fill in that title's name or type a title into the text field manually.</b></label>
<br></br>
<form>
<label>Game</label>
<input type="text" id="game" name="game" placeholder="What game are you playing?">
<br />
<label>Description</label>
<label style="color:gray;">(Default: 'Online', Min. Length: 2)</label>
<input type="text" id="desc" name="desc" placeholder="What mode? (Single Player, Online, etc.)">
<br />
<input type="submit">
</form>
</div>
</div>
<div class="right-side">
<h2>Supported Titles</h2>
<br>
<div id="title-container">
</div>
</div>
</div>
<script>
const electron = require('electron');
const {ipcRenderer, ipcMain} = electron;
const x = document.getElementById('x');
const max = document.getElementById('max');
const min = document.getElementById('min');
x.addEventListener('click', function (e) {
ipcRenderer.send('x');
});
max.addEventListener('click', function (e) {
ipcRenderer.send('max');
});
min.addEventListener('click', function (e) {
ipcRenderer.send('min');
});
const form = document.querySelector('form');
form.addEventListener('submit', submitForm);
function submitForm(e) {
e.preventDefault();
const game = document.querySelector('#game').value;
const desc = document.querySelector('#desc').value;
ipcRenderer.send('game:value', game);
ipcRenderer.send('desc:value', desc);
}
var noSpecialCharacters = function (str) {
return str.replace(/[^a-zA-Z0-9 ]/g, '');
}
document.addEventListener('DOMContentLoaded', function() {
ipcRenderer.send('getGameData');
ipcRenderer.on('sendingGameData', function(e, data) {
data.forEach(function(game) {
let clean_game = noSpecialCharacters(game);
document.getElementById('title-container').innerHTML += `<h4 id='${clean_game}'>${game}</h4>`;
})
data.forEach(function(game) {
let clean_game = noSpecialCharacters(game);
document.getElementById(clean_game).addEventListener('click', event => {document.querySelector('#game').value = document.getElementById(clean_game).textContent;});
})
})
})
</script>
</body>
</html>