Beispiel #1
0
function messages(serverID, channelID) {
		var menu = new UI.Menu({
		sections: [{
			title: '#flowerbed',
			items: [{
				id: '211722322099437568',
				timestamp: '1470550175018',
				title: 'Nate The Lever (Atlas)',
				subtitle: '>Flipped Cursor',
			}, {
				id: '120330239996854274',
				timestamp: '1470550175020',
				title: 'RoadCrosser',
				subtitle: '@Nate The Lever (Atlas) (╯°□°)╯︵ ┻━┻',
			}]
		}]
	});
	
	menu.on('select', function(e) {
		showMessage(e.item.title, e.item.subtitle, e.item.timestamp);
	});
	
	menu.on('longSelect', function(e) {
		showMenu({type: 'channel', title: '#flowerbed', subtitle: 'Welcome to the Undertale Discord server!'});
	});

	menu.show();
}
Beispiel #2
0
 function(data) {
   // Success!
   // console.log("Successfully fetched Asteroid data!" + data);
   var object = data;
   var nearEarthObjects = object.near_earth_objects;
   if(nearEarthObjects.length==0) {
     // console.log(" neo is undefined ");
     noAsteroidCard.show();
   } else {
     try {
       for(var i = 0; i < nearEarthObjects[todayDate].length; i++) {
         var obj = nearEarthObjects[todayDate][i];
         var lunarDistance = obj.close_approach_data[0].miss_distance.lunar;
         var kilometers = obj.close_approach_data[0].miss_distance.kilometers;
         var relativeVelocity = obj.close_approach_data[0].relative_velocity.kilometers_per_hour;
         var absoluteMag = obj.absolute_magnitude_h;
         asteroids.push({
           title: obj.name,
           subtitle: "Lunar Distance " + lunarDistance,
           relvel: formatNumber(parseInt(relativeVelocity.replace(',', ''))),
           lunarDistance: lunarDistance,
           absoluteMag: absoluteMag,
           kilometers: formatNumber(parseInt(kilometers.replace(',', ''))),
         });
       }
       asteroid_list.section(0).title ='AsteroidToday - ' + nearEarthObjects[todayDate].length;
       asteroid_list.show();
     } catch(err) {
       console.log('Caught error' + err);
       splashWindow.hide();
     }
   }
   splashWindow.hide();
 },
Beispiel #3
0
main.on('longClick', 'up', function(e) {
  var menu = new UI.Menu({
    sections: [{
      items: [{
        title: 'Player 1'
      }, {
        title: 'Bob'
      }, {
        title: 'Jacob'
      }, {
        title: 'Timothy'
      }, {
        title: 'Guilherme'
      }]
    }]
  });
  menu.on('select', function(e) {
    console.log('Selected item #' + e.itemIndex);
    console.log('The selection is titled "' + e.item.title + '"');
    Settings.data('player1', e.item.title);
    main.body(getBody());
    menu.hide();
  });
  menu.show();
});
Beispiel #4
0
function showMenu(topItem) {
			var menu = new UI.Menu({
		sections: [{
			title: capitalize(topItem.type),
			items: [{
				id: '-2',
				title: topItem.title,
				subtitle: topItem.subtitle
			}]
		}, {
			title: 'You!',
			items: [{
				id: '-1',
				title: 'Nate#2564',
				subtitle: 'Select for settings'
			}]
		}]
	});
	
	menu.on('select', function(e) {
		if(e.item.id === '-1') {
			menuSettings();
		} else if(e.item.id === '-2') {
			showMessage(e.item.title, e.item.subtitle, '-1'); //lazy woo
		}
	});

	menu.show();
}
Beispiel #5
0
 function (data) {
     if (data.error) {
         functions.showAndRemoveCard('Error', data.error, '', card);
     } else {
         card.hide();
         var menuItems = new Array(data.length);
         for (var i = 0; i < data.length; i++) {
             menuItems[i] = {
                 title: data[i].price,
                 subtitle: data[i].date,
                 description: data[i].description
             };
         }
         var history = new UI.Menu({
             sections: [{
                 title: 'Dining History',
                 items: menuItems
             }]
         });
         history.on('select', function (event) {
             functions.showCard(menuItems[event.itemIndex].title, menuItems[event.itemIndex].subtitle, menuItems[event.itemIndex].description);
         });
         history.show();
     }
 },
