Commit 609b75db authored by Karl Hasselbring's avatar Karl Hasselbring
Browse files

Fixed: LocalStorage ergänzt jetzt gespeicherte Get-Parameter wenn nicht gesetzt

parent b404b70e
......@@ -22,8 +22,23 @@ class StartpageController extends Controller
$focusPages = [];
$theme = "default";
$optionParams = ['param_sprueche', 'param_newtab', 'param_maps', 'param_autocomplete', 'param_lang', 'param_key'];
$option_values = [];
foreach ($optionParams as $param) {
$value = $request->input($param);
if ($value) {
$option_values[$param] = $value;
}
}
$autocomplete = 'on';
if(in_array('autocomplete', array_keys($option_values))) {
$autocomplete = $option_values['autocomplete'];
}
foreach ($request->all() as $key => $value) {
if ($value === 'on' && $key != 'param_sprueche' && $key != 'param_newtab' && $key !== 'param_maps' && $key !== 'param_autocomplete' && $key !== 'param_lang') {
if ($value === 'on' && !in_array($key, $optionParams)) {
$focusPages[] = str_replace('param_', '', $key);
}
if ($key === 'param_theme') {
......@@ -43,16 +58,12 @@ class StartpageController extends Controller
->with('browser', (new Agent())->browser())
->with('navbarFocus', 'suche')
->with('theme', $theme)
->with('autocomplete', $request->input('param_autocomplete', 'on'))
->with('foki', $this->loadFoki())
->with('focus', $request->input('focus', 'web'))
->with('lang', $request->input('param_lang', $lang))
->with('resultCount', $request->input('param_resultCount', '20'))
->with('time', $request->input('param_time', '1500'))
->with('sprueche', $request->input('param_sprueche', 'on'))
->with('newtab', $request->input('param_newtab', 'on'))
->with('maps', $maps = $request->input('param_maps', 'off'))
->with('key', $request->input('param_key', ''));
->with('request', $request->input('request', 'GET'))
->with('option_values', $option_values)
->with('autocomplete', $autocomplete);
}
public function loadPage($subpage)
......
......@@ -28,9 +28,7 @@ function loadLocalStorage () {
$('#theme').attr('href', '/css/theme.css.php?r=' + theme[0] + '&g=' + theme[1] + '&b=' + theme[2] + '&a=' + theme[3]);
}
}
if (localStorage.getItem('pers') && !isUseOnce()) {
setSettings();
}
setSettings();
}
}
......@@ -79,9 +77,9 @@ function setActionListeners () {
* Loads stored settings from local storage
*/
function setSettings () {
var acceptedParams = ['autocomplete', 'key', 'lang', 'newtab', 'sprueche'];
for (var key in localStorage) {
var value = localStorage.getItem(key);
var acceptedParams = ['autocomplete', 'key', 'lang', 'maps', 'newtab', 'sprueche', 'autocomplete'];
var accepted = false;
for (var i in acceptedParams) {
if (key === 'param_' + acceptedParams[i]) {
......@@ -90,19 +88,13 @@ function setSettings () {
}
if (accepted) {
key = key.substring(6);
$('#searchForm').append('<input type="hidden" name="' + key + '" value="' + value + '">');
// Check for existing hidden fields for this key
var existing = $('.search-hidden input[name="' + key + '"]');
if (existing.length === 0) {
// if none exist, create a new one
$('.search-hidden').append('<input type="hidden" name="' + key + '" value="' + value + '">');
}
}
$('#foki input[type=radio]#angepasst').attr('checked', true);
}
// Change the value of the lang input field to the given parameter
var lang = localStorage.getItem('param_lang');
if (lang !== null) {
$('input[name=lang]').val(lang);
}
// Change the value of the lang input field to the given parameter
var autocomplete = localStorage.getItem('param_autocomplete');
if (autocomplete !== null) {
$('input[name=eingabe]').attr('autocomplete', autocomplete);
}
// Change the request method to the given parameter
var requestMethod = localStorage.getItem('request');
......
......@@ -263,7 +263,7 @@
</div>
</div>-->
<fieldset>
<form id="searchForm" @if(Request::has('request') && Request::input('request') === "POST") method="POST" @elseif(Request::has('request') && Request::input('request') === "GET") method="GET" @else method="GET" @endif action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3") }}" accept-charset="UTF-8">
<form id="searchForm" method={{ $request }} action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/meta/meta.ger3") }}" accept-charset="UTF-8">
<div class="search-bar">
<div class="search-focus-selector">
<select name="focus" style="font-family: FontAwesome, sans-serif;">
......@@ -286,13 +286,10 @@
</div>
<div class="search-hidden">
<input type="hidden" name="encoding" value="utf8">
<input type="hidden" name="lang" value={{ $lang }} >
<input type="hidden" name="resultCount" value={{ $resultCount }} >
<input type="hidden" name="time" value={{ $time }} >
<input type="hidden" name="sprueche" value={{ $sprueche }} >
<input type="hidden" name="newtab" value={{ $newtab }} >
<input type="hidden" name="maps" value={{ $maps }} >
<input type="hidden" name="key" value={{ $key }} >
@foreach($option_values as $option => $value)
<input type="hidden" name={{ $option }} value={{ $value }}>
@endforeach
<input type="hidden" name="time" value={{ $time }}>
@foreach ($focusPages as $fp)
<input type="hidden" name={{ $fp }} value="on">
@endforeach
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment