-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
210 lines (204 loc) · 8.66 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="icon", href="trayicon.png">
<title>FGCompanion Settings</title>
</head>
<body style="overflow: hidden;">
<div class="fixed-action-btn">
<a onclick="saveSettings()" class="btn-floating btn-large black">
<i class="large material-icons">save</i>
</a>
</div>
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s3"><a href="#tab1">General</a></li>
<li class="tab col s3"><a class="active" href="#tab2">Rich Presence</a></li>
<li class="tab col s3 disabled"><a href="#tab3">Addon Store</a></li>
<li class="tab col s3"><a href="#tab4">My Profile</a></li>
<li class="tab col s3"><a href="#tab5">Credits & About</a></li>
</ul>
</div>
<div id="tab1" class="col s12">
<h5>General Settings</h5>
<label for="showRepoButton">Show repo ads (tysm for turning on)</label>
<div class="switch">
<label>
Off
<input id="showRepoButton" type="checkbox">
<span class="lever"></span>
On
</label>
</div>
<br>
<div class="row">
<div class="input-field col s6">
<input placeholder="url1,url2,url3" id="addonSources" type="text">
<label for="addonSources">Alternative sources for Addon Store</label>
</div>
</div>
</div>
<div id="tab2" class="col s12">
<h6>Available properties:</h6>
<div class="row">
<div class="col s6">
<p>
{desticao} - The ICAO of currently selected destination<br>
{depicao} - The ICAO of currently selected departure location<br>
{ete} - [DEV] Estimated time in seconds left to destination<br>
{icao} - Nearest airport ICAO (based on METAR report)<br>
{alt} - Current altitude<br>
{airspeed} - Current airspeed<br>
{aircraft} - Name of currently selected aircraft
</p>
</div>
<div class="col s6">
<p>
{icon} - [DEV] ID of aircraft for rendering RPC icons<br>
{paintjobtext} - Name of currently selected livery<br>
{airspace} - Reverse geocoded name of region you are flying above<br>
{emoji} - Emoji coresponding to Airspace name. Can be country flag or ocean<br>
{latitude} - [DEV] Current latitude<br>
{longitude} - [DEV] Current longtitude
</p>
</div>
</div>
<br>
<div class="row">
<div class="input-field col s6">
<input placeholder="SPD: {airspeed} kt | ALT: {altidude} ft" id="statePattern" type="text">
<label for="statePattern">State rendering pattern</label>
</div>
<div class="input-field col s6">
<input placeholder="Flying over {airspace} {emoji}" id="detailsPattern" type="text">
<label for="detailsPattern">Details rendering pattern</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input placeholder="SPD: {airspeed} kt | ALT: {altidude} ft" id="statePatternRoute" type="text">
<label for="statePatternRoute">State rendering pattern when route is set</label>
</div>
<div class="input-field col s6">
<input placeholder="Flying over {airspace} {emoji}" id="detailsPatternRoute" type="text">
<label for="detailsPatternRoute">Details rendering pattern when route is set</label>
</div>
</div>
<label for="rpcautooff">RPC Auto Off when FG Connection lost</label>
<div class="switch">
<label>
Off
<input id="rpcautooff" type="checkbox">
<span class="lever"></span>
On
</label>
</div>
<br>
<div class="row">
<div class="input-field col s6">
<input placeholder="localhost" id="address" type="text">
<label for="address">Phi Server address</label>
</div>
<div class="input-field col s6">
<input placeholder="8080" id="port" type="text">
<label for="port">Phi Server port</label>
</div>
</div>
</p>
</div>
<div id="tab3" class="col s12">
</div>
<div id="tab4" class="col s12">
<div id="profile">
<!--<br>
<a href="#" class="btn indigo accent-3"><i class="material-icons left">discord</i>Log In with Discord</a>
-->
</div>
</div>
<div id="tab5" class="col s12">
<div class="container">
<br>
Created with ❤️ by Jakub Kowal (JustKowal)<br>
<br>
UI created using MaterializeCSS.<br>
Licensed under the MIT license.<br>
Jakub Kowal 2021©<br>
All rights reserved.
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
api.send('get-settings',"")
api.recieve('get-settings-reply', (arg,event)=>{
window.settings = arg[0]
console.log(window.settings)
document.getElementById('statePattern').value = settings.statePattern
document.getElementById('detailsPattern').value = settings.detailsPattern
document.getElementById('statePatternRoute').value = settings.statePatternRoute
document.getElementById('detailsPatternRoute').value = settings.detailsPatternRoute
document.getElementById('rpcautooff').checked = settings.autoOffRPC
document.getElementById('showRepoButton').checked = settings.showRepoButton
document.getElementById('address').value = settings.address
document.getElementById('port').value = settings.port
})
api.recieve('save-settings-reply',(arg)=>{
if(arg == "ok"){
M.toast({html: 'Settings Saved!', classes: 'rounded green'})
}else{
M.toast({html: 'Error occured!', classes: 'rounded red'});
}
})
api.recieve('account-info', (response) => {
if (response[0].status) {
console.log(response)
document.getElementById('profile').innerHTML = `
<div class="container">
<br>
<div class="row">
<div class="col s2"><img src="${response[0].info.avatar}" class="circle responsive-img" style="width:100%;height:100%"></div>
<div class="col s8 offset-s1"><br><h3>${response[0].info.username.toUpperCase()}</h3></div>
</div>
</div>
`
}else{
console.log('user not logged in')
document.getElementById('profile').innerHTML = `
<br>
<a href="#" class="center btn indigo accent-3" onclick="login()"><i class="material-icons left">discord</i>Log In with Discord</a>
`
}
})
function saveSettings(){
api.send('save-settings',{
...window.settings,
statePattern: document.getElementById('statePattern').value,
detailsPattern: document.getElementById('detailsPattern').value,
statePatternRoute: document.getElementById('statePatternRoute').value,
detailsPatternRoute: document.getElementById('detailsPatternRoute').value,
autoOffRPC: document.getElementById('rpcautooff').checked,
showRepoButton: document.getElementById('showRepoButton').checked,
address: document.getElementById('address').value,
port: document.getElementById('port').value,
})
}
var el = document.querySelector('.tabs')
var instance = M.Tabs.init(el);
var el = document.querySelectorAll('.tooltipped')
var instances = M.Tooltip.init(el);
function loadprofile(){
api.send('get-account-info')
}
function login(){
var loginwindow = window.open("https://discord.com/api/oauth2/authorize?client_id=908005676612194335&redirect_uri=http%3A%2F%2Flocalhost%3A2137%2Fauth&response_type=code&scope=identify%20email","Discord Login",`width=${screen.width},height=${screen.height}`)
}
loadprofile()
</script>
</body>
</html>