[Libreoffice-commits] help.git: help3xsl/default.css help3xsl/get_bookmark.sh help3xsl/help.js help3xsl/index.html

Fabio Biocchetti fbbcchtt9 at gmail.com
Mon Oct 24 20:47:01 UTC 2016


 help3xsl/default.css     |    2 +-
 help3xsl/get_bookmark.sh |   13 ++++++-------
 help3xsl/help.js         |   35 +++++++++++++++++++++++++++--------
 help3xsl/index.html      |   34 +++++++++++++++++++++-------------
 4 files changed, 55 insertions(+), 29 deletions(-)

New commits:
commit 2f35a021df0677851b7f05522ca5b97b3992aca9
Author: Fabio Biocchetti <fbbcchtt9 at gmail.com>
Date:   Mon Oct 24 19:16:27 2016 +0200

    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 at edx.srv.br>
    Tested-by: Olivier Hallot <olivier.hallot at edx.srv.br>

diff --git a/help3xsl/default.css b/help3xsl/default.css
index 7065f0f..8863bbe 100644
--- a/help3xsl/default.css
+++ b/help3xsl/default.css
@@ -137,7 +137,7 @@ position: fixed;
 bottom: 5px;
 left: 5px; 
 overflow:auto; 
-width: 30%;
+width: 29%;
 height: 90%;
 }
 
diff --git a/help3xsl/get_bookmark.sh b/help3xsl/get_bookmark.sh
index b8e7ee6..a64ee24 100755
--- a/help3xsl/get_bookmark.sh
+++ b/help3xsl/get_bookmark.sh
@@ -1,11 +1,10 @@
 #/bin/bash
-#*--
-#* This file is part of the LibreOffice project.
-#*
-#* This Source Code Form is subject to the terms of the Mozilla Public
-#* License, v. 2.0. If a copy of the MPL was not distributed with this
-#* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#*
+
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 stub1='<html><head><link rel="stylesheet" type="text/css" href="/default.css"/></head><body><ul class="indexlink">'
 stub2='</ul></body></html>'
diff --git a/help3xsl/help.js b/help3xsl/help.js
index fb77cbc..839c895 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);
   });
 });
 
diff --git a/help3xsl/index.html b/help3xsl/index.html
index f326003..ffba610 100644
--- a/help3xsl/index.html
+++ b/help3xsl/index.html
@@ -1,8 +1,8 @@
 <html>
 <head>
-<link href="/default.css" rel="Stylesheet" type="text/css" />
-<script type="text/javascript" src="/jquery-3.1.1.min.js"></script>
-<script type="text/javascript" src="/help.js"></script>
+<link href="default.css" rel="Stylesheet" type="text/css" />
+<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
+<script type="text/javascript" src="help.js"></script>
 </head>
 <body>
 <input type="text" id="search-bar" style="margin-top:20px"/>
@@ -10,22 +10,30 @@
      <div id="TopLeft">
          <table>
             <tr>
-               <td class="topmenu"><p onclick="displayResult('/text/scalc/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=calc','calc')">Calc</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/swriter/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=writer','writer')">Writer</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/simpress/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=simpress','impress')">Impress</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/sdraw/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=sdraw','draw')">Draw</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/schart/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=schart','chart')">Chart</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/sbasic/shared/main0001.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=sbasic','basic')">Basic</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/smath/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=smath','math')">Math</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/shared/explorer/database/main.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=shared','shared')">Base</p></td>
-               <td class="topmenu"><p onclick="displayResult('/text/shared/guide/main.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=shared','shared')">Guide</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/scalc/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=calc','calc')">Calc</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/swriter/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=writer','writer')">Writer</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/simpress/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=simpress','impress')">Impress</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/sdraw/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=sdraw','draw')">Draw</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/schart/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=schart','chart')">Chart</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/sbasic/shared/main0001.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=sbasic','basic')">Basic</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/smath/main0000.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=smath','math')">Math</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/shared/explorer/database/main.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=shared','shared')">Base</p></td>
+               <td class="topmenu"><p onclick="displayResult('../source/text/shared/guide/main.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=shared','shared')">Guide</p></td>
              </tr>
           </table>
       </div>
      <div id="BottomLeft">
      </div>
 <script>
-$("#BottomLeft").load('/bookmark_shared.html');
+if (window.location.href.indexOf('?') && getParameterByName('page')) {
+  var module = getParameterByName("DbPAR");
+  var language = getParameterByName("Language");
+  var system = getParameterByName("System");
+  var usedb = getParameterByName("UseDB");
+  displayResult('../source/text/' + getParameterByName('page') + '&DbPAR='+module+'&Language='+language+'&System='+system+'&UseDB='+usedb);
+} else {
+  displayResult('../source/text/shared/main0108.xhp?Language=en-US&System=WIN&UseDB=no&DbPAR=shared','shared');
+}
 </script>
 </body>
 </html>


More information about the Libreoffice-commits mailing list