-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.js
237 lines (191 loc) · 6.54 KB
/
script.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
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
229
230
231
232
233
234
235
236
237
var inFullscreen = false;
var accounts = [
{
name: "James",
image: "https://avatars2.githubusercontent.com/u/42580341?s=460&v=4"
},
{
name: "Seb",
image: "https://avatars0.githubusercontent.com/u/39373619?s=460&v=4"
},
{
name: "Herbie"
},
{
name: "Caspar"
},
{
name: "Guest"
}
];
var selectedAccount = -1;
var updateAccount = true;
function toggleFullscreen() {
if (!inFullscreen) {
try {
document.body.requestFullscreen();
} catch (e) {}
try {
document.body.webkitRequestFullScreen();
} catch (e) {}
try {
document.body.mozRequestFullScreen();
} catch (e) {}
try {
document.body.msRequestFullScreen();
} catch (e) {}
inFullscreen = true;
} else {
try {
document.exitFullscreen();
} catch (e) {}
try {
document.webkitCancelFullScreen();
} catch (e) {}
try {
document.mozCancelFullScreen();
} catch (e) {}
try {
document.msExitFullScreen();
} catch (e) {}
inFullscreen = false;
}
}
function isSignedIn() {
return $("screen[name=desktop]").css("display") == "block";
}
function selectSignInAccount(index) {
selectedAccount = index;
$(".signInPersonalImage").removeClass("selected");
$(".signInPersonalImage[data-account='" + index + "']").addClass("selected");
if (sReader.reading) {sReader.speak(_("Account selected: %", accounts[selectedAccount].name));}
}
function signIn() {
if (selectedAccount >= 0) {
$(".myUsername").text(accounts[selectedAccount].name);
$(".myAccountImage").attr({
src: accounts[selectedAccount].image != undefined ? accounts[selectedAccount].image : "media/defaultAccount.png",
onerror: "this.src = 'media/defaultAccount.png';"
});
setTimeout(function() {
$(".signInPersonalImage").removeClass("selected");
$("#signInNetworkUsername, #signInPassword").val("");
}, 500);
screens.fade("desktop");
} else {
alert(_("Please select your account."), _("Could not sign you in"));
}
}
function signOut() {
$(".appBar").slideUp(500);
$("window").each(function() {
closeWindow($(this), false);
});
setTimeout(function() {
setTimeout(function() {
$(".myUsername").text(_("User"));
$(".myAccountImage").attr({
src: "media/defaultAccount.png",
onerror: ""
});
$(".appBar").slideDown();
$(".appBarOpenApps").html("");
}, 500);
screens.fade("signIn");
selectedAccount = -1;
}, 500);
}
// Wi-Fi functins, currently temporary until we remove the tests
function connectToWiFi() {
if ($("#WAPSSID").val() != "") {
if ($("#WAPPassword").val() != "") {
systemActions.wifiSetPassConnection($("#WAPSSID").val(), $("#WAPPassword").val());
} else {
systemActions.wifiSetOpenConnection($("#WAPSSID").val());
}
systemActions.wifiUpdate();
$("#WAPSSID").val("");
$("#WAPPassword").val("");
alert("Please wait while the Wi-Fi connects.", "Wi-Fi information submitted");
} else {
alert("Please provide an SSID.", "Incomplete information");
}
}
function disconnectFromWiFi() {
systemActions.wifiDisconnect();
systemActions.wifiUpdate();
alert("Please wait while the Wi-Fi disconnects.", "Wi-Fi is disconnecting");
}
function refreshSSIDs() {
systemActions.wifiGetSSID(function(data) {
$(".currentWAP").text(data);
});
systemActions.wifiGetWAPs(function(data) {
$(".availableWAPs").html("");
for (var i = 0; i < data.length; i++) {
$("<li>").text(data[i]).appendTo($(".availableWAPs"));
}
});
}
function goToWirelessSetupScreen() {
if (getURLParameter("bootable") == "true") {
screens.fade("wirelessSetup");
} else {
alert("Sorry, you can't change wireless settings in the web version of subOS.", "Could not go to wireless setup");
}
}
$(function() {
if ($("body").width() < 500) {
window.location.href = "notSupported.html";
}
screens.show("signIn");
setInterval(function() {
var date = new Date();
$(".infoTime").html(_("%", date));
$(".infoTime").attr("data-readable", _("The time is %", date));
var accountsBuild = "";
if (updateAccount) {
for (var i = 0; i < accounts.length; i++) {
accountsBuild += `
<div class="signInPersonalItem">
<a
href="javascript:selectSignInAccount(` + i + `);"
class="hidden button"
data-readable="@Select %|` + accounts[i].name.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) + `"
>
<img
src="` + (accounts[i].image != undefined ? accounts[i].image.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) : "media/defaultAccount.png") + `"
onerror="this.src = 'media/defaultAccount.png';"
data-readable="@Select %|` + accounts[i].name.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) + `"
class="signInPersonalImage" data-account=` + i + `
/>
</a>
<div class="signInPersonalText noTranslate">` + accounts[i].name.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """) + `</div>
</div>
`;
}
$(".signInPersonal").html(accountsBuild);
if (accounts.length == 1) {
selectSignInAccount(0);
}
updateAccount = false;
}
$("img").attr("draggable", "false");
}, 10);
$("main").css("padding-top", $(".infoBar").outerHeight() + "px");
$(document.body).on("contextmenu", "*", function(e) {
e.preventDefault();
});
$("#signInPassword").keyup(function(e) {
if (e.keyCode == 13) {
signIn();
}
});
$(".appBarOpenApps").sortable({
axis: "x",
scroll: false
});
if (getURLParameter("bootable") == "true") {
setInterval(refreshSSIDs, 5000);
}
});