Commit 07dc33df by Sheng

Use callbak complete instead of success

parent eb792d4d
...@@ -12,11 +12,14 @@ jQuery(function($){ ...@@ -12,11 +12,14 @@ jQuery(function($){
function store_items(names, data) { function store_items(names, data) {
var i, name; var i, name, value;
for (i = 0; i < names.length; i++) { for (i = 0; i < names.length; i++) {
name = names[i]; name = names[i];
window.localStorage.setItem(name, data.get(name)); value = data.get(name);
if (value){
window.localStorage.setItem(name, value);
}
} }
} }
...@@ -25,10 +28,12 @@ jQuery(function($){ ...@@ -25,10 +28,12 @@ jQuery(function($){
for (i=0; i < names.length; i++) { for (i=0; i < names.length; i++) {
name = names[i]; name = names[i];
value = window.localStorage.getItem(name) || ''; value = window.localStorage.getItem(name);
if (value) {
$('#'+name).val(value); $('#'+name).val(value);
} }
} }
}
restore_items(names); restore_items(names);
...@@ -52,25 +57,34 @@ jQuery(function($){ ...@@ -52,25 +57,34 @@ jQuery(function($){
} }
wssh.window_geometry = function() {
// for console use
var geometry = current_geometry();
console.log('Current window geometry: ' + JSON.stringify(geometry));
};
function format_geometry(cols, rows) { function format_geometry(cols, rows) {
return JSON.stringify({'cols': cols, 'rows': rows}); return JSON.stringify({'cols': cols, 'rows': rows});
} }
function callback(msg) { function reset_wssh() {
// console.log(msg); var name;
for (name in wssh) {
if (wssh.hasOwnProperty(name)) {
delete wssh[name];
}
}
}
function callback(resp) {
btn.prop('disabled', false);
if (resp.status !== 200) {
console.log(resp);
status.text('Response code: ' + resp.status);
return;
}
var msg = resp.responseJSON;
if (msg.status) { if (msg.status) {
status.text(msg.status); status.text(msg.status);
setTimeout(function(){
btn.prop('disabled', false);
}, 3000);
return; return;
} }
...@@ -95,6 +109,12 @@ jQuery(function($){ ...@@ -95,6 +109,12 @@ jQuery(function($){
term.on_resize(geometry.cols, geometry.rows); term.on_resize(geometry.cols, geometry.rows);
} }
wssh.window_geometry = function() {
// for console use
var geometry = current_geometry();
console.log('Current window geometry: ' + JSON.stringify(geometry));
};
wssh.websocket_send = function (data) { wssh.websocket_send = function (data) {
// for console use // for console use
if (!sock) { if (!sock) {
...@@ -118,6 +138,7 @@ jQuery(function($){ ...@@ -118,6 +138,7 @@ jQuery(function($){
wssh.set_encoding = function (new_encoding) { wssh.set_encoding = function (new_encoding) {
// for console use // for console use
if (new_encoding === undefined) { if (new_encoding === undefined) {
console.log('An encoding is required');
return; return;
} }
...@@ -136,8 +157,12 @@ jQuery(function($){ ...@@ -136,8 +157,12 @@ jQuery(function($){
wssh.reset_encoding = function () { wssh.reset_encoding = function () {
// for console use // for console use
if (encoding === msg.encoding) {
console.log('Already reset to ' + msg.encoding);
} else {
encoding = msg.encoding; encoding = msg.encoding;
console.log('Reset encoding to ' + msg.encoding); console.log('Reset encoding to ' + msg.encoding);
}
}; };
wssh.resize_terminal = function (cols, rows) { wssh.resize_terminal = function (cols, rows) {
...@@ -211,9 +236,9 @@ jQuery(function($){ ...@@ -211,9 +236,9 @@ jQuery(function($){
term.destroy(); term.destroy();
term = undefined; term = undefined;
sock = undefined; sock = undefined;
reset_wssh();
$('.container').show(); $('.container').show();
status.text(e.reason); status.text(e.reason);
btn.prop('disabled', false);
}; };
$(window).resize(function(){ $(window).resize(function(){
...@@ -267,7 +292,7 @@ jQuery(function($){ ...@@ -267,7 +292,7 @@ jQuery(function($){
url: url, url: url,
type: type, type: type,
data: data, data: data,
success: callback, complete: callback,
cache: false, cache: false,
contentType: false, contentType: false,
processData: false processData: false
......
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