Actually don't use an element to store the password; we'll use xhr2, we don't need hidden inputs where we're going.

This commit is contained in:
Nicolas Stepien 2011-12-30 00:13:42 +01:00
parent 5f03b8949d
commit 0005cf6930
2 changed files with 13 additions and 20 deletions

View File

@ -1243,10 +1243,10 @@
return ta.selectionEnd = ta.selectionStart = caretPos + text.length; return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
}, },
dialog: function() { dialog: function() {
var input, inputs, _i, _len; var input, _i, _len, _ref;
qr.el = ui.dialog('qr', 'top:0;right:0;', '\ qr.el = ui.dialog('qr', 'top:0;right:0;', '\
<style>\ <style>\
.autohide:not(:hover) > div:not(.move) {\ .autohide:not(:hover) > #form {\
display: none;\ display: none;\
}\ }\
#qr > .move {\ #qr > .move {\
@ -1259,26 +1259,23 @@
<input type=checkbox name=autohide id=autohide title=Auto-hide>\ <input type=checkbox name=autohide id=autohide title=Auto-hide>\
<a class=close></a>\ <a class=close></a>\
</div>\ </div>\
<div>\ <div id=form>\
<input name=name><input name=email><input name=pwd hidden><input name=subject>\ <input name=name><input name=email><input name=subject>\
<textarea></textarea>\ <textarea></textarea>\
</div>'); </div>');
$.on($('#autohide', qr.el), 'click', qr.hide); $.on($('#autohide', qr.el), 'click', qr.hide);
$.on($('.close', qr.el), 'click', qr.close); $.on($('.close', qr.el), 'click', qr.close);
inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el), $('[name=pwd]', qr.el)]; _ref = [$('[name=name]', qr.el), $('[name=email]', qr.el)];
for (_i = 0, _len = inputs.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = inputs[_i]; input = _ref[_i];
input.value = $.get("qr_" + input.name, null); input.value = $.get("qr_" + input.name, null);
$.on(input, 'change', function() { $.on(input, 'change', function() {
return $.set("qr_" + this.name, this.value); return $.set("qr_" + this.name, this.value);
}); });
} }
if (!inputs[2].value) {
$.set("qr_pwd", inputs[2].value = $('.postarea [name=pwd]').value);
}
$.on(window, 'storage', function(e) { $.on(window, 'storage', function(e) {
var match; var match;
if (match = e.key.match(/qr_(name|email|pwd)$/)) { if (match = e.key.match(/qr_(name|email)$/)) {
return $("[name=" + match[1] + "]", qr.el).value = JSON.parse(e.newValue); return $("[name=" + match[1] + "]", qr.el).value = JSON.parse(e.newValue);
} }
}); });

View File

@ -915,7 +915,7 @@ qr =
dialog: -> dialog: ->
qr.el = ui.dialog 'qr', 'top:0;right:0;', ' qr.el = ui.dialog 'qr', 'top:0;right:0;', '
<style> <style>
.autohide:not(:hover) > div:not(.move) { .autohide:not(:hover) > #form {
display: none; display: none;
} }
#qr > .move { #qr > .move {
@ -928,24 +928,20 @@ qr =
<input type=checkbox name=autohide id=autohide title=Auto-hide> <input type=checkbox name=autohide id=autohide title=Auto-hide>
<a class=close></a> <a class=close></a>
</div> </div>
<div> <div id=form>
<input name=name><input name=email><input name=pwd hidden><input name=subject> <input name=name><input name=email><input name=subject>
<textarea></textarea> <textarea></textarea>
</div>' </div>'
$.on $('#autohide', qr.el), 'click', qr.hide $.on $('#autohide', qr.el), 'click', qr.hide
$.on $('.close', qr.el), 'click', qr.close $.on $('.close', qr.el), 'click', qr.close
# save & load inputs' value with localStorage # save & load inputs' value with localStorage
inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el), $('[name=pwd]', qr.el)] for input in [$('[name=name]', qr.el), $('[name=email]', qr.el)]
for input in inputs
input.value = $.get "qr_#{input.name}", null input.value = $.get "qr_#{input.name}", null
$.on input, 'change', -> $.set "qr_#{@name}", @value $.on input, 'change', -> $.set "qr_#{@name}", @value
# load & save default password if there isn't any saved
unless inputs[2].value
$.set "qr_pwd", inputs[2].value = $('.postarea [name=pwd]').value
# sync between tabs # sync between tabs
$.on window, 'storage', (e) -> $.on window, 'storage', (e) ->
if match = e.key.match /qr_(name|email|pwd)$/ if match = e.key.match /qr_(name|email)$/
$("[name=#{match[1]}]", qr.el).value = JSON.parse e.newValue $("[name=#{match[1]}]", qr.el).value = JSON.parse e.newValue
$.add d.body, qr.el $.add d.body, qr.el