Improve barcode scanning

master
Skylar Ittner 8 years ago
parent b1bf598c86
commit 513e97f525

@ -9,7 +9,8 @@
# For more information about plugins see http://cordova.apache.org/blog/releases/2013/07/23/cordova-3.html # For more information about plugins see http://cordova.apache.org/blog/releases/2013/07/23/cordova-3.html
# #
phonegap-plugin-barcodescanner=https://github.com/phonegap/phonegap-plugin-barcodescanner.git com.phonegap.plugins.barcodescanner=https://github.com/Telerik-Verified-Plugins/BarcodeScanner
#phonegap-plugin-barcodescanner=https://github.com/phonegap/phonegap-plugin-barcodescanner.git
cordova-plugin-whitelist=https://github.com/apache/cordova-plugin-whitelist.git cordova-plugin-whitelist=https://github.com/apache/cordova-plugin-whitelist.git
cordova-plugin-splashscreen=https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git cordova-plugin-splashscreen=https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git
cordova-plugin-dialogs=https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git cordova-plugin-dialogs=https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git

@ -120,6 +120,11 @@
} }
] ]
} }
},
"res/values/strings.xml": {
"parents": {
"/resources": []
}
} }
} }
}, },
@ -160,7 +165,7 @@
"cordova-plugin-whitelist": { "cordova-plugin-whitelist": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
}, },
"phonegap-plugin-barcodescanner": { "com.phonegap.plugins.barcodescanner": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
} }
}, },
@ -469,9 +474,9 @@
"runs": true "runs": true
}, },
{ {
"id": "phonegap-plugin-barcodescanner.BarcodeScanner", "id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", "file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"clobbers": [ "clobbers": [
"cordova.plugins.barcodeScanner" "cordova.plugins.barcodeScanner"
] ]
@ -490,6 +495,6 @@
"cordova-plugin-network-information": "1.2.1-dev", "cordova-plugin-network-information": "1.2.1-dev",
"cordova-plugin-splashscreen": "3.2.2-dev", "cordova-plugin-splashscreen": "3.2.2-dev",
"cordova-plugin-whitelist": "1.2.1", "cordova-plugin-whitelist": "1.2.1",
"phonegap-plugin-barcodescanner": "6.0.1" "com.phonegap.plugins.barcodescanner": "5.0.1"
} }
} }

@ -303,9 +303,9 @@ module.exports = [
"runs": true "runs": true
}, },
{ {
"id": "phonegap-plugin-barcodescanner.BarcodeScanner", "id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", "file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"clobbers": [ "clobbers": [
"cordova.plugins.barcodeScanner" "cordova.plugins.barcodeScanner"
] ]
@ -326,7 +326,7 @@ module.exports.metadata =
"cordova-plugin-network-information": "1.2.1-dev", "cordova-plugin-network-information": "1.2.1-dev",
"cordova-plugin-splashscreen": "3.2.2-dev", "cordova-plugin-splashscreen": "3.2.2-dev",
"cordova-plugin-whitelist": "1.2.1", "cordova-plugin-whitelist": "1.2.1",
"phonegap-plugin-barcodescanner": "6.0.1" "com.phonegap.plugins.barcodescanner": "5.0.1"
}; };
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });

