Skip to content

Commit

Permalink
fixes External links shouldn't have duplicate detection... #16
Browse files Browse the repository at this point in the history
  • Loading branch information
pmario committed Feb 5, 2018
1 parent db174f1 commit aed71de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
25 changes: 10 additions & 15 deletions addon/content_scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ function createDomElements(parent, el) {

// main function
function main() {
injectMessageBox();
checkUrlConflict();
// check, if we are allowed to run!!
if (isTiddlyWiki5File(document) || isTiddlyWikiClassicFile(document)) {
injectMessageBox(document);
checkUrlConflict();
}
}

// TODO it's ugly .. improve this
Expand Down Expand Up @@ -205,7 +208,7 @@ function isTiddlyWiki5File(doc) {
var meta = document.getElementsByTagName("META");
if (meta) {
for (let i = 0; i < meta.length; i++) {
if (meta[i].content === "TiddlyWiki") return (doc.location.protocol === "file:");
if (meta[i].content === "TiddlyWiki") return true;
}
}
return false;
Expand Down Expand Up @@ -234,15 +237,9 @@ function injectClassicScript(doc) {

// main loop
function injectMessageBox(doc) {
doc = document;

// check, if we are allowed to run!!
if (isTiddlyWiki5File(doc)) {
// do nothing
} else if (isTiddlyWikiClassicFile(doc)) {
// check, if we are TWclassic!!
if (isTiddlyWikiClassicFile(doc)) {
injectClassicScript(doc);
} else {
return;
}

// Inject the message box
Expand Down Expand Up @@ -317,12 +314,10 @@ function injectMessageBox(doc) {
];
// backendMessage(template, color, background)
backendMessage(tabCreateMessage, "black", "lightgreen");
}
// alert("The file can't be saved to:" + path + "\n\nThe next save will open a 'Save Dialog'!");
// message.parentNode.setAttribute("data-tiddlyfox-saveas", "yes");
} // else if(response.openNewTabError)
} else {
message.parentNode.setAttribute("data-tiddlyfox-saveas", "no");
}
} // if (response.relPath === "")

let event1 = doc.createEvent("Events");
message.parentNode.setAttribute("data-tiddlyfox-subdir", response.subdir || "");
Expand Down
25 changes: 10 additions & 15 deletions content_scripts/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ function createDomElements(parent, el) {

// main function
function main() {
injectMessageBox();
checkUrlConflict();
// check, if we are allowed to run!!
if (isTiddlyWiki5File(document) || isTiddlyWikiClassicFile(document)) {
injectMessageBox(document);
checkUrlConflict();
}
}

// TODO it's ugly .. improve this
Expand Down Expand Up @@ -125,7 +128,7 @@ function isTiddlyWiki5File(doc) {
var meta = document.getElementsByTagName("META");
if (meta) {
for (let i = 0; i < meta.length; i++) {
if (meta[i].content === "TiddlyWiki") return (doc.location.protocol === "file:");
if (meta[i].content === "TiddlyWiki") return true;
}
}
return false;
Expand Down Expand Up @@ -154,15 +157,9 @@ function injectClassicScript(doc) {

// main loop
function injectMessageBox(doc) {
doc = document;

// check, if we are allowed to run!!
if (isTiddlyWiki5File(doc)) {
// do nothing
} else if (isTiddlyWikiClassicFile(doc)) {
// check, if we are TWclassic!!
if (isTiddlyWikiClassicFile(doc)) {
injectClassicScript(doc);
} else {
return;
}

// Inject the message box
Expand Down Expand Up @@ -237,12 +234,10 @@ function injectMessageBox(doc) {
];
// backendMessage(template, color, background)
backendMessage(tabCreateMessage, "black", "lightgreen");
}
// alert("The file can't be saved to:" + path + "\n\nThe next save will open a 'Save Dialog'!");
// message.parentNode.setAttribute("data-tiddlyfox-saveas", "yes");
} // else if(response.openNewTabError)
} else {
message.parentNode.setAttribute("data-tiddlyfox-saveas", "no");
}
} // if (response.relPath === "")

let event1 = doc.createEvent("Events");
message.parentNode.setAttribute("data-tiddlyfox-subdir", response.subdir || "");
Expand Down

0 comments on commit aed71de

Please sign in to comment.