Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
0057ad44
Commit
0057ad44
authored
Nov 14, 2017
by
Karl Hasselbring
Browse files
Fixed: Eigene Foki funktionieren jetzt wieder in der Suche
parent
4a1e633a
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
0057ad44
...
...
@@ -18,10 +18,11 @@ class MetaGerSearch extends Controller
return
redirect
()
->
to
(
'https://maps.metager.de/map/'
.
$searchinput
.
'/1240908.5493525574,6638783.2192695495,6'
);
}
if
(
$focus
!==
"angepasst"
&&
$this
->
startsWith
(
$focus
,
"focus_"
))
{
/*
if ($focus !== "angepasst" && $this->startsWith($focus, "focus_")) {
$metager->parseFormData($request);
return $metager->createView();
}
}*/
#die($request->header('User-Agent'));
$time
=
microtime
();
# Mit gelieferte Formulardaten parsen und abspeichern:
...
...
app/MetaGer.php
View file @
0057ad44
...
...
@@ -481,6 +481,8 @@ class MetaGer
$overtureEnabled
=
false
;
$sumaCount
=
0
;
$isCustomSearch
=
strpos
(
$this
->
fokus
,
'focus_'
)
==
0
;
/* Erstellt die Liste der eingestellten Sumas
* Der einzige Unterschied bei angepasstem Suchfokus ist,
* dass nicht nach den Typen einer Suma,
...
...
@@ -492,7 +494,7 @@ class MetaGer
* Zu Liste hinzufügen
*/
foreach
(
$sumas
as
$suma
)
{
if
((
$this
->
sumaIsSelected
(
$suma
,
$request
)
if
((
$this
->
sumaIsSelected
(
$suma
,
$request
,
$isCustomSearch
)
||
(
!
$this
->
isBildersuche
()
&&
$this
->
sumaIsAdsuche
(
$suma
,
$overtureEnabled
)))
&&
(
!
$this
->
sumaIsDisabled
(
$suma
)))
{
...
...
@@ -593,10 +595,10 @@ class MetaGer
# Spezielle Suchen und Sumas
public
function
sumaIsSelected
(
$suma
,
$request
)
public
function
sumaIsSelected
(
$suma
,
$request
,
$custom
)
{
if
(
$
this
->
fokus
===
"angepasst"
)
{
if
(
$request
->
has
(
$suma
[
"name"
]))
{
if
(
$
custom
)
{
if
(
$request
->
has
(
"engine_"
.
$suma
[
"name"
]))
{
return
true
;
}
}
else
{
...
...
public/js/searchbar.js
View file @
0057ad44
...
...
@@ -2,14 +2,14 @@ $(function () {
loadLocalStorage
();
setSearchbarActionListeners
();
loadInitialCustomFocuses
();
checkFocusEditable
();
loadSelectedFocus
();
loadInitialSelectedFocus
();
focusChanged
();
});
/**
* Loads the user theme and stored settings from local storage
*/
function
loadLocalStorage
()
{
function
loadLocalStorage
()
{
if
(
localStorage
)
{
setSettings
();
}
...
...
@@ -18,13 +18,13 @@ function loadLocalStorage () {
/**
* Sets all action listeners for this page
*/
function
setSearchbarActionListeners
()
{
function
setSearchbarActionListeners
()
{
$
(
'
.focusCheckbox
'
).
click
(
toggleDeleteButton
);
$
(
'
#addFocusBtn
'
).
click
(()
=>
showFocusCreateDialog
(
''
));
$
(
'
#editFocusBtn
'
).
click
(
editCurrentFocus
);
$
(
'
.save-focus-btn
'
).
click
(
saveFocus
);
$
(
'
.delete-focus-btn
'
).
click
(
deleteFocus
);
$
(
'
#focus-select
'
).
change
(
checkFocusEditable
);
$
(
'
#focus-select
'
).
change
(
focusChanged
);
// Save Focus on clicking enter while in the focus name input
$
(
'
#focus-name
'
).
keyup
(
function
(
event
)
{
if
(
event
.
keyCode
==
13
)
{
...
...
@@ -36,7 +36,7 @@ function setSearchbarActionListeners () {
});
}
function
setSettings
()
{
function
setSettings
()
{
var
acceptedParams
=
[
'
autocomplete
'
,
'
key
'
,
'
lang
'
,
'
newtab
'
,
'
sprueche
'
];
for
(
var
key
in
localStorage
)
{
var
value
=
localStorage
.
getItem
(
key
);
...
...
@@ -66,7 +66,7 @@ function setSettings () {
/**
* Loads all the custom focuses stored in local storage
*/
function
loadInitialCustomFocuses
()
{
function
loadInitialCustomFocuses
()
{
for
(
var
key
in
localStorage
)
{
if
(
key
.
startsWith
(
'
focus_
'
))
{
var
focus
=
loadFocusById
(
key
);
...
...
@@ -75,11 +75,15 @@ function loadInitialCustomFocuses () {
}
}
function
loadInitialSelectedFocus
()
{
setFocus
(
getFocusInUrl
());
}
/**
* Shows the focus create dialog
* If an id is given it will try to load a focus for the given id
*/
function
showFocusCreateDialog
(
id
)
{
function
showFocusCreateDialog
(
id
)
{
if
(
id
===
undefined
)
{
id
=
''
;
}
...
...
@@ -109,28 +113,26 @@ function showFocusCreateDialog (id) {
/**
* Shows the focus create dialog for a given id
*/
function
showFocusEditDialog
(
id
)
{
function
showFocusEditDialog
(
id
)
{
showFocusCreateDialog
(
id
);
}
function
getCurrentFocus
()
{
function
getCurrentFocus
()
{
return
document
.
getElementById
(
'
focus-select
'
).
value
;
}
/**
* Shows an edit dialog for the current selected focus
*/
function
editCurrentFocus
()
{
console
.
log
(
'
hi
'
);
function
editCurrentFocus
()
{
var
currentFocus
=
getCurrentFocus
();
console
.
log
(
currentFocus
);
showFocusEditDialog
(
currentFocus
);
}
/**
* Shows/Hides the delete button if (no) checkboxes are selected
*/
function
toggleDeleteButton
()
{
* Shows/Hides the delete button if (no) checkboxes are selected
*/
function
toggleDeleteButton
()
{
if
(
atLeastOneChecked
())
{
$
(
'
.delete-focus-btn
'
).
show
();
}
else
{
...
...
@@ -142,7 +144,7 @@ function toggleDeleteButton () {
* Save the current Focus
* Listens for save button
*/
function
saveFocus
()
{
function
saveFocus
()
{
/* Vorprüfungen */
// Falls keine Suchmaschine ausgewählt wurde
if
(
!
atLeastOneChecked
())
{
...
...
@@ -214,7 +216,7 @@ function saveFocus () {
* Delete current Focus
* Listens for delete button
*/
function
deleteFocusById
(
id
)
{
function
deleteFocusById
(
id
)
{
localStorage
.
removeItem
(
id
);
removeFocusById
(
id
);
$
(
'
#focus-select
'
).
change
();
...
...
@@ -224,7 +226,7 @@ function deleteFocusById (id) {
* Delete current Focus
* Listens for delete button
*/
function
deleteFocus
()
{
function
deleteFocus
()
{
var
oldId
=
document
.
getElementById
(
'
original-id
'
).
value
;
deleteFocusById
(
oldId
);
$
(
'
#create-focus-modal
'
).
modal
(
'
hide
'
);
...
...
@@ -234,7 +236,7 @@ function deleteFocus () {
/**
* Is the name valid (in terms of characters)?
*/
function
isValidName
(
name
)
{
function
isValidName
(
name
)
{
// no Characters other then a-z, A-Z, 0-9, ä, ö, ü, ß, -, _ allowed
// at least 1 character
return
/^
[
a-zA-Z0-9äöüß
\-
_
]
+$/
.
test
(
name
);
...
...
@@ -243,21 +245,21 @@ function isValidName (name) {
/**
* Is at least one focus selected?
*/
function
atLeastOneChecked
()
{
function
atLeastOneChecked
()
{
return
$
(
'
.focusCheckbox:checked
'
).
length
>
0
;
}
/**
* Is there already a focus with this name?
*/
function
alreadyInUse
(
name
)
{
function
alreadyInUse
(
name
)
{
return
localStorage
.
hasOwnProperty
(
getIdFromName
(
name
));
}
/**
* Adds an option to the focus selector
*/
function
addFocus
(
name
)
{
function
addFocus
(
name
)
{
var
id
=
getIdFromName
(
name
);
$
(
'
#focus-select
'
).
append
(
'
<option value="
'
+
id
+
'
" style="font-family: FontAwesome, sans-serif;">
'
+
name
+
'
</option>
'
);
}
...
...
@@ -265,14 +267,14 @@ function addFocus (name) {
/**
* Remove the focuses html-elements
*/
function
removeFocus
(
name
)
{
function
removeFocus
(
name
)
{
removeFocusById
(
getIdFromName
(
name
));
}
/**
* Remove the focuses html-elements
*/
function
removeFocusById
(
id
)
{
function
removeFocusById
(
id
)
{
if
(
id
==
''
)
{
return
;
}
...
...
@@ -283,7 +285,7 @@ function removeFocusById (id) {
* Turns a name into an id
* Converts special characters and spaces
*/
function
getIdFromName
(
name
)
{
function
getIdFromName
(
name
)
{
name
=
name
.
toLowerCase
();
name
=
name
.
split
(
'
'
).
join
(
'
_
'
);
name
=
name
.
split
(
'
ä
'
).
join
(
'
ae
'
);
...
...
@@ -295,21 +297,21 @@ function getIdFromName (name) {
/**
* Loads the focus object for the given id from local storage
*/
function
loadFocusById
(
id
)
{
function
loadFocusById
(
id
)
{
return
JSON
.
parse
(
localStorage
.
getItem
(
id
));
}
/**
* Unchecks all focuses from the focus creator dialog
*/
function
uncheckAll
()
{
function
uncheckAll
()
{
$
(
'
.focusCheckbox
'
).
prop
(
'
checked
'
,
false
);
}
/**
* Sets the selected focus to default
*/
function
setFocusToDefault
()
{
function
setFocusToDefault
()
{
setFocus
(
DEFAULT_FOCUS
);
}
...
...
@@ -317,33 +319,60 @@ function setFocusToDefault () {
* Sets the selected focus
* @param {String} focusID The id of the focus, without #
*/
function
setFocus
(
focusID
)
{
function
setFocus
(
focusID
)
{
$
(
'
#focus-select option[value="
'
+
focusID
+
'
"]
'
).
prop
(
'
selected
'
,
true
);
$
(
'
#focus-select
'
).
change
();
}
function
checkFocusEditable
()
{
if
(
getCurrentFocus
().
startsWith
(
'
focus_
'
))
{
function
focusChanged
()
{
var
selectedFocus
=
getCurrentFocus
();
if
(
focusIsEditable
(
selectedFocus
))
{
enableEditFocusBtn
();
}
else
{
disableEditFocusBtn
();
}
loadFocusForSearch
(
selectedFocus
);
}
function
focusIsEditable
(
focus
)
{
if
(
focus
.
startsWith
(
'
focus_
'
))
{
return
true
}
else
{
return
false
}
}
function
enableEditFocusBtn
()
{
function
enableEditFocusBtn
()
{
$
(
'
#editFocusBtn
'
).
removeClass
(
'
disabled
'
).
click
(
editCurrentFocus
);
}
function
disableEditFocusBtn
()
{
function
disableEditFocusBtn
()
{
$
(
'
#editFocusBtn
'
).
addClass
(
'
disabled
'
).
off
(
'
click
'
);
}
function
loadSelectedFocus
()
{
var
url
=
window
.
location
;
var
focus
=
/focus=
(
focus_
\w
+
)
/
.
exec
(
url
)[
1
];
if
(
focus
)
{
setFocus
(
focus
);
function
loadFocusForSearch
(
focus
)
{
var
focus
=
loadFocusById
(
focus
);
clearCustomSearch
();
for
(
var
key
in
focus
)
{
if
(
key
.
startsWith
(
"
engine_
"
)
&&
focus
[
key
]
==
'
on
'
)
{
addSumaToCustomSearch
(
key
);
}
}
}
function
clearCustomSearch
()
{
$
(
'
.custom-search-hidden
'
).
empty
();
}
function
addSumaToCustomSearch
(
sumaId
)
{
$
(
'
.custom-search-hidden
'
).
append
(
'
<input type="hidden" name="
'
+
sumaId
+
'
" value="on">
'
);
}
function
getFocusInUrl
()
{
var
url
=
window
.
location
;
var
focReg
=
/focus=
(
focus_
\w
+
)
/
.
exec
(
url
);
if
(
focReg
&&
focReg
[
1
])
{
return
focReg
[
1
];
}
}
//# sourceMappingURL=searchbar.js.map
resources/assets/js/searchbar.js
View file @
0057ad44
...
...
@@ -2,14 +2,14 @@ $(function () {
loadLocalStorage
();
setSearchbarActionListeners
();
loadInitialCustomFocuses
();
checkFocusEditable
();
loadSelectedFocus
();
loadInitialSelectedFocus
();
focusChanged
();
});
/**
* Loads the user theme and stored settings from local storage
*/
function
loadLocalStorage
()
{
function
loadLocalStorage
()
{
if
(
localStorage
)
{
setSettings
();
}
...
...
@@ -18,13 +18,13 @@ function loadLocalStorage () {
/**
* Sets all action listeners for this page
*/
function
setSearchbarActionListeners
()
{
function
setSearchbarActionListeners
()
{
$
(
'
.focusCheckbox
'
).
click
(
toggleDeleteButton
);
$
(
'
#addFocusBtn
'
).
click
(()
=>
showFocusCreateDialog
(
''
));
$
(
'
#editFocusBtn
'
).
click
(
editCurrentFocus
);
$
(
'
.save-focus-btn
'
).
click
(
saveFocus
);
$
(
'
.delete-focus-btn
'
).
click
(
deleteFocus
);
$
(
'
#focus-select
'
).
change
(
checkFocusEditable
);
$
(
'
#focus-select
'
).
change
(
focusChanged
);
// Save Focus on clicking enter while in the focus name input
$
(
'
#focus-name
'
).
keyup
(
function
(
event
)
{
if
(
event
.
keyCode
==
13
)
{
...
...
@@ -36,7 +36,7 @@ function setSearchbarActionListeners () {
});
}
function
setSettings
()
{
function
setSettings
()
{
var
acceptedParams
=
[
'
autocomplete
'
,
'
key
'
,
'
lang
'
,
'
newtab
'
,
'
sprueche
'
];
for
(
var
key
in
localStorage
)
{
var
value
=
localStorage
.
getItem
(
key
);
...
...
@@ -66,7 +66,7 @@ function setSettings () {
/**
* Loads all the custom focuses stored in local storage
*/
function
loadInitialCustomFocuses
()
{
function
loadInitialCustomFocuses
()
{
for
(
var
key
in
localStorage
)
{
if
(
key
.
startsWith
(
'
focus_
'
))
{
var
focus
=
loadFocusById
(
key
);
...
...
@@ -75,11 +75,15 @@ function loadInitialCustomFocuses () {
}
}
function
loadInitialSelectedFocus
()
{
setFocus
(
getFocusInUrl
());
}
/**
* Shows the focus create dialog
* If an id is given it will try to load a focus for the given id
*/
function
showFocusCreateDialog
(
id
)
{
function
showFocusCreateDialog
(
id
)
{
if
(
id
===
undefined
)
{
id
=
''
;
}
...
...
@@ -109,28 +113,26 @@ function showFocusCreateDialog (id) {
/**
* Shows the focus create dialog for a given id
*/
function
showFocusEditDialog
(
id
)
{
function
showFocusEditDialog
(
id
)
{
showFocusCreateDialog
(
id
);
}
function
getCurrentFocus
()
{
function
getCurrentFocus
()
{
return
document
.
getElementById
(
'
focus-select
'
).
value
;
}
/**
* Shows an edit dialog for the current selected focus
*/
function
editCurrentFocus
()
{
console
.
log
(
'
hi
'
);
function
editCurrentFocus
()
{
var
currentFocus
=
getCurrentFocus
();
console
.
log
(
currentFocus
);
showFocusEditDialog
(
currentFocus
);
}
/**
* Shows/Hides the delete button if (no) checkboxes are selected
*/
function
toggleDeleteButton
()
{
* Shows/Hides the delete button if (no) checkboxes are selected
*/
function
toggleDeleteButton
()
{
if
(
atLeastOneChecked
())
{
$
(
'
.delete-focus-btn
'
).
show
();
}
else
{
...
...
@@ -142,7 +144,7 @@ function toggleDeleteButton () {
* Save the current Focus
* Listens for save button
*/
function
saveFocus
()
{
function
saveFocus
()
{
/* Vorprüfungen */
// Falls keine Suchmaschine ausgewählt wurde
if
(
!
atLeastOneChecked
())
{
...
...
@@ -214,7 +216,7 @@ function saveFocus () {
* Delete current Focus
* Listens for delete button
*/
function
deleteFocusById
(
id
)
{
function
deleteFocusById
(
id
)
{
localStorage
.
removeItem
(
id
);
removeFocusById
(
id
);
$
(
'
#focus-select
'
).
change
();
...
...
@@ -224,7 +226,7 @@ function deleteFocusById (id) {
* Delete current Focus
* Listens for delete button
*/
function
deleteFocus
()
{
function
deleteFocus
()
{
var
oldId
=
document
.
getElementById
(
'
original-id
'
).
value
;
deleteFocusById
(
oldId
);
$
(
'
#create-focus-modal
'
).
modal
(
'
hide
'
);
...
...
@@ -234,7 +236,7 @@ function deleteFocus () {
/**
* Is the name valid (in terms of characters)?
*/
function
isValidName
(
name
)
{
function
isValidName
(
name
)
{
// no Characters other then a-z, A-Z, 0-9, ä, ö, ü, ß, -, _ allowed
// at least 1 character
return
/^
[
a-zA-Z0-9äöüß
\-
_
]
+$/
.
test
(
name
);
...
...
@@ -243,21 +245,21 @@ function isValidName (name) {
/**
* Is at least one focus selected?
*/
function
atLeastOneChecked
()
{
function
atLeastOneChecked
()
{
return
$
(
'
.focusCheckbox:checked
'
).
length
>
0
;
}
/**
* Is there already a focus with this name?
*/
function
alreadyInUse
(
name
)
{
function
alreadyInUse
(
name
)
{
return
localStorage
.
hasOwnProperty
(
getIdFromName
(
name
));
}
/**
* Adds an option to the focus selector
*/
function
addFocus
(
name
)
{
function
addFocus
(
name
)
{
var
id
=
getIdFromName
(
name
);
$
(
'
#focus-select
'
).
append
(
'
<option value="
'
+
id
+
'
" style="font-family: FontAwesome, sans-serif;">
'
+
name
+
'
</option>
'
);
}
...
...
@@ -265,14 +267,14 @@ function addFocus (name) {
/**
* Remove the focuses html-elements
*/
function
removeFocus
(
name
)
{
function
removeFocus
(
name
)
{
removeFocusById
(
getIdFromName
(
name
));
}
/**
* Remove the focuses html-elements
*/
function
removeFocusById
(
id
)
{
function
removeFocusById
(
id
)
{
if
(
id
==
''
)
{
return
;
}
...
...
@@ -283,7 +285,7 @@ function removeFocusById (id) {
* Turns a name into an id
* Converts special characters and spaces
*/
function
getIdFromName
(
name
)
{
function
getIdFromName
(
name
)
{
name
=
name
.
toLowerCase
();
name
=
name
.
split
(
'
'
).
join
(
'
_
'
);
name
=
name
.
split
(
'
ä
'
).
join
(
'
ae
'
);
...
...
@@ -295,21 +297,21 @@ function getIdFromName (name) {
/**
* Loads the focus object for the given id from local storage
*/
function
loadFocusById
(
id
)
{
function
loadFocusById
(
id
)
{
return
JSON
.
parse
(
localStorage
.
getItem
(
id
));
}
/**
* Unchecks all focuses from the focus creator dialog
*/
function
uncheckAll
()
{
function
uncheckAll
()
{
$
(
'
.focusCheckbox
'
).
prop
(
'
checked
'
,
false
);
}
/**
* Sets the selected focus to default
*/
function
setFocusToDefault
()
{
function
setFocusToDefault
()
{
setFocus
(
DEFAULT_FOCUS
);
}
...
...
@@ -317,31 +319,59 @@ function setFocusToDefault () {
* Sets the selected focus
* @param {String} focusID The id of the focus, without #
*/
function
setFocus
(
focusID
)
{
function
setFocus
(
focusID
)
{
$
(
'
#focus-select option[value="
'
+
focusID
+
'
"]
'
).
prop
(
'
selected
'
,
true
);
$
(
'
#focus-select
'
).
change
();
}
function
checkFocusEditable
()
{
if
(
getCurrentFocus
().
startsWith
(
'
focus_
'
))
{
function
focusChanged
()
{
var
selectedFocus
=
getCurrentFocus
();
if
(
focusIsEditable
(
selectedFocus
))
{
enableEditFocusBtn
();
}
else
{
disableEditFocusBtn
();
}
loadFocusForSearch
(
selectedFocus
);
}
function
focusIsEditable
(
focus
)
{
if
(
focus
.
startsWith
(
'
focus_
'
))
{
return
true
}
else
{
return
false
}
}
function
enableEditFocusBtn
()
{
function
enableEditFocusBtn
()
{
$
(
'
#editFocusBtn
'
).
removeClass
(
'
disabled
'
).
click
(
editCurrentFocus
);
}
function
disableEditFocusBtn
()
{
function
disableEditFocusBtn
()
{
$
(
'
#editFocusBtn
'
).
addClass
(
'
disabled
'
).
off
(
'
click
'
);
}
function
loadSelectedFocus
()
{
var
url
=
window
.
location
;
var
focus
=
/focus=
(
focus_
\w
+
)
/
.
exec
(
url
)[
1
];
if
(
focus
)
{
setFocus
(
focus
);
function
loadFocusForSearch
(
focus
)
{
var
focus
=
loadFocusById
(
focus
);
clearCustomSearch
();
for
(
var
key
in
focus
)
{
if
(
key
.
startsWith
(
"
engine_
"
)
&&
focus
[
key
]
==
'
on
'
)
{
addSumaToCustomSearch
(
key
);
}
}
}
function
clearCustomSearch
()
{
$
(
'
.custom-search-hidden
'
).
empty
();
}
function
addSumaToCustomSearch
(
sumaId
)
{
$
(
'
.custom-search-hidden
'
).
append
(
'
<input type="hidden" name="
'
+
sumaId
+
'
" value="on">
'
);
}
function
getFocusInUrl
()
{
var
url
=
window
.
location
;
var
focReg
=
/focus=
(
focus_
\w
+
)
/
.
exec
(
url
);
if
(
focReg
&&
focReg
[
1
])
{
return
focReg
[
1
];
}
}
\ No newline at end of file
resources/assets/less/metager/searchbar.less
View file @
0057ad44
...
...
@@ -139,11 +139,6 @@
.resultpage-searchbar {
margin: 5px 0px 0px 5px;
border-left: #bbb solid 1px;
>* {
border-left: 1px solid #aaa;
background-color: transparent;
}
:first-child {
border-left: none;
}
...
...
resources/views/layouts/researchandtabs.blade.php
View file @
0057ad44
...
...
@@ -18,26 +18,11 @@
</
div
>
<
div
id
=
"header-searchbar"
>
@
include
(
'parts.searchbar'
,
[
'class'
=>
'resultpage-searchbar'
,
'request'
=>
Request
::
method
()])
<!--
<
form
method
=
"{{ Request::method() }}"
accept
-
charset
=
"UTF-8"
class
=
"form search-bar-input"
id
=
"submitForm"
>
<
div
class
=
"searchbar"
>
<
input
autocomplete
=
"off"
class
=
"form-control search-input"
form
=
"submitForm"
id
=