1 /* This is sample front end code, uses the facilities provided by LoginManager
2 to easily create a login manager without having to deal with specific
3 implementation details. LoginManager uses jQuery events to wrap the
4 standard lightdm interface */
6 /* add a black box to hide enverything while its still loading,
7 this will be removed after LoginManager triggers its 'ready' event. */
8 $("body").append(`<div id="block" style="position: absolute;background-color: black;
9 width: 100%; height: 100vh; z-index:9999;"></div>`);
12 const greeter = new LoginManager();
14 // called after greeter and lightdm are initialized
15 $(greeter).on("ready", function(e) {
17 let $user = $("#selectUser");
18 let $session = $("#selectSession");
19 let $password = $("#inputPassword");
21 /*User the LoginManager's facility for easily filling the user
22 selection boxes and binding the appropriate
23 listeners needed by materialize */
24 greeter.fillUserSelect($user);
25 greeter.fillSessionSelect($session);
29 /* Bind shutdown, restart hibernate and suspend to the
30 appropriate buttons */
31 $("#buttonPoweroff").click(function() {
34 $("#buttonRestart").click(function() {
37 $("#hibernate").click(function() {
41 // Bind listener to the password box
42 $password.keypress((e) => {
43 // user has typed, remove placeholder and invalid class
44 $password.prop("placeholder", "").removeClass("invalid");
46 /* Attempt authentication, 'grant' event will be emitted on sucecss
47 and 'deny' will be emitted on failure */
48 if (e.keyCode == 13) {
49 let username = $user.children("option:selected").val();
50 let pass = $password.val();
51 greeter.auth(username, pass);
56 // when the user is authenticated, do a transition and login
57 $(greeter).on("grant", () => {
58 let session_key = $session.children("option:selected").val();
59 greeter.login(session_key);
62 // inform the user that the credentials are invalid
63 $password.removeClass("valid").addClass("invalid");
64 $password.val("").prop("placeholder", "Incorrect Password");
67 $(greeter.plugins.SplashScreen).on("active", function() {
68 $(".active-appear").fadeIn();
69 }).on("inactive", function() {
70 $(".active-appear").fadeOut();
74 /* Once everything else has loaded, its safe to remove the black screen
75 hiding the dom. Do it async so that all currently running async
76 functions have a chance to complete */
77 setTimeout(() => $("#block").remove(), dur=1);