Make barcode scanner work on Cordova browser platform (close #28)
This commit is contained in:
parent
3ecc981c67
commit
3602f77343
@ -120,7 +120,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
The following software may be included in this product: leaflet. A copy of the source code may be downloaded from git://github.com/Leaflet/Leaflet.git. This software contains the following license and notice below:
|
||||
|
||||
Copyright (c) 2010-2018, Vladimir Agafonkin
|
||||
Copyright (c) 2010-2019, Vladimir Agafonkin
|
||||
Copyright (c) 2010-2011, CloudMade
|
||||
All rights reserved.
|
||||
|
||||
@ -1907,7 +1907,7 @@ The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
-----
|
||||
|
||||
The following software may be included in this product: cordova-plugin-inappbrowser, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
The following software may be included in this product: cordova-plugin-device, cordova-plugin-inappbrowser, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-device (cordova-plugin-device), https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
@ -2962,7 +2962,7 @@ THE SOFTWARE.
|
||||
|
||||
-----
|
||||
|
||||
The following software may be included in this product: es-to-primitive, is-callable, is-date-object, is-symbol, string.prototype.trimleft, string.prototype.trimright. A copy of the source code may be downloaded from git://github.com/ljharb/es-to-primitive.git (es-to-primitive), git://github.com/ljharb/is-callable.git (is-callable), git://github.com/ljharb/is-date-object.git (is-date-object), git://github.com/ljharb/is-symbol.git (is-symbol), git://github.com/es-shims/String.prototype.trimLeft.git (string.prototype.trimleft), git://github.com/es-shims/String.prototype.trimRight.git (string.prototype.trimright). This software contains the following license and notice below:
|
||||
The following software may be included in this product: es-to-primitive, is-callable, is-date-object, is-symbol, string.prototype.trimleft, string.prototype.trimright. A copy of the source code may be downloaded from git://github.com/ljharb/es-to-primitive.git (es-to-primitive), git://github.com/ljharb/is-callable.git (is-callable), git://github.com/ljharb/is-date-object.git (is-date-object), git://github.com/inspect-js/is-symbol.git (is-symbol), git://github.com/es-shims/String.prototype.trimLeft.git (string.prototype.trimleft), git://github.com/es-shims/String.prototype.trimRight.git (string.prototype.trimright). This software contains the following license and notice below:
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
@ -18,7 +18,8 @@
|
||||
"cordova-plugin-inappbrowser": {},
|
||||
"cordova-plugin-powermanagement-netsyms": {},
|
||||
"cordova-plugin-whitelist": {},
|
||||
"phonegap-plugin-barcodescanner": {}
|
||||
"phonegap-plugin-barcodescanner": {},
|
||||
"cordova-plugin-device": {}
|
||||
},
|
||||
"platforms": [
|
||||
"android",
|
||||
@ -28,6 +29,7 @@
|
||||
"dependencies": {
|
||||
"cordova-android": "^8.1.0",
|
||||
"cordova-browser": "^6.0.0",
|
||||
"cordova-plugin-device": "^2.0.3",
|
||||
"cordova-plugin-inappbrowser": "^3.1.0",
|
||||
"cordova-plugin-powermanagement-netsyms": "git+https://source.netsyms.com/Netsyms/cordova-plugin-powermanagement",
|
||||
"cordova-plugin-whitelist": "^1.3.4"
|
||||
|
@ -29,6 +29,7 @@ cd jsbarcode
|
||||
rm -rf .dockerignore .eslintignore .eslintrcautomation bower.json CONTRIBUTING.md docker-compose.yml Dockerfile example gulpfile.js jsbarcode.d.ts README.md src test .travis.yml
|
||||
rm -rf dist/barcodes
|
||||
rm -rf dist/JsBarcode.all.js
|
||||
cd ..
|
||||
|
||||
cd framework7
|
||||
rm -rf components
|
||||
@ -36,8 +37,8 @@ rm -rf lazy-components
|
||||
rm -rf less
|
||||
rm -rf modules
|
||||
rm -rf utils
|
||||
|
||||
cd ..
|
||||
|
||||
cd material-design-icons
|
||||
rm -rf action
|
||||
rm -rf alert
|
||||
|
@ -64,98 +64,7 @@ var watchLocation = function (success, error) {
|
||||
}
|
||||
}
|
||||
|
||||
function initCordova() {
|
||||
platform_type = "cordova";
|
||||
|
||||
// Handle back button to close things
|
||||
document.addEventListener("backbutton", function (event) {
|
||||
router.back({force: true, ignoreCache: true});
|
||||
}, false);
|
||||
|
||||
document.addEventListener("deviceready", function () {
|
||||
if (localStorage.getItem("wakelock") == "true") {
|
||||
window.powerManagement.acquire(function () {
|
||||
console.log('Wakelock acquired');
|
||||
}, function () {
|
||||
console.log('Failed to acquire wakelock');
|
||||
});
|
||||
} else {
|
||||
window.powerManagement.release(function () {
|
||||
console.log('Wakelock released');
|
||||
}, function () {
|
||||
console.log('Failed to release wakelock');
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
|
||||
openBrowser = function (url) {
|
||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
window.open(url, '_system', '');
|
||||
}
|
||||
|
||||
scanBarcode = function (success, error) {
|
||||
cordova.plugins.barcodeScanner.scan(
|
||||
function (result) {
|
||||
if (!result.cancelled) {
|
||||
success(result.text);
|
||||
}
|
||||
},
|
||||
function (err) {
|
||||
if (typeof error == "function") {
|
||||
error(err);
|
||||
}
|
||||
},
|
||||
{
|
||||
showTorchButton: true,
|
||||
showFlipCameraButton : true,
|
||||
prompt: "Scan barcode",
|
||||
resultDisplayDuration: 0,
|
||||
disableSuccessBeep: true,
|
||||
formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417,AZTEC,MAXICODE"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function initNW() {
|
||||
platform_type = "nw";
|
||||
platform_theme = "md";
|
||||
|
||||
openBrowser = function (url) {
|
||||
nw.Window.open(url, {
|
||||
id: url
|
||||
}, function (browserwin) {
|
||||
// Add menubar so the user can navigate around if they click a link
|
||||
var browsermenu = new nw.Menu({type: 'menubar'});
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Back",
|
||||
click: function () {
|
||||
browserwin.window.history.back();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Forward",
|
||||
click: function () {
|
||||
browserwin.window.history.forward();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Home",
|
||||
click: function () {
|
||||
browserwin.window.location.href = url;
|
||||
}
|
||||
}));
|
||||
browserwin.menu = browsermenu;
|
||||
});
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
require('nw.gui').Shell.openExternal(url);
|
||||
}
|
||||
|
||||
function setupHTML5BarcodeScanner() {
|
||||
$("body").append('<script src="node_modules/@zxing/library/umd/index.min.js"></script>');
|
||||
|
||||
scanBarcode = function (success, error) {
|
||||
@ -200,13 +109,114 @@ function initNW() {
|
||||
};
|
||||
}
|
||||
|
||||
function initCordova() {
|
||||
platform_type = "cordova";
|
||||
// Handle back button to close things
|
||||
document.addEventListener("backbutton", function (event) {
|
||||
router.back({force: true, ignoreCache: true});
|
||||
}, false);
|
||||
document.addEventListener("deviceready", function () {
|
||||
if (localStorage.getItem("wakelock") == "true") {
|
||||
window.powerManagement.acquire(function () {
|
||||
console.log('Wakelock acquired');
|
||||
}, function () {
|
||||
console.log('Failed to acquire wakelock');
|
||||
});
|
||||
} else {
|
||||
window.powerManagement.release(function () {
|
||||
console.log('Wakelock released');
|
||||
}, function () {
|
||||
console.log('Failed to release wakelock');
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
openBrowser = function (url) {
|
||||
cordova.InAppBrowser.open(url, '_blank', 'location=yes');
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
window.open(url, '_system', '');
|
||||
}
|
||||
|
||||
if (typeof device != "undefined" && device.platform != "browser") {
|
||||
scanBarcode = function (success, error) {
|
||||
cordova.plugins.barcodeScanner.scan(
|
||||
function (result) {
|
||||
if (!result.cancelled) {
|
||||
success(result.text);
|
||||
}
|
||||
},
|
||||
function (err) {
|
||||
if (typeof error == "function") {
|
||||
error(err);
|
||||
}
|
||||
},
|
||||
{
|
||||
showTorchButton: true,
|
||||
showFlipCameraButton: true,
|
||||
prompt: "Scan barcode",
|
||||
resultDisplayDuration: 0,
|
||||
disableSuccessBeep: true,
|
||||
formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417,AZTEC,MAXICODE"
|
||||
}
|
||||
);
|
||||
};
|
||||
} else {
|
||||
setupHTML5BarcodeScanner();
|
||||
}
|
||||
}
|
||||
|
||||
function initNW() {
|
||||
platform_type = "nw";
|
||||
platform_theme = "md";
|
||||
openBrowser = function (url) {
|
||||
nw.Window.open(url, {
|
||||
id: url
|
||||
}, function (browserwin) {
|
||||
// Add menubar so the user can navigate around if they click a link
|
||||
var browsermenu = new nw.Menu({type: 'menubar'});
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Back",
|
||||
click: function () {
|
||||
browserwin.window.history.back();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Forward",
|
||||
click: function () {
|
||||
browserwin.window.history.forward();
|
||||
}
|
||||
}));
|
||||
browsermenu.append(new nw.MenuItem({
|
||||
label: "Home",
|
||||
click: function () {
|
||||
browserwin.window.location.href = url;
|
||||
}
|
||||
}));
|
||||
browserwin.menu = browsermenu;
|
||||
});
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
require('nw.gui').Shell.openExternal(url);
|
||||
}
|
||||
|
||||
|
||||
setupHTML5BarcodeScanner();
|
||||
}
|
||||
|
||||
function initBrowser() {
|
||||
platform_type = "browser";
|
||||
platform_theme = "md";
|
||||
|
||||
openBrowser = function (url) {
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
openExternalBrowser = function (url) {
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
setupHTML5BarcodeScanner();
|
||||
}
|
||||
|
||||
function initPlatform() {
|
||||
|
@ -225,7 +225,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
The following software may be included in this product: leaflet. A copy of the source code may be downloaded from git://github.com/Leaflet/Leaflet.git. This software contains the following license and notice below:
|
||||
|
||||
Copyright (c) 2010-2018, Vladimir Agafonkin
|
||||
Copyright (c) 2010-2019, Vladimir Agafonkin
|
||||
Copyright (c) 2010-2011, CloudMade
|
||||
All rights reserved.
|
||||
|
||||
@ -2012,7 +2012,7 @@ The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
-----
|
||||
|
||||
The following software may be included in this product: cordova-plugin-inappbrowser, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
The following software may be included in this product: cordova-plugin-device, cordova-plugin-inappbrowser, cordova-plugin-whitelist. A copy of the source code may be downloaded from https://github.com/apache/cordova-plugin-device (cordova-plugin-device), https://github.com/apache/cordova-plugin-inappbrowser (cordova-plugin-inappbrowser), https://github.com/apache/cordova-plugin-whitelist (cordova-plugin-whitelist). This software contains the following license and notice below:
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
@ -3067,7 +3067,7 @@ THE SOFTWARE.
|
||||
|
||||
-----
|
||||
|
||||
The following software may be included in this product: es-to-primitive, is-callable, is-date-object, is-symbol, string.prototype.trimleft, string.prototype.trimright. A copy of the source code may be downloaded from git://github.com/ljharb/es-to-primitive.git (es-to-primitive), git://github.com/ljharb/is-callable.git (is-callable), git://github.com/ljharb/is-date-object.git (is-date-object), git://github.com/ljharb/is-symbol.git (is-symbol), git://github.com/es-shims/String.prototype.trimLeft.git (string.prototype.trimleft), git://github.com/es-shims/String.prototype.trimRight.git (string.prototype.trimright). This software contains the following license and notice below:
|
||||
The following software may be included in this product: es-to-primitive, is-callable, is-date-object, is-symbol, string.prototype.trimleft, string.prototype.trimright. A copy of the source code may be downloaded from git://github.com/ljharb/es-to-primitive.git (es-to-primitive), git://github.com/ljharb/is-callable.git (is-callable), git://github.com/ljharb/is-date-object.git (is-date-object), git://github.com/inspect-js/is-symbol.git (is-symbol), git://github.com/es-shims/String.prototype.trimLeft.git (string.prototype.trimleft), git://github.com/es-shims/String.prototype.trimRight.git (string.prototype.trimright). This software contains the following license and notice below:
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user