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
Show 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($){
join
=
(
ws_url
[
ws_url
.
length
-
1
]
===
'/'
?
''
:
'/'
),
url
=
ws_url
+
join
+
'ws?id='
+
msg
.
id
,
sock
=
new
window
.
WebSocket
(
url
),
encoding
=
msg
.
encoding
,
encoding
,
decoder
,
terminal
=
document
.
getElementById
(
'#terminal'
),
term
=
new
window
.
Terminal
({
cursorBlink
:
true
,
});
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.term = term;
var
test_decoder
;
function
resize_terminal
(
term
)
{
var
geometry
=
current_geometry
();
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
()
{
// for console use
var
geometry
=
current_geometry
();
...
...
@@ -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
()
{
// for console use
if
(
encoding
===
msg
.
encoding
)
{
console
.
log
(
'Already reset to '
+
msg
.
encoding
);
}
else
{
encoding
=
msg
.
encoding
;
console
.
log
(
'Reset encoding to '
+
msg
.
encoding
);
set_encoding
(
msg
.
encoding
);
}
};
...
...
@@ -216,7 +214,6 @@ jQuery(function($){
var
reader
=
new
window
.
FileReader
();
reader
.
onloadend
=
function
(){
var
decoder
=
new
window
.
TextDecoder
(
encoding
);
var
text
=
decoder
.
decode
(
reader
.
result
);
// console.log(text);
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