Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let var be let #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.eslintrc.js
61 changes: 28 additions & 33 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,34 @@

/*jshint esversion: 6 */
// Import statements
const UI = require('ui');
const Vector2 = require('vector2');
const ajax = require('ajax');
const UI = require("ui");
const Vector2 = require("vector2");
const ajax = require("ajax");

var ID = [];
var LONG = '-75.6892807';
var LAT = '45.423664';
var Destinations = [];
var BusNumbers = [];
var Times = [];
let ID = [];
let LONG = '-75.6892807';
let LAT = '45.423664';
let Destinations = [];
let BusNumbers = [];
let Times = [];

function WRAP (){

for(var i = 0; i < BusNumbers.length; i++) {
var title = "#" + BusNumbers[i] + " in " +Times[i] + " mins";
//title = title.charAt(0).toUpperCase() + title.substring(1);
var subtitle = Destinations[i];
//subtitle = subtitle.charAt(0).toUpperCase() + subtitle.substring(1);
for(let i = 0; i < BusNumbers.length; i++) {
let title = "#" + BusNumbers[i] + " in " +Times[i] + " mins";
let subtitle = Destinations[i];
ID.push({
title:title,
subtitle:subtitle
});
}
ShowOptions();
showOptions();
}


var main = new UI.Window();
let main = new UI.Window();

var text = new UI.Text({
let text = new UI.Text({
position: new Vector2(0, 0),
size: new Vector2(144, 168),
text:'BusNow Loading Data! ...',
Expand All @@ -49,26 +47,23 @@ var text = new UI.Text({
main.add(text);
main.show();

//var LAT;
//var LONG;
//let LAT;
//let LONG;

loadBus(LAT,LONG);
var CustomURL;
function success(pos) {
//LAT = String(pos.coords.latitude);
//LONG = String(pos.coords.longitude);
let CustomURL;
LAT = String(pos.coords.latitude);
LONG = String(pos.coords.longitude);
CustomURL = "http://abdulwahaab.ca/octranspo/testing.php?lat=" + LAT + "&long=" + LONG;
/*console.log(LAT);
console.log(LONG);
console.log(CustomURL);*/
loadBus(LAT,LONG);

}
function error(err) {
if(err.code == err.PERMISSION_DENIED) {
console.log('Location access was denied by the user.');
var permission_denied = new UI.Window();
var error_msg = new UI.Text({
let permission_denied = new UI.Window();
let error_msg = new UI.Text({
position: new Vector2(0, 0),
size: new Vector2(144, 168),
text: 'Location access was denined by the user.',
Expand All @@ -86,22 +81,22 @@ function error(err) {
}
}

var options = {
let options = {
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 10000
};
navigator.geolocation.getCurrentPosition(success, error, options);
function loadBus(lat,long){
var CusURL = "http://abdulwahaab.ca/octranspo/testing.php?lat=" + lat + "&long=" + long;
let CusURL = "http://abdulwahaab.ca/octranspo/testing.php?lat=" + lat + "&long=" + long;
ajax(
{
url:CusURL,
type:'json'
},
function(Data){
var Routes = Data.GetRouteSummaryForStopResult.Routes;
for(var i = 0; i< Routes.Route.length;i++){
let Routes = Data.GetRouteSummaryForStopResult.Routes;
for(let i = 0; i< Routes.Route.length;i++){
if (Routes.Route[i].Trips.length === undefined || Routes.Route[i].Trips.length > 0){
BusNumbers.push(Routes.Route[i].RouteNo);
Destinations.push(Routes.Route[i].RouteHeading);
Expand All @@ -118,8 +113,8 @@ function loadBus(lat,long){
);
}

function ShowOptions(){
var menu = new UI.Menu({
function showOptions(){
let menu = new UI.Menu({
sections: [{
title: "Available Buses",
items:ID
Expand Down