Commit 9a49c9e5 by Sheng

Use localStorage

parent f09ba9ec
...@@ -7,9 +7,31 @@ jQuery(function($){ ...@@ -7,9 +7,31 @@ jQuery(function($){
var status = $('#status'), var status = $('#status'),
btn = $('.btn-primary'), 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() { function parse_xterm_style() {
var text = $('.xterm-helpers style').text(); var text = $('.xterm-helpers style').text();
var arr = text.split('xterm-normal-char{width:'); var arr = text.split('xterm-normal-char{width:');
...@@ -236,6 +258,8 @@ jQuery(function($){ ...@@ -236,6 +258,8 @@ jQuery(function($){
return; return;
} }
store_items(names, data);
status.text(''); status.text('');
btn.prop('disabled', true); btn.prop('disabled', true);
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
margin-top: 20px; margin-top: 20px;
} }
.btn-danger {
margin-left: 5px;
}
</style> </style>
</head> </head>
<body> <body>
...@@ -25,21 +28,21 @@ ...@@ -25,21 +28,21 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<label for="Hostname">Hostname</label> <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>
<div class="col"> <div class="col">
<label for="Port">Port</label> <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> </div>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<label for="Username">Username</label> <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>
<div class="col"> <div class="col">
<label for="Username">Private Key</label> <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> </div>
<div class="row"> <div class="row">
...@@ -53,6 +56,7 @@ ...@@ -53,6 +56,7 @@
</div> </div>
{% module xsrf_form_html() %} {% module xsrf_form_html() %}
<button type="submit" class="btn btn-primary">Connect</button> <button type="submit" class="btn btn-primary">Connect</button>
<button type="reset" class="btn btn-danger">Reset</button>
</form> </form>
</div> </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