dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

main.js (3795B)


      1 var selectedSession = lightdm.sessions[0];
      2 var selectedSessionIndex = 0;
      3 
      4 /* Listeners required by Lightdm */
      5 function authentication_complete() {
      6     writeDebugMessage("authentication_complete");
      7     if (lightdm.is_authenticated) {
      8         writeDebugMessage("User is authenticated. Session: " + selectedSession.name);
      9         lightdm.login(lightdm.authentication_user, selectedSession.key);
     10     }
     11 }
     12 
     13 function show_error(message) {
     14     writeDebugMessage("error: " + message);
     15 }
     16 
     17 function show_prompt(message) {
     18     writeDebugMessage("prompt: " + message);
     19     lightdm.provide_secret(jQuery("#password").val());
     20 }
     21 
     22 /* Simple logging function */
     23 function writeDebugMessage(message) {
     24     console.log(message);
     25 }
     26 
     27 /* Starts the sign in process */
     28 function submitPassword() {
     29     writeDebugMessage("submitPassword");
     30 //    lightdm.cancel_authentication();
     31     lightdm.cancel_timed_login();
     32     lightdm.start_authentication(jQuery("#username").val());
     33 }
     34 
     35 /* Cycle among different sessions */
     36 function cycleSessions() {
     37     writeDebugMessage("cycleSessions");
     38     selectedSession = lightdm.sessions[++selectedSessionIndex % lightdm.sessions.length];
     39     updateSessionNameContainer();
     40     jQuery("#sessionDisplay").show();
     41     writeDebugMessage("selectedSession: " + selectedSession.name);
     42 }
     43 
     44 var userIndex = 0;
     45 function cycleUsers() {
     46     writeDebugMessage("cycleUsers");
     47     jQuery("#username").val(lightdm.users[++userIndex % lightdm.users.length].name);
     48 }
     49 
     50 function updateSessionNameContainer() {
     51     writeDebugMessage("updateSessionNameContainer: " + selectedSession.name);
     52     jQuery("#sessionNameContainer").html(selectedSession.name);
     53 }
     54 
     55 jQuery(document).ready(function() {
     56 
     57     /* Creates the keypress listener to submit when the user
     58        presses ENTER or SHIFT+ENTER */
     59     jQuery("input").keypress(function() {
     60         if (event.which == 13 || event.which == 10) {
     61             event.preventDefault();
     62             submitPassword();
     63         }
     64     });
     65 
     66     jQuery(document).keydown(function() {
     67         if (!event.shiftKey && !event.ctrlKey && event.altKey && !event.metaKey) {
     68             switch (event.which) {
     69                 case 83: /* Alt + S */
     70                 case 67: /* Alt + C */
     71                     cycleSessions();
     72                     break;
     73                 case 72: /* Alt + H */
     74                     lightdm.hibernate();
     75                     break;
     76                 case 80: /* Alt + P */
     77                     lightdm.suspend();
     78                     break;
     79                 case 82: /* Alt + R */
     80                     lightdm.restart();
     81                     break;
     82                 case 76: /* Alt + L */
     83                     cycleUsers();
     84                     break;
     85             case 68: /* Alt + D */
     86                 lightdm.shutdown();
     87                 break;
     88             }
     89         }
     90     });
     91 
     92     /* Initiates the username field with the first username of the users' list */
     93     jQuery("#username").val(lightdm.users[0].name);
     94 
     95     updateSessionNameContainer();
     96 
     97 
     98     $('#motherOfAllContainers').fadeTo('slow', 0.3, function() {
     99         // $('#motherOfAllContainers').css("background", "url(/usr/share/lightdm-webkit/themes/musfealle/img/conc.jpg) no-repeat center center fixed");
    100         // $('#motherOfAllContainers').css("-webkit-background-size", "cover");
    101         // $('#motherOfAllContainers').css("-moz-background-size", "cover");
    102         // $('#motherOfAllContainers').css("-o-background-size", "cover");
    103         // $('#motherOfAllContainers').css("background-size: 100%");
    104 
    105         $("#inputBoxesContainer").show();
    106         $("#backgroundVideo").show();
    107 
    108         /* Moves the focus to the password field so in the best case scenario
    109            all the user has to do is type in the password and press ENTER */
    110         jQuery("#password").focus();
    111     }).fadeTo(2500, 1);
    112 
    113 });