Skip to content

Commit

Permalink
Handle cash deposits with deposit slips correctly. (Was getting stuck…
Browse files Browse the repository at this point in the history
… in a loop before.)
  • Loading branch information
abjennings committed Oct 31, 2014
1 parent 843c3fd commit 64e2fc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
20 changes: 12 additions & 8 deletions data/get-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@

function clickNextLink() {
var depositDetailsTbl = document.getElementById('DepositDetailsList');
var links = depositDetailsTbl.getElementsByTagName('a');
for (var i = links.length - 1; i >= 0; --i) {
var link = links[i];
if (link.innerHTML.trim() === "See" && !clickedLinks[link.id]) {
clickedLinks[link.id] = 1;
link.click();
setTimeout(function() { checkForImage(i); }, 100);
return;
if (!depositDetailsTbl) {
self.port.emit("AddDepositToIgnore", seq);
} else {
var links = depositDetailsTbl.getElementsByTagName('a');
for (var i = links.length - 1; i >= 0; --i) {
var link = links[i];
if (link.innerHTML.trim() === "See" && !clickedLinks[link.id]) {
clickedLinks[link.id] = 1;
link.click();
setTimeout(function() { checkForImage(i); }, 100);
return;
}
}
}
returnLink.click();
Expand Down
12 changes: 10 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var widget = require("sdk/widget");
var tabs = require("sdk/tabs");
var simplePrefs = require("sdk/simple-prefs");
var notifications = require("sdk/notifications");
var depositsToIgnore = {};

function SaveImage(msg) {
var fname = msg[0];
Expand All @@ -29,6 +30,11 @@ function SaveImage(msg) {
}
}

function AddDepositToIgnore(depno)
{
depositsToIgnore[depno] = 1;
}

function ItemList(lst) {
var dir = simplePrefs.prefs['directory'];
var fileList = fileIO.list(dir);
Expand All @@ -41,7 +47,7 @@ function ItemList(lst) {
}
}
for (i = 0; i < lst.length; ++i) {
if (!fileDict[lst[i]]) {
if (!fileDict[lst[i]] && !depositsToIgnore[lst[i]]) {
activityWorker.port.emit('Goto', lst[i]);
return;
}
Expand All @@ -61,7 +67,9 @@ function attachToTab(tab) {
activityWorker.port.on('ItemList', ItemList);
return true;
} else if (checkImageRE.test(tab.url) || depositRE.test(tab.url)) {
tab.attach({ contentScriptFile: data.url("get-images.js") }).port.on('SaveImage', SaveImage);
var checkWorker = tab.attach({ contentScriptFile: data.url("get-images.js") });
checkWorker.port.on('SaveImage', SaveImage);
checkWorker.port.on('AddDepositToIgnore', AddDepositToIgnore);
return true;
} else {
return false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Download all check images from Chase quickly",
"author": "Andrew Jennings",
"license": "MPL 2.0",
"version": "0.14",
"version": "0.15",
"preferences": [{
"name": "directory",
"title": "Directory for images",
Expand Down

0 comments on commit 64e2fc2

Please sign in to comment.