.then(function(stops){ var stopAggregates = stops.map(function(stop){ return { "name": stop.przystanek.properties.stop_name, "id": stop.przystanek.id, "distance": stop.distance, "headsigns": stop.przystanek.properties.headsigns.split(", ") }; }).reduce(function(all, elem){ var stopAggregate = _.findWhere(all, {"name": elem.name}); if(_.isUndefined(stopAggregate)){ all.push({"name": elem.name, "stops": [elem]}); } else { stopAggregate.stops.push(elem); } return all; }, []); var menu = new UI.Menu({ "highlightBackgroundColor": Feature.color("islamic-green", "black"), "sections": [{ "items": _.first(stopAggregates,10).map(function(aggragate){ return { "title": aggragate.name, "subtitle": _.uniq(_.flatten(aggragate.stops.map(function(stop){return stop.headsigns}))).join(" "), "aggregate": aggragate }; }) }] }); menu.on('select', function(selected) {singleStop.openWindow(selected.item.aggregate)}); menu.show(); Vibe.vibrate('short'); Light.trigger(); })
function realityCheck() { var config = getConfig(); console.log(config); if(config.freq == 480) { config.freq = config.freqTemp; } var w = new UI.Window({ fullscreen: true }); w.on('hide', function() { scheduleNextRealityCheck(config.freq); saveConfig(config); }); var q = new UI.Text({ position: new Vector2(0, 30), size: new Vector2(144, 100), font: 'bitham-30-black', text: 'Is this a dream?', textAlign: 'left' }); //var r = Math.floor(Math.random() * 2); var yes = new UI.Text({ position: new Vector2(0, 0), size: new Vector2(144, 20), font: 'gothic-18-bold', text: 'YES', textAlign: 'right' }); var no = new UI.Text({ position: new Vector2(0, 148), size: new Vector2(144, 20), font: 'gothic-18-bold', text: 'NO', textAlign: 'right' }); w.on('click', 'down', function() { w.hide(); }); w.add(q); w.add(yes); w.add(no); w.show(); Light.trigger(); Vibe.vibrate('long'); }
functions.alert = function(){ var settings = Settings.option(); //myLogger.debug('triggering alert'); if (settings.light){ Light.trigger(); console.log('alert light'); } if (settings.vibration){ Vibe.vibrate('short'); console.log('alert vibe'); } if (settings.reminderMode == "randomReminders"){ clearInterval(timer); var temp = getRandomInt(20,120)*60000; var now = Date.now(); console.log('now ' + now); console.log('interval ' + temp); console.log('expected ' + now + temp); timer = setInterval(functions.alert, temp); return timer; } };
function(responseText) { var menuItems = parseFeed(responseText, responseText.length); mainMenu = new UI.Menu({ sections: [{ title: 'CFL Schedule', items: menuItems }] }); var selectedWeek; mainMenu.on('select', function(event) { //selectedWeek = event.item; selectedWeek = responseText[event.itemIndex]; var weekItems = parseGames(selectedWeek.games, selectedWeek.games.length); weekMenu = new UI.Menu({ sections: [{ title: selectedWeek.name, items: weekItems }] }); weekMenu.on('select', function(event) { var selectedGame = selectedWeek.games[event.itemIndex]; gameScreen = new UI.Window({ backgroundColor: 'white', fullscreen: true }); var weekHeader = new UI.Text({ position: new Vector2(0, 0), size: new Vector2(144, 30), font: 'gothic-24-bold', textAlign: 'center', backgroundColor: 'black', color: 'white', text: selectedWeek.name }); gameScreen.add(weekHeader); var awayTitle = new UI.Text({ position: new Vector2(10, 30), size: new Vector2(57, 20), textAlign: 'center', color: 'black', text: 'AWAY' }); gameScreen.add(awayTitle); var homeTitle = new UI.Text({ position: new Vector2(77, 30), size: new Vector2(57, 20), textAlign: 'center', color: 'black', text: 'HOME' }); gameScreen.add(homeTitle); var awayScore = new UI.Text({ position: new Vector2(10, 55), size: new Vector2(57, 40), font: 'bitham-42-bold', textAlign: 'center', color: 'black', text: selectedGame.AwayScore }); gameScreen.add(awayScore); var homeScore = new UI.Text({ position: new Vector2(77, 55), size: new Vector2(57, 40), font: 'bitham-42-bold', textAlign: 'center', color: 'black', text: selectedGame.HomeScore }); gameScreen.add(homeScore); var awayTeam = new UI.Text({ position: new Vector2(10, 100), size: new Vector2(57, 20), font: 'gothic-24-bold', textAlign: 'center', color: 'black', text: selectedGame.AwayTeamShort }); gameScreen.add(awayTeam); var homeTeam = new UI.Text({ position: new Vector2(77, 100), size: new Vector2(57, 20), font: 'gothic-24-bold', textAlign: 'center', color: 'black', text: selectedGame.HomeTeamShort }); gameScreen.add(homeTeam); var date = new UI.Text({ position: new Vector2(0, 130), size: new Vector2(144, 40), textAlign: 'center', backgroundColor: 'black', color: 'white', text: selectedGame.Date }); gameScreen.add(date); gameScreen.show(); }); weekMenu.show(); }); if (init) { mainMenu.show(); splash.hide(); init = false; } Light.trigger(); getDate(); refreshTimer = setTimeout(function () {GetSchedule();}, refreshInterval * 60000); },