@ -99,6 +99,10 @@ function scanCode() {
}, },
function (error) { function (error) {
navigator.notification.alert("Scanning failed: " + error, null, "Error", 'Dismiss'); navigator.notification.alert("Scanning failed: " + error, null, "Error", 'Dismiss');
},
{
"showFlipCameraButton": true,
"prompt": "Scan a barcode to discover an item!"
} }
); );
} catch (ex) { } catch (ex) {

@ -1,3 +1,4 @@
cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScanner", function(require, exports, module) {
/** /**
* cordova is available under *either* the terms of the modified BSD license *or* the * cordova is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@ -9,8 +10,6 @@
var exec = require("cordova/exec"); var exec = require("cordova/exec");
var scanInProgress = false;
/** /**
* Constructor. * Constructor.
* *
@ -99,26 +98,7 @@ BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config
return; return;
} }
if (scanInProgress) { exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', config);
errorCallback('Scan is already in progress');
return;
}
scanInProgress = true;
exec(
function(result) {
scanInProgress = false;
successCallback(result);
},
function(error) {
scanInProgress = false;
errorCallback(error);
},
'BarcodeScanner',
'scan',
config
);
}; };
//------------------------------------------------------------------- //-------------------------------------------------------------------
@ -145,3 +125,5 @@ BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config
var barcodeScanner = new BarcodeScanner(); var barcodeScanner = new BarcodeScanner();
module.exports = barcodeScanner; module.exports = barcodeScanner;
});

@ -88,7 +88,7 @@ ext {
} }
// PLUGIN GRADLE EXTENSIONS START // PLUGIN GRADLE EXTENSIONS START
apply from: "phonegap-plugin-barcodescanner/TerranQuest-barcodescanner.gradle" apply from: "com.phonegap.plugins.barcodescanner/TerranQuest-barcodescanner.gradle"
// PLUGIN GRADLE EXTENSIONS END // PLUGIN GRADLE EXTENSIONS END
def hasBuildExtras = file('build-extras.gradle').exists() def hasBuildExtras = file('build-extras.gradle').exists()

@ -303,9 +303,9 @@ module.exports = [
"runs": true "runs": true
}, },
{ {
"id": "phonegap-plugin-barcodescanner.BarcodeScanner", "id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", "file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"clobbers": [ "clobbers": [
"cordova.plugins.barcodeScanner" "cordova.plugins.barcodeScanner"
] ]
@ -326,7 +326,7 @@ module.exports.metadata =
"cordova-plugin-network-information": "1.2.1-dev", "cordova-plugin-network-information": "1.2.1-dev",
"cordova-plugin-splashscreen": "3.2.2-dev", "cordova-plugin-splashscreen": "3.2.2-dev",
"cordova-plugin-whitelist": "1.2.1", "cordova-plugin-whitelist": "1.2.1",
"phonegap-plugin-barcodescanner": "6.0.1" "com.phonegap.plugins.barcodescanner": "5.0.1"
}; };
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });

@ -1,4 +1,4 @@
cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require, exports, module) { cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScanner", function(require, exports, module) {
/** /**
* cordova is available under *either* the terms of the modified BSD license *or* the * cordova is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
@ -10,8 +10,6 @@ cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require
var exec = require("cordova/exec"); var exec = require("cordova/exec");
var scanInProgress = false;
/** /**
* Constructor. * Constructor.
* *
@ -100,26 +98,7 @@ BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config
return; return;
} }
if (scanInProgress) { exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', config);
errorCallback('Scan is already in progress');
return;
}
scanInProgress = true;
exec(
function(result) {
scanInProgress = false;
successCallback(result);
},
function(error) {
scanInProgress = false;
errorCallback(error);
},
'BarcodeScanner',
'scan',
config
);
}; };
//------------------------------------------------------------------- //-------------------------------------------------------------------

@ -12,4 +12,4 @@
# Project target. # Project target.
target=android-24 target=android-24
android.library.reference.1=CordovaLib android.library.reference.1=CordovaLib
cordova.gradle.include.1=phonegap-plugin-barcodescanner/TerranQuest-barcodescanner.gradle cordova.gradle.include.1=com.phonegap.plugins.barcodescanner/TerranQuest-barcodescanner.gradle

@ -62,7 +62,7 @@
"cordova-plugin-geolocation": { "cordova-plugin-geolocation": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
}, },
"phonegap-plugin-barcodescanner": { "com.phonegap.plugins.barcodescanner": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
} }
}, },
@ -431,17 +431,17 @@
"runs": true "runs": true
}, },
{ {
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", "file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
"id": "phonegap-plugin-barcodescanner.BarcodeScanner", "id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"clobbers": [ "clobbers": [
"cordova.plugins.barcodeScanner" "cordova.plugins.barcodeScanner"
] ]
}, },
{ {
"file": "plugins/phonegap-plugin-barcodescanner/src/browser/BarcodeScannerProxy.js", "file": "plugins/com.phonegap.plugins.barcodescanner/src/browser/BarcodeScannerProxy.js",
"id": "phonegap-plugin-barcodescanner.BarcodeScannerProxy", "id": "com.phonegap.plugins.barcodescanner.BarcodeScannerProxy",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"runs": true "runs": true
} }
], ],
@ -458,6 +458,6 @@
"cordova-plugin-media": "2.2.1-dev", "cordova-plugin-media": "2.2.1-dev",
"cordova-plugin-media-capture": "1.2.1-dev", "cordova-plugin-media-capture": "1.2.1-dev",
"cordova-plugin-geolocation": "2.1.1-dev", "cordova-plugin-geolocation": "2.1.1-dev",
"phonegap-plugin-barcodescanner": "6.0.1" "com.phonegap.plugins.barcodescanner": "5.0.1"
} }
} }

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="103000" id="com.netsyms.terranquest.TerranQuest" version="1.3.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0"> <widget android-versionCode="104000" id="com.netsyms.terranquest.TerranQuest" version="1.4.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
<feature name="Device"> <feature name="Device">
<param name="browser-package" value="Device" /> <param name="browser-package" value="Device" />
</feature> </feature>

@ -363,17 +363,17 @@ module.exports = [
"runs": true "runs": true
}, },
{ {
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", "file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
"id": "phonegap-plugin-barcodescanner.BarcodeScanner", "id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"clobbers": [ "clobbers": [
"cordova.plugins.barcodeScanner" "cordova.plugins.barcodeScanner"
] ]
}, },
{ {
"file": "plugins/phonegap-plugin-barcodescanner/src/browser/BarcodeScannerProxy.js", "file": "plugins/com.phonegap.plugins.barcodescanner/src/browser/BarcodeScannerProxy.js",
"id": "phonegap-plugin-barcodescanner.BarcodeScannerProxy", "id": "com.phonegap.plugins.barcodescanner.BarcodeScannerProxy",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"runs": true "runs": true
} }
]; ];
@ -392,7 +392,7 @@ module.exports.metadata =
"cordova-plugin-media": "2.2.1-dev", "cordova-plugin-media": "2.2.1-dev",
"cordova-plugin-media-capture": "1.2.1-dev", "cordova-plugin-media-capture": "1.2.1-dev",
"cordova-plugin-geolocation": "2.1.1-dev", "cordova-plugin-geolocation": "2.1.1-dev",
"phonegap-plugin-barcodescanner": "6.0.1" "com.phonegap.plugins.barcodescanner": "5.0.1"
} }
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });

@ -1,4 +1,4 @@
cordova.define("phonegap-plugin-barcodescanner.BarcodeScannerProxy", function(require, exports, module) { function scan(success, error) { cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScannerProxy", function(require, exports, module) { function scan(success, error) {
var code = window.prompt("Enter barcode value (empty value will fire the error handler):"); var code = window.prompt("Enter barcode value (empty value will fire the error handler):");
if(code) { if(code) {
var result = { var result = {

@ -1,4 +1,4 @@
cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require, exports, module) { /** cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScanner", function(require, exports, module) { /**
* cordova is available under *either* the terms of the modified BSD license *or* the * cordova is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
* *
@ -9,8 +9,6 @@ cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require
var exec = require("cordova/exec"); var exec = require("cordova/exec");
var scanInProgress = false;
/** /**
* Constructor. * Constructor.
* *
@ -99,26 +97,7 @@ BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config
return; return;
} }
if (scanInProgress) { exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', config);
errorCallback('Scan is already in progress');
return;
}
scanInProgress = true;
exec(
function(result) {
scanInProgress = false;
successCallback(result);
},
function(error) {
scanInProgress = false;
errorCallback(error);
},
'BarcodeScanner',
'scan',
config
);
}; };
//------------------------------------------------------------------- //-------------------------------------------------------------------

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="103000" id="com.netsyms.terranquest.TerranQuest" version="1.3.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0"> <widget android-versionCode="104000" id="com.netsyms.terranquest.TerranQuest" version="1.4.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
<feature name="Device"> <feature name="Device">
<param name="browser-package" value="Device" /> <param name="browser-package" value="Device" />
</feature> </feature>

@ -363,17 +363,17 @@ module.exports = [
"runs": true "runs": true
}, },
{ {
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js", "file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
"id": "phonegap-plugin-barcodescanner.BarcodeScanner", "id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"clobbers": [ "clobbers": [
"cordova.plugins.barcodeScanner" "cordova.plugins.barcodeScanner"
] ]
}, },
{ {
"file": "plugins/phonegap-plugin-barcodescanner/src/browser/BarcodeScannerProxy.js", "file": "plugins/com.phonegap.plugins.barcodescanner/src/browser/BarcodeScannerProxy.js",
"id": "phonegap-plugin-barcodescanner.BarcodeScannerProxy", "id": "com.phonegap.plugins.barcodescanner.BarcodeScannerProxy",
"pluginId": "phonegap-plugin-barcodescanner", "pluginId": "com.phonegap.plugins.barcodescanner",
"runs": true "runs": true
} }
]; ];
@ -392,7 +392,7 @@ module.exports.metadata =
"cordova-plugin-media": "2.2.1-dev", "cordova-plugin-media": "2.2.1-dev",
"cordova-plugin-media-capture": "1.2.1-dev", "cordova-plugin-media-capture": "1.2.1-dev",
"cordova-plugin-geolocation": "2.1.1-dev", "cordova-plugin-geolocation": "2.1.1-dev",
"phonegap-plugin-barcodescanner": "6.0.1" "com.phonegap.plugins.barcodescanner": "5.0.1"
} }
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });

@ -0,0 +1,52 @@
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
-webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in;
-moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
-o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in;
transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}
.leaflet-cluster-spider-leg {
/* stroke-dashoffset (duration and function) should match with leaflet-marker-icon transform in order to track it exactly */
-webkit-transition: -webkit-stroke-dashoffset 0.3s ease-out, -webkit-stroke-opacity 0.3s ease-in;
-moz-transition: -moz-stroke-dashoffset 0.3s ease-out, -moz-stroke-opacity 0.3s ease-in;
-o-transition: -o-stroke-dashoffset 0.3s ease-out, -o-stroke-opacity 0.3s ease-in;
transition: stroke-dashoffset 0.3s ease-out, stroke-opacity 0.3s ease-in;
}
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
background-color: rgba(110, 204, 57, 0.6);
}
/*
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
}
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6);
}*/
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-left: 5px;
margin-top: 5px;
text-align: center;
border-radius: 15px;
}
.marker-cluster span {
line-height: 30px;
}