Beispiel #6
0
function handleNewMessage(_message) {
  message = _message;
  
  ingredients = message.ingredients;
  numIngreds = ingredients.length;
  instructions = message.steps;
  numInstrucs = message.steps.length;
  
  var mainMenu = new UI.Menu({
    sections: [{
      items: [{
        title: 'Ingredients',
        subtitle: 'View the ingredients'
      }, {
        title: 'Recipe',
        subtitle: 'View the steps'
      }]
    }]
  });
  mainMenu.on('select', function(e) {
    if(e.itemIndex === 0){
      ingMenus.show();
    }
    else{
      insMenus.show();
    }
  });
  mainMenu.show();
}
Beispiel #7
0
 function(data) {
   if(debug)
     console.log("DEBUG data for task assignment: " + JSON.stringify(data, null, 4));
     taskMenu.hide();
     detailCard.hide();
     resultsMenu.hide();
 },
Beispiel #8
0
function menuServers() {
	var menu = new UI.Menu({
		sections: [{
			title: 'Your Servers',
			items: [{
				id: '120330239996854274',
				title: '/r/Undertale',
				subtitle: '* - 1 mention',
			}, {
				id: '81384788765712384',
				title: 'Discord API',
				subtitle: '* New messages',
			}]
		}]
	});

	menu.on('select', function(e) {
		menuChannels(e.item.id);
	});
	
	menu.on('longSelect', function(e) {
		showMenu({type: 'friends', title: 'Friend status/DMs', subtitle: 'Maybe?'});
	});
	
	menu.show();
}
Beispiel #9
0
  function(data, status, request) {
    splashWindow.hide();
    menu.show();
    //console.log('Alias: ' + data.Results[2].devices[15].ATTR.alias);
    var aDevices = data.Results[2].devices;
    var myMenuPos = 0;
    for(var i = 0; i < aDevices.length; i++) {
      if(aDevices[i].ATTR.subType === 'switch')
        {
          var myAlias = aDevices[i].ATTR.alias;
          var myShorterAlias = myAlias.replace('Schalter: ', '');
          var myNextState = 'on';
          if (aDevices[i].STATE==='on') myNextState = 'off';
          menu.item(0, myMenuPos, {
            title: myShorterAlias,
            subtitle: 'State:' +  aDevices[i].STATE,
            state_next: myNextState,
            state_current: aDevices[i].STATE,
            switch_name:  aDevices[i].NAME,
            switch_url: scheme + '://' + user + ':' + passwd  + '@' + host  + ':' + port  + '/fhem?XHR=1&cmd.' + aDevices[i].NAME + '=set%20' + aDevices[i].NAME + '%20' + myNextState
          });
          console.log('Switch found:' + aDevices[i].ATTR.alias);
          myMenuPos++;
        }
    }    
    
},
Beispiel #10
0
function select_choice(e){

  if (e.item.status === 0){
    choice = [{title: "Start"}, {title: "Remove"}];
  }
  if (e.item.status == 4 || e.item.status == 6){
    choice = [{title: "Pause"}, {title: "Remove"}];
  }
  var menu_choice = new UI.Menu({
    backgroundColor: colors_dict.backgroundColor,
    textColor: colors_dict.textColor,
    highlightBackgroundColor: colors_dict.highlightBackgroundColor,
    highlightTextColor: colors_dict.highlightTextColor,
  fullscreen: true,
    sections: [{
      title: "Action",
      items: choice
    }]
  });

  menu_choice.show();

  menu_choice.on('select', function(element){
    console.log("Selected " + e.item.id);
    complete_action(element.item.title, e.item.id);
    menu_choice.hide();
  });
}
Beispiel #11
0
 function(data) {
   console.log('fetched Classifications');
   
   var classifications = data._embedded.classifications;
   var classificationsMenu = new UI.Menu({
     sections: [{
       items: classifications.map(function(cls) {
         return {
           title: cls.segment.name
         };
       })
     }],
     backgroundColor: styles.bgColor,
     textColor: styles.textColor,
     highlightBackgroundColor: styles.highlightBgColor,
     highlightTextColor: styles.highlightTextColor
   });  
   
   classificationsMenu.on('select', function(e) {
     var classification = classifications[e.itemIndex];
     var clsId = classification.segment.id;
     runSearch(clsId);
   });
   
   classificationsMenu.show();      
 },
