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
4c3120e5
Commit
4c3120e5
authored
Aug 23, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse decoder
parent
24a619ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
26 deletions
+23
-26
main.js
webssh/static/js/main.js
+23
-26
No files found.
webssh/static/js/main.js
View file @
4c3120e5
...
@@ -96,23 +96,42 @@ jQuery(function($){
...
@@ -96,23 +96,42 @@ jQuery(function($){
join
=
(
ws_url
[
ws_url
.
length
-
1
]
===
'/'
?
''
:
'/'
),
join
=
(
ws_url
[
ws_url
.
length
-
1
]
===
'/'
?
''
:
'/'
),
url
=
ws_url
+
join
+
'ws?id='
+
msg
.
id
,
url
=
ws_url
+
join
+
'ws?id='
+
msg
.
id
,
sock
=
new
window
.
WebSocket
(
url
),
sock
=
new
window
.
WebSocket
(
url
),
encoding
=
msg
.
encoding
,
encoding
,
decoder
,
terminal
=
document
.
getElementById
(
'#terminal'
),
terminal
=
document
.
getElementById
(
'#terminal'
),
term
=
new
window
.
Terminal
({
term
=
new
window
.
Terminal
({
cursorBlink
:
true
,
cursorBlink
:
true
,
});
});
console
.
log
(
url
);
console
.
log
(
url
);
console
.
log
(
'The deault encoding of your server is '
+
encoding
);
console
.
log
(
'The deault encoding of your server is '
+
msg
.
encoding
);
// wssh.sock = sock;
// wssh.sock = sock;
// wssh.term = term;
// wssh.term = term;
var
test_decoder
;
function
resize_terminal
(
term
)
{
function
resize_terminal
(
term
)
{
var
geometry
=
current_geometry
();
var
geometry
=
current_geometry
();
term
.
on_resize
(
geometry
.
cols
,
geometry
.
rows
);
term
.
on_resize
(
geometry
.
cols
,
geometry
.
rows
);
}
}
function
set_encoding
(
new_encoding
)
{
// for console use
if
(
new_encoding
===
undefined
)
{
console
.
log
(
'An encoding is required'
);
return
;
}
try
{
decoder
=
new
window
.
TextDecoder
(
new_encoding
);
encoding
=
new_encoding
;
console
.
log
(
'Set encoding to '
+
encoding
);
}
catch
(
TypeError
)
{
console
.
log
(
'Unknown encoding '
+
new_encoding
);
}
}
wssh
.
set_encoding
=
set_encoding
;
set_encoding
(
msg
.
encoding
);
wssh
.
window_geometry
=
function
()
{
wssh
.
window_geometry
=
function
()
{
// for console use
// for console use
var
geometry
=
current_geometry
();
var
geometry
=
current_geometry
();
...
@@ -139,33 +158,12 @@ jQuery(function($){
...
@@ -139,33 +158,12 @@ jQuery(function($){
}
}
};
};
wssh
.
set_encoding
=
function
(
new_encoding
)
{
// for console use
if
(
new_encoding
===
undefined
)
{
console
.
log
(
'An encoding is required'
);
return
;
}
try
{
test_decoder
=
new
window
.
TextDecoder
(
new_encoding
);
}
catch
(
TypeError
)
{
console
.
log
(
'Unknown encoding '
+
new_encoding
);
}
finally
{
if
(
test_decoder
!==
undefined
)
{
test_decoder
=
undefined
;
encoding
=
new_encoding
;
console
.
log
(
'Set encoding to '
+
encoding
);
}
}
};
wssh
.
reset_encoding
=
function
()
{
wssh
.
reset_encoding
=
function
()
{
// for console use
// for console use
if
(
encoding
===
msg
.
encoding
)
{
if
(
encoding
===
msg
.
encoding
)
{
console
.
log
(
'Already reset to '
+
msg
.
encoding
);
console
.
log
(
'Already reset to '
+
msg
.
encoding
);
}
else
{
}
else
{
encoding
=
msg
.
encoding
;
set_encoding
(
msg
.
encoding
);
console
.
log
(
'Reset encoding to '
+
msg
.
encoding
);
}
}
};
};
...
@@ -216,7 +214,6 @@ jQuery(function($){
...
@@ -216,7 +214,6 @@ jQuery(function($){
var
reader
=
new
window
.
FileReader
();
var
reader
=
new
window
.
FileReader
();
reader
.
onloadend
=
function
(){
reader
.
onloadend
=
function
(){
var
decoder
=
new
window
.
TextDecoder
(
encoding
);
var
text
=
decoder
.
decode
(
reader
.
result
);
var
text
=
decoder
.
decode
(
reader
.
result
);
// console.log(text);
// console.log(text);
if
(
term
)
{
if
(
term
)
{
...
...
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