Skip to content

Commit

Permalink
Merge pull request #22 from Cortys/2.0.2
Browse files Browse the repository at this point in the history
Update to Version 2.0.2
  • Loading branch information
Cortys committed Dec 19, 2014
2 parents 4eb3d2e + b9e2b66 commit 476833e
Show file tree
Hide file tree
Showing 21 changed files with 829 additions and 467 deletions.
5 changes: 5 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripturl": true,
"eqnull": true,
"loopfunc": true
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is a Chrome/Chromium extension, that allows you to do just that. After inst
Installation
-----

The installation is slightly complicated (since I don't want to add this to the Chrome Store).
The installation is slightly complicated (since I don't want to add this to the Chrome Store).
There are two ways of installing the extension.

### *IMPORTANT* for Windows users
Expand Down Expand Up @@ -78,6 +78,6 @@ Project started by SpergLord Enterprises, LLC and continued by other awesome con

If you have problems with the software/have an idea, add an issue on Github via Issues.

The code is under GPLv3 licence. Code uses JSZip by Stuart Knightley and JavaScript-Canvas-to-Blob by Sebastian Tschan.
The code is under GPLv3 licence. Code uses zip.js by Gildas Lormeau and JavaScript-Canvas-to-Blob by Sebastian Tschan.

[League Gothic](https://github.com/theleagueof/league-gothic) by Caroline Hadilaksono, Micah Rich, & Tyler Finck is used.
Binary file modified download.zip
Binary file not shown.
Binary file modified extension.crx
Binary file not shown.
40 changes: 21 additions & 19 deletions source/backgroundManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
//(C) 2013 Sperglord Enterprises
//Code is under GNUGPLv3 - read http://www.gnu.org/licenses/gpl.html

zip.workerScriptsPath = "/zip/";
zip.useWebWorkers = true;

zip.workerScriptsPath = "zip/";

zip.workerScripts = {
deflater: ["z-worker.js", "deflate.js"]
};

var ports = { // stores all opened connections of tabs to bg page
reader: {}, // reader tab connections
Expand Down Expand Up @@ -30,7 +36,7 @@ var ports = { // stores all opened connections of tabs to bg page
getWriter = function(callback) {
var tmpName, run;
if(!settings.tempMemory || !requestFileSystem) {
callback(new zip.BlobWriter());
callback(new zip.BlobWriter("application/"+(settings.container?"zip":"x-cbz")));
fs = null;
}
else {
Expand All @@ -47,7 +53,7 @@ var ports = { // stores all opened connections of tabs to bg page
run();
}, create);
};

if(!fs)
requestFileSystem(TEMPORARY, 4 * 1024 * 1024 * 1024, function (f) {
fs = f;
Expand All @@ -59,23 +65,23 @@ var ports = { // stores all opened connections of tabs to bg page
};

getSettings(function() {

connector.onConnect.addListener(function(port) {

if(port.name == "download") {
port.receive(function(request, callback) {
downloadFile(request.name, request.data, request.overwrite, callback);
});
return true;
}

var sender = port.senderId = port.sender.tab.id;

ports[port.name][sender] = port;

if(port.name == "controller")
port.children = {}; // each connection stores the ids of the tabs it opened as children; key = tab id, value always true

if(port.name == "reader") // ZIPPING logic - moved to background script to have a dedicated tab/thread for compression so that it doesn't make the reader tab itself slow
port.receive(function(request, callback) {
if(request.what == "new_zip") {
Expand Down Expand Up @@ -121,16 +127,12 @@ getSettings(function() {
return true;
}
else if(request.what == "message_to_opener" && openers[sender] !== "undefined" && ports.controller[openers[sender]]) {
ports.controller[openers[sender]].send({ what:"child_message", tab:sender, message:request.message }, function(data) {
callback(data);
});
ports.controller[openers[sender]].send({ what:"child_message", tab:sender, message:request.message }, callback);
return true;
}
else if(request.what == "broadcast_to_openers") {
for(var tab in ports.controller) {
ports.controller[tab].send({ what:"child_broadcast", tab:sender, message:request.message }, function(data) {
callback(data);
});
ports.controller[tab].send({ what:"child_broadcast", tab:sender, message:request.message }, callback);
}
return true;
}
Expand All @@ -156,23 +158,23 @@ getSettings(function() {
return true;
}
});

var disconnectAction = port.name == "controller"?function() {
for (var tab in port.children)
if(ports.reader[tab] && !ports.reader[tab].unlinked)
chrome.tabs.remove(tab*1);
}:closedReader;

port.onDisconnect.addListener(function() {
delete ports[port.name][sender];
disconnectAction(port);
port = sender = null;
});
});

});

chrome.runtime.onMessage.addListener(function(message) {
if(message == "update_settings")
getSettings();
});
});
Loading

0 comments on commit 476833e

Please sign in to comment.