Beispiel #12
0
function showMenu() {
  var mainMenu = new UI.Menu({
     sections: [{
       items: [{
         title: 'Search Events'
       }, {
         title: 'Favorites'
       }]
     }],
     backgroundColor: styles.bgColor,
     textColor: styles.textColor,
     highlightBackgroundColor: styles.highlightBgColor,
     highlightTextColor: styles.highlightTextColor
  });
  
  mainMenu.on('select', function(e) {
    console.log('mainMenu selected item: ' + e.itemIndex);
    
    switch (e.itemIndex) {
      case 0:
        showClassifications();
        break;
      case 1:
        showFavorites();
        break;
    }
  });
  
  mainMenu.show();
  splashScreen.hide();
}
Beispiel #13
0
main.on('click', 'up', function(e) {
  var menu = new UI.Menu({
    sections: [{
      items: [{
        title: 'light on',
        icon: 'images/menu_icon.png',
      }, {
        title: 'ligth off',
        icon: 'images/menu_icon.png',
      }]
    }]
  });
  menu.on('select', function(e) {
   var URL='http://45.79.151.162:8080/setoff.jsp';
   if (e.item.title=='light on'){
      URL='http://45.79.151.162:8080/seton.jsp';
   }
      ajax({
        url : URL,
        type:'json',
      },
    function(data) {
      console.log(data);
    });
      
  });
  menu.show();
});
Beispiel #14
0
function locationSuccess(position) {
  var lat = position.coords.latitude;
  var lon = position.coords.longitude;
  var title = 'Paikannettu';
  if (lat > hslBounds[0] || lon > hslBounds[1] || lat < hslBounds[2] || lon < hslBounds[3]) {
    title = 'Arvottu paikka';
    lat = Math.random()/10 + 60.17;
    lon = Math.random()/5 + 24.8;
    randomLocation = true;
  }
  main.section(0, {title: title, items: [
    {
      title: Math.round(lat*10000)/10000 + ',' + Math.round(lon*10000)/10000,
      subtitle: 'Päivitä sijainti'
    }
  ]});
  main.item(0, 1, {title: 'Haetaan pysäkit...'});
  // console.log("Got location " + lat + ',' + lon);
  var href = stopsURI + lon + ',' + lat;
  console.log("Getting " + href);
  ajax(
    {url: href, type: 'json'},
    buildStopMenu,
    logError
  );
}
Beispiel #15
0
function menuChannels(serverID) {
	var menu = new UI.Menu({
		sections: [{
			title: '/r/Undertale - Text Channels',
			items: [{
				id: '128997354450714624',
				title: '#flowerbed',
				subtitle: 'Welcome to the Undertale Discord server!',
			}, {
				id: '120330239996854274',
				title: '#newhome',
				subtitle: '* - General discussion, on topic or off.',
			}]
		}]
	});

	menu.on('select', function(e) {
		messages(serverID, e.item.id);
	});
	
	menu.on('longSelect', function(e) {
		showMenu({type: 'server', title: '/r/Undertale', subtitle: '1600 Members'});
	});

	menu.show();
}
Beispiel #16
0
function loadCYOASettings() {
		var cyoaID = current.cyoaID;
		var data = currentData;
		console.log('Settings Loading. cyoaID: ' + cyoaID);
		loadSplash.show();
		console.log(pinnedCYOAs.contains(cyoaID));

		var menu = new UI.Menu({
			sections: [{
				title: 'Sort',
				items: [{
					id: 0,
					title: ((pinnedCYOAs.contains(cyoaID)) ? 'Unpin CYOA' : 'Pin CYOA'),
				}, {
					id: 1,
					title: 'First Post',
					subtitle: data[cyoaID].first.timestamp
				}, {
					id: 2,
					title: 'Last Post',
					subtitle: data[cyoaID].last.timestamp
				}]
			}]
		});

		menu.on('select', function(e) {
			if (e.item.id === 0) {
				var parsedPinnedCYOAs = pinnedCYOAs;
				console.log(Array.isArray(parsedPinnedCYOAs));
				if (parsedPinnedCYOAs.contains(cyoaID)) {
					var index = parsedPinnedCYOAs.indexOf(cyoaID);
					parsedPinnedCYOAs.splice(index, 1);
					Settings.option('pinnedCYOAs', parsedPinnedCYOAs);
					pinnedCYOAs = Settings.option('pinnedCYOAs');
					console.log('removed ' + cyoaID);
				} else {
					parsedPinnedCYOAs.push(cyoaID);
					Settings.option('pinnedCYOAs', parsedPinnedCYOAs);
					pinnedCYOAs = Settings.option('pinnedCYOAs');
					console.log(pinnedCYOAs);
					console.log('added ' + cyoaID);
				}
				console.log(parsedPinnedCYOAs);
				menu.item(e.sectionIndex, e.itemIndex, {
					title: ((parsedPinnedCYOAs.contains(cyoaID)) ? 'Unpin CYOA' : 'Pin CYOA')
				});
				Settings.option('pinnedCYOAs', parsedPinnedCYOAs);
				pinnedCYOAs = Settings.option('pinnedCYOAs');
			}
			if (e.item.id === 1) {
				/// TO BE DONE!
			}
		});

		//Show menu
		menu.show();
		loadSplash.hide();
		console.log('Settings Loaded');
	} //load settings & stuff for a CYOA
