From cf790c30c572ccf4ab5d0378733d673d437e42e1 Mon Sep 17 00:00:00 2001 From: Css16 Date: Sun, 26 Mar 2017 23:05:52 +0200 Subject: tdf#106574 JavaScript navigation history with links added, CSS improvements Change-Id: I991e4a9c48f91997dc44fb7b9b9c2f57a3c49099 Reviewed-on: https://gerrit.libreoffice.org/35728 Reviewed-by: Olivier Hallot Tested-by: Olivier Hallot --- source/help.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source/help.js') diff --git a/source/help.js b/source/help.js index 6de81edd9f..cb9cf393b6 100644 --- a/source/help.js +++ b/source/help.js @@ -47,6 +47,8 @@ function getParameterByName(name, url) { return decodeURIComponent(results[2].replace(/\+/g, " ")); } +var navigationHistory = []; + function displayXML(xml, xsl, urlVars, moduleName, language, system) { var xsltProcessor; var resultDocument; @@ -79,6 +81,35 @@ function displayXML(xml, xsl, urlVars, moduleName, language, system) { var fileName = $(this).attr('href'); + navigationHistory.push({ + name: $(this).text(), + fileName: fileName + }); + if (navigationHistory.length > 5) { + navigationHistory.shift(); + } + var previousHistory = '' + navigationHistory.forEach(function(history) { + previousHistory += '' + history.name + ' > ' + }); + $('#NavigationHistory') + .html('' + previousHistory + ''); + + $('#NavigationHistory span.section').click(function() { + loadXMLDoc($(this).attr('filename'), function() { + var xmlDoc = this.responseXML; + if (xmlDoc != null) { + var resultDocument = xsltProcessor.transformToFragment(xmlDoc, document); + $("#DisplayArea").html($(resultDocument).find('#DisplayArea').html()); + $("#TopRight").html('

Contents displayed is: ' + fileName + '

'); + } + else { + console.log('Cannot load ' + fileName); + } + }); + }) + + loadXMLDoc(fileName, function() { var xmlDoc = this.responseXML; if (xmlDoc != null) { @@ -103,6 +134,8 @@ function displayXML(xml, xsl, urlVars, moduleName, language, system) { } function displayResult(file, moduleName, language, system) { + $('#NavigationHistory') + .html(''); // load the XSLT loadXMLDoc('online_transform.xsl', function() { var xsl = this.responseXML; -- cgit