-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/xdjinnx/Slebble
- Loading branch information
Showing
5 changed files
with
85 additions
and
64 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,89 @@ | ||
/* eslint strict: 0 */ | ||
/* global trackJs */ | ||
|
||
var Slebble = require('./slebble.js'); | ||
window._trackJs = { token: '9f36ea9a2ea04439907e32f217e1fcc2' }; | ||
|
||
Pebble.addEventListener('ready', () => { | ||
console.log('ready'); | ||
var response = localStorage.data; | ||
if (response !== '' && typeof response === 'string') { | ||
console.log('has data'); | ||
response = JSON.parse(localStorage.data); | ||
console.log('saved data'+JSON.stringify(response)); | ||
Slebble.loadConfig(response); | ||
var stations = []; | ||
for (var i = 0; i < response.route.length; i++) { | ||
Pebble.addEventListener('ready', () => { | ||
trackJs.attempt(() => { | ||
console.log('Running ready event'); | ||
console.log('TrackJs version: ' + trackJs.version); | ||
|
||
var response = localStorage.data; | ||
if (response !== '' && typeof response === 'string') { | ||
console.log('has data'); | ||
response = JSON.parse(localStorage.data); | ||
console.log('saved data'+JSON.stringify(response)); | ||
Slebble.loadConfig(response); | ||
var stations = []; | ||
for (var i = 0; i < response.route.length; i++) { | ||
let ad = {}; | ||
ad.from = response.route[i].from.replace(/\053/g, ' '); | ||
stations.push(ad); | ||
} | ||
Slebble.addStation(stations, 0); | ||
} else { | ||
let ad = {}; | ||
ad.from = response.route[i].from.replace(/\053/g, ' '); | ||
stations.push(ad); | ||
ad.from = 'No configuration'; | ||
ad = [ad]; | ||
Slebble.addStation(ad, 0); | ||
} | ||
Slebble.addStation(stations, 0); | ||
} else { | ||
let ad = {}; | ||
ad.from = 'No configuration'; | ||
ad = [ad]; | ||
Slebble.addStation(ad, 0); | ||
} | ||
}, this); | ||
}); | ||
|
||
|
||
Pebble.addEventListener('showConfiguration', () => { | ||
if (localStorage.data) { | ||
Pebble.openURL('https://diesel-ability-711.appspot.com/webconfig/index.html?version=2.0' + '&setting=' + localStorage.data); | ||
} else { | ||
Pebble.openURL('https://diesel-ability-711.appspot.com/webconfig/index.html?version=2.0'); | ||
} | ||
Pebble.addEventListener('showConfiguration', () => { | ||
trackJs.attempt(() => { | ||
if (localStorage.data) { | ||
Pebble.openURL('https://diesel-ability-711.appspot.com/webconfig/index.html?version=2.0' + '&setting=' + localStorage.data); | ||
} else { | ||
Pebble.openURL('https://diesel-ability-711.appspot.com/webconfig/index.html?version=2.0'); | ||
} | ||
}, this); | ||
}); | ||
|
||
Pebble.addEventListener('webviewclosed', (e) => { | ||
if (e.response === 'reset') { | ||
localStorage.removeItem('data'); | ||
} else if (e.response !== 'CANCELLED' && e.response.substring(0, 12) !== '{"route": []' && e.response !== '{}') { | ||
localStorage.setItem('data', e.response); | ||
Pebble.addEventListener('webviewclosed', (e) => { | ||
trackJs.attempt((e) => { | ||
if (e.response === 'reset') { | ||
localStorage.removeItem('data'); | ||
} else if (e.response !== 'CANCELLED' && e.response.substring(0, 12) !== '{"route": []' && e.response !== '{}') { | ||
localStorage.setItem('data', e.response); | ||
|
||
if (localStorage.data) { | ||
var response = JSON.parse(localStorage.data); | ||
Slebble.loadConfig(response); | ||
if (localStorage.data) { | ||
var response = JSON.parse(localStorage.data); | ||
Slebble.loadConfig(response); | ||
|
||
var stations = []; | ||
for (var i = 0; i < response.route.length; i++) { | ||
var ad = {}; | ||
ad.from = response.route[i].from.replace(/\053/g, ' '); | ||
stations.push(ad); | ||
} | ||
var stations = []; | ||
for (var i = 0; i < response.route.length; i++) { | ||
var ad = {}; | ||
ad.from = response.route[i].from.replace(/\053/g, ' '); | ||
stations.push(ad); | ||
} | ||
|
||
Slebble.addStation(stations, 0); | ||
Slebble.addStation(stations, 0); | ||
|
||
} | ||
} | ||
} | ||
}, this, e); | ||
}); | ||
|
||
Pebble.addEventListener('appmessage', (e) => { | ||
/** | ||
* payload[1] : menu row | ||
* payload[2] : step, is saying which instruction the watch excpects | ||
* payload[3] : expected package key | ||
*/ | ||
if (e.payload[2] === 0) { | ||
if (e.payload[1] !== 0) { | ||
Slebble.requestRides(e.payload[1] - 1, e.payload[2], e.payload[3]); | ||
Pebble.addEventListener('appmessage', (e) => { | ||
trackJs.attempt((e) => { | ||
/** | ||
* payload[1] : menu row | ||
* payload[2] : step, is saying which instruction the watch excpects | ||
* payload[3] : expected package key | ||
*/ | ||
if (e.payload[2] === 0) { | ||
if (e.payload[1] !== 0) { | ||
Slebble.requestRides(e.payload[1] - 1, e.payload[2], e.payload[3]); | ||
} else { | ||
Slebble.requestGeoRides(e.payload[3]); | ||
} | ||
} else if (e.payload[2] === 1){ | ||
Slebble.requestRides(e.payload[1], e.payload[2], e.payload[3]); | ||
} else { | ||
Slebble.requestGeoRides(e.payload[3]); | ||
Slebble.requestUpdate(e.payload[3]); | ||
} | ||
} else if (e.payload[2] === 1){ | ||
Slebble.requestRides(e.payload[1], e.payload[2], e.payload[3]); | ||
} else { | ||
Slebble.requestUpdate(e.payload[3]); | ||
} | ||
}, this, e); | ||
}); |
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