Skip to content

Commit

Permalink
1.4
Browse files Browse the repository at this point in the history
RELEASE
* also fixed an issue with getPrefNoSetStuff('quick_save_dir')
* also commented out the console.log's in the ocr workers, no need for
those
  • Loading branch information
Noitidart committed Jan 12, 2016
1 parent f61b7b3 commit 255cb94
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 37 deletions.
2 changes: 0 additions & 2 deletions amo-reviewer.txt

This file was deleted.

2 changes: 1 addition & 1 deletion app/js/app_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const core = {
resources: 'chrome://nativeshot/content/resources/',
images: 'chrome://nativeshot/content/resources/images/'
},
cache_key: Math.random()
cache_key: 'v1.4'
},
os: {
name: OS.Constants.Sys.Name.toLowerCase(),
Expand Down
2 changes: 1 addition & 1 deletion app/js/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const core = {
resources: 'chrome://nativeshot/content/resources/',
images: 'chrome://nativeshot/content/resources/images/'
},
cache_key: Math.random()
cache_key: 'v1.4'
},
os: {
name: OS.Constants.Sys.Name.toLowerCase(),
Expand Down
50 changes: 25 additions & 25 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const core = {
scripts: 'chrome://nativeshot/content/resources/scripts/',
styles: 'chrome://nativeshot/content/resources/styles/',
},
cache_key: Math.random() // set to version on release
cache_key: 'v1.4' // set to version on release
},
os: {
name: OS.Constants.Sys.Name.toLowerCase(),
Expand Down Expand Up @@ -1667,12 +1667,12 @@ var gEditor = {
(this.canComp.toBlobHD || this.canComp.toBlob).call(this.canComp, function(b) {
gEditor.closeOutEditor(e); // as i cant close out yet as i need this.canComp see line above this one: `(this.canComp.toBlobHD || this.canComp.toBlob).call(this.canComp, function(b) {` link374748304
// let file = new FileUtils.File('C:\\Users\\Vayeate\\Pictures\\imglogo.jpg');
console.log('blob ready:', b);


var fileReader = Cc['@mozilla.org/files/filereader;1'].createInstance(Ci.nsIDOMFileReader);
fileReader.addEventListener('load', function (event) {
var buffer = event.target.result;
// console.error('buffer ready:', buffer.constructor.name);


var pathToRevImg = OS.Path.join(OS.Constants.Path.tmpDir, 'nativeshot_revsearch-' + Date.now() + '.png');
var promise_writeRevImg = OS.File.writeAtomic(pathToRevImg, new Uint8Array(buffer));
Expand Down Expand Up @@ -1713,15 +1713,15 @@ var gEditor = {
name: 'promise_writeRevImg',
aReason: aReason
};
console.error(rejObj);

}
).catch(
function(aCaught) {
var rejObj = {
name: 'promise_writeRevImg',
aCaught: aCaught
};
console.error(rejObj);

}
);

Expand Down Expand Up @@ -1768,7 +1768,7 @@ var gEditor = {
};

var cImgData = this.ctxComp.getImageData(0, 0, this.canComp.width, this.canComp.height);
console.log('cImgData:', cImgData);

gEditor.closeOutEditor(e);

var promiseAllArr_ocr = [];
Expand All @@ -1786,7 +1786,7 @@ var gEditor = {
var promiseAll_ocr = Promise.all(promiseAllArr_ocr);
promiseAll_ocr.then(
function(aTxtArr) {
console.log('Fullfilled - promiseAll_ocr - ', aTxtArr);

cImgData = undefined; // when do all, we dont transfer, so it doesnt get neutered, so lets just do this, it might help it gc
var alertStrArr = [];
for (var i=0; i<allArr_serviceTypeStr.length; i++) {
Expand All @@ -1809,13 +1809,13 @@ var gEditor = {
var selectedChoiceIndex = {};
var rez_select = Services.prompt.select(cDOMWindow, 'NativeShot - Copy to Clipboard', 'Select which result to copy to clipboard:', choices.length, choices, selectedChoiceIndex)
if (rez_select) {
console.log('selectedChoiceIndex:', selectedChoiceIndex); // this is ```Object { value: 2 }```

if (selectedChoiceIndex.value == 0) {
copyTextToClip(alertStr, cDOMWindow);
console.log('copied all to clip:', alertStr);

} else {
copyTextToClip(aTxtArr[selectedChoiceIndex.value - 1], cDOMWindow);
console.log('copied just ', selectedChoiceIndex.value, ' to clip:', aTxtArr[selectedChoiceIndex.value - 1]);

}
}
}
Expand Down Expand Up @@ -3054,15 +3054,15 @@ function getPrefNoSetStuff(aPrefName) {
// os path to dir to save in
var defaultVal = function() {
try {
OSPath_saveDir = Services.dirsvc.get('XDGPict', Ci.nsIFile).path; // works on linux
return Services.dirsvc.get('XDGPict', Ci.nsIFile).path; // works on linux
} catch (ex) {
try {
OSPath_saveDir = Services.dirsvc.get('Pict', Ci.nsIFile).path; // works on windows
return Services.dirsvc.get('Pict', Ci.nsIFile).path; // works on windows
} catch (ex) {
try {
OSPath_saveDir = Services.dirsvc.get('Pct', Ci.nsIFile).path; // works on mac
return Services.dirsvc.get('Pct', Ci.nsIFile).path; // works on mac
} catch (ex) {
OSPath_saveDir = OS.Constants.Path.desktopDir;
return OS.Constants.Path.desktopDir;
}
}
}
Expand Down Expand Up @@ -3459,7 +3459,7 @@ function SICWorker(workerScopeName, aPath, aFuncExecScope=bootstrap, aCore=core)
var afterInitListener = function(aMsgEvent) {
// note:all msgs from bootstrap must be postMessage([nameOfFuncInWorker, arg1, ...])
var aMsgEventData = aMsgEvent.data;
console.log('mainthread receiving message:', aMsgEventData);


// postMessageWithCallback from worker to mt. so worker can setup callbacks after having mt do some work
var callbackPendingId;
Expand All @@ -3478,20 +3478,20 @@ function SICWorker(workerScopeName, aPath, aFuncExecScope=bootstrap, aCore=core)
function(aVal) {
if (aVal.length >= 2 && aVal[aVal.length-1] == SIC_TRANS_WORD && Array.isArray(aVal[aVal.length-2])) {
// to transfer in callback, set last element in arr to SIC_TRANS_WORD and 2nd to last element an array of the transferables // cannot transfer on promise reject, well can, but i didnt set it up as probably makes sense not to
console.error('doing transferrrrr');

aVal.pop();
bootstrap[workerScopeName].postMessage([callbackPendingId, aVal], aVal.pop());
} else {
bootstrap[workerScopeName].postMessage([callbackPendingId, aVal]);
}
},
function(aReason) {
console.error('aReject:', aReason);

bootstrap[workerScopeName].postMessage([callbackPendingId, ['promise_rejected', aReason]]);
}
).catch(
function(aCatch) {
console.error('aCatch:', aCatch);

bootstrap[workerScopeName].postMessage([callbackPendingId, ['promise_rejected', aCatch]]);
}
);
Expand All @@ -3507,7 +3507,7 @@ function SICWorker(workerScopeName, aPath, aFuncExecScope=bootstrap, aCore=core)
}
}
}
else { console.warn('funcName', funcName, 'not in scope of aFuncExecScope') } // else is intentionally on same line with console. so on finde replace all console. lines on release it will take this out


};

Expand All @@ -3531,11 +3531,11 @@ function SICWorker(workerScopeName, aPath, aFuncExecScope=bootstrap, aCore=core)
var thisCallbackId = SIC_CB_PREFIX + sic_last_cb_id; // + lastCallbackId; // link8888881
aFuncExecScope[thisCallbackId] = function() {
delete aFuncExecScope[thisCallbackId];
// console.log('in mainthread callback trigger wrap, will apply aCB with these arguments:', arguments, 'turned into array:', Array.prototype.slice.call(arguments));

aCB.apply(null, arguments[0]);
};
aPostMessageArr.push(thisCallbackId);
// console.log('aPostMessageArr:', aPostMessageArr);

bootstrap[workerScopeName].postMessage(aPostMessageArr, aPostMessageTransferList);
};

Expand Down Expand Up @@ -4051,7 +4051,7 @@ function encodeFormData(data, charset, forArrBuf_nameDotExt, forArrBuf_mimeType)
var mime = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
ctype = mime.getTypeFromFile(v) || ctype;
} catch (ex) {
console.warn("failed to get type", ex);

}
item += "Content-Type: " + ctype + "\r\n\r\n";

Expand All @@ -4064,7 +4064,7 @@ function encodeFormData(data, charset, forArrBuf_nameDotExt, forArrBuf_mimeType)
item = "";

} else {
console.error('in else');

item += "Content-Disposition: form-data; name=\"" + encode(k, true) + "\"\r\n\r\n";
item += encode(v);

Expand All @@ -4089,7 +4089,7 @@ function genericReject(aPromiseName, aPromiseToReject, aReason) {
name: aPromiseName,
aReason: aReason
};
console.error('Rejected - ' + aPromiseName + ' - ', rejObj);

if (aPromiseToReject) {
aPromiseToReject.reject(rejObj);
}
Expand All @@ -4099,7 +4099,7 @@ function genericCatch(aPromiseName, aPromiseToReject, aCaught) {
name: aPromiseName,
aCaught: aCaught
};
console.error('Caught - ' + aPromiseName + ' - ', rejObj);

if (aPromiseToReject) {
aPromiseToReject.reject(rejObj);
}
Expand Down
4 changes: 2 additions & 2 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>NativeShot@jetpack</em:id>
<em:version>1.3-night</em:version>
<em:version>1.3</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:optionsType>3</em:optionsType>
Expand All @@ -16,7 +16,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>33.0</em:minVersion> <!-- due to PromiseWorker (badging of countdown only works 36+) (sharing to twitter only works in version supporting globalmessagemanager im not sure what that min version is) -->
<em:maxVersion>41.0</em:maxVersion> <!-- the latest version i tested it in -->
<em:maxVersion>44.*</em:maxVersion> <!-- the latest version i tested it in -->
</Description>
</em:targetApplication>

Expand Down
2 changes: 1 addition & 1 deletion modules/gocr/GOCRWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ worker.log = function(...args) {
self.addEventListener('message', msg => worker.handleMessage(msg));

function readByteArr(aImgBuf, aWidth, aHeight) {
console.info('GOCR aImgBuf:', aImgBuf, 'aWidth:', aWidth, 'aHeight:', aHeight, '');
// console.info('GOCR aImgBuf:', aImgBuf, 'aWidth:', aWidth, 'aHeight:', aHeight, '');
var cImgData = new ImageData(new Uint8ClampedArray(aImgBuf), aWidth, aHeight);
var txt = GOCR(cImgData);
return txt;
Expand Down
2 changes: 1 addition & 1 deletion modules/ocrad/OCRADWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ worker.log = function(...args) {
self.addEventListener('message', msg => worker.handleMessage(msg));

function readByteArr(aImgBuf, aWidth, aHeight) {
console.info('OCRAD aImgBuf:', aImgBuf, 'aWidth:', aWidth, 'aHeight:', aHeight, '');
// console.info('OCRAD aImgBuf:', aImgBuf, 'aWidth:', aWidth, 'aHeight:', aHeight, '');
var cImgData = new ImageData(new Uint8ClampedArray(aImgBuf), aWidth, aHeight);
var txt = OCRAD(cImgData);
return txt;
Expand Down
8 changes: 4 additions & 4 deletions resources/scripts/fs_twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var core = {
content_accessible: 'chrome://nativeshot-accessible/content/',
scripts: 'chrome://nativeshot/content/resources/scripts/'
},
cache_key: Math.random() // set to version on release
cache_key: 'v1.4' // set to version on release
}
};
const gContentFrameMessageManager = this;
Expand Down Expand Up @@ -169,14 +169,14 @@ function on_nativeShot_notifyDataTweetSuccess(aEvent) {

var parser = Cc['@mozilla.org/xmlextras/domparser;1'].createInstance(Ci.nsIDOMParser);
var parsedDocument = parser.parseFromString(refDetails.tweet_html, 'text/html');
console.error('refDetails.tweet_html:', refDetails.tweet_html);


var photos = [];
var pattPhotoUrl = /data-(?:image-url|img-src)=["']?([^"' >]+)/g; // https://github.com/Noitidart/NativeShot/wiki/Twitter-Response-HTML
var matchPhotoUrl;
console.log('ok looping');

while (matchPhotoUrl = pattPhotoUrl.exec(refDetails.tweet_html)) {
console.log('matchPhotoUrl:', matchPhotoUrl);

photos.push(matchPhotoUrl[1]);
}

Expand Down

0 comments on commit 255cb94

Please sign in to comment.