Skip to content

Commit

Permalink
Save and restore last field values in local storage.
Browse files Browse the repository at this point in the history
Partial solution to Issue 29.
  • Loading branch information
rpwoodbu committed Sep 21, 2014
1 parent 58d63a5 commit 7f0d52b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/app/mosh_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,38 @@ window.onload = function() {
sshModeButton.onchange = updateMode;
var manualModeButton = document.querySelector('#manual-mode');
manualModeButton.onchange = updateMode;
loadFields();
var form = document.querySelector('#args');
form.onsubmit = function() { return false; };
updateMode();
};

var kSyncFieldNames = [ 'addr', 'port', 'user', 'command' ];

function loadFields() {
var form = document.querySelector('#args');
kSyncFieldNames.forEach(function(field) {
var key = 'field_' + field;
chrome.storage.local.get(key, function(o) {
if (o[key] !== undefined) {
form[field].value = o[key];
}
});
});
}

function saveFields() {
var form = document.querySelector('#args');
kSyncFieldNames.forEach(function(field) {
var key = 'field_' + field;
var o = {};
o[key] = form[field].value;
chrome.storage.local.set(o);
});
}

function onConnectClick(e) {
saveFields();
var args = {}
var form = document.querySelector('#args');
args['addr'] = form['addr'].value;
Expand Down

0 comments on commit 7f0d52b

Please sign in to comment.