diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js index 2d35b4e..0cd2291 100644 --- a/webssh/static/js/main.js +++ b/webssh/static/js/main.js @@ -7,9 +7,31 @@ jQuery(function($){ var status = $('#status'), btn = $('.btn-primary'), - style = {}; + style = {}, + names = ['hostname', 'port', 'username', 'password']; + function store_items(names, data) { + var i, name; + + for (i = 0; i < names.length; i++) { + name = names[i]; + window.localStorage.setItem(name, data.get(name)); + } + } + + function restore_items(names) { + var i, name, value; + + for (i=0; i < names.length; i++) { + name = names[i]; + value = window.localStorage.getItem(name) || ''; + $('#'+name).val(value); + } + } + + restore_items(names); + function parse_xterm_style() { var text = $('.xterm-helpers style').text(); var arr = text.split('xterm-normal-char{width:'); @@ -236,6 +258,8 @@ jQuery(function($){ return; } + store_items(names, data); + status.text(''); btn.prop('disabled', true); diff --git a/webssh/templates/index.html b/webssh/templates/index.html index 48db51b..2ecd185 100644 --- a/webssh/templates/index.html +++ b/webssh/templates/index.html @@ -17,6 +17,9 @@ margin-top: 20px; } + .btn-danger { + margin-left: 5px; + } @@ -25,21 +28,21 @@
- +
- +
- +
- +
@@ -53,6 +56,7 @@
{% module xsrf_form_html() %} +