Pebble JavaScript

171 Views Asked by At

i am currently writing a watch app for my pebble time steel and are struggling as i try to introduce time synchronization. basically my code so far has all my lessons imported in as variables and i have an if-else statement to decide what day it is.

main.on('click', 'select', function(e) {
var d = new Date();
var n = d.getDay();
if (n == '1' ){
var h = d.getHours();
console.log(h);
var hm1 = 'm' + h;
console.log (hm1);
[hm1].show();
 }

This is only some of the code and i have had it work with just 'lesson1.show' before. i know the console logs are not necessary but they are useful for trouble shooting (sometimes;D).

var m9 = new UI.Card();
m9.title('Lesson 1');
m9.subtitle('Maths');
m9.body('08:55 - 09:54');

This is how i have the days laid out, from my illeducated mind this seems it would work but it doesn't. All i get is:

[PHONE] pebble-app.js:?: Timetable:343 21
[PHONE] pebble-app.js:?: Timetable:345 m21
[PHONE] pebble-app.js:?: Timetable:2221 JavaScript Error:
TypeError: [hm1].show is not a function
at null.<anonymous> (app.js:235:23)
at emitToHandlers (lib/emitter.js:121:17)
at Emitter.emit (lib/emitter.js:141:35)
at Window._emit (ui/window.js:274:12)
at Function.Window.emit (ui/window.js:286:17)
at Function.Window.emitClick (ui/window.js:301:17)
at Object.SimplyPebble.onPacket (ui/simply-pebble.js:1436:14)
at Array.SimplyPebble.onAppMessage (ui/simply-pebble.js:1480:18)
at Object.PebbleEventListener.dispatchEvent (webview_startup.js:143:50)

Any help is appreciated :D

1

There are 1 best solutions below

1
On BEST ANSWER

if anyone is looking for a similar issue use the eval statement this helped combide the variables as a javascript function