Commit 9a49c9e5 by Sheng

Use localStorage

parent f09ba9ec
......@@ -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);
......
......@@ -17,6 +17,9 @@
margin-top: 20px;
}
.btn-danger {
margin-left: 5px;
}
</style>
</head>
<body>
......@@ -25,21 +28,21 @@
<div class="row">
<div class="col">
<label for="Hostname">Hostname</label>
<input class="form-control" type="text" name="hostname" value="" required>
<input class="form-control" type="text" id="hostname" name="hostname" value="" required>
</div>
<div class="col">
<label for="Port">Port</label>
<input class="form-control" type="number" name="port" min=1 max=65535 value="" required>
<input class="form-control" type="number" id="port" name="port" min=1 max=65535 value="" required>
</div>
</div>
<div class="row">
<div class="col">
<label for="Username">Username</label>
<input class="form-control" type="text" name="username" value="" required>
<input class="form-control" type="text" id="username" name="username" value="" required>
</div>
<div class="col">
<label for="Username">Private Key</label>
<input class="form-control" type="file" name="privatekey" value="">
<input class="form-control" type="file" id="privatekey" name="privatekey" value="">
</div>
</div>
<div class="row">
......@@ -53,6 +56,7 @@
</div>
{% module xsrf_form_html() %}
<button type="submit" class="btn btn-primary">Connect</button>
<button type="reset" class="btn btn-danger">Reset</button>
</form>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment