mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
HTTP Server: Add search-suggest [#489]
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
width: 100%;
|
||||
list-style: none;
|
||||
background: transparent; /*2013-08-20:else blue vertical bar will be visible directly underneath right-edge of search box*/
|
||||
z-index: 128; /*else indicators page-indicator icons will show; EX:en.w:Earth; DATE:2019-08-04*/
|
||||
}
|
||||
|
||||
#xowa-search-suggestions li {
|
||||
|
||||
@@ -37,11 +37,37 @@ function receiveSuggestions (search, suggestions) {
|
||||
}
|
||||
window.receiveSuggestions = receiveSuggestions;
|
||||
function fetchSuggestions () {
|
||||
if (xowa_mode_is_server)
|
||||
xowa_exec_async(function(){}, 'get_search_suggestions', currentSearch, 'receiveSuggestions');
|
||||
if (xowa_global_values.mode_is_http) {
|
||||
var wiki = xowa.page.wiki;
|
||||
var search = document.getElementById("searchInput").value;
|
||||
sendByAjaxWithCallback
|
||||
( 'xowa.search.ui.suggest'
|
||||
, { wiki: wiki
|
||||
, search: search
|
||||
, cbk: "receiveSuggestions"
|
||||
}
|
||||
, function(xreq)
|
||||
{
|
||||
eval(xreq.responseText);
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
xowa_exec('get_search_suggestions', currentSearch, 'receiveSuggestions');
|
||||
}
|
||||
function sendByAjaxWithCallback(cmd, data, cbk) {
|
||||
var xreq = new XMLHttpRequest();
|
||||
xreq.onreadystatechange = function() {
|
||||
if (xreq.readyState == 4 && xreq.status == 200) {
|
||||
cbk(xreq)
|
||||
}
|
||||
};
|
||||
var form_data = new FormData();
|
||||
form_data.append('msg', JSON.stringify({cmd:cmd, data:data}));
|
||||
form_data.append('app_mode', 'http_server');
|
||||
xreq.open("POST", '/exec/json', true);
|
||||
xreq.send(form_data);
|
||||
}
|
||||
|
||||
function renderSuggestion (page_db, page_display) {
|
||||
var textNode = document.createElement('span'),
|
||||
@@ -49,7 +75,11 @@ function renderSuggestion (page_db, page_display) {
|
||||
liNode = document.createElement('li');
|
||||
textNode.innerHTML = page_display;
|
||||
textNode.setAttribute('xowa_page_db', page_db);
|
||||
linkNode.href = '/wiki/' + page_db;
|
||||
var href = '/wiki/' + page_db;
|
||||
if (xowa_global_values.mode_is_http) {
|
||||
href = '/' + xowa.page.wiki + href;
|
||||
}
|
||||
linkNode.href = href;
|
||||
linkNode.appendChild(textNode);
|
||||
liNode.appendChild(linkNode);
|
||||
return liNode;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
width: 100%;
|
||||
list-style: none;
|
||||
background: transparent; /*2013-08-20:else blue vertical bar will be visible directly underneath right-edge of search box*/
|
||||
z-index: 128; /*else indicators page-indicator icons will show; EX:en.w:Earth; DATE:2019-08-04*/
|
||||
}
|
||||
|
||||
#xowa-search-suggestions li {
|
||||
|
||||
Reference in New Issue
Block a user