Skip to content

Commit

Permalink
Merge pull request #199 from zxing-js/release/v0.14.3
Browse files Browse the repository at this point in the history
Release/v0.15.0.

May the force be with you. 💚
  • Loading branch information
odahcam authored Jul 23, 2019
2 parents 2fddaca + 8e19d28 commit 2f6503e
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 97 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
language: node_js

node_js:
- '12'
- '11'
- '10'

Expand Down
6 changes: 2 additions & 4 deletions docs/examples/barcode-camera/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ <h1 class="title">Scan barcode from Video Camera</h1>
</div>

<label>Result:</label>
<blockquote>
<p id="result"></p>
</blockquote>
<pre><code id="result"></code></pre>

<p>See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/barcode-camera/">source code</a> for this example.</p>

Expand Down Expand Up @@ -89,7 +87,7 @@ <h1 class="title">Scan barcode from Video Camera</h1>
}

document.getElementById('startButton').addEventListener('click', () => {
codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video').then((result) => {
codeReader.decodeOnceFromVideoDevice(selectedDeviceId, 'video').then((result) => {
console.log(result)
document.getElementById('result').textContent = result.text
}).catch((err) => {
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/multi-camera/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ <h1 class="title">Scan 1D/2D Code from Video Camera</h1>
</div>

<label>Result:</label>
<blockquote>
<p id="result"></p>
</blockquote>
<pre><code id="result"></code></pre>

<p>See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/multi-camera/">source code</a>
for this example.</p>
Expand Down Expand Up @@ -92,7 +90,7 @@ <h1 class="title">Scan 1D/2D Code from Video Camera</h1>
}

document.getElementById('startButton').addEventListener('click', () => {
codeReader.decodeFromInputVideoDeviceContinuously(selectedDeviceId, 'video', (result, err) => {
codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
if (result) {
console.log(result)
document.getElementById('result').textContent = result.text
Expand Down
4 changes: 1 addition & 3 deletions docs/examples/multi-image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ <h1 class="title">Scan 1D/2D Code from Image</h1>
</div>

<label>Result:</label>
<blockquote>
<p id="result"></p>
</blockquote>
<pre><code id="result"></code></pre>

<p>See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/multi-image/">source code</a> for this example.</p>

Expand Down
78 changes: 66 additions & 12 deletions docs/examples/qr-camera/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ <h1 class="title">Scan QR Code from Video Camera</h1>
</select>
</div>

<div style="display: table">
<label for="decoding-style"> Decoding Style:</label>
<select id="decoding-style" size="1">
<option value="once">Decode once</option>
<option value="continuously">Decode continuously</option>
</select>
</div>

<label>Result:</label>
<blockquote>
<p id="result"></p>
</blockquote>
<pre><code id="result"></code></pre>

<p>See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/qr-camera/">source code</a> for
this example.</p>
Expand All @@ -61,12 +67,58 @@ <h1 class="title">Scan QR Code from Video Camera</h1>

</main>

<script type="text/javascript" src="https://unpkg.com/@zxing/library@latest"></script>
<script src="./index.min.js"></script>
<!-- <script type="text/javascript" src="https://unpkg.com/@zxing/library@latest"></script> -->
<script type="text/javascript">
function decodeOnce(codeReader, selectedDeviceId) {
codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video').then((result) => {
console.log(result)
document.getElementById('result').textContent = result.text
}).catch((err) => {
console.error(err)
document.getElementById('result').textContent = err
})
}

function decodeContinuously(codeReader, selectedDeviceId) {
codeReader.decodeFromInputVideoDeviceContinuously(selectedDeviceId, 'video', (result, err) => {
if (result) {
// properly decoded qr code
console.log('Found QR code!', result)
document.getElementById('result').textContent = result.text
}

if (err) {
// As long as this error belongs into one of the following categories
// the code reader is going to continue as excepted. Any other error
// will stop the decoding loop.
//
// Excepted Exceptions:
//
// - NotFoundException
// - ChecksumException
// - FormatException

if (err instanceof ZXing.NotFoundException) {
console.log('No QR code found.')
}

if (err instanceof ZXing.ChecksumException) {
console.log('A code was found, but it\'s read value was not valid.')
}

if (err instanceof ZXing.FormatException) {
console.log('A code was found, but it was in a invalid format.')
}
}
})
}

window.addEventListener('load', function () {
let selectedDeviceId;
const codeReader = new ZXing.BrowserQRCodeReader()
console.log('ZXing code reader initialized')

codeReader.getVideoInputDevices()
.then((videoInputDevices) => {
const sourceSelect = document.getElementById('sourceSelect')
Expand All @@ -88,14 +140,16 @@ <h1 class="title">Scan QR Code from Video Camera</h1>
}

document.getElementById('startButton').addEventListener('click', () => {
codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video').then((result) => {
console.log(result)
document.getElementById('result').textContent = result.text
}).catch((err) => {
console.error(err)
document.getElementById('result').textContent = err
})
console.log(`Started continous decode from camera with id ${selectedDeviceId}`)

const decodingStyle = document.getElementById('decoding-style').value;

if (decodingStyle == "once") {
decodeOnce(codeReader, selectedDeviceId);
} else {
decodeContinuously(codeReader, selectedDeviceId);
}

console.log(`Started decode from camera with id ${selectedDeviceId}`)
})

document.getElementById('resetButton').addEventListener('click', () => {
Expand Down
4 changes: 1 addition & 3 deletions docs/examples/qr-image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ <h1 class="title">Scan QR Code from Image</h1>
</div>

<label>Result:</label>
<blockquote>
<p id="result"></p>
</blockquote>
<pre><code id="result"></code></pre>

<p>See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/qr-image/">source code</a> for this example.</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/qr-svg-writer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="title">Write QR Code to SVG</h1>
</div>

<label>Result:</label>
<div id="result"></div>
<pre><code id="result"></code></pre>

<p>See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/qr-svg-writer/">source code</a> for this example.</p>

Expand Down
4 changes: 1 addition & 3 deletions docs/examples/qr-video/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ <h1 class="title">Scan QR Code from Video File</h1>
</div>

<label>Result:</label>
<blockquote>
<p id="result"></p>
</blockquote>
<pre><code id="result"></code></pre>

<p>
See the <a href="https://github.com/zxing-js/library/tree/master/docs/examples/qr-video/">source code</a> for
Expand Down
Loading

0 comments on commit 2f6503e

Please sign in to comment.