Commit 241178e8 authored by Karl Hasselbring's avatar Karl Hasselbring
Browse files

Made sprueche quicktip optional

Added quicktip blacklist
parent d4291f89
...@@ -10,9 +10,17 @@ $(document).ready(function () { ...@@ -10,9 +10,17 @@ $(document).ready(function () {
$($('#foki > li#savedFokiTabSelector').get(0)).find('>a').tab('show'); $($('#foki > li#savedFokiTabSelector').get(0)).find('>a').tab('show');
} }
loadQuicktips('test', 'de', true); // TODO var sprueche = getURLParameter('sprueche') === 'on'; // load the sprueche url parameter
if (localStorage.hasOwnProperty('param_sprueche')) {
sprueche = localStorage.getItem('param_sprueche') === 'on'; // check for sprueche local storage parameter
}
loadQuicktips('test', 'de', sprueche); // load the quicktips
}); });
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}
function activateJSOnlyContent () { function activateJSOnlyContent () {
$('#searchplugin').removeClass('hide'); $('#searchplugin').removeClass('hide');
$('.js-only').removeClass('js-only'); $('.js-only').removeClass('js-only');
...@@ -537,35 +545,45 @@ function resultSaver (index) { ...@@ -537,35 +545,45 @@ function resultSaver (index) {
} }
function loadQuicktips (search, locale, sprueche) { function loadQuicktips (search, locale, sprueche) {
getQuicktips(search, locale, sprueche, createQuicktips); var blacklist = [];
if (!sprueche) {
blacklist.push('sprueche');
}
getQuicktips(search, locale, blacklist, createQuicktips);
} }
function getQuicktips (search, locale, sprueche, loadedHandler) { const QUICKTIP_SERVER = 'http://localhost:63825';
/*
{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/qt") }}
?q={{ $metager->getQ() }}
&sprueche={{ $metager->getSprueche() }}
&lang={{ Request::input('lang', 'all') }}
&unfilteredLink={{ base64_encode($metager->getUnfilteredLink()) }}
*/
$.get('http://localhost:8080/quicktips.xml?search=' + search + '&locale=' + locale, function (data, status) { /**
* Requests quicktips from the quicktip server and passes them to the loadedHandler
*
* @param {String} search search term
* @param {String} locale 2 letter locale identifier
* @param {Array<String>} blacklist excluded loaders
* @param {Function} loadedHandler handler for loaded quicktips
*/
function getQuicktips (search, locale, blacklist, loadedHandler) {
var getString = QUICKTIP_SERVER + '/quicktips.xml?search=' + search + '&locale=' + locale;
blacklist.forEach(function (value) {
getString += '&loader_' + value + '=false';
});
$.get(getString, function (data, status) {
if (status === 'success') { if (status === 'success') {
var quicktips = $(data).find('entry').map(function () { var quicktips = $(data).find('entry').map(function () {
return quicktip = { return quicktip = {
type: $(this).children('type').text(), type: $(this).children('type').text(),
title: $(this).children('title').text(), title: $(this).children('title').text(),
summary: $(this).children('summary').text(), summary: $(this).children('summary').text(),
url: $(this).children('url').text(),
gefVon: $(this).children('gefVon').text(),
priority: $(this).children('priority').text(),
details: $(this).children('details').map(function () { details: $(this).children('details').map(function () {
return { return {
title: $(this).children('title').text(), title: $(this).children('title').text(),
text: $(this).children('text').text(), text: $(this).children('text').text(),
url: $(this).children('url').text() url: $(this).children('url').text()
} }
}).toArray(), }).toArray()
url: $(this).children('url').text(),
gefVon: $(this).children('gefVon').text(),
priority: $(this).children('priority').text()
}; };
}).toArray(); }).toArray();
loadedHandler(quicktips); loadedHandler(quicktips);
...@@ -580,19 +598,25 @@ function getQuicktips (search, locale, sprueche, loadedHandler) { ...@@ -580,19 +598,25 @@ function getQuicktips (search, locale, sprueche, loadedHandler) {
* <div class="quicktip" type="TYPE"> * <div class="quicktip" type="TYPE">
* <details> * <details>
* <summary> * <summary>
* <h1><a href="URL">TITLE * <h1><a href="URL">TITLE</a></h1>
* <p>SUMMARY * <p>SUMMARY</p>
* </summary>
* <div class="quicktip-detail">
* <h2><a href="DETAILURL">DETAILTITLE</a></h1>
* <p>DETAILSUMMARY</p>
* </div>
* <div class="quicktip-detail"> * <div class="quicktip-detail">
* <h1><a href="DETAILURL">DETAILTITLE * ...
* <p>DETAILSUMMARY * </div>
* ...
* </details>
* <span>GEFVON * <span>GEFVON
* </...> * </div>
* * </div>
* *
* @param {*} quicktips * @param {Object} quicktips
*/ */
function createQuicktips (quicktips) { function createQuicktips (quicktips, sprueche) {
console.log(quicktips);
var quicktipsDiv = $('#quicktips'); var quicktipsDiv = $('#quicktips');
quicktips.sort(function (a, b) { quicktips.sort(function (a, b) {
return b.priority - a.priority; return b.priority - a.priority;
......
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