Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 1e3f578

Browse files
committed
Fix barcode scanning on Android 4.2
1 parent 300f192 commit 1e3f578

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

www/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ <h1>Example</h1>
4949
</div>
5050
</div>
5151
<script type="text/javascript" src="cordova.js"></script>
52+
<script type="text/javascript" src="js/polyfill.js"></script>
5253
<script type="text/javascript" src="js/lodash.custom.js"></script>
5354
<script type="text/javascript" src="js/machina.js"></script>
5455
<script type="text/javascript" src="js/util.js"></script>

www/js/polyfill.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
// Needed for Android 4.2
3+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill
4+
if (!String.prototype.includes) {
5+
String.prototype.includes = function(search, start) {
6+
'use strict';
7+
if (typeof start !== 'number') {
8+
start = 0;
9+
}
10+
11+
if (start + search.length > this.length) {
12+
return false;
13+
} else {
14+
return this.indexOf(search, start) !== -1;
15+
}
16+
};
17+
}

0 commit comments

Comments
 (0)