mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #458 from kiwix/html_decoded_suggestions
Correctly encoding/decoding HTML entities in search suggestions
This commit is contained in:
commit
bd781f8e8b
|
@ -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/external/jquery/jquery.js"></script>
|
||||||
<script type="text/javascript" src="{{root}}/skin/jquery-ui/jquery-ui.min.js"></script>
|
<script type="text/javascript" src="{{root}}/skin/jquery-ui/jquery-ui.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
function htmlDecode(input) {
|
||||||
|
var doc = new DOMParser().parseFromString(input, "text/html");
|
||||||
|
return doc.documentElement.textContent;
|
||||||
|
}
|
||||||
var jk = jQuery.noConflict();
|
var jk = jQuery.noConflict();
|
||||||
jk(function() {
|
jk(function() {
|
||||||
jk( "#kiwixsearchbox" ).autocomplete({
|
jk( "#kiwixsearchbox" ).autocomplete({
|
||||||
|
@ -12,6 +16,13 @@
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
cache: false,
|
cache: false,
|
||||||
|
|
||||||
|
response: function( event, ui ) {
|
||||||
|
for(const item of ui.content) {
|
||||||
|
item.label = htmlDecode(item.label);
|
||||||
|
item.value = htmlDecode(item.value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
jk( "#kiwixsearchbox" ).val(ui.item.value);
|
jk( "#kiwixsearchbox" ).val(ui.item.value);
|
||||||
jk( "#kiwixsearchform" ).submit();
|
jk( "#kiwixsearchform" ).submit();
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
{{#suggestions}}{{^first}},{{/first}}
|
{{#suggestions}}{{^first}},{{/first}}
|
||||||
{
|
{
|
||||||
"value" : "{{value}}",
|
"value" : "{{value}}",
|
||||||
"label" : "{{& label}}"
|
"label" : "{{label}}"
|
||||||
}{{/suggestions}}
|
}{{/suggestions}}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue