Commit 01b4b9bc authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '516-gespeicherte-ergebnisse-auf-die-startseite-bringen' into 'development'

Resolve "Gespeicherte Ergebnisse auf die Startseite bringen."

Closes #516

See merge request !903
parents 653b6229 a1298f7a
......@@ -24,7 +24,9 @@ elixir(function (mix) {
*/
mix.scripts(['lib/jquery.js', 'lib/jquery-ui.min.js', 'lib/bootstrap.js', 'lib/lightslider.js', 'lib/masonry.js', 'lib/imagesloaded.js', 'lib/openpgp.min.js', 'lib/iframeResizer.min.js', 'lib/md5.js'], 'public/js/lib.js')
mix.scripts(['lib/jquery.js', 'lib/iframeResizer.contentWindow.min.js'], 'public/js/quicktips.js')
mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js'])
mix.scripts(['scriptStartPage.js', 'results.js'], 'public/js/scriptStartPage.js');
mix.scripts(['scriptResultPage.js', 'results.js'], 'public/js/scriptResultPage.js');
mix.version(['css/themes/default.css', 'js/lib.js', 'js/quicktips.js']);
mix.less('metager/beitritt.less', 'public/css/beitritt.css')
mix.version(['css/beitritt.css'])
mix.version(['js/widgets.js', 'js/editLanguage.js', 'js/kontakt.js', 'js/scriptResultPage.js', 'js/scriptStartPage.js', 'js/settings.js'])
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,10 @@ $(document).ready(function () {
var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector');
getDocumentReadyForUse(focus, custom);
botProtection();
new Results(); // Adds the saved Results if they are present
new Results().updateResultPageInterface(); // Adds the saved Results if they are present
if(document.location.href.indexOf("focus=container") !== -1){
$($("#foki > li#savedFokiTabSelector").get(0)).find(">a").tab("show");
}
});
function activateJSOnlyContent () {
......@@ -517,6 +520,22 @@ function initialLoadContent (fokus) {
});
}
function resultSaver(index) {
var title = $(".result[data-count=" + index + "] a.title").html();
var link = $(".result[data-count=" + index + "] a.title").attr("href");
var anzeigeLink = $(".result[data-count=" + index + "] div.link-link > a").html();
var gefVon = $(".result[data-count=" + index + "] span.hoster").html();
var hoster = $(".result[data-count=" + index + "] a.title").attr("data-hoster");
var anonym = $(".result[data-count=" + index + "] a.proxy").attr("href");
var description = $(".result[data-count=" + index + "] div.description").html();
var color = $(".result[data-count=" + index + "] div.number").css("color");
var rank = parseFloat($(".result[data-count=" + index + "]").attr("data-rank"));
new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);
var to = $("#savedFokiTabSelector").length ? $("#savedFokiTabSelector") : $("#foki");
$(".result[data-count=" + index + "]").transfer({to: to, duration: 1000});
new Results().updateResultPageInterface();
}
/*
* This object gathers all stored Result Objects and can Update the Interface to show them.
*/
......@@ -525,13 +544,12 @@ function Results(sort){
this.prefix = "result_";
this.results = [];
this.updateResults();
this.length = this.results.length;
this.sortResults(sort);
this.updateInterface(sort);
}
Results.prototype.sortResults = function(sortType){
if(sortType === undefined) sortType = "chronological";
console.log(this.results);
switch(sortType){
case "chronological":
this.results.sort(function(a,b){
......@@ -549,13 +567,12 @@ Results.prototype.sortResults = function(sortType){
break;
case "alphabetical":
this.results.sort(function(a,b){
if(a.hostname > b.hostname) return -1;
if(a.hostname < b.hostname) return 1;
if(b.hostname > a.hostname) return -1;
if(b.hostname < a.hostname) return 1;
return 0;
});
break;
}
console.log(this.results);
}
Results.prototype.updateResults = function(){
......@@ -584,7 +601,7 @@ Results.prototype.deleteResults = function(){
});
}
Results.prototype.updateInterface = function(sortType){
Results.prototype.updateResultPageInterface = function(sortType){
if(this.results.length === 0){
$("#savedFokiTabSelector, #savedFoki").remove();
$($("#foki > li[data-loaded=1]").get(0)).find(">a").tab("show");
......@@ -639,19 +656,19 @@ Results.prototype.addToContainer = function(container, sortType){
$(container).prepend(options);
$(options).find("select").change(function(){
new Results($(this).val());
new Results($(this).val()).updateResultPageInterface();
});
$(options).find("button").click({caller: this}, function(event){
event.data.caller.deleteResults();
new Results();
new Results().updateResultPageInterface();
});
$(options).find("input").keyup(function(){
var search = $(this).val();
$("#savedFoki > div.result").each(function(index, value){
var html = $(this).html();
if(html.indexOf(search) === -1){
if(html.toLowerCase().indexOf(search.toLowerCase()) === -1){
$(value).addClass("hidden");
}else{
$(value).removeClass("hidden");
......@@ -661,22 +678,6 @@ Results.prototype.addToContainer = function(container, sortType){
}
function resultSaver(index) {
var title = $(".result[data-count=" + index + "] a.title").html();
var link = $(".result[data-count=" + index + "] a.title").attr("href");
var anzeigeLink = $(".result[data-count=" + index + "] div.link-link > a").html();
var gefVon = $(".result[data-count=" + index + "] span.hoster").html();
var hoster = $(".result[data-count=" + index + "] a.title").attr("data-hoster");
var anonym = $(".result[data-count=" + index + "] a.proxy").attr("href");
var description = $(".result[data-count=" + index + "] div.description").html();
var color = $(".result[data-count=" + index + "] div.number").css("color");
var rank = parseFloat($(".result[data-count=" + index + "]").attr("data-rank"));
new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);
var to = $("#savedFokiTabSelector").length ? $("#savedFokiTabSelector") : $("#foki");
$(".result[data-count=" + index + "]").transfer({to: to, duration: 1000});
new Results();
}
function Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){
this.prefix = "result_"; // Präfix for the localStorage so we can find all Items
......@@ -776,7 +777,7 @@ Result.prototype.setIndex = function(index){
Result.prototype.remove = function(){
localStorage.removeItem(this.prefix + this.hash);
new Results();
new Results().updateResultPageInterface();
}
Result.prototype.toHtml = function(){
......@@ -816,3 +817,4 @@ Result.prototype.toHtml = function(){
});
return result;
}
//# sourceMappingURL=scriptResultPage.js.map
{"version":3,"sources":["scriptResultPage.js","results.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACzhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"scriptResultPage.js","sourcesContent":["$(document).ready(function () {\r\n activateJSOnlyContent();\r\n createCustomFocuses();\r\n var focus = $('#foki > li.active > a').attr('aria-controls');\r\n var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector');\r\n getDocumentReadyForUse(focus, custom);\r\n botProtection();\r\n new Results().updateResultPageInterface(); // Adds the saved Results if they are present\r\n if(document.location.href.indexOf(\"focus=container\") !== -1){\r\n $($(\"#foki > li#savedFokiTabSelector\").get(0)).find(\">a\").tab(\"show\");\r\n }\r\n});\r\n\r\nfunction activateJSOnlyContent () {\r\n $('#searchplugin').removeClass('hide');\r\n $('.options').removeClass('hide');\r\n}\r\n\r\nfunction tabs () {\r\n $('#foki > li.tab-selector > a').each(function () {\r\n if ($(this).attr('target') != '_blank') {\r\n $(this).attr('href', '#' + $(this).attr('aria-controls'));\r\n $(this).attr('role', 'tab');\r\n $(this).attr('data-toggle', 'tab');\r\n }\r\n });\r\n $('#foki > li.tab-selector > a').off();\r\n $('#foki > li.tab-selector > a').on('show.bs.tab', function (e) {\r\n var fokus = $(this).attr('aria-controls');\r\n var link = $('#' + fokus + 'TabSelector a').attr('data-href');\r\n if ($('#' + fokus + 'TabSelector').attr('data-loaded') != '1') {\r\n $.get(link, function (data) {\r\n $('#' + fokus + 'TabSelector').attr('data-loaded', '1');\r\n $('#' + fokus).html(data);\r\n $('input[name=focus]').val($('#foki li.active a').attr('aria-controls'));\r\n getDocumentReadyForUse(fokus);\r\n });\r\n } else {\r\n getDocumentReadyForUse(fokus);\r\n }\r\n });\r\n}\r\n\r\nfunction getDocumentReadyForUse (fokus, custom = false) {\r\n clickLog();\r\n popovers();\r\n if (fokus === 'bilder') imageLoader();\r\n if (custom) initialLoadContent(fokus);\r\n // pagination()\r\n tabs();\r\n theme();\r\n fokiChanger();\r\n pluginInfo();\r\n productWidget();\r\n $('iframe:not(.resized)').iFrameResize();\r\n $('iframe').addClass('resized');\r\n}\r\n\r\nfunction pluginInfo () {\r\n if (localStorage) {\r\n if (localStorage.getItem('pluginInfo') == 'off') $('#searchplugin').css('display', 'none');\r\n $('#searchplugin').on('close.bs.alert', function () {\r\n $.get('/pluginClose');\r\n localStorage.setItem('pluginInfo', 'off');\r\n });\r\n $('#searchplugin a.btn').click(function () {\r\n $.get('/pluginInstall');\r\n });\r\n }\r\n}\r\n\r\n\r\n\r\nfunction theme () {\r\n if (localStorage) {\r\n var theme = localStorage.getItem('theme');\r\n if (theme != null) {\r\n if ((theme.match(/,/g) || []).length != 3) {\r\n localStorage.removeItem('theme');\r\n } else {\r\n theme = theme.split(',');\r\n $('#theme').attr('href', '/css/theme.css.php?r=' + theme[0] + '&g=' + theme[1] + '&b=' + theme[2] + '&a=' + theme[3]);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction clickLog () {\r\n $('.result a.title, .result div.link-link a').off();\r\n $('.result a.title, .result div.link-link a').click(function () {\r\n $.get('/clickstats', {\r\n i: $('meta[name=p]').attr('content'),\r\n s: $(this).attr('data-hoster'),\r\n q: $('meta[name=q]').attr('content'),\r\n p: $(this).attr('data-count'),\r\n url: $(this).attr('href')\r\n });\r\n });\r\n}\r\n\r\nfunction botProtection () {\r\n if ($('meta[name=pqr]').length > 0) {\r\n var link = atob($('meta[name=pqr]').attr('content'));\r\n var hash = $('meta[name=pq]').attr('content');\r\n document.location.href = link + '&bot=' + hash;\r\n }\r\n}\r\n\r\nfunction popovers () {\r\n $('[data-toggle=popover]').each(function (e) {\r\n $(this).popover('destroy');\r\n $(this).popover({\r\n // html : true,\r\n // title : \"<i class=\"fa fa-cog\" aria-hidden=\"true\"></i> Optionen\",\r\n content: $(this).parent().find('.content').html()\r\n });\r\n });\r\n}\r\n\r\nfunction pagination () {\r\n $('.pagination li:not(.active) > a').attr('href', '#');\r\n $('.pagination li.disabled > a').removeAttr('href');\r\n $('.pagination li:not(.active) > a').off();\r\n $('.pagination li:not(.active) > a').click(paginationHandler);\r\n}\r\n\r\nfunction paginationHandler () {\r\n var link = $(this).attr('data-href');\r\n if (link.length == 0) {\r\n return;\r\n }\r\n var tabPane = $('.tab-pane.active');\r\n $(tabPane).html('<div class=\"loader\"><img src=\"/img/ajax-loader.gif\" alt=\"\" /></div>');\r\n $.get(link, function (data) {\r\n $(tabPane).html(data);\r\n $('.pagination li:not(.active) > a').attr('href', '#');\r\n $('.pagination li.disabled > a').removeAttr('href');\r\n $('.pagination li:not(.active) > a').off();\r\n $('.pagination li:not(.active) > a').click(paginationHandler);\r\n getDocumentReadyForUse();\r\n });\r\n}\r\n\r\nfunction imageLoader () {\r\n if (typeof $('#container').masonry == 'undefined') {\r\n return;\r\n }\r\n var $grid = $('#container').masonry({\r\n columnWidth: 150,\r\n itemSelector: '.item',\r\n gutter: 10,\r\n isFitWidth: true\r\n });\r\n $grid.imagesLoaded().progress(function (instance, image) {\r\n $grid.masonry('layout');\r\n });\r\n}\r\n\r\nfunction eliminateHost (host) {\r\n $('.result:not(.ad)').each(function (e) {\r\n var host2 = $(this).find('.link-link > a').attr('data-host');\r\n if (host2.indexOf(host) === 0) {\r\n $(this).css('display', 'none');\r\n }\r\n });\r\n}\r\n\r\nfunction fokiChanger () {\r\n $('#fokiChanger ul > li').click(function () {\r\n document.location.href = $(this).attr('data-href');\r\n });\r\n}\r\n// Polyfill for form attribute\r\n(function ($) {\r\n /**\r\n * polyfill for html5 form attr\r\n */\r\n // detect if browser supports this\r\n var sampleElement = $('[form]').get(0);\r\n var isIE11 = !(window.ActiveXObject) && 'ActiveXObject' in window;\r\n if (sampleElement && window.HTMLFormElement && sampleElement.form instanceof HTMLFormElement && !isIE11) {\r\n // browser supports it, no need to fix\r\n return;\r\n }\r\n /**\r\n * Append a field to a form\r\n *\r\n */\r\n $.fn.appendField = function (data) {\r\n // for form only\r\n if (!this.is('form')) return;\r\n // wrap data\r\n if (!$.isArray(data) && data.name && data.value) {\r\n data = [data];\r\n }\r\n var $form = this;\r\n // attach new params\r\n $.each(data, function (i, item) {\r\n $('<input/>').attr('type', 'hidden').attr('name', item.name).val(item.value).appendTo($form);\r\n });\r\n return $form;\r\n };\r\n /**\r\n * Find all input fields with form attribute point to jQuery object\r\n * \r\n */\r\n $('form[id]').submit(function (e) {\r\n var $form = $(this);\r\n // serialize data\r\n var data = $('[form=' + $form.attr('id') + ']').serializeArray();\r\n // append data to form\r\n $form.appendField(data);\r\n }).each(function () {\r\n var form = this,\r\n $form = $(form),\r\n $fields = $('[form=' + $form.attr('id') + ']');\r\n $fields.filter('button, input').filter('[type=reset],[type=submit]').click(function () {\r\n var type = this.type.toLowerCase();\r\n if (type === 'reset') {\r\n // reset form\r\n form.reset();\r\n // for elements outside form\r\n $fields.each(function () {\r\n this.value = this.defaultValue;\r\n this.checked = this.defaultChecked;\r\n }).filter('select').each(function () {\r\n $(this).find('option').each(function () {\r\n this.selected = this.defaultSelected;\r\n });\r\n });\r\n } else if (type.match(/^submit|image$/i)) {\r\n $(form).appendField({\r\n name: this.name,\r\n value: this.value\r\n }).submit();\r\n }\r\n });\r\n });\r\n})(jQuery);\r\n\r\nfunction productWidget () {\r\n var isMobile = false; // initiate as false\r\n // device detection\r\n if (/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(navigator.userAgent.substr(0, 4))) isMobile = true;\r\n if (isMobile) {\r\n $('.lightSlider').lightSlider({\r\n item: 5,\r\n loop: false,\r\n slideMove: 2,\r\n easing: 'cubic-bezier(0.25, 0, 0.25, 1)',\r\n speed: 600,\r\n pager: false,\r\n prevHtml: '<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i><span class=\"sr-only\">Previous</span>',\r\n nextHtml: '<i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i><span class=\"sr-only\">Next</span>',\r\n responsive: [{\r\n breakpoint: 1400,\r\n settings: {\r\n item: 4,\r\n slideMove: 2\r\n }\r\n }, {\r\n breakpoint: 1200,\r\n settings: {\r\n item: 3,\r\n slideMove: 2\r\n }\r\n }, {\r\n breakpoint: 980,\r\n settings: {\r\n item: 4,\r\n slideMove: 2\r\n }\r\n }, {\r\n breakpoint: 720,\r\n settings: {\r\n item: 3,\r\n slideMove: 1\r\n }\r\n }, {\r\n breakpoint: 520,\r\n settings: {\r\n item: 2,\r\n slideMove: 1\r\n }\r\n } ]\r\n });\r\n } else {\r\n $('.lightSlider').lightSlider({\r\n item: 5,\r\n loop: false,\r\n slideMove: 2,\r\n easing: 'cubic-bezier(0.25, 0, 0.25, 1)',\r\n speed: 600,\r\n pager: false,\r\n enableTouch: false,\r\n enableDrag: false,\r\n prevHtml: '<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i><span class=\"sr-only\">Previous</span>',\r\n nextHtml: '<i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i><span class=\"sr-only\">Next</span>',\r\n responsive: [{\r\n breakpoint: 1400,\r\n settings: {\r\n item: 4,\r\n slideMove: 2\r\n }\r\n }, {\r\n breakpoint: 1200,\r\n settings: {\r\n item: 3,\r\n slideMove: 2\r\n }\r\n }, {\r\n breakpoint: 980,\r\n settings: {\r\n item: 4,\r\n slideMove: 2\r\n }\r\n }, {\r\n breakpoint: 720,\r\n settings: {\r\n item: 3,\r\n slideMove: 1\r\n }\r\n }, {\r\n breakpoint: 520,\r\n settings: {\r\n item: 2,\r\n slideMove: 1\r\n }\r\n } ]\r\n });\r\n }\r\n $('.lightSliderContainer').removeClass('hidden');\r\n}\r\n/**\r\n * Creates focus tab and tab selector for every stored focus in local storage\r\n */\r\nfunction createCustomFocuses () {\r\n for (var key in localStorage) {\r\n if (key.startsWith('focus_')) {\r\n var focus = loadFocusById(key);\r\n var active = false;\r\n if (getActiveFocusId() === getIdFromName(focus.name)) {\r\n active = true;\r\n }\r\n addFocus(focus, active);\r\n addTab(focus, active);\r\n }\r\n }\r\n}\r\n/**\r\n * Adds a focuses tab selector to the tab selector section\r\n * \r\n * @if( $metager->getFokus() === \"produktsuche\" )\r\n * <li id=\"produktsucheTabSelector\" class=\"active tab-selector\" role=\"presentation\" data-loaded=\"1\">\r\n * <a aria-controls=\"produktsuche\" data-href=\"#produktsuche\" href=\"#produktsuche\">\r\n * <i class=\"fa fa-shopping-cart\" aria-hidden=\"true\"></i>\r\n * <span class=\"hidden-xs\">{{ trans('index.foki.produkte') }}</span>\r\n * </a>\r\n * </li>\r\n * @else\r\n * <li id=\"produktsucheTabSelector\" class=\"tab-selector\" role=\"presentation\" data-loaded=\"0\">\r\n * <a aria-controls=\"produktsuche\" data-href=\"{!! $metager->generateSearchLink('produktsuche') !!}\" href=\"{!! $metager->generateSearchLink('produktsuche', false) !!}\">\r\n * <i class=\"fa fa-shopping-cart\" aria-hidden=\"true\"></i>\r\n * <span class=\"hidden-xs\">{{ trans('index.foki.produkte') }}</span>\r\n * </a>\r\n * </li>\r\n * @endif\r\n */\r\nfunction addFocus (focus, active = false) {\r\n var id = getIdFromName(focus.name);\r\n var foki = document.getElementById('foki');\r\n // create <input>\r\n var focusElement = document.createElement('li');\r\n focusElement.id = id + 'TabSelector';\r\n focusElement.classList.add('tab-selector');\r\n focusElement.classList.add('custom-focus-tab-selector');\r\n if (active) {\r\n focusElement.classList.add('active');\r\n focusElement.setAttribute('data-loaded', '1');\r\n } else {\r\n focusElement.setAttribute('data-loaded', '0');\r\n }\r\n focusElement.setAttribute('role', 'presentation');\r\n // create <a>\r\n var focusElementLink = document.createElement('a');\r\n focusElementLink.setAttribute('aria-controls', id);\r\n var searchLink = generateSearchLinkForFocus(focus);\r\n focusElementLink.setAttribute('data-href', searchLink);\r\n focusElementLink.setAttribute('href', searchLink);\r\n // create <a> icon\r\n var focusElementIcon = document.createElement('i');\r\n focusElementIcon.classList.add('fa');\r\n focusElementIcon.classList.add('fa-star');\r\n focusElementIcon.setAttribute('aria-hidden', 'true');\r\n // create <span> focusname\r\n var focusElementName = document.createElement('span');\r\n focusElementName.classList.add('hidden-xs');\r\n focusElementName.innerHTML = focus.name;\r\n // add new elements\r\n var mapsTabSelector = document.getElementById('mapsTabSelector');\r\n foki.insertBefore(focusElement, mapsTabSelector);\r\n focusElement.appendChild(focusElementLink);\r\n focusElementLink.appendChild(focusElementIcon);\r\n focusElementLink.appendChild(focusElementName);\r\n}\r\n/**\r\n * Adds a focuses tab to the tab section\r\n * \r\n * @if( $metager->getFokus() === \"produktsuche\" )\r\n * <div role=\"tabpanel\" class=\"tab-pane active\" id=\"produktsuche\">\r\n * <div class=\"row\">\r\n * @yield('results')\r\n * </div>\r\n * </div>\r\n * @else\r\n * <div role=\"tabpanel\" class=\"tab-pane\" id=\"produktsuche\">\r\n * <div class=\"loader\">\r\n * <img src=\"/img/ajax-loader.gif\" alt=\"\" />\r\n * </div>\r\n * </div>\r\n * @endif\r\n */\r\nfunction addTab (focus, active = false) {\r\n var id = getIdFromName(focus.name);\r\n // create tab div\r\n var tabPane = document.createElement('div');\r\n tabPane.id = id;\r\n tabPane.classList.add('tab-pane');\r\n if (active) {\r\n tabPane.classList.add('active');\r\n }\r\n tabPane.setAttribute('role', 'tabpanel');\r\n // create row div\r\n var row = document.createElement('div');\r\n row.classList.add('loader');\r\n // create loader image\r\n var img = document.createElement('img');\r\n img.setAttribute('src', '/img/ajax-loader.gif');\r\n img.setAttribute('alt', '');\r\n row.appendChild(img);\r\n // add new elements\r\n var tabs = document.getElementById('main-content-tabs');\r\n tabs.appendChild(tabPane);\r\n tabPane.appendChild(row);\r\n}\r\n/**\r\n * Turns a name into an id\r\n * Converts special characters and spaces\r\n */\r\nfunction getIdFromName (name) {\r\n return 'focus_' + name.split(' ').join('_').toLowerCase();\r\n}\r\n/**\r\n * Loads the focus object for the given id from local storage\r\n */\r\nfunction loadFocusById (id) {\r\n return JSON.parse(localStorage.getItem(id));\r\n}\r\n/**\r\n * Gets the id of the currently active focus\r\n */\r\nfunction getActiveFocusId () {\r\n var search = window.location.search;\r\n var from = search.indexOf('focus=') + 'focus='.length;\r\n var to = search.substring(from).indexOf('&') + from;\r\n if (to <= 0) {\r\n to = search.substring(from).length;\r\n }\r\n return search.substring(from, to);\r\n}\r\n/**\r\n * Turns the link of the current page into a search link for the given focus\r\n */\r\n// TODO catch error if link is http://localhost:8000/meta/meta.ger3?\r\nfunction generateSearchLinkForFocus (focus) {\r\n var link = document.location.href;\r\n // remove old engine settings\r\n // not yet tested, only for compability problems with old versions of bookmarks and plugins\r\n /*\r\n while (link.indexOf(\"engine_\") !== -1) {\r\n var from = search.indexOf(\"engine_\")\r\n var to = search.substring(from).indexOf(\"&\") + from\r\n if (to === 0) {\r\n to = search.substring(from).length\r\n }\r\n link = link.substring(0, from) + link.substring(to)\r\n }\r\n */\r\n // add new engine settings\r\n for (var key in focus) {\r\n if (key.startsWith('engine_')) {\r\n var focusName = key.substring('engine_'.length);\r\n link += '&' + focusName + '=' + focus[key];\r\n }\r\n }\r\n link += '&out=results';\r\n link = replaceFocusInUrl(link);\r\n return link;\r\n}\r\n/**\r\n * Replaces the focus in a given url with the \"angepasst\" focus\r\n */\r\nfunction replaceFocusInUrl (url) {\r\n var from = url.indexOf('focus=');\r\n var to = url.substring(from).indexOf('&') + from;\r\n if (to === 0) {\r\n to = url.substring(from).length;\r\n }\r\n url = url.substring(0, from) + url.substring(to);\r\n return url + '&focus=angepasst';\r\n}\r\n/**\r\n * Loads the content for a given fokus\r\n */\r\nfunction initialLoadContent (fokus) {\r\n var link = $('#' + fokus + 'TabSelector a').attr('data-href');\r\n $.get(link, function (data) {\r\n $('#' + fokus).html(data);\r\n getDocumentReadyForUse(fokus);\r\n });\r\n}\r\n\r\nfunction resultSaver(index) {\r\n var title = $(\".result[data-count=\" + index + \"] a.title\").html();\r\n var link = $(\".result[data-count=\" + index + \"] a.title\").attr(\"href\");\r\n var anzeigeLink = $(\".result[data-count=\" + index + \"] div.link-link > a\").html();\r\n var gefVon = $(\".result[data-count=\" + index + \"] span.hoster\").html();\r\n var hoster = $(\".result[data-count=\" + index + \"] a.title\").attr(\"data-hoster\");\r\n var anonym = $(\".result[data-count=\" + index + \"] a.proxy\").attr(\"href\");\r\n var description = $(\".result[data-count=\" + index + \"] div.description\").html();\r\n var color = $(\".result[data-count=\" + index + \"] div.number\").css(\"color\");\r\n var rank = parseFloat($(\".result[data-count=\" + index + \"]\").attr(\"data-rank\"));\r\n new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);\r\n var to = $(\"#savedFokiTabSelector\").length ? $(\"#savedFokiTabSelector\") : $(\"#foki\");\r\n $(\".result[data-count=\" + index + \"]\").transfer({to: to, duration: 1000});\r\n new Results().updateResultPageInterface();\r\n}\r\n","/*\r\n * This object gathers all stored Result Objects and can Update the Interface to show them.\r\n*/\r\nfunction Results(sort){\r\n if(!localStorage) return;\r\n this.prefix = \"result_\";\r\n this.results = [];\r\n this.updateResults();\r\n this.length = this.results.length;\r\n this.sortResults(sort);\r\n}\r\n\r\nResults.prototype.sortResults = function(sortType){\r\n if(sortType === undefined) sortType = \"chronological\";\r\n switch(sortType){\r\n case \"chronological\":\r\n this.results.sort(function(a,b){\r\n if(a.added > b.added) return -1;\r\n if(a.added < b.added) return 1;\r\n return 0;\r\n });\r\n break;\r\n case \"rank\":\r\n this.results.sort(function(a,b){\r\n if(a.rank > b.rank) return -1;\r\n if(a.rank < b.rank) return 1;\r\n return 0;\r\n });\r\n break;\r\n case \"alphabetical\":\r\n this.results.sort(function(a,b){\r\n if(b.hostname > a.hostname) return -1;\r\n if(b.hostname < a.hostname) return 1;\r\n return 0;\r\n });\r\n break;\r\n }\r\n}\r\n\r\nResults.prototype.updateResults = function(){\r\n // Iterate over all Keys in the LocalStorage\r\n for(var i = 0; i < localStorage.length; i++){\r\n if(localStorage.key(i).indexOf(this.prefix) === 0){\r\n var key = localStorage.key(i);\r\n key = key.substr(this.prefix.length);\r\n var tmpResult = new Result(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, key);\r\n tmpResult.setIndex(i);\r\n this.results.push(tmpResult);\r\n }\r\n }\r\n}\r\n\r\nResults.prototype.deleteResults = function(){\r\n var keys = [];\r\n for(var i = 0; i < localStorage.length; i++){\r\n if(localStorage.key(i).indexOf(this.prefix) === 0){\r\n var key = localStorage.key(i);\r\n keys.push(key);\r\n }\r\n }\r\n $.each(keys, function(index, value){\r\n localStorage.removeItem(value);\r\n });\r\n}\r\n\r\nResults.prototype.updateResultPageInterface = function(sortType){\r\n if(this.results.length === 0){\r\n $(\"#savedFokiTabSelector, #savedFoki\").remove();\r\n $($(\"#foki > li[data-loaded=1]\").get(0)).find(\">a\").tab(\"show\");\r\n return;\r\n }\r\n if($(\"#savedFokiTabSelector\").length === 0){\r\n var savedFoki = $('\\\r\n <li id=\"savedFokiTabSelector\" data-loaded=\"1\" class=\"tab-selector\" role=\"presentation\">\\\r\n <a aria-controls=\"savedFoki\" href=\"#savedFoki\" role=\"tab\" data-toggle=\"tab\">\\\r\n <span class=\"glyphicon glyphicon-floppy-disk\"></span> gespeicherte Ergebnisse\\\r\n <span class=\"badge\">' + this.results.length + '</span>\\\r\n </a>\\\r\n </li>\\\r\n ');\r\n $(\"#foki\").append(savedFoki);\r\n }else{\r\n $(\"#savedFokiTabSelector span.badge\").html(this.results.length);\r\n }\r\n if($(\"#savedFoki\").length === 0){\r\n // Now append the Tab Panel\r\n var tabPanel = $('\\\r\n <div role=\"tabpanel\" class=\"tab-pane\" id=\"savedFoki\">\\\r\n </div>\\\r\n ');\r\n $(\"#main-content-tabs\").append(tabPanel);\r\n }else{\r\n $(\"#savedFoki\").html(\"\");\r\n var tabPanel = $(\"#savedFoki\");\r\n }\r\n this.addToContainer(tabPanel, sortType);\r\n}\r\n\r\nResults.prototype.addToContainer = function(container, sortType){\r\n $.each(this.results, function(index, result){\r\n $(container).append(result.toHtml());\r\n });\r\n\r\n var options = $('\\\r\n <div class=\"saver-options row\">\\\r\n <input class=\"form-control\" type=\"text\" placeholder=\"Filtern\">\\\r\n <select class=\"form-control\">\\\r\n <option value=\"chronological\">Chronologisch</option>\\\r\n <option value=\"rank\">MetaGer-Ranking</option>\\\r\n <option value=\"alphabetical\">Alphabetisch (Hostname)</option>\\\r\n </select>\\\r\n <button class=\"btn btn-danger btn-md\"><span class=\"glyphicon glyphicon-trash\"></span> <span class=\"hidden-xs\">Ergebnisse</span> löschen</button>\\\r\n </div>\\\r\n ');\r\n\r\n $(options).find(\"option[value=\" + sortType + \"]\").prop(\"selected\", true);\r\n\r\n $(container).prepend(options);\r\n\r\n $(options).find(\"select\").change(function(){\r\n new Results($(this).val()).updateResultPageInterface();\r\n });\r\n\r\n $(options).find(\"button\").click({caller: this}, function(event){\r\n event.data.caller.deleteResults();\r\n new Results().updateResultPageInterface();\r\n });\r\n\r\n $(options).find(\"input\").keyup(function(){\r\n var search = $(this).val();\r\n $(\"#savedFoki > div.result\").each(function(index, value){\r\n var html = $(this).html();\r\n if(html.toLowerCase().indexOf(search.toLowerCase()) === -1){\r\n $(value).addClass(\"hidden\");\r\n }else{\r\n $(value).removeClass(\"hidden\");\r\n }\r\n });\r\n });\r\n\r\n}\r\n\r\nfunction Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){\r\n this.prefix = \"result_\"; // Präfix for the localStorage so we can find all Items\r\n\r\n if(hash !== null && hash !== undefined){\r\n this.hash = hash;\r\n this.load();\r\n }else{\r\n this.hash = MD5(title + link + anzeigeLink + gefVon + hoster + anonym + description);\r\n\r\n this.title = title;\r\n this.link = link;\r\n this.anzeigeLink = anzeigeLink;\r\n this.gefVon = gefVon;\r\n this.hoster = hoster;\r\n this.anonym = anonym;\r\n this.description = description;\r\n this.color = color;\r\n this.rank = rank;\r\n this.added = new Date().getTime();\r\n var parser = document.createElement('a');\r\n parser.href = this.anzeigeLink;\r\n this.hostname = parser.hostname;\r\n this.save()\r\n }\r\n}\r\n\r\nResult.prototype.load = function(){\r\n if(localStorage){\r\n var result = localStorage.getItem(this. prefix + this.hash);\r\n if(result === null) return false;\r\n result = b64DecodeUnicode(result);\r\n result = JSON.parse(result);\r\n this.title = result.title;\r\n this.link = result.link;\r\n this.anzeigeLink = result.anzeigeLink;\r\n this.gefVon = result.gefVon;\r\n this.hoster = result.hoster;\r\n this.anonym = result.anonym;\r\n this.description = result.description;\r\n this.added = result.added;\r\n this.color = result.color;\r\n this.rank = result.rank;\r\n this.hostname = result.hostname;\r\n return true;\r\n }else{\r\n return false;\r\n }\r\n}\r\n\r\nResult.prototype.save = function(){\r\n /*\r\n * This function will save the data of this Result to the LocalStorage\r\n */\r\n if(localStorage){\r\n\r\n var result = {\r\n title: this.title,\r\n link: this.link,\r\n anzeigeLink: this.anzeigeLink,\r\n gefVon: this.gefVon,\r\n hoster: this.hoster,\r\n anonym: this.anonym,\r\n description: this.description,\r\n added: this.added,\r\n color: this.color,\r\n rank: this.rank,\r\n hostname: this.hostname\r\n };\r\n\r\n result = JSON.stringify(result);\r\n result = b64EncodeUnicode(result);\r\n\r\n localStorage.setItem(this.prefix + this.hash, result);\r\n\r\n return true;\r\n }else{\r\n return false;\r\n }\r\n}\r\n\r\nfunction b64EncodeUnicode(str) {\r\n return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {\r\n return String.fromCharCode('0x' + p1);\r\n }));\r\n}\r\n\r\nfunction b64DecodeUnicode(str) {\r\n return decodeURIComponent(Array.prototype.map.call(atob(str), function(c) {\r\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\r\n }).join(''));\r\n}\r\n\r\n\r\nResult.prototype.setIndex = function(index){\r\n this.index = index;\r\n}\r\n\r\nResult.prototype.remove = function(){\r\n localStorage.removeItem(this.prefix + this.hash);\r\n new Results().updateResultPageInterface();\r\n}\r\n\r\nResult.prototype.toHtml = function(){\r\n var result = $('\\\r\n <div class=\"result row\">\\\r\n <div class=\"col-sm-1 glyphicon glyphicon-trash remover\" title=\"Ergebnis aus dem Speicher löschen\">\\\r\n </div>\\\r\n <div class=\"resultInformation col-xs-12 col-sm-11\">\\\r\n <div class=\"col-xs-10 col-sm-11\" style=\"padding:0; \">\\\r\n <p class=\"title\">\\\r\n <a class=\"title\" href=\"' + this.link + '\" target=\"_blank\" data-hoster=\"' + this.hoster + '\" data-count=\"1\" rel=\"noopener\">\\\r\n ' + this.title + '\\\r\n </a>\\\r\n </p>\\\r\n <div class=\"link\">\\\r\n <div>\\\r\n <div class=\"link-link\">\\\r\n <a href=\"' + this.link + '\" target=\"_blank\" data-hoster=\"' + this.hoster + '\" data-count=\"' + this.index + '\" rel=\"noopener\">\\\r\n ' + this.anzeigeLink + '\\\r\n </a>\\\r\n </div>\\\r\n </div>\\\r\n <span class=\"hoster\">\\\r\n ' + this.gefVon + '\\\r\n </span>\\\r\n <a class=\"proxy\" onmouseover=\"$(this).popover(\\'show\\');\" onmouseout=\"$(this).popover(\\'hide\\');\" data-toggle=\"popover\" data-placement=\"auto right\" data-container=\"body\" data-content=\"Der Link wird anonymisiert geöffnet. Ihre Daten werden nicht zum Zielserver übertragen. Möglicherweise funktionieren manche Webseiten nicht wie gewohnt.\" href=\"' + this.proxy + '\" target=\"_blank\" rel=\"noopener\" data-original-title=\"\" title=\"\">\\\r\n <img src=\"/img/proxyicon.png\" alt=\"\">\\\r\n anonym öffnen\\\r\n </a>\\\r\n </div>\\\r\n </div>\\\r\n <div class=\"description\">' + this.description + '</div>\\\r\n </div>\\\r\n </div>');\r\n $(result).find(\".remover\").click({caller: this}, function(event){\r\n event.data.caller.remove();\r\n });\r\n return result;\r\n}"]}
\ No newline at end of file
$(document).ready(function () {
// checkPlugin()
if (location.href.indexOf('#plugin-modal') > -1) {
$('#plugin-modal').modal('show');
}
$('#addFocusBtn').removeClass('hide');
$('button').popover();
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]);
}
}
if (localStorage.getItem('pers') && !isUseOnce()) {
setSettings();
}
}
setActionListeners();
loadInitialCustomFocuses();
loadSavedResults();
});
function setActionListeners () {
$('button').on('shown.bs.popover', function () {
$('#color-chooser a').click(function () {
var theme = $(this).attr('data-rgba');
if (localStorage) {
localStorage.setItem('theme', theme);
location.href = '/';
}
});
});
$('#mobileFoki').change(function () {
var focus = $('#mobileFoki > option:selected').val();
if (focus == 'angepasst') {
window.location = './settings/';
} else {
window.location = './?focus=' + focus;
}
});
if ($('fieldset#foki.mobile').length) {
$('fieldset#foki.mobile label#anpassen-label').click(function () {
window.location = './settings/';
});
}
$('#addFocusBtn').click(function () {
showFocusCreateDialog('');
});
$('#save-focus-btn').click(saveFocus);
$('#delete-focus-btn').click(deleteFocus);
$('#focus-name').keyup(function (event) {
if (event.keyCode == 13) {
$('#save-focus-btn').click();
}
});
$('#create-focus-modal').on('shown.bs.modal', function () {
$('#focus-name').focus();
});
}
function setSettings () {
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage.getItem(key);
if (key.startsWith('param_') && !key.endsWith('lang') && !key.endsWith('autocomplete')) {
key = key.substring(key.indexOf('param_') + 6);
$('#searchForm').append('<input type="hidden" name="' + key + '" value="' + value + '">');
}
$('#foki input[type=radio]#angepasst').attr('checked', true);
}
if (localStorage.getItem('param_lang') !== null) {
var value = localStorage.getItem('param_lang');
// Change the value of the lang input field to the given parameter
$('input[name=lang]').val(value);
}
if (localStorage.getItem('param_autocomplete') !== null) {
var value = localStorage.getItem('param_autocomplete');
// Change the value of the lang input field to the given parameter
$('input[name=eingabe]').attr('autocomplete', value);
}
if ($('fieldset#foki.mobile').length) {
$('fieldset.mobile input#bilder').val('angepasst');
$('fieldset.mobile input#bilder').prop('checked', true);
$('fieldset.mobile input#bilder').attr('id', 'angepasst');
$('fieldset.mobile label#bilder-label').attr('id', 'anpassen-label');
$('fieldset.mobile label#anpassen-label').attr('for', 'angepasst');
$('fieldset.mobile label#anpassen-label i.fa').attr('class', 'fa fa-cog');
$('fieldset.mobile label#anpassen-label span.content').html('angepasst');
}
}
// Polyfill for form attribute
(function ($) {
/**
* polyfill for html5 form attr
*/
// detect if browser supports this
var sampleElement = $('[form]').get(0);
var isIE11 = !(window.ActiveXObject) && 'ActiveXObject' in window;
if (sampleElement && window.HTMLFormElement && sampleElement.form instanceof HTMLFormElement && !isIE11) {
// browser supports it, no need to fix
return;
}
/**
* Append a field to a form
*
*/
$.fn.appendField = function (data) {
// for form only
if (!this.is('form')) return;
// wrap data
if (!$.isArray(data) && data.name && data.value) {
data = [data];
}
var $form = this;
// attach new params
$.each(data, function (i, item) {
$('<input/>').attr('type', 'hidden').attr('name', item.name).val(item.value).appendTo($form);
});
return $form;
};
/**
* Find all input fields with form attribute point to jQuery object
*
*/
$('form[id]').submit(function (e) {
var $form = $(this);
// serialize data
var data = $('[form=' + $form.attr('id') + ']').serializeArray();
// append data to form
$form.appendField(data);
}).each(function () {
var form = this,
$form = $(form),
$fields = $('[form=' + $form.attr('id') + ']');
$fields.filter('button, input').filter('[type=reset],[type=submit]').click(function () {
var type = this.type.toLowerCase();
if (type === 'reset') {
// reset form
form.reset();
// for elements outside form
$fields.each(function () {
this.value = this.defaultValue;
this.checked = this.defaultChecked;
}).filter('select').each(function () {
$(this).find('option').each(function () {
this.selected = this.defaultSelected;
});
});
} else if (type.match(/^submit|image$/i)) {
$(form).appendField({
name: this.name,
value: this.value
}).submit();
}
});
});
})(jQuery);
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// At least Safari 3+: "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// Internet Explorer 6-11
var isIE = /*@cc_on!@*/ false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
// Prüft, ob der URL-Parameter "usage" auf "once" gesetzt ist.
function isUseOnce () {
var url = document.location.search;
var pos = url.indexOf('usage=');
if (pos >= 0 && url.substring(pos + 6, pos + 11) == 'once') {
return true;
} else {
return false;
}
}
/**
* Loads all the custom focuses stored in local storage
*/
function loadInitialCustomFocuses () {
for (var key in localStorage) {
if (key.startsWith('focus_')) {
var focus = loadFocusById(key);
addFocus(focus.name);
}
}
}
/**
* Shows the focus create dialog
* If an id is given it will try to load a focus for the given id
*/
function showFocusCreateDialog (id) {
if (id === undefined) {
id = '';
}
document.getElementById('original-id').value = id;
$('#create-focus-modal').modal('show');
var storedFocus = loadFocusById(id);
var focus = {};
// Try to load a focus for the given id
$('#focus-name').val('');
uncheckAll();
if (storedFocus !== null) {
try {
focus = JSON.parse(localStorage.getItem(id));
$('#focus-name').val(focus.name);
for (var key in focus) {
if (key.startsWith('engine_')) {
$('.focusCheckbox[name=' + key + ']').prop('checked', true);
}
}
} catch (ex) {
console.error(ex);
}
}
}
/**
* 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) && oldId !== id) {
overwrite = confirm('Name bereits genutzt\nüberschreiben?');
if (overwrite) {
localStorage.removeItem(id);
removeFocusById(id);
}
}
if (overwrite) {
var focus = {};
$('input[type=checkbox]:checked').each(function (el) {
focus[$(this).attr('name')] = $(this).val();
});
focus['name'] = name;
if (oldId !== '') {
localStorage.removeItem(oldId);
removeFocusById(oldId);
}
localStorage.setItem(id, JSON.stringify(focus));
addFocus(name);
$('#create-focus-modal').modal('hide');
}
} else {
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;
if ($('#' + oldId).prop('checked')) {
setFocusToDefault();
}
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));
}
/**
* 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">
* <i class="fa fa-star" aria-hidden="true"></i>
* <span class="content">NAME</span>
* <button class="btn btn-default">
* <i class="fa fa-pencil" aria-hidden="true"></i>
* </button>
* </label>
*/
function addFocus (name) {
var id = getIdFromName(name);
var foki = document.getElementById('foki');
// create <div> to wrap all Elements
var wrapper = document.createElement('div');
wrapper.classList.add('focus');
// create <input>
var newFocus = document.createElement('input');
newFocus.id = id;
newFocus.classList.add('focus-radio');
newFocus.classList.add('custom-focus');
newFocus.classList.add('hide');
newFocus.type = 'radio';
newFocus.name = 'focus';
newFocus.value = id;
newFocus.setAttribute('Form', 'searchForm');
newFocus.checked = true;
newFocus.required = true;
// create <label>
var newFocusLabel = document.createElement('label');
newFocusLabel.id = id + '-label';
newFocusLabel.classList.add('focus-label');
newFocusLabel.classList.add('custom-focus-label');
newFocusLabel.htmlFor = id;
// create <i> icon
var newFocusIcon = document.createElement('i');
newFocusIcon.classList.add('fa');
newFocusIcon.classList.add('fa-star');
newFocusIcon.setAttribute('aria-hidden', 'true');
// create content
var newFocusContent = document.createElement('span');
newFocusIcon.classList.add('content');
newFocusContent.textContent = ' ' + name;
// create edit button
var newFocusEditLink = document.createElement('a');
newFocusEditLink.classList.add('focus-edit');
newFocusEditLink.classList.add('custom-focus-edit');
newFocusEditLink.classList.add('mutelink');
newFocusEditLink.href = '#';
newFocusEditLink.onclick = function () {
showFocusEditDialog(id);
};
var newFocusEditLinkIcon = document.createElement('i');
newFocusEditLinkIcon.classList.add('fa');
newFocusEditLinkIcon.classList.add('fa-pencil');
newFocusEditLinkIcon.setAttribute('aria-hidden', 'true');
// add new elements
var addFocusBtn = document.getElementById('addFocusBtnDiv');
foki.insertBefore(wrapper, addFocusBtn);
wrapper.appendChild(newFocus);
wrapper.appendChild(newFocusLabel);
newFocusLabel.appendChild(newFocusIcon);
newFocusLabel.appendChild(newFocusContent);
wrapper.appendChild(newFocusEditLink);
newFocusEditLink.appendChild(newFocusEditLinkIcon);
}
/**
* 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('_');
name = name.split('ä').join('ae');
name = name.split('ö').join('oe');
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);
}