Beispiel #17
0
    function(data) {

      // If we're successful!
      console.log("Successfully fetched Solar info!");
      console.log("Last Updated: " + data.overview.lastUpdateTime);

      // Extract data from web, rounds the values, then makes it the correct units---
      var currentpower = data.overview.currentPower.power; //W
      var todayenergy = data.overview.lastDayData.energy; //Wh
      var monthenergy = data.overview.lastMonthData.energy; //Wh
      var yearenergy = data.overview.lastYearData.energy; //Wh
      var lifetimeenergy = data.overview.lifeTimeData.energy; //Wh
      var lifetimerevenue = data.overview.lifeTimeData.revenue; //$

      // Last Updated----------------------------------------------------------------
      var lastupdated = data.overview.lastUpdateTime;

      // Creates menu items based on the above data from the web---------------------
      var menuItems = [
        {
          title: "Current Power",
          subtitle: numberFormat(currentpower, 'W')
        },
        {
          title: "Today\'s Energy",
          subtitle: numberFormat(todayenergy, 'Wh')
        },
        {
          title: "Month\'s Energy",
          subtitle: numberFormat(monthenergy, 'Wh')
        },
        {
          title: "YTD Energy",
          subtitle: numberFormat(yearenergy, 'Wh')
        },
        {
          title: "Lifetime Energy",
          subtitle: numberFormat(lifetimeenergy, 'Wh')
        },
        {
          title: "Lifetime Revenue",
          subtitle: "$ " + lifetimerevenue.toFixed(2)
        },
        {
          title: "Last Updated",
          subtitle: (lastupdated)
        }
      ];

      // Creates info to show user
      var resultsMenu = new UI.Menu({
        sections: [{
          items: menuItems
        }]
      });

      resultsMenu.show(); //shows the menu items
      Intro.hide();
    },
Beispiel #18
0
  function(xml) {
    var myRegexp = /<item>[\s]*<title>(.*)<\/title>[\s]*<description>([^<>]*)<\/description>[\s]*<pubDate>(.*)<\/pubDate>[\s]*<link>(.*)<\/link>[\s]*<\/item>/g;
    var textRegexp = /([\S]*: [0-9]+)/g;
    var titles = [];
    var currentTitleIndex = -1;
    
    var match = myRegexp.exec(xml);

    while (match !== null) {
      var pollenMatch = match[2].match(textRegexp);
      var text = "Ingen pollen";
      var subtitle = text;
      if (pollenMatch) {
        text = pollenMatch.join('\n');
        subtitle = pollenMatch.join(', ');
      }
      
      text += '\n\n' + match[3];
      
      titles.push({ title: match[1], subtitle: subtitle, text: text });
     
      match = myRegexp.exec(xml);
    }
    
    var makeDetailCard = function() {
      var detailCard = new UI.Card({
        title: titles[currentTitleIndex].title,
        body: titles[currentTitleIndex].text,
        scrollable: true
      });          
    
      detailCard.on('click', function(event) {
        if (currentTitleIndex < titles.length - 1) {
          currentTitleIndex++;

          detailCard.hide();
          
          makeDetailCard(currentTitleIndex);
        }
      });
      
      detailCard.show();    
    };
    
    var listCard = new UI.Menu({
      sections: [{
        title: 'Pollental',
        items: titles
      }]
    });
    
    listCard.on('select', function(event) {
      currentTitleIndex = event.itemIndex;
      makeDetailCard();      
    });
    
    listCard.show();
    splashCard.hide();
  },
