Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑天保
webssh
Commits
07dc33df
Commit
07dc33df
authored
Aug 22, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use callbak complete instead of success
parent
eb792d4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
20 deletions
+45
-20
main.js
webssh/static/js/main.js
+45
-20
No files found.
webssh/static/js/main.js
View file @
07dc33df
...
...
@@ -12,11 +12,14 @@ jQuery(function($){
function
store_items
(
names
,
data
)
{
var
i
,
name
;
var
i
,
name
,
value
;
for
(
i
=
0
;
i
<
names
.
length
;
i
++
)
{
name
=
names
[
i
];
window
.
localStorage
.
setItem
(
name
,
data
.
get
(
name
));
value
=
data
.
get
(
name
);
if
(
value
){
window
.
localStorage
.
setItem
(
name
,
value
);
}
}
}
...
...
@@ -25,8 +28,10 @@ jQuery(function($){
for
(
i
=
0
;
i
<
names
.
length
;
i
++
)
{
name
=
names
[
i
];
value
=
window
.
localStorage
.
getItem
(
name
)
||
''
;
$
(
'#'
+
name
).
val
(
value
);
value
=
window
.
localStorage
.
getItem
(
name
);
if
(
value
)
{
$
(
'#'
+
name
).
val
(
value
);
}
}
}
...
...
@@ -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
)
{
return
JSON
.
stringify
({
'cols'
:
cols
,
'rows'
:
rows
});
}
function
callback
(
msg
)
{
// console.log(msg);
function
reset_wssh
()
{
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
)
{
status
.
text
(
msg
.
status
);
setTimeout
(
function
(){
btn
.
prop
(
'disabled'
,
false
);
},
3000
);
return
;
}
...
...
@@ -95,6 +109,12 @@ jQuery(function($){
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
)
{
// for console use
if
(
!
sock
)
{
...
...
@@ -118,6 +138,7 @@ jQuery(function($){
wssh
.
set_encoding
=
function
(
new_encoding
)
{
// for console use
if
(
new_encoding
===
undefined
)
{
console
.
log
(
'An encoding is required'
);
return
;
}
...
...
@@ -136,8 +157,12 @@ jQuery(function($){
wssh
.
reset_encoding
=
function
()
{
// for console use
encoding
=
msg
.
encoding
;
console
.
log
(
'Reset encoding to '
+
msg
.
encoding
);
if
(
encoding
===
msg
.
encoding
)
{
console
.
log
(
'Already reset to '
+
msg
.
encoding
);
}
else
{
encoding
=
msg
.
encoding
;
console
.
log
(
'Reset encoding to '
+
msg
.
encoding
);
}
};
wssh
.
resize_terminal
=
function
(
cols
,
rows
)
{
...
...
@@ -211,9 +236,9 @@ jQuery(function($){
term
.
destroy
();
term
=
undefined
;
sock
=
undefined
;
reset_wssh
();
$
(
'.container'
).
show
();
status
.
text
(
e
.
reason
);
btn
.
prop
(
'disabled'
,
false
);
};
$
(
window
).
resize
(
function
(){
...
...
@@ -267,7 +292,7 @@ jQuery(function($){
url
:
url
,
type
:
type
,
data
:
data
,
success
:
callback
,
complete
:
callback
,
cache
:
false
,
contentType
:
false
,
processData
:
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment