Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
687aa3b6
Commit
687aa3b6
authored
Feb 13, 2020
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: Clean up code and make jslint happy
parent
a6bbe886
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
27 deletions
+21
-27
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.js
...ateItem/web_page_module/rjs_gadget_document_scanner_js.js
+19
-25
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.xml
...teItem/web_page_module/rjs_gadget_document_scanner_js.xml
+2
-2
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.js
View file @
687aa3b6
/*jslint indent: 2, unparam: true */
/*global rJS, RSVP, window, document, navigator, Cropper, Promise, JSON, jIO, promiseEventListener, domsugar, createImageBitmap, FormData, Caman
, URL, File
*/
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
Caman
,
URL
,
File
)
{
/*global rJS, RSVP, window, document, navigator, Cropper, Promise, JSON, jIO, promiseEventListener, domsugar, createImageBitmap, FormData, Caman*/
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
caman
)
{
"
use strict
"
;
//////////////////////////////////////////////////
...
...
@@ -51,10 +51,7 @@
}
function
handleCropper
(
element
,
data
,
callback
)
{
var
cropper
,
queue
=
new
RSVP
.
Queue
(),
img
=
domsugar
(
"
img
"
),
canvas
=
domsugar
(
'
canvas
'
,
{
'
class
'
:
'
canvas
'
});
var
cropper
;
function
canceller
()
{
cropper
.
destroy
();
...
...
@@ -97,7 +94,7 @@
});
})
.
push
(
function
(
evt
)
{
var
state_dict
=
{}
,
var
state_dict
=
{}
;
data
=
JSON
.
parse
(
evt
.
target
.
responseText
);
state_dict
[
'
blob_state_
'
+
blob_page
]
=
'
OK
'
;
state_dict
[
'
blob_uuid_
'
+
blob_page
]
=
data
.
uuid
;
...
...
@@ -188,12 +185,6 @@
return
gadget
.
getTranslationList
([
"
Page
"
,
"
New Page
"
])
.
push
(
function
(
result_list
)
{
thumbnail_dom_list
.
push
(
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
// Do not allow to show again the current image
disabled
:
(
len
===
gadget
.
state
.
page
-
1
),
'
class
'
:
'
new-btn ui-btn-icon-left ui-icon-plus
'
}));
for
(
i
=
0
;
i
<
len
;
i
+=
1
)
{
// XXX TODO display a loader when saving
if
(
gadget
.
state
[
'
blob_state_
'
+
i
]
!==
'
deleted
'
)
{
...
...
@@ -217,7 +208,13 @@
src
:
gadget
.
state
[
'
blob_url_
'
+
i
]})]));
}
}
return
domsugar
(
'
ol
'
,
{
"
class
"
:
"
thumbnail-list
"
},
thumbnail_dom_list
);
return
domsugar
(
"
div
"
,
{
"
class
"
:
"
thumbnail-area
"
},
[
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
// Do not allow to show again the current image
disabled
:
(
len
===
gadget
.
state
.
page
-
1
),
'
class
'
:
'
new-btn ui-btn-icon-left ui-icon-plus
'
}),
domsugar
(
'
ol
'
,
{
"
class
"
:
"
thumbnail-list
"
},
thumbnail_dom_list
)
]);
});
}
...
...
@@ -293,9 +290,7 @@
// Capture the media stream
function
captureAndRenderPicture
(
gadget
)
{
var
file
,
settings
=
gadget
.
state
.
preferred_image_settings_data
,
data
=
gadget
.
state
.
preferred_cropped_canvas_data
,
var
settings
=
gadget
.
state
.
preferred_image_settings_data
,
image_capture
=
new
window
.
ImageCapture
(
gadget
.
element
.
querySelector
(
'
video
'
).
srcObject
.
getVideoTracks
()[
0
]
),
...
...
@@ -319,7 +314,7 @@
var
canvas
=
domsugar
(
'
canvas
'
,
{
'
class
'
:
'
canvas
'
});
return
new
Promise
(
function
(
resolve
)
{
// XXX the correct usage is `new Caman()` but the library does not support it
C
aman
(
canvas
,
result
.
target
.
result
,
function
()
{
c
aman
(
canvas
,
result
.
target
.
result
,
function
()
{
if
(
settings
.
brightness
&&
settings
.
brightness
!==
0
)
{
this
.
brightness
(
settings
.
brightness
);
}
...
...
@@ -337,9 +332,8 @@
});
});
});
}
else
{
return
blob
;
}
return
blob
;
})
.
push
(
function
(
blob
)
{
return
RSVP
.
all
([
...
...
@@ -524,7 +518,7 @@
// if display_step is not modified
return
buildPreviousThumbnailDom
(
gadget
)
.
push
(
function
(
result
)
{
thumbnail_container
=
gadget
.
element
.
querySelector
(
'
.thumbnail-
list
'
);
thumbnail_container
=
gadget
.
element
.
querySelector
(
'
.thumbnail-
area
'
);
thumbnail_container
.
parentElement
.
replaceChild
(
result
,
thumbnail_container
...
...
@@ -659,7 +653,7 @@
for
(
key
in
gadget
.
state
)
{
if
(
gadget
.
state
.
hasOwnProperty
(
key
))
{
if
(
key
.
indexOf
(
"
blob_state_
"
)
!==
-
1
&&
gadget
.
state
[
key
]
==
"
OK
"
)
{
gadget
.
state
[
key
]
==
=
"
OK
"
)
{
uuid_key
=
"
blob_uuid_
"
+
key
.
replace
(
"
blob_state_
"
,
""
);
image_list
.
push
(
gadget
.
state
[
uuid_key
]);
}
...
...
@@ -700,4 +694,4 @@
.
declareAcquiredMethod
(
"
getTranslationList
"
,
"
getTranslationList
"
);
}(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
Caman
,
URL
,
File
));
\ No newline at end of file
}(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
Promise
,
JSON
,
jIO
,
promiseEventListener
,
domsugar
,
createImageBitmap
,
FormData
,
Caman
));
\ No newline at end of file
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.xml
View file @
687aa3b6
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
981.5
2410.59293.63010
</string>
</value>
<value>
<string>
981.5
3435.24231.47104
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
15815
34665.68
</float>
<float>
15815
96045.41
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment