Merge pull request #135 from janekptacijarabaci/aboutSupport_improvements_1

moebius#57: about:support - "Copy text to clipboard": "Places Database" - "Verify" (results)
This commit is contained in:
New Tobin Paradigm
2018-04-13 00:46:41 -04:00
committed by GitHub
2 changed files with 32 additions and 13 deletions
+29 -10
View File
@@ -715,7 +715,8 @@ Serializer.prototype = {
let hasText = false;
for (let child of elem.childNodes) {
if (child.nodeType == Node.TEXT_NODE) {
let text = this._nodeText(child);
let text = this._nodeText(
child, (child.classList && child.classList.contains("endline")));
this._appendText(text);
hasText = hasText || !!text.trim();
}
@@ -742,7 +743,7 @@ Serializer.prototype = {
}
},
_startNewLine: function (lines) {
_startNewLine: function () {
let currLine = this._currentLine;
if (currLine) {
// The current line is not empty. Trim it.
@@ -754,7 +755,7 @@ Serializer.prototype = {
this._lines.push("");
},
_appendText: function (text, lines) {
_appendText: function (text) {
this._currentLine += text;
},
@@ -777,7 +778,8 @@ Serializer.prototype = {
let col = tableHeadingCols[i];
if (col.localName != "th" || col.classList.contains("title-column"))
break;
colHeadings[i] = this._nodeText(col).trim();
colHeadings[i] = this._nodeText(
col, (col.classList && col.classList.contains("endline"))).trim();
}
}
let hasColHeadings = Object.keys(colHeadings).length > 0;
@@ -804,7 +806,10 @@ Serializer.prototype = {
let text = "";
if (colHeadings[j])
text += colHeadings[j] + ": ";
text += this._nodeText(children[j]).trim();
text += this._nodeText(
children[j],
(children[j].classList &&
children[j].classList.contains("endline"))).trim();
this._appendText(text);
this._startNewLine();
}
@@ -820,7 +825,10 @@ Serializer.prototype = {
if (this._ignoreElement(trs[i]))
continue;
let children = trs[i].querySelectorAll("th,td");
let rowHeading = this._nodeText(children[0]).trim();
let rowHeading = this._nodeText(
children[0],
(children[0].classList &&
children[0].classList.contains("endline"))).trim();
if (children[0].classList.contains("title-column")) {
if (!this._isHiddenSubHeading(children[0]))
this._appendText(rowHeading);
@@ -834,7 +842,10 @@ Serializer.prototype = {
// queued up from querySelectorAll earlier.
this._appendText(rowHeading + ": ");
} else {
this._appendText(rowHeading + ": " + this._nodeText(children[1]).trim());
this._appendText(rowHeading + ": " + this._nodeText(
children[1],
(children[1].classList &&
children[1].classList.contains("endline"))).trim());
}
}
this._startNewLine();
@@ -846,8 +857,16 @@ Serializer.prototype = {
return elem.classList.contains("no-copy");
},
_nodeText: function (node) {
return node.textContent.replace(/\s+/g, " ");
_nodeText: function (node, endline) {
let whiteChars = /\s+/g
let whiteCharsButNoEndline = /(?!\n)[\s]+/g;
let _node = node.cloneNode(true);
if (_node.firstElementChild &&
(_node.firstElementChild.nodeName.toLowerCase() == "button")) {
_node.removeChild(_node.firstElementChild);
}
return _node.textContent.replace(
endline ? whiteCharsButNoEndline : whiteChars, " ");
},
};
@@ -919,7 +938,7 @@ function setupEventListeners() {
PlacesDBUtils.checkAndFixDatabase(function(aLog) {
let msg = aLog.join("\n");
$("verify-place-result").style.display = "block";
$("verify-place-result").classList.remove("no-copy");
$("verify-place-result-parent").classList.remove("no-copy");
$("verify-place-result").textContent = msg;
});
});
+3 -3
View File
@@ -407,16 +407,16 @@
</h2>
<table>
<tr class="no-copy">
<tr id="verify-place-result-parent" class="no-copy">
<th class="column">
&aboutSupport.placeDatabaseIntegrity;
</th>
<td>
<td class="endline">
<button id="verify-place-integrity-button">
&aboutSupport.placeDatabaseVerifyIntegrity;
</button>
<pre id="verify-place-result" class="hidden no-copy"></pre>
<pre id="verify-place-result" class="hidden"></pre>
</td>
</tr>
</table>