@ -295,4 +295,37 @@ body {
#team-choice-list { #team-choice-list {
color: #000; color: #000;
font-size: 120%; font-size: 120%;
}
#place-log {
padding: 5px;
border-left: 1px solid white;
border-bottom: 1px solid white;
border-right: 0px;
border-top: 0px;
border-radius: 0px;
height: 100px;
max-height: 100px;
min-height: 100px;
overflow-y: hidden;
}
#user-health-place-bar {
background-color: green;
}
#user-health-place {
height: 15px;
}
#place-health-place-bar {
background-color: white;
}
#place-health-place {
height: 15px;
}
#capturebtn {
color: black;
} }

@ -26,6 +26,7 @@
<link href="css/font-awesome.css" rel="stylesheet"> <link href="css/font-awesome.css" rel="stylesheet">
<link href="css/L.Control.Locate.css" rel="stylesheet"> <link href="css/L.Control.Locate.css" rel="stylesheet">
<link href="css/MarkerCluster.css" rel="stylesheet">
<!-- jQuery Version 1.11.1 --> <!-- jQuery Version 1.11.1 -->
<script src="js/jquery.js"></script> <script src="js/jquery.js"></script>
@ -46,6 +47,7 @@
<script src="js/leaflet.js"></script> <script src="js/leaflet.js"></script>
<script src="js/L.Control.Locate.min.js"></script> <script src="js/L.Control.Locate.min.js"></script>
<script src="js/leaflet.markercluster.js"></script>
</head> </head>
<body> <body>

