Skip to content

Commit

Permalink
Merge pull request #461 from MananJethwani/issue/444
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr authored Mar 15, 2021
2 parents 32643fb + fb26f6b commit 0f36879
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
32 changes: 32 additions & 0 deletions static/skin/taskbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}

(function ($) {
const root = $( `link[type='root']` ).attr("href");

$( "#kiwixsearchbox" ).autocomplete({

source: `${root}/suggest?content=${window.location.pathname.split(`${root}/`)[1].split('/')[0]}`,
dataType: "json",
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) {
$( "#kiwixsearchbox" ).val(ui.item.value);
$( "#kiwixsearchform" ).submit();
},

});

/* cybook hack */
if (navigator.userAgent.indexOf("bookeen/cybook") != -1) {
$("html").addClass("cybook");
}

if ($(window).width() < 520) {
var didScroll;
var lastScrollTop = 0;
Expand Down
34 changes: 1 addition & 33 deletions static/templates/head_part.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
<link type="text/css" href="{{root}}/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
<link type="text/css" href="{{root}}/skin/taskbar.css" rel="Stylesheet" />
<link type="root" href="{{root}}">
<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({

source: "{{root}}/suggest?content={{#urlencoded}}{{{content}}}{{/urlencoded}}",
dataType: "json",
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) {
jk( "#kiwixsearchbox" ).val(ui.item.value);
jk( "#kiwixsearchform" ).submit();
},

});
});

/* cybook hack */
if (navigator.userAgent.indexOf("bookeen/cybook") != -1) {
jk("html").addClass("cybook");
}
</script>
<script type="text/javascript" src="{{root}}/skin/taskbar.js" async></script>

0 comments on commit 0f36879

Please sign in to comment.