Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
8b1da35e
Commit
8b1da35e
authored
6 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
The label for the langcode now isn't shown anymore if it's the default (all)
parent
3f18ab39
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/assets/js/searchbar.js
+27
-20
27 additions, 20 deletions
resources/assets/js/searchbar.js
with
27 additions
and
20 deletions
resources/assets/js/searchbar.js
+
27
−
20
View file @
8b1da35e
$
(
function
()
{
$
(
function
()
{
loadLocalStorage
();
loadLocalStorage
();
setActionListenersSearchbar
();
setActionListenersSearchbar
();
updateLangLabelCode
();
updateLangLabelCode
();
});
});
function
setActionListenersSearchbar
()
{
function
setActionListenersSearchbar
()
{
$
(
'
#input-key
'
).
change
(
saveKey
);
$
(
"
#input-key
"
).
change
(
saveKey
);
$
(
'
#input-lang
'
).
change
(
saveLang
);
$
(
"
#input-lang
"
).
change
(
saveLang
);
}
}
function
saveKey
()
{
function
saveKey
()
{
var
key
=
$
(
'
#input-key
'
).
val
();
var
key
=
$
(
"
#input-key
"
).
val
();
localStorage
.
setItem
(
'
key
'
,
key
);
localStorage
.
setItem
(
"
key
"
,
key
);
}
}
function
loadKey
()
{
function
loadKey
()
{
var
key
=
localStorage
.
getItem
(
'
key
'
);
var
key
=
localStorage
.
getItem
(
"
key
"
);
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
$
(
'
#input-key
'
).
val
(
key
);
$
(
"
#input-key
"
).
val
(
key
);
}
}
}
}
function
saveLang
()
{
function
saveLang
()
{
var
lang
=
$
(
'
#input-lang
'
).
val
();
var
lang
=
$
(
"
#input-lang
"
).
val
();
localStorage
.
setItem
(
'
lang
'
,
lang
);
if
(
lang
!=
"
all
"
)
localStorage
.
setItem
(
"
lang
"
,
lang
);
else
localStorage
.
removeItem
(
"
lang
"
);
updateLangLabelCode
(
lang
);
updateLangLabelCode
(
lang
);
}
}
function
loadLang
()
{
function
loadLang
()
{
var
lang
=
localStorage
.
getItem
(
'
lang
'
);
var
lang
=
localStorage
.
getItem
(
"
lang
"
);
if
(
lang
!=
null
)
{
if
(
lang
!=
null
)
{
$
(
'
#input-lang
'
).
val
(
lang
);
$
(
"
#input-lang
"
).
val
(
lang
);
}
}
}
}
...
@@ -46,12 +47,12 @@ function loadLocalStorage() {
...
@@ -46,12 +47,12 @@ function loadLocalStorage() {
}
}
function
setSettings
()
{
function
setSettings
()
{
var
acceptedParams
=
[
'
autocomplete
'
,
'
key
'
,
'
lang
'
,
'
newtab
'
,
'
sprueche
'
];
var
acceptedParams
=
[
"
autocomplete
"
,
"
key
"
,
"
lang
"
,
"
newtab
"
,
"
sprueche
"
];
for
(
var
key
in
localStorage
)
{
for
(
var
key
in
localStorage
)
{
var
value
=
localStorage
.
getItem
(
key
);
var
value
=
localStorage
.
getItem
(
key
);
var
accepted
=
false
;
var
accepted
=
false
;
for
(
var
i
in
acceptedParams
)
{
for
(
var
i
in
acceptedParams
)
{
if
(
key
===
'
param_
'
+
acceptedParams
[
i
])
{
if
(
key
===
"
param_
"
+
acceptedParams
[
i
])
{
accepted
=
true
;
accepted
=
true
;
}
}
}
}
...
@@ -61,20 +62,26 @@ function setSettings() {
...
@@ -61,20 +62,26 @@ function setSettings() {
var
existing
=
$
(
'
.search-hidden input[name="
'
+
key
+
'
"]
'
);
var
existing
=
$
(
'
.search-hidden input[name="
'
+
key
+
'
"]
'
);
if
(
existing
.
length
===
0
)
{
if
(
existing
.
length
===
0
)
{
// if none exist, create a new one
// if none exist, create a new one
$
(
'
.search-hidden
'
).
append
(
'
<input type="hidden" name="
'
+
key
+
'
" value="
'
+
value
+
'
">
'
);
$
(
"
.search-hidden
"
).
append
(
'
<input type="hidden" name="
'
+
key
+
'
" value="
'
+
value
+
'
">
'
);
}
}
}
}
}
}
// Change the request method to the given parameter
// Change the request method to the given parameter
var
requestMethod
=
localStorage
.
getItem
(
'
request
'
);
var
requestMethod
=
localStorage
.
getItem
(
"
request
"
);
if
(
requestMethod
!==
null
&&
(
requestMethod
===
'
GET
'
||
requestMethod
===
'
POST
'
))
{
if
(
$
(
'
#searchForm
'
).
attr
(
'
method
'
,
requestMethod
);
requestMethod
!==
null
&&
(
requestMethod
===
"
GET
"
||
requestMethod
===
"
POST
"
)
)
{
$
(
"
#searchForm
"
).
attr
(
"
method
"
,
requestMethod
);
}
}
}
}
function
updateLangLabelCode
(
langcode
=
null
)
{
function
updateLangLabelCode
(
langcode
=
null
)
{
if
(
!
langcode
)
{
if
(
!
langcode
)
{
var
langcode
=
localStorage
.
getItem
(
'
lang
'
);
var
langcode
=
localStorage
.
getItem
(
"
lang
"
);
}
}
$
(
'
#lang-label-code
'
).
html
(
langcode
);
if
(
langcode
==
"
all
"
)
langcode
=
""
;
}
$
(
"
#lang-label-code
"
).
html
(
langcode
);
\ No newline at end of file
}
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