Failed to execute template. Cause: [Access denied when checking [script] access to [xwiki:Collaboratory.UX.HbpSkin.WebHome] for user [xwiki:XWiki.Admin]]. Click on this message for details.

Context Search Axel - HBP Wiki

IAM21 instance, do not create collab nor modify a team, your changes will be lost


Context Search Axel

Version 26.2 by messines on 2022/10/14 09:22


  window.addEventListener('DOMContentLoaded', function() {
    const contextSearchType = document.getElementById("context-search-type");
    const contextSearchText = document.getElementById("context-search-text");
    const contextSearchResponse = document.getElementById("context-search-response");
    const contextSearchButton = document.getElementById("context-search-button");
    contextSearchButton.addEventListener('click', function() {
      const context = contextSearchType.options[contextSearchType.selectedIndex].value;
      const term = contextSearchText.value;
      switch(context) {
          case 'collabs':
            document.location.href = `/bin/view/Collabs/#search=${term}`;
            break;
          case 'current-collab':
            handleXWikiSearch('bougaultx');
            break
          default:
            handleXWikiSearch()
      }

    });
    
    function handleXWikiSearch(space) {
  require(['jquery'], function($) {
    var solrServiceURL = new XWiki.Document('SuggestSolrService', 'XWiki').getURL('get');
    const contextSearchButton = document.getElementById("context-search-button");
    const xwikiSpace = space ? `.${space}` : '';
    contextSearchButton.addEventListener('click', function() {
    $.post(solrServiceURL, {
        outputSyntax: 'plain',
        media: 'json',
        query: [
          'q=title:"awesome"~100 OR doccontent:"awesome"~100',
          'fq=type:DOCUMENT',
          `fq=space:Collabs${xwikiSpace}.*`
        ].join('\n'),
        input: $('#context-search-text').val()
      }).then(res => {
      contextSearchResponse.innerText = JSON.stringify(res, null, 2);
    });

    });
  });
}
  });