Skip to content

Commit

Permalink
fixed type detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kobar committed Aug 12, 2018
1 parent 624d59f commit 9a46451
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 83 deletions.
126 changes: 54 additions & 72 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])
};
$scope.items = [];
$scope.itemsUnique = [];
$scope.itemsAll = [];
//$scope.itemsAll = [];


//var obj = this.list;
Expand All @@ -123,10 +123,9 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])
$scope.submitEvent = function(){
var eDate = new Date();


alert("Success2: " + JSON.stringify(obj));

alert(obj);
//alert(obj);
//alert(obj.length);
//alert(obj[0].name);

Expand All @@ -143,15 +142,15 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])
temp.reporter = obj[i].reporter;
temp.uuid = $scope.deviceUUID;

$scope.itemsAll.push(temp);
$rootScope.itemsAll.push(temp);

$scope.items.push(temp);
}

//$scope.itemsUnique = removeDuplicates($scope.items, "id");
//saveAllDatatoFire();

saveDatatoFire();
//saveDatatoFire();

/***
setTimeout(function(){
Expand Down Expand Up @@ -194,7 +193,7 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])

if(!$scope.itemsUnique[i].name){
$scope.itemsUnique[i].name ='';
}saveDatatoFire
}

if(!$scope.itemsUnique[i].eDate){
$scope.itemsUnique[i].eDate = '';
Expand Down Expand Up @@ -367,11 +366,6 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])
'$scope', '$stateParams','$state','$ionicLoading',
function ($scope, $stateParams,$state,$ionicLoading) {

$scope.eventTitle="";
$scope.eventMessage="";
$scope.eventDate="";
$scope.eventTime="";

$scope.submitEvent = function(){
var success = function(message){
//alert("Success: " + JSON.stringify(message));
Expand Down Expand Up @@ -425,15 +419,52 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])

// show service list
.controller('servicelistCtrl', [
'$scope', '$stateParams','$state','$ionicLoading',
function ($scope, $stateParams,$state,$ionicLoading) {
'$scope', '$rootScope', '$stateParams','$state','$ionicLoading',
function ($scope, $rootScope, $stateParams,$state,$ionicLoading) {

$scope.eventTitle="";
$scope.eventMessage="";
$scope.eventDate="";
$scope.eventTime="";

$scope.list = function(){
$scope.list_esny = function(){
$rootScope.title = 'Emergency shelters near you';
$state.go('list');
}

$scope.list_efu = function(){
$rootScope.title = 'Emergency Food and Water near you';
$state.go('list');
}

$scope.list_gs = function(){
$rootScope.title = 'Open Gas Stations with fuel';
$state.go('list');
}

$scope.list_cs = function(){
$rootScope.title = 'Charging Stations';
$state.go('list');
}

$scope.list_ofs = function(){
$rootScope.title = 'Open Food Stores';
$state.go('list');
}

$scope.list_watm = function(){
$rootScope.title = 'Working ATMs';
$state.go('list');
}

$scope.getList = function(){
if ($stateParams.type != null) {
var type = $stateParams.type;
} else {
var type = 'other';
}

alert("type =",type);

//$state.go('displayPage');
$state.go('list');
Expand All @@ -451,70 +482,21 @@ angular.module('app.controllers', ['ionic', 'ngCordova'])

// show list
.controller('listCtrl', [
'$scope', '$stateParams','$state','$ionicLoading',
function ($scope, $stateParams,$state,$ionicLoading) {

$scope.eventTitle="";
$scope.eventMessage="";
$scope.eventDate="";
$scope.eventTime="";
'$scope', '$rootScope','$stateParams','$state','$ionicLoading',
function ($scope, $rootScope, $stateParams,$state,$ionicLoading) {

$scope.submitEvent = function(){
var success = function(message){
//alert("Success: " + JSON.stringify(message));
if ($rootScope.type != null) {
$scope.type = $rootScope.type;
}

//alert(message.length);
//alert(message[0].title);

for(var i =0; i < message.length; i++){

var temp = {};
temp.id = message[i].id;
temp.title = message[i].title;
temp.sDate = message[i].startDate;
temp.eDate = message[i].endDate;
temp.message = message[i].message;
temp.location = message[i].location;
temp.allday = message[i].allday;
}

setTimeout(function(){
if(isEmpty($scope.itemsUnique)){
//alert("No Event Found");
}
}, 500);

};
var error = function(message) {
alert("Error: " + message);
};

//var sDate = new Date();
var sDate = $scope.eventDate;
var sDate2 = new Date(sDate.getTime() + Date.parse($scope.eventTime));
//alert("eventTime: " + $scope.eventTime);
//alert("eventTime: " + Date.parse($scope.eventTime));
var sDate3 = new Date(sDate2.getTime() - (5*60*60*1000)); // -5 hours
//sDate.setFullYear(sDate.getFullYear() - 5); // start date is now - 5 years
//var eDate = new Date();
//eDate.setFullDay(sDate.getFullDay() + 1); // start date is now - 5 years
var eDate = new Date(sDate3.getTime() + 60*60*1000); // add an hour

// if (window.cordova && window.cordova.plugins) {
// window.plugins.calendar.createEvent(title,eventLocation,notes,startDate,endDate,success,error);
window.plugins.calendar.createEvent($scope.eventTitle,"",$scope.eventMessage,sDate3,eDate,success,error);
// }
$state.go('home');
$scope.gotoUrl = function(){
cordova.InAppBrowser.open(sponsorUrl, '_system', 'location=yes');
return false
}

}
$scope.backtoHome = function(){
$state.go('home');
}


function isEmpty(str) {
return (!str || 0 === str.length);
}

}])

2 changes: 1 addition & 1 deletion www/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ angular.module('app.routes', [])
})

.state('list', {
url: '/list',
url: '/list',
templateUrl: 'templates/list.html',
controller: 'listCtrl'
})
Expand Down
20 changes: 10 additions & 10 deletions www/templates/servicelist.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<ion-view title="Services Search" cache-view="false" hide-nav-bar="false" hide-back-button="false" id="page1">
<ion-content padding="true" class="has-header">
<div class="spacer" style="width: 300px; height: 46px;"></div>
<div class="spacer" style="width: 300px; height: 26px;"></div>
<header id="header">
<div class="container"> <!-- holder -->
<div class="logo2">
<a href="#">
<img src="img/1.png" width="80%" alt="essr">
<img src="img/header.png" width="110%" alt="essr">
</a><br/>
<a href="#" ng-click="gotoUrl();">
<img src="img/sponsor.png" width="80%" alt="essr">
<img src="img/sponsor.png" width="90%" alt="sponsor">
</a><br/>
</div>
</div>
</header>

<h2>Search For: </h2>
<a ui-sref="list()" id="button3" class="button icon-left ion-home button-assertive button-block">Emergency shelters near you</a>
<a ui-sref="list()" id="button3" class="button icon-left ion-fork button-assertive button-block">Emergency food and water near you</a>
<a ng-click="list()" id="button4" class="button icon-left ion-android-car button-positive button-block">Gas Stations with gas and power</a>
<a ui-sref="list()" id="button5" class="button icon-left ion-battery-charging button-positive button-block">Charging locations</a>
<a ui-sref="list()" id="button3" class="button icon-left ion-android-cart button-positive button-block">Open food stores</a>
<a ui-sref="list()" id="button3" class="button icon-left ion-card button-positive button-block">Working ATMs</a>
<a ui-sref="goSearch()" id="button3" class="button button-positive button-block">Other</a>
<button ng-click="list_esny();" id="button2" class="button icon-left ion-fork button-assertive button-block">Emergency Shelter near you</button>
<button ng-click="list_efu();" id="button3" class="button icon-left ion-fork button-assertive button-block">Emergency food and water near you</button>
<button ng-click="list_gs();" id="button4" class="button icon-left ion-android-car button-positive button-block">Gas Stations with gas and power</button>
<button ng-click="list_cs();" id="button5" class="button icon-left ion-battery-charging button-positive button-block">Charging locations</button>
<button ng-click="list_ofs();" id="button6" class="button icon-left ion-android-cart button-positive button-block">Open food stores</button>
<button ng-click="list_watm();" id="button7" class="button icon-left ion-card button-positive button-block">Working ATMs</button>
<a ui-sref="goSearch()" id="button8" class="button button-positive button-block">Other</a>
</ion-content>
</ion-view>

0 comments on commit 9a46451

Please sign in to comment.