mirror of https://github.com/kiwix/libkiwix.git
HTML decoding of suggestions in the frontend
Since the `value` field of the search suggestion results is HTML escaped/encoded in the backend (see static/templates/suggestion.json) it must be decoded in the frontend.
This commit is contained in:
parent
89d7e68a39
commit
a7fea462b0
|
@ -4,6 +4,10 @@
|
|||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/external/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
function htmlDecode(input) {
|
||||
var doc = new DOMParser().parseFromString(input, "text/html");
|
||||
return doc.documentElement.textContent;
|
||||
}
|
||||
var jk = jQuery.noConflict();
|
||||
jk(function() {
|
||||
jk( "#kiwixsearchbox" ).autocomplete({
|
||||
|
@ -12,6 +16,12 @@
|
|||
dataType: "json",
|
||||
cache: false,
|
||||
|
||||
response: function( event, ui ) {
|
||||
for(const item of ui.content) {
|
||||
item.value = htmlDecode(item.value);
|
||||
}
|
||||
},
|
||||
|
||||
select: function(event, ui) {
|
||||
jk( "#kiwixsearchbox" ).val(ui.item.value);
|
||||
jk( "#kiwixsearchform" ).submit();
|
||||
|
|
Loading…
Reference in New Issue