mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-18 10:08:53 +00:00
add doc v1.1.2
This commit is contained in:
22
doc/webhelp/template/js/custom.js
Normal file
22
doc/webhelp/template/js/custom.js
Normal file
@@ -0,0 +1,22 @@
|
||||
var executed = false;
|
||||
$( document ).ready(function() {
|
||||
$("#searchForm").on("submit", (e) => {
|
||||
// WebHelps triggers the submit event handler multiple times.
|
||||
if(!executed) { // We make sure that we execute it only one time.
|
||||
e.stopPropagation();
|
||||
var userQuery = $('#textToSearch').val();
|
||||
if (userQuery.trim() === '') {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z]+$/.test(userQuery)) {
|
||||
userQuery = userQuery.replace(/[\u4e00-\u9fa5]{2}/g, '$& '); // if the input isn't english characters, split every given Chinese input (string) by separating every two Chinese chars by spaces.
|
||||
}
|
||||
// userQuery = userQuery.replace(/[\u4e00-\u9fa5]{2}/g, '$& '); // split every given Chinese input by separating every two Chinese characters by spaces.
|
||||
//userQuery = userQuery.replace(/[\u4e00-\u9fa5]/g, '$& '); // split every given Chinese input by separating every Chinese character by spaces.
|
||||
$('#textToSearch').val(userQuery);
|
||||
executed = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
21
doc/webhelp/template/js/search-filter.js
Normal file
21
doc/webhelp/template/js/search-filter.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Object that implements the methods required by WebHelp to run a search filter.
|
||||
*/
|
||||
function CustomSearchFilter() {
|
||||
|
||||
/**
|
||||
* Method required to run the search filter in webhelp. It is called when the users
|
||||
* executes the query in the search page.
|
||||
*
|
||||
* @param {WebHelpAPI.SearchResult} searchResult The search result for the executed query.
|
||||
*
|
||||
* @return A list of WebHelpAPI.SearchResult objects
|
||||
*/
|
||||
this.filterResults = function (searchResult) {
|
||||
// implement filter
|
||||
return filteredResults;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the Search Filter to WebHelp
|
||||
WebHelpAPI.setCustomSearchFilter(new CustomSearchFilter());
|
||||
Reference in New Issue
Block a user