Commit b5712227 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Improve code and comment

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