Beispiel #19
0
    }, function (data) {
        if (data.status != 0) {
            functions.showAndRemoveCard('Error', '', data.message, loading);
        } else {
            if (data.projects.length > 0) {
                loading.hide();
                data = data.projects;
                var publishedMenuItems = [];
                var incompleteMenuItems = [];
                for (var i = 0; i < data.length; i++) {
                    if (data[i].version) {
                        publishedMenuItems.push({
                            title: data[i].title,
                            subtitle: "Version: " + data[i].version,
                            update_date: data[i].update_date,
                            aplite: data[i].aplite,
                            basalt: data[i].basalt,
                            chalk: data[i].chalk,
                            ios: data[i].ios,
                            android: data[i].android,
                            timeline: data[i].timeline,
                            hearts: data[i].hearts,
                            installs: data[i].installs
                        });
                    } else {
                        incompleteMenuItems.push({
                            title: data[i].title,
                            subtitle: "Version: " + data[i].version,
                            update_date: data[i].update_date,
                            aplite: data[i].aplite,
                            basalt: data[i].basalt,
                            chalk: data[i].chalk,
                            ios: data[i].ios,
                            android: data[i].android,
                            timeline: data[i].timeline,
                            hearts: data[i].hearts,
                            installs: data[i].installs
                        });
                    }


                }
                var menu = new UI.Menu({
                    sections: [{
                        title: 'Published - ' + publishedMenuItems.length, items: publishedMenuItems
                    },{
                        title: 'Incomplete - ' + incompleteMenuItems.length, items: incompleteMenuItems
                    }]
                });

                menu.on('select', function (event) {
                    functions.showCard(event.item.title, event.item.subtitle,'Installs: ' + event.item.installs + '\nHearts: ' + event.item.hearts + '\nLast Updated:\n' + event.item.update_date + '\nAplite: ' + event.item.aplite + '\nBasalt: ' + event.item.basalt + '\nChalk: ' + event.item.chalk + '\nAndroid: ' + event.item.android + '\niOS: ' + event.item.ios + '\nTimeline: ' + event.item.timeline);
                });
                menu.show();
            } else {
                functions.showAndRemoveCard('Error', 'You do not have any projects published!', '', loading);
            }
        }
    }, function () {
Beispiel #20
0
/**
 * Initialize the application and menu
 */
function load_app(){
  if (localStorage.getItem("options") === null) {
    console.log("No options in Localstorage");
    resetConfig();
  } else {
    try {
      console.log("Get options from Localstorage");
      console.log(localStorage.getItem("options"));
      options = JSON.parse(decodeURIComponent(localStorage.getItem("options")));
      options.delijnHaltes = options.delijnHaltes.split("\n");
      options.mivbHaltes = options.mivbHaltes.split("\n");
      options.nmbsHaltes = options.nmbsHaltes.split("\n");
      console.log("Options = " + JSON.stringify(options));
    } catch (err){
      resetConfig();
    }
  }
  
  try{ hideError(); }catch (err){}
  try{ hideLoading(); }catch (err){}
  try{ screen_menu.hide(); }catch (err){}
  try{ screen_delijn.hide(); }catch (err){}
  try{ screen_delijn_arrivals.hide(); }catch (err){}
  try{ screen_mivb.hide(); }catch (err){}
  try{ screen_mivb_arrivals.hide(); }catch (err){}
  try{ screen_nmbs.hide(); }catch (err){}
  try{ screen_nmbs_arrivals.hide(); }catch (err){}
  
  initLoadingScreen();
  initErrorScreen();
  
  screen_menu = new UI.Menu({
    sections: [{
      title: 'BETransport',
      items: [{
        title: getMessage(messages.transport_delijn),
        icon: 'images/icon_delijn.png'
//       },{
//         title: getMessage(messages.transport_mivb),
//         icon: 'images/icon_mivbstib.png'
      },{
        title: getMessage(messages.transport_nmbs),
        icon: 'images/icon_nmbs.png'
      }]
    }]
  });
  screen_menu.on('select', function(e) {
    console.log("Menu selection : " + e.itemIndex);
    switch(e.itemIndex){
      case 0:
        load_delijn();
        break;
      case 1:
        load_nmbs();
        break;
    }
  });
  screen_menu.show(); 
}
Beispiel #21
0
    fetchData('decktypecount', function(data) {
        var menu = new UI.Menu({
            sections: [{
                items: createItem(data.decks)
            }]
        });

        menu.show();
    });
Beispiel #22
0
function completeTask( event )
{
	if(DEBUG) console.log( "Changing Complete Status" );

	var date = new Date().toISOString();
	date = date.slice( 0, date.indexOf( "T" ) );

	// Mark as done optimistically to improve UX.
	if( event.item.data.completed )
		taskMenu.item( event.sectionIndex, event.itemIndex, { title: event.item.title, subtitle: event.item.subtitle, icon: "images/task.png", data: event.item.data, position: event.item.position } );
	else
		taskMenu.item( event.sectionIndex, event.itemIndex, { title: event.item.title, subtitle: event.item.subtitle, icon: "images/done.png", data: event.item.data, position: event.item.position } );

	ajax(
	{
		url:     api + "/tasks/" + event.item.data.id,
		type:    "json",
		method:  "get",
		headers: header
	},
	function( taskData )
	{
		ajax(
		{
			url:     api + "/tasks/" + event.item.data.id,
			type:    "json",
			method:  "patch",
			headers: header,
			data:    { revision: taskData.revision, completed: !taskData.completed }
		},
		function( data )
		{
			if(DEBUG) console.log( JSON.stringify( data ) );
			
			if( data.completed )
			{
				if(DEBUG) console.log( "Task Marked Complete" );
				taskMenu.item( event.sectionIndex, event.itemIndex, { title: event.item.title, subtitle: event.item.subtitle, icon: "images/done.png", data: data, position: event.item.position } );
			}
			else
			{
				if(DEBUG) console.log( "Task Marked Incomplete" );
				taskMenu.item( event.sectionIndex, event.itemIndex, { title: event.item.title, subtitle: event.item.subtitle, icon: "images/task.png", data: data, position: event.item.position } );
			}
		},
		function( err )
		{
			if(DEBUG) console.log( "Completing Task Failed: " + JSON.stringify( err ) );
			reportError( "Marking Task Complete AJAX: " + JSON.stringify( err ) );
		});
	},
	function( err )
	{
		if(DEBUG) console.log( "Completing Task Failed: " + JSON.stringify( err ) );
		reportError( "Marking Task Complete AJAX: " + JSON.stringify( err ) );
	});
}
Beispiel #23
0
 displayMenu: function(title, items) {
   var menu = new UI.Menu({
     sections: [{
       title: title,
       items: items
     }]
   });
       
   menu.show();
 },
Beispiel #24
0
   function(data) {
     var menuItems = parseFeed(data, 10);
     var resultsMenu = new UI.Menu({
     sections: [{
     title: cityName,
     items: menuItems
   }]
 });
 resultsMenu.show();
 }
Beispiel #25
0
 function(data){
   console.log(data);
   menuTransporte.items(0, data);
   Vibe.vibrate('short');
   menuTransporte.on('select', function(e){
     ecobiciCard.title(e.item.title);
     ecobiciCard.body(e.item.steps);
     ecobiciCard.show();
   });
 },
Beispiel #26
0
 menu.on('select', function (e) {
     switch (e.item.title) {
         case 'Mainboard':
             main.show();
             break;
         case 'Sideboard':
             side.show();
             break;
     }
 });
Beispiel #27
0
function showMenu() {
  // We create a simple menu with a few options
  var menu = new UI.Menu({
    sections: [{
      items: [{
        title: 'Personal Security',
        subtitle: 'Alert your loved ones.'
      },
      {
        title: 'Home Security',
        subtitle: 'Secure your devices.'
      },
      {
        title: 'Voice Help',
        subtitle: 'Speak to receive help'
      }]
    }]
  });
  menu.on('accelTap', function(e) {
    console.log('Accel detected');
    var options = {
      enableHighAccuracy : false,
      maximumAge : 10000,
      timeout : 30000
    };
    navigator.geolocation.getCurrentPosition(success, error, options);
    function success(pos) {
      console.log('success');
      console.log('lat=' + pos.coords.latitude + 'lon=' + pos.coords.longitude);
      ref.child("personal").child("1").update({"emergency" : true, "gps" : pos.coords.latitude + " " + pos.coords.longitude});
    }
    function error(err) {
      console.log('err occured');
      console.log(err);
    }
  });
  // When the user selects an option...
  menu.on('select', function(e) {
    // We use the title to perform operations
    switch (e.item.title) {
      case 'Home Security':
      	showSecurityView();
        break;
      case 'Personal Security':
        showPersonalView();
      	break;
      case 'Voice Help':
        showVoiceView();
        break;
    }
  });

  // Finally make sure the menu is set to show.
  menu.show();
}
Beispiel #28
0
 function(json) {
   if (json.length === 0 ) {
     UIError.show();
   } else {
     var cinemaMenu = [];
     for(var i = 0; i < json.theater.length; i++) {
       if (json.theater[i].name !== '') {
         cinemaMenu.push({
           title:json.theater[i].name,
           subtitle:json.theater[i].info.replace("&#39;", "'")
         });
       }
     }    
     var UIListCinema = new UI.Menu({
       sections: [{
         title: 'Cinema',
         items: cinemaMenu
       }]
     });
     UILoading.hide();
     UIListCinema.show();
     UIListCinema.on('select', function(cinemaSelect) {
       var moviesMenu = [];
       for(var i = 0; i < json.theater[cinemaSelect.itemIndex].movies.length; i++) {
       var name = decodeURIComponent(json.theater[cinemaSelect.itemIndex].movies[i].name);
         moviesMenu.push({
           title: name.replace("&amp;", "").replace("ccedil;", ""),
           subtitle: json.theater[cinemaSelect.itemIndex].movies[i].time.join(', ')
         });
       }
       var UIMovieList = new UI.Menu({
         sections: [{
           title: 'Movies',
           items: moviesMenu
         }]
       });
       UIMovieList.show();
       UIMovieList.on('select', function(movieSelect) {
         var time = '';
         var name = decodeURIComponent(json.theater[cinemaSelect.itemIndex].movies[movieSelect.itemIndex].name);
         for(var i = 0; i < json.theater[cinemaSelect.itemIndex].movies[movieSelect.itemIndex].time.length; i++) {
           time += json.theater[cinemaSelect.itemIndex].movies[movieSelect.itemIndex].time[i] + '\n';
         }
         var UIDetail = new UI.Card({
           title: name.replace("&amp;", "").replace("ccedil;", ""),
           body: time,
           scrollable: true
         });
         UIDetail.show();
       });
     }); 
   }
 },
Beispiel #29
0
 function(data)
 {
   console.log('data url ' + TPRU);
   // Show a card with clicked item details
   
   var teamPlayDetMenu = new UI.Menu();
   for (var i = 0; i < data.length; i++) {
     teamPlayDetMenu.item(0, i, { title: data[i].name, subtitle: "#" + data[i].number + " pos: " + data[i].position });
   }
   // no select action required.
   teamPlayDetMenu.show();
 });
