Commit 36c17c5f authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch '690-spruche-im-standard-anzeigen' into 'development'

Resolve "Sprüche im standard anzeigen"

Closes #690

See merge request !1192
parents e2b43721 7de9b5de
......@@ -13,8 +13,9 @@ $(document).ready(function () {
if (localStorage.hasOwnProperty('param_sprueche')) {
var sprueche = localStorage.getItem('param_sprueche') === 'on'; // check for sprueche local storage parameter
} else {
var sprueche = getURLParameter('sprueche') === 'on'; // load the sprueche url parameter
var sprueche = getURLParameter('sprueche', 'on') === 'on'; // load the sprueche url parameter
}
var search = getMetaTag('q') || '';
var locale = getMetaTag('l') || 'de';
loadQuicktips(search, locale, sprueche); // load the quicktips
......@@ -26,11 +27,11 @@ function readLocaleFromUrl (defaultLocale) {
}
*/
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
function getURLParameter (name, defaultValue) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || defaultValue;
}
function getMetaTag(name) {
function getMetaTag (name) {
if (typeof $('meta[name="' + name + '"')[0] !== 'undefined') {
return $('meta[name="' + name + '"')[0].content || null;
} else {
......@@ -38,12 +39,12 @@ function getMetaTag(name) {
}
}
function activateJSOnlyContent() {
function activateJSOnlyContent () {
$('#searchplugin').removeClass('hide');
$('.js-only').removeClass('js-only');
}
function tabs() {
function tabs () {
$('#foki > li.tab-selector > a').each(function () {
if ($(this).attr('target') != '_blank') {
$(this).attr('href', '#' + $(this).attr('aria-controls'));
......@@ -68,8 +69,8 @@ function tabs() {
});
}
function getDocumentReadyForUse(fokus, custom) {
if (typeof custom == "undefined") custom = false;
function getDocumentReadyForUse (fokus, custom) {
if (typeof custom == 'undefined') custom = false;
activateJSOnlyContent();
clickLog();
popovers();
......@@ -84,7 +85,7 @@ function getDocumentReadyForUse(fokus, custom) {
$('iframe').addClass('resized');
}
function pluginInfo() {
function pluginInfo () {
if (localStorage) {
if (localStorage.getItem('pluginInfo') == 'off') $('#searchplugin').css('display', 'none');
$('#searchplugin').on('close.bs.alert', function () {
......@@ -97,7 +98,7 @@ function pluginInfo() {
}
}
function theme() {
function theme () {
if (localStorage) {
var theme = localStorage.getItem('theme');
if (theme != null) {
......@@ -111,7 +112,7 @@ function theme() {
}
}
function clickLog() {
function clickLog () {
$('.result a.title, .result div.link-link a').off();
$('.result a.title, .result div.link-link a').click(function () {
$.get('/clickstats', {
......@@ -124,7 +125,7 @@ function clickLog() {
});
}
function botProtection() {
function botProtection () {
if ($('meta[name=pqr]').length > 0) {
var link = atob($('meta[name=pqr]').attr('content'));
var hash = $('meta[name=pq]').attr('content');
......@@ -132,7 +133,7 @@ function botProtection() {
}
}
function popovers() {
function popovers () {
$('[data-toggle=popover]').each(function (e) {
$(this).popover({
// html : true,
......@@ -142,14 +143,14 @@ function popovers() {
});
}
function pagination() {
function pagination () {
$('.pagination li:not(.active) > a').attr('href', '#');
$('.pagination li.disabled > a').removeAttr('href');
$('.pagination li:not(.active) > a').off();
$('.pagination li:not(.active) > a').click(paginationHandler);
}
function paginationHandler() {
function paginationHandler () {
var link = $(this).attr('data-href');
if (link.length == 0) {
return;
......@@ -166,7 +167,7 @@ function paginationHandler() {
});
}
function imageLoader() {
function imageLoader () {
if (typeof $('#container').masonry == 'undefined') {
return;
}
......@@ -181,7 +182,7 @@ function imageLoader() {
});
}
function eliminateHost(host) {
function eliminateHost (host) {
$('.result:not(.ad)').each(function (e) {
var host2 = $(this).find('.link-link > a').attr('data-host');
if (host2.indexOf(host) === 0) {
......@@ -190,7 +191,7 @@ function eliminateHost(host) {
});
}
function fokiChanger() {
function fokiChanger () {
$('#fokiChanger ul > li').click(function () {
document.location.href = $(this).attr('data-href');
});
......@@ -266,7 +267,7 @@ function fokiChanger() {
/**
* Creates focus tab and tab selector for every stored focus in local storage
*/
function createCustomFocuses() {
function createCustomFocuses () {
for (var key in localStorage) {
if (key.startsWith('focus_')) {
var focus = loadFocusById(key);
......@@ -298,8 +299,8 @@ function createCustomFocuses() {
* </li>
* @endif
*/
function addFocus(focus, active) {
if (typeof active == "undefined") active = false;
function addFocus (focus, active) {
if (typeof active == 'undefined') active = false;
var id = getIdFromName(focus.name);
var foki = document.getElementById('foki');
// create <input>
......@@ -353,8 +354,8 @@ function addFocus(focus, active) {
* </div>
* @endif
*/
function addTab(focus, active) {
if (typeof active == "undefined") active = false;
function addTab (focus, active) {
if (typeof active == 'undefined') active = false;
var id = getIdFromName(focus.name);
// create tab div
var tabPane = document.createElement('div');
......@@ -381,19 +382,19 @@ function addTab(focus, active) {
* Turns a name into an id
* Converts special characters and spaces
*/
function getIdFromName(name) {
function getIdFromName (name) {
return 'focus_' + name.split(' ').join('_').toLowerCase();
}
/**
* Loads the focus object for the given id from local storage
*/
function loadFocusById(id) {
function loadFocusById (id) {
return JSON.parse(localStorage.getItem(id));
}
/**
* Gets the id of the currently active focus
*/
function getActiveFocusId() {
function getActiveFocusId () {
var search = window.location.search;
var from = search.indexOf('focus=') + 'focus='.length;
var to = search.substring(from).indexOf('&') + from;
......@@ -406,7 +407,7 @@ function getActiveFocusId() {
* Turns the link of the current page into a search link for the given focus
*/
// TODO catch error if link is http://localhost:8000/meta/meta.ger3?
function generateSearchLinkForFocus(focus) {
function generateSearchLinkForFocus (focus) {
var link = document.location.href;
// remove old engine settings
// not yet tested, only for compability problems with old versions of bookmarks and plugins
......@@ -434,7 +435,7 @@ function generateSearchLinkForFocus(focus) {
/**
* Replaces the focus in a given url with the "angepasst" focus
*/
function replaceFocusInUrl(url) {
function replaceFocusInUrl (url) {
var from = url.indexOf('focus=');
var to = url.substring(from).indexOf('&') + from;
if (to === 0) {
......@@ -446,7 +447,7 @@ function replaceFocusInUrl(url) {
/**
* Loads the content for a given fokus
*/
function initialLoadContent(fokus) {
function initialLoadContent (fokus) {
var link = $('#' + fokus + 'TabSelector a').attr('data-href');
$.get(link, function (data) {
$('#' + fokus).html(data);
......@@ -454,7 +455,7 @@ function initialLoadContent(fokus) {
});
}
function resultSaver(index) {
function resultSaver (index) {
var title = $('div.tab-pane.active .result[data-count=' + index + '] a.title').html();
var link = $('div.tab-pane.active .result[data-count=' + index + '] a.title').attr('href');
var anzeigeLink = $('div.tab-pane.active .result[data-count=' + index + '] div.link-link > a').html();
......@@ -473,7 +474,7 @@ function resultSaver(index) {
new Results().updateResultPageInterface();
}
function loadQuicktips(search, locale, sprueche) {
function loadQuicktips (search, locale, sprueche) {
var blacklist = [];
if (!sprueche) {
blacklist.push('sprueche');
......@@ -482,7 +483,7 @@ function loadQuicktips(search, locale, sprueche) {
}
const QUICKTIP_SERVER = 'https://quicktips.metager3.de';
//const QUICKTIP_SERVER = 'http://localhost:63825';
// const QUICKTIP_SERVER = 'http://localhost:63825'
/**
* Requests quicktips from the quicktip server and passes them to the loadedHandler
......@@ -492,7 +493,7 @@ const QUICKTIP_SERVER = 'https://quicktips.metager3.de';
* @param {Array<String>} blacklist excluded loaders
* @param {Function} loadedHandler handler for loaded quicktips
*/
function getQuicktips(search, locale, blacklist, loadedHandler) {
function getQuicktips (search, locale, blacklist, loadedHandler) {
var getString = QUICKTIP_SERVER + '/quicktips.xml?search=' + search + '&locale=' + locale;
blacklist.forEach(function (value) {
getString += '&loader_' + value + '=false';
......@@ -504,7 +505,7 @@ function getQuicktips(search, locale, blacklist, loadedHandler) {
type: $(this).children('mg\\:type').text(),
title: $(this).children('title').text(),
summary: $(this).children('content').text(),
url: $(this).children('link').attr("href"),
url: $(this).children('link').attr('href'),
gefVon: $(this).children('mg\\:gefVon').text(),
score: $(this).children('relevance\\:score').text(),
details: $(this).children('mg\\:details').children('entry').map(function () {
......@@ -546,7 +547,7 @@ function getQuicktips(search, locale, blacklist, loadedHandler) {
*
* @param {Object} quicktips
*/
function createQuicktips(quicktips, sprueche) {
function createQuicktips (quicktips, sprueche) {
var quicktipsDiv = $('#quicktips');
quicktips.sort(function (a, b) {
return b.score - a.score;
......@@ -597,4 +598,4 @@ function createQuicktips(quicktips, sprueche) {
.append('<span class="gefVon">' + quicktip.gefVon + '</span>');
quicktipsDiv.append(quicktipDiv);
});
}
\ No newline at end of file
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment