Permalink
Browse files

Save your common settings in session storage.

  • Loading branch information...
deviantintegral committed Feb 28, 2013
1 parent a6d501b commit bc0a61fb78b78f52ffdaf3351a9f7c426b2c6d40
Showing with 20 additions and 0 deletions.
  1. +20 −0 assets/js/views/overview.js
@@ -26,9 +26,24 @@ var OverviewView = Backbone.View.extend({
}
$('.overview_button').bind('click', $.proxy(this.render, this));
+
+ // Load saved settings.
+ this.savedSettings(['nick', 'realName', 'server']);
+
return this;
},
+ // Restore any settings saved in localStorage.
+ savedSettings: function(settings) {
+ for (var i in settings) {
+ var setting = settings[i];
+ var s = sessionStorage.getItem(setting);
+ if (s) {
+ $('#connect-' + setting).val(s);
+ }
+ }
+ },
+
connectOnEnter: function(event) {
if (event.keyCode !== 13) return;
if($('#connect-button').length){
@@ -93,6 +108,11 @@ var OverviewView = Backbone.View.extend({
irc.me = new User(connectInfo);
irc.me.on('change:nick', irc.appView.renderUserBox);
irc.socket.emit('connect', connectInfo);
+
+ // Save standard settings in session storage.
+ sessionStorage.setItem('nick', nick);
+ sessionStorage.setItem('realName', realName);
+ sessionStorage.setItem('server', server);
}
},

0 comments on commit bc0a61f

Please sign in to comment.