From 2f35a021df0677851b7f05522ca5b97b3992aca9 Mon Sep 17 00:00:00 2001 From: Fabio Biocchetti Date: Mon, 24 Oct 2016 19:16:27 +0200 Subject: Fix comments in script and JavaScript refactor. Comments correction in shell script Introduced js debouncer for search bar xml-stylesheet tag removed Introduced parameter passing through pages Links in XHP pages now work with js Minor adjustments Change-Id: Ibf5f7a74c3249fa6f1ff4d3037fe821797e88d1d Reviewed-on: https://gerrit.libreoffice.org/30231 Reviewed-by: Olivier Hallot Tested-by: Olivier Hallot --- help3xsl/help.js | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'help3xsl/help.js') diff --git a/help3xsl/help.js b/help3xsl/help.js index fb77cbc14d..839c895016 100644 --- a/help3xsl/help.js +++ b/help3xsl/help.js @@ -15,21 +15,33 @@ if (response == 1){return xhttp.responseXML;} return xhttp.responseText; } +function getParameterByName(name, url) { + if (!url) { + url = window.location.href; + } + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, " ")); +} function displayResult(file, moduleName, language, system) { var xml = loadXMLDoc(file, 1); -var xsl = loadXMLDoc('/online_transform.xsl', 1); +var xsl = loadXMLDoc('online_transform.xsl', 1); var xsltProcessor; var resultDocument; var bookmarkHTML; var urlVars = getUrlVars(file); var module = urlVars["DbPAR"]; + moduleName = moduleName || module; var language = urlVars["Language"]; var system = urlVars["System"]; var usedb = urlVars["UseDB"]; - document.getElementById("DisplayArea").innerHTML= null; - document.getElementById("BottomLeft").innerHTML= null; + document.getElementById("DisplayArea").innerHTML= null; + document.getElementById("BottomLeft").innerHTML= null; // code for IE if (window.ActiveXObject || xhttp.responseType == "msxml-document") { @@ -45,8 +57,9 @@ else if (document.implementation && document.implementation.createDocument) if (language){xsltProcessor.setParameter(null, "Language", language);} if (system){xsltProcessor.setParameter(null, "System", system);} - $(document).on('click', '#BottomLeft a', function(e) { + $(document).on('click', '#BottomLeft a, #DisplayArea a', function(e) { e.preventDefault(); + $('#search-bar').val(''); var xml = loadXMLDoc($(this).attr('href'), 1); var resultDocument = xsltProcessor.transformToFragment(xml, document); $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html()); @@ -57,16 +70,22 @@ else if (document.implementation && document.implementation.createDocument) resultDocument = xsltProcessor.transformToFragment(xml, document); $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html()); // Handle bookmar panel - $("#BottomLeft").load('/bookmark_'+moduleName+'.html'); + $("#BottomLeft").load('bookmark_'+moduleName+'.html'); } } +var debouncer = null; $(document).ready(function() { $('#search-bar').keyup(function() { - $("#BottomLeft ul li" ).show(); - if($(this).val()) { - $("#BottomLeft ul a:not(:contains('" + $(this).val() + "'))" ).parent().hide(); + if(debouncer) { + clearTimeout(debouncer); } + debouncer = setTimeout(function(){ + $("#BottomLeft ul li" ).show(); + if($('#search-bar').val()) { + $("#BottomLeft ul a:not(:contains('" + $('#search-bar').val() + "'))" ).parent().hide(); + } + }, 500); }); }); -- cgit