Skip to content

Commit

Permalink
Add invisible spaces in html-tree (for compare).
Browse files Browse the repository at this point in the history
If copy html-tree and paste text to text-editor, you will see hierarchy.
Invisible spaces also copy to buffer.
Copy&Paste text from asn1js need for compare ASN1 in WinMerge or in
other compare-tools.
  • Loading branch information
polarnik committed Nov 28, 2014
1 parent 7d22aaf commit b40f505
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ var ASN1 = (typeof module !== 'undefined') ? require('./asn1.js') : window.ASN1,
}
};

ASN1.prototype.toDOM = function () {
ASN1.prototype.toDOM = function (spaces) {
var node = DOM.tag("div", "node");
node.asn1 = this;
var head = DOM.tag("div", "head");
var s = this.typeName().replace(/_/g, " ");
head.innerHTML = s;
if (spaces == undefined)
spaces = "";
head.innerHTML = "<span class='spaces'>" + spaces + "</span>" + s;
spaces = spaces + "&nbsp;&nbsp;";
var content = this.content(contentLength);
if (content !== null) {
var preview = DOM.tag("span", "preview"),
Expand Down Expand Up @@ -97,7 +100,7 @@ ASN1.prototype.toDOM = function () {
var sub = DOM.tag("div", "sub");
if (this.sub !== null) {
for (var i = 0, max = this.sub.length; i < max; ++i)
sub.appendChild(this.sub[i].toDOM());
sub.appendChild(this.sub[i].toDOM(spaces));
}
node.appendChild(sub);
head.onclick = function () {
Expand Down
3 changes: 3 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ html, body {
color: #505050;
font-weight: normal;
}
.spaces {
font-size: 0px;
}
#tree {
font-family: monospace;
}
Expand Down

3 comments on commit b40f505

@polarnik
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asn1 js spaces

@lapo-luchini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nice (and easy to implement) idea, I'm sorry I didn't merge it sooner.

@lapo-luchini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Committed in c27f970

Please sign in to comment.