aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2016-02-18 21:16:34 +1300
committerDavid Phillips <dbphillipsnz@gmail.com>2016-02-18 21:16:34 +1300
commit729a2f6baad6d6542674f7a0066b2b191ae0033d (patch)
tree1ff0c5b8195273ea682965c890bc5c61bc828a99
parentfc3c7e2a7769dcc433e47450455f604442e88631 (diff)
downloadpetrichor-729a2f6baad6d6542674f7a0066b2b191ae0033d.tar.xz
Tweak to external js file
-rw-r--r--index.html189
1 files changed, 23 insertions, 166 deletions
diff --git a/index.html b/index.html
index ef7ddc0..f424466 100644
--- a/index.html
+++ b/index.html
@@ -1,168 +1,25 @@
<html>
- <head>
- <link rel="stylesheet" type="text/css" href="petrichor.css" />
- <script type="text/javascript">
-
- password_prompt = false;
- selected_user = null;
- time_remaining = 0
-
- function show_prompt(text, type)
- {
- password_prompt = true;
- label = document.getElementById('password_label');
- label.innerHTML = text;
-
- users = document.getElementById('users');
- for (i in users.children)
- {
- user = users.children[i];
- if (user.id != ('user_' + selected_user) && user.style != null)
- user.style.opacity = 0.1;
- }
-
- entry = document.getElementById('password_entry');
- entry.value = '';
-
- var selected = document.getElementById("user_" + selected_user);
- rect = selected.getBoundingClientRect();
- cont = document.getElementById('password_container');
-
- cont.style.top = rect.top;
- if (cont.style.left != rect.right)
- cont.style.left = rect.right;
- cont.classList.add('shown');
-
- entry.focus();
- }
-
- function show_message(text, type)
- {
- cont = document.getElementById('message_container');
- document.getElementById('message_label').innerHTML = text;
-
- if (text.length > 0)
- {
- var selected = document.getElementById("user_" + selected_user);
- rect = selected.getBoundingClientRect();
-
- cont.style.top = rect.top;
- if (cont.style.left != rect.right)
- cont.style.left = rect.right;
- cont.style.top = rect.top;
- cont.classList.add("shown");
- } else {
- cont.classList.remove("shown");
- }
- }
-
- function reset()
- {
- users = document.getElementById('users');
- for (i in users.children)
- {
- child = users.children[i];
- if (child.style != null)
- child.style.opacity = 1;
- }
- document.getElementById('password_container').classList.remove("shown");
- password_prompt = false;
- }
-
- function authentication_complete()
- {
-// document.getElementById('password_entry').value = '';
- if (lightdm.is_authenticated)
- lightdm.start_session_sync(lightdm.authentication_user, lightdm.default_session);
- else
- show_message('<span class="error-icon">&#x26A0;</span> Authentication Failed');
-
- reset();
- }
-
- function start_authentication(username)
- {
- document.getElementById('message_container').classList.remove("shown");
-
- if (!password_prompt) {
- selected_user = username;
- lightdm.authenticate(username);
- }
- }
-
- function provide_secret()
- {
- entry = document.getElementById('password_entry');
- lightdm.respond(entry.value);
- }
-
- function autologin_timer_expired(username)
- {
- lightdm.authenticate(lightdm.autologin_user);
- }
-
- function countdown()
- {
- label = document.getElementById('countdown_label');
- label.innerHTML = ' in ' + time_remaining + ' seconds';
- time_remaining--;
- if (time_remaining >= 0)
- setTimeout('countdown()', 1000);
- }
-
- function update_time()
- {
- var days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
- var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
- var d = new Date();
- niceHours = d.getHours();
- niceMinutes = d.getMinutes();
- // I'm yearning for strftime
- if (niceHours < 10)
- niceHours = "0"+niceHours;
- if (niceMinutes < 10)
- niceMinutes = "0"+niceMinutes;
- document.getElementById('date').innerHTML = days[d.getDay()] + ", " + d.getDate() + " " + months[d.getMonth()];
- document.getElementById('time').innerHTML = niceHours + ":" + niceMinutes;
- setTimeout('update_time()', 1000);
- }
-
- document.write('<div id="users">');
- for (i in lightdm.users)
- {
- user = lightdm.users[i];
-
- image = user.image;
-
- document.write('<div class="user" id="user_' + user.name +'"onclick="start_authentication(\'' + user.name + '\')" style="cursor: pointer;">');
- document.write('<img class="avatar" src="file:///' + image + '" /><span class="name">'+user.display_name+'</span>');
- if (user.name == lightdm.autologin_user && lightdm.autologin_timeout > 0)
- document.write('<span id="countdown_label"></span>');
- document.write(' </div>');
- }
- document.write('</div>');
-
-
- time_remaining = lightdm.autologin_timeout;
- if (time_remaining > 0)
- countdown();
- </script>
- </head>
-
- <body onclick="reset();" onload="update_time();">
- <div id="date-container">
- <div id="date"></div>
- <div id="time"></div>
- </div>
- <div id="password_container">
- <form action="javascript:provide_secret()">
- <span id="password_label"></span>
- <input id="password_entry" type="password" />
- </form>
- </div>
- <div id="message_container">
- <span id="message_label"></span>
- </div>
- <img id="shutdown" src="iec5009.svg" onclick="lightdm.shutdown();" />
- </body>
+ <head>
+ <link rel="stylesheet" type="text/css" href="petrichor.css" />
+ <script src="petrichor.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ start();
+ </script>
+ </head>
+ <body onclick="reset();" onload="update_time();">
+ <div id="date-container">
+ <div id="date"></div>
+ <div id="time"></div>
+ </div>
+ <div id="password_container">
+ <form action="javascript:provide_secret()">
+ <span id="password_label"></span>
+ <input id="password_entry" type="password" />
+ </form>
+ </div>
+ <div id="message_container">
+ <span id="message_label"></span>
+ </div>
+ <img id="shutdown" src="iec5009.svg" onclick="lightdm.shutdown();" />
+ </body>
</html>