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 var $cover = $(`<div id="block" style="position: absolute;
9 background-color: black;width: 100%; height: 100vh; z-index:9999;"></div>`);
11 $(document).ready(() => {
12 $("body").append($cover);
16 const greeter = new LoginManager();
18 // called after greeter and lightdm are initialized
19 $(greeter).on("ready", function(e) {
21 var selectSession = $("#selectSession");
23 LocalStorage.setItem('access_count', selectSession);
24 window.LocalStorage.setItem('access_count', selectSession);
25 LocalStorage.access_count = selectSession
27 selectSession = LocalStorage.getItem('access_count');
28 selectSession = window.LocalStorage.getItem('access_count');
29 selectSession = LocalStorage.access_count
32 let $user = $("#selectUser");
33 let $session = selectSession;
34 let $password = $("#inputPassword");
37 /*User the LoginManager's facility for easily filling the user
38 selection boxes and binding the appropriate
39 listeners needed by materialize */
40 greeter.fillUserSelect($user);
41 greeter.fillSessionSelect($session);
45 /* Bind shutdown, restart hibernate and suspend to the
46 appropriate buttons */
47 $("#buttonPoweroff").click(function() {
50 $("#buttonRestart").click(function() {
53 $("#hibernate").click(function() {
57 // Bind listener to the password box
58 $password.keypress((e) => {
59 // user has typed, remove placeholder and invalid class
60 $password.prop("placeholder", "").removeClass("invalid");
62 /* Attempt authentication, 'grant' event will be emitted on sucecss
63 and 'deny' will be emitted on failure */
64 if (e.keyCode == 13) {
65 let username = $user.children("option:selected").val();
66 let pass = $password.val();
67 greeter.auth(username, pass);
72 // when the user is authenticated, do a transition and login
73 $(greeter).on("grant", () => {
74 let session_key = $session.children("option:selected").val();
76 $cover.fadeIn("slow", () => greeter.login(session_key));
79 // inform the user that the credentials are invalid
80 $password.removeClass("valid").addClass("invalid");
81 $password.val("").prop("placeholder", "Incorrect Password");
84 $(greeter.plugins.SplashScreen).on("active", function() {
85 $(".active-appear").fadeIn();
86 }).on("inactive", function() {
87 $(".active-appear").fadeOut();
91 /* Once everything else has loaded, its safe to remove the black screen
92 hiding the dom. Do it async so that all currently running async
93 functions have a chance to complete */
94 setTimeout(() => $cover.fadeOut(), dur=1);