Commit d3b1e97e authored by Karl's avatar Karl
Browse files

Man kann jetzt einen Suchfokus auch verändert abspeichern

parent 7a745b1d
......@@ -310,7 +310,9 @@ function productWidget() {
}
$(".lightSliderContainer").removeClass("hidden");
}
/**
* Creates focus tab and tab selector for every stored focus in local storage
*/
function createCustomFocuses() {
for (var key in localStorage) {
if (key.startsWith("focus_")) {
......@@ -324,23 +326,25 @@ function createCustomFocuses() {
}
}
}
/*
@if( $metager->getFokus() === "produktsuche" )
<li id="produktsucheTabSelector" class="active tab-selector" role="presentation" data-loaded="1">
<a aria-controls="produktsuche" data-href="#produktsuche" href="#produktsuche">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@else
<li id="produktsucheTabSelector" class="tab-selector" role="presentation" data-loaded="0">
<a aria-controls="produktsuche" data-href="{!! $metager->generateSearchLink('produktsuche') !!}" href="{!! $metager->generateSearchLink('produktsuche', false) !!}">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
</a>
</li>
@endif
*/
/**
* Adds a focuses tab selector to the tab selector section
*
* @if( $metager->getFokus() === "produktsuche" )
* <li id="produktsucheTabSelector" class="active tab-selector" role="presentation" data-loaded="1">
* <a aria-controls="produktsuche" data-href="#produktsuche" href="#produktsuche">
* <span class='glyphicon glyphicon-shopping-cart'></span>
* <span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
* </a>
* </li>
* @else
* <li id="produktsucheTabSelector" class="tab-selector" role="presentation" data-loaded="0">
* <a aria-controls="produktsuche" data-href="{!! $metager->generateSearchLink('produktsuche') !!}" href="{!! $metager->generateSearchLink('produktsuche', false) !!}">
* <span class='glyphicon glyphicon-shopping-cart'></span>
* <span class="hidden-xs">{{ trans('index.foki.produkte') }}</span>
* </a>
* </li>
* @endif
*/
function addFocus(focus, active = false) {
var id = getIdFromName(focus.name);
var foki = document.getElementById("foki");
......@@ -377,21 +381,23 @@ function addFocus(focus, active = false) {
focusElementLink.appendChild(focusElementIcon);
focusElementLink.appendChild(focusElementName);
}
/*
@if( $metager->getFokus() === "produktsuche" )
<div role="tabpanel" class="tab-pane active" id="produktsuche">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="produktsuche">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>
@endif
*/
/**
* Adds a focuses tab to the tab section
*
* @if( $metager->getFokus() === "produktsuche" )
* <div role="tabpanel" class="tab-pane active" id="produktsuche">
* <div class="row">
* @yield('results')
* </div>
* </div>
* @else
* <div role="tabpanel" class="tab-pane" id="produktsuche">
* <div class="loader">
* <img src="/img/ajax-loader.gif" alt="" />
* </div>
* </div>
* @endif
*/
function addTab(focus, active = false) {
var id = getIdFromName(focus.name);
// create tab div
......@@ -415,15 +421,22 @@ function addTab(focus, active = false) {
tabs.appendChild(tabPane)
tabPane.appendChild(row);
}
/**
* Turns a name into an id
* Converts special characters and spaces
*/
function getIdFromName(name) {
return "focus_" + name.split(" ").join("_").toLowerCase();
}
/**
* Loads the focus object for the given id from local storage
*/
function loadFocusById(id) {
return JSON.parse(localStorage.getItem(id));
}
/**
* Gets the id of the currently active focus
*/
function getActiveFocusId() {
var search = window.location.search;
var from = search.indexOf("focus=") + "focus=".length;
......@@ -434,11 +447,14 @@ function getActiveFocusId() {
id = search.substring(from, to);
return id;
}
/**
* Turns the link of the current page into a search link for the given focus
*/
// TODO catch error if link is http://localhost:8000/meta/meta.ger3?
function generateSearchLinkForFocus(focus) {
var link = document.location.href;
// remove old engine settings
// not yet tested
// not yet tested, only for compability problems with old versions of bookmarks and plugins
/*
while (link.indexOf("engine_") !== -1) {
var from = search.indexOf("engine_");
......@@ -460,7 +476,9 @@ function generateSearchLinkForFocus(focus) {
link = replaceFocusInUrl(link);
return link;
}
/**
* Replaces the focus in a given url with the "angepasst" focus
*/
function replaceFocusInUrl(url) {
var from = url.indexOf("focus=");
var to = url.substring(from).indexOf("&") + from;
......@@ -470,7 +488,9 @@ function replaceFocusInUrl(url) {
url = url.substring(0, from) + url.substring(to);
return url + "&focus=angepasst";
}
/**
* Loads the content for a given fokus
*/
function initialLoadContent(fokus) {
var link = $("#" + fokus + "TabSelector a").attr("data-href");
$.get(link, function(data) {
......
......@@ -174,7 +174,9 @@ function isUseOnce() {
return false;
}
}
/**
* Loads all the custom focuses stored in local storage
*/
function loadInitialCustomFocuses() {
for (var key in localStorage) {
if (key.startsWith("focus_")) {
......@@ -183,7 +185,10 @@ function loadInitialCustomFocuses() {
}
}
}
/**
* Shows the focus create dialog
* If an id is given it will try to load a focus for the given id
*/
function showFocusCreateDialog(id = "") {
document.getElementById("original-id").value = id;
$("#create-focus-modal").modal("show");
......@@ -206,17 +211,23 @@ function showFocusCreateDialog(id = "") {
}
}
}
/**
* Shows the focus create dialog for a given id
*/
function showFocusEditDialog(id) {
showFocusCreateDialog(id);
}
/**
* Save the current Focus
* Listens for save button
*/
function saveFocus() {
var name = document.getElementById("focus-name").value;
if (isValidName(name) && atLeastOneChecked()) {
var oldId = document.getElementById("original-id").value;
var id = getIdFromName(name);
var overwrite = true;
if (alreadyInUse(name)) {
if (alreadyInUse(name) && oldId !== id) {
overwrite = confirm("Name bereits genutzt\nüberschreiben?");
if (overwrite) {
localStorage.removeItem(id);
......@@ -224,7 +235,6 @@ function saveFocus() {
}
}
if (overwrite) {
var oldId = document.getElementById("original-id").value;
var focus = {};
$("input[type=checkbox]:checked").each(function(el) {
focus[$(this).attr("name")] = $(this).val();
......@@ -242,37 +252,48 @@ function saveFocus() {
alert("Bitte gültigen Namen eingeben:\n* Keine Sonderzeichen\n* Mindestens 1 Buchstabe\n* Mindestens 1 Suchmaschine auswählen");
}
}
/**
* Delete current Focus
* Listens for delete button
*/
function deleteFocus() {
var oldId = document.getElementById("original-id").value;
localStorage.removeItem(oldId);
removeFocusById(oldId);
$("#create-focus-modal").modal("hide");
}
/**
* Is the name valid (in terms of characters)?
*/
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);
}
/**
* Is at least one focus selected?
*/
function atLeastOneChecked() {
return $("input[type=checkbox]:checked").length > 0;
}
/**
* Is there already a focus with this name?
*/
function alreadyInUse(name) {
return localStorage.hasOwnProperty(getIdFromName(name));
}
function deleteFocus() {
var oldId = document.getElementById("original-id").value;
localStorage.removeItem(oldId);
removeFocusById(oldId);
$("#create-focus-modal").modal("hide");
}
/*
<input id="NAME" class="hide" type="radio" name="focus" value="NAME" form="searchForm" checked required>
<label id="NAME-label" for="NAME">
<span class="glyphicon glyphicon-star"></span>
<span class="content">NAME</span>
<button class="btn btn-default">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</label>
*/
/**
* Adds a focus html-element to the focus selection
*
* <input id="NAME" class="hide" type="radio" name="focus" value="NAME" form="searchForm" checked required>
* <label id="NAME-label" for="NAME">
* <span class="glyphicon glyphicon-star"></span>
* <span class="content">NAME</span>
* <button class="btn btn-default">
* <span class="glyphicon glyphicon-pencil"></span>
* </button>
* </label>
*/
function addFocus(name) {
var id = getIdFromName(name);
var foki = document.getElementById("foki");
......@@ -327,18 +348,25 @@ function addFocus(name) {
wrapper.appendChild(newFocusEditLink);
newFocusEditLink.appendChild(newFocusEditLinkGlyphicon);
}
/**
* Remove the focuses html-elements
*/
function removeFocus(name) {
removeFocusById(getIdFromName(name));
}
/**
* Remove the focuses html-elements
*/
function removeFocusById(id) {
var focusRadio = document.getElementById(id);
var focus = focusRadio.parentNode;
var parent = focus.parentNode;
parent.removeChild(focus);
}
/**
* Turns a name into an id
* Converts special characters and spaces
*/
function getIdFromName(name) {
name = name.toLowerCase();
name = name.split(" ").join("_");
......@@ -347,15 +375,21 @@ function getIdFromName(name) {
name = name.split("ü").join("ue");
return "focus_" + name;
}
/**
* Loads the focus object for the given id from local storage
*/
function loadFocusById(id) {
return JSON.parse(localStorage.getItem(id));
}
/**
* Unchecks all focuses from the focus creator dialog
*/
function uncheckAll() {
$(".focusCheckbox").prop("checked", false);
}
/**
* Resets all settings
*/
function resetOptions() {
localStorage.removeItem("pers");
var keys = [];
......
{
"js/editLanguage.js": "js/editLanguage-7a1cbfb2ba.js",
"js/kontakt.js": "js/kontakt-de49d68db3.js",
"js/scriptResultPage.js": "js/scriptResultPage-1eb7e4a36b.js",
"js/scriptStartPage.js": "js/scriptStartPage-1d6e62e8c9.js",
"js/scriptResultPage.js": "js/scriptResultPage-95d76cf16b.js",
"js/scriptStartPage.js": "js/scriptStartPage-330e649107.js",
"js/settings.js": "js/settings-6ff0eab621.js",
"js/widgets.js": "js/widgets-866379dd63.js"
}
\ No newline at end of file
This diff is collapsed.
......@@ -224,9 +224,10 @@ function showFocusEditDialog(id) {
function saveFocus() {
var name = document.getElementById("focus-name").value;
if (isValidName(name) && atLeastOneChecked()) {
var oldId = document.getElementById("original-id").value;
var id = getIdFromName(name);
var overwrite = true;
if (alreadyInUse(name)) {
if (alreadyInUse(name) && oldId !== id) {
overwrite = confirm("Name bereits genutzt\nüberschreiben?");
if (overwrite) {
localStorage.removeItem(id);
......@@ -234,7 +235,6 @@ function saveFocus() {
}
}
if (overwrite) {
var oldId = document.getElementById("original-id").value;
var focus = {};
$("input[type=checkbox]:checked").each(function(el) {
focus[$(this).attr("name")] = $(this).val();
......
$(document).ready(function() {
$(".hint").tooltip();
$(".language-text-area").each(function() {
auto_grow(this);
});
$(".language-text-area").keyup(function() {
auto_grow(this);
});
});
function auto_grow(element) {
element.style.height = "5px";
element.style.height = (element.scrollHeight + 10) + "px";
}
\ No newline at end of file
//based on https://github.com/encrypt-to/secure.contactform.php
/* The MIT License (MIT)
Copyright (c) 2013 Jan Wiegelmann
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
function encrypt() {
if (window.crypto && window.crypto.getRandomValues) {
var message = document.getElementById("message");
if (message.value.indexOf("-----BEGIN PGP MESSAGE-----") !== -1 && message.value.indexOf("-----END PGP MESSAGE-----") !== -1) {
// encryption done
} else {
var pub_key = openpgp.key.readArmored(document.getElementById("pubkey").innerHTML).keys[0];
var plaintext = message.value;
var ciphertext = openpgp.encryptMessage([pub_key], plaintext);
message.value = ciphertext;
return true;
}
} else {
switch (getLanguage()) {
case "de":
alert("Fehler: Ihr Browser wird nicht unterstützt. Bitte installieren Sie einen aktuellen Browser wie z.B. Mozilla Firefox.");
break;
case "en":
alert("Error: Your browser is not supported. Please install an up to date browser like Mozilla Firefox.");
break;
case "es":
// alert(""); TODO
break;
}
return false;
}
}
$(document).ready(function() {
switch (getLanguage()) {
case "de":
$(".encrypt-btn").html("Verschlüsseln und senden");
break;
case "en":
$(".encrypt-btn").html("encrypt and send");
break;
case "es":
// $(".encrypt-btn").html(""); TODO
break;
}
$(".contact").submit(function() {
return encrypt(this);
});
});
function getLanguage() {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]["httpEquiv"] == "language") {
return metaData[m]["content"];
}
}
}
\ No newline at end of file
$(document).ready(function() {
getDocumentReadyForUse($("#foki > li.active > a").attr("aria-controls"));
$('iframe').iFrameResize();
botProtection();
});
function tabs() {
//return;
$("#foki > li.tab-selector > a").each(function() {
if($(this).attr("target") != "_blank") {
$(this).attr("href", "#" + $(this).attr("aria-controls"));
$(this).attr("role", "tab");
$(this).attr("data-toggle", "tab");
}
});
$("#foki > li.tab-selector > a").off();
$("#foki > li.tab-selector > a").on("show.bs.tab", function(e) {
var fokus = $(this).attr("aria-controls");
var link = $("#" + fokus + "TabSelector a").attr("data-href");
if ($("#" + fokus + "TabSelector").attr("data-loaded") != "1") {
$.get(link, function(data) {
$("#" + fokus + "TabSelector").attr("data-loaded", "1");
$("#" + fokus).html(data);
$("input[name=focus]").val($("#foki li.active a").attr("aria-controls"));
getDocumentReadyForUse(fokus);
});
} else {
getDocumentReadyForUse(fokus);
}
});
}
function getDocumentReadyForUse(fokus) {
clickLog();
popovers();
if (fokus === "bilder") imageLoader();
//pagination();
tabs();
theme();
fokiChanger();
pluginInfo();
productWidget();
}
function pluginInfo() {
if (localStorage) {
if (localStorage.getItem('pluginInfo') == "off") $("#searchplugin").css("display", "none");
$("#searchplugin").on('close.bs.alert', function() {
$.get('/pluginClose');
localStorage.setItem('pluginInfo', 'off');
});
$("#searchplugin a.btn").click(function() {
$.get('/pluginInstall');
});
}
}
function theme() {
if (localStorage) {
var theme = localStorage.getItem("theme");
if (theme != null) {
if ((theme.match(/,/g) || []).length != 3) {
localStorage.removeItem("theme");
} else {
theme = theme.split(",");
$("#theme").attr("href", "/css/theme.css.php?r=" + theme[0] + "&g=" + theme[1] + "&b=" + theme[2] + "&a=" + theme[3]);
}
}
}
}
function clickLog() {
$(".result a.title, .result div.link-link a").off();
$(".result a.title, .result div.link-link a").click(function() {
$.get("/clickstats", {
i: $("meta[name=p]").attr("content"),
s: $(this).attr("data-hoster"),
q: $("meta[name=q]").attr("content"),
p: $(this).attr("data-count"),
url: $(this).attr("href")
});
});
}
function popovers() {
$("[data-toggle=popover]").each(function(e) {
$(this).popover("destroy");
$(this).popover({
//html : true,
//title : "<span class='glyphicon glyphicon-cog'></span> Optionen",
content: $(this).parent().find(".content").html()
});
});
}
function pagination() {
$(".pagination li:not(.active) > a").attr("href", "#");
$(".pagination li.disabled > a").removeAttr("href");
$(".pagination li:not(.active) > a").off();
$(".pagination li:not(.active) > a").click(paginationHandler);
}
function paginationHandler() {
var link = $(this).attr("data-href");
if (link.length == 0) {
return;
}
var tabPane = $(".tab-pane.active");
$(tabPane).html("<div class=\"loader\"><img src=\"/img/ajax-loader.gif\" alt=\"\" /></div>");
$.get(link, function(data) {
$(tabPane).html(data);
$(".pagination li:not(.active) > a").attr("href", "#");
$(".pagination li.disabled > a").removeAttr("href");
$(".pagination li:not(.active) > a").off();
$(".pagination li:not(.active) > a").click(paginationHandler);
getDocumentReadyForUse();
});
}
function imageLoader() {
if (typeof $("#container").masonry == "undefined") {
return;
}
var $grid = $("#container").masonry({
columnWidth: 150,
itemSelector: '.item',
gutter: 10,
isFitWidth: true
});
$grid.imagesLoaded().progress(function(instance, image) {
$grid.masonry('layout');
});
}
function eliminateHost(host) {
$(".result:not(.ad)").each(function(e) {
var host2 = $(this).find(".link-link > a").attr("data-host");
if (host2.indexOf(host) === 0) {
$(this).css("display", "none");
}
});
}
function fokiChanger() {
$("#fokiChanger ul > li").click(function() {
document.location.href = $(this).attr("data-href");