summaryrefslogtreecommitdiffstats
path: root/help3xsl/help.js
diff options
context:
space:
mode:
authorFabio Biocchetti <fbbcchtt9@gmail.com>2016-10-24 19:16:27 +0200
committerOlivier Hallot <olivier.hallot@edx.srv.br>2016-10-24 20:46:37 +0000
commit2f35a021df0677851b7f05522ca5b97b3992aca9 (patch)
tree004dc979092069b702bc5717dcc47ea7669eade4 /help3xsl/help.js
parenttdf#80439 Help pages for (NET)WORKDAYS.INTL (diff)
downloadhelp-2f35a021df0677851b7f05522ca5b97b3992aca9.tar.gz
help-2f35a021df0677851b7f05522ca5b97b3992aca9.zip
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 <olivier.hallot@edx.srv.br> Tested-by: Olivier Hallot <olivier.hallot@edx.srv.br>
Diffstat (limited to 'help3xsl/help.js')
-rw-r--r--help3xsl/help.js35
1 files changed, 27 insertions, 8 deletions
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);
});
});