scriptResultPage.js.map 32.4 KB
Newer Older
1
{"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 () {\n  activateJSOnlyContent();\n  createCustomFocuses();\n  var focus = $('#foki > li.active > a').attr('aria-controls');\n  var custom = $('#foki > li.active').hasClass('custom-focus-tab-selector');\n  getDocumentReadyForUse(focus, custom);\n  botProtection();\n  new Results().updateResultPageInterface();      // Adds the saved Results if they are present\n  if(document.location.href.indexOf(\"focus=container\") !== -1){\n    $($(\"#foki > li#savedFokiTabSelector\").get(0)).find(\">a\").tab(\"show\");\n  }\n});\n\nfunction activateJSOnlyContent () {\n  $('#searchplugin').removeClass('hide');\n  $('.options').removeClass('hide');\n}\n\nfunction tabs () {\n  $('#foki > li.tab-selector > a').each(function () {\n    if ($(this).attr('target') != '_blank') {\n      $(this).attr('href', '#' + $(this).attr('aria-controls'));\n      $(this).attr('role', 'tab');\n      $(this).attr('data-toggle', 'tab');\n    }\n  });\n  $('#foki > li.tab-selector > a').off();\n  $('#foki > li.tab-selector > a').on('show.bs.tab', function (e) {\n    var fokus = $(this).attr('aria-controls');\n    var link = $('#' + fokus + 'TabSelector a').attr('data-href');\n    if ($('#' + fokus + 'TabSelector').attr('data-loaded') != '1') {\n      $.get(link, function (data) {\n        $('#' + fokus + 'TabSelector').attr('data-loaded', '1');\n        $('#' + fokus).html(data);\n        $('input[name=focus]').val($('#foki li.active a').attr('aria-controls'));\n        getDocumentReadyForUse(fokus);\n      });\n    } else {\n      getDocumentReadyForUse(fokus);\n    }\n  });\n}\n\nfunction getDocumentReadyForUse (fokus, custom = false) {\n  clickLog();\n  popovers();\n  if (fokus === 'bilder') imageLoader();\n  if (custom) initialLoadContent(fokus);\n  // pagination()\n  tabs();\n  theme();\n  fokiChanger();\n  pluginInfo();\n  productWidget();\n  $('iframe:not(.resized)').iFrameResize();\n  $('iframe').addClass('resized');\n}\n\nfunction pluginInfo () {\n  if (localStorage) {\n    if (localStorage.getItem('pluginInfo') == 'off') $('#searchplugin').css('display', 'none');\n    $('#searchplugin').on('close.bs.alert', function () {\n      $.get('/pluginClose');\n      localStorage.setItem('pluginInfo', 'off');\n    });\n    $('#searchplugin a.btn').click(function () {\n      $.get('/pluginInstall');\n    });\n  }\n}\n\n\n\nfunction theme () {\n  if (localStorage) {\n    var theme = localStorage.getItem('theme');\n    if (theme != null) {\n      if ((theme.match(/,/g) || []).length != 3) {\n        localStorage.removeItem('theme');\n      } else {\n        theme = theme.split(',');\n        $('#theme').attr('href', '/css/theme.css.php?r=' + theme[0] + '&g=' + theme[1] + '&b=' + theme[2] + '&a=' + theme[3]);\n      }\n    }\n  }\n}\n\nfunction clickLog () {\n  $('.result a.title, .result div.link-link a').off();\n  $('.result a.title, .result div.link-link a').click(function () {\n    $.get('/clickstats', {\n      i: $('meta[name=p]').attr('content'),\n      s: $(this).attr('data-hoster'),\n      q: $('meta[name=q]').attr('content'),\n      p: $(this).attr('data-count'),\n      url: $(this).attr('href')\n    });\n  });\n}\n\nfunction botProtection () {\n  if ($('meta[name=pqr]').length > 0) {\n    var link = atob($('meta[name=pqr]').attr('content'));\n    var hash = $('meta[name=pq]').attr('content');\n    document.location.href = link + '&bot=' + hash;\n  }\n}\n\nfunction popovers () {\n  $('[data-toggle=popover]').each(function (e) {\n    $(this).popover('destroy');\n    $(this).popover({\n      // html          :   true,\n      // title         :   \"<i class=\"fa fa-cog\" aria-hidden=\"true\"></i> Optionen\",\n      content: $(this).parent().find('.content').html()\n    });\n  });\n}\n\nfunction pagination () {\n  $('.pagination li:not(.active) > a').attr('href', '#');\n  $('.pagination li.disabled > a').removeAttr('href');\n  $('.pagination li:not(.active) > a').off();\n  $('.pagination li:not(.active) > a').click(paginationHandler);\n}\n\nfunction paginationHandler () {\n  var link = $(this).attr('data-href');\n  if (link.length == 0) {\n    return;\n  }\n  var tabPane = $('.tab-pane.active');\n  $(tabPane).html('<div class=\"loader\"><img src=\"/img/ajax-loader.gif\" alt=\"\" /></div>');\n  $.get(link, function (data) {\n    $(tabPane).html(data);\n    $('.pagination li:not(.active) > a').attr('href', '#');\n    $('.pagination li.disabled > a').removeAttr('href');\n    $('.pagination li:not(.active) > a').off();\n    $('.pagination li:not(.active) > a').click(paginationHandler);\n    getDocumentReadyForUse();\n  });\n}\n\nfunction imageLoader () {\n  if (typeof $('#container').masonry == 'undefined') {\n    return;\n  }\n  var $grid = $('#container').masonry({\n    columnWidth: 150,\n    itemSelector: '.item',\n    gutter: 10,\n    isFitWidth: true\n  });\n  $grid.imagesLoaded().progress(function (instance, image) {\n    $grid.masonry('layout');\n  });\n}\n\nfunction eliminateHost (host) {\n  $('.result:not(.ad)').each(function (e) {\n    var host2 = $(this).find('.link-link > a').attr('data-host');\n    if (host2.indexOf(host) === 0) {\n      $(this).css('display', 'none');\n    }\n  });\n}\n\nfunction fokiChanger () {\n  $('#fokiChanger ul > li').click(function () {\n    document.location.href = $(this).attr('data-href');\n  });\n}\n// Polyfill for form attribute\n(function ($) {\n  /**\n   * polyfill for html5 form attr\n   */\n  // detect if browser supports this\n  var sampleElement = $('[form]').get(0);\n  var isIE11 = !(window.ActiveXObject) && 'ActiveXObject' in window;\n  if (sampleElement && window.HTMLFormElement && sampleElement.form instanceof HTMLFormElement && !isIE11) {\n    // browser supports it, no need to fix\n    return;\n  }\n  /**\n   * Append a field to a form\n   *\n   */\n  $.fn.appendField = function (data) {\n    // for form only\n    if (!this.is('form')) return;\n    // wrap data\n    if (!$.isArray(data) && data.name && data.value) {\n      data = [data];\n    }\n    var $form = this;\n    // attach new params\n    $.each(data, function (i, item) {\n      $('<input/>').attr('type', 'hidden').attr('name', item.name).val(item.value).appendTo($form);\n    });\n    return $form;\n  };\n  /**\n   * Find all input fields with form attribute point to jQuery object\n   * \n   */\n  $('form[id]').submit(function (e) {\n    var $form = $(this);\n    // serialize data\n    var data = $('[form=' + $form.attr('id') + ']').serializeArray();\n    // append data to form\n    $form.appendField(data);\n  }).each(function () {\n    var form = this,\n      $form = $(form),\n      $fields = $('[form=' + $form.attr('id') + ']');\n    $fields.filter('button, input').filter('[type=reset],[type=submit]').click(function () {\n      var type = this.type.toLowerCase();\n      if (type === 'reset') {\n        // reset form\n        form.reset();\n        // for elements outside form\n        $fields.each(function () {\n          this.value = this.defaultValue;\n          this.checked = this.defaultChecked;\n        }).filter('select').each(function () {\n          $(this).find('option').each(function () {\n            this.selected = this.defaultSelected;\n          });\n        });\n      } else if (type.match(/^submit|image$/i)) {\n        $(form).appendField({\n          name: this.name,\n          value: this.value\n        }).submit();\n      }\n    });\n  });\n})(jQuery);\n\nfunction productWidget () {\n  var isMobile = false; // initiate as false\n  // device detection\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;\n  if (isMobile) {\n    $('.lightSlider').lightSlider({\n      item: 5,\n      loop: false,\n      slideMove: 2,\n      easing: 'cubic-bezier(0.25, 0, 0.25, 1)',\n      speed: 600,\n      pager: false,\n      prevHtml: '<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i><span class=\"sr-only\">Previous</span>',\n      nextHtml: '<i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i><span class=\"sr-only\">Next</span>',\n      responsive: [{\n        breakpoint: 1400,\n        settings: {\n          item: 4,\n          slideMove: 2\n        }\n      }, {\n        breakpoint: 1200,\n        settings: {\n          item: 3,\n          slideMove: 2\n        }\n      }, {\n        breakpoint: 980,\n        settings: {\n          item: 4,\n          slideMove: 2\n        }\n      }, {\n        breakpoint: 720,\n        settings: {\n          item: 3,\n          slideMove: 1\n        }\n      }, {\n        breakpoint: 520,\n        settings: {\n          item: 2,\n          slideMove: 1\n        }\n      } ]\n    });\n  } else {\n    $('.lightSlider').lightSlider({\n      item: 5,\n      loop: false,\n      slideMove: 2,\n      easing: 'cubic-bezier(0.25, 0, 0.25, 1)',\n      speed: 600,\n      pager: false,\n      enableTouch: false,\n      enableDrag: false,\n      prevHtml: '<i class=\"fa fa-chevron-left\" aria-hidden=\"true\"></i><span class=\"sr-only\">Previous</span>',\n      nextHtml: '<i class=\"fa fa-chevron-right\" aria-hidden=\"true\"></i><span class=\"sr-only\">Next</span>',\n      responsive: [{\n        breakpoint: 1400,\n        settings: {\n          item: 4,\n          slideMove: 2\n        }\n      }, {\n        breakpoint: 1200,\n        settings: {\n          item: 3,\n          slideMove: 2\n        }\n      }, {\n        breakpoint: 980,\n        settings: {\n          item: 4,\n          slideMove: 2\n        }\n      }, {\n        breakpoint: 720,\n        settings: {\n          item: 3,\n          slideMove: 1\n        }\n      }, {\n        breakpoint: 520,\n        settings: {\n          item: 2,\n          slideMove: 1\n        }\n      } ]\n    });\n  }\n  $('.lightSliderContainer').removeClass('hidden');\n}\n/**\n * Creates focus tab and tab selector for every stored focus in local storage\n */\nfunction createCustomFocuses () {\n  for (var key in localStorage) {\n    if (key.startsWith('focus_')) {\n      var focus = loadFocusById(key);\n      var active = false;\n      if (getActiveFocusId() === getIdFromName(focus.name)) {\n        active = true;\n      }\n      addFocus(focus, active);\n      addTab(focus, active);\n    }\n  }\n}\n/**\n * Adds a focuses tab selector to the tab selector section\n * \n * @if( $metager->getFokus() === \"produktsuche\" )\n *     <li id=\"produktsucheTabSelector\" class=\"active tab-selector\" role=\"presentation\" data-loaded=\"1\">\n *        <a aria-controls=\"produktsuche\" data-href=\"#produktsuche\" href=\"#produktsuche\">\n *             <i class=\"fa fa-shopping-cart\" aria-hidden=\"true\"></i>\n *             <span class=\"hidden-xs\">{{ trans('index.foki.produkte') }}</span>\n *         </a>\n *     </li>\n * @else\n *     <li id=\"produktsucheTabSelector\" class=\"tab-selector\" role=\"presentation\" data-loaded=\"0\">\n *         <a aria-controls=\"produktsuche\" data-href=\"{!! $metager->generateSearchLink('produktsuche') !!}\" href=\"{!! $metager->generateSearchLink('produktsuche', false) !!}\">\n *             <i class=\"fa fa-shopping-cart\" aria-hidden=\"true\"></i>\n *             <span class=\"hidden-xs\">{{ trans('index.foki.produkte') }}</span>\n *         </a>\n *     </li>\n * @endif\n */\nfunction addFocus (focus, active = false) {\n  var id = getIdFromName(focus.name);\n  var foki = document.getElementById('foki');\n  // create <input>\n  var focusElement = document.createElement('li');\n  focusElement.id = id + 'TabSelector';\n  focusElement.classList.add('tab-selector');\n  focusElement.classList.add('custom-focus-tab-selector');\n  if (active) {\n    focusElement.classList.add('active');\n    focusElement.setAttribute('data-loaded', '1');\n  } else {\n    focusElement.setAttribute('data-loaded', '0');\n  }\n  focusElement.setAttribute('role', 'presentation');\n  // create <a>\n  var focusElementLink = document.createElement('a');\n  focusElementLink.setAttribute('aria-controls', id);\n  var searchLink = generateSearchLinkForFocus(focus);\n  focusElementLink.setAttribute('data-href', searchLink);\n  focusElementLink.setAttribute('href', searchLink);\n  // create <a> icon\n  var focusElementIcon = document.createElement('i');\n  focusElementIcon.classList.add('fa');\n  focusElementIcon.classList.add('fa-star');\n  focusElementIcon.setAttribute('aria-hidden', 'true');\n  // create <span> focusname\n  var focusElementName = document.createElement('span');\n  focusElementName.classList.add('hidden-xs');\n  focusElementName.innerHTML = focus.name;\n  // add new elements\n  var mapsTabSelector = document.getElementById('mapsTabSelector');\n  foki.insertBefore(focusElement, mapsTabSelector);\n  focusElement.appendChild(focusElementLink);\n  focusElementLink.appendChild(focusElementIcon);\n  focusElementLink.appendChild(focusElementName);\n}\n/**\n * Adds a focuses tab to the tab section\n * \n * @if( $metager->getFokus() === \"produktsuche\" )\n *     <div role=\"tabpanel\" class=\"tab-pane active\" id=\"produktsuche\">\n *         <div class=\"row\">\n *                 @yield('results')\n *         </div>\n *      </div>\n * @else\n *     <div role=\"tabpanel\" class=\"tab-pane\" id=\"produktsuche\">\n *         <div class=\"loader\">\n *             <img src=\"/img/ajax-loader.gif\" alt=\"\" />\n *         </div>\n *     </div>\n * @endif\n */\nfunction addTab (focus, active = false) {\n  var id = getIdFromName(focus.name);\n  // create tab div\n  var tabPane = document.createElement('div');\n  tabPane.id = id;\n  tabPane.classList.add('tab-pane');\n  if (active) {\n    tabPane.classList.add('active');\n  }\n  tabPane.setAttribute('role', 'tabpanel');\n  // create row div\n  var row = document.createElement('div');\n  row.classList.add('loader');\n  // create loader image\n  var img = document.createElement('img');\n  img.setAttribute('src', '/img/ajax-loader.gif');\n  img.setAttribute('alt', '');\n  row.appendChild(img);\n  // add new elements\n  var tabs = document.getElementById('main-content-tabs');\n  tabs.appendChild(tabPane);\n  tabPane.appendChild(row);\n}\n/**\n * Turns a name into an id\n * Converts special characters and spaces\n */\nfunction getIdFromName (name) {\n  return 'focus_' + name.split(' ').join('_').toLowerCase();\n}\n/**\n * Loads the focus object for the given id from local storage\n */\nfunction loadFocusById (id) {\n  return JSON.parse(localStorage.getItem(id));\n}\n/**\n * Gets the id of the currently active focus\n */\nfunction getActiveFocusId () {\n  var search = window.location.search;\n  var from = search.indexOf('focus=') + 'focus='.length;\n  var to = search.substring(from).indexOf('&') + from;\n  if (to <= 0) {\n    to = search.substring(from).length;\n  }\n  return search.substring(from, to);\n}\n/**\n * Turns the link of the current page into a search link for the given focus\n */\n// TODO catch error if link is http://localhost:8000/meta/meta.ger3?\nfunction generateSearchLinkForFocus (focus) {\n  var link = document.location.href;\n  // remove old engine settings\n  // not yet tested, only for compability problems with old versions of bookmarks and plugins\n  /*\n  while (link.indexOf(\"engine_\") !== -1) {\n      var from = search.indexOf(\"engine_\")\n      var to = search.substring(from).indexOf(\"&\") + from\n      if (to === 0) {\n          to = search.substring(from).length\n      }\n      link = link.substring(0, from) + link.substring(to)\n  }\n  */\n  // add new engine settings\n  for (var key in focus) {\n    if (key.startsWith('engine_')) {\n      var focusName = key.substring('engine_'.length);\n      link += '&' + focusName + '=' + focus[key];\n    }\n  }\n  link += '&out=results';\n  link = replaceFocusInUrl(link);\n  return link;\n}\n/**\n * Replaces the focus in a given url with the \"angepasst\" focus\n */\nfunction replaceFocusInUrl (url) {\n  var from = url.indexOf('focus=');\n  var to = url.substring(from).indexOf('&') + from;\n  if (to === 0) {\n    to = url.substring(from).length;\n  }\n  url = url.substring(0, from) + url.substring(to);\n  return url + '&focus=angepasst';\n}\n/**\n * Loads the content for a given fokus\n */\nfunction initialLoadContent (fokus) {\n  var link = $('#' + fokus + 'TabSelector a').attr('data-href');\n  $.get(link, function (data) {\n    $('#' + fokus).html(data);\n    getDocumentReadyForUse(fokus);\n  });\n}\n\nfunction resultSaver(index) {\n  var title = $(\".result[data-count=\" + index + \"] a.title\").html();\n  var link = $(\".result[data-count=\" + index + \"] a.title\").attr(\"href\");\n  var anzeigeLink = $(\".result[data-count=\" + index + \"] div.link-link > a\").html();\n  var gefVon = $(\".result[data-count=\" + index + \"] span.hoster\").html();\n  var hoster =  $(\".result[data-count=\" + index + \"] a.title\").attr(\"data-hoster\");\n  var anonym = $(\".result[data-count=\" + index + \"] a.proxy\").attr(\"href\");\n  var description = $(\".result[data-count=\" + index + \"] div.description\").html();\n  var color = $(\".result[data-count=\" + index + \"] div.number\").css(\"color\");\n  var rank = parseFloat($(\".result[data-count=\" + index + \"]\").attr(\"data-rank\"));\n  new Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, undefined);\n  var to = $(\"#savedFokiTabSelector\").length ? $(\"#savedFokiTabSelector\") : $(\"#foki\");\n  $(\".result[data-count=\" + index + \"]\").transfer({to: to, duration: 1000});\n  new Results().updateResultPageInterface();\n}\n","/*\n * This object gathers all stored Result Objects and can Update the Interface to show them.\n*/\nfunction Results(sort){\n  if(!localStorage) return;\n  this.prefix = \"result_\";\n  this.results = [];\n  this.updateResults();\n  this.length = this.results.length;\n  this.sortResults(sort);\n}\n\nResults.prototype.sortResults = function(sortType){\n  if(sortType === undefined) sortType = \"chronological\";\n  switch(sortType){\n    case \"chronological\":\n      this.results.sort(function(a,b){\n        if(a.added > b.added) return -1;\n        if(a.added < b.added) return 1;\n        return 0;\n      });\n      break;\n    case \"rank\":\n      this.results.sort(function(a,b){\n        if(a.rank > b.rank) return -1;\n        if(a.rank < b.rank) return 1;\n        return 0;\n      });\n      break;\n    case \"alphabetical\":\n      this.results.sort(function(a,b){\n        if(b.hostname > a.hostname) return -1;\n        if(b.hostname < a.hostname) return 1;\n        return 0;\n      });\n      break;\n  }\n}\n\nResults.prototype.updateResults = function(){\n  // Iterate over all Keys in the LocalStorage\n  for(var i = 0; i < localStorage.length; i++){\n    if(localStorage.key(i).indexOf(this.prefix) === 0){\n      var key = localStorage.key(i);\n      key = key.substr(this.prefix.length);\n      var tmpResult = new Result(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, key);\n      tmpResult.setIndex(i);\n      this.results.push(tmpResult);\n    }\n  }\n}\n\nResults.prototype.deleteResults = function(){\n  var keys = [];\n  for(var i = 0; i < localStorage.length; i++){\n    if(localStorage.key(i).indexOf(this.prefix) === 0){\n      var key = localStorage.key(i);\n      keys.push(key);\n    }\n  }\n  $.each(keys, function(index, value){\n    localStorage.removeItem(value);\n  });\n}\n\nResults.prototype.updateResultPageInterface = function(sortType){\n  if(this.results.length === 0){\n    $(\"#savedFokiTabSelector, #savedFoki\").remove();\n    $($(\"#foki > li[data-loaded=1]\").get(0)).find(\">a\").tab(\"show\");\n    return;\n  }\n  if($(\"#savedFokiTabSelector\").length === 0){\n    var savedFoki = $('\\\n      <li id=\"savedFokiTabSelector\" data-loaded=\"1\" class=\"tab-selector\" role=\"presentation\">\\\n        <a aria-controls=\"savedFoki\" href=\"#savedFoki\" role=\"tab\" data-toggle=\"tab\">\\\n          <span class=\"glyphicon glyphicon-floppy-disk\"></span> gespeicherte Ergebnisse\\\n          <span class=\"badge\">' + this.results.length + '</span>\\\n        </a>\\\n      </li>\\\n      ');\n    $(\"#foki\").append(savedFoki);\n  }else{\n    $(\"#savedFokiTabSelector span.badge\").html(this.results.length);\n  }\n    if($(\"#savedFoki\").length === 0){\n      // Now append the Tab Panel\n      var tabPanel = $('\\\n        <div role=\"tabpanel\" class=\"tab-pane\" id=\"savedFoki\">\\\n        </div>\\\n        ');\n      $(\"#main-content-tabs\").append(tabPanel);\n    }else{\n      $(\"#savedFoki\").html(\"\");\n      var tabPanel = $(\"#savedFoki\");\n    }\n    this.addToContainer(tabPanel, sortType);\n}\n\nResults.prototype.addToContainer = function(container, sortType){\n  $.each(this.results, function(index, result){\n    $(container).append(result.toHtml());\n  });\n\n  var options = $('\\\n      <div class=\"saver-options row\">\\\n          <input class=\"form-control\" type=\"text\" placeholder=\"Filtern\">\\\n          <select class=\"form-control\">\\\n            <option value=\"chronological\">Chronologisch</option>\\\n            <option value=\"rank\">MetaGer-Ranking</option>\\\n            <option value=\"alphabetical\">Alphabetisch (Hostname)</option>\\\n          </select>\\\n          <button class=\"btn btn-danger btn-md\"><span class=\"glyphicon glyphicon-trash\"></span> <span class=\"hidden-xs\">Ergebnisse</span> löschen</button>\\\n      </div>\\\n    ');\n\n  $(options).find(\"option[value=\" + sortType + \"]\").prop(\"selected\", true);\n\n  $(container).prepend(options);\n\n  $(options).find(\"select\").change(function(){\n    new Results($(this).val()).updateResultPageInterface();\n  });\n\n  $(options).find(\"button\").click({caller: this}, function(event){\n      event.data.caller.deleteResults();\n      new Results().updateResultPageInterface();\n  });\n\n  $(options).find(\"input\").keyup(function(){\n    var search = $(this).val();\n    $(\"#savedFoki > div.result\").each(function(index, value){\n      var html = $(this).html();\n      if(html.toLowerCase().indexOf(search.toLowerCase()) === -1){\n        $(value).addClass(\"hidden\");\n      }else{\n        $(value).removeClass(\"hidden\");\n      }\n    });\n  });\n\n}\n\nfunction Result(title, link, anzeigeLink, gefVon, hoster, anonym, description, color, rank, hash){\n  this.prefix = \"result_\";  // Präfix for the localStorage so we can find all Items\n\n  if(hash !== null && hash !== undefined){\n    this.hash = hash;\n    this.load();\n  }else{\n    this.hash = MD5(title + link + anzeigeLink + gefVon + hoster + anonym + description);\n\n    this.title = title;\n    this.link = link;\n    this.anzeigeLink = anzeigeLink;\n    this.gefVon = gefVon;\n    this.hoster = hoster;\n    this.anonym = anonym;\n    this.description = description;\n    this.color = color;\n    this.rank = rank;\n    this.added = new Date().getTime();\n    var parser = document.createElement('a');\n    parser.href = this.anzeigeLink;\n    this.hostname = parser.hostname;\n    this.save()\n  }\n}\n\nResult.prototype.load = function(){\n  if(localStorage){\n    var result = localStorage.getItem(this. prefix + this.hash);\n    if(result === null) return false;\n    result = b64DecodeUnicode(result);\n    result = JSON.parse(result);\n    this.title = result.title;\n    this.link = result.link;\n    this.anzeigeLink = result.anzeigeLink;\n    this.gefVon = result.gefVon;\n    this.hoster = result.hoster;\n    this.anonym = result.anonym;\n    this.description = result.description;\n    this.added = result.added;\n    this.color = result.color;\n    this.rank = result.rank;\n    this.hostname = result.hostname;\n    return true;\n  }else{\n    return false;\n  }\n}\n\nResult.prototype.save = function(){\n  /*\n  * This function will save the data of this Result to the LocalStorage\n  */\n  if(localStorage){\n\n    var result = {\n      title: this.title,\n      link: this.link,\n      anzeigeLink: this.anzeigeLink,\n      gefVon: this.gefVon,\n      hoster: this.hoster,\n      anonym: this.anonym,\n      description: this.description,\n      added: this.added,\n      color: this.color,\n      rank: this.rank,\n      hostname: this.hostname\n    };\n\n    result = JSON.stringify(result);\n    result = b64EncodeUnicode(result);\n\n    localStorage.setItem(this.prefix + this.hash, result);\n\n    return true;\n  }else{\n    return false;\n  }\n}\n\nfunction b64EncodeUnicode(str) {\n    return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {\n        return String.fromCharCode('0x' + p1);\n    }));\n}\n\nfunction b64DecodeUnicode(str) {\n    return decodeURIComponent(Array.prototype.map.call(atob(str), function(c) {\n        return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n    }).join(''));\n}\n\n\nResult.prototype.setIndex = function(index){\n  this.index = index;\n}\n\nResult.prototype.remove = function(){\n  localStorage.removeItem(this.prefix + this.hash);\n  new Results().updateResultPageInterface();\n}\n\nResult.prototype.toHtml = function(){\n  var result = $('\\\n    <div class=\"result row\">\\\n      <div class=\"col-sm-1 glyphicon glyphicon-trash remover\" title=\"Ergebnis aus dem Speicher löschen\">\\\n      </div>\\\n      <div class=\"resultInformation col-xs-12 col-sm-11\">\\\n        <div class=\"col-xs-10 col-sm-11\" style=\"padding:0; \">\\\n          <p class=\"title\">\\\n            <a class=\"title\" href=\"' + this.link + '\" target=\"_blank\" data-hoster=\"' + this.hoster + '\" data-count=\"1\" rel=\"noopener\">\\\n              ' + this.title + '\\\n            </a>\\\n          </p>\\\n          <div class=\"link\">\\\n            <div>\\\n              <div class=\"link-link\">\\\n                <a href=\"' + this.link + '\" target=\"_blank\" data-hoster=\"' + this.hoster + '\" data-count=\"' + this.index + '\" rel=\"noopener\">\\\n                  ' + this.anzeigeLink + '\\\n                </a>\\\n            </div>\\\n          </div>\\\n          <span class=\"hoster\">\\\n            ' + this.gefVon + '\\\n          </span>\\\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=\"\">\\\n            <img src=\"/img/proxyicon.png\" alt=\"\">\\\n            anonym öffnen\\\n          </a>\\\n        </div>\\\n      </div>\\\n      <div class=\"description\">' + this.description + '</div>\\\n      </div>\\\n    </div>');\n  $(result).find(\".remover\").click({caller: this}, function(event){\n    event.data.caller.remove();\n  });\n  return result;\n}"]}