@ -26,10 +26,10 @@ function logout() {
password = null; password = null;
$('#content-zone').load("screens/login.html"); $('#content-zone').load("screens/login.html");
} else { } else {
alert("Error: Server did not properly acknowledge logout. You might have problems for the next few hours if you switch accounts."); navigator.notification.alert("Server did not properly acknowledge logout. You might have problems for the next few hours if you switch accounts.", null, "Error", 'Dismiss');
} }
}).fail(function () { }).fail(function () {
alert("Error: Cannot connect to authentication server. Check your Internet connection and try again. If that fails, clear the app data or reinstall TerranQuest."); navigator.notification.alert("Cannot connect to authentication server. Check your Internet connection and try again. If that fails, clear the app data or reinstall TerranQuest.", null, "Error", 'Dismiss');
}); });
} }
@ -81,11 +81,22 @@ function dosignup() {
}, },
function (data) { function (data) {
if (data === 'OK') { if (data === 'OK') {
username = $('#usernameBox').val().toLowerCase(); $.getJSON(mkApiUrl('pinglogin') + "?user=" + $('#usernameBox').val(), function (out) {
password = $('#passwordBox').val(); if (out.status === 'OK') {
localStorage.setItem("username", username); username = $('#usernameBox').val().toLowerCase();
localStorage.setItem("password", password); password = $('#passwordBox').val();
checkUserHasTeamOpenChooserIfNot(username); localStorage.setItem("username", username);
localStorage.setItem("password", password);
navigator.splashscreen.hide();
checkUserHasTeamOpenChooserIfNot(username);
} else {
navigator.notification.alert("You've signed up successfully, but we can't log you in. Restart the app and try again.", null, "Error", 'Dismiss');
authOpInProgress = false;
}
}).fail(function (err) {
navigator.notification.alert("You've signed up successfully, but we can't log you in. Restart the app and try again.", null, "Error", 'Dismiss');
authOpInProgress = false;
});
} else { } else {
$('#signupBtn').html('<i class="fa fa-user-plus"></i> Sign Up'); $('#signupBtn').html('<i class="fa fa-user-plus"></i> Sign Up');
$('#signupBtn').attr('disabled', false); $('#signupBtn').attr('disabled', false);

File diff suppressed because it is too large Load Diff

@ -52,7 +52,15 @@ var placeLayer = L.geoJson(
fillOpacity: 0.6 fillOpacity: 0.6
}); });
} }
}).addTo(map); });//.addTo(map);
var placemarkers = L.markerClusterGroup({
spiderfyDistanceMultiplier: 2,
showCoverageOnHover: false,
zoomToBoundsOnClick: false
});
placemarkers.addLayer(placeLayer);
map.addLayer(placemarkers);
var lc = L.control.locate({ var lc = L.control.locate({
position: 'topleft', // set the location of the control position: 'topleft', // set the location of the control
@ -65,7 +73,7 @@ var lc = L.control.locate({
remainActive: true, // if true locate control remains active on click even if the user's location is in view. remainActive: true, // if true locate control remains active on click even if the user's location is in view.
markerClass: L.circleMarker, // L.circleMarker or L.marker markerClass: L.circleMarker, // L.circleMarker or L.marker
circleStyle: {}, // change the style of the circle around the user's location circleStyle: {}, // change the style of the circle around the user's location
markerStyle: {}, markerStyle: {color: '#008000', fillColor: '#32CD32'},
followCircleStyle: {}, // set difference for the style of the circle around the user's location while following followCircleStyle: {}, // set difference for the style of the circle around the user's location while following
followMarkerStyle: {}, followMarkerStyle: {},
icon: 'fa fa-map-marker', // class for icon, fa-location-arrow or fa-map-marker icon: 'fa fa-map-marker', // class for icon, fa-location-arrow or fa-map-marker
@ -126,10 +134,12 @@ function loadPlaces(lat, long) {
function (data) { function (data) {
if (data.type === 'FeatureCollection') { if (data.type === 'FeatureCollection') {
placeLayer.clearLayers(); placeLayer.clearLayers();
placemarkers.clearLayers();
data.features.forEach(function (item) { data.features.forEach(function (item) {
item.properties.popupContent = "<span class='marker-popup-text' onclick='openPlace(" + item.properties.osm_id + ")'>" + item.properties.name + "</span>"; item.properties.popupContent = "<span class='marker-popup-text' onclick='openPlace(" + item.properties.osm_id + ")'>" + item.properties.name + "</span>";
placeLayer.addData(item); placeLayer.addData(item);
}); });
placemarkers.addLayer(placeLayer);
} }
} }
); );

@ -83,7 +83,18 @@ function scanCode() {
cordova.plugins.barcodeScanner.scan( cordova.plugins.barcodeScanner.scan(
function (result) { function (result) {
if (!result.cancelled) { if (!result.cancelled) {
navigator.notification.alert("Scanned code: " + result.text, null, "OK", 'Dismiss'); $.getJSON(mkApiUrl('code2item', 'gs'), {
code: result.text
}, function (data) {
if (data.status === 'OK') {
navigator.notification.alert("Found one " + data.message, null, "Found an item!", 'OK');
} else {
navigator.notification.alert(data.message, null, "Huh?", 'OK');
}
}).fail(function () {
navigator.notification.alert("Nothing happened!", null, "Huh?", 'OK');
});
//navigator.notification.alert("Scanned code: " + result.text, null, "OK", 'Dismiss');
} }
}, },
function (error) { function (error) {
@ -91,7 +102,7 @@ function scanCode() {
} }
); );
} catch (ex) { } catch (ex) {
alert(ex.message); navigator.notification.alert(ex.message, null, "Error", 'Dismiss');
} }
} }

@ -11,7 +11,7 @@
* Syncs the user's stats with the server and calls refreshStats(). * Syncs the user's stats with the server and calls refreshStats().
*/ */
function syncStats() { function syncStats() {
$.getJSON(mkApiUrl('getstats'), { $.getJSON(mkApiUrl('getstats', 'gs'), {
user: username user: username
}, function (data) { }, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
@ -58,7 +58,7 @@ setInterval(function () {
}, 10 * 1000); }, 10 * 1000);
setInterval(function () { setInterval(function () {
getChat(); getChat();
}, 2000); }, 3000);
// Send chat messages // Send chat messages
$("#chatsendform").submit(function (event) { $("#chatsendform").submit(function (event) {
message = $('#chatbox-input').val(); message = $('#chatbox-input').val();

@ -1,4 +1,4 @@
cordova.define("phonegap-plugin-barcodescanner.BarcodeScannerProxy", function(require, exports, module) { function scan(success, error) { cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScannerProxy", function(require, exports, module) { function scan(success, error) {
var code = window.prompt("Enter barcode value (empty value will fire the error handler):"); var code = window.prompt("Enter barcode value (empty value will fire the error handler):");
if(code) { if(code) {
var result = { var result = {

@ -1,5 +1,4 @@
cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require, exports, module) { cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScanner", function(require, exports, module) { /**
/**
* cordova is available under *either* the terms of the modified BSD license *or* the * cordova is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
* *
@ -10,8 +9,6 @@ cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require
var exec = require("cordova/exec"); var exec = require("cordova/exec");
var scanInProgress = false;
/** /**
* Constructor. * Constructor.
* *
@ -100,26 +97,7 @@ BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config
return; return;
} }
if (scanInProgress) { exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', config);
errorCallback('Scan is already in progress');
return;
}
scanInProgress = true;
exec(
function(result) {
scanInProgress = false;
successCallback(result);
},
function(error) {
scanInProgress = false;
errorCallback(error);
},
'BarcodeScanner',
'scan',
config
);
}; };
//------------------------------------------------------------------- //-------------------------------------------------------------------

@ -32,7 +32,7 @@
function setTeam() { function setTeam() {
//alert($('input[name=teamChooser]:checked').val()); //alert($('input[name=teamChooser]:checked').val());
var team = $('input[name=teamChooser]:checked').val(); var team = $('input[name=teamChooser]:checked').val();
$.getJSON(mkApiUrl('setteam', 'gs'), { $.getJSON(mkApiUrl('setteam', 'gs'), {
teamid: team teamid: team
}, function (data) { }, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
@ -40,10 +40,10 @@
openscreen("home"); openscreen("home");
} else { } else {
// Error? // Error?
alert("Error: " + data.message); navigator.notification.alert(data.message, null, "Error", 'OK');
} }
}).fail(function () { }).fail(function () {
alert("Something bad happened, try again later."); navigator.notification.alert("Something went wrong, try again later.", null, "Error", 'OK');
}); });
} }

@ -7,15 +7,36 @@
</div> </div>
<script> <script>
function useitem(uuid) {
$.getJSON(mkApiUrl('useitem', 'gs'), {
itemuuid: uuid
}, function (data) {
if (data.status === 'OK') {
loadinventory();
syncStats();
} else {
navigator.notification.alert(data.message, null, "Error", 'OK');
}
}).fail(function () {
navigator.notification.alert("Cannot use item. Try again.", null, "Error", 'OK');
});
}
function getitemhtmlfromjson(item) { function getitemhtmlfromjson(item) {
return "\ var itemhtml = "\
<div class='list-group-item inventory-item' id='item-" + item.itemuuid + "'>\ <div class='list-group-item inventory-item' id='item-" + item.itemuuid + "'>\
<h4 class='itemname'>" + item.itemname + "</h4>\ <h4 class='itemname'>" + item.itemname + "</h4>\
<p class='itemdesc'>" + item.itemdesc + "</p>\ <p class='itemdesc'>" + item.itemdesc + "</p>";
<span class='itemid' style='display: none;'>" + item.itemid + "</span>\ if (item.classname == "healmagic") {
itemhtml += "<span class='btn btn-success' onclick=\"useitem('" + item.itemuuid + "')\">\
Use Item\
</span>";
}
itemhtml += "<span class='itemid' style='display: none;'>" + item.itemid + "</span>\
<span class='itemclassid' style='display: none;'>" + item.classid + "</span>\ <span class='itemclassid' style='display: none;'>" + item.classid + "</span>\
<span class='itemjson' style='display: none;'>" + item.itemjson + "</span>\ <span class='itemjson' style='display: none;'>" + item.itemjson + "</span>\
</div>"; </div>";
return itemhtml;
} }
function loadinventory() { function loadinventory() {
@ -34,6 +55,6 @@
$('#inventory-list').html(content); $('#inventory-list').html(content);
}); });
} }
loadinventory(); loadinventory();
</script> </script>

@ -2,9 +2,14 @@
<div class="h4" id="place-name"></div> <div class="h4" id="place-name"></div>
<div id="place-info-div"> <div id="place-info-div">
Type: <span id="team-label"></span><br /> Type: <span id="team-label"></span><br />
Life: <span id="life-label"></span> <!-- Life: <span id="life-label"></span><br /> -->
Place life: <div class="progress" id="place-health-place"><div id="place-health-place-bar" class="progress-bar" role="progressbar" ></div></div>
<div class="btn btn-success btn-wide" id="capturebtn" onclick="attempttake()"></div>
My life: <div class="progress" id="user-health-place"><div id="user-health-place-bar" class="progress-bar" role="progressbar" ></div></div>
</div>
<div class="well well-sm place-log" id="place-log">
</div> </div>
<div class="btn btn-primary btn-wide" id="capturebtn" onclick="attempttake()"></div>
</div> </div>
<script> <script>
@ -21,7 +26,7 @@
if (placeteam == 0) { if (placeteam == 0) {
$('#capturebtn').text("Claim"); $('#capturebtn').text("Claim");
} else if (placeteam == userteamid) { } else if (placeteam == userteamid) {
$('#capturebtn').css('display', 'none'); $('#capturebtn').css('visibility', 'hidden');
} else { } else {
$('#capturebtn').text("Challenge"); $('#capturebtn').text("Challenge");
} }
@ -29,12 +34,30 @@
} }
function resyncstats() { function resyncstats() {
$.getJSON(mkApiUrl('getstats', 'gs'), {
user: username
}, function (data) {
if (data.status === 'OK') {
maxenergy = data.stats.maxenergy;
energy = data.stats.energy;
level = data.stats.level;
energypercent = (energy * 1.0 / maxenergy * 1.0) * 100.0;
$('#user-health-place-bar').css('width', String(energypercent) + '%');
refreshStats();
}
});
$.getJSON(mkApiUrl('placestats', 'gs'), { $.getJSON(mkApiUrl('placestats', 'gs'), {
locationid: thisplace.properties.gameinfo.locationid locationid: thisplace.properties.gameinfo.locationid
}, function (data) { }, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
placeteam = data.stats.teamid; placeteam = data.stats.teamid;
$("#life-label").text(Math.round(data.stats.currentlife) + " / " + Math.round(data.stats.maxlife)); var placepercent;
if (data.stats.currentlife > 0) {
placepercent = (Math.round(data.stats.currentlife) * 1.0 / Math.round(data.stats.maxlife) * 1.0) * 100.0;
} else {
placepercent = 0;
}
$('#place-health-place-bar').css('width', String(placepercent) + '%');
loadTeamSwag(); loadTeamSwag();
} else { } else {
// //
@ -45,12 +68,19 @@
function resetafteraction() { function resetafteraction() {
resyncstats(); resyncstats();
setTimeout(resetcapturebtn, 3 * 1000); setTimeout(resetcapturebtn, 2 * 1000);
} }
function loadTeamSwag() { function loadTeamSwag() {
$("#place-name").css("border-color", "#" + getTeamColorFromId(placeteam)); $("#place-name").css("border-color", "#" + getTeamColorFromId(placeteam));
$("#place-info-div").css("border-color", "#" + getTeamColorFromId(placeteam)); $("#place-info-div").css("border-color", "#" + getTeamColorFromId(placeteam));
$("#place-log").css("border-color", "#" + getTeamColorFromId(placeteam));
if (placeteam == 0) {
$("#capturebtn").css("background-color", "#" + getTeamColorFromId(userteamid));
} else {
$("#capturebtn").css("background-color", "#" + getTeamColorFromId(placeteam));
}
$("#place-health-place-bar").css("background-color", "#" + getTeamColorFromId(placeteam));
$("#team-label").css("color", "#" + getTeamColorFromId(placeteam)); $("#team-label").css("color", "#" + getTeamColorFromId(placeteam));
$("#team-label").text(getTeamNameFromId(placeteam)); $("#team-label").text(getTeamNameFromId(placeteam));
} }
@ -74,11 +104,22 @@
}, function (data) { }, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
$('#capturebtn').text(data.message); $('#capturebtn').text(data.message);
switch (Math.round(Math.random() * (3 - 1) + 1)) {
case 1:
$('#place-log').prepend("Attacking...<br />");
break;
case 2:
$('#place-log').prepend("Attacking..<br />");
break;
case 3:
$('#place-log').prepend("Attacking....<br />");
}
resetafteraction(); resetafteraction();
} else { } else {
$('#capturebtn').text(data.message); $('#capturebtn').text(data.message);
$('#capturebtn').removeClass('btn-primary'); $('#capturebtn').removeClass('btn-primary');
$('#capturebtn').addClass('btn-warning'); $('#capturebtn').addClass('btn-warning');
$('#place-log').prepend(data.message + "<br />");
resetafteraction(); resetafteraction();
} }
//alert(data.message); //alert(data.message);
@ -99,11 +140,13 @@
}, function (data) { }, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
$('#capturebtn').text(data.message); $('#capturebtn').text(data.message);
$('#place-log').prepend("Claimed!<br />");
resetafteraction(); resetafteraction();
} else { } else {
$('#capturebtn').text(data.message); $('#capturebtn').text(data.message);
$('#capturebtn').removeClass('btn-primary'); $('#capturebtn').removeClass('btn-primary');
$('#capturebtn').addClass('btn-warning'); $('#capturebtn').addClass('btn-warning');
$('#place-log').prepend(data.message + "<br />");
resetafteraction(); resetafteraction();
} }
//alert(data.message); //alert(data.message);

@ -37,7 +37,7 @@
"cordova-plugin-whitelist": { "cordova-plugin-whitelist": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
}, },
"phonegap-plugin-barcodescanner": { "com.phonegap.plugins.barcodescanner": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
} }
}, },

@ -37,7 +37,7 @@
"cordova-plugin-geolocation": { "cordova-plugin-geolocation": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
}, },
"phonegap-plugin-barcodescanner": { "com.phonegap.plugins.barcodescanner": {
"PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest" "PACKAGE_NAME": "com.netsyms.terranquest.TerranQuest"
} }
}, },

@ -1,12 +1,13 @@
{ {
"name": "phonegap-plugin-barcodescanner", "name": "phonegap-plugin-barcodescanner",
"version": "6.0.1", "version": "5.0.1",
"description": "You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.", "description": "You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.",
"cordova": { "cordova": {
"id": "phonegap-plugin-barcodescanner", "id": "phonegap-plugin-barcodescanner",
"platforms": [ "platforms": [
"ios", "ios",
"android", "android",
"windows8",
"windows", "windows",
"wp8", "wp8",
"blackberry10", "blackberry10",
@ -22,6 +23,7 @@
"ecosystem:phonegap", "ecosystem:phonegap",
"cordova-ios", "cordova-ios",
"cordova-android", "cordova-android",
"cordova-windows8",
"cordova-windows", "cordova-windows",
"cordova-wp8", "cordova-wp8",
"cordova-blackberry10", "cordova-blackberry10",

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" <?xml version="1.0" encoding="UTF-8"?><plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets"
id="phonegap-plugin-barcodescanner" id="com.phonegap.plugins.barcodescanner"
version="6.0.1"> version="5.0.1">
<name>BarcodeScanner</name> <name>BarcodeScanner</name>
<description>You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.</description> <description>You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.</description>
@ -97,6 +97,21 @@
<dependency id="cordova-plugin-compat" version="^1.0.0" /> <dependency id="cordova-plugin-compat" version="^1.0.0" />
</platform> </platform>
<platform name="windows8">
<js-module src="src/windows/BarcodeScannerProxy.js" name="BarcodeScannerProxy">
<merges target="" />
</js-module>
<config-file target="package.appxmanifest" parent="/Package/Capabilities">
<DeviceCapability Name="webcam" />
</config-file>
<framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference" versions="&lt;=8.1"/>
<framework src="src/windows/lib.UW/WinRTBarcodeReader.UW.csproj" custom="true" type="projectReference" versions=">8.1"/>
<asset src="src/windows/assets/plugin-barcodeScanner.css" target="css/plugin-barcodeScanner.css" />
</platform>
<platform name="windows"> <platform name="windows">
<js-module src="src/windows/BarcodeScannerProxy.js" name="BarcodeScannerProxy"> <js-module src="src/windows/BarcodeScannerProxy.js" name="BarcodeScannerProxy">
<merges target="" /> <merges target="" />
@ -112,8 +127,6 @@
<framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference" versions="&lt;=8.1"/> <framework src="src/windows/lib/WinRTBarcodeReader.csproj" custom="true" type="projectReference" versions="&lt;=8.1"/>
<asset src="src/windows/assets/plugin-barcodeScanner.css" target="css/plugin-barcodeScanner.css" /> <asset src="src/windows/assets/plugin-barcodeScanner.css" target="css/plugin-barcodeScanner.css" />
<hook src="hooks/windows/check-arch.js" type="before_compile" />
<hook src="hooks/windows/check-arch.js" type="before_run" />
</platform> </platform>
<!-- Windows Phone 8 --> <!-- Windows Phone 8 -->

@ -336,11 +336,11 @@ parentViewController:(UIViewController*)parentViewController
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
- (void)barcodeScanDone:(void (^)(void))callbackBlock { - (void)barcodeScanDone {
self.capturing = NO; self.capturing = NO;
[self.captureSession stopRunning]; [self.captureSession stopRunning];
[self.parentViewController dismissViewControllerAnimated:YES completion:callbackBlock]; [self.parentViewController dismissViewControllerAnimated: YES completion:nil];
// viewcontroller holding onto a reference to us, release them so they // viewcontroller holding onto a reference to us, release them so they
// will release us // will release us
self.viewController = nil; self.viewController = nil;
@ -380,25 +380,22 @@ parentViewController:(UIViewController*)parentViewController
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
- (void)barcodeScanSucceeded:(NSString*)text format:(NSString*)format { - (void)barcodeScanSucceeded:(NSString*)text format:(NSString*)format {
dispatch_sync(dispatch_get_main_queue(), ^{ dispatch_sync(dispatch_get_main_queue(), ^{
[self barcodeScanDone:^{ [self barcodeScanDone];
[self.plugin returnSuccess:text format:format cancelled:FALSE flipped:FALSE callback:self.callback];
}];
AudioServicesPlaySystemSound(_soundFileObject); AudioServicesPlaySystemSound(_soundFileObject);
[self.plugin returnSuccess:text format:format cancelled:FALSE flipped:FALSE callback:self.callback];
}); });
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
- (void)barcodeScanFailed:(NSString*)message { - (void)barcodeScanFailed:(NSString*)message {
[self barcodeScanDone:^{ [self barcodeScanDone];
[self.plugin returnError:message callback:self.callback]; [self.plugin returnError:message callback:self.callback];
}];
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
- (void)barcodeScanCancelled { - (void)barcodeScanCancelled {
[self barcodeScanDone:^{ [self barcodeScanDone];
[self.plugin returnSuccess:@"" format:@"" cancelled:TRUE flipped:self.isFlipped callback:self.callback]; [self.plugin returnSuccess:@"" format:@"" cancelled:TRUE flipped:self.isFlipped callback:self.callback];
}];
if (self.isFlipped) { if (self.isFlipped) {
self.isFlipped = NO; self.isFlipped = NO;
} }

@ -250,13 +250,6 @@ module.exports = {
capture, capture,
reader; reader;
// Save call state for suspend/resume
BarcodeReader.scanCallArgs = {
success: success,
fail: fail,
args: args
};
function updatePreviewForRotation(evt) { function updatePreviewForRotation(evt) {
if (!capture) { if (!capture) {
return; return;
@ -351,16 +344,7 @@ module.exports = {
return WinJS.Promise.timeout(INITIAL_FOCUS_DELAY) return WinJS.Promise.timeout(INITIAL_FOCUS_DELAY)
.then(function () { .then(function () {
try { try {
return controller.focusControl.focusAsync().then(function () { return controller.focusControl.focusAsync();
return result;
}, function (e) {
// This happens on mutliple taps
if (e.number !== OPERATION_IS_IN_PROGRESS) {
console.error('focusAsync failed: ' + e);
return WinJS.Promise.wrapError(e);
}
return result;
});
} catch (e) { } catch (e) {
// This happens on mutliple taps // This happens on mutliple taps
if (e.number !== OPERATION_IS_IN_PROGRESS) { if (e.number !== OPERATION_IS_IN_PROGRESS) {
@ -515,7 +499,6 @@ module.exports = {
* Removes preview frame and corresponding objects from window * Removes preview frame and corresponding objects from window
*/ */
function destroyPreview() { function destroyPreview() {
var promise = WinJS.Promise.as();
Windows.Graphics.Display.DisplayInformation.getForCurrentView().removeEventListener("orientationchanged", updatePreviewForRotation, false); Windows.Graphics.Display.DisplayInformation.getForCurrentView().removeEventListener("orientationchanged", updatePreviewForRotation, false);
document.removeEventListener('backbutton', cancelPreview); document.removeEventListener('backbutton', cancelPreview);
@ -526,19 +509,14 @@ module.exports = {
if (capturePreviewFrame) { if (capturePreviewFrame) {
document.body.removeChild(capturePreviewFrame); document.body.removeChild(capturePreviewFrame);
} }
capturePreviewFrame = null;
reader && reader.stop(); reader && reader.stop();
reader = null; reader = null;
if (capture) { capture && capture.stopRecordAsync();
promise = capture.stopRecordAsync();
}
capture = null; capture = null;
enableZoomAndScroll(); enableZoomAndScroll();
return promise;
} }
/** /**
@ -551,12 +529,12 @@ module.exports = {
} }
function checkCancelled() { function checkCancelled() {
if (BarcodeReader.scanCancelled || BarcodeReader.suspended) { if (BarcodeReader.scanCancelled) {
throw new Error('Canceled'); throw new Error('Canceled');
} }
} }
BarcodeReader.scanPromise = WinJS.Promise.wrap(createPreview()) WinJS.Promise.wrap(createPreview())
.then(function () { .then(function () {
checkCancelled(); checkCancelled();
return startPreview(); return startPreview();
@ -574,12 +552,7 @@ module.exports = {
return reader.readCode(); return reader.readCode();
}); });
}) })
.then(function (result) { .done(function (result) {
// Suppress null result (cancel) on suspending
if (BarcodeReader.suspended) {
return;
}
destroyPreview(); destroyPreview();
success({ success({
text: result && result.text, text: result && result.text,
@ -587,12 +560,8 @@ module.exports = {
cancelled: !result cancelled: !result
}); });
}, function (error) { }, function (error) {
// Suppress null result (cancel) on suspending
if (BarcodeReader.suspended) {
return;
}
destroyPreview(); destroyPreview();
if (error.message == 'Canceled') { if (error.message == 'Canceled') {
success({ success({
cancelled: true cancelled: true
@ -601,12 +570,6 @@ module.exports = {
fail(error); fail(error);
} }
}); });
BarcodeReader.videoPreviewIsVisible = function () {
return capturePreviewFrame !== null;
}
BarcodeReader.destroyPreview = destroyPreview;
}, },
/** /**
@ -620,53 +583,4 @@ module.exports = {
} }
}; };
var app = WinJS.Application;
function waitForScanEnd() {
return BarcodeReader.scanPromise || WinJS.Promise.as();
}
function suspend(args) {
BarcodeReader.suspended = true;
if (args) {
args.setPromise(BarcodeReader.destroyPreview()
.then(waitForScanEnd, waitForScanEnd));
} else {
BarcodeReader.destroyPreview();
}
}
function resume() {
BarcodeReader.suspended = false;
module.exports.scan(BarcodeReader.scanCallArgs.success, BarcodeReader.scanCallArgs.fail, BarcodeReader.scanCallArgs.args);
}
function onVisibilityChanged() {
if (document.visibilityState === 'hidden'
&& BarcodeReader.videoPreviewIsVisible && BarcodeReader.videoPreviewIsVisible() && BarcodeReader.destroyPreview) {
suspend();
} else if (BarcodeReader.suspended) {
resume();
}
}
// Windows 8.1 projects
document.addEventListener('msvisibilitychange', onVisibilityChanged);
// Windows 10 projects
document.addEventListener('visibilitychange', onVisibilityChanged);
// About to be suspended
app.addEventListener('checkpoint', function (args) {
if (BarcodeReader.videoPreviewIsVisible && BarcodeReader.videoPreviewIsVisible() && BarcodeReader.destroyPreview) {
suspend(args);
}
});
// Resuming from a user suspension
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", function () {
if (BarcodeReader.suspended) {
resume();
}
}, false);
require("cordova/exec/proxy").add("BarcodeScanner", module.exports); require("cordova/exec/proxy").add("BarcodeScanner", module.exports);

@ -7,7 +7,7 @@
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
--> -->
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -23,9 +23,6 @@
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
<TargetFrameworkVersion />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -123,8 +120,8 @@
<HintPath>ZXing.winmd</HintPath> <HintPath>ZXing.winmd</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' "> <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion> <VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@ -134,4 +131,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

Some files were not shown because too many files have changed in this diff Show More