diff options
author | John McLear <john@mclear.co.uk> | 2012-12-03 06:35:16 -0800 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2012-12-03 06:35:16 -0800 |
commit | 55d543f9ca6ed9985b54f4c60ac6a947cc5b5822 (patch) | |
tree | 8eddf2359f6596b56c5c2b632cf7a3e7c0a07aa2 /src/static/js | |
parent | 17fb60e483933bfa81fbff53c72f032c4114634a (diff) | |
parent | 1e8d954560bc7e475d73ce9e4df82ffeb2492c80 (diff) | |
download | etherpad-lite-55d543f9ca6ed9985b54f4c60ac6a947cc5b5822.zip |
Merge pull request #1221 from ether/focus-on-password
proper fix for focus and some styling of the form and allows for pressin...
Diffstat (limited to 'src/static/js')
-rw-r--r-- | src/static/js/pad.js | 29 | ||||
-rw-r--r-- | src/static/js/pad_utils.js | 19 |
2 files changed, 32 insertions, 16 deletions
diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 34f2a287..9ad701b3 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -51,18 +51,20 @@ var randomString = require('./pad_utils').randomString; var hooks = require('./pluginfw/hooks'); -function createCookie(name, value, days, path) -{ +function createCookie(name, value, days, path){ /* Warning Internet Explorer doesn't use this it uses the one from pad_utils.js */ if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } - else var expires = ""; + else{ + var expires = ""; + } - if(!path) + if(!path){ // If the path isn't set then just whack the cookie on the root path path = "/"; + } //Check if the browser is IE and if so make sure the full path is set in the cookie if(navigator.appName=='Microsoft Internet Explorer'){ @@ -202,6 +204,7 @@ function savePassword() createCookie("password",$("#passwordinput").val(),null,document.location.pathname); //reload document.location=document.location; + return false; } function handshake() @@ -298,21 +301,25 @@ function handshake() //the access was not granted, give the user a message if(!receivedClientVars && obj.accessStatus) { + $('.passForm').submit(require(module.id).savePassword); + if(obj.accessStatus == "deny") { - $("#editorloadingbox").html("<b>You do not have permission to access this pad</b>"); + $('#loading').hide(); + $("#permissionDenied").show(); } else if(obj.accessStatus == "needPassword") { - $("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" + - "<input id='passwordinput' type='password' name='password'>"+ - "<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>"); + $('#loading').hide(); + $('#passwordRequired').show(); + $("#passwordinput").focus(); } else if(obj.accessStatus == "wrongPassword") { - $("#editorloadingbox").html("<b>Your password was wrong</b><br>" + - "<input id='passwordinput' type='password' name='password'>"+ - "<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>"); + $('#loading').hide(); + $('#wrongPassword').show(); + $('#passwordRequired').show(); + $("#passwordinput").focus(); } } diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index 83ee9aae..82f7fcad 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -39,20 +39,29 @@ function randomString(len) return randomstring; } -function createCookie(name, value, days, path) -{ +function createCookie(name, value, days, path){ /* Used by IE */ if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } - else var expires = ""; + else{ + var expires = ""; + } - if(!path) + if(!path){ // IF the Path of the cookie isn't set then just create it on root path = "/"; + } + + //Check if the browser is IE and if so make sure the full path is set in the cookie + if(navigator.appName=='Microsoft Internet Explorer'){ + document.cookie = name + "=" + value + expires + "; path=/"; /* Note this bodge fix for IE is temporary until auth is rewritten */ + } + else{ + document.cookie = name + "=" + value + expires + "; path=" + path; + } - document.cookie = name + "=" + value + expires + "; path=" + path; } function readCookie(name) |