first commit
This commit is contained in:
58
lightdm/main.js
Normal file
58
lightdm/main.js
Normal file
@@ -0,0 +1,58 @@
|
||||
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);
|
||||
} );
|
||||
} else {
|
||||
getImg();
|
||||
input.value = "";
|
||||
input.placeholder = "user";
|
||||
input.type = "text";
|
||||
input.disabled = false;
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}
|
||||
|
||||
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(dm_background.png)";
|
||||
//"url(wallpapers/" + pad(index, 2) + ".png)";
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
getImg();
|
||||
input.focus();
|
||||
input.select();
|
||||
input.value = lightdm.select_user_hint;
|
||||
if(input.value) {
|
||||
authenticate(input.value);
|
||||
}
|
||||
}
|
||||
|
||||
function authenticate(input_text) {
|
||||
if(!lightdm.in_authentication || !lightdm.authentication_user) {
|
||||
lightdm.authenticate(input_text);
|
||||
input.value = "";
|
||||
input.type = "password";
|
||||
input.placeholder = "password";
|
||||
input.disabled = false;
|
||||
} else {
|
||||
input.disabled = true;
|
||||
lightdm.respond(input_text);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user