added motion detection
This commit is contained in:
parent
460e91defc
commit
796541ae69
@ -11,7 +11,7 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
const CACHE_VERSION = { 'version': '0.0.967' };
|
const CACHE_VERSION = { 'version': '0.0.972' };
|
||||||
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
||||||
const RUNTIME = 'runtime';
|
const RUNTIME = 'runtime';
|
||||||
|
|
||||||
|
@ -54,12 +54,25 @@ const LocationModel = Backbone.Model.extend({
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const updateLocation = (position) => {
|
||||||
|
console.log('New position', position);
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
console.log(now);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updatelocationthrottled = _.throttle(updateLocation, 10000);
|
||||||
|
|
||||||
|
|
||||||
geolocation.on('change', function (position) {
|
geolocation.on('change', function (position) {
|
||||||
console.log('Location update');
|
console.log('Location update');
|
||||||
|
updatelocationthrottled(position);
|
||||||
|
|
||||||
const latitude = Number.parseFloat(position.coords.latitude).toFixed(6);
|
const latitude = Number.parseFloat(position.coords.latitude).toFixed(6);
|
||||||
const longitude = Number.parseFloat(position.coords.longitude).toFixed(6);
|
const longitude = Number.parseFloat(position.coords.longitude).toFixed(6);
|
||||||
|
|
||||||
const location = { 'latitude': latitude, 'longitude': longitude, 'timestamp': position.timestamp };
|
const location = { 'latitude': latitude, 'longitude': longitude, 'timestamp': position.timestamp };
|
||||||
|
console.log('Loc', location);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
console.log(now.getTime(), now.getTime() - this.throttler);
|
console.log(now.getTime(), now.getTime() - this.throttler);
|
||||||
@ -70,7 +83,7 @@ const LocationModel = Backbone.Model.extend({
|
|||||||
else
|
else
|
||||||
console.log('Throttling location update...');
|
console.log('Throttling location update...');
|
||||||
|
|
||||||
if (!this.has('motion')) {
|
/*if (!this.has('motion')) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const ts = now.getTime();
|
const ts = now.getTime();
|
||||||
|
|
||||||
@ -122,7 +135,7 @@ const LocationModel = Backbone.Model.extend({
|
|||||||
console.log(motion);
|
console.log(motion);
|
||||||
this.set('motion', motion);
|
this.set('motion', motion);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// this.set('location', location);
|
// this.set('location', location);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user