Changes for page Context Search
Last modified by bougault on 2023/02/20 16:29
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -3,9 +3,7 @@ 3 3 !!! POC. Code would must be reviewed / optimized and packaged for use in production !!! 4 4 --> 5 5 <script type="module"> 6 -import {LitElement, html} from 'https://cdn.jsdelivr.net/gh/lit/dist@2/core/lit-core.min.js'; 7 -window.addEventListener('DOMContentLoaded', function() { 8 - 6 + import {LitElement, html} from 'https://cdn.jsdelivr.net/gh/lit/dist@2/core/lit-core.min.js'; 9 9 class UnifiedSearch extends LitElement { 10 10 /* 11 11 static properties = { ... ... @@ -62,35 +62,6 @@ 62 62 } 63 63 } 64 64 customElements.define('clb-unified-search', UnifiedSearch); 65 - 66 - function handleXWikiSearch(space, callback) { 67 - require(['jquery'], function($) { 68 - var solrServiceURL = new XWiki.Document('SuggestSolrService', 'XWiki').getURL('get'); 69 - const contextSearchButton = document.getElementById("context-search-button"); 70 - const xwikiSpace = space ? `.${space}` : ''; 71 - contextSearchButton.addEventListener('click', function() { 72 - $.post(solrServiceURL, { 73 - outputSyntax: 'plain', 74 - media: 'json', 75 - query: [ 76 - 'q="__INPUT__"~100', 77 - 'fq=type:DOCUMENT', 78 - `fq=space:Collabs${xwikiSpace}.*` 79 - ].join('\n'), 80 - input: $('#context-search-text').val() 81 - }).then(res => { 82 - if(callback) { 83 - callback(res).then(results => { 84 - contextSearchResponse.innerText = JSON.stringify(results, null, 2); 85 - }) 86 - } else { 87 - contextSearchResponse.innerText = JSON.stringify(res, null, 2); 88 - } 89 - }); 90 - }); 91 - }); 92 - } 93 -}); 94 94 </script> 95 95 96 96 <clb-unified-search></clb-unified-search>