Beispiel #30
0
/*
 * Loads trains passing through `station` into a menu.
 */
function load_trains(station)
{
	console.log('Showing trains through ' + station.Name + ':');
	
	var trains_list = new UI.Menu({ sections: [{ title: station.Name, items: [{ title: 'Loading...' }] }] });
	trains_list.show();
	
	new Ajax({
		url: wmata_trains_url + '/' + concat_station_codes(station) + '?api_key=' + wmata_api_key,
		type: 'json'
	}, function (data) {
		if (data.Trains.length > 0)
		{
			console.log(data.Trains.length + ' trains');
			var added = 0;
			for (var t in data.Trains)
			{
				console.log(data.Trains[t].Min + '\t' + data.Trains[t].Line + '\t' + data.Trains[t].DestinationName);
				if (data.Trains[t].DestinationName == 'No Passenger')
					continue;
				else if (data.Trains[t].DestinationName == 'Train')
					trains_list.item(0, added, { title: tr_time(data.Trains[t].Min), subtitle: 'Train' });
				else
					trains_list.item(0, added, { title: tr_time(data.Trains[t].Min), subtitle: 'to ' + data.Trains[t].DestinationName, icon: 'images/' + data.Trains[t].Line.toLowerCase() + '.png' });
				
				added ++;
			}
			trains_list.on('select', function (e) {
				trains_list.hide();
				load_trains(station);
			});
		}
		else
		{
			var card = new UI.Card({
				title: station.Name,
				body: 'No trains are currently scheduled to stop at this station.',
				scrollable: true
			});
			trains_list.hide();
			card.show();
		}
	}, function (error) {
		var card = new UI.Card({
			title: 'Error',
			body: error,
			scrollable: true
		});
		console.log('Error getting trains: ' + error);
		trains_list.hide();
		card.show();
	});
}