Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
545c1444
Commit
545c1444
authored
4 years ago
by
Steinwender, Tamara
Browse files
Options
Downloads
Patches
Plain Diff
Add code documentation
parent
b04521a9
No related branches found
No related tags found
No related merge requests found
Pipeline
#13486
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/qr-code-scanner/src/qr-code-scanner.js
+29
-12
29 additions, 12 deletions
packages/qr-code-scanner/src/qr-code-scanner.js
with
29 additions
and
12 deletions
packages/qr-code-scanner/src/qr-code-scanner.js
+
29
−
12
View file @
545c1444
...
...
@@ -84,6 +84,11 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
}
};
/**
* Ckecks if browser support video recording
* Gets video devices of device
*
*/
checkSupport
()
{
const
that
=
this
;
let
devices_map
=
new
Map
();
...
...
@@ -93,8 +98,6 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
navigator
.
mediaDevices
.
enumerateDevices
()
.
then
(
function
(
devices
)
{
devices
.
forEach
(
function
(
device
)
{
//console.log(device.kind + ": " + device.label + " id = " + device.deviceId);
// that._("#error").innerText += " | device.kind: " + device.kind + " id: " + device.deviceId + " label: " + device.label + " | ";
if
(
device
.
kind
===
'
videoinput
'
)
{
let
id
=
device
.
deviceId
;
if
(
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
.
test
(
navigator
.
userAgent
))
{
...
...
@@ -119,8 +122,6 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
}
else
{
that
.
activeCamera
=
Array
.
from
(
devices_map
)[
0
][
0
];
}
})
.
catch
(
function
(
err
)
{
console
.
log
(
err
.
name
+
"
:
"
+
err
.
message
);
...
...
@@ -132,7 +133,6 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
const
results
=
[];
for
(
let
i
=
0
;
i
!==
sourceInfos
.
length
;
++
i
)
{
const
sourceInfo
=
sourceInfos
[
i
];
// that._("#error").innerText += " * kind: " + sourceInfo.kind + " id: " + sourceInfo.id + " label: " + sourceInfo.label + " * ";
if
(
sourceInfo
.
kind
===
'
video
'
)
{
devices_map
.
set
(
sourceInfo
.
id
?
sourceInfo
.
id
:
true
,
sourceInfo
.
label
||
i18n
.
t
(
'
camera
'
)
+
(
devices_map
.
size
+
1
))
results
.
push
({
...
...
@@ -158,17 +158,25 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
}
/**
* Get a loading message
*
* @param string
*/
getLoadingMsg
(
string
)
{
let
loadingMsg
=
html
`<dbp-mini-spinner class="spinner"></dbp-mini-spinner>
${
i18n
.
t
(
string
)}
`
;
return
loadingMsg
;
}
/**
* Init and start the video and QR code scan
*
*/
qrCodeScannerInit
()
{
this
.
stopScan
=
false
;
this
.
askPermission
=
true
;
let
video
=
document
.
createElement
(
"
video
"
);
let
canvasElement
=
this
.
_
(
"
#canvas
"
);
let
canvas
=
canvasElement
.
getContext
(
"
2d
"
);
...
...
@@ -194,7 +202,6 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
let
videoId
=
this
.
activeCamera
;
let
constraint
=
{
video
:
{
deviceId
:
videoId
}
};
if
(
(
videoId
===
'
environment
'
||
videoId
===
''
)
)
{
console
.
log
(
"
vid:
"
,
videoId
);
constraint
=
{
video
:
{
facingMode
:
"
environment
"
}
};
...
...
@@ -309,10 +316,6 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
drawLine
(
bottomRightCorner
,
bottomLeftCorner
,
color
);
drawLine
(
bottomLeftCorner
,
topLeftCorner
,
color
);
/*drawLine(code.location.topLeftCorner, code.location.topRightCorner, color);
drawLine(code.location.topRightCorner, code.location.bottomRightCorner, color);
drawLine(code.location.bottomRightCorner, code.location.bottomLeftCorner, color);
drawLine(code.location.bottomLeftCorner, code.location.topLeftCorner, color);*/
outputMessage
.
hidden
=
true
;
outputData
.
parentElement
.
hidden
=
false
;
outputData
.
innerText
=
code
.
data
;
...
...
@@ -326,16 +329,30 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
}
}
/**
* Update if video source is changed
*
* @param e
*/
updateSource
(
e
)
{
this
.
activeCamera
=
e
.
srcElement
.
value
;
this
.
sourceChanged
=
true
;
}
/**
* Stops the active video and scan process
*
*/
stopScanning
()
{
this
.
askPermission
=
false
;
this
.
videoRunning
=
false
;
}
/**
* Sends an event with the data which is detected from QR code reader
*
* @param data
*/
sendUrl
(
data
)
{
const
event
=
new
CustomEvent
(
"
dbp-qr-code-scanner-data
"
,
{
bubbles
:
true
,
composed
:
true
,
detail
:
data
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment