Commit b5712227 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Improve code and comment

parent 3add7a8f
......@@ -17,7 +17,7 @@
});
}
function handleDataURLRead(data_url) {
function getOrientationFromDataUrl(data_url) {
var view = new DataView(data_url),
length = view.byteLength,
offset = 2,
......@@ -59,18 +59,14 @@
return -1;
}
function getOrientation(blob, callback) {
var fr = new FileReader();
return new RSVP.Promise(function waitFormDataURLRead(resolve, reject) {
fr.addEventListener("load", function onload(evt) {
resolve(handleDataURLRead(evt.target.result));
function getOrientation(blob) {
return RSVP.Queue()
.push(function () {
return jIO.util.readBlobAsArrayBuffer(blob);
})
.push(function (evt) {
return getOrientationFromDataUrl(evt.target.result);
});
fr.addEventListener("error", reject);
fr.readAsArrayBuffer(blob);
}, function cancelReadBlobAsDataURL() {
fr.abort();
});
}
function handleUserMedia(device_id, callback) {
......@@ -159,11 +155,11 @@
viewMode: 3,
// Avoid any cropper calculation or guessing
scalable: false,
// By default rotatable is true, if you remove it.
// Make sure, it is set on data.
// Please, DON'T touch on rotatable and checkOrientation. Removing it,
// we will not be able to fix orientation before crop.
rotatable: true,
zoomable: false,
checkOrientation: true,
zoomable: false,
movable: false,
data: data,
ready: function () {
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.16659.47570.45977</string> </value>
<value> <string>982.16683.22364.19575</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1583149298.17</float>
<float>1583153003.34</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment