[Libreoffice-commits] dev-tools.git: help3/xhpeditor
Olivier Hallot (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 5 10:22:19 UTC 2019
help3/xhpeditor/config.php | 1 +
help3/xhpeditor/index.php | 37 +++++++++++++++++++++----------------
help3/xhpeditor/xhp2html.js | 18 ++++++++++++++++++
3 files changed, 40 insertions(+), 16 deletions(-)
New commits:
commit bc89f2b293b390d98cf2b598f307c3af64aee1d6
Author: Olivier Hallot <olivier.hallot at libreoffice.org>
AuthorDate: Thu Dec 5 07:18:55 2019 -0300
Commit: Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Thu Dec 5 11:22:00 2019 +0100
XHP editor: open local file and render
Change-Id: Ia6e1358064281e03d326f6398fb101a71637450e
Reviewed-on: https://gerrit.libreoffice.org/84541
Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>
Tested-by: Olivier Hallot <olivier.hallot at libreoffice.org>
diff --git a/help3/xhpeditor/config.php b/help3/xhpeditor/config.php
index cf51506..9bcd6a7 100644
--- a/help3/xhpeditor/config.php
+++ b/help3/xhpeditor/config.php
@@ -12,6 +12,7 @@ $CONFIG = array (
'help_path' => 'helpcontent2/source/',
'icon_path' => 'icon-themes',
'productname' => 'LibreOffice',
+'xhpDTD' => 'helpcontent2/helpers/xmlhelp.dtd',
);
?>
diff --git a/help3/xhpeditor/index.php b/help3/xhpeditor/index.php
index 2e2b084..780dcbc 100644
--- a/help3/xhpeditor/index.php
+++ b/help3/xhpeditor/index.php
@@ -25,7 +25,7 @@ $xhp = $_POST["xhpdoc"];
<script type="text/javascript" src="addon/hint/show-hint.js"></script>
<script type="text/javascript" src="addon/hint/xml-hint.js"></script>
<script type="text/javascript" src="mode/xml/xml.js"></script>
- <script type="text/javascript" src="xhp2html.js"></script>
+ <script type="text/javascript" src="xhp2html.js" defer=""></script>
<script type="text/javascript" src="helpcontent2/help3xsl/help2.js"></script>
<script type="text/javascript" src="helpcontent2/help3xsl/prism.js"></script>
<script type="text/javascript" src="helpcontent2/help3xsl/help.js" defer=""></script>
@@ -37,20 +37,29 @@ $xhp = $_POST["xhpdoc"];
<div class="leftside">
<h2>LibreOffice Documentation XHP Editor</h2>
<form id="CMtextarea" class="form_area" action="index.php" method="post">
- <textarea id="xhpeditor" name="xhpdoc" form="CMtextarea"><?php echo $xhp; ?></textarea></br>
<input type="submit" name="render_page" value="Render page"/>
<input type="submit" name="get_patch" value="Generate patch"/>
<input type="submit" name="check_xhp" value="Check XHP"/>
+ <input type="submit" name="open_master" value="Open Master"/>
+ <textarea id="xhpeditor" name="xhpdoc" form="CMtextarea">
+<?php
+if (isset($_POST["render_page"])) {
+echo $xhp;
+}elseif (isset($_POST["get_patch"])) {
+echo "get patch";
+}elseif (isset($_POST["check_xhp"])) {
+echo "check xhp";
+}elseif (isset($_POST["open_master"])) {
+echo "Open in master repository";
+}else{
+echo $xhp;
+}
+?>
+ </textarea></br>
</form>
- <br />
- <div class="snip_heading">
- <div class="snip_div">Actions:</div>
- <p>File name: <input type="text" id="01" name="filename" value="test.xhp"/><button onclick="loadText(document.getElementById('01').value);">Open File</button></p>
- <p>File name: <input type="text" id="02" name="filename" value="test.xhp"/>
- <button onclick="alert('Not yet implemented');">Save Changes</button>
- </p>
-</div>
-
+ <div class="snip_heading"><div class="snip_div">Open local file:</div>
+ <input type="file" id="file-input" accept=".xhp"/>
+ </div>
<div class="snip_heading"><div class="snip_div">Edit:</div>
<button onclick="editor.undo()">Undo</button>
<button onclick="editor.redo()">Redo</button>
@@ -133,11 +142,7 @@ $xhp = $_POST["xhpdoc"];
$proc->importStyleSheet($xsl);
echo $proc->transformToXml($xml);
echo'</div>';
- } else if(isset($_POST["get_patch"])) {
- echo '<h2>Patch</h2><div id="patchpage"><textarea>';
- print $xhp;
- echo '</textarea></div>';
- }else {}
+ }
?>
</div>
</body>
diff --git a/help3/xhpeditor/xhp2html.js b/help3/xhpeditor/xhp2html.js
index a38f4fc..1543b01 100644
--- a/help3/xhpeditor/xhp2html.js
+++ b/help3/xhpeditor/xhp2html.js
@@ -9,6 +9,7 @@
/* change these parameters to fit your installation */
+
var xhttp;
function loadDoc(filename, isXML)
@@ -33,3 +34,20 @@ function loadText(filename){
var text = loadDoc(filename,false);
editor.doc.setValue(text);
}
+
+function readSingleFile(e) {
+ var file = e.target.files[0];
+
+ if (!file) {
+ return;
+ }
+ var reader = new FileReader();
+ reader.onload = function(e) {
+ var contents = e.target.result;
+ editor.doc.setValue(contents);
+ };
+ reader.readAsText(file);
+}
+
+document.getElementById('file-input').addEventListener('change', readSingleFile, false);
+
More information about the Libreoffice-commits
mailing list