From ebe524ded3b0835934f228d5b7c5795cb3013035 Mon Sep 17 00:00:00 2001 From: Stephan Preeker Date: Fri, 29 Dec 2017 16:47:29 +0100 Subject: [PATCH] make javascript more secure.. --- src/scripts/tutti/4_search.js | 49 +++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/scripts/tutti/4_search.js b/src/scripts/tutti/4_search.js index cd72c43a..604d3cd0 100644 --- a/src/scripts/tutti/4_search.js +++ b/src/scripts/tutti/4_search.js @@ -157,7 +157,7 @@ $(document).ready(function() { minLength: 0, templates: { suggestion: function(hit) { - console.log('hit!'); + var hitMedia = (hit.media ? ' · '+hit.media+'' : ''); var hitFree = (hit.is_free ? '
free
' : ''); var hitPicture; @@ -174,21 +174,27 @@ $(document).ready(function() { .attr('title', hit.name) .text(hit.name); - return '' + - '' + - '
' + - '
' + - hitPicture + - hitFree + - '
' + - $searchHitName.html() + - '
' + - $span.html() + ' · ' + - '' + hit.node_type + '' + - hitMedia + - '
' + - '
'+ - '
'; + return $('', { + href: '/nodes/'+ hit.objectID + '/redir', + class: "search-site-result", + id: hit.objectID + }).append( + '
' + + '
' + + hitPicture + + hitFree + + '
' + + $searchHitName.html() + + '
' + + $span.html() + ' · ' + + $('', { + class: "node_type", + text: hit.node_type + }) + + hitMedia + + '
' + + '
' + ) } } }); @@ -227,7 +233,11 @@ $(document).ready(function() { searchInput.bind('typeahead:render', function(event, suggestions, async, dataset) { if( suggestions != undefined && $('.tt-all-results').length <= 0){ $('.tt-dataset').append( - '
' + + $("", { + id: "search-advanced", + href: '/search?q='+ $("#cloud-search").val() + '&page=1', + class: "search-site-result advanced tt-suggestion", + }).append( '
' + '' + ) + ); } });