Wiki source code of UpdateUserVelocity
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{html clean="false"}} |
| 2 | |||
| |
35.1 | 3 | <button id="context-script-button" class="btn btn-primary">Execute Script</button> |
| |
1.1 | 4 | |
| |
2.2 | 5 | <pre id="context-search-response"></pre> |
| 6 | <script> | ||
| 7 | window.addEventListener('DOMContentLoaded', function() { | ||
| 8 | const contextSearchType = document.getElementById("context-search-type"); | ||
| 9 | const contextSearchText = document.getElementById("context-search-text"); | ||
| 10 | const contextSearchResponse = document.getElementById("context-search-response"); | ||
| |
35.1 | 11 | const contextSearchButton = document.getElementById("context-script-button"); |
| |
2.2 | 12 | contextSearchButton.addEventListener('click', function() { |
| 13 | const context = contextSearchType.options[contextSearchType.selectedIndex].value; | ||
| |
2.3 | 14 | const term = contextSearchText.value; |
| 15 | switch(context) { | ||
| 16 | case 'collabs': | ||
| 17 | document.location.href = `/bin/view/Collabs/#search=${term}`; | ||
| 18 | break; | ||
| 19 | case 'current-collab': | ||
| |
19.1 | 20 | handleXWikiSearch('bougaultx'); |
| |
2.3 | 21 | break |
| 22 | default: | ||
| |
16.1 | 23 | handleXWikiSearch() |
| |
2.3 | 24 | } |
| 25 | |||
| |
2.2 | 26 | }); |
| |
24.1 | 27 | |
| 28 | function handleXWikiSearch(space) { | ||
| |
16.1 | 29 | require(['jquery'], function($) { |
| 30 | var solrServiceURL = new XWiki.Document('SuggestSolrService', 'XWiki').getURL('get'); | ||
| |
35.1 | 31 | const contextSearchButton = document.getElementById("context-script-button"); |
| |
17.1 | 32 | const xwikiSpace = space ? `.${space}` : ''; |
| |
16.1 | 33 | contextSearchButton.addEventListener('click', function() { |
| |
21.1 | 34 | $.post(solrServiceURL, { |
| |
16.1 | 35 | outputSyntax: 'plain', |
| 36 | media: 'json', | ||
| 37 | query: [ | ||
| |
34.4 | 38 | 'q=title:"__INPUT__"~100 OR doccontent:"__INPUT__"~100', |
| |
16.1 | 39 | 'fq=type:DOCUMENT', |
| |
18.1 | 40 | `fq=space:Collabs${xwikiSpace}.*` |
| |
16.1 | 41 | ].join('\n'), |
| 42 | input: $('#context-search-text').val() | ||
| |
23.1 | 43 | }).then(res => { |
| 44 | contextSearchResponse.innerText = JSON.stringify(res, null, 2); | ||
| 45 | }); | ||
| |
21.1 | 46 | |
| |
4.5 | 47 | }); |
| |
3.2 | 48 | }); |
| |
16.1 | 49 | } |
| |
24.1 | 50 | }); |
| 51 | |||
| 52 | |||
| |
2.2 | 53 | </script> |
| |
1.1 | 54 | {{/html}} |