scriptResultPage.js.map 34 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 () {\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}"]}