Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibreTranslate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Riße, Matthias
LibreTranslate
Commits
54f5c5ed
Unverified
Commit
54f5c5ed
authored
Feb 7, 2022
by
Sébastien Thuret
Browse files
Options
Downloads
Patches
Plain Diff
keep selected languages and text in url
parent
61a148d6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/static/js/app.js
+32
-0
32 additions, 0 deletions
app/static/js/app.js
with
32 additions
and
0 deletions
app/static/js/app.js
+
32
−
0
View file @
54f5c5ed
...
...
@@ -82,6 +82,24 @@ document.addEventListener('DOMContentLoaded', function(){
return
;
}
const
sourceLanguage
=
self
.
langs
.
find
(
l
=>
l
.
code
===
self
.
getQueryParam
(
'
source
'
))
const
isSourceAuto
=
!
sourceLanguage
&&
self
.
getQueryParam
(
'
source
'
)
===
"
auto
"
const
targetLanguage
=
self
.
langs
.
find
(
l
=>
l
.
code
===
self
.
getQueryParam
(
'
target
'
))
if
(
sourceLanguage
||
isSourceAuto
)
{
self
.
sourceLang
=
isSourceAuto
?
"
auto
"
:
sourceLanguage
.
code
}
if
(
targetLanguage
)
{
self
.
targetLang
=
targetLanguage
.
code
}
const
defaultText
=
self
.
getQueryParam
(
'
q
'
)
if
(
defaultText
)
{
self
.
inputText
=
decodeURI
(
defaultText
)
}
self
.
loading
=
false
;
}
else
{
self
.
error
=
"
Cannot load /languages
"
;
...
...
@@ -195,9 +213,23 @@ document.addEventListener('DOMContentLoaded', function(){
dismissError
:
function
(){
this
.
error
=
''
;
},
getQueryParam
:
function
(
key
)
{
const
params
=
new
URLSearchParams
(
window
.
location
.
search
);
return
params
.
get
(
key
)
},
updateQueryParam
:
function
(
key
,
value
)
{
let
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
)
searchParams
.
set
(
key
,
value
);
let
newRelativePathQuery
=
window
.
location
.
pathname
+
'
?
'
+
searchParams
.
toString
();
history
.
pushState
(
null
,
''
,
newRelativePathQuery
);
},
handleInput
:
function
(
e
){
this
.
closeSuggestTranslation
(
e
)
this
.
updateQueryParam
(
'
source
'
,
this
.
sourceLang
)
this
.
updateQueryParam
(
'
target
'
,
this
.
targetLang
)
this
.
updateQueryParam
(
'
q
'
,
encodeURI
(
this
.
inputText
))
if
(
this
.
timeout
)
clearTimeout
(
this
.
timeout
);
this
.
timeout
=
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment