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
5d1d5e92
Commit
5d1d5e92
authored
Sep 13, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support browser edge
parent
2b571229
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
2 deletions
+69
-2
main.js
webssh/static/js/main.js
+69
-2
No files found.
webssh/static/js/main.js
View file @
5d1d5e92
...
@@ -4,6 +4,37 @@ var jQuery;
...
@@ -4,6 +4,37 @@ var jQuery;
var
wssh
=
{};
var
wssh
=
{};
(
function
()
{
// For FormData without getter and setter
var
proto
=
FormData
.
prototype
;
proto
.
data
=
{};
if
(
!
proto
.
get
)
{
proto
.
get
=
function
(
name
)
{
if
(
!
proto
.
data
[
name
])
{
var
input
=
document
.
querySelector
(
'input[name="'
+
name
+
'"]'
),
value
;
if
(
input
)
{
if
(
input
.
type
===
'file'
)
{
value
=
input
.
files
[
0
];
}
else
{
value
=
input
.
value
;
}
proto
.
data
[
name
]
=
value
;
}
}
return
proto
.
data
[
name
];
};
}
if
(
!
proto
.
set
)
{
proto
.
set
=
function
(
name
,
value
)
{
proto
.
data
[
name
]
=
value
;
};
}
}());
jQuery
(
function
(
$
){
jQuery
(
function
(
$
){
var
status
=
$
(
'#status'
),
var
status
=
$
(
'#status'
),
btn
=
$
(
'.btn-primary'
),
btn
=
$
(
'.btn-primary'
),
...
@@ -73,7 +104,7 @@ jQuery(function($){
...
@@ -73,7 +104,7 @@ jQuery(function($){
}
}
function
read_
file_as_text
(
file
,
callback
,
decoder
)
{
function
read_
as_text_with_decoder
(
file
,
callback
,
decoder
)
{
var
reader
=
new
window
.
FileReader
();
var
reader
=
new
window
.
FileReader
();
if
(
decoder
===
undefined
)
{
if
(
decoder
===
undefined
)
{
...
@@ -101,6 +132,36 @@ jQuery(function($){
...
@@ -101,6 +132,36 @@ jQuery(function($){
}
}
function
read_as_text_with_encoding
(
file
,
callback
,
encoding
)
{
var
reader
=
new
window
.
FileReader
();
if
(
encoding
===
undefined
)
{
encoding
=
'utf-8'
;
}
reader
.
onload
=
function
()
{
if
(
callback
)
{
callback
(
reader
.
result
);
}
};
reader
.
onerror
=
function
(
e
)
{
console
.
error
(
e
);
};
reader
.
readAsText
(
file
,
encoding
);
}
function
read_file_as_text
(
file
,
callback
,
decoder
)
{
if
(
!
window
.
TextDecoder
)
{
read_as_text_with_encoding
(
file
,
callback
,
decoder
);
}
else
{
read_as_text_with_decoder
(
file
,
callback
,
decoder
);
}
}
function
reset_wssh
()
{
function
reset_wssh
()
{
var
name
;
var
name
;
...
@@ -139,7 +200,7 @@ jQuery(function($){
...
@@ -139,7 +200,7 @@ jQuery(function($){
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
=
'utf-8'
,
encoding
=
'utf-8'
,
decoder
=
new
window
.
TextDecoder
(
'utf-8'
)
,
decoder
=
window
.
TextDecoder
?
new
window
.
TextDecoder
(
encoding
)
:
encoding
,
terminal
=
document
.
getElementById
(
'#terminal'
),
terminal
=
document
.
getElementById
(
'#terminal'
),
term
=
new
window
.
Terminal
({
term
=
new
window
.
Terminal
({
cursorBlink
:
true
,
cursorBlink
:
true
,
...
@@ -175,6 +236,11 @@ jQuery(function($){
...
@@ -175,6 +236,11 @@ jQuery(function($){
return
;
return
;
}
}
if
(
!
window
.
TextDecoder
)
{
decoder
=
new_encoding
;
encoding
=
decoder
;
console
.
log
(
'Set encoding to '
+
encoding
);
}
else
{
try
{
try
{
decoder
=
new
window
.
TextDecoder
(
new_encoding
);
decoder
=
new
window
.
TextDecoder
(
new_encoding
);
encoding
=
decoder
.
encoding
;
encoding
=
decoder
.
encoding
;
...
@@ -183,6 +249,7 @@ jQuery(function($){
...
@@ -183,6 +249,7 @@ jQuery(function($){
console
.
log
(
'Unknown encoding '
+
new_encoding
);
console
.
log
(
'Unknown encoding '
+
new_encoding
);
}
}
}
}
}
wssh
.
set_encoding
=
set_encoding
;
wssh
.
set_encoding
=
set_encoding
;
set_encoding
(
msg
.
encoding
);
set_encoding
(
msg
.
encoding
);
...
...
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