Hi guys,
First question is about search functionality:Is it possible to automate the <input> elements using forEach to check if current Confluence instance has spaces where Viewport is active? Like so:
search_bar.vm (lower):#set($search = "/search")
#if ($stringUtils.equals(${viewport.link}, "/") == false)
#set($search = "${viewport.link}/search")
#end
<form action="$search" method="GET" id="search>
<input type="text" autocomplete="off" name="q" value="$!searchRequest.queryString" />
#f
orEa
ch ($[spacename variable] in [viewport placeholder?)]
<input type="hidden" name="s" value="$[spacename variable would come here]" />
#end
</form>
Is there a way to automate this or does the confluence restrictions do by itself? I feel like automating this as presented would give a little extra sense of security, since inputs are limited to only work on active viewports, so it ignores internal confluence spaces when searching content. There is probably a benefit for database query also?
Second question is about quick search functionality:
How can I achieve quick search functionality in custom viewport theme? I have jQuery (main.js named as quicksearch.js) and the code snippet from
k15t help documentation, which is "gutted" to two templates:
search.vm - Shows results
search_bar.vm - A subtemplate which is included in every page to top right corner.
search_bar.vm (upper):
#if ($stringUtils.contains($url.query, 'quicksearch=true'))
#foreach($result in $searchResults.items)
<li n="$velocityCount" class="search-result">
<a href="$result.link">$result.displayTitle</a>
</li>
#end
#else
#set($search = "/search")
#if ($stringUtils.equals(${viewport.link}, "/") == false)
#set($search = "${viewport.link}/search")
#end
LOWER SNIPPET STARTS FROM HERE
quicksearch.js:$(document).ready(() => {
$('#search-input').on('keyup', function () {
if($('#search-input').val().length >= 3){
$('#search-results')
.load(
$('#search').attr('action'), "quicksearch=true&q=" + $("#search-input")
.val());
}
});
});
I feel like i'm missing something here. The Search Template (Recipe part of help documentation) says something about scroll-search.js, which I think is part of SCROLL WEBHELP theme. Do I need to build something like it? Since it has window manipulation
"window.SCROLL_WEBHELP".
Thank you.