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;
},
dialog: function() {
var input, inputs, _i, _len;
var input, _i, _len, _ref;
qr.el = ui.dialog('qr', 'top:0;right:0;', '\
<style>\
.autohide:not(:hover) > div:not(.move) {\
.autohide:not(:hover) > #form {\
display: none;\
}\
#qr > .move {\
@ -1259,26 +1259,23 @@
<input type=checkbox name=autohide id=autohide title=Auto-hide>\
<a class=close></a>\
</div>\
<div>\
<input name=name><input name=email><input name=pwd hidden><input name=subject>\
<div id=form>\
<input name=name><input name=email><input name=subject>\
<textarea></textarea>\
</div>');
$.on($('#autohide', qr.el), 'click', qr.hide);
$.on($('.close', qr.el), 'click', qr.close);
inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el), $('[name=pwd]', qr.el)];
for (_i = 0, _len = inputs.length; _i < _len; _i++) {
input = inputs[_i];
_ref = [$('[name=name]', qr.el), $('[name=email]', qr.el)];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i];
input.value = $.get("qr_" + input.name, null);
$.on(input, 'change', function() {
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) {
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);
}
});

View File

@ -915,7 +915,7 @@ qr =
dialog: ->
qr.el = ui.dialog 'qr', 'top:0;right:0;', '
<style>
.autohide:not(:hover) > div:not(.move) {
.autohide:not(:hover) > #form {
display: none;
}
#qr > .move {
@ -928,24 +928,20 @@ qr =
<input type=checkbox name=autohide id=autohide title=Auto-hide>
<a class=close></a>
</div>
<div>
<input name=name><input name=email><input name=pwd hidden><input name=subject>
<div id=form>
<input name=name><input name=email><input name=subject>
<textarea></textarea>
</div>'
$.on $('#autohide', qr.el), 'click', qr.hide
$.on $('.close', qr.el), 'click', qr.close
# save & load inputs' value with localStorage
inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el), $('[name=pwd]', qr.el)]
for input in inputs
for input in [$('[name=name]', qr.el), $('[name=email]', qr.el)]
input.value = $.get "qr_#{input.name}", null
$.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
$.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
$.add d.body, qr.el