From c89558254bcc4e22049baadabbbb0effecd24d7d Mon Sep 17 00:00:00 2001 From: Karl Hasselbring <Karl Hasselbring> Date: Wed, 27 Sep 2017 09:54:54 +0200 Subject: [PATCH] =?UTF-8?q?Die=20Quicktips=20laden=20f=C3=BCr=20null=20wer?= =?UTF-8?q?te=20jetzt=20standardwerte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/scriptResultPage.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/scriptResultPage.js b/resources/assets/js/scriptResultPage.js index 5a01018a4..83355e35b 100644 --- a/resources/assets/js/scriptResultPage.js +++ b/resources/assets/js/scriptResultPage.js @@ -15,23 +15,27 @@ $(document).ready(function () { } else { var sprueche = getURLParameter('sprueche') === 'on'; // load the sprueche url parameter } - var search = getMetaTag('q'); - var locale = getMetaTag('l'); + var search = getMetaTag('q') || ''; + var locale = getMetaTag('l') || 'de'; loadQuicktips(search, locale, sprueche); // load the quicktips }); /* function readLocaleFromUrl(defaultLocale) { - return location.pathname.substr(1, location.pathname.indexOf('/meta', 0) - 1) || 'de'; + return location.pathname.substr(1, location.pathname.indexOf('/meta', 0) - 1) || 'de' } */ -function getURLParameter(name) { +function getURLParameter (name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null; } -function getMetaTag(name) { - return $('meta[name="' + name + '"')[0].content; +function getMetaTag (name) { + if (typeof $('meta[name="' + name + '"')[0] !== 'undefined') { + return $('meta[name="' + name + '"')[0].content || null; + } else { + return null; + } } function activateJSOnlyContent () { @@ -595,7 +599,7 @@ function getQuicktips (search, locale, blacklist, loadedHandler) { title: $(this).children('title').text(), text: $(this).children('text').text(), url: $(this).children('url').text() - } + }; }).toArray() }; }).toArray(); @@ -659,7 +663,7 @@ function createQuicktips (quicktips, sprueche) { detailElem .append(detailHeadlineElem) .append('<p>' + detail.text + '</p>'); - mainElem.append(detailElem); + mainElem.append(detailElem); }); } else { mainElem = $('<div class="quicktip-summary">'); -- GitLab