Skip to content

Commit

Permalink
handle edge case where page title has <html> elements, also changed a…
Browse files Browse the repository at this point in the history
…nimation speed of save indicator
  • Loading branch information
tconfrey committed Feb 28, 2024
1 parent e820f7b commit c16e71a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
7 changes: 5 additions & 2 deletions app/BTAppNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ class BTAppNode extends BTNode {
// Node title as shown in tree, <a> for url. Compare to BTNode.displayTag = plain tag text
let txt = "";
if (this._keyword) txt += `<span class='keyword'>${this._keyword} </span>`; // TODO etc
return txt + BTAppNode._orgTextToHTML(this.title);

// first escape any html entities
let title = this.title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
return txt + BTAppNode._orgTextToHTML(title);
}

url() {
Expand Down Expand Up @@ -512,7 +515,7 @@ class BTAppNode extends BTNode {
});
window.postMessage({'function': 'groupAndPositionTabs', 'tabGroupId': this.tabGroupId,
'windowId': this.windowId, 'tabInfo': tabInfo,
'groupName': BTAppNode.displayTagFromTitle(this.displayTag)});
'groupName': BTAppNode.displayNameFromTitle(this.displayTag)});
}

putInGroup() {
Expand Down
11 changes: 7 additions & 4 deletions app/BTNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BTNode {
this._title = title;
this._parentId = parentId;
this._URL = BTNode.URLFromTitle(title);
this._displayTag = BTNode.displayTagFromTitle(title);
this._displayTag = BTNode.displayNameFromTitle(title);
this._childIds = [];
this._tagPath = '';
this.generateUniqueTagPath();
Expand All @@ -32,7 +32,7 @@ class BTNode {
set title(ttl) {
this._title = ttl;
this._URL = BTNode.URLFromTitle(ttl); // regenerate URL when title is changed
this._displayTag = BTNode.displayTagFromTitle(ttl);
this._displayTag = BTNode.displayNameFromTitle(ttl);
}
get title() {
return this._title;
Expand Down Expand Up @@ -124,8 +124,11 @@ class BTNode {
return hits ? hits[1] : "";
}

static displayTagFromTitle(title) {
// Visible tag for this node. Pull tags out, use url if no tag
static displayNameFromTitle(title) {
// Visible title for this node. Pull displayed title out, use url if none

// first escape any html entities
title = title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
let outputStr = title.replace(/\[\[(.*?)\]\[(.*?)\]\]/gm, (match, $1, $2) =>
{return $2 || $1;});
return outputStr;
Expand Down
2 changes: 1 addition & 1 deletion app/bt.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function brainZoom(iteration = 0) {
return;
}
$("#brain").attr("src", path);
const interval = 150; //iteration == 4 ? 200 : 100;
const interval = (iteration <= 4 ? 150 : 50);
setTimeout(function() {brainZoom(++iteration);}, interval);

}
Expand Down
7 changes: 5 additions & 2 deletions versions/Release-Candidate/app/BTAppNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ class BTAppNode extends BTNode {
// Node title as shown in tree, <a> for url. Compare to BTNode.displayTag = plain tag text
let txt = "";
if (this._keyword) txt += `<span class='keyword'>${this._keyword} </span>`; // TODO etc
return txt + BTAppNode._orgTextToHTML(this.title);

// first escape any html entities
let title = this.title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
return txt + BTAppNode._orgTextToHTML(title);
}

url() {
Expand Down Expand Up @@ -512,7 +515,7 @@ class BTAppNode extends BTNode {
});
window.postMessage({'function': 'groupAndPositionTabs', 'tabGroupId': this.tabGroupId,
'windowId': this.windowId, 'tabInfo': tabInfo,
'groupName': BTAppNode.displayTagFromTitle(this.displayTag)});
'groupName': BTAppNode.displayNameFromTitle(this.displayTag)});
}

putInGroup() {
Expand Down
11 changes: 7 additions & 4 deletions versions/Release-Candidate/app/BTNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BTNode {
this._title = title;
this._parentId = parentId;
this._URL = BTNode.URLFromTitle(title);
this._displayTag = BTNode.displayTagFromTitle(title);
this._displayTag = BTNode.displayNameFromTitle(title);
this._childIds = [];
this._tagPath = '';
this.generateUniqueTagPath();
Expand All @@ -32,7 +32,7 @@ class BTNode {
set title(ttl) {
this._title = ttl;
this._URL = BTNode.URLFromTitle(ttl); // regenerate URL when title is changed
this._displayTag = BTNode.displayTagFromTitle(ttl);
this._displayTag = BTNode.displayNameFromTitle(ttl);
}
get title() {
return this._title;
Expand Down Expand Up @@ -124,8 +124,11 @@ class BTNode {
return hits ? hits[1] : "";
}

static displayTagFromTitle(title) {
// Visible tag for this node. Pull tags out, use url if no tag
static displayNameFromTitle(title) {
// Visible title for this node. Pull displayed title out, use url if none

// first escape any html entities
title = title.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
let outputStr = title.replace(/\[\[(.*?)\]\[(.*?)\]\]/gm, (match, $1, $2) =>
{return $2 || $1;});
return outputStr;
Expand Down
2 changes: 1 addition & 1 deletion versions/Release-Candidate/app/bt.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function brainZoom(iteration = 0) {
return;
}
$("#brain").attr("src", path);
const interval = 150; //iteration == 4 ? 200 : 100;
const interval = (iteration <= 4 ? 150 : 50);
setTimeout(function() {brainZoom(++iteration);}, interval);

}
Expand Down

0 comments on commit c16e71a

Please sign in to comment.