Aleksander Machniak
2014-07-25 2c0d3e1dd0a3df01c8adea0de5f2826f0bcb9434
program/js/app.js
@@ -3374,9 +3374,7 @@
    }
    // check for locally stored compose data
    if (window.localStorage) {
      this.compose_restore_dialog(0, html_mode)
    }
    this.compose_restore_dialog(0, html_mode)
    if (input_to.val() == '')
      input_to.focus();
@@ -3900,15 +3898,16 @@
      }
    });
    if (window.localStorage && !empty) {
    if (!empty) {
      var index = this.local_storage_get_item('compose.index', []),
        key = this.env.compose_id;
        if ($.inArray(key, index) < 0) {
          index.push(key);
        }
        this.local_storage_set_item('compose.' + key, formdata, true);
        this.local_storage_set_item('compose.index', index);
      if ($.inArray(key, index) < 0) {
        index.push(key);
      }
      this.local_storage_set_item('compose.' + key, formdata, true);
      this.local_storage_set_item('compose.index', index);
    }
  };
@@ -3940,27 +3939,24 @@
  // remove stored compose data from localStorage
  this.remove_compose_data = function(key)
  {
    if (window.localStorage) {
      var index = this.local_storage_get_item('compose.index', []);
    var index = this.local_storage_get_item('compose.index', []);
      if ($.inArray(key, index) >= 0) {
        this.local_storage_remove_item('compose.' + key);
        this.local_storage_set_item('compose.index', $.grep(index, function(val,i) { return val != key; }));
      }
    if ($.inArray(key, index) >= 0) {
      this.local_storage_remove_item('compose.' + key);
      this.local_storage_set_item('compose.index', $.grep(index, function(val,i) { return val != key; }));
    }
  };
  // clear all stored compose data of this user
  this.clear_compose_data = function()
  {
    if (window.localStorage) {
      var i, index = this.local_storage_get_item('compose.index', []);
    var i, index = this.local_storage_get_item('compose.index', []);
      for (i=0; i < index.length; i++) {
        this.local_storage_remove_item('compose.' + index[i]);
      }
      this.local_storage_remove_item('compose.index');
    for (i=0; i < index.length; i++) {
      this.local_storage_remove_item('compose.' + index[i]);
    }
    this.local_storage_remove_item('compose.index');
  };
@@ -3981,18 +3977,16 @@
        return;
    }
    var i, rx,
      id = obj.options[obj.selectedIndex].value,
    var id = obj.options[obj.selectedIndex].value,
      sig = this.env.identity,
      delim = this.env.recipients_separator,
      rx_delim = RegExp.escape(delim),
      headers = ['replyto', 'bcc'];
      rx_delim = RegExp.escape(delim);
    // update reply-to/bcc fields with addresses defined in identities
    for (i in headers) {
      var key = headers[i],
        old_val = sig && this.env.identities[sig] ? this.env.identities[sig][key] : '',
        new_val = id && this.env.identities[id] ? this.env.identities[id][key] : '',
    $.each(['replyto', 'bcc'], function() {
      var rx, key = this,
        old_val = sig && ref.env.identities[sig] ? ref.env.identities[sig][key] : '',
        new_val = id && ref.env.identities[id] ? ref.env.identities[id][key] : '',
        input = $('[name="_'+key+'"]'), input_val = input.val();
      // remove old address(es)
@@ -4019,7 +4013,7 @@
      if (old_val || new_val)
        input.val(input_val).change();
    }
    });
    // enable manual signature insert
    if (this.env.signatures && this.env.signatures[id]) {
@@ -5896,6 +5890,9 @@
  {
    if (!this.gui_objects.subscriptionlist)
      return false;
    // disable drag-n-drop temporarily
    this.subscription_list.draggable('destroy').droppable('destroy');
    var row, n, tmp, tmp_name, rowid, collator, pos, p, parent = '',
      folders = [], list = [], slist = [],
@@ -8032,22 +8029,43 @@
  // wrapper for localStorage.getItem(key)
  this.local_storage_get_item = function(key, deflt, encrypted)
  {
    var item;
    // TODO: add encryption
    var item = localStorage.getItem(this.get_local_storage_prefix() + key);
    try {
      item = localStorage.getItem(this.get_local_storage_prefix() + key);
    }
    catch (e) { }
    return item !== null ? JSON.parse(item) : (deflt || null);
  };
  // wrapper for localStorage.setItem(key, data)
  this.local_storage_set_item = function(key, data, encrypted)
  {
    // TODO: add encryption
    return localStorage.setItem(this.get_local_storage_prefix() + key, JSON.stringify(data));
    // try/catch to handle no localStorage support, but also error
    // in Safari-in-private-browsing-mode where localStorage exists
    // but can't be used (#1489996)
    try {
      // TODO: add encryption
      localStorage.setItem(this.get_local_storage_prefix() + key, JSON.stringify(data));
      return true;
    }
    catch (e) {
      return false;
    }
  };
  // wrapper for localStorage.removeItem(key)
  this.local_storage_remove_item = function(key)
  {
    return localStorage.removeItem(this.get_local_storage_prefix() + key);
    try {
      localStorage.removeItem(this.get_local_storage_prefix() + key);
      return true;
    }
    catch (e) {
      return false;
    }
  };
}  // end object rcube_webmail