From fddca354b33eb2f855178657b775a4008e8da8d5 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 26 Nov 2012 20:52:10 +0000 Subject: [PATCH 01/11] proper fix for focus and some styling of the form and allows for pressing enter on form so generally a better fix --- src/static/js/pad.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 34f2a287..936298ab 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -305,14 +305,22 @@ function handshake() else if(obj.accessStatus == "needPassword") { $("#editorloadingbox").html("You need a password to access this pad
" + - ""+ - ""); + "
"+ + ""); + $("#passwordinput").focus(); + $(".passForm").submit(function(){ + $('.passForm button').click(); + }); } else if(obj.accessStatus == "wrongPassword") { $("#editorloadingbox").html("Your password was wrong
" + - ""+ - ""); + ""+ + ""); + $("#passwordinput").focus(); + $(".passForm").submit(function(){ + $('.passForm button').click(); + }); } } From f880473360e26f683df73700366f36b7dc757bdb Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 26 Nov 2012 20:54:28 +0000 Subject: [PATCH 02/11] remember the styling for the pasword prompt --- src/static/css/pad.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/static/css/pad.css b/src/static/css/pad.css index 64f9f0d4..01a19514 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -190,6 +190,19 @@ a img { height: 30px; z-index: 100; } + +#editorloadingbox passForm{ + padding:10px; +} + +#editorloadingbox input{ + padding:10px; +} + +#editorloadingbox button{ + padding:10px; +} + #editorcontainerbox { position: absolute; bottom: 0; From c445197e7fc03572aa31511e35f9193a47332c20 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 27 Nov 2012 15:10:36 +0000 Subject: [PATCH 03/11] Update src/static/css/pad.css --- src/static/css/pad.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/css/pad.css b/src/static/css/pad.css index 01a19514..a2540614 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -191,7 +191,7 @@ a img { z-index: 100; } -#editorloadingbox passForm{ +#editorloadingbox .passForm{ padding:10px; } From 3cdf66c2f77d6aa57f38635492464ecc4a2059f7 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 Dec 2012 17:03:56 +0000 Subject: [PATCH 04/11] first effort to move into templates but javascript is broken so dont pull --- src/static/css/pad.css | 13 +++++++++++++ src/static/js/pad.js | 25 +++++++++++++++++-------- src/templates/pad.html | 14 +++++++++++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/static/css/pad.css b/src/static/css/pad.css index 01a19514..6f96b92d 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -22,6 +22,7 @@ iframe { .readonly .acl-write { display: none; } + #users { background: #f7f7f7; background: -webkit-linear-gradient( #F7F7F7,#EEE); @@ -891,3 +892,15 @@ input[type=checkbox] { line-height: 24px } } + +#passwordRequired{ + display:none; +} + +#permissionDenied{ + display:none; +} + +#wrongPassword{ + display:none; +} diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 936298ab..bfe8bf8c 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -298,30 +298,39 @@ function handshake() //the access was not granted, give the user a message if(!receivedClientVars && obj.accessStatus) { + $('.passForm').submit(function(){ + // THIS BIT DOESNT WORK + alert("I AM BROKEN"); + padutils.escapeHtml('require('+JSON.stringify(module.id)).savePassword(); + }); + if(obj.accessStatus == "deny") { - $("#editorloadingbox").html("You do not have permission to access this pad"); + $('#loading').hide(); + $("#permissionDenied").show()); } else if(obj.accessStatus == "needPassword") { - $("#editorloadingbox").html("You need a password to access this pad
" + +/* $("#editorloadingbox").html("You need a password to access this pad
" + ""+ ""); $("#passwordinput").focus(); $(".passForm").submit(function(){ $('.passForm button').click(); }); +*/ + $('#loading').hide(); + $('#passwordRequired').show(); + $("#passwordinput").focus(); } else if(obj.accessStatus == "wrongPassword") { - $("#editorloadingbox").html("Your password was wrong
" + - ""+ - ""); + $('#loading').hide(); + $('#wrongPassword').show(); $("#passwordinput").focus(); - $(".passForm").submit(function(){ - $('.passForm button').click(); - }); + } + } //if we haven't recieved the clientVars yet, then this message should it be diff --git a/src/templates/pad.html b/src/templates/pad.html index 3f3eee4f..402d9003 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -184,7 +184,19 @@
-

Loading...

+
+

You need a password to access this pad

+ + + +
+
+

You do not have permission to access this pad

+
+
+

Your password was wrong

+
+

Loading...

From 84d154b168f792bd6c95aa9c78df8ddc0d867805 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 3 Dec 2012 11:35:06 +0000 Subject: [PATCH 05/11] Update strings, add UK strings, fix JS --- src/locales/en.ini | 3 +++ src/static/js/pad.js | 12 +----------- src/templates/pad.html | 6 +++--- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/locales/en.ini b/src/locales/en.ini index e542594d..225b16cf 100644 --- a/src/locales/en.ini +++ b/src/locales/en.ini @@ -21,6 +21,9 @@ pad.toolbar.showusers.title = Show the users on this pad pad.colorpicker.save = Save pad.colorpicker.cancel = Cancel pad.loading = Loading... +pad.passwordRequired = You need a password to access this pad +pad.permissionDenied = You do not have permission to access this pad +pad.wrongPassword = Your password was wrong pad.settings.padSettings = Pad Settings pad.settings.myView = My View pad.settings.stickychat = Chat always on screen diff --git a/src/static/js/pad.js b/src/static/js/pad.js index bfe8bf8c..aef06eff 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -299,9 +299,7 @@ function handshake() if(!receivedClientVars && obj.accessStatus) { $('.passForm').submit(function(){ - // THIS BIT DOESNT WORK - alert("I AM BROKEN"); - padutils.escapeHtml('require('+JSON.stringify(module.id)).savePassword(); + require(module.id).savePassword(); }); if(obj.accessStatus == "deny") @@ -311,14 +309,6 @@ function handshake() } else if(obj.accessStatus == "needPassword") { -/* $("#editorloadingbox").html("You need a password to access this pad
" + - "
"+ - ""); - $("#passwordinput").focus(); - $(".passForm").submit(function(){ - $('.passForm button').click(); - }); -*/ $('#loading').hide(); $('#passwordRequired').show(); $("#passwordinput").focus(); diff --git a/src/templates/pad.html b/src/templates/pad.html index e37163e1..d9c6be46 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -185,16 +185,16 @@
-

You need a password to access this pad

+

You need a password to access this pad

-

You do not have permission to access this pad

+

You do not have permission to access this pad

-

Your password was wrong

+

Your password was wrong

Loading...

From b0463bd7d5c64b25cff95718e9b529320a10586e Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 3 Dec 2012 11:41:51 +0000 Subject: [PATCH 06/11] whoopsi --- src/static/js/pad.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index aef06eff..54d44278 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -298,14 +298,12 @@ function handshake() //the access was not granted, give the user a message if(!receivedClientVars && obj.accessStatus) { - $('.passForm').submit(function(){ - require(module.id).savePassword(); - }); + $('.passForm').submit(pad.savePassword); if(obj.accessStatus == "deny") { $('#loading').hide(); - $("#permissionDenied").show()); + $("#permissionDenied").show(); } else if(obj.accessStatus == "needPassword") { @@ -318,9 +316,7 @@ function handshake() $('#loading').hide(); $('#wrongPassword').show(); $("#passwordinput").focus(); - } - } //if we haven't recieved the clientVars yet, then this message should it be From 4843840d72095229e022b81629fb6639ef201946 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 3 Dec 2012 11:44:30 +0000 Subject: [PATCH 07/11] last JS fix --- src/static/js/pad.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 54d44278..316802bf 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -298,7 +298,7 @@ function handshake() //the access was not granted, give the user a message if(!receivedClientVars && obj.accessStatus) { - $('.passForm').submit(pad.savePassword); + $('.passForm').submit(require(module.id).savePassword); if(obj.accessStatus == "deny") { From d09894ce779e1b55970514d1318119dd2485da44 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 3 Dec 2012 12:05:11 +0000 Subject: [PATCH 08/11] make it show password dialog on wrong password --- src/static/js/pad.js | 1 + src/static/js/pad_utils.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 316802bf..d380a8dc 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -315,6 +315,7 @@ function handshake() { $('#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..f752722f 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -52,7 +52,17 @@ function createCookie(name, value, days, path) if(!path) path = "/"; - document.cookie = name + "=" + value + expires + "; path=" + path; + if(!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'){ + document.cookie = name + "=" + value + expires + "; path="+document.location; + } + else{ + document.cookie = name + "=" + value + expires + "; path=" + path; + } + } function readCookie(name) From 0b92fdfc628656f9d7b562d62733778f144e65d9 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 3 Dec 2012 12:47:11 +0000 Subject: [PATCH 09/11] fix IE auth but only a temp fix --- src/static/js/pad_utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index f752722f..59c3d419 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -52,8 +52,9 @@ function createCookie(name, value, days, path) if(!path) path = "/"; - if(!path) - path = "/"; + // This fixes an issue with IE not wanting to store cookies for Auth #1234. It's a temp fix because + // Really we should be storing the cookie on teh document.location path and not modifying the fsking URL to contain a password! + document.cookie = name + "=" + value + expires + "; 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'){ From b3e55f64a86951ddd25243c4b593cf61ec109c4c Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 3 Dec 2012 13:10:32 +0000 Subject: [PATCH 10/11] stop password being clearly visible --- src/static/js/pad.js | 1 + src/static/js/pad_utils.js | 2 +- src/templates/pad.html | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index d380a8dc..cace9bf7 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -202,6 +202,7 @@ function savePassword() createCookie("password",$("#passwordinput").val(),null,document.location.pathname); //reload document.location=document.location; + return false; } function handshake() diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index 59c3d419..7c97b035 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -54,7 +54,7 @@ function createCookie(name, value, days, path) // This fixes an issue with IE not wanting to store cookies for Auth #1234. It's a temp fix because // Really we should be storing the cookie on teh document.location path and not modifying the fsking URL to contain a password! - document.cookie = name + "=" + value + expires + "; path=" + "/"; + // document.cookie = name + "=" + value + expires + "; 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'){ diff --git a/src/templates/pad.html b/src/templates/pad.html index 896a62f6..a392980a 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -186,7 +186,7 @@

You need a password to access this pad

-
+
From 1e8d954560bc7e475d73ce9e4df82ffeb2492c80 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 3 Dec 2012 14:28:25 +0000 Subject: [PATCH 11/11] best I can do with this temporary fix for IE --- src/static/js/pad.js | 10 ++++++---- src/static/js/pad_utils.js | 16 +++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index cace9bf7..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'){ diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index 7c97b035..82f7fcad 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -39,26 +39,24 @@ 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 = "/"; - - // This fixes an issue with IE not wanting to store cookies for Auth #1234. It's a temp fix because - // Really we should be storing the cookie on teh document.location path and not modifying the fsking URL to contain a password! - // document.cookie = name + "=" + value + expires + "; 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="+document.location; + 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;