diff options
author | Fabio Bioccetti <fabio.biocchetti@gmail.com> | 2016-10-21 12:35:55 -0200 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@edx.srv.br> | 2016-10-21 20:26:11 +0000 |
commit | f6f7781565812712d41180f312289ad65c46ff78 (patch) | |
tree | d01002e3fafc538cf9cef71f175fec8d38250cdf /help3xsl/help.js | |
parent | 599f664d48f995c461e06daf2295c1f9921fbcb8 (diff) |
tdf#97745 Help pages in browser (WIP)
Work in progress:
Search index
Javascript xhp server
patch2: rename jj.js to help.js
updated index.html accordingly
Change-Id: Idece5ea25b0906b3fbdfd1f401e8dcfdfa4bd947
Reviewed-on: https://gerrit.libreoffice.org/30143
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.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/help3xsl/help.js b/help3xsl/help.js new file mode 100644 index 0000000000..fb77cbc14d --- /dev/null +++ b/help3xsl/help.js @@ -0,0 +1,80 @@ +function loadXMLDoc(filename, response) +{ +if (window.ActiveXObject) + { + xhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } +else + { + xhttp = new XMLHttpRequest(); + } +xhttp.open("GET", filename, false); +try {xhttp.responseType = "msxml-document"} catch(err) {} // Helping IE11 +xhttp.send(""); +if (response == 1){return xhttp.responseXML;} +return xhttp.responseText; +} + + +function displayResult(file, moduleName, language, system) +{ +var xml = loadXMLDoc(file, 1); +var xsl = loadXMLDoc('/online_transform.xsl', 1); +var xsltProcessor; +var resultDocument; +var bookmarkHTML; +var urlVars = getUrlVars(file); + var module = urlVars["DbPAR"]; + var language = urlVars["Language"]; + var system = urlVars["System"]; + var usedb = urlVars["UseDB"]; + document.getElementById("DisplayArea").innerHTML= null; + document.getElementById("BottomLeft").innerHTML= null; +// code for IE +if (window.ActiveXObject || xhttp.responseType == "msxml-document") + { + ex = xml.transformNode(xsl); + document.getElementById("DisplayArea").innerHTML = ex; + } +// code for Chrome, Firefox, Opera, etc. +else if (document.implementation && document.implementation.createDocument) + { + xsltProcessor = new XSLTProcessor(); + + if (module){xsltProcessor.setParameter(null, "appl", module);} + if (language){xsltProcessor.setParameter(null, "Language", language);} + if (system){xsltProcessor.setParameter(null, "System", system);} + + $(document).on('click', '#BottomLeft a', function(e) { + e.preventDefault(); + var xml = loadXMLDoc($(this).attr('href'), 1); + var resultDocument = xsltProcessor.transformToFragment(xml, document); + $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html()); + return false; + }); + + xsltProcessor.importStylesheet(xsl); + resultDocument = xsltProcessor.transformToFragment(xml, document); + $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html()); + // Handle bookmar panel + $("#BottomLeft").load('/bookmark_'+moduleName+'.html'); + } +} + +$(document).ready(function() { + $('#search-bar').keyup(function() { + $("#BottomLeft ul li" ).show(); + if($(this).val()) { + $("#BottomLeft ul a:not(:contains('" + $(this).val() + "'))" ).parent().hide(); + } + }); +}); + +//http://papermashup.com/read-url-get-variables-withjavascript/ + +function getUrlVars(file) { +var vars = {}; +var parts = file.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {vars[key] = value;}); +//var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {vars[key] = value;}); +return vars; +} |