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
b14b8a9f
Commit
b14b8a9f
authored
Aug 24, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added state to wssh
parent
4710d8c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
main.js
webssh/static/js/main.js
+17
-7
No files found.
webssh/static/js/main.js
View file @
b14b8a9f
...
@@ -8,7 +8,11 @@ jQuery(function($){
...
@@ -8,7 +8,11 @@ jQuery(function($){
var
status
=
$
(
'#status'
),
var
status
=
$
(
'#status'
),
btn
=
$
(
'.btn-primary'
),
btn
=
$
(
'.btn-primary'
),
style
=
{},
style
=
{},
connected
=
false
,
DISCONNECTED
=
0
,
CONNECTING
=
1
,
CONNECTED
=
2
,
state
=
DISCONNECTED
,
messages
=
{
1
:
'This client is connecting ...'
,
2
:
'This client is already connnected.'
},
key_max_size
=
16384
,
key_max_size
=
16384
,
form_id
=
'#connect'
,
form_id
=
'#connect'
,
names
=
[
'hostname'
,
'port'
,
'username'
,
'password'
],
names
=
[
'hostname'
,
'port'
,
'username'
,
'password'
],
...
@@ -111,6 +115,7 @@ jQuery(function($){
...
@@ -111,6 +115,7 @@ jQuery(function($){
if
(
resp
.
status
!==
200
)
{
if
(
resp
.
status
!==
200
)
{
console
.
log
(
resp
);
console
.
log
(
resp
);
status
.
text
(
'Response code: '
+
resp
.
status
);
status
.
text
(
'Response code: '
+
resp
.
status
);
state
=
DISCONNECTED
;
return
;
return
;
}
}
...
@@ -118,6 +123,7 @@ jQuery(function($){
...
@@ -118,6 +123,7 @@ jQuery(function($){
if
(
msg
.
status
)
{
if
(
msg
.
status
)
{
console
.
log
(
msg
);
console
.
log
(
msg
);
status
.
text
(
msg
.
status
);
status
.
text
(
msg
.
status
);
state
=
DISCONNECTED
;
return
;
return
;
}
}
...
@@ -246,7 +252,7 @@ jQuery(function($){
...
@@ -246,7 +252,7 @@ jQuery(function($){
$
(
'.container'
).
hide
();
$
(
'.container'
).
hide
();
term
.
open
(
terminal
,
true
);
term
.
open
(
terminal
,
true
);
term
.
toggleFullscreen
(
true
);
term
.
toggleFullscreen
(
true
);
connected
=
true
;
state
=
CONNECTED
;
};
};
sock
.
onmessage
=
function
(
msg
)
{
sock
.
onmessage
=
function
(
msg
)
{
...
@@ -265,7 +271,7 @@ jQuery(function($){
...
@@ -265,7 +271,7 @@ jQuery(function($){
reset_wssh
();
reset_wssh
();
$
(
'.container'
).
show
();
$
(
'.container'
).
show
();
status
.
text
(
e
.
reason
);
status
.
text
(
e
.
reason
);
connected
=
false
;
state
=
DISCONNECTED
;
};
};
$
(
window
).
resize
(
function
(){
$
(
window
).
resize
(
function
(){
...
@@ -277,8 +283,8 @@ jQuery(function($){
...
@@ -277,8 +283,8 @@ jQuery(function($){
function
connect_without_options
()
{
function
connect_without_options
()
{
if
(
connected
)
{
if
(
state
!==
DISCONNECTED
)
{
console
.
log
(
'This client was already connected.'
);
console
.
log
(
messages
[
state
]
);
return
;
return
;
}
}
...
@@ -304,6 +310,8 @@ jQuery(function($){
...
@@ -304,6 +310,8 @@ jQuery(function($){
contentType
:
false
,
contentType
:
false
,
processData
:
false
processData
:
false
});
});
state
=
CONNECTING
;
}
}
if
(
!
hostname
||
!
port
||
!
username
)
{
if
(
!
hostname
||
!
port
||
!
username
)
{
...
@@ -341,8 +349,8 @@ jQuery(function($){
...
@@ -341,8 +349,8 @@ jQuery(function($){
function
connect_with_options
(
opts
)
{
function
connect_with_options
(
opts
)
{
if
(
connected
)
{
if
(
state
!==
DISCONNECTED
)
{
console
.
log
(
'This client was already connected.'
);
console
.
log
(
messages
[
state
]
);
return
;
return
;
}
}
...
@@ -390,6 +398,8 @@ jQuery(function($){
...
@@ -390,6 +398,8 @@ jQuery(function($){
data
:
data
,
data
:
data
,
complete
:
ajax_complete_callback
complete
:
ajax_complete_callback
});
});
state
=
CONNECTING
;
}
}
wssh
.
connect
=
function
(
opts
)
{
wssh
.
connect
=
function
(
opts
)
{
...
...
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