Created
August 13, 2014 20:44
-
-
Save wonderdogone/bed4b3701317165d1741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>RedBoy</title> | |
<meta name="description" content="ble test scanning"> | |
<script src="jquery-1.11.1.min.js"></script> | |
<script src="cordova.js"></script> | |
</head> | |
<body> | |
<h1>Blu</h1> | |
<li> | |
<input type="button" id="getBlue" value="Scan Beacons" /> | |
<button id="docs" onclick="location.href='http://docs.build.phonegap.com'"> | |
Doc</button> | |
<button id="monitor">Scan</button> | |
</li> | |
<li id="feedback"> | |
</li> | |
<script type="text/javascript"> | |
//event handling using jquery | |
$(document).ready (function () { | |
$('#getBlue').click(function () { | |
var value = 'Very Nice Day Sir'; | |
$('#feedback').html(value); | |
console.log('hey jim'); | |
}); | |
//start monitoring beacons | |
$('#monitor').click(function () { | |
//create region | |
function createBeacon() { | |
var uuid = 'f7826da6-4fa2-4e98-8024-bc5b71e0893e'; // mandatory | |
var identifier = 'Umvb'; // mandatory | |
var minor = 39304; // optional, defaults to wildcard if left empty | |
var major = 61171; // optional, defaults to wildcard if left empty | |
// throws an error if the parameters are not valid | |
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor); | |
return beaconRegion; | |
} | |
var logToDom = function (message) { | |
var e = document.createElement('label'); | |
e.innerText = message; | |
var br = document.createElement('br'); | |
var br2 = document.createElement('br'); | |
document.body.appendChild(e); | |
document.body.appendChild(br); | |
document.body.appendChild(br2); | |
}; | |
var delegate = new cordova.plugins.locationManager.Delegate().implement({ | |
didDetermineStateForRegion: function (pluginResult) { | |
logToDom('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult)); | |
cordova.plugins.locationManager.appendToDeviceLog('[DOM] didDetermineStateForRegion: ' | |
+ JSON.stringify(pluginResult)); | |
}, | |
didStartMonitoringForRegion: function (pluginResult) { | |
console.log('didStartMonitoringForRegion:', pluginResult); | |
logToDom('didStartMonitoringForRegion:' + JSON.stringify(pluginResult)); | |
}, | |
didRangeBeaconsInRegion: function (pluginResult) { | |
logToDom('[DOM] didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult)); | |
} | |
}); | |
var uuid = 'f7826da6-4fa2-4e98-8024-bc5b71e0893e'; | |
var identifier = 'Umvb'; | |
var minor = 39304; | |
var major = 61171; | |
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor); | |
cordova.plugins.locationManager.setDelegate(delegate); | |
cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion) | |
.fail(console.error) | |
.done(); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment