-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.js
51 lines (46 loc) · 1.3 KB
/
main.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
var input = document.getElementById("input");
input.addEventListener("keydown", function (e) {
if (e.keyCode === 13) {
authenticate(e.target.value);
}
});
window.authentication_complete = function() {
if (lightdm.is_authenticated) {
console.log("Authenticated!");
$( 'body' ).fadeOut( 1000, () => {
lightdm.login(lightdm.authentication_user, null);
} );
}
}
function pad(a, b) {
return (1e15 + a + "").slice(-b);
}
function getImg() {
index = Math.floor(Math.random() * 25);
console.log(pad(index,2));
document.getElementsByTagName('body')[0].style.backgroundImage =
"url(wallpapers/" + pad(index, 2) + ".png)";
}
window.onload = function() {
getImg();
input.focus();
input.select();
}
function authenticate(input_text) {
if(!lightdm.in_authentication) {
lightdm.authenticate(input_text);
input.value = "";
input.type = "password";
input.placeholder = "password";
} else if(!lightdm.authentication_user) {
lightdm.respond(input_text);
input.value = "";
input.type = "password";
input.placeholder = "password";
} else {
lightdm.respond(input_text);
input.value = "";
input.type = "text";
input.placeholder = "user";
}
}