mirror of
https://github.com/wahyd4/BarcodeScanner.git
synced 2026-08-09 13:05:55 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c24882311f | ||
|
|
18f2f7a9fe | ||
|
|
10d66a4e67 | ||
|
|
27d6d653fc | ||
|
|
4efcc86a24 | ||
|
|
4d38047b41 | ||
|
|
af21cd20f6 | ||
|
|
e38147f27f | ||
|
|
b45ce29fec | ||
|
|
77d4a3dda2 | ||
|
|
6f4e09be4f | ||
|
|
b0747cadce | ||
|
|
3332885acd | ||
|
|
2331218b5a | ||
|
|
7ec3d477c2 | ||
|
|
3ab188539c | ||
|
|
d9f9f2dc9b | ||
|
|
ea1586b0ff | ||
|
|
10f8e6b116 | ||
|
|
f26cde76f5 | ||
|
|
5d452348da | ||
|
|
4d8646e26d | ||
|
|
cc0f7d82a1 | ||
|
|
f94c6129ae | ||
|
|
4579d40dc0 | ||
|
|
40849d52d6 | ||
|
|
2f7d652587 | ||
|
|
c1d0b47929 | ||
|
|
381ee1c6ac | ||
|
|
560cecc5b8 | ||
|
|
a0373c766f | ||
|
|
f9e3d0cffa | ||
|
|
604ebdf144 | ||
|
|
7c47973f78 | ||
|
|
1661cc4387 | ||
|
|
15b5cb9442 | ||
|
|
1d8ee5ca8d | ||
|
|
3c73e21796 | ||
|
|
c7158af58e | ||
|
|
3f166162a0 |
@@ -3,7 +3,7 @@ BarcodeScanner
|
||||
|
||||
Cross-platform BarcodeScanner for Cordova / PhoneGap.
|
||||
|
||||
Follows the [Cordova Plugin spec](https://github.com/alunny/cordova-plugin-spec), so that it works with [Pluginstall](https://github.com/alunny/pluginstall).
|
||||
Follows the [Cordova Plugin spec](https://github.com/apache/cordova-plugman/blob/master/plugin_spec.md), so that it works with [Plugman](https://github.com/apache/cordova-plugman).
|
||||
|
||||
This plugin leverages Cordova/PhoneGap's [require/define functionality used for plugins](http://simonmacdonald.blogspot.ca/2012/08/so-you-wanna-write-phonegap-200-android.html).
|
||||
|
||||
@@ -47,8 +47,8 @@ The following barcode types are currently supported:
|
||||
`success` and `fail` are callback functions. Success is passed an object with data, type and cancelled properties. Data is the text representation of the barcode data, type is the type of barcode detected and cancelled is whether or not the user cancelled the scan.
|
||||
|
||||
A full example could be:
|
||||
|
||||
var scanner = window.PhoneGap.require("cordova/plugin/BarcodeScanner");
|
||||
```
|
||||
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
|
||||
|
||||
scanner.scan(
|
||||
function (result) {
|
||||
@@ -61,7 +61,7 @@ A full example could be:
|
||||
alert("Scanning failed: " + error);
|
||||
}
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
## Encoding a Barcode ##
|
||||
The plugin creates the object `window.plugins.barcodeScanner` with the method `encode(type, data, success, fail)`.
|
||||
@@ -72,9 +72,10 @@ Supported encoding types:
|
||||
* PHONE_TYPE
|
||||
* SMS_TYPE
|
||||
|
||||
```
|
||||
A full example could be:
|
||||
|
||||
var scanner = window.PhoneGap.require("cordova/plugin/BarcodeScanner");
|
||||
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
|
||||
|
||||
scanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
|
||||
alert("encode success: " + success);
|
||||
@@ -82,6 +83,7 @@ A full example could be:
|
||||
alert("encoding failed: " + fail);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## Thanks on Github ##
|
||||
|
||||
@@ -110,4 +112,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE.
|
||||
|
||||
+29
-1
@@ -2,9 +2,15 @@
|
||||
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="com.phonegap.plugins.barcodescanner"
|
||||
version="0.3.1">
|
||||
version="0.5.5">
|
||||
|
||||
<name>BarcodeScanner</name>
|
||||
|
||||
<description>Scans Barcodes.</description>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=2.0.0" />
|
||||
</engines>
|
||||
|
||||
<asset src="www/barcodescanner.js" target="barcodescanner.js" />
|
||||
|
||||
@@ -262,4 +268,26 @@
|
||||
<source-file src="src/android/LibraryProject/res/values-zh-rTW/strings.xml" target-dir="res/values-zh-rTW"/>
|
||||
|
||||
</platform>
|
||||
|
||||
<license>
|
||||
Copyright (c) 2012 Adobe Software Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
</license>
|
||||
</plugin>
|
||||
|
||||
@@ -19,35 +19,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
describe('Plugin object (window.plugins)', function () {
|
||||
var scanner;
|
||||
|
||||
describe('cordova.require object should exist', function () {
|
||||
it("should exist", function() {
|
||||
expect(window.plugins).toBeDefined();
|
||||
expect(window.cordova).toBeDefined();
|
||||
expect(typeof cordova.require == 'function').toBe(true);
|
||||
});
|
||||
|
||||
it("should contain a barcodeScanner object", function() {
|
||||
expect(window.plugins.barcodeScanner).toBeDefined();
|
||||
expect(typeof window.plugins.barcodeScanner == 'object').toBe(true);
|
||||
it("BarcodeScanner plugin should exist", function() {
|
||||
scanner = cordova.require("cordova/plugin/BarcodeScanner")
|
||||
expect(scanner).toBeDefined();
|
||||
expect(typeof scanner == 'object').toBe(true);
|
||||
});
|
||||
|
||||
it("should contain a scan function", function() {
|
||||
expect(window.plugins.barcodeScanner.scan).toBeDefined();
|
||||
expect(typeof window.plugins.barcodeScanner.scan == 'function').toBe(true);
|
||||
expect(scanner.scan).toBeDefined();
|
||||
expect(typeof scanner.scan == 'function').toBe(true);
|
||||
});
|
||||
|
||||
it("should contain an encode function", function() {
|
||||
expect(window.plugins.barcodeScanner.encode).toBeDefined();
|
||||
expect(typeof window.plugins.barcodeScanner.encode == 'function').toBe(true);
|
||||
expect(scanner.encode).toBeDefined();
|
||||
expect(typeof scanner.encode == 'function').toBe(true);
|
||||
});
|
||||
|
||||
it("should contain three DestinationType constants", function() {
|
||||
expect(BarcodeScanner.Encode.TEXT_TYPE).toBe("TEXT_TYPE");
|
||||
expect(BarcodeScanner.Encode.EMAIL_TYPE).toBe("EMAIL_TYPE");
|
||||
expect(BarcodeScanner.Encode.PHONE_TYPE).toBe("PHONE_TYPE");
|
||||
expect(BarcodeScanner.Encode.SMS_TYPE).toBe("SMS_TYPE");
|
||||
expect(scanner.Encode.TEXT_TYPE).toBe("TEXT_TYPE");
|
||||
expect(scanner.Encode.EMAIL_TYPE).toBe("EMAIL_TYPE");
|
||||
expect(scanner.Encode.PHONE_TYPE).toBe("PHONE_TYPE");
|
||||
expect(scanner.Encode.SMS_TYPE).toBe("SMS_TYPE");
|
||||
});
|
||||
/*
|
||||
it("should call scan successfully", function() {
|
||||
window.plugins.barcodeScanner.scan(function() {}, function() {});
|
||||
scanner.scan(function() {}, function() {});
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<widget xmlns = "http://www.w3.org/ns/widgets"
|
||||
xmlns:gap = "http://phonegap.com/ns/1.0"
|
||||
id = "org.apache.cordova.example"
|
||||
version = "2.0.0">
|
||||
<name>cordovaExample</name>
|
||||
|
||||
<description>
|
||||
Barcode Scanner Spec
|
||||
</description>
|
||||
|
||||
<author href="http://phonegap.com" email="support@phonegap.com">
|
||||
Ryan Willoughby - PhoneGap Team
|
||||
</author>
|
||||
|
||||
<gap:preference name="phonegap-version" value="2.5.0" />
|
||||
|
||||
<gap:plugin name="BarcodeScanner"/>
|
||||
|
||||
</widget>
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
|
||||
PhoneGap.define("cordova/plugin/BarcodeScanner",
|
||||
cordova.define("cordova/plugin/BarcodeScanner",
|
||||
|
||||
function (require, exports, module) {
|
||||
|
||||
@@ -54,12 +54,12 @@ PhoneGap.define("cordova/plugin/BarcodeScanner",
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: failure parameter not a function");
|
||||
console.log("BarcodeScanner.encode failure: failure parameter not a function");
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
|
||||
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user