Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions extension/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var testmode = false; //set to true to avoid path test
var testmode = true; //set to true to avoid path test
var minutebacks = false; //set to true to allow backs every minute for testing

var tiddlywikilocations = "tiddlywikilocations";
Expand Down Expand Up @@ -45,7 +45,17 @@ chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {


function dodownload (msg,tiddlywikilocations){
var objUrl = URL.createObjectURL(new Blob([msg.txt], {type: 'text/html'}));
var objUrl = URL.createObjectURL(new Blob([msg.txt], {type: 'text/html'}));

console.log("id:" + chrome.runtime.id)

chrome.downloads.onDeterminingFilename.addListener(function SuggestFilename(item, suggest) {
if (item.byExtensionId && item.byExtensionId === chrome.runtime.id) {
suggest({filename: tiddlywikilocations+$["/"]+ msg.path, conflictAction: 'overwrite'});
chrome.downloads.onDeterminingFilename.removeListener(SuggestFilename);
}
});

chrome.downloads.download({
url: objUrl,
filename: tiddlywikilocations+$["/"]+ msg.path,
Expand Down Expand Up @@ -119,6 +129,7 @@ function dodownload (msg,tiddlywikilocations){
}
console.log("savetiddlersbg: background 3nd step");
// show the choose file dialogue when tw not under 'tiddlywikilocations'
// testmode=true
if (!msg.twdl) {
console.log("savetiddlersbg: not in "+tiddlywikilocations+" "+msg.path);
sendResponse({status:"failedloc",location:tiddlywikilocations});
Expand Down Expand Up @@ -206,6 +217,4 @@ function dodownload (msg,tiddlywikilocations){
}
});
}return true;
});


});