Commit 76b54f1b authored by Bon Lemuel Dela Cruz's avatar Bon Lemuel Dela Cruz

- Weekly Survey Updates

- Blaze Map "Red" "Yellow" "Green"
- My Diary
parent a0fcfc32
<ion-view view-title="My Trip Diary" ng-init="loadComparisonMessages();">
<ion-nav-buttons side="right">
</ion-nav-buttons>
<ion-content padding="true">
<ion-refresher pulling-text="Pull to refresh" on-refresh="loadComparisonMessages(); clearGraphs();"></ion-refresher>
<div class="card">
<div class="item item-header item-clear bgbluegreen text-light"> Comparison Message </div>
<div class="item item-body">
<p>Some Interesting Facts:</p>
<p>"Your shortest travel time is {{comparisonMessage.best_time}} minutes."</p>
<p>"Your worst travel time is {{comparisonMessage.worst_time}} minutes."</p>
<p>"By comparison, {{comparisonMessage.zero_car_user}} who lives in the same area as you do achieved the shortest travel time of {{comparisonMessage.best_near_car_blazer}} minutes."</p>
</div>
</form>
</div>
<div class="card">
<div class="item item-header item-clear bgbluegreen text-light"> Home to School Travel Times </div>
<div class="item">
<form name="form_1">
<label class="item item-input">
<span class="input-label">Start Date:</span>
<input type="date" ng-model="request.start_date" required>
</label>
<label class="item item-input">
<span class="input-label">End Date:</span>
<input type="date" ng-model="request.end_date" required>
</label>
<button class="button button-block button-dark button-outline" ng-disabled="form_1.$invalid" ng-click="loadHometoSchoolTravel();"> Show </button>
</div>
<div class="item item-body">
<p>Range: {{request.start_date | date:'mediumDate'}} - {{request.end_date | date:'mediumDate'}}</p>
<canvas id="line" class="chart chart-line" chart-data="htsdata" chart-labels="htslabels" chart-options="options" chart-dataset-override="datasetOverride" chart-click="onClick"></canvas>
</div>
</form>
</div>
<div class="card">
<div class="item item-header item-clear bgbluegreen text-light"> Mode Use by Trips </div>
<div class="item item-body">
<form name="form_2">
<label class="item item-input">
<span class="input-label">Start Date:</span>
<input type="date" ng-model="requestMode.start_date" required>
</label>
<label class="item item-input">
<span class="input-label">End Date:</span>
<input type="date" ng-model="requestMode.end_date" required>
</label>
<button class="button button-block button-dark button-outline" ng-disabled="form_2.$invalid" ng-click="loadModeUseTravel();"> Show </button>
</div>
<div class="item item-body">
<p>Range: {{requestMode.start_date | date:'mediumDate'}} - {{requestMode.end_date | date:'mediumDate'}}</p>
<canvas id="pie" class="chart chart-pie" chart-data="hmadata" chart-labels="hmalabels"></canvas>
</div>
</div>
</ion-content>
</ion-view>
\ No newline at end of file
angular.module('blazer.diarycontrollers', [])
.controller('DiaryCtrl', function($scope, $filter, getBlazer, postBlazer) {
$scope.request = {};
$scope.travelData = {};
$scope.htslabels = {};
$scope.htsdata = {};
$scope.loadHometoSchoolTravel = function() {
$scope.htslabels = [];
$scope.htsdata = [];
var request = {
username: localStorage.getItem("username"),
start_date: $filter('date')($scope.request.start_date, 'yyyy-MM-dd'),
end_date: $filter('date')($scope.request.end_date, 'yyyy-MM-dd'),
}
postBlazer.HometoSchoolTravelTimes(request)
.success(function(response) {
console.log("HOME TO SCHOOL DATA", JSON.stringify(response));
$scope.travelData = response.travel_times;
$scope.htslabels = [];
$scope.htsdata = [];
for (var i = 0; i < $scope.travelData.length; i++) {
console.log("[ PARSED DATA ]", JSON.stringify($scope.travelData[i]));
var string_data = $scope.travelData[i].date;
$scope.htslabels.push([string_data.toString()]);
$scope.htsdata.push([$scope.travelData[i].time]);
}
console.log(JSON.stringify($scope.htslabels));
console.log(JSON.stringify($scope.htsdata));
})
.error(function(response) {
console.error("HOME TO SCHOOL ERROR", response);
});
}
$scope.requestMode = {};
$scope.hmadata = [];
$scope.hmalabels = [];
$scope.loadModeUseTravel = function() {
$scope.hmadata = [];
$scope.hmalabels = [];
var requestMode = {
username: localStorage.getItem("username"),
start_date: $filter('date')($scope.request.start_date, 'yyyy-MM-dd'),
end_date: $filter('date')($scope.request.end_date, 'yyyy-MM-dd'),
}
getBlazer.getHowYouMoveAround(requestMode.start_date, requestMode.end_date, requestMode.username).then(function(data) {
console.log("[ TRAVEL MODE ]", JSON.stringify(data));
if (!data) {
$ionicLoading.show({ template: "No data for this request", duration: 1000 });
} else {
angular.forEach(data, function(value, key) {
$scope.hmalabels.push([key]);
$scope.hmadata.push(value);
});
console.log($scope.hmalabels);
console.log($scope.hmadata);
}
});
}
$scope.comparisonMessage = {};
$scope.loadComparisonMessages = function() {
$scope.$broadcast('scroll.refreshComplete');
var requestMode = {
username: localStorage.getItem("username")
}
getBlazer.getComparisonMessage(requestMode.username).then(function(data) {
console.log("[ TRAVEL MODE ]", JSON.stringify(data));
$scope.comparisonMessage = {
best_time: data.fact_1.best_time,
worst_time: data.fact_1.worst_time,
best_time_near: data.fact_1.best_time_near,
total_car_usage: data.fact_2.total_car_usage,
best_near_car_usage: data.fact_2.best_near_car_usage,
best_near_car_blazer: data.fact_2.best_near_car_blazer,
zero_car_user: data.fact_2.zero_car_user
}
});
}
$scope.clearGraphs = function() {
$scope.$broadcast('scroll.refreshComplete');
$scope.requestMode = {};
$scope.hmadata = [];
$scope.hmalabels = [];
$scope.request = {};
$scope.travelData = {};
$scope.htslabels = {};
$scope.htsdata = {};
}
});
\ No newline at end of file
...@@ -2,574 +2,614 @@ angular.module('blazer.mapcontrollers', []) ...@@ -2,574 +2,614 @@ angular.module('blazer.mapcontrollers', [])
.controller('MapCtrl', function($scope, $cordovaGeolocation, $cordovaDialogs, $stateParams, $ionicModal, $ionicPopup, $ionicLoading, $interval, $filter, $ionicPopover, getBlazer, postBlazer, $ionicSideMenuDelegate, $ionicHistory, $cordovaNetwork) { .controller('MapCtrl', function($scope, $cordovaGeolocation, $cordovaDialogs, $stateParams, $ionicModal, $ionicPopup, $ionicLoading, $interval, $filter, $ionicPopover, getBlazer, postBlazer, $ionicSideMenuDelegate, $ionicHistory, $cordovaNetwork) {
// CLEAR HISTORY // CLEAR HISTORY
$ionicHistory.clearHistory(); $ionicHistory.clearHistory();
/* SIDE MENU TRIGGER */ /* SIDE MENU TRIGGER */
$ionicSideMenuDelegate.canDragContent(false); // SET SIDE MENU DRAG FALSE $ionicSideMenuDelegate.canDragContent(false); // SET SIDE MENU DRAG FALSE
$scope.openMenu = function(){ $scope.openMenu = function() {
$ionicSideMenuDelegate.toggleLeft(); $ionicSideMenuDelegate.toggleLeft();
} }
/* MAP DEFAULTS */ /* MAP DEFAULTS */
var map = L.map('mapid'); // var map = new L.map('mapid', { center: new L.LatLng(14.5818, 120.9771), zoom: 12 });
map.setView(new L.LatLng(14.5818, 120.9771), 12); // var googleLayer = new L.Google('ROADMAP');
//MAP BOX // map.addLayer(googleLayer);
//GOOGLE MAP
L.tileLayer(maplayer, {
maxZoom: 18, var map = L.map('mapid');
minZoom: 9, map.setView(new L.LatLng(14.5818, 120.9771), 12);
attribution: '© OpenStreetMap contributors' //LEAFLET
}).addTo(map);
L.tileLayer(maplayer, {
/* MAP COMPONENTS */ maxZoom: 18,
var markers, circles, line; minZoom: 9,
$scope.drawMarkers = function(lat, lon, message){ attribution: '© OpenStreetMap contributors'
markers = new L.marker([lat, lon]).addTo(map); }).addTo(map);
markers.bindPopup(message).openPopup();
} /* MAP COMPONENTS */
var markers, circles, line;
/* Draw Trip Marker */ $scope.drawMarkers = function(lat, lon, message) {
$scope.drawTripMarkers = function(lat, lon){ markers = new L.marker([lat, lon]).addTo(map);
markers = new L.marker([lat, lon]).addTo(map); markers.bindPopup(message).openPopup();
markers.bindPopup('On Trip').openPopup(); }
}
/* Draw Trip Marker */
/* Draw Radius */ $scope.drawTripMarkers = function(lat, lon) {
$scope.drawCircle = function(lat, lon){ markers = new L.marker([lat, lon]).addTo(map);
circle = L.circle([lat, lon], 500, { markers.bindPopup('On Trip').openPopup();
color: '', }
fillColor: '#165c5b',
fillOpacity: 0.3 /* Draw Radius */
}).addTo(map); $scope.drawCircle = function(lat, lon) {
} circle = L.circle([lat, lon], 500, {
color: '',
var coordinates = []; // FOR DRAWN LINES fillColor: '#165c5b',
var logCoordinates = []; // FOR LOGGING TRIP fillOpacity: 0.3
var setLatLng; }).addTo(map);
var coords; }
$scope.drawLineTrack = function(lat, lon){
var polylineOptions = { var coordinates = []; // FOR DRAWN LINES
color: '#185c82', var logCoordinates = []; // FOR LOGGING TRIP
weight: 6, var setLatLng;
opacity: 0.9 var coords;
}; $scope.drawLineTrack = function(lat, lon) {
var polylineOptions = {
setLatLng = new L.LatLng(lat, lon); // USING LEAFLET LATLNG color: '#185c82',
coords = { lat, lon }; // USING SELF LATLNG weight: 6,
opacity: 0.9
coordinates.push(coords); };
console.log(coordinates);
line = new L.polyline(coordinates, polylineOptions); setLatLng = new L.LatLng(lat, lon); // USING LEAFLET LATLNG
// line.addTo(map); coords = { lat, lon }; // USING SELF LATLNG
map.addLayer(line);
// map.fitBounds(line.getBounds()); // zoom the map to the polyline coordinates.push(coords);
console.log(coordinates);
// REMOVE MARKERS line = new L.polyline(coordinates, polylineOptions);
map.removeLayer(markers); // line.addTo(map);
map.addLayer(line);
$scope.drawMarkers(lat, lon, 'On Trip'); // DRAW TRIP MARKER ] // map.fitBounds(line.getBounds()); // zoom the map to the polyline
}
// REMOVE MARKERS
/* EVENT LISTENERS */ map.removeLayer(markers);
$scope.mapButton = true;
function onMapDrag(e) { $scope.drawMarkers(lat, lon, 'On Trip'); // DRAW TRIP MARKER ]
$scope.mapButton = false; }
console.log("Map Drag ", $scope.mapButton);
} /* EVENT LISTENERS */
function onMapDragEnd(e) { $scope.mapButton = true;
$scope.mapButton = true;
console.log("Map Drag ", $scope.mapButton); function onMapDrag(e) {
} $scope.mapButton = false;
map.on('move', onMapDrag); // FIRE MAPDRAG console.log("Map Drag ", $scope.mapButton);
map.on('moveend', onMapDragEnd); // FIRE MAPDRAG END }
$scope.clearPolylines = function(){ function onMapDragEnd(e) {
console.debug("********** Clear Polylines **********"); $scope.mapButton = true;
for(var i = 0; i < coordinates.length; i ++){ console.log("Map Drag ", $scope.mapButton);
map.removeLayer(line._latlngs[i]); }
console.error("[ CHECK LOOP ]", i +" "+coordinates.length); map.on('move', onMapDrag); // FIRE MAPDRAG
console.log("[ DELETE LINES ]", line._latlngs[i]); map.on('moveend', onMapDragEnd); // FIRE MAPDRAG END
// coordinates.splice(i, 1); // REMOVE AN ITEM ON AN ARRAY
} $scope.clearPolylines = function() {
} console.debug("********** Clear Polylines **********");
for (var i = 0; i < coordinates.length; i++) {
/* LOAD USER ON MAP WITH RADIUS */ map.removeLayer(line._latlngs[i]);
var userLocated = false; console.error("[ CHECK LOOP ]", i + " " + coordinates.length);
$scope.initializedLocateUser = function(){ console.log("[ DELETE LINES ]", line._latlngs[i]);
console.debug("********** Initialized Location **********"); // coordinates.splice(i, 1); // REMOVE AN ITEM ON AN ARRAY
var posOptions = {enableHighAccuracy: true}; }
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) { }
map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15); // SET MAP VIEW
if(userLocated == false){ /* LOAD USER ON MAP WITH RADIUS */
$scope.drawMarkers(position.coords.latitude, position.coords.longitude, 'Your current location'); // DRAW MARKERS var userLocated = false;
$scope.drawCircle(position.coords.latitude, position.coords.longitude); // DRAW CIRCLE RADIUS $scope.initializedLocateUser = function() {
userLocated = true; console.debug("********** Initialized Location **********");
} var posOptions = { enableHighAccuracy: true };
else { $cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) {
console.log("USER ALREADY LOCATED"); map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15); // SET MAP VIEW
userLocated = true; if (userLocated == false) {
} $scope.drawMarkers(position.coords.latitude, position.coords.longitude, 'Your current location'); // DRAW MARKERS
}, function(error) { $scope.drawCircle(position.coords.latitude, position.coords.longitude); // DRAW CIRCLE RADIUS
console.log("LOCATING ERROR ", error); userLocated = true;
}); } else {
} console.log("USER ALREADY LOCATED");
userLocated = true;
/* Calculate Distance between points */ }
$scope.getDistanceFromLatLonInKm = function(lat1,lon1,lat2,lon2) { }, function(error) {
var R = 6371; // Radius of the earth in km console.log("LOCATING ERROR ", error);
var dLat = deg2rad(lat2-lat1); // deg2rad function });
var dLon = deg2rad(lon2-lon1); }
var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); /* Calculate Distance between points */
var d = R * c; // Distance in km $scope.getDistanceFromLatLonInKm = function(lat1, lon1, lat2, lon2) {
console.log("[ DISTANCE BETWEEN COORDINDATES ]", d); var R = 6371; // Radius of the earth in km
return d; var dLat = deg2rad(lat2 - lat1); // deg2rad function
} var dLon = deg2rad(lon2 - lon1);
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
function deg2rad(deg) { var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return deg * (Math.PI/180) var d = R * c; // Distance in km
} console.log("[ DISTANCE BETWEEN COORDINDATES ]", d);
return d;
/* MAIN ALGORITHM */ }
var tripStatusRef = false;
$scope.getUserLocation = function(){ function deg2rad(deg) {
console.debug("********** Trip Location **********"); return deg * (Math.PI / 180)
var posOptions = {enableHighAccuracy: true}; }
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
console.log("[ CURRENT LOCATION ]", position.coords); /* MAIN ALGORITHM */
if(!tripStatusRef){ var tripStatusRef = false;
$scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // INITIAL LINE ON TRIP $scope.getUserLocation = function() {
tripStatusRef = true; console.debug("********** Trip Location **********");
} var posOptions = { enableHighAccuracy: true };
$cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) {
// Filter Coordinates Distance Method console.log("[ CURRENT LOCATION ]", position.coords);
var locationData = { if (!tripStatusRef) {
lat: position.coords.latitude, $scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // INITIAL LINE ON TRIP
lng: position.coords.longitude tripStatusRef = true;
} }
if(logCoordinates.length > 0) // CHECK IF ARAY IS EMPTY // Filter Coordinates Distance Method
{ var locationData = {
if($scope.getDistanceFromLatLonInKm(locationData.lat, locationData.lng, logCoordinates[0].lat, logCoordinates[0].lng) > 0.03) lat: position.coords.latitude,
{ lng: position.coords.longitude
logCoordinates.splice(0, 0, locationData); }
console.log("[ LOCATION ARRAY ]", logCoordinates);
$scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // DRAW LINE ON TRIP if (logCoordinates.length > 0) // CHECK IF ARAY IS EMPTY
} {
else if ($scope.getDistanceFromLatLonInKm(locationData.lat, locationData.lng, logCoordinates[0].lat, logCoordinates[0].lng) > 0.03) {
{ logCoordinates.splice(0, 0, locationData);
console.error("[ You need to be 500 meters away from your current position ]", logCoordinates); console.log("[ LOCATION ARRAY ]", logCoordinates);
} $scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // DRAW LINE ON TRIP
} } else {
else console.error("[ You need to be 500 meters away from your current position ]", logCoordinates);
{ }
logCoordinates.splice(0, 0, locationData); } else {
console.log("[ INITIAL LOCATION ARRAY ]", logCoordinates); logCoordinates.splice(0, 0, locationData);
} console.log("[ INITIAL LOCATION ARRAY ]", logCoordinates);
}
}, function(error) {
console.error("GENERAL LOCATION ERROR ", error); }, function(error) {
}); console.error("GENERAL LOCATION ERROR ", error);
} });
}
$scope.refreshMap = function(){
console.debug("********** Refresh Map **********"); $scope.refreshMap = function() {
if(userLocated == true){ console.debug("********** Refresh Map **********");
map.removeLayer(markers); if (userLocated == true) {
map.removeLayer(circle); map.removeLayer(markers);
map.removeLayer(geojsonLayer); map.removeLayer(circle);
// map.removeLayer(line); map.removeLayer(geojsonLayer);
console.log("Map refreshed. Layers Removed"); // map.removeLayer(line);
userLocated = false; console.log("Map refreshed. Layers Removed");
} userLocated = false;
$scope.initializedLocateUser(); }
$scope.clearPolylines(); $scope.initializedLocateUser();
} $scope.clearPolylines();
}
/* CONFIRM TRIP DESTINATION */
$scope.confirmTripDestination = function(){ /* CONFIRM TRIP DESTINATION */
var tripPopup = $ionicPopup.show({ $scope.confirmTripDestination = function() {
title: 'Trip Destination', var tripPopup = $ionicPopup.show({
subTitle: 'Select your destination', title: 'Trip Destination',
scope: $scope, subTitle: 'Select your destination',
buttons: [ scope: $scope,
{ buttons: [{
text: 'School', text: 'School',
type: 'button-dark button-outline', type: 'button-dark button-outline',
onTap: function() { onTap: function() {
localStorage.setItem("currentTrip", 'trip2'); localStorage.setItem("currentTrip", 'trip2');
$scope.tripStart(); $scope.tripStart();
console.log('Destination to School'); console.log('Destination to School');
} }
}, },
{ {
text: 'Home', text: 'Home',
type: 'button-dark button-outline', type: 'button-dark button-outline',
onTap: function() { onTap: function() {
localStorage.setItem("currentTrip", 'trip1'); localStorage.setItem("currentTrip", 'trip1');
$scope.tripStart(); $scope.tripStart();
console.log('Destination to Home'); console.log('Destination to Home');
} }
} }
] ]
}); });
} }
/* SET SEARCH BARANGAY */ /* SET SEARCH BARANGAY */
$scope.BarangayList = {}; $scope.BarangayList = {};
$scope.getAllBarangay = function(){ $scope.getAllBarangay = function() {
console.debug("******* GET ALL BARANGAY ******"); console.debug("******* GET ALL BARANGAY ******");
getBlazer.getAllBarangay().then(function(data){ getBlazer.getAllBarangay().then(function(data) {
$scope.BarangayList = data; $scope.BarangayList = data;
console.log("[ Barangay Data ]", JSON.stringify($scope.BarangayList)); console.log("[ Barangay Data ]", JSON.stringify($scope.BarangayList));
}); });
} }
$scope.selectedBarangayData = ''; $scope.selectedBarangayData = '';
$scope.currentBarangay = ''; $scope.currentBarangay = '';
$scope.currentBarangayTime = ''; $scope.currentBarangayTime = '';
$scope.onLoadSelection = function(){ $scope.onLoadSelection = function() {
$scope.data = {}; $scope.data = {};
// An elaborate, custom popup // An elaborate, custom popup
var myPopup = $ionicPopup.show({ var myPopup = $ionicPopup.show({
template: '<label class="input-label">Barangay</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangay"><option ng-repeat = "barangay in BarangayList" value="{{barangay.name}}">{{barangay.name}}</option></select></label><label class="input-label">Time</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangayTime"><option value="AM">AM Trips</option><option value="PM">PM Trips</option></select></label>', template: '<label class="input-label">Barangay</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangay"><option ng-repeat = "barangay in BarangayList" value="{{barangay.name}}">{{barangay.name}}</option></select></label><label class="input-label">Time</label><label class="item item-input item-select"><div class="input-label"></div><select ng-model="data.selectedBarangayTime"><option value="AM">AM Trips</option><option value="PM">PM Trips</option></select></label>',
title: 'Select your Barangay', title: 'Select your Barangay',
subTitle: 'To view the most COMMON MODE of transportation in your barangay.', subTitle: 'To view the most COMMON MODE of transportation in your barangay.',
scope: $scope, scope: $scope,
buttons: [ buttons: [{
{ text: 'Select',
text: 'Select', type: 'button-dark button-outline',
type: 'button-dark button-outline', onTap: function(e) {
onTap: function(e) { console.log("[ SELECT DATA ]", $scope.data.selectedBarangay + " " + $scope.data.selectedBarangayTime);
console.log("[ SELECT DATA ]", $scope.data.selectedBarangay +" "+ $scope.data.selectedBarangayTime); // LOAD MAP FUNCTIONS
// LOAD MAP FUNCTIONS $scope.selectedBarangayData = $scope.data.selectedBarangay + " " + $scope.data.selectedBarangayTime;
$scope.selectedBarangayData = $scope.data.selectedBarangay +" "+ $scope.data.selectedBarangayTime; $scope.currentBarangay = $scope.data.selectedBarangay;
$scope.currentBarangay = $scope.data.selectedBarangay; $scope.currentBarangayTime = $scope.data.selectedBarangayTime;
$scope.currentBarangayTime = $scope.data.selectedBarangayTime; $scope.data = {};
$scope.data = {}; }
} },
}, {
{ text: 'Cancel',
text: 'Cancel', type: 'button-dark button-outline',
type: 'button-dark button-outline', onTap: function(e) {
onTap: function(e) { console.log("[ LOAD BARANGAY CANCELLED ]")
console.log("[ LOAD BARANGAY CANCELLED ]") }
} }
} ]
] });
}); }
}
/* CHART JS DATA */
/* CHART JS DATA */ $scope.BarangayData = {};
$scope.BarangayData = {}; $scope.loadBarangayData = function() {
$scope.loadBarangayData = function(){ console.debug("********** Get Barangay Data **********");
console.debug("********** Get Barangay Data **********"); var barangayinfo = {
var barangayinfo = { "barangay": $scope.currentBarangay,
"barangay": $scope.currentBarangay, "time": $scope.currentBarangayTime
"time": $scope.currentBarangayTime };
}; postBlazer.BarangayInformation(barangayinfo)
postBlazer.BarangayInformation(barangayinfo) .success(function(response) {
.success(function(response) { console.log(" BARANGAY SUCCESS", response);
console.log(" BARANGAY SUCCESS", response); $scope.BarangayData = response;
$scope.BarangayData = response; console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData));
console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData)); $scope.openChart($scope.BarangayData); // LOAD CHART MODAL
$scope.openChart($scope.BarangayData); // LOAD CHART MODAL $scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay);
$scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay); // RESET VALUES
// RESET VALUES $scope.selectedBarangayData = '';
$scope.selectedBarangayData = ''; $scope.currentBarangay = '';
$scope.currentBarangay = ''; $scope.currentBarangayTime = '';
$scope.currentBarangayTime = ''; })
}) .error(function(response) {
.error(function(response) { console.error("BARANGAY ERROR", response);
console.error("BARANGAY ERROR", response); });
}); }
}
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.data = [ $scope.data = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]; ];
$scope.value = ''; $scope.value = '';
$scope.loadValue = function(val){ $scope.loadValue = function(val) {
$scope.value = val; $scope.value = val;
} }
$ionicModal.fromTemplateUrl('app/map/modal/graph.html', { $ionicModal.fromTemplateUrl('app/map/modal/graph.html', {
scope: $scope, scope: $scope,
animation: 'slide-in-up' animation: 'slide-in-up'
}).then(function(modal) { }).then(function(modal) {
$scope.modalChart = modal; $scope.modalChart = modal;
}); });
/* MODAL LISTENER */ /* MODAL LISTENER */
$scope.$on('modal.hidden', function() { $scope.$on('modal.hidden', function() {
console.log("Modal is Hidden"); console.log("Modal is Hidden");
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"]; $scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.data = [ $scope.data = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]; ];
}); });
$scope.openChart = function(data) { $scope.openChart = function(data) {
$scope.modalChart.show(); $scope.modalChart.show();
console.log("[ CHART DATA ]", data); console.log("[ CHART DATA ]", data);
$scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"]; $scope.labels = ["Car", "Tricycle", "Pedicab", "Jeep", "Bus", "Van", "Walk", "Carpool", "Bicycle", "Train", "Taxi"];
$scope.data = [ $scope.data = [
[data.car, data.tricycle, data.pedicab, data.jeep, data.bus, data.van, data.walk, data.carpool, data.bicycle, data.train, data.taxi] [data.car, data.tricycle, data.pedicab, data.jeep, data.bus, data.van, data.walk, data.carpool, data.bicycle, data.train, data.taxi]
]; ];
}; };
$scope.closeChart = function() { $scope.closeChart = function() {
$scope.modalChart.hide(); $scope.modalChart.hide();
}; };
/* START TRIP */ /* START TRIP */
$scope.tripStatus = false; $scope.tripStatus = false;
var startTime, endTime; var startTime, endTime;
var intervalTrigger; var intervalTrigger;
userLocated = false; userLocated = false;
$scope.tripStart = function(){ $scope.tripStart = function() {
map.removeLayer(markers); map.removeLayer(markers);
map.removeLayer(circle); map.removeLayer(circle);
map.removeLayer(geojsonLayer); map.removeLayer(geojsonLayer);
$scope.tripStatus = true; $scope.tripStatus = true;
var newDate = new Date(); var newDate = new Date();
startTime = newDate.getTime(); startTime = newDate.getTime();
localStorage.setItem("starttime", startTime); localStorage.setItem("starttime", startTime);
console.log("START TRIP TIME", startTime); console.log("START TRIP TIME", startTime);
$scope.getUserLocation(); $scope.getUserLocation();
intervalTrigger = $interval($scope.getUserLocation, 1000); // START FUNCTION CALL 'LOOP'' intervalTrigger = $interval($scope.getUserLocation, 1000); // START FUNCTION CALL 'LOOP''
} }
/* END TRIP */ /* END TRIP */
$scope.tripEnd = function(){ $scope.tripEnd = function() {
/* CHECK IF MOBILE IS ONLINE */ /* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork()); console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){ if ($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G || $cordovaNetwork.getNetwork() == Connection.CELL_4G) {
$scope.tripStatus = false; $scope.tripStatus = false;
tripStatusRef = false; tripStatusRef = false;
var newDate = new Date(); var newDate = new Date();
var endTime = newDate.getTime(); var endTime = newDate.getTime();
localStorage.setItem("endtime", endTime); localStorage.setItem("endtime", endTime);
console.log("END TRIP TIME", endTime); console.log("END TRIP TIME", endTime);
// TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG // TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG
$scope.clearPolylines(); $scope.clearPolylines();
map.removeLayer(line); // REMOVE LINE TRACK map.removeLayer(line); // REMOVE LINE TRACK
parsedData = []; // CLEAR BLAZER MARKER ARRAY parsedData = []; // CLEAR BLAZER MARKER ARRAY
$interval.cancel(intervalTrigger); // CANCEL FUNCTION CALL $interval.cancel(intervalTrigger); // CANCEL FUNCTION CALL
$scope.sendTrackingLocation(); // SEND LOCATION DATA $scope.sendTrackingLocation(); // SEND LOCATION DATA
$scope.openEndTripSurvey(); // OPEN END TRIP SURVEY $scope.openEndTripSurvey(); // OPEN END TRIP SURVEY
} } else {
else { $cordovaDialogs.alert('You need to be ONLINE before ending this trip. Thank you.', 'Ooops', "OKAY");
$cordovaDialogs.alert('You need to be ONLINE before ending this trip. Thank you.', 'Ooops', "OKAY"); }
} }
}
/* SEND LOCATION DATA */
/* SEND LOCATION DATA */ $scope.sendTrackingLocation = function() {
$scope.sendTrackingLocation = function(){ var username = localStorage.getItem("username");
var username = localStorage.getItem("username"); console.debug("********** Send Tracking Location **********");
console.debug("********** Send Tracking Location **********"); postBlazer.LogTrip(logCoordinates, username)
postBlazer.LogTrip(logCoordinates, username) .success(function(response) {
.success(function(response) { console.log("LOG TRIP SUCCESS", response);
console.log("LOG TRIP SUCCESS", response); coordinates = [];
coordinates = []; logCoordinates = [];
logCoordinates = []; })
}) .error(function(response) {
.error(function(response) { console.error("LOG TRIP ERROR", response);
console.error("LOG TRIP ERROR", response); });
}); }
}
/* LOAD HEATMAP */
/* LOAD HEATMAP */ $scope.loadHeatMap = function() {
$scope.loadHeatMap = function(){ console.debug("********** Load Heat Map **********");
console.debug("********** Load Heat Map **********"); }
}
/* Show Blazers Data */
/* Show Blazers Data */ $scope.blazersData = {};
$scope.blazersData = {}; $scope.getBlazersDataV2 = function() {
$scope.getBlazersData = function(){ getBlazer.getMapData().then(function(data) {
getBlazer.getBlazerDataInfo().then(function(data){ $scope.blazersData = data;
$scope.blazersData = data; console.log("[ Blazer Data V2 ]", JSON.stringify($scope.blazersData));
console.log("[ Blazer Data ]", JSON.stringify($scope.blazersData)); $scope.plotBlazers();
$scope.plotBlazers(); });
}); }
}
/* Show Blazers Data */
/* Plot Blazers Data on Map */ $scope.blazersData = {};
var parsedData = []; $scope.getBlazersData = function() {
var geojsonLayer = []; getBlazer.getBlazerDataInfo().then(function(data) {
$scope.plotBlazers = function(){ $scope.blazersData = data;
console.log("[ Blazer Data ]", JSON.stringify($scope.blazersData));
console.debug("********** Plot Blazers on Map **********"); $scope.plotBlazers();
});
parsedData = []; }
angular.forEach($scope.blazersData, function(value, key) {
console.log("[ VALUE SCOPE ]", JSON.stringify(value)); /* Plot Blazers Data on Map */
var formatData = { var parsedData = [];
"type": "Feature", var geojsonLayer = [];
"properties": { $scope.plotBlazers = function() {
"username": "Anonymous Blazer", console.debug("********** Plot Blazers on Map **********");
}, parsedData = [];
"geometry": { angular.forEach($scope.blazersData, function(value, key) {
"type": "Point", console.log("[ VALUE SCOPE ]", JSON.stringify(value));
"coordinates": [value.longitude, value.latitude] var formatData = {
} "type": "Feature",
} "properties": {
parsedData.push(formatData); "barangay_name": value.barangay_name,
}); "blazer_count": value.blazer_count,
"car_percentage": value.car_percentage,
// Map Icon Options },
"geometry": {
// ICON "type": "Point",
// var iconOptions = L.icon({ "coordinates": [value.lon, value.lat]
// iconUrl: 'img/mapicon.png', }
// iconSize: [35, 37], }
// iconAnchor: [18, 2] parsedData.push(formatData);
// }); });
// POINTS
var iconOptions = {
radius: 8, // PLOT DATA
fillColor: "green", function onEachFeature(feature, layer) {
color: "green", if (feature.properties && feature.properties.barangay_name) {
weight: 1, layer.bindPopup('<div class="pop-up-containter">' + feature.properties.barangay_name + '</div>');
opacity: 1, }
fillOpacity: 0.8 }
}; /*
The colors refer to the car percentage. If car percentage is above 50%, the color is shades of red (the redder, the closer to 100% car percentage). Yellow is 50%. Below 50%, then shades of green. Very green means 0% car use.
// PLOT DATA */
function onEachFeature(feature, layer)
{ /*
if (feature.properties && feature.properties.username) The size refers to the blazer count. If blaze count <= 20, then, small. If blazer count is more than or equal to 50, then size is big. Medium is between 20 and 50.
{ */
layer.bindPopup('<div class="pop-up-containter">Blazer</h4><div style="font-size: 15px">'+feature.properties.username+'</div></div>'); geojsonLayer = L.geoJson(parsedData, {
} onEachFeature: onEachFeature,
} pointToLayer: function(feature, latlng) {
geojsonLayer = L.geoJson(parsedData, { var circle_radius = '';
onEachFeature: onEachFeature, var circle_fill = '';
pointToLayer: function (feature, latlng) { var circle_opacity = '';
return L.circleMarker(latlng, iconOptions);
} // RADIUS SETTER
}).addTo(map); if (parseInt(feature.properties.blazer_count) >= 50) {
map.fitBounds(geojsonLayer.getBounds()); console.log("BIG");
} circle_radius = 500;
} else if (parseInt(feature.properties.blazer_count) < 50 && parseInt(feature.properties.blazer_count) > 20) {
/* Weekly Survey Call */ console.log("MEDIUM");
$scope.loadWeeklySurvey = function(){ circle_radius = 250;
console.debug("********** Open Weekly Survey **********"); } else if (parseInt(feature.properties.blazer_count) <= 20) {
var newDate = new Date(); console.log("SMALL");
var currentDate = $filter('date')(newDate, 'yyyyMMww'); circle_radius = 100;
var dayToday = $filter('date')(newDate, 'EEEE'); }
console.log("[ Date Today ]" , currentDate);
// COLOR SETTER
if(dayToday == 'Friday' || dayToday == 'Saturday'){ if (feature.properties.car_percentage > 80) {
if(localStorage.getItem(currentDate) === null){ console.log("RED");
var tripPopup = $ionicPopup.show({ circle_fill = "red";
title: 'Hey it\'s '+dayToday+'!', circle_opacity = 0.8;
subTitle: 'Take the weekly survey. You are awesome!', } else if (feature.properties.car_percentage > 50 && feature.properties.car_percentage <= 80) {
scope: $scope, console.log("LIGHT RED");
buttons: [ circle_fill = "red";
{ circle_opacity = 0.3;
text: 'Let\s go!', } else if (feature.properties.car_percentage <= 50 && feature.properties.car_percentage >= 30) {
type: 'button-dark button-outline', console.log("YELLOW");
onTap: function(e) { circle_fill = "yellow";
console.log("[ TAKE WEEKLY SURVEY ]"); circle_opacity = 0.8;
$scope.openWeeklySurvey(); } else if (feature.properties.car_percentage < 30 && feature.properties.car_percentage >= 20) {
} console.log("LIGHT YELLOW");
}, circle_fill = "yellow";
{ circle_opacity = 0.3;
text: 'Later', } else if (feature.properties.car_percentage < 20) {
type: 'button-dark button-outline', circle_fill = "green";
onTap: function(e) { circle_opacity = 0.8;
console.log("[ NO WEEKLY SURVEY ]") }
} // return L.circleMarker(latlng, iconOptions);
} return L.circle(latlng, circle_radius, {
] color: '',
}); fillColor: circle_fill,
} fillOpacity: circle_opacity,
} })
} }
}).addTo(map);
$scope.triggerWeeklySurvey = function(){ map.fitBounds(geojsonLayer.getBounds());
console.debug("********** Trigger Weekly Survey **********"); }
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww'); /* Weekly Survey Call */
var dayToday = $filter('date')(newDate, 'EEEE'); $scope.loadWeeklySurvey = function() {
console.log("[ Date Today ]" , currentDate); console.debug("********** Open Weekly Survey **********");
var newDate = new Date();
if(localStorage.getItem(currentDate) === null){ var currentDate = $filter('date')(newDate, 'yyyyMMww');
var tripPopup = $ionicPopup.show({ var dayToday = $filter('date')(newDate, 'EEEE');
title: 'Hey it\'s '+dayToday+'!', console.log("[ Date Today ]", currentDate);
subTitle: 'Take the weekly survey. You are awesome!',
scope: $scope, if (dayToday == 'Friday' || dayToday == 'Saturday' || dayToday == 'Sunday') {
buttons: [ if (localStorage.getItem(currentDate) === null) {
{ var tripPopup = $ionicPopup.show({
text: 'Let\s go!', title: 'Hey it\'s ' + dayToday + '!',
type: 'button-dark button-outline', subTitle: 'Take the weekly survey. You are awesome!',
onTap: function(e) { scope: $scope,
console.log("[ TAKE WEEKLY SURVEY ]"); buttons: [{
$scope.openWeeklySurvey(); text: 'Let\s go!',
} type: 'button-dark button-outline',
}, onTap: function(e) {
{ console.log("[ TAKE WEEKLY SURVEY ]");
text: 'Later', $scope.openWeeklySurvey();
type: 'button-dark button-outline', }
onTap: function(e) { },
console.log("[ NO WEEKLY SURVEY ]") {
} text: 'Later',
} type: 'button-dark button-outline',
] onTap: function(e) {
}); console.log("[ NO WEEKLY SURVEY ]")
} }
else { }
$cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY"); ]
} });
} }
}
/* Popover Methods */ }
$ionicPopover.fromTemplateUrl('app/map/popover/map-popover.html', {
scope: $scope $scope.triggerWeeklySurvey = function() {
}).then(function(popover) { console.debug("********** Trigger Weekly Survey **********");
$scope.popover = popover; var newDate = new Date();
}); var currentDate = $filter('date')(newDate, 'yyyyMMww');
$scope.openPopover = function($event) { var dayToday = $filter('date')(newDate, 'EEEE');
$scope.popover.show($event); console.log("[ Date Today ]", currentDate);
console.log("OPEN POPOVER");
}; if (dayToday == 'Friday' || dayToday == 'Saturday' || dayToday == 'Sunday') {
$scope.closePopover = function() { if (localStorage.getItem(currentDate) === null) {
$scope.popover.hide(); var tripPopup = $ionicPopup.show({
}; title: 'Hey it\'s ' + dayToday + '!',
$scope.$on('$destroy', function() { subTitle: 'Take the weekly survey. You are awesome!',
$scope.popover.remove(); scope: $scope,
}); buttons: [{
// EndTrip Modal text: 'Let\s go!',
$ionicModal.fromTemplateUrl('app/survey/endtrip.html', { type: 'button-dark button-outline',
scope: $scope, onTap: function(e) {
animation: 'slide-in-up' console.log("[ TAKE WEEKLY SURVEY ]");
}).then(function(modal) { $scope.openWeeklySurvey();
$scope.modalEndTrip = modal; }
}); },
$scope.openEndTripSurvey = function() { {
$scope.modalEndTrip.show(); text: 'Later',
}; type: 'button-dark button-outline',
// Weekly Survey Modal onTap: function(e) {
$ionicModal.fromTemplateUrl('app/survey/weekly.html', { console.log("[ NO WEEKLY SURVEY ]")
scope: $scope, }
animation: 'slide-in-up' }
}).then(function(modal) { ]
$scope.modalWeeklyTrip = modal; });
}); } else {
$scope.openWeeklySurvey = function() { $cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY");
$scope.modalWeeklyTrip.show(); }
}; } else {
console.log("Cannot Take Survey Today");
$cordovaDialogs.alert('Sorry. But you may only take the weekly survey on Friday, Saturday, or Sunday. Thank you.', 'Weekly Survey', "OKAY");
}
}
/* Popover Methods */
$ionicPopover.fromTemplateUrl('app/map/popover/map-popover.html', {
scope: $scope
}).then(function(popover) {
$scope.popover = popover;
});
$scope.openPopover = function($event) {
$scope.popover.show($event);
console.log("OPEN POPOVER");
};
$scope.closePopover = function() {
$scope.popover.hide();
};
$scope.$on('$destroy', function() {
$scope.popover.remove();
});
// EndTrip Modal
$ionicModal.fromTemplateUrl('app/survey/endtrip.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modalEndTrip = modal;
});
$scope.openEndTripSurvey = function() {
$scope.modalEndTrip.show();
};
// Weekly Survey Modal
$ionicModal.fromTemplateUrl('app/survey/weekly_v2.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modalWeeklyTrip = modal;
});
$scope.openWeeklySurvey = function() {
$scope.modalWeeklyTrip.show();
};
}); });
\ No newline at end of file
<ion-view view-title="BLAZE" ng-init="initializedLocateUser();loadWeeklySurvey();getAllBarangay();"> <ion-view view-title="BLAZE" ng-init="initializedLocateUser();loadWeeklySurvey();getAllBarangay();">
<ion-nav-buttons side="left"> <ion-nav-buttons side="left">
<button ng-click="openMenu()" class="button button-icon ion-android-menu" ng-disabled="tripStatus"></button> <button ng-click="openMenu()" class="button button-icon ion-android-menu" ng-disabled="tripStatus"></button>
</ion-nav-buttons> </ion-nav-buttons>
<ion-nav-buttons side="right"> <ion-nav-buttons side="right">
<button ng-click="openPopover($event);" class="button button-icon ion-android-apps" ng-disabled="tripStatus"></button> <button ng-click="openPopover($event);" class="button button-icon ion-android-apps" ng-disabled="tripStatus"></button>
</ion-nav-buttons> </ion-nav-buttons>
<ion-floating-button style='opacity: 0.8;'' click="refreshMap();" has-footer="true" button-color="#333333" icon="ion-android-refresh" icon-color="#fff" ng-hide="tripStatus"> <ion-floating-button style='opacity: 0.8;' click="refreshMap();" has-footer="true" button-color="#333333" icon="ion-android-refresh" icon-color="#fff" ng-hide="tripStatus">
</ion-floating-button> </ion-floating-button>
<div class="bar bar-subheader bar-clear darkblue item-input-inset"> <div class="bar bar-subheader bar-clear darkblue item-input-inset">
<a class="item-input-wrapper" ng-click="onLoadSelection();"> <a class="item-input-wrapper" ng-click="onLoadSelection();">
<i class="icon ion-ios-search placeholder-icon"></i> <i class="icon ion-ios-search placeholder-icon"></i>
<input type="text" placeholder="Search Barangay" ng-model="selectedBarangayData" disabled> <input type="text" placeholder="Search Barangay" ng-model="selectedBarangayData" disabled>
</a> </a>
<button class="button button-stable" style="color: #000000;" ng-click="loadBarangayData();" ng-disabled="!selectedBarangayData"> <button class="button button-stable" style="color: #000000;" ng-click="loadBarangayData();" ng-disabled="!selectedBarangayData">
Show Show
</button> </button>
</div> </div>
<ion-content class="has-subheader" data-tap-disabled="true"> <ion-content class="has-subheader" data-tap-disabled="true">
<div id="mapid"></div> <div id="mapid"></div>
</ion-content> </ion-content>
<ion-footer-bar align-title="center" class="bar bar-clear darkblue"> <ion-footer-bar align-title="center" class="bar bar-clear darkblue">
<div class="button-bar"> <div class="button-bar">
<div class="button-bar" ng-if="!tripStatus"> <div class="button-bar" ng-if="!tripStatus">
<button ng-click="confirmTripDestination();" class="button button-icon ion-android-arrow-dropright-circle light"> Start Trip</button> <button ng-click="confirmTripDestination();" class="button button-icon ion-android-arrow-dropright-circle light"> Start Trip</button>
</div> </div>
<div class="button-bar" ng-if="tripStatus"> <div class="button-bar" ng-if="tripStatus">
<button ng-click="tripEnd();" class="button button-icon ion-android-cancel stable"> Stop Trip</button> <button ng-click="tripEnd();" class="button button-icon ion-android-cancel stable"> Stop Trip</button>
</div> </div>
</div> </div>
</ion-footer-bar> </ion-footer-bar>
</ion-view> </ion-view>
\ No newline at end of file
<ion-popover-view class="fit"> <ion-popover-view class="fit">
<ion-content scroll="false"> <ion-content scroll="false">
<div class="list"> <div class="list">
<a ng-click="getBlazersData();closePopover($event);" class="item item-icon-left"> <a ng-click="getBlazersDataV2();closePopover($event);" class="item item-icon-left">
<i class="icon ion-android-pin"></i> <i class="icon ion-android-pin"></i> Show Blazers
Show Blazers </a>
</a> <a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left">
<!--<a ng-click="loadHeatMap();" class="item item-icon-left"> <i class="icon ion-android-clipboard"></i> Weekly Survey
<i class="icon ion-android-pin"></i> </a>
Load Heatmap </div>
</a>--> </ion-content>
<a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left"> </ion-popover-view>
<i class="icon ion-android-clipboard"></i> \ No newline at end of file
Weekly Survey
</a>
</div>
</ion-content>
</ion-popover-view>
<ion-side-menus enable-menu-with-back-views="false"> <ion-side-menus enable-menu-with-back-views="false">
<ion-side-menu-content> <ion-side-menu-content>
<ion-nav-bar class="bar bar-clear darkblue"> <ion-nav-bar class="bar bar-clear darkblue">
<ion-nav-back-button> <ion-nav-back-button>
</ion-nav-back-button> </ion-nav-back-button>
<ion-nav-buttons side="left"> <ion-nav-buttons side="left">
<button class="button button-clear button-icon button-clear ion-android-menu" menu-toggle="left"></button> <button class="button button-clear button-icon button-clear ion-android-menu" menu-toggle="left"></button>
</ion-nav-buttons> </ion-nav-buttons>
</ion-nav-bar> </ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view> <ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content> </ion-side-menu-content>
<ion-side-menu side="left" width="220"> <ion-side-menu side="left" width="220">
<ion-content class="darkSide"> <ion-content class="darkSide">
<h3 class="text-light"><center>BLAZE</center></h3> <h3 class="text-light">
<ion-item nav-clear menu-close href="#/app/profile" class="item-avatar"><ionic-letter-avatar data="{{ user.username }}" shape="round" charcount="2"></ionic-letter-avatar><h4 class="text-light">{{ user.username }}</h4><h5 class="text-light">Blazer User</h5></ion-item> <center>BLAZE</center>
<ion-item nav-clear menu-close href="#/app/map" class="item-icon item-icon-left"><i class="icon ion-android-compass"></i>Blaze Network</ion-item> </h3>
<!-- <ion-item nav-clear menu-close href="#/app/offerride" class="item-icon item-icon-left"><i class="icon ion-android-car"></i>Offer a Ride</ion-item> --> <ion-item nav-clear menu-close href="#/app/profile" class="item-avatar">
<ion-item nav-clear menu-close href="#/app/sharedride" class="item-icon item-icon-left"><i class="icon ion-android-contacts"></i>Shared Ride</ion-item> <ionic-letter-avatar data="{{ user.username }}" shape="round" charcount="2"></ionic-letter-avatar>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Travel Stats</ion-item> <h4 class="text-light">{{ user.username }}</h4>
<ion-item nav-clear menu-close href="#/app/about" class="item-icon item-icon-left"><i class="icon ion-android-bulb"></i>About</ion-item> <h5 class="text-light">Blazer User</h5>
<ion-item nav-clear menu-close href="#/app/settings" class="item-icon item-icon-left"><i class="icon ion-android-settings"></i>Settings</ion-item> </ion-item>
</ion-content> <ion-item nav-clear menu-close href="#/app/map" class="item-icon item-icon-left"><i class="icon ion-android-compass"></i>Blaze Network</ion-item>
</ion-side-menu> <!-- <ion-item nav-clear menu-close href="#/app/offerride" class="item-icon item-icon-left"><i class="icon ion-android-car"></i>Offer a Ride</ion-item> -->
</ion-side-menus> <ion-item nav-clear menu-close href="#/app/sharedride" class="item-icon item-icon-left"><i class="icon ion-android-contacts"></i>Shared Ride</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Travel Stats</ion-item>
<ion-item nav-clear menu-close href="#/app/diary" class="item-icon item-icon-left"><i class="icon ion-bookmark"></i>My Trip Diary</ion-item>
<!--<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-edit"></i>Trip Logging</ion-item>-->
<ion-item nav-clear menu-close href="#/app/about" class="item-icon item-icon-left"><i class="icon ion-android-bulb"></i>About</ion-item>
<ion-item nav-clear menu-close href="#/app/settings" class="item-icon item-icon-left"><i class="icon ion-android-settings"></i>Settings</ion-item>
</ion-content>
</ion-side-menu>
</ion-side-menus>
\ No newline at end of file
<ion-view view-title="Offer a Ride" ng-init="getUserLocation();"> <ion-view view-title="Offer a Ride" ng-init="getUserLocation();">
<ion-nav-buttons side="right"> <ion-nav-buttons side="right">
<!--<button class="button button-clear button-light" ng-click="resetOfferRide();" ng-disabled="setPosition == true">Referesh</button>--> <!--<button class="button button-clear button-light" ng-click="resetOfferRide();" ng-disabled="setPosition == true">Referesh</button>-->
</ion-nav-buttons> </ion-nav-buttons>
<ion-content data-tap-disabled="false"> <ion-content data-tap-disabled="false">
<form name="offerride"> <form name="offerride">
<div class="item item-divider"> Offer Ride </div> <div class="item item-divider"> Offer Ride </div>
<p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific point of Destination.</p> <p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific point of Destination.</p>
<div class="item item-divider item-light"> Destination </div> <div class="item item-divider item-light"> Destination </div>
<!--<label class="item item-input"> <!--<label class="item item-input">
<input type="text" placeholder="Destination Address" location-suggestion location="location" ng-model="location.formatted_address"> <input type="text" placeholder="Destination Address" location-suggestion location="location" ng-model="location.formatted_address">
</label>--> </label>-->
<div id="mapdestination"></div> <div id="mapdestination"></div>
<p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific Pick-up Location.</p> <p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific Pick-up Location.</p>
<div class="item item-divider item-light"> Pick-up Location (specify) </div> <div class="item item-divider item-light"> Pick-up Location (specify) </div>
<div id="mappickup"></div> <div id="mappickup"></div>
<div class="item item-stacked-label" ion-datetime-picker am-pm ng-model="offer.assembly" required> <div class="item item-stacked-label" ion-datetime-picker am-pm ng-model="offer.assembly" required>
<span class="input-label">Date and Time</span> <span class="input-label">Date and Time</span>
<p>{{offer.assembly| date: "MMMM dd, yyyy 'at' H:mm:ss a"}}</p> <p>{{offer.assembly| date: "MMMM dd, yyyy 'at' H:mm:ss a"}}</p>
</div> </div>
<label class="item item-input item-stacked-label border-bottom-select"> <label class="item item-input item-stacked-label border-bottom-select">
<span class="input-label"> Car Brand</span> <span class="input-label"> Car Brand</span>
</label> </label>
<label class="item item-input item-select border-top"> <label class="item item-input item-select border-top">
<div class="input-label"> <div class="input-label">
&nbsp; &nbsp;
</div> </div>
...@@ -70,14 +70,14 @@ ...@@ -70,14 +70,14 @@
<option value="Volvo">Volvo</option> <option value="Volvo">Volvo</option>
</select> </select>
</label> </label>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label">Plate Number</span> <span class="input-label">Plate Number</span>
<input type="text" ng-model="offer.platenumber" placeholder="ABC123 or ABCD123" max-length="8" ng-maxlength="7" required/> <input type="text" ng-model="offer.platenumber" placeholder="ABC123 or ABCD123" max-length="8" ng-maxlength="7" required/>
</label> </label>
<label class="item item-input item-stacked-label border-bottom-select"> <label class="item item-input item-stacked-label border-bottom-select">
<span class="input-label"> Capacity</span> <span class="input-label"> Capacity</span>
</label> </label>
<label class="item item-input item-select border-top"> <label class="item item-input item-select border-top">
<div class="input-label"> <div class="input-label">
&nbsp; &nbsp;
</div> </div>
...@@ -98,19 +98,19 @@ ...@@ -98,19 +98,19 @@
<option value="15">15 Seater</option> <option value="15">15 Seater</option>
</select> </select>
</label> </label>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label">Mobile Number</span> <span class="input-label">Mobile Number</span>
<input type="number" ng-model="offer.mobile" placeholder="(09)** *** ****" maxlength="11" ng-maxlength="11" required/> <input type="number" ng-model="offer.mobile" placeholder="(09)** *** ****" maxlength="11" ng-maxlength="11" required/>
</label> </label>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label"> Other Details</span> <span class="input-label"> Other Details</span>
<textarea type="text" placeholder="Fuel contribution" ng-model="offer.notes" style="height: 100px;"></textarea> <textarea type="text" placeholder="Fuel contribution" ng-model="offer.notes" style="height: 100px;"></textarea>
</label> </label>
<div class="padding"> <div class="padding">
<button class="button button-block button-dark button-outline" ng-disabled="offerride.$invalid" ng-click="offerRide(location);"> <button class="button button-block button-dark button-outline" ng-disabled="offerride.$invalid" ng-click="offerRide(location);">
Offer Ride Offer Ride
</button> </button>
</div> </div>
</form> </form>
</ion-content> </ion-content>
</ion-view> </ion-view>
\ No newline at end of file
<ion-view view-title="My Travel Stats" ng-init="getTravelStats();"> <ion-view view-title="My Travel Stats" ng-init="getTravelStats();">
<ion-nav-buttons side="right"> <ion-nav-buttons side="right">
</ion-nav-buttons> </ion-nav-buttons>
<ion-content> <ion-content>
<ion-refresher pulling-text="Pull to refresh" on-refresh="getTravelStats();"></ion-refresher> <ion-refresher pulling-text="Pull to refresh" on-refresh="getTravelStats();"></ion-refresher>
<div class="list"> <div class="list card">
<div class="item item-divider"> Mode of Use </div> <div class="item item-divider"> Mode of Use </div>
<div class="item"> <div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Latest</i> <i class="button button-block button-clear bgbluegreen text-light">Latest</i>
<i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_latest }}</b></i> <i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_latest }}</b></i>
<i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_latest }}</b></i> <i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_latest }}</b></i>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_latest}}</b></i>--> <!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_latest}}</b></i>-->
</div> </div>
<div class="item"> <div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Frequently Used</i> <i class="button button-block button-clear bgbluegreen text-light">Frequently Used</i>
<i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_frequent }}</b></i> <i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_frequent }}</b></i>
<i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent }}</b></i> <i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent }}</b></i>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_average}}</b></i>--> </div>
</div> <div class="item">
<div class="item"> <i class="button button-block button-clear bgbluegreen text-light">Low-Carbon</i>
<i class="button button-block button-clear bgbluegreen text-light">Low-Carbon</i> <i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_best }}</b></i>
<i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_best }}</b></i> <i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent_positive }}</b></i>
<i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent_positive }}</b></i> </div>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_best}}</b></i>--> </div>
</div> <div class="list card">
<!--<div class="item item-thumbnail-left item-borderless"> <div class="item item-divider"> Time </div>
<img ng-src="img/info.png"> <div class="item">
<i> Latest </i> <i class="button button-block button-clear bgbluegreen text-light">Latest</i>
<p>Transportation: <i ng-if="!blazersStats.mode_latest">NULL</i>{{ blazersStats.mode_latest }}</p> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_latest }}</b></i>
<p>Mood: <i ng-if="!blazersStats.emo_latest">NULL</i>{{ blazersStats.emo_latest }}</p> </div>
</div> <div class="item">
<div class="item item-thumbnail-left item-borderless"> <i class="button button-block button-clear bgbluegreen text-light">Average</i>
<img ng-src="img/info.png"> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_average }}</b></i>
<i>Frequently Used</i> </div>
<p>Transportation: <i ng-if="!blazersStats.mode_frequent">NULL</i>{{ blazersStats.mode_frequent }}</p> <div class="item">
<p>Mood: <i ng-if="!blazersStats.emo_frequent">NULL</i>{{ blazersStats.emo_frequent }}</p> <i class="button button-block button-clear bgbluegreen text-light">Best</i>
</div> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_best }}</b></i>
<div class="item item-thumbnail-left item-borderless"> </div>
<img ng-src="img/info.png"> </div>
<i>Low-Carbon</i> </ion-content>
<p>Transportation: <i ng-if="!blazersStats.mode_best">NULL</i>{{ blazersStats.mode_best }}</p> </ion-view>
<p>Mood: <i ng-if="!blazersStats.emo_frequent_positive">NULL</i>{{ blazersStats.emo_frequent_positive }}</p> \ No newline at end of file
</div>-->
<div class="item item-divider"> Time </div>
<div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Latest</i>
<i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_latest }}</b></i>
</div>
<div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Average</i>
<i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_average }}</b></i>
</div>
<div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Best</i>
<i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_best }}</b></i>
</div>
<!--<div class="item item-borderless item-icon-left">
<i class="icon ion-android-wifi"></i>
Latest
<span class="item-note"> <i ng-if="!blazersStats.time_latest">NULL</i>{{ blazersStats.time_latest }} </span>
</div>
<div class="item item-borderless item-icon-left">
<i class="icon ion-android-wifi"></i>
Average
<span class="item-note"> <i ng-if="!blazersStats.time_average">NULL</i>{{ blazersStats.time_average }} </span>
</div>
<div class="item item-borderless item-icon-left">
<i class="icon ion-android-wifi"></i>
Best
<span class="item-note"> <i ng-if="!blazersStats.time_best">NULL</i>{{ blazersStats.time_best }} </span>
</div>-->
</div>
</ion-content>
</ion-view>
...@@ -2,260 +2,241 @@ angular.module('blazer.surveycontrollers', []) ...@@ -2,260 +2,241 @@ angular.module('blazer.surveycontrollers', [])
.controller('SurveyCtrl', function($scope, $ionicModal, $filter, $ionicSlideBoxDelegate, $ionicScrollDelegate, postBlazer, $cordovaNetwork, $cordovaDialogs) { .controller('SurveyCtrl', function($scope, $ionicModal, $filter, $ionicSlideBoxDelegate, $ionicScrollDelegate, postBlazer, $cordovaNetwork, $cordovaDialogs) {
$scope.closeEndTripModal = function() { $scope.closeEndTripModal = function() {
$scope.modalEndTrip.hide(); $scope.modalEndTrip.hide();
}; };
$scope.closeWeeklyModal = function() {
$scope.modalWeeklyTrip.hide();
};
$scope.endtrip = {};
$scope.postEndTripSurvey = function(){
/* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime");
var endTime = localStorage.getItem("endtime");
var newDate = new Date();
var timeStamp = newDate.getTime();
var currentTrip = localStorage.getItem("currentTrip");
var postdata = {
"trip_id" : tripID,
"username": username,
"depart": startTime,
"arrive": endTime,
"mode": $scope.endtrip.mode,
"exp": $scope.endtrip.overallxp,
"emotion": $scope.endtrip.emotion,
"type": currentTrip
}
console.log("[ POST END TRIP SURVEY ]");
postBlazer.EndTripSurvey(postdata)
.success(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.log("SEND ENDTRIP SURVEY SUCCESS", response);
})
.error(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response);
});
}
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.disableSwipe = function() {
$ionicSlideBoxDelegate.enableSlide(false);
};
$scope.currentIndex = '';
$scope.backSlide = function(){
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.previous();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.nextPageSlide = function(){
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.next();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.weekly = {};
$scope.postWeeklySurvey = function(){
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username");
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE');
var dateCreated = $filter('date')(newDate, 'yyyy - MM - dd HH: mm: ss');
var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){
angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 'C'){
surveyAnswer = null;
}
// var surveyAns = surveyAnswer;
// var surveyAnsStr = surveyAns.join(",");
var surveyString = surveyAnswer.toString(); $scope.closeWeeklyModal = function() {
$scope.modalWeeklyTrip.hide();
};
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString)); $scope.endtrip = {};
var postdata = { $scope.postEndTripSurvey = function() {
"user_id": userID, /* CHECK IF MOBILE IS ONLINE */
"username": username, console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
"choice": $scope.weekly.main, if ($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G || $cordovaNetwork.getNetwork() == Connection.CELL_4G) {
"survey_ans": surveyString, var tripID = localStorage.getItem("tripid");
"date_created": dateCreated var username = localStorage.getItem("username");
} var startTime = localStorage.getItem("starttime");
postBlazer.WeeklySurvey(postdata) var endTime = localStorage.getItem("endtime");
.success(function(response) { var newDate = new Date();
console.log("SEND WEEKLY SURVEY SUCCESS", response); var timeStamp = newDate.getTime();
localStorage.setItem(currentDate, currentDate); var currentTrip = localStorage.getItem("currentTrip");
$scope.resetValues();
$scope.closeWeeklyModal(); var postdata = {
}) "trip_id": tripID,
.error(function(response) { "username": username,
console.error("SEND WEEKLY SURVEY ERROR", response); "depart": startTime,
$scope.resetValues(); "arrive": endTime,
$scope.closeWeeklyModal(); "mode": $scope.endtrip.mode,
}); "exp": $scope.endtrip.overallxp,
} "emotion": $scope.endtrip.emotion,
else { "type": currentTrip
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY"); }
} console.log("[ POST END TRIP SURVEY ]");
} postBlazer.EndTripSurvey(postdata)
.success(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.log("SEND ENDTRIP SURVEY SUCCESS", response);
})
.error(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response);
});
} else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.disableSwipe = function() {
$ionicSlideBoxDelegate.enableSlide(false);
};
$scope.currentIndex = '';
$scope.backSlide = function() {
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.previous();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.nextPageSlide = function() {
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.next();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.resetValues = function(){
$scope.weekly = {}; $scope.weekly = {};
$scope.postWeeklySurvey = function() {
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if ($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G || $cordovaNetwork.getNetwork() == Connection.CELL_4G) {
var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username");
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE');
var dateCreated = $filter('date')(newDate, 'yyyy - MM - dd HH: mm: ss');
var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */
if ($scope.weekly.main == 1 || $scope.weekly.main == 2 || $scope.weekly.main == 3 || $scope.weekly.main == 4 || $scope.weekly.main == 5 || $scope.weekly.main == 6) {
angular.forEach($scope.choice1, function(value, key) {
if (value == 'N/A') {
surveyAnswer.push(value);
} else {
surveyAnswer.push(parseInt(value));
}
})
} else if ($scope.weekly.main == 'C') {
surveyAnswer = null;
}
var surveyString = surveyAnswer.toString();
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString));
var postdata = {
"user_id": userID,
"username": username,
"choice": $scope.weekly.main,
"survey_ans": surveyString,
"date_created": dateCreated
}
postBlazer.WeeklySurvey(postdata)
.success(function(response) {
console.log("SEND WEEKLY SURVEY SUCCESS", response);
localStorage.setItem(currentDate, currentDate);
$scope.resetValues();
$scope.closeWeeklyModal();
})
.error(function(response) {
console.error("SEND WEEKLY SURVEY ERROR", response);
$scope.resetValues();
$scope.closeWeeklyModal();
});
} else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.resetValues = function() {
$scope.weekly = {};
$scope.choice1 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0"
};
$scope.choice3 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0",
nine: "0",
ten: "0"
};
$scope.choice4 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
$scope.choice5 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
}
$scope.choiceOneA = [
{ text: "0", value: "0" },
{ text: "1", value: "1" },
{ text: "2", value: "2" },
{ text: "3", value: "3" },
{ text: "4", value: "4" },
{ text: "5", value: "5" }
];
$scope.choiceOneB = [
{ text: "6", value: "6" },
{ text: "7", value: "7" },
{ text: "8", value: "8" },
{ text: "9", value: "9" },
{ text: "10", value: "10" }
];
$scope.choice1 = { $scope.choice1 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0", seven: "0",
eight: "0" eight: "0"
}; };
$scope.choice3 = { $scope.choice3 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0", seven: "0",
eight: "0", eight: "0",
nine: "0", nine: "0",
ten: "0" ten: "0"
}; };
$scope.choice4 = { $scope.choice4 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0" seven: "0"
}; };
$scope.choice5 = { $scope.choice5 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0" seven: "0"
}; };
}
$scope.choiceOneA = [
{ text: "0", value: "0" },
{ text: "1", value: "1" },
{ text: "2", value: "2" },
{ text: "3", value: "3" },
{ text: "4", value: "4" },
{ text: "5", value: "5" }
];
$scope.choiceOneB = [
{ text: "6", value: "6" },
{ text: "7", value: "7" },
{ text: "8", value: "8" },
{ text: "9", value: "9" },
{ text: "10", value: "10" }
];
$scope.choice1 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0"
};
$scope.choice3 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0",
nine: "0",
ten: "0"
};
$scope.choice4 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
$scope.choice5 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
$scope.items = [
{ number: 1 },
{ number: 2 },
{ number: 3 },
{ number: 4 },
{ number: 5 },
{ number: 6 },
{ number: 7 },
{ number: 8 },
{ number: 9 },
{ number: 10 },
{ number: 11 },
{ number: 12 },
{ number: 13 },
{ number: 14 },
{ number: 15 }
];
$scope.selectedItem = $scope.items[2];
});
$scope.items = [
{ number: 1 },
{ number: 2 },
{ number: 3 },
{ number: 4 },
{ number: 5 },
{ number: 6 },
{ number: 7 },
{ number: 8 },
{ number: 9 },
{ number: 10 },
{ number: 11 },
{ number: 12 },
{ number: 13 },
{ number: 14 },
{ number: 15 }
];
$scope.selectedItem = $scope.items[2];
});
\ No newline at end of file
<ion-modal-view ng-controller="SurveyCtrl">
<form name="survey">
<ion-header-bar align-title="center" class="bar bar-clear darkblue">
<div class="buttons">
<button class="button button-clear button-light" ng-if="currentIndex!=0" ng-click="backSlide();"><i class="button-icon icon ion-back"></i>Back</button>
</div>
<h1 class="title">Weekly Survey</h1>
<div class="buttons">
<button class="button button-clear button-light" ng-disabled="survey.$invalid" ng-click="postWeeklySurvey()"><i class="button-icon icon ion-android-send"></i></button>
</div>
</ion-header-bar>
<ion-content padding="true">
<ion-slide-box on-slide-changed="slideHasChanged($index)" show-pager="false" ng-init="disableSwipe(); resetValues();" class="dynamic-slider">
<ion-slide>
<div class="item item-light item-text-wrap">
<p class="text-dark">Choose one statement that best describes your car use in the past 4-5 days and how you feel about it.</p>
</div>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=1 ng-click="nextPageSlide()"><b>A:</b> "These past few days, I used car frequently to school, either driving or being driven alone. I am happy about it and I am not at all thinking of lessening my car use."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=2 ng-click="nextPageSlide()"><b>B:</b> "I used car frequently to school over the last few days. I don't know if I can reduce my car use but I am willing to explore possible ways to change my behavior."</ion-radio>
<ion-radio class="item item-text-wrap justify " ng-model="weekly.main" ng-value=3 ng-click="nextPageSlide()"><b>C:</b> "I used car frequently to school in the past 4-5 days. I want to reduce my car use but I don't know how to. In the coming week, I will try to make a plan on how I can achieve my goal of going by alternative modes for some
of my trips to the university."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=4 ng-click="nextPageSlide()"><b>D:</b> "I used car frequently to school in the last few days. I already have some plan on how to go to school by alternatives but I have not implemented it yet. In the coming week, I will attempt to finally implement it."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=5 ng-click="nextPageSlide()"><b>E:</b> "I was able to reduce (further?) my level of car use these past 4-5 days. I will try to maintain this or reduce it more in the coming week."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=6 ng-click="nextPageSlide()"><b>F:</b> "These past few days, I mostly used alternative modes even though I could use car."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value="'C'" ng-click="postWeeklySurvey()"><b>G:</b> "As I do not own/have access to a car, I have no choice butto use alternative modes."</ion-radio>
</ion-slide>
<ion-slide>
<div class="item item-light item-text-wrap">
<p class="text-dark">Kindly read carefully and tell us how much you agree or disagree with each of the 15 statements. Choose N/A if thestatement is not applicable to you.</p>
</div>
<!-- FIRST -->
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>1:</b> "I will feel good about myself if I am able to use alternatives for my trips to school." </span>
</label>
<div class="button-bar" style="border-bottom: 0px; border-top: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.one =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.one =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.one =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1one" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.one" value="{{choice1.one}}"> {{choice1.one}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.one" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>2:</b> "I will feel bad if I do nothing to adopt a more pro-environmental mobility lifestyle." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.two =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.two =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.two =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1two" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.two" value="{{choice1.two}}"> {{choice1.two}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.two" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>3:</b> "Before I make the trip by car, I first consider if I can make the same trip by alternatives. Cars should be seen as mode of last resort." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.three =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.three =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.three =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1three" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.three" value="{{choice1.three}}"> {{choice1.three}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.three" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>4:</b> “I know some Ateneans who, though have access to cars, go to school by alternatives. They somehow motivate me to travel like them." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.four =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.four =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.four =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1four" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.four" value="{{choice1.four}}"> {{choice1.four}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.four" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>5:</b> "Each of us can contribute in solving eco-problems associated with car use by using car less or ridesharing with others if possible." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.five =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.five =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.five =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1five" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.five" value="{{choice1.five}}"> {{choice1.five}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.five" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>6:</b> "There are social costs associated with car use: traffic congestion, traffic accidents, air pollution and global warming." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.six =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.six =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.six =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1six" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.six" value="{{choice1.six}}"> {{choice1.six}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.six" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>7:</b> "It is possible for me to go to the university (more often) by carpool or other alternative modes." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.seven =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.seven =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.seven =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1seven" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.seven" value="{{choice1.seven}}"> {{choice1.seven}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.seven" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>8:</b> "I intend to contribute in taking cars off the roads, either by taking alternative means or pooling with others car trips going to same destination." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.eight =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.eight =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.eight =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1eight" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.eight" value="{{choice1.eight}}"> {{choice1.eight}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.eight" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>9:</b> "Among the different mode options to go to the university, there is one option, except driving alone or being the only passenger driven, that is favorable for me." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.nine =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.nine =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.nine =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1nine" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.nine" value="{{choice1.nine}}"> {{choice1.nine}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.nine" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>10:</b> "I have decided which mode to use as substitute for my car for some of my trips to the university. I intend to make a plan on how to go to the university using this mode." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.ten =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.ten =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.ten =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1ten" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.ten" value="{{choice1.ten}}"> {{choice1.ten}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.ten" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>11:</b> "I have plan on how to go to school by alternatives, and I have already run through my head on how to best carry out this plan." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.eleven =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.eleven =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.eleven =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1eleven" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.eleven" value="{{choice1.eleven}}"> {{choice1.eleven}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.eleven" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>12:</b> "I have anticipated all the possible problems that can occur and hinder me as I put this plan into practice." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.twelve =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.twelve =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.twelve =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1twelve" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.twelve" value="{{choice1.twelve}}"> {{choice1.twelve}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.twelve" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>13:</b> "I have already mentally developed ways to overcome such problems and obstacles or to be flexible depending on the situation." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.thirteen =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.thirteen =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.thirteen =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1thirteen" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.thirteen" value="{{choice1.thirteen}}"> {{choice1.thirteen}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.thirteen" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>14:</b> "Within the next seven days, I intend to actually use (more) public transport or rideshare in going to the university/home." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.fourteen =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.fourteen =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.fourteen =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1fourteen" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.fourteen" value="{{choice1.fourteen}}"> {{choice1.fourteen}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.fourteen" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>15:</b> "I will continue to use alternatives to go to school, even though this may be inconvenient." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.fifteen =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.fifteen =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.fifteen =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1fifteen" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.fifteen" value="{{choice1.fifteen}}"> {{choice1.fifteen}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.fifteen" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
</ion-slide>
</ion-slide-box>
</form>
</ion-content>
</ion-modal-view>
\ No newline at end of file
...@@ -14,111 +14,156 @@ ...@@ -14,111 +14,156 @@
.leaflet-zoom-box, .leaflet-zoom-box,
.leaflet-image-layer, .leaflet-image-layer,
.leaflet-layer { .leaflet-layer {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
} }
.leaflet-container { .leaflet-container {
overflow: hidden; overflow: hidden;
-ms-touch-action: none; -ms-touch-action: none;
touch-action: none;
} }
.leaflet-tile, .leaflet-tile,
.leaflet-marker-icon, .leaflet-marker-icon,
.leaflet-marker-shadow { .leaflet-marker-shadow {
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
user-select: none; user-select: none;
-webkit-user-drag: none; -webkit-user-drag: none;
} }
.leaflet-marker-icon, .leaflet-marker-icon,
.leaflet-marker-shadow { .leaflet-marker-shadow {
display: block; display: block;
} }
/* map is broken in FF if you have max-width: 100% on tiles */ /* map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container img { .leaflet-container img {
max-width: none !important; max-width: none !important;
} }
/* stupid Android 2 doesn't understand "max-width: none" properly */ /* stupid Android 2 doesn't understand "max-width: none" properly */
.leaflet-container img.leaflet-image-layer { .leaflet-container img.leaflet-image-layer {
max-width: 15000px !important; max-width: 15000px !important;
} }
.leaflet-tile { .leaflet-tile {
filter: inherit; filter: inherit;
visibility: hidden; visibility: hidden;
} }
.leaflet-tile-loaded { .leaflet-tile-loaded {
visibility: inherit; visibility: inherit;
} }
.leaflet-zoom-box { .leaflet-zoom-box {
width: 0; width: 0;
height: 0; height: 0;
} }
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg { .leaflet-overlay-pane svg {
-moz-user-select: none; -moz-user-select: none;
} }
.leaflet-tile-pane { z-index: 2; } .leaflet-tile-pane {
.leaflet-objects-pane { z-index: 3; } z-index: 2;
.leaflet-overlay-pane { z-index: 4; } }
.leaflet-shadow-pane { z-index: 5; }
.leaflet-marker-pane { z-index: 6; } .leaflet-objects-pane {
.leaflet-popup-pane { z-index: 7; } z-index: 3;
}
.leaflet-overlay-pane {
z-index: 4;
}
.leaflet-shadow-pane {
z-index: 5;
}
.leaflet-marker-pane {
z-index: 6;
}
.leaflet-popup-pane {
z-index: 7;
}
.leaflet-vml-shape { .leaflet-vml-shape {
width: 1px; width: 1px;
height: 1px; height: 1px;
} }
.lvml { .lvml {
behavior: url(#default#VML); behavior: url(#default#VML);
display: inline-block; display: inline-block;
position: absolute; position: absolute;
} }
/* control positioning */ /* control positioning */
.leaflet-control { .leaflet-control {
position: relative; position: relative;
z-index: 7; z-index: 7;
pointer-events: auto; pointer-events: auto;
} }
.leaflet-top, .leaflet-top,
.leaflet-bottom { .leaflet-bottom {
position: absolute; position: absolute;
z-index: 1000; z-index: 1000;
pointer-events: none; pointer-events: none;
} }
.leaflet-top { .leaflet-top {
top: 0; top: 0;
} }
.leaflet-right { .leaflet-right {
right: 0; right: 0;
} }
.leaflet-bottom { .leaflet-bottom {
bottom: 0; bottom: 0;
} }
.leaflet-left { .leaflet-left {
left: 0; left: 0;
} }
.leaflet-control { .leaflet-control {
float: left; float: left;
clear: both; clear: both;
} }
.leaflet-right .leaflet-control { .leaflet-right .leaflet-control {
float: right; float: right;
} }
.leaflet-top .leaflet-control { .leaflet-top .leaflet-control {
margin-top: 10px; margin-top: 10px;
} }
.leaflet-bottom .leaflet-control { .leaflet-bottom .leaflet-control {
margin-bottom: 10px; margin-bottom: 10px;
} }
.leaflet-left .leaflet-control { .leaflet-left .leaflet-control {
margin-left: 10px; margin-left: 10px;
} }
.leaflet-right .leaflet-control { .leaflet-right .leaflet-control {
margin-right: 10px; margin-right: 10px;
} }
...@@ -126,128 +171,143 @@ ...@@ -126,128 +171,143 @@
.leaflet-fade-anim .leaflet-tile, .leaflet-fade-anim .leaflet-tile,
.leaflet-fade-anim .leaflet-popup { .leaflet-fade-anim .leaflet-popup {
opacity: 0; opacity: 0;
-webkit-transition: opacity 0.2s linear; -webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear; transition: opacity 0.2s linear;
} }
.leaflet-fade-anim .leaflet-tile-loaded, .leaflet-fade-anim .leaflet-tile-loaded,
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1; opacity: 1;
} }
.leaflet-zoom-anim .leaflet-zoom-animated { .leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -webkit-transition: -webkit-transform 0.25s cubic-bezier(0, 0, 0.25, 1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0, 0, 0.25, 1);
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); -o-transition: -o-transform 0.25s cubic-bezier(0, 0, 0.25, 1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1); transition: transform 0.25s cubic-bezier(0, 0, 0.25, 1);
} }
.leaflet-zoom-anim .leaflet-tile, .leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile, .leaflet-pan-anim .leaflet-tile,
.leaflet-touching .leaflet-zoom-animated { .leaflet-touching .leaflet-zoom-animated {
-webkit-transition: none; -webkit-transition: none;
-moz-transition: none; -moz-transition: none;
-o-transition: none; -o-transition: none;
transition: none; transition: none;
} }
.leaflet-zoom-anim .leaflet-zoom-hide { .leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden; visibility: hidden;
} }
/* cursors */ /* cursors */
.leaflet-clickable { .leaflet-clickable {
cursor: pointer; cursor: pointer;
} }
.leaflet-container { .leaflet-container {
cursor: -webkit-grab; cursor: -webkit-grab;
cursor: -moz-grab; cursor: -moz-grab;
} }
.leaflet-popup-pane, .leaflet-popup-pane,
.leaflet-control { .leaflet-control {
cursor: auto; cursor: auto;
} }
.leaflet-dragging .leaflet-container, .leaflet-dragging .leaflet-container,
.leaflet-dragging .leaflet-clickable { .leaflet-dragging .leaflet-clickable {
cursor: move; cursor: move;
cursor: -webkit-grabbing; cursor: -webkit-grabbing;
cursor: -moz-grabbing; cursor: -moz-grabbing;
} }
/* visual tweaks */ /* visual tweaks */
.leaflet-container { .leaflet-container {
background: #ddd; background: #ddd;
outline: 0; outline: 0;
} }
.leaflet-container a { .leaflet-container a {
color: #0078A8; color: #0078A8;
} }
.leaflet-container a.leaflet-active { .leaflet-container a.leaflet-active {
outline: 2px solid orange; outline: 2px solid orange;
} }
.leaflet-zoom-box { .leaflet-zoom-box {
border: 2px dotted #38f; border: 2px dotted #38f;
background: rgba(255,255,255,0.5); background: rgba(255, 255, 255, 0.5);
} }
/* general typography */ /* general typography */
.leaflet-container { .leaflet-container {
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
} }
/* general toolbar styles */ /* general toolbar styles */
.leaflet-bar { .leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
border-radius: 4px; border-radius: 4px;
} }
.leaflet-bar a, .leaflet-bar a,
.leaflet-bar a:hover { .leaflet-bar a:hover {
background-color: #fff; background-color: #fff;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
width: 26px; width: 26px;
height: 26px; height: 26px;
line-height: 26px; line-height: 26px;
display: block; display: block;
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
color: black; color: black;
} }
.leaflet-bar a, .leaflet-bar a,
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
background-position: 50% 50%; background-position: 50% 50%;
background-repeat: no-repeat; background-repeat: no-repeat;
display: block; display: block;
} }
.leaflet-bar a:hover { .leaflet-bar a:hover {
background-color: #f4f4f4; background-color: #f4f4f4;
} }
.leaflet-bar a:first-child { .leaflet-bar a:first-child {
border-top-left-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
} }
.leaflet-bar a:last-child { .leaflet-bar a:last-child {
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
border-bottom: none; border-bottom: none;
} }
.leaflet-bar a.leaflet-disabled { .leaflet-bar a.leaflet-disabled {
cursor: default; cursor: default;
background-color: #f4f4f4; background-color: #f4f4f4;
color: #bbb; color: #bbb;
} }
.leaflet-touch .leaflet-bar a { .leaflet-touch .leaflet-bar a {
width: 30px; width: 30px;
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
} }
...@@ -255,224 +315,251 @@ ...@@ -255,224 +315,251 @@
.leaflet-control-zoom-in, .leaflet-control-zoom-in,
.leaflet-control-zoom-out { .leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace; font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px; text-indent: 1px;
} }
.leaflet-control-zoom-out { .leaflet-control-zoom-out {
font-size: 20px; font-size: 20px;
} }
.leaflet-touch .leaflet-control-zoom-in { .leaflet-touch .leaflet-control-zoom-in {
font-size: 22px; font-size: 22px;
} }
.leaflet-touch .leaflet-control-zoom-out { .leaflet-touch .leaflet-control-zoom-out {
font-size: 24px; font-size: 24px;
} }
/* layers control */ /* layers control */
.leaflet-control-layers { .leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
background: #fff; background: #fff;
border-radius: 5px; border-radius: 5px;
} }
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
background-image: url(images/layers.png); background-image: url(images/layers.png);
width: 36px; width: 36px;
height: 36px; height: 36px;
} }
.leaflet-retina .leaflet-control-layers-toggle { .leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png); background-image: url(images/layers-2x.png);
background-size: 26px 26px; background-size: 26px 26px;
} }
.leaflet-touch .leaflet-control-layers-toggle { .leaflet-touch .leaflet-control-layers-toggle {
width: 44px; width: 44px;
height: 44px; height: 44px;
} }
.leaflet-control-layers .leaflet-control-layers-list, .leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle { .leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none; display: none;
} }
.leaflet-control-layers-expanded .leaflet-control-layers-list { .leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block; display: block;
position: relative; position: relative;
} }
.leaflet-control-layers-expanded { .leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px; padding: 6px 10px 6px 6px;
color: #333; color: #333;
background: #fff; background: #fff;
} }
.leaflet-control-layers-selector { .leaflet-control-layers-selector {
margin-top: 2px; margin-top: 2px;
position: relative; position: relative;
top: 1px; top: 1px;
} }
.leaflet-control-layers label { .leaflet-control-layers label {
display: block; display: block;
} }
.leaflet-control-layers-separator { .leaflet-control-layers-separator {
height: 0; height: 0;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px; margin: 5px -10px 5px -6px;
} }
/* attribution and scale controls */ /* attribution and scale controls */
.leaflet-container .leaflet-control-attribution { .leaflet-container .leaflet-control-attribution {
background: #fff; background: #fff;
background: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.7);
margin: 0; margin: 0;
} }
.leaflet-control-attribution, .leaflet-control-attribution,
.leaflet-control-scale-line { .leaflet-control-scale-line {
padding: 0 5px; padding: 0 5px;
color: #333; color: #333;
} }
.leaflet-control-attribution a { .leaflet-control-attribution a {
text-decoration: none; text-decoration: none;
} }
.leaflet-control-attribution a:hover { .leaflet-control-attribution a:hover {
text-decoration: underline; text-decoration: underline;
} }
.leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale { .leaflet-container .leaflet-control-scale {
font-size: 11px; font-size: 11px;
} }
.leaflet-left .leaflet-control-scale { .leaflet-left .leaflet-control-scale {
margin-left: 5px; margin-left: 5px;
} }
.leaflet-bottom .leaflet-control-scale { .leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px; margin-bottom: 5px;
} }
.leaflet-control-scale-line { .leaflet-control-scale-line {
border: 2px solid #777; border: 2px solid #777;
border-top: none; border-top: none;
line-height: 1.1; line-height: 1.1;
padding: 2px 5px 1px; padding: 2px 5px 1px;
font-size: 11px; font-size: 11px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
-moz-box-sizing: content-box; -moz-box-sizing: content-box;
box-sizing: content-box; box-sizing: content-box;
background: #fff;
background: #fff; background: rgba(255, 255, 255, 0.5);
background: rgba(255, 255, 255, 0.5);
} }
.leaflet-control-scale-line:not(:first-child) { .leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777; border-top: 2px solid #777;
border-bottom: none; border-bottom: none;
margin-top: -2px; margin-top: -2px;
} }
.leaflet-control-scale-line:not(:first-child):not(:last-child) { .leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777; border-bottom: 2px solid #777;
} }
.leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar { .leaflet-touch .leaflet-bar {
box-shadow: none; box-shadow: none;
} }
.leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar { .leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2); border: 2px solid rgba(0, 0, 0, 0.2);
background-clip: padding-box; background-clip: padding-box;
} }
/* popup */ /* popup */
.leaflet-popup { .leaflet-popup {
position: absolute; position: absolute;
text-align: center; text-align: center;
} }
.leaflet-popup-content-wrapper { .leaflet-popup-content-wrapper {
padding: 1px; padding: 1px;
text-align: left; text-align: left;
border-radius: 12px; border-radius: 12px;
} }
.leaflet-popup-content { .leaflet-popup-content {
margin: 13px 19px; margin: 13px 19px;
line-height: 1.4; line-height: 1.4;
} }
.leaflet-popup-content p { .leaflet-popup-content p {
margin: 18px 0; margin: 18px 0;
} }
.leaflet-popup-tip-container { .leaflet-popup-tip-container {
margin: 0 auto; margin: 0 auto;
width: 40px; width: 40px;
height: 20px; height: 20px;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0; .leaflet-popup-tip {
width: 17px;
-webkit-transform: rotate(45deg); height: 17px;
-moz-transform: rotate(45deg); padding: 1px;
-ms-transform: rotate(45deg); margin: -10px auto 0;
-o-transform: rotate(45deg); -webkit-transform: rotate(45deg);
transform: rotate(45deg); -moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
} }
.leaflet-popup-content-wrapper, .leaflet-popup-content-wrapper,
.leaflet-popup-tip { .leaflet-popup-tip {
background: white; background: white;
box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
} }
.leaflet-container a.leaflet-popup-close-button { .leaflet-container a.leaflet-popup-close-button {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
padding: 4px 4px 0 0; padding: 4px 4px 0 0;
text-align: center; text-align: center;
width: 18px; width: 18px;
height: 14px; height: 14px;
font: 16px/14px Tahoma, Verdana, sans-serif; font: 16px/14px Tahoma, Verdana, sans-serif;
color: #c3c3c3; color: #c3c3c3;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
background: transparent; background: transparent;
} }
.leaflet-container a.leaflet-popup-close-button:hover { .leaflet-container a.leaflet-popup-close-button:hover {
color: #999; color: #999;
} }
.leaflet-popup-scrolled { .leaflet-popup-scrolled {
overflow: auto; overflow: auto;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
} }
.leaflet-oldie .leaflet-popup-content-wrapper { .leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1; zoom: 1;
} }
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; .leaflet-oldie .leaflet-popup-tip {
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid: DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
} }
.leaflet-oldie .leaflet-popup-tip-container { .leaflet-oldie .leaflet-popup-tip-container {
margin-top: -1px; margin-top: -1px;
} }
.leaflet-oldie .leaflet-control-zoom, .leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers, .leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper, .leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip { .leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999; border: 1px solid #999;
} }
/* div icon */ /* div icon */
.leaflet-div-icon { .leaflet-div-icon {
background: #fff; background: #fff;
border: 1px solid #666; border: 1px solid #666;
} }
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />--> <!--<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />-->
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
<link href="css/style.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="css/leaflet.css"> <link rel="stylesheet" href="css/leaflet.css">
<link rel="stylesheet" href="css/leaflet-routing-machine.css"> <link rel="stylesheet" href="css/leaflet-routing-machine.css">
<link href="lib/ion-floating-menu/dist/ion-floating-menu.css" rel="stylesheet" type="text/css"> <link href="lib/ion-floating-menu/dist/ion-floating-menu.css" rel="stylesheet" type="text/css">
<!--<link href="lib/leaflet-markercluster/dist/MarkerCluster.css" rel="stylesheet" type="text/css"/>--> <!--<link href="lib/leaflet-markercluster/dist/MarkerCluster.css" rel="stylesheet" type="text/css"/>-->
<link href="lib/ion-datetime-picker/release/ion-datetime-picker.min.css" rel="stylesheet"> <link href="lib/ion-datetime-picker/release/ion-datetime-picker.min.css" rel="stylesheet">
...@@ -27,8 +28,9 @@ ...@@ -27,8 +28,9 @@
<!-- cordova script (this will be a 404 during development) --> <!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/ng-cordova.min.js"></script> <script src="lib/ngCordova/ng-cordova.min.js"></script>
<script src="cordova.js"></script> <script src="cordova.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script> <script src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
<!--<script src="lib/leaflet/leaflet-google.js"></script>-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- your app's js --> <!-- your app's js -->
...@@ -45,6 +47,7 @@ ...@@ -45,6 +47,7 @@
<script src="app/misc/js/misc.js"></script> <script src="app/misc/js/misc.js"></script>
<script src="app/ride/js/ride.js"></script> <script src="app/ride/js/ride.js"></script>
<script src="app/message/js/message.js"></script> <script src="app/message/js/message.js"></script>
<script src="app/diary/js/diary.js"></script>
<script src="js/config.js"></script> <script src="js/config.js"></script>
<script src="js/blazerAPI.js"></script> <script src="js/blazerAPI.js"></script>
...@@ -53,12 +56,15 @@ ...@@ -53,12 +56,15 @@
<script src="lib/ion-floating-menu/dist/ion-floating-menu.js" type="text/javascript"></script> <script src="lib/ion-floating-menu/dist/ion-floating-menu.js" type="text/javascript"></script>
<!--<script src="lib/leaflet-markercluster/dist/leaflet.markercluster.js" type="text/javascript"></script>--> <!--<script src="lib/leaflet-markercluster/dist/leaflet.markercluster.js" type="text/javascript"></script>-->
<script src="lib/ion-datetime-picker/release/ion-datetime-picker.min.js"></script> <script src="lib/ion-datetime-picker/release/ion-datetime-picker.min.js"></script>
<script src="js/directives/radioButtons.js"></script> <script src="js/directives/radioButtons.js"></script>
</head>
<body ng-app="blazer" class="platform-android platform-cordova platform-webview">
</head>
<body ng-app="blazer" class="platform-android platform-cordova platform-webview">
<ion-nav-view></ion-nav-view> <ion-nav-view></ion-nav-view>
</body> </body>
</html>
</html>
\ No newline at end of file
angular.module('blazer', [ angular.module('blazer', [
'ionic', 'ionic',
'blazer.landingcontrollers', 'blazer.landingcontrollers',
'blazer.menucontrollers', 'blazer.menucontrollers',
'blazer.authenticationcontrollers', 'blazer.authenticationcontrollers',
'blazer.mapcontrollers', 'blazer.mapcontrollers',
'blazer.offerridecontrollers', 'blazer.offerridecontrollers',
'blazer.sharedridecontrollers', 'blazer.sharedridecontrollers',
'blazer.statuscontrollers', 'blazer.statuscontrollers',
'blazer.tripcontrollers', 'blazer.tripcontrollers',
'blazer.misccontrollers', 'blazer.misccontrollers',
'blazer.surveycontrollers', 'blazer.surveycontrollers',
'blazer.apiservices', 'blazer.diarycontrollers',
'blazer.rideinformation', 'blazer.apiservices',
'blazer.composemessage', 'blazer.rideinformation',
'ionic-letter-avatar', 'blazer.composemessage',
'ngCordova', 'ionic-letter-avatar',
'radioButtons', 'ngCordova',
'ion-floating-menu', 'radioButtons',
'ion-datetime-picker', 'ion-floating-menu',
'chart.js' 'ion-datetime-picker',
'chart.js'
]) ])
.run(function($ionicPlatform, $ionicPickerI18n) { .run(function($ionicPlatform, $ionicPickerI18n) {
$ionicPlatform.ready(function() { $ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) { if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true); cordova.plugins.Keyboard.disableScroll(true);
} }
if (window.StatusBar) { if (window.StatusBar) {
// org.apache.cordova.statusbar required // org.apache.cordova.statusbar required
StatusBar.styleDefault(); StatusBar.styleDefault();
} }
$ionicPickerI18n.ok = "Set"; $ionicPickerI18n.ok = "Set";
$ionicPickerI18n.okClass = "button-dark button-outline"; $ionicPickerI18n.okClass = "button-dark button-outline";
$ionicPickerI18n.cancelClass = "button-dark button-outline"; $ionicPickerI18n.cancelClass = "button-dark button-outline";
}); });
$ionicPlatform.registerBackButtonAction(function (event) { $ionicPlatform.registerBackButtonAction(function(event) {
event.preventDefault(); event.preventDefault();
}, 100); }, 100);
}) })
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) { .config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top $ionicConfigProvider.tabs.position('bottom'); // other values: top
$ionicConfigProvider.tabs.style('standard'); $ionicConfigProvider.tabs.style('standard');
$ionicConfigProvider.spinner.icon('lines'); $ionicConfigProvider.spinner.icon('lines');
$stateProvider $stateProvider
/* LANDING */ /* LANDING */
.state('landing', { .state('landing', {
url: '/landing', url: '/landing',
templateUrl: 'app/landing/landing.html', templateUrl: 'app/landing/landing.html',
controller: 'LandingCtrl' controller: 'LandingCtrl'
}) })
/* MENU */ /* MENU */
.state('app', { .state('app', {
url: '/app', url: '/app',
abstract: true, abstract: true,
templateUrl: 'app/menu/menu.html', templateUrl: 'app/menu/menu.html',
controller: 'MenuCtrl' controller: 'MenuCtrl'
}) })
/* LOGIN */ /* LOGIN */
.state('login', { .state('login', {
url: '/login', url: '/login',
templateUrl: 'app/auth/login.html', templateUrl: 'app/auth/login.html',
controller: 'AuthCtrl' controller: 'AuthCtrl'
}) })
/* HOME */ /* HOME */
.state('app.map', { .state('app.map', {
url: '/map', url: '/map',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/map/map.html', templateUrl: 'app/map/map.html',
controller: 'MapCtrl' controller: 'MapCtrl'
} }
} }
}) })
/* TRIP */ /* TRIP */
.state('app.trip', { .state('app.trip', {
url: '/trip', url: '/trip',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/trip/trip.html', templateUrl: 'app/trip/trip.html',
controller: 'TripCtrl' controller: 'TripCtrl'
} }
} }
}) })
/* SHAREDRIDE */ /* SHAREDRIDE */
.state('app.offerride', { .state('app.offerride', {
url: '/offerride', url: '/offerride',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/offerride/offerride.html', templateUrl: 'app/offerride/offerride.html',
controller: 'OfferRideCtrl' controller: 'OfferRideCtrl'
} }
} }
}) })
/* SHAREDRIDE */ /* SHAREDRIDE */
.state('app.sharedride', { .state('app.sharedride', {
url: '/sharedride', url: '/sharedride',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/sharedride/sharedride.html', templateUrl: 'app/sharedride/sharedride.html',
controller: 'SharedRideCtrl' controller: 'SharedRideCtrl'
} }
} }
}) })
/* STATUS */ /* STATUS */
.state('app.status', { .state('app.status', {
url: '/status', url: '/status',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/status/status.html', templateUrl: 'app/status/status.html',
controller: 'StatusCtrl' controller: 'StatusCtrl'
} }
} }
}) })
/* PROFILE */ /* PROFILE */
.state('app.profile', { .state('app.profile', {
url: '/profile', url: '/profile',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/misc/profile.html', templateUrl: 'app/misc/profile.html',
controller: 'MiscCtrl' controller: 'MiscCtrl'
} }
} }
}) })
/* ABOUT */ /* ABOUT */
.state('app.about', { .state('app.about', {
url: '/about', url: '/about',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/misc/about.html', templateUrl: 'app/misc/about.html',
controller: 'MiscCtrl' controller: 'MiscCtrl'
} }
} }
}) })
/* SETTINGS */ /* SETTINGS */
.state('app.settings', { .state('app.settings', {
url: '/settings', url: '/settings',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/misc/settings.html', templateUrl: 'app/misc/settings.html',
controller: 'MiscCtrl' controller: 'MiscCtrl'
} }
} }
}) })
/* RIDE INFORMATION */ /* RIDE INFORMATION */
.state('app.ride', { .state('app.ride', {
url: '/ride/:id', url: '/ride/:id',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/ride/ride.html', templateUrl: 'app/ride/ride.html',
controller: 'RideInfoCtrl' controller: 'RideInfoCtrl'
} }
} }
}) })
/* COMPOSE MESSAGE */ /* COMPOSE MESSAGE */
.state('app.message', { .state('app.message', {
url: '/message', url: '/message',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/message/message.html', templateUrl: 'app/message/message.html',
controller: 'MsgCtrl' controller: 'MsgCtrl'
} }
} }
}) })
$urlRouterProvider.otherwise('/landing');
/* DIARY */
.state('app.diary', {
url: '/diary',
views: {
'menuContent': {
templateUrl: 'app/diary/diary.html',
controller: 'DiaryCtrl'
}
}
})
$urlRouterProvider.otherwise('/landing');
}) })
\ No newline at end of file
...@@ -4,622 +4,1106 @@ ...@@ -4,622 +4,1106 @@
angular.module('blazer.apiservices', []) angular.module('blazer.apiservices', [])
/*-------------------------------------------------- GET -------------------------------------------------- */ /*-------------------------------------------------- GET -------------------------------------------------- */
.factory('getBlazer', function($http, $ionicLoading){ .factory('getBlazer', function($http, $ionicLoading) {
var AllBlazerData = []; var TempData = [];
var AllUserData = [];
var AllTravelStatus = []; return {
var AllSharedRideData = [];
var DetailedSharedRide = {}; getBlazerDataInfo: function() {
var AllModesofTransport = {}; $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
var AllBarangay = [];
return $http.get(blazerAPI + '/blazer_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
return { console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
getBlazerDataInfo: function(){ $ionicLoading.hide();
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); return TempData;
}, function(err) {
return $http.get(blazerAPI + '/blazer_data.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllBlazerData = response.data; return;
$ionicLoading.hide(); })
return AllBlazerData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getUserProfile: function(username) {
$ionicLoading.hide(); console.log("****** ON ENTER GET USER PROFILE SERVICE ******");
return ; // $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'});
})
}, return $http.get(blazerAPI + '/user_profile.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
getUserProfile: function(username) { TempData = response.data[0];
console.log("****** ON ENTER GET USER PROFILE SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); return TempData;
}, function(err) {
return $http.get(blazerAPI+'/user_profile.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllUserData = response.data[0]; return;
$ionicLoading.hide(); })
return AllUserData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getTravelStats: function(username) {
$ionicLoading.hide(); console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******");
return ; // $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'});
})
}, return $http.get(blazerAPI + '/travel_stats.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
getTravelStats: function(username) { TempData = response.data;
console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'});
return TempData;
return $http.get(blazerAPI+'/travel_stats.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); }, function(err) {
AllTravelStatus = response.data; console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return AllTravelStatus; return;
})
}, function(err) { },
console.error('[ ERROR ]', JSON.stringify(err)); /* NOT USED */
$ionicLoading.hide(); getSharedRide: function() {
console.log("****** ON ENTER GET SHARED RIDE SERVICE ******");
return ; // $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} );
})
}, return $http.get(blazerAPI + '/take_shared_ride_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
/* NOT USED */ console.log('[ SUCCESS ]', JSON.stringify(response));
getSharedRide: function() { TempData = response.data;
console.log("****** ON ENTER GET SHARED RIDE SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); return TempData;
}, function(err) {
return $http.get(blazerAPI+'/take_shared_ride_data.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllSharedRideData = response.data; return;
$ionicLoading.hide(); })
return AllSharedRideData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getTakeSharedRide: function(username) {
$ionicLoading.hide(); console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******");
return ; // $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} );
})
}, return $http.get(blazerAPI + '/take_shared_ride_data.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
getTakeSharedRide: function(username) { TempData = response.data;
console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); return TempData;
}, function(err) {
return $http.get(blazerAPI+'/take_shared_ride_data.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllSharedRideData = response.data; return;
$ionicLoading.hide(); })
return AllSharedRideData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getDetailedSharedRide: function(rideID, username) {
$ionicLoading.hide(); DetailedSharedRide = {};
return ; console.log("[ RIDE ID ]", rideID);
}) console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******");
}, $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI + '/take_shared_ride_data.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
getDetailedSharedRide: function(rideID, username) { // console.log('[ SUCCESS ]', JSON.stringify(response));
DetailedSharedRide = {}; TempData = response.data;
console.log("[ RIDE ID ]", rideID); angular.forEach(TempData, function(value, key) {
console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******"); if (value.id === rideID) {
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); DetailedSharedRide = { "id": value.id, "createdby": value.createdby, "destination": value.destination, "pickuplocation": value.pickuplocation, "pickup_lat": value.pickup_lat, "pickup_long": value.pickup_long, "assemblytime": value.assemblytime, "model": value.model, "mobilenum": value.mobilenum, "otherdetails": value.otherdetails, "subscribers": value.subscribers, "capacityleft": value.capacityleft, "avatar": value.avatar, "ride_status": value.ride_status, "interested_status": value.interested_status }
return $http.get(blazerAPI+'/take_shared_ride_data.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide));
// console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllSharedRideData = response.data; }
angular.forEach(AllSharedRideData, function(value, key) { });
if (value.id === rideID) { return DetailedSharedRide;
DetailedSharedRide = { "id": value.id, "createdby": value.createdby, "destination": value.destination, "pickuplocation": value.pickuplocation, "pickup_lat": value.pickup_lat, "pickup_long": value.pickup_long, "assemblytime": value.assemblytime, "model": value.model, "mobilenum": value.mobilenum, "otherdetails": value.otherdetails, "subscribers": value.subscribers, "capacityleft": value.capacityleft, "avatar": value.avatar, "ride_status": value.ride_status, "interested_status": value.interested_status } }, function(err) {
console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
} return;
}); })
return DetailedSharedRide; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); /* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */
$ionicLoading.hide(); getModeofTransportation: function(rideID) {
return ; console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******");
}) $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
}, return $http.get(blazerAPI + '/get_transportation_mode.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
// console.log('[ SUCCESS ]', JSON.stringify(response));
/* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */ TempData = response.data;
getModeofTransportation: function(rideID) { angular.forEach(TempData, function(value, key) {
console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******"); if (value.id === rideID) {
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); TempData = {};
return $http.get(blazerAPI+'/get_transportation_mode.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.log("[ MODE OF TRANSPORT ]", JSON.stringify(TempData));
// console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllModesofTransport = response.data; }
angular.forEach(AllModesofTransport, function(value, key) { });
if (value.id === rideID) { return TempData;
AllModesofTransport = {}; }, function(err) {
console.log("[ MODE OF TRANSPORT ]", JSON.stringify(AllModesofTransport)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
} return;
}); })
return AllModesofTransport; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getAllBarangay: function() {
$ionicLoading.hide(); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return ;
}) return $http.get(blazerAPI + '/get_barangay.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
}, console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
getAllBarangay: function(){ // LOOP BARANGAY DATA
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); var BarangayData = [];
for (var i = 0; i < TempData.length; i++) {
return $http.get(blazerAPI + '/get_barangay.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.log("Barangay " + i, TempData[i]);
console.log('[ SUCCESS ]', JSON.stringify(response)); BarangayData.push({ "name": TempData[i] });
AllBarangay = response.data; }
// LOOP BARANGAY DATA $ionicLoading.hide();
var BarangayData = []; return BarangayData;
for(var i = 0; i < AllBarangay.length; i++){ }, function(err) {
console.log("Barangay "+i,AllBarangay[i]); console.error('[ ERROR ]', JSON.stringify(err));
BarangayData.push({"name":AllBarangay[i]}); $ionicLoading.hide();
} return;
$ionicLoading.hide(); })
return BarangayData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getMapData: function() {
$ionicLoading.hide(); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return ;
}) return $http.get(blazerAPI_V2 + '/index.php/map/barangay_visualization', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
}, console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
} $ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getMostPopulatNonCarMode: function(barangay, time) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI_V2 + '/index.php/barangay/most_popular_non_car/' + barangay + '/' + time, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
$ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getHowYouMoveAround: function(start, end, username) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI_V2 + '/index.php/diary/how_you_moved/' + start + '/' + end + '/' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
$ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getHowYouMoveAround: function(start, end, username) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI_V2 + '/index.php/diary/how_you_moved/' + start + '/' + end + '/' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
$ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getComparisonMessage: function(username) {
return $http.get('http://blaze.eacomm.com/includes/get_facts.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
return TempData;
},
function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
}
}) })
/*-------------------------------------------------- POST -------------------------------------------------- */ /*-------------------------------------------------- POST -------------------------------------------------- */
.service('postBlazer', function($q, $http, $ionicLoading) { .service('postBlazer', function($q, $http, $ionicLoading) {
return { return {
LoginUser: function(user) { LoginUser: function(user) {
console.log("****** ON ENTER LOGIN SERVICE ******"); console.log("****** ON ENTER LOGIN SERVICE ******");
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ USER CREDENTIALS ] -> ", JSON.stringify(user)); console.log("[ USER CREDENTIALS ] -> ", JSON.stringify(user));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
$http({method: 'POST', url: blazerAPI + '/login.php', $http({
data: $.param(user), method: 'POST',
headers : {'Content-Type': 'application/x-www-form-urlencoded'} url: blazerAPI + '/login.php',
}).success(function(responseData) { data: $.param(user),
console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData)); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
if(responseData.status == 0){ }).success(function(responseData) {
$ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000}); console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData));
deferred.reject('Error'); if (responseData.status == 0) {
} $ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000 });
else if(responseData.status == 1){ deferred.reject('Error');
deferred.resolve('Success'); } else if (responseData.status == 1) {
// $ionicLoading.show({ template: "Success!", duration: 500}); deferred.resolve('Success');
$ionicLoading.hide(); // $ionicLoading.show({ template: "Success!", duration: 500});
localStorage.setItem("userID", responseData.user.id); $ionicLoading.hide();
console.log("[ USER ID ]", responseData.user.id); localStorage.setItem("userID", responseData.user.id);
} console.log("[ USER ID ]", responseData.user.id);
}).error(function(responseData) { }
console.error("[ ERROR ]", JSON.stringify(responseData)); }).error(function(responseData) {
deferred.reject('Error'); console.error("[ ERROR ]", JSON.stringify(responseData));
$ionicLoading.show({ template: "Check your connection!", duration: 500}); deferred.reject('Error');
}); $ionicLoading.show({ template: "Check your connection!", duration: 500 });
});
promise.success = function(fn) {
promise.then(fn); promise.success = function(fn) {
return promise; promise.then(fn);
} return promise;
promise.error = function(fn) { }
promise.then(null, fn); promise.error = function(fn) {
return promise; promise.then(null, fn);
} return promise;
return promise; }
}, return promise;
},
LogTrip: function(coords, username) {
console.log("****** ON ENTER TRIP LOGGING SERVICE ******"); LogTrip: function(coords, username) {
console.log("****** ON ENTER TRIP LOGGING SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise; var deferred = $q.defer();
var promise = deferred.promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 500});
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 500 });
var logTrip = {};
var currentTrip = localStorage.getItem("currentTrip"); var logTrip = {};
var currentTrip = localStorage.getItem("currentTrip");
logTrip = {
username: username, logTrip = {
type: currentTrip, username: username,
coordinates: coords type: currentTrip,
} coordinates: coords
}
console.log("[ TRIP JSON ]", JSON.stringify(logTrip));
console.log("[ TRIP JSON ]", JSON.stringify(logTrip));
$http({ method: 'POST', url: blazerAPI + '/log_trip.php',
data: $.param(logTrip), $http({
headers : {'Content-Type': 'application/x-www-form-urlencoded'} method: 'POST',
}).success(function(responseData) { url: blazerAPI + '/log_trip.php',
console.log("[ SUCCESS ]", JSON.stringify(responseData)); data: $.param(logTrip),
localStorage.setItem("tripid", responseData.trip_id); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
deferred.resolve('Success'); }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
// $ionicLoading.show({ template: "Success!", duration: 1000}); localStorage.setItem("tripid", responseData.trip_id);
}).error(function(responseData) { deferred.resolve('Success');
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); // $ionicLoading.show({ template: "Success!", duration: 1000});
}).error(function(responseData) {
$ionicLoading.show({ template: "Sending Error!", duration: 1000}); console.error("[ ERROR ]", JSON.stringify(responseData));
}); deferred.reject('Error');
promise.success = function(fn) { $ionicLoading.show({ template: "Sending Error!", duration: 1000 });
promise.then(fn); });
return promise;
} promise.success = function(fn) {
promise.error = function(fn) { promise.then(fn);
promise.then(null, fn); return promise;
return promise; }
} promise.error = function(fn) {
return promise; promise.then(null, fn);
}, return promise;
}
EndTripSurvey: function(data) { return promise;
console.log("****** ON ENTER TRIP END SERVICE ******"); },
var deferred = $q.defer(); EndTripSurvey: function(data) {
var promise = deferred.promise; console.log("****** ON ENTER TRIP END SERVICE ******");
var endtripdata = {
"trip_id" : data.trip_id, var deferred = $q.defer();
"username": data.username, var promise = deferred.promise;
"depart": data.depart, var endtripdata = {
"arrive": data.arrive, "trip_id": data.trip_id,
"mode": data.mode, "username": data.username,
"exp": data.exp, "depart": data.depart,
"emotion": data.emotion, "arrive": data.arrive,
"type": data.type "mode": data.mode,
}; "exp": data.exp,
"emotion": data.emotion,
var stringendtripdata = angular.fromJson(endtripdata); "type": data.type
};
console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); var stringendtripdata = angular.fromJson(endtripdata);
$http({method: 'POST', url: blazerAPI + '/end_trip.php', console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data));
data: $.param(stringendtripdata), $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(responseData) { $http({
console.log("[ SUCCESS ]", JSON.stringify(responseData)); method: 'POST',
deferred.resolve('Success'); url: blazerAPI + '/end_trip.php',
data: $.param(stringendtripdata),
$ionicLoading.show({ template: "Submitted!", duration: 1000}); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).error(function(responseData) { }).success(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.resolve('Success');
$ionicLoading.show({ template: "Try Again!", duration: 1000}); $ionicLoading.show({ template: "Submitted!", duration: 1000 });
}); }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
promise.success = function(fn) { deferred.reject('Error');
promise.then(fn);
return promise; $ionicLoading.show({ template: "Try Again!", duration: 1000 });
} });
promise.error = function(fn) {
promise.then(null, fn); promise.success = function(fn) {
return promise; promise.then(fn);
} return promise;
return promise; }
}, promise.error = function(fn) {
promise.then(null, fn);
WeeklySurvey: function(data) { return promise;
console.log("****** ON ENTER WEEKLY SURVEY SERVICE ******"); }
return promise;
var deferred = $q.defer(); },
var promise = deferred.promise;
WeeklySurvey: function(data) {
console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data)); console.log("****** ON ENTER WEEKLY SURVEY SERVICE ******");
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000});
var weeklysurveydata = { var deferred = $q.defer();
"user_id": data.user_id, var promise = deferred.promise;
"username": data.username,
"choice": data.choice, console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data));
"survey_ans": data.survey_ans, $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
"date_created": data.date_created var weeklysurveydata = {
}; "user_id": data.user_id,
$http({method: 'POST', url: blazerAPI + '/weekly_survey.php', "username": data.username,
data: $.param(weeklysurveydata), "choice": data.choice,
headers : {'Content-Type': 'application/x-www-form-urlencoded'} "survey_ans": data.survey_ans,
}).success(function(responseData) { "date_created": data.date_created
console.log("[ SUCCESS ]", JSON.stringify(responseData)); };
deferred.resolve('Success'); $http({
method: 'POST',
$ionicLoading.show({ template: "Submitted!", duration: 1000}); url: blazerAPI + '/weekly_survey.php',
}).error(function(responseData) { data: $.param(weeklysurveydata),
console.error("[ ERROR ]", JSON.stringify(responseData)); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
deferred.reject('Error'); }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
$ionicLoading.show({ template: "Try Again!", duration: 1000}); deferred.resolve('Success');
});
$ionicLoading.show({ template: "Submitted!", duration: 1000 });
promise.success = function(fn) { }).error(function(responseData) {
promise.then(fn); console.error("[ ERROR ]", JSON.stringify(responseData));
return promise; deferred.reject('Error');
}
promise.error = function(fn) { $ionicLoading.show({ template: "Try Again!", duration: 1000 });
promise.then(null, fn); });
return promise;
} promise.success = function(fn) {
return promise; promise.then(fn);
}, return promise;
}
TakeSharedRide: function(data) { promise.error = function(fn) {
console.log("****** ON ENTER TAKE SHARED RIDE SERVICE ******"); promise.then(null, fn);
return promise;
var deferred = $q.defer(); }
var promise = deferred.promise; return promise;
},
console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); TakeSharedRide: function(data) {
var sharedRideData = { console.log("****** ON ENTER TAKE SHARED RIDE SERVICE ******");
"ride_id": data.ride_id,
"user": data.username var deferred = $q.defer();
}; var promise = deferred.promise;
$http({method: 'POST', url: blazerAPI + '/take_shared_ride_post.php',
data: $.param(sharedRideData), console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data));
headers : {'Content-Type': 'application/x-www-form-urlencoded'} $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
}).success(function(responseData) { var sharedRideData = {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); "ride_id": data.ride_id,
deferred.resolve('Success'); "user": data.username
};
// $ionicLoading.show({ template: "Success!", duration: 1000}); $http({
}).error(function(responseData) { method: 'POST',
console.error("[ ERROR ]", JSON.stringify(responseData)); url: blazerAPI + '/take_shared_ride_post.php',
deferred.reject('Error'); data: $.param(sharedRideData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
$ionicLoading.show({ template: "Request Error!", duration: 1000}); }).success(function(responseData) {
}); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
promise.success = function(fn) {
promise.then(fn); // $ionicLoading.show({ template: "Success!", duration: 1000});
return promise; }).error(function(responseData) {
} console.error("[ ERROR ]", JSON.stringify(responseData));
promise.error = function(fn) { deferred.reject('Error');
promise.then(null, fn);
return promise; $ionicLoading.show({ template: "Request Error!", duration: 1000 });
} });
return promise;
}, promise.success = function(fn) {
promise.then(fn);
InterestedRide: function(data) { return promise;
console.log("****** ON ENTER INTERESTED RIDE SERVICE ******"); }
promise.error = function(fn) {
var deferred = $q.defer(); promise.then(null, fn);
var promise = deferred.promise; return promise;
}
console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data)); return promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); },
var interestedRideData = {
"ride_id": data.ride_id, InterestedRide: function(data) {
"username": data.username console.log("****** ON ENTER INTERESTED RIDE SERVICE ******");
};
$http({method: 'POST', url: blazerAPI + '/interested_ride_post.php', var deferred = $q.defer();
data: $.param(interestedRideData), var promise = deferred.promise;
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(responseData) { console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data));
console.log("[ SUCCESS ]", JSON.stringify(responseData)); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
deferred.resolve('Success'); var interestedRideData = {
"ride_id": data.ride_id,
// $ionicLoading.show({ template: "Success!", duration: 1000}); "username": data.username
}).error(function(responseData) { };
console.error("[ ERROR ]", JSON.stringify(responseData)); $http({
deferred.reject('Error'); method: 'POST',
url: blazerAPI + '/interested_ride_post.php',
$ionicLoading.show({ template: "Request Error!", duration: 1000}); data: $.param(interestedRideData),
}); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
promise.success = function(fn) { console.log("[ SUCCESS ]", JSON.stringify(responseData));
promise.then(fn); deferred.resolve('Success');
return promise;
} // $ionicLoading.show({ template: "Success!", duration: 1000});
promise.error = function(fn) { }).error(function(responseData) {
promise.then(null, fn); console.error("[ ERROR ]", JSON.stringify(responseData));
return promise; deferred.reject('Error');
}
return promise; $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}, });
OfferRide: function(data) { promise.success = function(fn) {
console.log("****** ON ENTER OFFER RIDE SERVICE ******"); promise.then(fn);
return promise;
var deferred = $q.defer(); }
var promise = deferred.promise; promise.error = function(fn) {
promise.then(null, fn);
console.log("[ OFFER DATA ] -> ", JSON.stringify(data)); return promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); }
var offerRiderData = { return promise;
"name": data.name, },
"pickup_lat": data.pickup_lat,
"pickup_lng": data.pickup_lng, OfferRide: function(data) {
"dest_lat": data.dest_lat, console.log("****** ON ENTER OFFER RIDE SERVICE ******");
"dest_lng": data.dest_lng,
"assembly_time": data.assembly_time, var deferred = $q.defer();
"car_model": data.car_model, var promise = deferred.promise;
"capacity": data.capacity,
"mobile": data.mobile, console.log("[ OFFER DATA ] -> ", JSON.stringify(data));
"other": data.other $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
}; var offerRiderData = {
$http({method: 'POST', url: blazerAPI + '/offer_ride.php', "name": data.name,
data: $.param(offerRiderData), "pickup_lat": data.pickup_lat,
headers : {'Content-Type': 'application/x-www-form-urlencoded'} "pickup_lng": data.pickup_lng,
}).success(function(responseData) { "dest_lat": data.dest_lat,
console.log("[ SUCCESS ]", JSON.stringify(responseData)); "dest_lng": data.dest_lng,
deferred.resolve('Success'); "assembly_time": data.assembly_time,
$ionicLoading.show({ template: "Ride Offered", duration: 1000}); "car_model": data.car_model,
}).error(function(responseData) { "capacity": data.capacity,
console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData)); "mobile": data.mobile,
deferred.reject('Error'); "other": data.other
$ionicLoading.show({ template: "Request Error!", duration: 1000}); };
}); $http({
method: 'POST',
promise.success = function(fn) { url: blazerAPI + '/offer_ride.php',
promise.then(fn); data: $.param(offerRiderData),
return promise; headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
} }).success(function(responseData) {
promise.error = function(fn) { console.log("[ SUCCESS ]", JSON.stringify(responseData));
promise.then(null, fn); deferred.resolve('Success');
return promise; $ionicLoading.show({ template: "Ride Offered", duration: 1000 });
} }).error(function(responseData) {
return promise; console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData));
}, deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
BarangayInformation: function(data) { });
console.log("****** ON ENTER BARANGAY DATA SERVICE ******");
promise.success = function(fn) {
var deferred = $q.defer(); promise.then(fn);
var promise = deferred.promise; return promise;
}
console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data)); promise.error = function(fn) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); promise.then(null, fn);
return promise;
var selectedBarangay = { }
"barangay": data.barangay, return promise;
"time": data.time },
};
BarangayInformation: function(data) {
$http({method: 'POST', url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php', console.log("****** ON ENTER BARANGAY DATA SERVICE ******");
data: $.param(selectedBarangay),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} var deferred = $q.defer();
}).success(function(responseData) { var promise = deferred.promise;
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData); console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data));
$ionicLoading.hide(); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
return responseData;
}).error(function(responseData) { var selectedBarangay = {
console.error("[ ERROR ]", JSON.stringify(responseData)); "barangay": data.barangay,
deferred.reject('Error'); "time": data.time
};
$ionicLoading.show({ template: "Request Error!", duration: 1000});
}); $http({
method: 'POST',
promise.success = function(fn) { url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php',
promise.then(fn); data: $.param(selectedBarangay),
return promise; headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
} }).success(function(responseData) {
promise.error = function(fn) { console.log("[ SUCCESS ]", JSON.stringify(responseData));
promise.then(null, fn); deferred.resolve(responseData);
return promise; $ionicLoading.hide();
} return responseData;
return promise; }).error(function(responseData) {
}, console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
ForgotPassword: function(data) {
console.log("****** ON ENTER FORGOT PASSWORD SERVICE ******"); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
var deferred = $q.defer();
var promise = deferred.promise; promise.success = function(fn) {
promise.then(fn);
console.log("[ EMAIL DATA ] -> ", JSON.stringify(data)); return promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); }
var emailData = { promise.error = function(fn) {
"email_address": data.email_address, promise.then(null, fn);
}; return promise;
$http({method: 'POST', url: 'http://blaze.eacomm.com/send_password.php', }
data: $.param(emailData), return promise;
headers : {'Content-Type': 'application/x-www-form-urlencoded'} },
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); ForgotPassword: function(data) {
deferred.resolve('Success'); console.log("****** ON ENTER FORGOT PASSWORD SERVICE ******");
$ionicLoading.show({ template: "Success!", duration: 1000}); var deferred = $q.defer();
}).error(function(responseData) { var promise = deferred.promise;
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); console.log("[ EMAIL DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
$ionicLoading.show({ template: "Request Error!", duration: 1000}); var emailData = {
}); "email_address": data.email_address,
};
promise.success = function(fn) { $http({
promise.then(fn); method: 'POST',
return promise; url: 'http://blaze.eacomm.com/send_password.php',
} data: $.param(emailData),
promise.error = function(fn) { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
promise.then(null, fn); }).success(function(responseData) {
return promise; console.log("[ SUCCESS ]", JSON.stringify(responseData));
} deferred.resolve('Success');
return promise;
}, $ionicLoading.show({ template: "Success!", duration: 1000 });
}).error(function(responseData) {
} console.error("[ ERROR ]", JSON.stringify(responseData));
}) deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
/******************** API V2 *********************/
UserSummary: function(data) {
console.log("****** ON ENTER USER SUMMARY SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"user_id": data.user_id,
"username": data.username
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/get_summary',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
GetTripDetails: function(data) {
console.log("****** ON ENTER TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"date": data.date
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/get_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
LogTripV2: function(data) {
console.log("****** ON ENTER LOG TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"origin": data.origin,
"destination": data.destination,
"username": data.username,
"type": data.type,
"datecreated": data.datecreated,
"depart": data.depart,
"arrive": data.arrive,
"mode": data.mode,
"exp": data.exp,
"emotion": data.emotion,
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/add_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
UpdateTrip: function(data) {
console.log("****** ON ENTER UPDATE TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"trip_uploads_id": data.trip_uploads_id,
"origin": data.origin,
"destination": data.destination,
"username": data.username,
"type": data.type,
"datecreated": data.datecreated,
"depart": data.depart,
"arrive": data.arrive,
"mode": data.mode,
"exp": data.exp,
"emotion": data.emotion,
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/update_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
NoTrip: function(data) {
console.log("****** ON ENTER NO TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"id": data.id,
"mode": data.mode,
"date": data.date, // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/no_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
VerifyTrip: function(data) {
console.log("****** ON ENTER VERIFY TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"date": data.date, // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/verify',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
HometoSchoolTravelTimes: function(data) {
console.log("****** ON ENTER HOME TO SCHOOL TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"start_date": data.start_date, // YYYY-MM-DD
"end_date": data.end_date // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/get_home_to_school_travel_time',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
TripLogGraph: function(data) {
console.log("****** ON ENTER TRIP LOG GRAPH DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"month": data.month, // YYYY-MM-DD
"year": data.year // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/trip_log_graph',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
PerformanceSummary: function(data) {
console.log("****** ON ENTER PERFORMANCE SUMMARY DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"user_id": data.user_id,
"date": data.date, // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/performance',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
/*********** MAP DIRECTIVES ***********/
.service('LocationService', function($q){
var autocompleteService = new google.maps.places.AutocompleteService();
var detailsService = new google.maps.places.PlacesService(document.createElement("input"));
return {
searchAddress: function(input) {
var deferred = $q.defer();
autocompleteService.getPlacePredictions({
input: input
}, function(result, status) {
if(status == google.maps.places.PlacesServiceStatus.OK){
console.log(status);
deferred.resolve(result);
}else{
deferred.reject(status)
}
});
return deferred.promise;
},
getDetails: function(placeId) {
var deferred = $q.defer();
detailsService.getDetails({placeId: placeId}, function(result) {
deferred.resolve(result);
});
return deferred.promise;
} }
};
}) })
.directive('locationSuggestion', function($ionicModal, LocationService){
return { /*********** MAP DIRECTIVES ***********/
restrict: 'A', .service('LocationService', function($q) {
scope: { var autocompleteService = new google.maps.places.AutocompleteService();
location: '=' var detailsService = new google.maps.places.PlacesService(document.createElement("input"));
}, return {
link: function($scope, element){ searchAddress: function(input) {
console.log('locationSuggestion started!'); var deferred = $q.defer();
$scope.search = {};
$scope.search.suggestions = []; autocompleteService.getPlacePredictions({
$scope.search.query = ""; input: input
$ionicModal.fromTemplateUrl('app/offerride/popover/location.html', { }, function(result, status) {
scope: $scope, if (status == google.maps.places.PlacesServiceStatus.OK) {
focusFirstInput: true console.log(status);
}).then(function(modal) { deferred.resolve(result);
$scope.modal = modal; } else {
}); deferred.reject(status)
element[0].addEventListener('focus', function(event) { }
$scope.open(); });
});
$scope.$watch('search.query', function(newValue) { return deferred.promise;
if (newValue) { },
LocationService.searchAddress(newValue).then(function(result) { getDetails: function(placeId) {
$scope.search.error = null; var deferred = $q.defer();
$scope.search.suggestions = result; detailsService.getDetails({ placeId: placeId }, function(result) {
}, function(status){ deferred.resolve(result);
$scope.search.error = "There was an error :( " + status; });
}); return deferred.promise;
}; }
$scope.open = function() {
$scope.modal.show();
};
$scope.close = function() {
$scope.modal.hide();
};
$scope.choosePlace = function(place) {
LocationService.getDetails(place.place_id).then(function(location) {
$scope.location = location;
$scope.close();
});
}; };
}); })
} .directive('locationSuggestion', function($ionicModal, LocationService) {
} return {
}) restrict: 'A',
; scope: {
location: '='
},
link: function($scope, element) {
console.log('locationSuggestion started!');
$scope.search = {};
$scope.search.suggestions = [];
$scope.search.query = "";
$ionicModal.fromTemplateUrl('app/offerride/popover/location.html', {
scope: $scope,
focusFirstInput: true
}).then(function(modal) {
$scope.modal = modal;
});
element[0].addEventListener('focus', function(event) {
$scope.open();
});
$scope.$watch('search.query', function(newValue) {
if (newValue) {
LocationService.searchAddress(newValue).then(function(result) {
$scope.search.error = null;
$scope.search.suggestions = result;
}, function(status) {
$scope.search.error = "There was an error :( " + status;
});
};
$scope.open = function() {
$scope.modal.show();
};
$scope.close = function() {
$scope.modal.hide();
};
$scope.choosePlace = function(place) {
LocationService.getDetails(place.place_id).then(function(location) {
$scope.location = location;
$scope.close();
});
};
});
}
}
});
\ No newline at end of file
var blazerAPI = 'http://blaze.eacomm.com/api'; var blazerAPI = 'http://blaze.eacomm.com/api';
var appVersion = '1.0.0'; var blazerAPI_V2 = 'http://blaze.eacomm.com/api_v2';
var buildNumber = '1.0.0'; var appVersion = '2.0.0';
var buildNumber = '0.0.1';
var maplayer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var maplayer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
// 'https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiemVyb2Rlbm5pcyIsImEiOiJjaXNjeGxheWkwMDJtMm52bzMzd2lyNmZ4In0.IkVfNZVJ6eE8WCssMvrJiA' // 'https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiemVyb2Rlbm5pcyIsImEiOiJjaXNjeGxheWkwMDJtMm52bzMzd2lyNmZ4In0.IkVfNZVJ6eE8WCssMvrJiA'
\ No newline at end of file
(function (factory) { (function(factory) {
'use strict'; 'use strict';
if (typeof exports === 'object') { if (typeof exports === 'object') {
// Node/CommonJS // Node/CommonJS
module.exports = factory( module.exports = factory(
typeof angular !== 'undefined' ? angular : require('angular'), typeof angular !== 'undefined' ? angular : require('angular'),
typeof Chart !== 'undefined' ? Chart : require('chart.js')); typeof Chart !== 'undefined' ? Chart : require('chart.js'));
} else if (typeof define === 'function' && define.amd) { } else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module. // AMD. Register as an anonymous module.
define(['angular', 'chart'], factory); define(['angular', 'chart'], factory);
} else { } else {
// Browser globals // Browser globals
factory(angular, Chart); factory(angular, Chart);
} }
}(function (angular, Chart) { }(function(angular, Chart) {
'use strict'; 'use strict';
Chart.defaults.global.responsive = true; Chart.defaults.global.responsive = true;
Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>';
Chart.defaults.global.colours = [ Chart.defaults.global.colours = [
'#97BBCD', // blue '#97BBCD', // blue
'#DCDCDC', // light grey '#DCDCDC', // light grey
'#F7464A', // red '#F7464A', // red
'#46BFBD', // green '#46BFBD', // green
'#FDB45C', // yellow '#FDB45C', // yellow
'#949FB1', // grey '#949FB1', // grey
'#4D5360' // dark grey '#4D5360' // dark grey
]; ];
var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' && var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' &&
window.G_vmlCanvasManager !== null && window.G_vmlCanvasManager !== null &&
typeof window.G_vmlCanvasManager.initElement === 'function'; typeof window.G_vmlCanvasManager.initElement === 'function';
if (usingExcanvas) Chart.defaults.global.animation = false; if (usingExcanvas) Chart.defaults.global.animation = false;
return angular.module('chart.js', []) return angular.module('chart.js', [])
.provider('ChartJs', ChartJsProvider) .provider('ChartJs', ChartJsProvider)
.factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory]) .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory])
.directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }]) .directive('chartBase', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory(); }])
.directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Line'); }]) .directive('chartLine', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Line'); }])
.directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Bar'); }]) .directive('chartBar', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Bar'); }])
.directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Radar'); }]) .directive('chartRadar', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Radar'); }])
.directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Doughnut'); }]) .directive('chartDoughnut', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Doughnut'); }])
.directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Pie'); }]) .directive('chartPie', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Pie'); }])
.directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('PolarArea'); }]); .directive('chartPolarArea', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('PolarArea'); }]);
/**
* Wrapper for chart.js
* Allows configuring chart js using the provider
*
* angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) {
* ChartJsProvider.setOptions({ responsive: true });
* ChartJsProvider.setOptions('Line', { responsive: false });
* })))
*/
function ChartJsProvider () {
var options = {};
var ChartJs = {
Chart: Chart,
getOptions: function (type) {
var typeOptions = type && options[type] || {};
return angular.extend({}, options, typeOptions);
}
};
/** /**
* Allow to set global options during configuration * Wrapper for chart.js
* Allows configuring chart js using the provider
*
* angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) {
* ChartJsProvider.setOptions({ responsive: true });
* ChartJsProvider.setOptions('Line', { responsive: false });
* })))
*/ */
this.setOptions = function (type, customOptions) { function ChartJsProvider() {
// If no type was specified set option for the global object var options = {};
if (! customOptions) { var ChartJs = {
customOptions = type; Chart: Chart,
options = angular.extend(options, customOptions); getOptions: function(type) {
return; var typeOptions = type && options[type] || {};
} return angular.extend({}, options, typeOptions);
// Set options for the specific chart
options[type] = angular.extend(options[type] || {}, customOptions);
};
this.$get = function () {
return ChartJs;
};
}
function ChartJsFactory (ChartJs, $timeout) {
return function chart (type) {
return {
restrict: 'CA',
scope: {
data: '=?',
labels: '=?',
options: '=?',
series: '=?',
colours: '=?',
getColour: '=?',
chartType: '=',
legend: '@',
click: '=?',
hover: '=?',
chartData: '=?',
chartLabels: '=?',
chartOptions: '=?',
chartSeries: '=?',
chartColours: '=?',
chartLegend: '@',
chartClick: '=?',
chartHover: '=?'
},
link: function (scope, elem/*, attrs */) {
var chart, container = document.createElement('div');
container.className = 'chart-container';
elem.replaceWith(container);
container.appendChild(elem[0]);
if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar (fromName, toName) {
scope.$watch(fromName, function (newVal) {
if (typeof newVal === 'undefined') return;
scope[toName] = newVal;
});
}
/* provide backward compatibility to "old" directive names, by
* having an alias point from the new names to the old names. */
aliasVar('chartData', 'data');
aliasVar('chartLabels', 'labels');
aliasVar('chartOptions', 'options');
aliasVar('chartSeries', 'series');
aliasVar('chartColours', 'colours');
aliasVar('chartLegend', 'legend');
aliasVar('chartClick', 'click');
aliasVar('chartHover', 'hover');
// Order of setting "watch" matter
scope.$watch('data', function (newVal, oldVal) {
if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) return;
var chartType = type || scope.chartType;
if (! chartType) return;
if (chart) {
if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem);
chart.destroy();
} }
};
createChart(chartType);
}, true); /**
* Allow to set global options during configuration
scope.$watch('series', resetChart, true); */
scope.$watch('labels', resetChart, true); this.setOptions = function(type, customOptions) {
scope.$watch('options', resetChart, true); // If no type was specified set option for the global object
scope.$watch('colours', resetChart, true); if (!customOptions) {
customOptions = type;
scope.$watch('chartType', function (newVal, oldVal) { options = angular.extend(options, customOptions);
if (isEmpty(newVal)) return; return;
if (angular.equals(newVal, oldVal)) return;
if (chart) chart.destroy();
createChart(newVal);
});
scope.$on('$destroy', function () {
if (chart) chart.destroy();
});
function resetChart (newVal, oldVal) {
if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return;
var chartType = type || scope.chartType;
if (! chartType) return;
// chart.update() doesn't work for series and labels
// so we have to re-create the chart entirely
if (chart) chart.destroy();
createChart(chartType);
}
function createChart (type) {
if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) {
return $timeout(function () {
createChart(type);
}, 50, false);
} }
if (! scope.data || ! scope.data.length) return; // Set options for the specific chart
scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour; options[type] = angular.extend(options[type] || {}, customOptions);
scope.colours = getColours(type, scope); };
var cvs = elem[0], ctx = cvs.getContext('2d');
var data = Array.isArray(scope.data[0]) ?
getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :
getData(scope.labels, scope.data, scope.colours);
var options = angular.extend({}, ChartJs.getOptions(type), scope.options);
chart = new ChartJs.Chart(ctx)[type](data, options);
scope.$emit('create', chart);
// Bind events
cvs.onclick = scope.click ? getEventHandler(scope, chart, 'click', false) : angular.noop;
cvs.onmousemove = scope.hover ? getEventHandler(scope, chart, 'hover', true) : angular.noop;
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); this.$get = function() {
} return ChartJs;
};
function deprecated (attr) { }
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log; function ChartJsFactory(ChartJs, $timeout) {
if (!! scope[attr]) { return function chart(type) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' + return {
'Please use "chart-%s" instead.', attr, attr); restrict: 'CA',
} scope: {
data: '=?',
labels: '=?',
options: '=?',
series: '=?',
colours: '=?',
getColour: '=?',
chartType: '=',
legend: '@',
click: '=?',
hover: '=?',
chartData: '=?',
chartLabels: '=?',
chartOptions: '=?',
chartSeries: '=?',
chartColours: '=?',
chartLegend: '@',
chartClick: '=?',
chartHover: '=?'
},
link: function(scope, elem /*, attrs */ ) {
var chart, container = document.createElement('div');
container.className = 'chart-container';
elem.replaceWith(container);
container.appendChild(elem[0]);
if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar(fromName, toName) {
scope.$watch(fromName, function(newVal) {
if (typeof newVal === 'undefined') return;
scope[toName] = newVal;
});
}
/* provide backward compatibility to "old" directive names, by
* having an alias point from the new names to the old names. */
aliasVar('chartData', 'data');
aliasVar('chartLabels', 'labels');
aliasVar('chartOptions', 'options');
aliasVar('chartSeries', 'series');
aliasVar('chartColours', 'colours');
aliasVar('chartLegend', 'legend');
aliasVar('chartClick', 'click');
aliasVar('chartHover', 'hover');
// Order of setting "watch" matter
scope.$watch('data', function(newVal, oldVal) {
if (!newVal || !newVal.length || (Array.isArray(newVal[0]) && !newVal[0].length)) return;
var chartType = type || scope.chartType;
if (!chartType) return;
if (chart) {
if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem);
chart.destroy();
}
createChart(chartType);
}, true);
scope.$watch('series', resetChart, true);
scope.$watch('labels', resetChart, true);
scope.$watch('options', resetChart, true);
scope.$watch('colours', resetChart, true);
scope.$watch('chartType', function(newVal, oldVal) {
if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return;
if (chart) chart.destroy();
createChart(newVal);
});
scope.$on('$destroy', function() {
if (chart) chart.destroy();
});
function resetChart(newVal, oldVal) {
if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return;
var chartType = type || scope.chartType;
if (!chartType) return;
// chart.update() doesn't work for series and labels
// so we have to re-create the chart entirely
if (chart) chart.destroy();
createChart(chartType);
}
function createChart(type) {
if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) {
return $timeout(function() {
createChart(type);
}, 50, false);
}
if (!scope.data || !scope.data.length) return;
scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour;
scope.colours = getColours(type, scope);
var cvs = elem[0],
ctx = cvs.getContext('2d');
var data = Array.isArray(scope.data[0]) ?
getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :
getData(scope.labels, scope.data, scope.colours);
var options = angular.extend({}, ChartJs.getOptions(type), scope.options);
chart = new ChartJs.Chart(ctx)[type](data, options);
scope.$emit('create', chart);
// Bind events
cvs.onclick = scope.click ? getEventHandler(scope, chart, 'click', false) : angular.noop;
cvs.onmousemove = scope.hover ? getEventHandler(scope, chart, 'hover', true) : angular.noop;
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
}
function deprecated(attr) {
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log;
if (!!scope[attr]) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' +
'Please use "chart-%s" instead.', attr, attr);
}
}
}
}
};
};
function canUpdateChart(newVal, oldVal) {
if (newVal && oldVal && newVal.length && oldVal.length) {
return Array.isArray(newVal[0]) ?
newVal.length === oldVal.length && newVal.every(function(element, index) {
return element.length === oldVal[index].length;
}) :
oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;
} }
} return false;
} }
};
};
function canUpdateChart (newVal, oldVal) {
if (newVal && oldVal && newVal.length && oldVal.length) {
return Array.isArray(newVal[0]) ?
newVal.length === oldVal.length && newVal.every(function (element, index) {
return element.length === oldVal[index].length; }) :
oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;
}
return false;
}
function sum (carry, val) { function sum(carry, val) {
return carry + val; return carry + val;
} }
function getEventHandler (scope, chart, action, triggerOnlyOnChange) { function getEventHandler(scope, chart, action, triggerOnlyOnChange) {
var lastState = null; var lastState = null;
return function (evt) { return function(evt) {
var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent; var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent;
if (atEvent) { if (atEvent) {
var activePoints = atEvent.call(chart, evt); var activePoints = atEvent.call(chart, evt);
if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) { if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) {
lastState = activePoints; lastState = activePoints;
scope[action](activePoints, evt); scope[action](activePoints, evt);
scope.$apply(); scope.$apply();
} }
}
};
} }
};
}
function getColours (type, scope) { function getColours(type, scope) {
var colours = angular.copy(scope.colours || var colours = angular.copy(scope.colours ||
ChartJs.getOptions(type).colours || ChartJs.getOptions(type).colours ||
Chart.defaults.global.colours Chart.defaults.global.colours
); );
while (colours.length < scope.data.length) { while (colours.length < scope.data.length) {
colours.push(scope.getColour()); colours.push(scope.getColour());
} }
return colours.map(convertColour); return colours.map(convertColour);
} }
function convertColour (colour) { function convertColour(colour) {
if (typeof colour === 'object' && colour !== null) return colour; if (typeof colour === 'object' && colour !== null) return colour;
if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1))); if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1)));
return getRandomColour(); return getRandomColour();
} }
function getRandomColour () { function getRandomColour() {
var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)]; var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)];
return getColour(colour); return getColour(colour);
} }
function getColour (colour) { function getColour(colour) {
return { return {
fillColor: rgba(colour, 0.2), fillColor: rgba(colour, 0.2),
strokeColor: rgba(colour, 1), strokeColor: rgba(colour, 1),
pointColor: rgba(colour, 1), pointColor: rgba(colour, 1),
pointStrokeColor: '#fff', pointStrokeColor: '#fff',
pointHighlightFill: '#fff', pointHighlightFill: '#fff',
pointHighlightStroke: rgba(colour, 0.8) pointHighlightStroke: rgba(colour, 0.8)
}; };
} }
function getRandomInt (min, max) { function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min; return Math.floor(Math.random() * (max - min + 1)) + min;
} }
function rgba (colour, alpha) { function rgba(colour, alpha) {
if (usingExcanvas) { if (usingExcanvas) {
// rgba not supported by IE8 // rgba not supported by IE8
return 'rgb(' + colour.join(',') + ')'; return 'rgb(' + colour.join(',') + ')';
} else { } else {
return 'rgba(' + colour.concat(alpha).join(',') + ')'; return 'rgba(' + colour.concat(alpha).join(',') + ')';
} }
} }
// Credit: http://stackoverflow.com/a/11508164/1190235 // Credit: http://stackoverflow.com/a/11508164/1190235
function hexToRgb (hex) { function hexToRgb(hex) {
var bigint = parseInt(hex, 16), var bigint = parseInt(hex, 16),
r = (bigint >> 16) & 255, r = (bigint >> 16) & 255,
g = (bigint >> 8) & 255, g = (bigint >> 8) & 255,
b = bigint & 255; b = bigint & 255;
return [r, g, b]; return [r, g, b];
} }
function getDataSets (labels, data, series, colours) { function getDataSets(labels, data, series, colours) {
return { return {
labels: labels, labels: labels,
datasets: data.map(function (item, i) { datasets: data.map(function(item, i) {
return angular.extend({}, colours[i], { return angular.extend({}, colours[i], {
label: series[i], label: series[i],
data: item data: item
}); });
}) })
}; };
} }
function getData (labels, data, colours) { function getData(labels, data, colours) {
return labels.map(function (label, i) { return labels.map(function(label, i) {
return angular.extend({}, colours[i], { return angular.extend({}, colours[i], {
label: label, label: label,
value: data[i], value: data[i],
color: colours[i].strokeColor, color: colours[i].strokeColor,
highlight: colours[i].pointHighlightStroke highlight: colours[i].pointHighlightStroke
}); });
}); });
} }
function setLegend (elem, chart) { function setLegend(elem, chart) {
var $parent = elem.parent(), var $parent = elem.parent(),
$oldLegend = $parent.find('chart-legend'), $oldLegend = $parent.find('chart-legend'),
legend = '<chart-legend>' + chart.generateLegend() + '</chart-legend>'; legend = '<chart-legend>' + chart.generateLegend() + '</chart-legend>';
if ($oldLegend.length) $oldLegend.replaceWith(legend); if ($oldLegend.length) $oldLegend.replaceWith(legend);
else $parent.append(legend); else $parent.append(legend);
} }
function updateChart (chart, values, scope, elem) { function updateChart(chart, values, scope, elem) {
if (Array.isArray(scope.data[0])) { if (Array.isArray(scope.data[0])) {
chart.datasets.forEach(function (dataset, i) { chart.datasets.forEach(function(dataset, i) {
(dataset.points || dataset.bars).forEach(function (dataItem, j) { (dataset.points || dataset.bars).forEach(function(dataItem, j) {
dataItem.value = values[i][j]; dataItem.value = values[i][j];
}); });
}); });
} else { } else {
chart.segments.forEach(function (segment, i) { chart.segments.forEach(function(segment, i) {
segment.value = values[i]; segment.value = values[i];
}); });
} }
chart.update(); chart.update();
scope.$emit('update', chart); scope.$emit('update', chart);
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
} }
function isEmpty (value) { function isEmpty(value) {
return ! value || return !value ||
(Array.isArray(value) && ! value.length) || (Array.isArray(value) && !value.length) ||
(typeof value === 'object' && ! Object.keys(value).length); (typeof value === 'object' && !Object.keys(value).length);
} }
function isResponsive (type, scope) { function isResponsive(type, scope) {
var options = angular.extend({}, Chart.defaults.global, ChartJs.getOptions(type), scope.options); var options = angular.extend({}, Chart.defaults.global, ChartJs.getOptions(type), scope.options);
return options.responsive; return options.responsive;
}
} }
} }));
})); \ No newline at end of file
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '',
opacity: 1,
continuousWorld: false,
noWrap: false,
},
// Possible types: SATELLITE, ROADMAP, HYBRID
initialize: function(type, options) {
L.Util.setOptions(this, options);
this._type = google.maps.MapTypeId[type || 'SATELLITE'];
},
onAdd: function(map, insertAtTheBottom) {
this._map = map;
this._insertAtTheBottom = insertAtTheBottom;
// create a container div for tiles
this._initContainer();
this._initMapObject();
// set up events
map.on('viewreset', this._resetCallback, this);
this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);
map.on('move', this._update, this);
//map.on('moveend', this._update, this);
this._reset();
this._update();
},
onRemove: function(map) {
this._map._container.removeChild(this._container);
//this._container = null;
this._map.off('viewreset', this._resetCallback, this);
this._map.off('move', this._update, this);
//this._map.off('moveend', this._update, this);
},
getAttribution: function() {
return this.options.attribution;
},
setOpacity: function(opacity) {
this.options.opacity = opacity;
if (opacity < 1) {
L.DomUtil.setOpacity(this._container, opacity);
}
},
_initContainer: function() {
var tilePane = this._map._container
first = tilePane.firstChild;
if (!this._container) {
this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
this._container.id = "_GMapContainer";
}
if (true) {
tilePane.insertBefore(this._container, first);
this.setOpacity(this.options.opacity);
var size = this._map.getSize();
this._container.style.width = size.x + 'px';
this._container.style.height = size.y + 'px';
}
},
_initMapObject: function() {
this._google_center = new google.maps.LatLng(0, 0);
var map = new google.maps.Map(this._container, {
center: this._google_center,
zoom: 0,
mapTypeId: this._type,
disableDefaultUI: true,
keyboardShortcuts: false,
draggable: false,
disableDoubleClickZoom: true,
scrollwheel: false,
streetViewControl: false
});
var _this = this;
this._reposition = google.maps.event.addListenerOnce(map, "center_changed",
function() { _this.onReposition(); });
map.backgroundColor = '#ff0000';
this._google = map;
},
_resetCallback: function(e) {
this._reset(e.hard);
},
_reset: function(clearOldContainer) {
this._initContainer();
},
_update: function() {
this._resize();
var bounds = this._map.getBounds();
var ne = bounds.getNorthEast();
var sw = bounds.getSouthWest();
var google_bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(sw.lat, sw.lng),
new google.maps.LatLng(ne.lat, ne.lng)
);
var center = this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._google.setCenter(_center);
this._google.setZoom(this._map.getZoom());
//this._google.fitBounds(google_bounds);
},
_resize: function() {
var size = this._map.getSize();
if (this._container.style.width == size.x &&
this._container.style.height == size.y)
return;
this._container.style.width = size.x + 'px';
this._container.style.height = size.y + 'px';
google.maps.event.trigger(this._google, "resize");
},
onReposition: function() {
//google.maps.event.trigger(this._google, "resize");
}
});
\ No newline at end of file
<ion-view view-title="My Trip Diary" ng-init="loadComparisonMessages();">
<ion-nav-buttons side="right">
</ion-nav-buttons>
<ion-content padding="true">
<ion-refresher pulling-text="Pull to refresh" on-refresh="loadComparisonMessages(); clearGraphs();"></ion-refresher>
<div class="card">
<div class="item item-header item-clear bgbluegreen text-light"> Comparison Message </div>
<div class="item item-body">
<p>Some Interesting Facts:</p>
<p>"Your shortest travel time is {{comparisonMessage.best_time}} minutes."</p>
<p>"Your worst travel time is {{comparisonMessage.worst_time}} minutes."</p>
<p>"By comparison, {{comparisonMessage.zero_car_user}} who lives in the same area as you do achieved the shortest travel time of {{comparisonMessage.best_near_car_blazer}} minutes."</p>
</div>
</form>
</div>
<div class="card">
<div class="item item-header item-clear bgbluegreen text-light"> Home to School Travel Times </div>
<div class="item">
<form name="form_1">
<label class="item item-input">
<span class="input-label">Start Date:</span>
<input type="date" ng-model="request.start_date" required>
</label>
<label class="item item-input">
<span class="input-label">End Date:</span>
<input type="date" ng-model="request.end_date" required>
</label>
<button class="button button-block button-dark button-outline" ng-disabled="form_1.$invalid" ng-click="loadHometoSchoolTravel();"> Show </button>
</div>
<div class="item item-body">
<p>Range: {{request.start_date | date:'mediumDate'}} - {{request.end_date | date:'mediumDate'}}</p>
<canvas id="line" class="chart chart-line" chart-data="htsdata" chart-labels="htslabels" chart-options="options" chart-dataset-override="datasetOverride" chart-click="onClick"></canvas>
</div>
</form>
</div>
<div class="card">
<div class="item item-header item-clear bgbluegreen text-light"> Mode Use by Trips </div>
<div class="item item-body">
<form name="form_2">
<label class="item item-input">
<span class="input-label">Start Date:</span>
<input type="date" ng-model="requestMode.start_date" required>
</label>
<label class="item item-input">
<span class="input-label">End Date:</span>
<input type="date" ng-model="requestMode.end_date" required>
</label>
<button class="button button-block button-dark button-outline" ng-disabled="form_2.$invalid" ng-click="loadModeUseTravel();"> Show </button>
</div>
<div class="item item-body">
<p>Range: {{requestMode.start_date | date:'mediumDate'}} - {{requestMode.end_date | date:'mediumDate'}}</p>
<canvas id="pie" class="chart chart-pie" chart-data="hmadata" chart-labels="hmalabels"></canvas>
</div>
</div>
</ion-content>
</ion-view>
\ No newline at end of file
angular.module('blazer.diarycontrollers', [])
.controller('DiaryCtrl', function($scope, $filter, getBlazer, postBlazer) {
$scope.request = {};
$scope.travelData = {};
$scope.htslabels = {};
$scope.htsdata = {};
$scope.loadHometoSchoolTravel = function() {
$scope.htslabels = [];
$scope.htsdata = [];
var request = {
username: localStorage.getItem("username"),
start_date: $filter('date')($scope.request.start_date, 'yyyy-MM-dd'),
end_date: $filter('date')($scope.request.end_date, 'yyyy-MM-dd'),
}
postBlazer.HometoSchoolTravelTimes(request)
.success(function(response) {
console.log("HOME TO SCHOOL DATA", JSON.stringify(response));
$scope.travelData = response.travel_times;
$scope.htslabels = [];
$scope.htsdata = [];
for (var i = 0; i < $scope.travelData.length; i++) {
console.log("[ PARSED DATA ]", JSON.stringify($scope.travelData[i]));
var string_data = $scope.travelData[i].date;
$scope.htslabels.push([string_data.toString()]);
$scope.htsdata.push([$scope.travelData[i].time]);
}
console.log(JSON.stringify($scope.htslabels));
console.log(JSON.stringify($scope.htsdata));
})
.error(function(response) {
console.error("HOME TO SCHOOL ERROR", response);
});
}
$scope.requestMode = {};
$scope.hmadata = [];
$scope.hmalabels = [];
$scope.loadModeUseTravel = function() {
$scope.hmadata = [];
$scope.hmalabels = [];
var requestMode = {
username: localStorage.getItem("username"),
start_date: $filter('date')($scope.request.start_date, 'yyyy-MM-dd'),
end_date: $filter('date')($scope.request.end_date, 'yyyy-MM-dd'),
}
getBlazer.getHowYouMoveAround(requestMode.start_date, requestMode.end_date, requestMode.username).then(function(data) {
console.log("[ TRAVEL MODE ]", JSON.stringify(data));
if (!data) {
$ionicLoading.show({ template: "No data for this request", duration: 1000 });
} else {
angular.forEach(data, function(value, key) {
$scope.hmalabels.push([key]);
$scope.hmadata.push(value);
});
console.log($scope.hmalabels);
console.log($scope.hmadata);
}
});
}
$scope.comparisonMessage = {};
$scope.loadComparisonMessages = function() {
$scope.$broadcast('scroll.refreshComplete');
var requestMode = {
username: localStorage.getItem("username")
}
getBlazer.getComparisonMessage(requestMode.username).then(function(data) {
console.log("[ TRAVEL MODE ]", JSON.stringify(data));
$scope.comparisonMessage = {
best_time: data.fact_1.best_time,
worst_time: data.fact_1.worst_time,
best_time_near: data.fact_1.best_time_near,
total_car_usage: data.fact_2.total_car_usage,
best_near_car_usage: data.fact_2.best_near_car_usage,
best_near_car_blazer: data.fact_2.best_near_car_blazer,
zero_car_user: data.fact_2.zero_car_user
}
});
}
$scope.clearGraphs = function() {
$scope.$broadcast('scroll.refreshComplete');
$scope.requestMode = {};
$scope.hmadata = [];
$scope.hmalabels = [];
$scope.request = {};
$scope.travelData = {};
$scope.htslabels = {};
$scope.htsdata = {};
}
});
\ No newline at end of file
...@@ -12,9 +12,14 @@ angular.module('blazer.mapcontrollers', []) ...@@ -12,9 +12,14 @@ angular.module('blazer.mapcontrollers', [])
} }
/* MAP DEFAULTS */ /* MAP DEFAULTS */
// var map = new L.map('mapid', { center: new L.LatLng(14.5818, 120.9771), zoom: 12 });
// var googleLayer = new L.Google('ROADMAP');
// map.addLayer(googleLayer);
//GOOGLE MAP
var map = L.map('mapid'); var map = L.map('mapid');
map.setView(new L.LatLng(14.5818, 120.9771), 12); map.setView(new L.LatLng(14.5818, 120.9771), 12);
//MAP BOX //LEAFLET
L.tileLayer(maplayer, { L.tileLayer(maplayer, {
maxZoom: 18, maxZoom: 18,
...@@ -388,6 +393,16 @@ angular.module('blazer.mapcontrollers', []) ...@@ -388,6 +393,16 @@ angular.module('blazer.mapcontrollers', [])
console.debug("********** Load Heat Map **********"); console.debug("********** Load Heat Map **********");
} }
/* Show Blazers Data */
$scope.blazersData = {};
$scope.getBlazersDataV2 = function() {
getBlazer.getMapData().then(function(data) {
$scope.blazersData = data;
console.log("[ Blazer Data V2 ]", JSON.stringify($scope.blazersData));
$scope.plotBlazers();
});
}
/* Show Blazers Data */ /* Show Blazers Data */
$scope.blazersData = {}; $scope.blazersData = {};
$scope.getBlazersData = function() { $scope.getBlazersData = function() {
...@@ -402,54 +417,86 @@ angular.module('blazer.mapcontrollers', []) ...@@ -402,54 +417,86 @@ angular.module('blazer.mapcontrollers', [])
var parsedData = []; var parsedData = [];
var geojsonLayer = []; var geojsonLayer = [];
$scope.plotBlazers = function() { $scope.plotBlazers = function() {
console.debug("********** Plot Blazers on Map **********"); console.debug("********** Plot Blazers on Map **********");
parsedData = []; parsedData = [];
angular.forEach($scope.blazersData, function(value, key) { angular.forEach($scope.blazersData, function(value, key) {
console.log("[ VALUE SCOPE ]", JSON.stringify(value)); console.log("[ VALUE SCOPE ]", JSON.stringify(value));
var formatData = { var formatData = {
"type": "Feature", "type": "Feature",
"properties": { "properties": {
"username": "Anonymous Blazer", "barangay_name": value.barangay_name,
"blazer_count": value.blazer_count,
"car_percentage": value.car_percentage,
}, },
"geometry": { "geometry": {
"type": "Point", "type": "Point",
"coordinates": [value.longitude, value.latitude] "coordinates": [value.lon, value.lat]
} }
} }
parsedData.push(formatData); parsedData.push(formatData);
}); });
// Map Icon Options
// ICON
// var iconOptions = L.icon({
// iconUrl: 'img/mapicon.png',
// iconSize: [35, 37],
// iconAnchor: [18, 2]
// });
// POINTS
var iconOptions = {
radius: 8,
fillColor: "green",
color: "green",
weight: 1,
opacity: 1,
fillOpacity: 0.8
};
// PLOT DATA // PLOT DATA
function onEachFeature(feature, layer) { function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.username) { if (feature.properties && feature.properties.barangay_name) {
layer.bindPopup('<div class="pop-up-containter">Blazer</h4><div style="font-size: 15px">' + feature.properties.username + '</div></div>'); layer.bindPopup('<div class="pop-up-containter">' + feature.properties.barangay_name + '</div>');
} }
} }
/*
The colors refer to the car percentage. If car percentage is above 50%, the color is shades of red (the redder, the closer to 100% car percentage). Yellow is 50%. Below 50%, then shades of green. Very green means 0% car use.
*/
/*
The size refers to the blazer count. If blaze count <= 20, then, small. If blazer count is more than or equal to 50, then size is big. Medium is between 20 and 50.
*/
geojsonLayer = L.geoJson(parsedData, { geojsonLayer = L.geoJson(parsedData, {
onEachFeature: onEachFeature, onEachFeature: onEachFeature,
pointToLayer: function(feature, latlng) { pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, iconOptions); var circle_radius = '';
var circle_fill = '';
var circle_opacity = '';
// RADIUS SETTER
if (parseInt(feature.properties.blazer_count) >= 50) {
console.log("BIG");
circle_radius = 500;
} else if (parseInt(feature.properties.blazer_count) < 50 && parseInt(feature.properties.blazer_count) > 20) {
console.log("MEDIUM");
circle_radius = 250;
} else if (parseInt(feature.properties.blazer_count) <= 20) {
console.log("SMALL");
circle_radius = 100;
}
// COLOR SETTER
if (feature.properties.car_percentage > 80) {
console.log("RED");
circle_fill = "red";
circle_opacity = 0.8;
} else if (feature.properties.car_percentage > 50 && feature.properties.car_percentage <= 80) {
console.log("LIGHT RED");
circle_fill = "red";
circle_opacity = 0.3;
} else if (feature.properties.car_percentage <= 50 && feature.properties.car_percentage >= 30) {
console.log("YELLOW");
circle_fill = "yellow";
circle_opacity = 0.8;
} else if (feature.properties.car_percentage < 30 && feature.properties.car_percentage >= 20) {
console.log("LIGHT YELLOW");
circle_fill = "yellow";
circle_opacity = 0.3;
} else if (feature.properties.car_percentage < 20) {
circle_fill = "green";
circle_opacity = 0.8;
}
// return L.circleMarker(latlng, iconOptions);
return L.circle(latlng, circle_radius, {
color: '',
fillColor: circle_fill,
fillOpacity: circle_opacity,
})
} }
}).addTo(map); }).addTo(map);
map.fitBounds(geojsonLayer.getBounds()); map.fitBounds(geojsonLayer.getBounds());
...@@ -463,7 +510,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -463,7 +510,7 @@ angular.module('blazer.mapcontrollers', [])
var dayToday = $filter('date')(newDate, 'EEEE'); var dayToday = $filter('date')(newDate, 'EEEE');
console.log("[ Date Today ]", currentDate); console.log("[ Date Today ]", currentDate);
if (dayToday == 'Friday' || dayToday == 'Saturday') { if (dayToday == 'Friday' || dayToday == 'Saturday' || dayToday == 'Sunday') {
if (localStorage.getItem(currentDate) === null) { if (localStorage.getItem(currentDate) === null) {
var tripPopup = $ionicPopup.show({ var tripPopup = $ionicPopup.show({
title: 'Hey it\'s ' + dayToday + '!', title: 'Hey it\'s ' + dayToday + '!',
...@@ -497,30 +544,35 @@ angular.module('blazer.mapcontrollers', []) ...@@ -497,30 +544,35 @@ angular.module('blazer.mapcontrollers', [])
var dayToday = $filter('date')(newDate, 'EEEE'); var dayToday = $filter('date')(newDate, 'EEEE');
console.log("[ Date Today ]", currentDate); console.log("[ Date Today ]", currentDate);
if (localStorage.getItem(currentDate) === null) { if (dayToday == 'Friday' || dayToday == 'Saturday' || dayToday == 'Sunday') {
var tripPopup = $ionicPopup.show({ if (localStorage.getItem(currentDate) === null) {
title: 'Hey it\'s ' + dayToday + '!', var tripPopup = $ionicPopup.show({
subTitle: 'Take the weekly survey. You are awesome!', title: 'Hey it\'s ' + dayToday + '!',
scope: $scope, subTitle: 'Take the weekly survey. You are awesome!',
buttons: [{ scope: $scope,
text: 'Let\s go!', buttons: [{
type: 'button-dark button-outline', text: 'Let\s go!',
onTap: function(e) { type: 'button-dark button-outline',
console.log("[ TAKE WEEKLY SURVEY ]"); onTap: function(e) {
$scope.openWeeklySurvey(); console.log("[ TAKE WEEKLY SURVEY ]");
} $scope.openWeeklySurvey();
}, }
{ },
text: 'Later', {
type: 'button-dark button-outline', text: 'Later',
onTap: function(e) { type: 'button-dark button-outline',
console.log("[ NO WEEKLY SURVEY ]") onTap: function(e) {
console.log("[ NO WEEKLY SURVEY ]")
}
} }
} ]
] });
}); } else {
$cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY");
}
} else { } else {
$cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY"); console.log("Cannot Take Survey Today");
$cordovaDialogs.alert('Sorry. But you may only take the weekly survey on Friday, Saturday, or Sunday. Thank you.', 'Weekly Survey', "OKAY");
} }
} }
...@@ -551,7 +603,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -551,7 +603,7 @@ angular.module('blazer.mapcontrollers', [])
$scope.modalEndTrip.show(); $scope.modalEndTrip.show();
}; };
// Weekly Survey Modal // Weekly Survey Modal
$ionicModal.fromTemplateUrl('app/survey/weekly.html', { $ionicModal.fromTemplateUrl('app/survey/weekly_v2.html', {
scope: $scope, scope: $scope,
animation: 'slide-in-up' animation: 'slide-in-up'
}).then(function(modal) { }).then(function(modal) {
......
<ion-view view-title="BLAZE" ng-init="initializedLocateUser();loadWeeklySurvey();getAllBarangay();"> <ion-view view-title="BLAZE" ng-init="initializedLocateUser();loadWeeklySurvey();getAllBarangay();">
<ion-nav-buttons side="left"> <ion-nav-buttons side="left">
<button ng-click="openMenu()" class="button button-icon ion-android-menu" ng-disabled="tripStatus"></button> <button ng-click="openMenu()" class="button button-icon ion-android-menu" ng-disabled="tripStatus"></button>
</ion-nav-buttons> </ion-nav-buttons>
<ion-nav-buttons side="right"> <ion-nav-buttons side="right">
<button ng-click="openPopover($event);" class="button button-icon ion-android-apps" ng-disabled="tripStatus"></button> <button ng-click="openPopover($event);" class="button button-icon ion-android-apps" ng-disabled="tripStatus"></button>
</ion-nav-buttons> </ion-nav-buttons>
<ion-floating-button style='opacity: 0.8;'' click="refreshMap();" has-footer="true" button-color="#333333" icon="ion-android-refresh" icon-color="#fff" ng-hide="tripStatus"> <ion-floating-button style='opacity: 0.8;' click="refreshMap();" has-footer="true" button-color="#333333" icon="ion-android-refresh" icon-color="#fff" ng-hide="tripStatus">
</ion-floating-button> </ion-floating-button>
<div class="bar bar-subheader bar-clear darkblue item-input-inset"> <div class="bar bar-subheader bar-clear darkblue item-input-inset">
<a class="item-input-wrapper" ng-click="onLoadSelection();"> <a class="item-input-wrapper" ng-click="onLoadSelection();">
<i class="icon ion-ios-search placeholder-icon"></i> <i class="icon ion-ios-search placeholder-icon"></i>
<input type="text" placeholder="Search Barangay" ng-model="selectedBarangayData" disabled> <input type="text" placeholder="Search Barangay" ng-model="selectedBarangayData" disabled>
</a> </a>
<button class="button button-stable" style="color: #000000;" ng-click="loadBarangayData();" ng-disabled="!selectedBarangayData"> <button class="button button-stable" style="color: #000000;" ng-click="loadBarangayData();" ng-disabled="!selectedBarangayData">
Show Show
</button> </button>
</div> </div>
<ion-content class="has-subheader" data-tap-disabled="true"> <ion-content class="has-subheader" data-tap-disabled="true">
<div id="mapid"></div> <div id="mapid"></div>
</ion-content> </ion-content>
<ion-footer-bar align-title="center" class="bar bar-clear darkblue"> <ion-footer-bar align-title="center" class="bar bar-clear darkblue">
<div class="button-bar"> <div class="button-bar">
<div class="button-bar" ng-if="!tripStatus"> <div class="button-bar" ng-if="!tripStatus">
<button ng-click="confirmTripDestination();" class="button button-icon ion-android-arrow-dropright-circle light"> Start Trip</button> <button ng-click="confirmTripDestination();" class="button button-icon ion-android-arrow-dropright-circle light"> Start Trip</button>
</div> </div>
<div class="button-bar" ng-if="tripStatus"> <div class="button-bar" ng-if="tripStatus">
<button ng-click="tripEnd();" class="button button-icon ion-android-cancel stable"> Stop Trip</button> <button ng-click="tripEnd();" class="button button-icon ion-android-cancel stable"> Stop Trip</button>
</div> </div>
</div> </div>
</ion-footer-bar> </ion-footer-bar>
</ion-view> </ion-view>
\ No newline at end of file
<ion-popover-view class="fit"> <ion-popover-view class="fit">
<ion-content scroll="false"> <ion-content scroll="false">
<div class="list"> <div class="list">
<a ng-click="getBlazersData();closePopover($event);" class="item item-icon-left"> <a ng-click="getBlazersDataV2();closePopover($event);" class="item item-icon-left">
<i class="icon ion-android-pin"></i> <i class="icon ion-android-pin"></i> Show Blazers
Show Blazers </a>
</a> <a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left">
<!--<a ng-click="loadHeatMap();" class="item item-icon-left"> <i class="icon ion-android-clipboard"></i> Weekly Survey
<i class="icon ion-android-pin"></i> </a>
Load Heatmap </div>
</a>--> </ion-content>
<a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left"> </ion-popover-view>
<i class="icon ion-android-clipboard"></i> \ No newline at end of file
Weekly Survey
</a>
</div>
</ion-content>
</ion-popover-view>
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
<!-- <ion-item nav-clear menu-close href="#/app/offerride" class="item-icon item-icon-left"><i class="icon ion-android-car"></i>Offer a Ride</ion-item> --> <!-- <ion-item nav-clear menu-close href="#/app/offerride" class="item-icon item-icon-left"><i class="icon ion-android-car"></i>Offer a Ride</ion-item> -->
<ion-item nav-clear menu-close href="#/app/sharedride" class="item-icon item-icon-left"><i class="icon ion-android-contacts"></i>Shared Ride</ion-item> <ion-item nav-clear menu-close href="#/app/sharedride" class="item-icon item-icon-left"><i class="icon ion-android-contacts"></i>Shared Ride</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Travel Stats</ion-item> <ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Travel Stats</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>My Diary</ion-item> <ion-item nav-clear menu-close href="#/app/diary" class="item-icon item-icon-left"><i class="icon ion-bookmark"></i>My Trip Diary</ion-item>
<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-android-wifi"></i>Trip Logging</ion-item> <!--<ion-item nav-clear menu-close href="#/app/status" class="item-icon item-icon-left"><i class="icon ion-edit"></i>Trip Logging</ion-item>-->
<ion-item nav-clear menu-close href="#/app/about" class="item-icon item-icon-left"><i class="icon ion-android-bulb"></i>About</ion-item> <ion-item nav-clear menu-close href="#/app/about" class="item-icon item-icon-left"><i class="icon ion-android-bulb"></i>About</ion-item>
<ion-item nav-clear menu-close href="#/app/settings" class="item-icon item-icon-left"><i class="icon ion-android-settings"></i>Settings</ion-item> <ion-item nav-clear menu-close href="#/app/settings" class="item-icon item-icon-left"><i class="icon ion-android-settings"></i>Settings</ion-item>
</ion-content> </ion-content>
......
<ion-view view-title="Offer a Ride" ng-init="getUserLocation();"> <ion-view view-title="Offer a Ride" ng-init="getUserLocation();">
<ion-nav-buttons side="right"> <ion-nav-buttons side="right">
<!--<button class="button button-clear button-light" ng-click="resetOfferRide();" ng-disabled="setPosition == true">Referesh</button>--> <!--<button class="button button-clear button-light" ng-click="resetOfferRide();" ng-disabled="setPosition == true">Referesh</button>-->
</ion-nav-buttons> </ion-nav-buttons>
<ion-content data-tap-disabled="false"> <ion-content data-tap-disabled="false">
<form name="offerride"> <form name="offerride">
<div class="item item-divider"> Offer Ride </div> <div class="item item-divider"> Offer Ride </div>
<p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific point of Destination.</p> <p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific point of Destination.</p>
<div class="item item-divider item-light"> Destination </div> <div class="item item-divider item-light"> Destination </div>
<!--<label class="item item-input"> <!--<label class="item item-input">
<input type="text" placeholder="Destination Address" location-suggestion location="location" ng-model="location.formatted_address"> <input type="text" placeholder="Destination Address" location-suggestion location="location" ng-model="location.formatted_address">
</label>--> </label>-->
<div id="mapdestination"></div> <div id="mapdestination"></div>
<p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific Pick-up Location.</p> <p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific Pick-up Location.</p>
<div class="item item-divider item-light"> Pick-up Location (specify) </div> <div class="item item-divider item-light"> Pick-up Location (specify) </div>
<div id="mappickup"></div> <div id="mappickup"></div>
<div class="item item-stacked-label" ion-datetime-picker am-pm ng-model="offer.assembly" required> <div class="item item-stacked-label" ion-datetime-picker am-pm ng-model="offer.assembly" required>
<span class="input-label">Date and Time</span> <span class="input-label">Date and Time</span>
<p>{{offer.assembly| date: "MMMM dd, yyyy 'at' H:mm:ss a"}}</p> <p>{{offer.assembly| date: "MMMM dd, yyyy 'at' H:mm:ss a"}}</p>
</div> </div>
<label class="item item-input item-stacked-label border-bottom-select"> <label class="item item-input item-stacked-label border-bottom-select">
<span class="input-label"> Car Brand</span> <span class="input-label"> Car Brand</span>
</label> </label>
<label class="item item-input item-select border-top"> <label class="item item-input item-select border-top">
<div class="input-label"> <div class="input-label">
&nbsp; &nbsp;
</div> </div>
...@@ -70,14 +70,14 @@ ...@@ -70,14 +70,14 @@
<option value="Volvo">Volvo</option> <option value="Volvo">Volvo</option>
</select> </select>
</label> </label>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label">Plate Number</span> <span class="input-label">Plate Number</span>
<input type="text" ng-model="offer.platenumber" placeholder="ABC123 or ABCD123" max-length="8" ng-maxlength="7" required/> <input type="text" ng-model="offer.platenumber" placeholder="ABC123 or ABCD123" max-length="8" ng-maxlength="7" required/>
</label> </label>
<label class="item item-input item-stacked-label border-bottom-select"> <label class="item item-input item-stacked-label border-bottom-select">
<span class="input-label"> Capacity</span> <span class="input-label"> Capacity</span>
</label> </label>
<label class="item item-input item-select border-top"> <label class="item item-input item-select border-top">
<div class="input-label"> <div class="input-label">
&nbsp; &nbsp;
</div> </div>
...@@ -98,19 +98,19 @@ ...@@ -98,19 +98,19 @@
<option value="15">15 Seater</option> <option value="15">15 Seater</option>
</select> </select>
</label> </label>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label">Mobile Number</span> <span class="input-label">Mobile Number</span>
<input type="number" ng-model="offer.mobile" placeholder="(09)** *** ****" maxlength="11" ng-maxlength="11" required/> <input type="number" ng-model="offer.mobile" placeholder="(09)** *** ****" maxlength="11" ng-maxlength="11" required/>
</label> </label>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label"> Other Details</span> <span class="input-label"> Other Details</span>
<textarea type="text" placeholder="Fuel contribution" ng-model="offer.notes" style="height: 100px;"></textarea> <textarea type="text" placeholder="Fuel contribution" ng-model="offer.notes" style="height: 100px;"></textarea>
</label> </label>
<div class="padding"> <div class="padding">
<button class="button button-block button-dark button-outline" ng-disabled="offerride.$invalid" ng-click="offerRide(location);"> <button class="button button-block button-dark button-outline" ng-disabled="offerride.$invalid" ng-click="offerRide(location);">
Offer Ride Offer Ride
</button> </button>
</div> </div>
</form> </form>
</ion-content> </ion-content>
</ion-view> </ion-view>
\ No newline at end of file
<ion-view view-title="My Travel Stats" ng-init="getTravelStats();"> <ion-view view-title="My Travel Stats" ng-init="getTravelStats();">
<ion-nav-buttons side="right"> <ion-nav-buttons side="right">
</ion-nav-buttons> </ion-nav-buttons>
<ion-content> <ion-content>
<ion-refresher pulling-text="Pull to refresh" on-refresh="getTravelStats();"></ion-refresher> <ion-refresher pulling-text="Pull to refresh" on-refresh="getTravelStats();"></ion-refresher>
<div class="list"> <div class="list card">
<div class="item item-divider"> Mode of Use </div> <div class="item item-divider"> Mode of Use </div>
<div class="item"> <div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Latest</i> <i class="button button-block button-clear bgbluegreen text-light">Latest</i>
<i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_latest }}</b></i> <i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_latest }}</b></i>
<i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_latest }}</b></i> <i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_latest }}</b></i>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_latest}}</b></i>--> <!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_latest}}</b></i>-->
</div> </div>
<div class="item"> <div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Frequently Used</i> <i class="button button-block button-clear bgbluegreen text-light">Frequently Used</i>
<i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_frequent }}</b></i> <i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_frequent }}</b></i>
<i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent }}</b></i> <i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent }}</b></i>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_average}}</b></i>--> </div>
</div> <div class="item">
<div class="item"> <i class="button button-block button-clear bgbluegreen text-light">Low-Carbon</i>
<i class="button button-block button-clear bgbluegreen text-light">Low-Carbon</i> <i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_best }}</b></i>
<i class="button button-block icon-left ion-android-car"><b>{{ blazersStats.mode_best }}</b></i> <i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent_positive }}</b></i>
<i class="button button-block icon-left ion-android-bulb"><b>{{ blazersStats.emo_frequent_positive }}</b></i> </div>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_best}}</b></i>--> </div>
</div> <div class="list card">
<!--<div class="item item-thumbnail-left item-borderless"> <div class="item item-divider"> Time </div>
<img ng-src="img/info.png"> <div class="item">
<i> Latest </i> <i class="button button-block button-clear bgbluegreen text-light">Latest</i>
<p>Transportation: <i ng-if="!blazersStats.mode_latest">NULL</i>{{ blazersStats.mode_latest }}</p> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_latest }}</b></i>
<p>Mood: <i ng-if="!blazersStats.emo_latest">NULL</i>{{ blazersStats.emo_latest }}</p> </div>
</div> <div class="item">
<div class="item item-thumbnail-left item-borderless"> <i class="button button-block button-clear bgbluegreen text-light">Average</i>
<img ng-src="img/info.png"> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_average }}</b></i>
<i>Frequently Used</i> </div>
<p>Transportation: <i ng-if="!blazersStats.mode_frequent">NULL</i>{{ blazersStats.mode_frequent }}</p> <div class="item">
<p>Mood: <i ng-if="!blazersStats.emo_frequent">NULL</i>{{ blazersStats.emo_frequent }}</p> <i class="button button-block button-clear bgbluegreen text-light">Best</i>
</div> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_best }}</b></i>
<div class="item item-thumbnail-left item-borderless"> </div>
<img ng-src="img/info.png"> </div>
<i>Low-Carbon</i> </ion-content>
<p>Transportation: <i ng-if="!blazersStats.mode_best">NULL</i>{{ blazersStats.mode_best }}</p> </ion-view>
<p>Mood: <i ng-if="!blazersStats.emo_frequent_positive">NULL</i>{{ blazersStats.emo_frequent_positive }}</p> \ No newline at end of file
</div>-->
<div class="item item-divider"> Time </div>
<div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Latest</i>
<i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_latest }}</b></i>
</div>
<div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Average</i>
<i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_average }}</b></i>
</div>
<div class="item">
<i class="button button-block button-clear bgbluegreen text-light">Best</i>
<i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_best }}</b></i>
</div>
<!--<div class="item item-borderless item-icon-left">
<i class="icon ion-android-wifi"></i>
Latest
<span class="item-note"> <i ng-if="!blazersStats.time_latest">NULL</i>{{ blazersStats.time_latest }} </span>
</div>
<div class="item item-borderless item-icon-left">
<i class="icon ion-android-wifi"></i>
Average
<span class="item-note"> <i ng-if="!blazersStats.time_average">NULL</i>{{ blazersStats.time_average }} </span>
</div>
<div class="item item-borderless item-icon-left">
<i class="icon ion-android-wifi"></i>
Best
<span class="item-note"> <i ng-if="!blazersStats.time_best">NULL</i>{{ blazersStats.time_best }} </span>
</div>-->
</div>
</ion-content>
</ion-view>
...@@ -2,260 +2,241 @@ angular.module('blazer.surveycontrollers', []) ...@@ -2,260 +2,241 @@ angular.module('blazer.surveycontrollers', [])
.controller('SurveyCtrl', function($scope, $ionicModal, $filter, $ionicSlideBoxDelegate, $ionicScrollDelegate, postBlazer, $cordovaNetwork, $cordovaDialogs) { .controller('SurveyCtrl', function($scope, $ionicModal, $filter, $ionicSlideBoxDelegate, $ionicScrollDelegate, postBlazer, $cordovaNetwork, $cordovaDialogs) {
$scope.closeEndTripModal = function() { $scope.closeEndTripModal = function() {
$scope.modalEndTrip.hide(); $scope.modalEndTrip.hide();
}; };
$scope.closeWeeklyModal = function() {
$scope.modalWeeklyTrip.hide();
};
$scope.endtrip = {};
$scope.postEndTripSurvey = function(){
/* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime");
var endTime = localStorage.getItem("endtime");
var newDate = new Date();
var timeStamp = newDate.getTime();
var currentTrip = localStorage.getItem("currentTrip");
var postdata = {
"trip_id" : tripID,
"username": username,
"depart": startTime,
"arrive": endTime,
"mode": $scope.endtrip.mode,
"exp": $scope.endtrip.overallxp,
"emotion": $scope.endtrip.emotion,
"type": currentTrip
}
console.log("[ POST END TRIP SURVEY ]");
postBlazer.EndTripSurvey(postdata)
.success(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.log("SEND ENDTRIP SURVEY SUCCESS", response);
})
.error(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response);
});
}
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.disableSwipe = function() {
$ionicSlideBoxDelegate.enableSlide(false);
};
$scope.currentIndex = '';
$scope.backSlide = function(){
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.previous();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.nextPageSlide = function(){
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.next();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.weekly = {};
$scope.postWeeklySurvey = function(){
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username");
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE');
var dateCreated = $filter('date')(newDate, 'yyyy - MM - dd HH: mm: ss');
var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){
angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 'C'){
surveyAnswer = null;
}
// var surveyAns = surveyAnswer;
// var surveyAnsStr = surveyAns.join(",");
var surveyString = surveyAnswer.toString(); $scope.closeWeeklyModal = function() {
$scope.modalWeeklyTrip.hide();
};
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString)); $scope.endtrip = {};
var postdata = { $scope.postEndTripSurvey = function() {
"user_id": userID, /* CHECK IF MOBILE IS ONLINE */
"username": username, console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
"choice": $scope.weekly.main, if ($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G || $cordovaNetwork.getNetwork() == Connection.CELL_4G) {
"survey_ans": surveyString, var tripID = localStorage.getItem("tripid");
"date_created": dateCreated var username = localStorage.getItem("username");
} var startTime = localStorage.getItem("starttime");
postBlazer.WeeklySurvey(postdata) var endTime = localStorage.getItem("endtime");
.success(function(response) { var newDate = new Date();
console.log("SEND WEEKLY SURVEY SUCCESS", response); var timeStamp = newDate.getTime();
localStorage.setItem(currentDate, currentDate); var currentTrip = localStorage.getItem("currentTrip");
$scope.resetValues();
$scope.closeWeeklyModal(); var postdata = {
}) "trip_id": tripID,
.error(function(response) { "username": username,
console.error("SEND WEEKLY SURVEY ERROR", response); "depart": startTime,
$scope.resetValues(); "arrive": endTime,
$scope.closeWeeklyModal(); "mode": $scope.endtrip.mode,
}); "exp": $scope.endtrip.overallxp,
} "emotion": $scope.endtrip.emotion,
else { "type": currentTrip
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY"); }
} console.log("[ POST END TRIP SURVEY ]");
} postBlazer.EndTripSurvey(postdata)
.success(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.log("SEND ENDTRIP SURVEY SUCCESS", response);
})
.error(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response);
});
} else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.disableSwipe = function() {
$ionicSlideBoxDelegate.enableSlide(false);
};
$scope.currentIndex = '';
$scope.backSlide = function() {
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.previous();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.nextPageSlide = function() {
$ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.next();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
}
$scope.resetValues = function(){
$scope.weekly = {}; $scope.weekly = {};
$scope.postWeeklySurvey = function() {
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if ($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G || $cordovaNetwork.getNetwork() == Connection.CELL_4G) {
var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username");
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE');
var dateCreated = $filter('date')(newDate, 'yyyy - MM - dd HH: mm: ss');
var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */
if ($scope.weekly.main == 1 || $scope.weekly.main == 2 || $scope.weekly.main == 3 || $scope.weekly.main == 4 || $scope.weekly.main == 5 || $scope.weekly.main == 6) {
angular.forEach($scope.choice1, function(value, key) {
if (value == 'N/A') {
surveyAnswer.push(value);
} else {
surveyAnswer.push(parseInt(value));
}
})
} else if ($scope.weekly.main == 'C') {
surveyAnswer = null;
}
var surveyString = surveyAnswer.toString();
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString));
var postdata = {
"user_id": userID,
"username": username,
"choice": $scope.weekly.main,
"survey_ans": surveyString,
"date_created": dateCreated
}
postBlazer.WeeklySurvey(postdata)
.success(function(response) {
console.log("SEND WEEKLY SURVEY SUCCESS", response);
localStorage.setItem(currentDate, currentDate);
$scope.resetValues();
$scope.closeWeeklyModal();
})
.error(function(response) {
console.error("SEND WEEKLY SURVEY ERROR", response);
$scope.resetValues();
$scope.closeWeeklyModal();
});
} else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.resetValues = function() {
$scope.weekly = {};
$scope.choice1 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0"
};
$scope.choice3 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0",
nine: "0",
ten: "0"
};
$scope.choice4 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
$scope.choice5 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
}
$scope.choiceOneA = [
{ text: "0", value: "0" },
{ text: "1", value: "1" },
{ text: "2", value: "2" },
{ text: "3", value: "3" },
{ text: "4", value: "4" },
{ text: "5", value: "5" }
];
$scope.choiceOneB = [
{ text: "6", value: "6" },
{ text: "7", value: "7" },
{ text: "8", value: "8" },
{ text: "9", value: "9" },
{ text: "10", value: "10" }
];
$scope.choice1 = { $scope.choice1 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0", seven: "0",
eight: "0" eight: "0"
}; };
$scope.choice3 = { $scope.choice3 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0", seven: "0",
eight: "0", eight: "0",
nine: "0", nine: "0",
ten: "0" ten: "0"
}; };
$scope.choice4 = { $scope.choice4 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0" seven: "0"
}; };
$scope.choice5 = { $scope.choice5 = {
one: "0", one: "0",
two: "0", two: "0",
three: "0", three: "0",
four: "0", four: "0",
five: "0", five: "0",
six: "0", six: "0",
seven: "0" seven: "0"
}; };
}
$scope.choiceOneA = [
{ text: "0", value: "0" },
{ text: "1", value: "1" },
{ text: "2", value: "2" },
{ text: "3", value: "3" },
{ text: "4", value: "4" },
{ text: "5", value: "5" }
];
$scope.choiceOneB = [
{ text: "6", value: "6" },
{ text: "7", value: "7" },
{ text: "8", value: "8" },
{ text: "9", value: "9" },
{ text: "10", value: "10" }
];
$scope.choice1 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0"
};
$scope.choice3 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0",
eight: "0",
nine: "0",
ten: "0"
};
$scope.choice4 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
$scope.choice5 = {
one: "0",
two: "0",
three: "0",
four: "0",
five: "0",
six: "0",
seven: "0"
};
$scope.items = [
{ number: 1 },
{ number: 2 },
{ number: 3 },
{ number: 4 },
{ number: 5 },
{ number: 6 },
{ number: 7 },
{ number: 8 },
{ number: 9 },
{ number: 10 },
{ number: 11 },
{ number: 12 },
{ number: 13 },
{ number: 14 },
{ number: 15 }
];
$scope.selectedItem = $scope.items[2];
});
$scope.items = [
{ number: 1 },
{ number: 2 },
{ number: 3 },
{ number: 4 },
{ number: 5 },
{ number: 6 },
{ number: 7 },
{ number: 8 },
{ number: 9 },
{ number: 10 },
{ number: 11 },
{ number: 12 },
{ number: 13 },
{ number: 14 },
{ number: 15 }
];
$scope.selectedItem = $scope.items[2];
});
\ No newline at end of file
<ion-modal-view ng-controller="SurveyCtrl">
<form name="survey">
<ion-header-bar align-title="center" class="bar bar-clear darkblue">
<div class="buttons">
<button class="button button-clear button-light" ng-if="currentIndex!=0" ng-click="backSlide();"><i class="button-icon icon ion-back"></i>Back</button>
</div>
<h1 class="title">Weekly Survey</h1>
<div class="buttons">
<button class="button button-clear button-light" ng-disabled="survey.$invalid" ng-click="postWeeklySurvey()"><i class="button-icon icon ion-android-send"></i></button>
</div>
</ion-header-bar>
<ion-content padding="true">
<ion-slide-box on-slide-changed="slideHasChanged($index)" show-pager="false" ng-init="disableSwipe(); resetValues();" class="dynamic-slider">
<ion-slide>
<div class="item item-light item-text-wrap">
<p class="text-dark">Choose one statement that best describes your car use in the past 4-5 days and how you feel about it.</p>
</div>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=1 ng-click="nextPageSlide()"><b>A:</b> "These past few days, I used car frequently to school, either driving or being driven alone. I am happy about it and I am not at all thinking of lessening my car use."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=2 ng-click="nextPageSlide()"><b>B:</b> "I used car frequently to school over the last few days. I don't know if I can reduce my car use but I am willing to explore possible ways to change my behavior."</ion-radio>
<ion-radio class="item item-text-wrap justify " ng-model="weekly.main" ng-value=3 ng-click="nextPageSlide()"><b>C:</b> "I used car frequently to school in the past 4-5 days. I want to reduce my car use but I don't know how to. In the coming week, I will try to make a plan on how I can achieve my goal of going by alternative modes for some
of my trips to the university."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=4 ng-click="nextPageSlide()"><b>D:</b> "I used car frequently to school in the last few days. I already have some plan on how to go to school by alternatives but I have not implemented it yet. In the coming week, I will attempt to finally implement it."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=5 ng-click="nextPageSlide()"><b>E:</b> "I was able to reduce (further?) my level of car use these past 4-5 days. I will try to maintain this or reduce it more in the coming week."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value=6 ng-click="nextPageSlide()"><b>F:</b> "These past few days, I mostly used alternative modes even though I could use car."</ion-radio>
<ion-radio class="item item-text-wrap justify" ng-model="weekly.main" ng-value="'C'" ng-click="postWeeklySurvey()"><b>G:</b> "As I do not own/have access to a car, I have no choice butto use alternative modes."</ion-radio>
</ion-slide>
<ion-slide>
<div class="item item-light item-text-wrap">
<p class="text-dark">Kindly read carefully and tell us how much you agree or disagree with each of the 15 statements. Choose N/A if thestatement is not applicable to you.</p>
</div>
<!-- FIRST -->
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>1:</b> "I will feel good about myself if I am able to use alternatives for my trips to school." </span>
</label>
<div class="button-bar" style="border-bottom: 0px; border-top: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.one =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.one =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.one =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1one" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.one" value="{{choice1.one}}"> {{choice1.one}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.one" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>2:</b> "I will feel bad if I do nothing to adopt a more pro-environmental mobility lifestyle." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.two =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.two =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.two =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1two" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.two" value="{{choice1.two}}"> {{choice1.two}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.two" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>3:</b> "Before I make the trip by car, I first consider if I can make the same trip by alternatives. Cars should be seen as mode of last resort." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.three =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.three =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.three =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1three" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.three" value="{{choice1.three}}"> {{choice1.three}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.three" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>4:</b> “I know some Ateneans who, though have access to cars, go to school by alternatives. They somehow motivate me to travel like them." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.four =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.four =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.four =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1four" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.four" value="{{choice1.four}}"> {{choice1.four}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.four" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>5:</b> "Each of us can contribute in solving eco-problems associated with car use by using car less or ridesharing with others if possible." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.five =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.five =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.five =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1five" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.five" value="{{choice1.five}}"> {{choice1.five}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.five" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>6:</b> "There are social costs associated with car use: traffic congestion, traffic accidents, air pollution and global warming." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.six =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.six =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.six =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1six" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.six" value="{{choice1.six}}"> {{choice1.six}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.six" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>7:</b> "It is possible for me to go to the university (more often) by carpool or other alternative modes." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.seven =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.seven =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.seven =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1seven" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.seven" value="{{choice1.seven}}"> {{choice1.seven}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.seven" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>8:</b> "I intend to contribute in taking cars off the roads, either by taking alternative means or pooling with others car trips going to same destination." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.eight =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.eight =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.eight =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1eight" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.eight" value="{{choice1.eight}}"> {{choice1.eight}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.eight" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>9:</b> "Among the different mode options to go to the university, there is one option, except driving alone or being the only passenger driven, that is favorable for me." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.nine =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.nine =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.nine =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1nine" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.nine" value="{{choice1.nine}}"> {{choice1.nine}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.nine" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>10:</b> "I have decided which mode to use as substitute for my car for some of my trips to the university. I intend to make a plan on how to go to the university using this mode." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.ten =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.ten =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.ten =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1ten" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.ten" value="{{choice1.ten}}"> {{choice1.ten}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.ten" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>11:</b> "I have plan on how to go to school by alternatives, and I have already run through my head on how to best carry out this plan." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.eleven =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.eleven =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.eleven =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1eleven" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.eleven" value="{{choice1.eleven}}"> {{choice1.eleven}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.eleven" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>12:</b> "I have anticipated all the possible problems that can occur and hinder me as I put this plan into practice." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.twelve =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.twelve =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.twelve =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1twelve" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.twelve" value="{{choice1.twelve}}"> {{choice1.twelve}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.twelve" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>13:</b> "I have already mentally developed ways to overcome such problems and obstacles or to be flexible depending on the situation." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.thirteen =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.thirteen =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.thirteen =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1thirteen" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.thirteen" value="{{choice1.thirteen}}"> {{choice1.thirteen}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.thirteen" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>14:</b> "Within the next seven days, I intend to actually use (more) public transport or rideshare in going to the university/home." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.fourteen =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.fourteen =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.fourteen =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1fourteen" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.fourteen" value="{{choice1.fourteen}}"> {{choice1.fourteen}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.fourteen" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
<label class="item item-stacked-label item-text-wrap justify" style="border-bottom: 0px;">
<span><b>15:</b> "I will continue to use alternatives to go to school, even though this may be inconvenient." </span>
</label>
<div class="button-bar" style="border-bottom: 0px;">
<p class="button button-clear button-positive" ng-click="choice1.fifteen =-5">Disagree</p>
<p class="button button-clear button-positive" ng-click="choice1.fifteen =0">Neutral</p>
<p class="button button-clear button-positive" ng-click="choice1.fifteen =5">Agree</p>
</div>
<div class="item range range-positive" style="border-top: 0px;">
<input type="range" name="choice1fifteen" min=-5 max=5 step=1 ng-value=0 ng-model="choice1.fifteen" value="{{choice1.fifteen}}"> {{choice1.fifteen}}
</div>
<ion-checkbox class="button-bar checkbox-positive" ng-model="choice1.fifteen" ng-true-value="'N/A'" ng-false-value="''">
Not applicable
</ion-checkbox>
</ion-slide>
</ion-slide-box>
</form>
</ion-content>
</ion-modal-view>
\ No newline at end of file
...@@ -14,111 +14,156 @@ ...@@ -14,111 +14,156 @@
.leaflet-zoom-box, .leaflet-zoom-box,
.leaflet-image-layer, .leaflet-image-layer,
.leaflet-layer { .leaflet-layer {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
} }
.leaflet-container { .leaflet-container {
overflow: hidden; overflow: hidden;
-ms-touch-action: none; -ms-touch-action: none;
touch-action: none;
} }
.leaflet-tile, .leaflet-tile,
.leaflet-marker-icon, .leaflet-marker-icon,
.leaflet-marker-shadow { .leaflet-marker-shadow {
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
user-select: none; user-select: none;
-webkit-user-drag: none; -webkit-user-drag: none;
} }
.leaflet-marker-icon, .leaflet-marker-icon,
.leaflet-marker-shadow { .leaflet-marker-shadow {
display: block; display: block;
} }
/* map is broken in FF if you have max-width: 100% on tiles */ /* map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container img { .leaflet-container img {
max-width: none !important; max-width: none !important;
} }
/* stupid Android 2 doesn't understand "max-width: none" properly */ /* stupid Android 2 doesn't understand "max-width: none" properly */
.leaflet-container img.leaflet-image-layer { .leaflet-container img.leaflet-image-layer {
max-width: 15000px !important; max-width: 15000px !important;
} }
.leaflet-tile { .leaflet-tile {
filter: inherit; filter: inherit;
visibility: hidden; visibility: hidden;
} }
.leaflet-tile-loaded { .leaflet-tile-loaded {
visibility: inherit; visibility: inherit;
} }
.leaflet-zoom-box { .leaflet-zoom-box {
width: 0; width: 0;
height: 0; height: 0;
} }
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg { .leaflet-overlay-pane svg {
-moz-user-select: none; -moz-user-select: none;
} }
.leaflet-tile-pane { z-index: 2; } .leaflet-tile-pane {
.leaflet-objects-pane { z-index: 3; } z-index: 2;
.leaflet-overlay-pane { z-index: 4; } }
.leaflet-shadow-pane { z-index: 5; }
.leaflet-marker-pane { z-index: 6; } .leaflet-objects-pane {
.leaflet-popup-pane { z-index: 7; } z-index: 3;
}
.leaflet-overlay-pane {
z-index: 4;
}
.leaflet-shadow-pane {
z-index: 5;
}
.leaflet-marker-pane {
z-index: 6;
}
.leaflet-popup-pane {
z-index: 7;
}
.leaflet-vml-shape { .leaflet-vml-shape {
width: 1px; width: 1px;
height: 1px; height: 1px;
} }
.lvml { .lvml {
behavior: url(#default#VML); behavior: url(#default#VML);
display: inline-block; display: inline-block;
position: absolute; position: absolute;
} }
/* control positioning */ /* control positioning */
.leaflet-control { .leaflet-control {
position: relative; position: relative;
z-index: 7; z-index: 7;
pointer-events: auto; pointer-events: auto;
} }
.leaflet-top, .leaflet-top,
.leaflet-bottom { .leaflet-bottom {
position: absolute; position: absolute;
z-index: 1000; z-index: 1000;
pointer-events: none; pointer-events: none;
} }
.leaflet-top { .leaflet-top {
top: 0; top: 0;
} }
.leaflet-right { .leaflet-right {
right: 0; right: 0;
} }
.leaflet-bottom { .leaflet-bottom {
bottom: 0; bottom: 0;
} }
.leaflet-left { .leaflet-left {
left: 0; left: 0;
} }
.leaflet-control { .leaflet-control {
float: left; float: left;
clear: both; clear: both;
} }
.leaflet-right .leaflet-control { .leaflet-right .leaflet-control {
float: right; float: right;
} }
.leaflet-top .leaflet-control { .leaflet-top .leaflet-control {
margin-top: 10px; margin-top: 10px;
} }
.leaflet-bottom .leaflet-control { .leaflet-bottom .leaflet-control {
margin-bottom: 10px; margin-bottom: 10px;
} }
.leaflet-left .leaflet-control { .leaflet-left .leaflet-control {
margin-left: 10px; margin-left: 10px;
} }
.leaflet-right .leaflet-control { .leaflet-right .leaflet-control {
margin-right: 10px; margin-right: 10px;
} }
...@@ -126,128 +171,143 @@ ...@@ -126,128 +171,143 @@
.leaflet-fade-anim .leaflet-tile, .leaflet-fade-anim .leaflet-tile,
.leaflet-fade-anim .leaflet-popup { .leaflet-fade-anim .leaflet-popup {
opacity: 0; opacity: 0;
-webkit-transition: opacity 0.2s linear; -webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear; transition: opacity 0.2s linear;
} }
.leaflet-fade-anim .leaflet-tile-loaded, .leaflet-fade-anim .leaflet-tile-loaded,
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1; opacity: 1;
} }
.leaflet-zoom-anim .leaflet-zoom-animated { .leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -webkit-transition: -webkit-transform 0.25s cubic-bezier(0, 0, 0.25, 1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0, 0, 0.25, 1);
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); -o-transition: -o-transform 0.25s cubic-bezier(0, 0, 0.25, 1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1); transition: transform 0.25s cubic-bezier(0, 0, 0.25, 1);
} }
.leaflet-zoom-anim .leaflet-tile, .leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile, .leaflet-pan-anim .leaflet-tile,
.leaflet-touching .leaflet-zoom-animated { .leaflet-touching .leaflet-zoom-animated {
-webkit-transition: none; -webkit-transition: none;
-moz-transition: none; -moz-transition: none;
-o-transition: none; -o-transition: none;
transition: none; transition: none;
} }
.leaflet-zoom-anim .leaflet-zoom-hide { .leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden; visibility: hidden;
} }
/* cursors */ /* cursors */
.leaflet-clickable { .leaflet-clickable {
cursor: pointer; cursor: pointer;
} }
.leaflet-container { .leaflet-container {
cursor: -webkit-grab; cursor: -webkit-grab;
cursor: -moz-grab; cursor: -moz-grab;
} }
.leaflet-popup-pane, .leaflet-popup-pane,
.leaflet-control { .leaflet-control {
cursor: auto; cursor: auto;
} }
.leaflet-dragging .leaflet-container, .leaflet-dragging .leaflet-container,
.leaflet-dragging .leaflet-clickable { .leaflet-dragging .leaflet-clickable {
cursor: move; cursor: move;
cursor: -webkit-grabbing; cursor: -webkit-grabbing;
cursor: -moz-grabbing; cursor: -moz-grabbing;
} }
/* visual tweaks */ /* visual tweaks */
.leaflet-container { .leaflet-container {
background: #ddd; background: #ddd;
outline: 0; outline: 0;
} }
.leaflet-container a { .leaflet-container a {
color: #0078A8; color: #0078A8;
} }
.leaflet-container a.leaflet-active { .leaflet-container a.leaflet-active {
outline: 2px solid orange; outline: 2px solid orange;
} }
.leaflet-zoom-box { .leaflet-zoom-box {
border: 2px dotted #38f; border: 2px dotted #38f;
background: rgba(255,255,255,0.5); background: rgba(255, 255, 255, 0.5);
} }
/* general typography */ /* general typography */
.leaflet-container { .leaflet-container {
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
} }
/* general toolbar styles */ /* general toolbar styles */
.leaflet-bar { .leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
border-radius: 4px; border-radius: 4px;
} }
.leaflet-bar a, .leaflet-bar a,
.leaflet-bar a:hover { .leaflet-bar a:hover {
background-color: #fff; background-color: #fff;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
width: 26px; width: 26px;
height: 26px; height: 26px;
line-height: 26px; line-height: 26px;
display: block; display: block;
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
color: black; color: black;
} }
.leaflet-bar a, .leaflet-bar a,
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
background-position: 50% 50%; background-position: 50% 50%;
background-repeat: no-repeat; background-repeat: no-repeat;
display: block; display: block;
} }
.leaflet-bar a:hover { .leaflet-bar a:hover {
background-color: #f4f4f4; background-color: #f4f4f4;
} }
.leaflet-bar a:first-child { .leaflet-bar a:first-child {
border-top-left-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px; border-top-right-radius: 4px;
} }
.leaflet-bar a:last-child { .leaflet-bar a:last-child {
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
border-bottom: none; border-bottom: none;
} }
.leaflet-bar a.leaflet-disabled { .leaflet-bar a.leaflet-disabled {
cursor: default; cursor: default;
background-color: #f4f4f4; background-color: #f4f4f4;
color: #bbb; color: #bbb;
} }
.leaflet-touch .leaflet-bar a { .leaflet-touch .leaflet-bar a {
width: 30px; width: 30px;
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
} }
...@@ -255,224 +315,251 @@ ...@@ -255,224 +315,251 @@
.leaflet-control-zoom-in, .leaflet-control-zoom-in,
.leaflet-control-zoom-out { .leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace; font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px; text-indent: 1px;
} }
.leaflet-control-zoom-out { .leaflet-control-zoom-out {
font-size: 20px; font-size: 20px;
} }
.leaflet-touch .leaflet-control-zoom-in { .leaflet-touch .leaflet-control-zoom-in {
font-size: 22px; font-size: 22px;
} }
.leaflet-touch .leaflet-control-zoom-out { .leaflet-touch .leaflet-control-zoom-out {
font-size: 24px; font-size: 24px;
} }
/* layers control */ /* layers control */
.leaflet-control-layers { .leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
background: #fff; background: #fff;
border-radius: 5px; border-radius: 5px;
} }
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
background-image: url(images/layers.png); background-image: url(images/layers.png);
width: 36px; width: 36px;
height: 36px; height: 36px;
} }
.leaflet-retina .leaflet-control-layers-toggle { .leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png); background-image: url(images/layers-2x.png);
background-size: 26px 26px; background-size: 26px 26px;
} }
.leaflet-touch .leaflet-control-layers-toggle { .leaflet-touch .leaflet-control-layers-toggle {
width: 44px; width: 44px;
height: 44px; height: 44px;
} }
.leaflet-control-layers .leaflet-control-layers-list, .leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle { .leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none; display: none;
} }
.leaflet-control-layers-expanded .leaflet-control-layers-list { .leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block; display: block;
position: relative; position: relative;
} }
.leaflet-control-layers-expanded { .leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px; padding: 6px 10px 6px 6px;
color: #333; color: #333;
background: #fff; background: #fff;
} }
.leaflet-control-layers-selector { .leaflet-control-layers-selector {
margin-top: 2px; margin-top: 2px;
position: relative; position: relative;
top: 1px; top: 1px;
} }
.leaflet-control-layers label { .leaflet-control-layers label {
display: block; display: block;
} }
.leaflet-control-layers-separator { .leaflet-control-layers-separator {
height: 0; height: 0;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px; margin: 5px -10px 5px -6px;
} }
/* attribution and scale controls */ /* attribution and scale controls */
.leaflet-container .leaflet-control-attribution { .leaflet-container .leaflet-control-attribution {
background: #fff; background: #fff;
background: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.7);
margin: 0; margin: 0;
} }
.leaflet-control-attribution, .leaflet-control-attribution,
.leaflet-control-scale-line { .leaflet-control-scale-line {
padding: 0 5px; padding: 0 5px;
color: #333; color: #333;
} }
.leaflet-control-attribution a { .leaflet-control-attribution a {
text-decoration: none; text-decoration: none;
} }
.leaflet-control-attribution a:hover { .leaflet-control-attribution a:hover {
text-decoration: underline; text-decoration: underline;
} }
.leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale { .leaflet-container .leaflet-control-scale {
font-size: 11px; font-size: 11px;
} }
.leaflet-left .leaflet-control-scale { .leaflet-left .leaflet-control-scale {
margin-left: 5px; margin-left: 5px;
} }
.leaflet-bottom .leaflet-control-scale { .leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px; margin-bottom: 5px;
} }
.leaflet-control-scale-line { .leaflet-control-scale-line {
border: 2px solid #777; border: 2px solid #777;
border-top: none; border-top: none;
line-height: 1.1; line-height: 1.1;
padding: 2px 5px 1px; padding: 2px 5px 1px;
font-size: 11px; font-size: 11px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
-moz-box-sizing: content-box; -moz-box-sizing: content-box;
box-sizing: content-box; box-sizing: content-box;
background: #fff;
background: #fff; background: rgba(255, 255, 255, 0.5);
background: rgba(255, 255, 255, 0.5);
} }
.leaflet-control-scale-line:not(:first-child) { .leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777; border-top: 2px solid #777;
border-bottom: none; border-bottom: none;
margin-top: -2px; margin-top: -2px;
} }
.leaflet-control-scale-line:not(:first-child):not(:last-child) { .leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777; border-bottom: 2px solid #777;
} }
.leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar { .leaflet-touch .leaflet-bar {
box-shadow: none; box-shadow: none;
} }
.leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar { .leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2); border: 2px solid rgba(0, 0, 0, 0.2);
background-clip: padding-box; background-clip: padding-box;
} }
/* popup */ /* popup */
.leaflet-popup { .leaflet-popup {
position: absolute; position: absolute;
text-align: center; text-align: center;
} }
.leaflet-popup-content-wrapper { .leaflet-popup-content-wrapper {
padding: 1px; padding: 1px;
text-align: left; text-align: left;
border-radius: 12px; border-radius: 12px;
} }
.leaflet-popup-content { .leaflet-popup-content {
margin: 13px 19px; margin: 13px 19px;
line-height: 1.4; line-height: 1.4;
} }
.leaflet-popup-content p { .leaflet-popup-content p {
margin: 18px 0; margin: 18px 0;
} }
.leaflet-popup-tip-container { .leaflet-popup-tip-container {
margin: 0 auto; margin: 0 auto;
width: 40px; width: 40px;
height: 20px; height: 20px;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0; .leaflet-popup-tip {
width: 17px;
-webkit-transform: rotate(45deg); height: 17px;
-moz-transform: rotate(45deg); padding: 1px;
-ms-transform: rotate(45deg); margin: -10px auto 0;
-o-transform: rotate(45deg); -webkit-transform: rotate(45deg);
transform: rotate(45deg); -moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
} }
.leaflet-popup-content-wrapper, .leaflet-popup-content-wrapper,
.leaflet-popup-tip { .leaflet-popup-tip {
background: white; background: white;
box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
} }
.leaflet-container a.leaflet-popup-close-button { .leaflet-container a.leaflet-popup-close-button {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
padding: 4px 4px 0 0; padding: 4px 4px 0 0;
text-align: center; text-align: center;
width: 18px; width: 18px;
height: 14px; height: 14px;
font: 16px/14px Tahoma, Verdana, sans-serif; font: 16px/14px Tahoma, Verdana, sans-serif;
color: #c3c3c3; color: #c3c3c3;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
background: transparent; background: transparent;
} }
.leaflet-container a.leaflet-popup-close-button:hover { .leaflet-container a.leaflet-popup-close-button:hover {
color: #999; color: #999;
} }
.leaflet-popup-scrolled { .leaflet-popup-scrolled {
overflow: auto; overflow: auto;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
} }
.leaflet-oldie .leaflet-popup-content-wrapper { .leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1; zoom: 1;
} }
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; .leaflet-oldie .leaflet-popup-tip {
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid: DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
} }
.leaflet-oldie .leaflet-popup-tip-container { .leaflet-oldie .leaflet-popup-tip-container {
margin-top: -1px; margin-top: -1px;
} }
.leaflet-oldie .leaflet-control-zoom, .leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers, .leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper, .leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip { .leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999; border: 1px solid #999;
} }
/* div icon */ /* div icon */
.leaflet-div-icon { .leaflet-div-icon {
background: #fff; background: #fff;
border: 1px solid #666; border: 1px solid #666;
} }
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />--> <!--<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />-->
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
<link href="css/style.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="css/leaflet.css"> <link rel="stylesheet" href="css/leaflet.css">
<link rel="stylesheet" href="css/leaflet-routing-machine.css"> <link rel="stylesheet" href="css/leaflet-routing-machine.css">
<link href="lib/ion-floating-menu/dist/ion-floating-menu.css" rel="stylesheet" type="text/css"> <link href="lib/ion-floating-menu/dist/ion-floating-menu.css" rel="stylesheet" type="text/css">
<!--<link href="lib/leaflet-markercluster/dist/MarkerCluster.css" rel="stylesheet" type="text/css"/>--> <!--<link href="lib/leaflet-markercluster/dist/MarkerCluster.css" rel="stylesheet" type="text/css"/>-->
<link href="lib/ion-datetime-picker/release/ion-datetime-picker.min.css" rel="stylesheet"> <link href="lib/ion-datetime-picker/release/ion-datetime-picker.min.css" rel="stylesheet">
...@@ -27,8 +28,9 @@ ...@@ -27,8 +28,9 @@
<!-- cordova script (this will be a 404 during development) --> <!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/ng-cordova.min.js"></script> <script src="lib/ngCordova/ng-cordova.min.js"></script>
<script src="cordova.js"></script> <script src="cordova.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script> <script src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
<!--<script src="lib/leaflet/leaflet-google.js"></script>-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- your app's js --> <!-- your app's js -->
...@@ -45,6 +47,7 @@ ...@@ -45,6 +47,7 @@
<script src="app/misc/js/misc.js"></script> <script src="app/misc/js/misc.js"></script>
<script src="app/ride/js/ride.js"></script> <script src="app/ride/js/ride.js"></script>
<script src="app/message/js/message.js"></script> <script src="app/message/js/message.js"></script>
<script src="app/diary/js/diary.js"></script>
<script src="js/config.js"></script> <script src="js/config.js"></script>
<script src="js/blazerAPI.js"></script> <script src="js/blazerAPI.js"></script>
...@@ -53,12 +56,15 @@ ...@@ -53,12 +56,15 @@
<script src="lib/ion-floating-menu/dist/ion-floating-menu.js" type="text/javascript"></script> <script src="lib/ion-floating-menu/dist/ion-floating-menu.js" type="text/javascript"></script>
<!--<script src="lib/leaflet-markercluster/dist/leaflet.markercluster.js" type="text/javascript"></script>--> <!--<script src="lib/leaflet-markercluster/dist/leaflet.markercluster.js" type="text/javascript"></script>-->
<script src="lib/ion-datetime-picker/release/ion-datetime-picker.min.js"></script> <script src="lib/ion-datetime-picker/release/ion-datetime-picker.min.js"></script>
<script src="js/directives/radioButtons.js"></script> <script src="js/directives/radioButtons.js"></script>
</head>
<body ng-app="blazer">
</head>
<body ng-app="blazer">
<ion-nav-view></ion-nav-view> <ion-nav-view></ion-nav-view>
</body> </body>
</html>
</html>
\ No newline at end of file
angular.module('blazer', [ angular.module('blazer', [
'ionic', 'ionic',
'blazer.landingcontrollers', 'blazer.landingcontrollers',
'blazer.menucontrollers', 'blazer.menucontrollers',
'blazer.authenticationcontrollers', 'blazer.authenticationcontrollers',
'blazer.mapcontrollers', 'blazer.mapcontrollers',
'blazer.offerridecontrollers', 'blazer.offerridecontrollers',
'blazer.sharedridecontrollers', 'blazer.sharedridecontrollers',
'blazer.statuscontrollers', 'blazer.statuscontrollers',
'blazer.tripcontrollers', 'blazer.tripcontrollers',
'blazer.misccontrollers', 'blazer.misccontrollers',
'blazer.surveycontrollers', 'blazer.surveycontrollers',
'blazer.apiservices', 'blazer.diarycontrollers',
'blazer.rideinformation', 'blazer.apiservices',
'blazer.composemessage', 'blazer.rideinformation',
'ionic-letter-avatar', 'blazer.composemessage',
'ngCordova', 'ionic-letter-avatar',
'radioButtons', 'ngCordova',
'ion-floating-menu', 'radioButtons',
'ion-datetime-picker', 'ion-floating-menu',
'chart.js' 'ion-datetime-picker',
'chart.js'
]) ])
.run(function($ionicPlatform, $ionicPickerI18n) { .run(function($ionicPlatform, $ionicPickerI18n) {
$ionicPlatform.ready(function() { $ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) { if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true); cordova.plugins.Keyboard.disableScroll(true);
} }
if (window.StatusBar) { if (window.StatusBar) {
// org.apache.cordova.statusbar required // org.apache.cordova.statusbar required
StatusBar.styleDefault(); StatusBar.styleDefault();
} }
$ionicPickerI18n.ok = "Set"; $ionicPickerI18n.ok = "Set";
$ionicPickerI18n.okClass = "button-dark button-outline"; $ionicPickerI18n.okClass = "button-dark button-outline";
$ionicPickerI18n.cancelClass = "button-dark button-outline"; $ionicPickerI18n.cancelClass = "button-dark button-outline";
}); });
$ionicPlatform.registerBackButtonAction(function (event) { $ionicPlatform.registerBackButtonAction(function(event) {
event.preventDefault(); event.preventDefault();
}, 100); }, 100);
}) })
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) { .config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top $ionicConfigProvider.tabs.position('bottom'); // other values: top
$ionicConfigProvider.tabs.style('standard'); $ionicConfigProvider.tabs.style('standard');
$ionicConfigProvider.spinner.icon('lines'); $ionicConfigProvider.spinner.icon('lines');
$stateProvider $stateProvider
/* LANDING */ /* LANDING */
.state('landing', { .state('landing', {
url: '/landing', url: '/landing',
templateUrl: 'app/landing/landing.html', templateUrl: 'app/landing/landing.html',
controller: 'LandingCtrl' controller: 'LandingCtrl'
}) })
/* MENU */ /* MENU */
.state('app', { .state('app', {
url: '/app', url: '/app',
abstract: true, abstract: true,
templateUrl: 'app/menu/menu.html', templateUrl: 'app/menu/menu.html',
controller: 'MenuCtrl' controller: 'MenuCtrl'
}) })
/* LOGIN */ /* LOGIN */
.state('login', { .state('login', {
url: '/login', url: '/login',
templateUrl: 'app/auth/login.html', templateUrl: 'app/auth/login.html',
controller: 'AuthCtrl' controller: 'AuthCtrl'
}) })
/* HOME */ /* HOME */
.state('app.map', { .state('app.map', {
url: '/map', url: '/map',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/map/map.html', templateUrl: 'app/map/map.html',
controller: 'MapCtrl' controller: 'MapCtrl'
} }
} }
}) })
/* TRIP */ /* TRIP */
.state('app.trip', { .state('app.trip', {
url: '/trip', url: '/trip',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/trip/trip.html', templateUrl: 'app/trip/trip.html',
controller: 'TripCtrl' controller: 'TripCtrl'
} }
} }
}) })
/* SHAREDRIDE */ /* SHAREDRIDE */
.state('app.offerride', { .state('app.offerride', {
url: '/offerride', url: '/offerride',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/offerride/offerride.html', templateUrl: 'app/offerride/offerride.html',
controller: 'OfferRideCtrl' controller: 'OfferRideCtrl'
} }
} }
}) })
/* SHAREDRIDE */ /* SHAREDRIDE */
.state('app.sharedride', { .state('app.sharedride', {
url: '/sharedride', url: '/sharedride',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/sharedride/sharedride.html', templateUrl: 'app/sharedride/sharedride.html',
controller: 'SharedRideCtrl' controller: 'SharedRideCtrl'
} }
} }
}) })
/* STATUS */ /* STATUS */
.state('app.status', { .state('app.status', {
url: '/status', url: '/status',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/status/status.html', templateUrl: 'app/status/status.html',
controller: 'StatusCtrl' controller: 'StatusCtrl'
} }
} }
}) })
/* PROFILE */ /* PROFILE */
.state('app.profile', { .state('app.profile', {
url: '/profile', url: '/profile',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/misc/profile.html', templateUrl: 'app/misc/profile.html',
controller: 'MiscCtrl' controller: 'MiscCtrl'
} }
} }
}) })
/* ABOUT */ /* ABOUT */
.state('app.about', { .state('app.about', {
url: '/about', url: '/about',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/misc/about.html', templateUrl: 'app/misc/about.html',
controller: 'MiscCtrl' controller: 'MiscCtrl'
} }
} }
}) })
/* SETTINGS */ /* SETTINGS */
.state('app.settings', { .state('app.settings', {
url: '/settings', url: '/settings',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/misc/settings.html', templateUrl: 'app/misc/settings.html',
controller: 'MiscCtrl' controller: 'MiscCtrl'
} }
} }
}) })
/* RIDE INFORMATION */ /* RIDE INFORMATION */
.state('app.ride', { .state('app.ride', {
url: '/ride/:id', url: '/ride/:id',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/ride/ride.html', templateUrl: 'app/ride/ride.html',
controller: 'RideInfoCtrl' controller: 'RideInfoCtrl'
} }
} }
}) })
/* COMPOSE MESSAGE */ /* COMPOSE MESSAGE */
.state('app.message', { .state('app.message', {
url: '/message', url: '/message',
views: { views: {
'menuContent': { 'menuContent': {
templateUrl: 'app/message/message.html', templateUrl: 'app/message/message.html',
controller: 'MsgCtrl' controller: 'MsgCtrl'
} }
} }
}) })
$urlRouterProvider.otherwise('/landing');
/* DIARY */
.state('app.diary', {
url: '/diary',
views: {
'menuContent': {
templateUrl: 'app/diary/diary.html',
controller: 'DiaryCtrl'
}
}
})
$urlRouterProvider.otherwise('/landing');
}) })
\ No newline at end of file
...@@ -4,622 +4,1106 @@ ...@@ -4,622 +4,1106 @@
angular.module('blazer.apiservices', []) angular.module('blazer.apiservices', [])
/*-------------------------------------------------- GET -------------------------------------------------- */ /*-------------------------------------------------- GET -------------------------------------------------- */
.factory('getBlazer', function($http, $ionicLoading){ .factory('getBlazer', function($http, $ionicLoading) {
var AllBlazerData = []; var TempData = [];
var AllUserData = [];
var AllTravelStatus = []; return {
var AllSharedRideData = [];
var DetailedSharedRide = {}; getBlazerDataInfo: function() {
var AllModesofTransport = {}; $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
var AllBarangay = [];
return $http.get(blazerAPI + '/blazer_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
return { console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
getBlazerDataInfo: function(){ $ionicLoading.hide();
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); return TempData;
}, function(err) {
return $http.get(blazerAPI + '/blazer_data.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllBlazerData = response.data; return;
$ionicLoading.hide(); })
return AllBlazerData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getUserProfile: function(username) {
$ionicLoading.hide(); console.log("****** ON ENTER GET USER PROFILE SERVICE ******");
return ; // $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'});
})
}, return $http.get(blazerAPI + '/user_profile.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
getUserProfile: function(username) { TempData = response.data[0];
console.log("****** ON ENTER GET USER PROFILE SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); return TempData;
}, function(err) {
return $http.get(blazerAPI+'/user_profile.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllUserData = response.data[0]; return;
$ionicLoading.hide(); })
return AllUserData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getTravelStats: function(username) {
$ionicLoading.hide(); console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******");
return ; // $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'});
})
}, return $http.get(blazerAPI + '/travel_stats.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
getTravelStats: function(username) { TempData = response.data;
console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'});
return TempData;
return $http.get(blazerAPI+'/travel_stats.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); }, function(err) {
AllTravelStatus = response.data; console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return AllTravelStatus; return;
})
}, function(err) { },
console.error('[ ERROR ]', JSON.stringify(err)); /* NOT USED */
$ionicLoading.hide(); getSharedRide: function() {
console.log("****** ON ENTER GET SHARED RIDE SERVICE ******");
return ; // $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} );
})
}, return $http.get(blazerAPI + '/take_shared_ride_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
/* NOT USED */ console.log('[ SUCCESS ]', JSON.stringify(response));
getSharedRide: function() { TempData = response.data;
console.log("****** ON ENTER GET SHARED RIDE SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); return TempData;
}, function(err) {
return $http.get(blazerAPI+'/take_shared_ride_data.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllSharedRideData = response.data; return;
$ionicLoading.hide(); })
return AllSharedRideData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getTakeSharedRide: function(username) {
$ionicLoading.hide(); console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******");
return ; // $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} );
})
}, return $http.get(blazerAPI + '/take_shared_ride_data.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
getTakeSharedRide: function(username) { TempData = response.data;
console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******"); $ionicLoading.hide();
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); return TempData;
}, function(err) {
return $http.get(blazerAPI+'/take_shared_ride_data.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.error('[ ERROR ]', JSON.stringify(err));
console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllSharedRideData = response.data; return;
$ionicLoading.hide(); })
return AllSharedRideData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getDetailedSharedRide: function(rideID, username) {
$ionicLoading.hide(); DetailedSharedRide = {};
return ; console.log("[ RIDE ID ]", rideID);
}) console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******");
}, $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI + '/take_shared_ride_data.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
getDetailedSharedRide: function(rideID, username) { // console.log('[ SUCCESS ]', JSON.stringify(response));
DetailedSharedRide = {}; TempData = response.data;
console.log("[ RIDE ID ]", rideID); angular.forEach(TempData, function(value, key) {
console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******"); if (value.id === rideID) {
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); DetailedSharedRide = { "id": value.id, "createdby": value.createdby, "destination": value.destination, "pickuplocation": value.pickuplocation, "pickup_lat": value.pickup_lat, "pickup_long": value.pickup_long, "assemblytime": value.assemblytime, "model": value.model, "mobilenum": value.mobilenum, "otherdetails": value.otherdetails, "subscribers": value.subscribers, "capacityleft": value.capacityleft, "avatar": value.avatar, "ride_status": value.ride_status, "interested_status": value.interested_status }
return $http.get(blazerAPI+'/take_shared_ride_data.php?username='+username, {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide));
// console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllSharedRideData = response.data; }
angular.forEach(AllSharedRideData, function(value, key) { });
if (value.id === rideID) { return DetailedSharedRide;
DetailedSharedRide = { "id": value.id, "createdby": value.createdby, "destination": value.destination, "pickuplocation": value.pickuplocation, "pickup_lat": value.pickup_lat, "pickup_long": value.pickup_long, "assemblytime": value.assemblytime, "model": value.model, "mobilenum": value.mobilenum, "otherdetails": value.otherdetails, "subscribers": value.subscribers, "capacityleft": value.capacityleft, "avatar": value.avatar, "ride_status": value.ride_status, "interested_status": value.interested_status } }, function(err) {
console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
} return;
}); })
return DetailedSharedRide; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); /* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */
$ionicLoading.hide(); getModeofTransportation: function(rideID) {
return ; console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******");
}) $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
}, return $http.get(blazerAPI + '/get_transportation_mode.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
// console.log('[ SUCCESS ]', JSON.stringify(response));
/* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */ TempData = response.data;
getModeofTransportation: function(rideID) { angular.forEach(TempData, function(value, key) {
console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******"); if (value.id === rideID) {
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); TempData = {};
return $http.get(blazerAPI+'/get_transportation_mode.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.log("[ MODE OF TRANSPORT ]", JSON.stringify(TempData));
// console.log('[ SUCCESS ]', JSON.stringify(response)); $ionicLoading.hide();
AllModesofTransport = response.data; }
angular.forEach(AllModesofTransport, function(value, key) { });
if (value.id === rideID) { return TempData;
AllModesofTransport = {}; }, function(err) {
console.log("[ MODE OF TRANSPORT ]", JSON.stringify(AllModesofTransport)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
} return;
}); })
return AllModesofTransport; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getAllBarangay: function() {
$ionicLoading.hide(); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return ;
}) return $http.get(blazerAPI + '/get_barangay.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
}, console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
getAllBarangay: function(){ // LOOP BARANGAY DATA
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); var BarangayData = [];
for (var i = 0; i < TempData.length; i++) {
return $http.get(blazerAPI + '/get_barangay.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { console.log("Barangay " + i, TempData[i]);
console.log('[ SUCCESS ]', JSON.stringify(response)); BarangayData.push({ "name": TempData[i] });
AllBarangay = response.data; }
// LOOP BARANGAY DATA $ionicLoading.hide();
var BarangayData = []; return BarangayData;
for(var i = 0; i < AllBarangay.length; i++){ }, function(err) {
console.log("Barangay "+i,AllBarangay[i]); console.error('[ ERROR ]', JSON.stringify(err));
BarangayData.push({"name":AllBarangay[i]}); $ionicLoading.hide();
} return;
$ionicLoading.hide(); })
return BarangayData; },
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); getMapData: function() {
$ionicLoading.hide(); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return ;
}) return $http.get(blazerAPI_V2 + '/index.php/map/barangay_visualization', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
}, console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
} $ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getMostPopulatNonCarMode: function(barangay, time) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI_V2 + '/index.php/barangay/most_popular_non_car/' + barangay + '/' + time, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
$ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getHowYouMoveAround: function(start, end, username) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI_V2 + '/index.php/diary/how_you_moved/' + start + '/' + end + '/' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
$ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getHowYouMoveAround: function(start, end, username) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI_V2 + '/index.php/diary/how_you_moved/' + start + '/' + end + '/' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
$ionicLoading.hide();
return TempData;
}, function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
getComparisonMessage: function(username) {
return $http.get('http://blaze.eacomm.com/includes/get_facts.php?username=' + username, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response));
TempData = response.data;
return TempData;
},
function(err) {
console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide();
return;
})
},
}
}) })
/*-------------------------------------------------- POST -------------------------------------------------- */ /*-------------------------------------------------- POST -------------------------------------------------- */
.service('postBlazer', function($q, $http, $ionicLoading) { .service('postBlazer', function($q, $http, $ionicLoading) {
return { return {
LoginUser: function(user) { LoginUser: function(user) {
console.log("****** ON ENTER LOGIN SERVICE ******"); console.log("****** ON ENTER LOGIN SERVICE ******");
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ USER CREDENTIALS ] -> ", JSON.stringify(user)); console.log("[ USER CREDENTIALS ] -> ", JSON.stringify(user));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
$http({method: 'POST', url: blazerAPI + '/login.php', $http({
data: $.param(user), method: 'POST',
headers : {'Content-Type': 'application/x-www-form-urlencoded'} url: blazerAPI + '/login.php',
}).success(function(responseData) { data: $.param(user),
console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData)); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
if(responseData.status == 0){ }).success(function(responseData) {
$ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000}); console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData));
deferred.reject('Error'); if (responseData.status == 0) {
} $ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000 });
else if(responseData.status == 1){ deferred.reject('Error');
deferred.resolve('Success'); } else if (responseData.status == 1) {
// $ionicLoading.show({ template: "Success!", duration: 500}); deferred.resolve('Success');
$ionicLoading.hide(); // $ionicLoading.show({ template: "Success!", duration: 500});
localStorage.setItem("userID", responseData.user.id); $ionicLoading.hide();
console.log("[ USER ID ]", responseData.user.id); localStorage.setItem("userID", responseData.user.id);
} console.log("[ USER ID ]", responseData.user.id);
}).error(function(responseData) { }
console.error("[ ERROR ]", JSON.stringify(responseData)); }).error(function(responseData) {
deferred.reject('Error'); console.error("[ ERROR ]", JSON.stringify(responseData));
$ionicLoading.show({ template: "Check your connection!", duration: 500}); deferred.reject('Error');
}); $ionicLoading.show({ template: "Check your connection!", duration: 500 });
});
promise.success = function(fn) {
promise.then(fn); promise.success = function(fn) {
return promise; promise.then(fn);
} return promise;
promise.error = function(fn) { }
promise.then(null, fn); promise.error = function(fn) {
return promise; promise.then(null, fn);
} return promise;
return promise; }
}, return promise;
},
LogTrip: function(coords, username) {
console.log("****** ON ENTER TRIP LOGGING SERVICE ******"); LogTrip: function(coords, username) {
console.log("****** ON ENTER TRIP LOGGING SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise; var deferred = $q.defer();
var promise = deferred.promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 500});
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 500 });
var logTrip = {};
var currentTrip = localStorage.getItem("currentTrip"); var logTrip = {};
var currentTrip = localStorage.getItem("currentTrip");
logTrip = {
username: username, logTrip = {
type: currentTrip, username: username,
coordinates: coords type: currentTrip,
} coordinates: coords
}
console.log("[ TRIP JSON ]", JSON.stringify(logTrip));
console.log("[ TRIP JSON ]", JSON.stringify(logTrip));
$http({ method: 'POST', url: blazerAPI + '/log_trip.php',
data: $.param(logTrip), $http({
headers : {'Content-Type': 'application/x-www-form-urlencoded'} method: 'POST',
}).success(function(responseData) { url: blazerAPI + '/log_trip.php',
console.log("[ SUCCESS ]", JSON.stringify(responseData)); data: $.param(logTrip),
localStorage.setItem("tripid", responseData.trip_id); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
deferred.resolve('Success'); }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
// $ionicLoading.show({ template: "Success!", duration: 1000}); localStorage.setItem("tripid", responseData.trip_id);
}).error(function(responseData) { deferred.resolve('Success');
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); // $ionicLoading.show({ template: "Success!", duration: 1000});
}).error(function(responseData) {
$ionicLoading.show({ template: "Sending Error!", duration: 1000}); console.error("[ ERROR ]", JSON.stringify(responseData));
}); deferred.reject('Error');
promise.success = function(fn) { $ionicLoading.show({ template: "Sending Error!", duration: 1000 });
promise.then(fn); });
return promise;
} promise.success = function(fn) {
promise.error = function(fn) { promise.then(fn);
promise.then(null, fn); return promise;
return promise; }
} promise.error = function(fn) {
return promise; promise.then(null, fn);
}, return promise;
}
EndTripSurvey: function(data) { return promise;
console.log("****** ON ENTER TRIP END SERVICE ******"); },
var deferred = $q.defer(); EndTripSurvey: function(data) {
var promise = deferred.promise; console.log("****** ON ENTER TRIP END SERVICE ******");
var endtripdata = {
"trip_id" : data.trip_id, var deferred = $q.defer();
"username": data.username, var promise = deferred.promise;
"depart": data.depart, var endtripdata = {
"arrive": data.arrive, "trip_id": data.trip_id,
"mode": data.mode, "username": data.username,
"exp": data.exp, "depart": data.depart,
"emotion": data.emotion, "arrive": data.arrive,
"type": data.type "mode": data.mode,
}; "exp": data.exp,
"emotion": data.emotion,
var stringendtripdata = angular.fromJson(endtripdata); "type": data.type
};
console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); var stringendtripdata = angular.fromJson(endtripdata);
$http({method: 'POST', url: blazerAPI + '/end_trip.php', console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data));
data: $.param(stringendtripdata), $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(responseData) { $http({
console.log("[ SUCCESS ]", JSON.stringify(responseData)); method: 'POST',
deferred.resolve('Success'); url: blazerAPI + '/end_trip.php',
data: $.param(stringendtripdata),
$ionicLoading.show({ template: "Submitted!", duration: 1000}); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).error(function(responseData) { }).success(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.resolve('Success');
$ionicLoading.show({ template: "Try Again!", duration: 1000}); $ionicLoading.show({ template: "Submitted!", duration: 1000 });
}); }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
promise.success = function(fn) { deferred.reject('Error');
promise.then(fn);
return promise; $ionicLoading.show({ template: "Try Again!", duration: 1000 });
} });
promise.error = function(fn) {
promise.then(null, fn); promise.success = function(fn) {
return promise; promise.then(fn);
} return promise;
return promise; }
}, promise.error = function(fn) {
promise.then(null, fn);
WeeklySurvey: function(data) { return promise;
console.log("****** ON ENTER WEEKLY SURVEY SERVICE ******"); }
return promise;
var deferred = $q.defer(); },
var promise = deferred.promise;
WeeklySurvey: function(data) {
console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data)); console.log("****** ON ENTER WEEKLY SURVEY SERVICE ******");
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000});
var weeklysurveydata = { var deferred = $q.defer();
"user_id": data.user_id, var promise = deferred.promise;
"username": data.username,
"choice": data.choice, console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data));
"survey_ans": data.survey_ans, $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
"date_created": data.date_created var weeklysurveydata = {
}; "user_id": data.user_id,
$http({method: 'POST', url: blazerAPI + '/weekly_survey.php', "username": data.username,
data: $.param(weeklysurveydata), "choice": data.choice,
headers : {'Content-Type': 'application/x-www-form-urlencoded'} "survey_ans": data.survey_ans,
}).success(function(responseData) { "date_created": data.date_created
console.log("[ SUCCESS ]", JSON.stringify(responseData)); };
deferred.resolve('Success'); $http({
method: 'POST',
$ionicLoading.show({ template: "Submitted!", duration: 1000}); url: blazerAPI + '/weekly_survey.php',
}).error(function(responseData) { data: $.param(weeklysurveydata),
console.error("[ ERROR ]", JSON.stringify(responseData)); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
deferred.reject('Error'); }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
$ionicLoading.show({ template: "Try Again!", duration: 1000}); deferred.resolve('Success');
});
$ionicLoading.show({ template: "Submitted!", duration: 1000 });
promise.success = function(fn) { }).error(function(responseData) {
promise.then(fn); console.error("[ ERROR ]", JSON.stringify(responseData));
return promise; deferred.reject('Error');
}
promise.error = function(fn) { $ionicLoading.show({ template: "Try Again!", duration: 1000 });
promise.then(null, fn); });
return promise;
} promise.success = function(fn) {
return promise; promise.then(fn);
}, return promise;
}
TakeSharedRide: function(data) { promise.error = function(fn) {
console.log("****** ON ENTER TAKE SHARED RIDE SERVICE ******"); promise.then(null, fn);
return promise;
var deferred = $q.defer(); }
var promise = deferred.promise; return promise;
},
console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); TakeSharedRide: function(data) {
var sharedRideData = { console.log("****** ON ENTER TAKE SHARED RIDE SERVICE ******");
"ride_id": data.ride_id,
"user": data.username var deferred = $q.defer();
}; var promise = deferred.promise;
$http({method: 'POST', url: blazerAPI + '/take_shared_ride_post.php',
data: $.param(sharedRideData), console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data));
headers : {'Content-Type': 'application/x-www-form-urlencoded'} $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
}).success(function(responseData) { var sharedRideData = {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); "ride_id": data.ride_id,
deferred.resolve('Success'); "user": data.username
};
// $ionicLoading.show({ template: "Success!", duration: 1000}); $http({
}).error(function(responseData) { method: 'POST',
console.error("[ ERROR ]", JSON.stringify(responseData)); url: blazerAPI + '/take_shared_ride_post.php',
deferred.reject('Error'); data: $.param(sharedRideData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
$ionicLoading.show({ template: "Request Error!", duration: 1000}); }).success(function(responseData) {
}); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
promise.success = function(fn) {
promise.then(fn); // $ionicLoading.show({ template: "Success!", duration: 1000});
return promise; }).error(function(responseData) {
} console.error("[ ERROR ]", JSON.stringify(responseData));
promise.error = function(fn) { deferred.reject('Error');
promise.then(null, fn);
return promise; $ionicLoading.show({ template: "Request Error!", duration: 1000 });
} });
return promise;
}, promise.success = function(fn) {
promise.then(fn);
InterestedRide: function(data) { return promise;
console.log("****** ON ENTER INTERESTED RIDE SERVICE ******"); }
promise.error = function(fn) {
var deferred = $q.defer(); promise.then(null, fn);
var promise = deferred.promise; return promise;
}
console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data)); return promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); },
var interestedRideData = {
"ride_id": data.ride_id, InterestedRide: function(data) {
"username": data.username console.log("****** ON ENTER INTERESTED RIDE SERVICE ******");
};
$http({method: 'POST', url: blazerAPI + '/interested_ride_post.php', var deferred = $q.defer();
data: $.param(interestedRideData), var promise = deferred.promise;
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(responseData) { console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data));
console.log("[ SUCCESS ]", JSON.stringify(responseData)); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
deferred.resolve('Success'); var interestedRideData = {
"ride_id": data.ride_id,
// $ionicLoading.show({ template: "Success!", duration: 1000}); "username": data.username
}).error(function(responseData) { };
console.error("[ ERROR ]", JSON.stringify(responseData)); $http({
deferred.reject('Error'); method: 'POST',
url: blazerAPI + '/interested_ride_post.php',
$ionicLoading.show({ template: "Request Error!", duration: 1000}); data: $.param(interestedRideData),
}); headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
promise.success = function(fn) { console.log("[ SUCCESS ]", JSON.stringify(responseData));
promise.then(fn); deferred.resolve('Success');
return promise;
} // $ionicLoading.show({ template: "Success!", duration: 1000});
promise.error = function(fn) { }).error(function(responseData) {
promise.then(null, fn); console.error("[ ERROR ]", JSON.stringify(responseData));
return promise; deferred.reject('Error');
}
return promise; $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}, });
OfferRide: function(data) { promise.success = function(fn) {
console.log("****** ON ENTER OFFER RIDE SERVICE ******"); promise.then(fn);
return promise;
var deferred = $q.defer(); }
var promise = deferred.promise; promise.error = function(fn) {
promise.then(null, fn);
console.log("[ OFFER DATA ] -> ", JSON.stringify(data)); return promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); }
var offerRiderData = { return promise;
"name": data.name, },
"pickup_lat": data.pickup_lat,
"pickup_lng": data.pickup_lng, OfferRide: function(data) {
"dest_lat": data.dest_lat, console.log("****** ON ENTER OFFER RIDE SERVICE ******");
"dest_lng": data.dest_lng,
"assembly_time": data.assembly_time, var deferred = $q.defer();
"car_model": data.car_model, var promise = deferred.promise;
"capacity": data.capacity,
"mobile": data.mobile, console.log("[ OFFER DATA ] -> ", JSON.stringify(data));
"other": data.other $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
}; var offerRiderData = {
$http({method: 'POST', url: blazerAPI + '/offer_ride.php', "name": data.name,
data: $.param(offerRiderData), "pickup_lat": data.pickup_lat,
headers : {'Content-Type': 'application/x-www-form-urlencoded'} "pickup_lng": data.pickup_lng,
}).success(function(responseData) { "dest_lat": data.dest_lat,
console.log("[ SUCCESS ]", JSON.stringify(responseData)); "dest_lng": data.dest_lng,
deferred.resolve('Success'); "assembly_time": data.assembly_time,
$ionicLoading.show({ template: "Ride Offered", duration: 1000}); "car_model": data.car_model,
}).error(function(responseData) { "capacity": data.capacity,
console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData)); "mobile": data.mobile,
deferred.reject('Error'); "other": data.other
$ionicLoading.show({ template: "Request Error!", duration: 1000}); };
}); $http({
method: 'POST',
promise.success = function(fn) { url: blazerAPI + '/offer_ride.php',
promise.then(fn); data: $.param(offerRiderData),
return promise; headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
} }).success(function(responseData) {
promise.error = function(fn) { console.log("[ SUCCESS ]", JSON.stringify(responseData));
promise.then(null, fn); deferred.resolve('Success');
return promise; $ionicLoading.show({ template: "Ride Offered", duration: 1000 });
} }).error(function(responseData) {
return promise; console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData));
}, deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
BarangayInformation: function(data) { });
console.log("****** ON ENTER BARANGAY DATA SERVICE ******");
promise.success = function(fn) {
var deferred = $q.defer(); promise.then(fn);
var promise = deferred.promise; return promise;
}
console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data)); promise.error = function(fn) {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); promise.then(null, fn);
return promise;
var selectedBarangay = { }
"barangay": data.barangay, return promise;
"time": data.time },
};
BarangayInformation: function(data) {
$http({method: 'POST', url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php', console.log("****** ON ENTER BARANGAY DATA SERVICE ******");
data: $.param(selectedBarangay),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} var deferred = $q.defer();
}).success(function(responseData) { var promise = deferred.promise;
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData); console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data));
$ionicLoading.hide(); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
return responseData;
}).error(function(responseData) { var selectedBarangay = {
console.error("[ ERROR ]", JSON.stringify(responseData)); "barangay": data.barangay,
deferred.reject('Error'); "time": data.time
};
$ionicLoading.show({ template: "Request Error!", duration: 1000});
}); $http({
method: 'POST',
promise.success = function(fn) { url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php',
promise.then(fn); data: $.param(selectedBarangay),
return promise; headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
} }).success(function(responseData) {
promise.error = function(fn) { console.log("[ SUCCESS ]", JSON.stringify(responseData));
promise.then(null, fn); deferred.resolve(responseData);
return promise; $ionicLoading.hide();
} return responseData;
return promise; }).error(function(responseData) {
}, console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
ForgotPassword: function(data) {
console.log("****** ON ENTER FORGOT PASSWORD SERVICE ******"); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
var deferred = $q.defer();
var promise = deferred.promise; promise.success = function(fn) {
promise.then(fn);
console.log("[ EMAIL DATA ] -> ", JSON.stringify(data)); return promise;
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); }
var emailData = { promise.error = function(fn) {
"email_address": data.email_address, promise.then(null, fn);
}; return promise;
$http({method: 'POST', url: 'http://blaze.eacomm.com/send_password.php', }
data: $.param(emailData), return promise;
headers : {'Content-Type': 'application/x-www-form-urlencoded'} },
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); ForgotPassword: function(data) {
deferred.resolve('Success'); console.log("****** ON ENTER FORGOT PASSWORD SERVICE ******");
$ionicLoading.show({ template: "Success!", duration: 1000}); var deferred = $q.defer();
}).error(function(responseData) { var promise = deferred.promise;
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); console.log("[ EMAIL DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
$ionicLoading.show({ template: "Request Error!", duration: 1000}); var emailData = {
}); "email_address": data.email_address,
};
promise.success = function(fn) { $http({
promise.then(fn); method: 'POST',
return promise; url: 'http://blaze.eacomm.com/send_password.php',
} data: $.param(emailData),
promise.error = function(fn) { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
promise.then(null, fn); }).success(function(responseData) {
return promise; console.log("[ SUCCESS ]", JSON.stringify(responseData));
} deferred.resolve('Success');
return promise;
}, $ionicLoading.show({ template: "Success!", duration: 1000 });
}).error(function(responseData) {
} console.error("[ ERROR ]", JSON.stringify(responseData));
}) deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
/******************** API V2 *********************/
UserSummary: function(data) {
console.log("****** ON ENTER USER SUMMARY SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"user_id": data.user_id,
"username": data.username
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/get_summary',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
GetTripDetails: function(data) {
console.log("****** ON ENTER TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"date": data.date
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/get_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
LogTripV2: function(data) {
console.log("****** ON ENTER LOG TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"origin": data.origin,
"destination": data.destination,
"username": data.username,
"type": data.type,
"datecreated": data.datecreated,
"depart": data.depart,
"arrive": data.arrive,
"mode": data.mode,
"exp": data.exp,
"emotion": data.emotion,
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/add_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
UpdateTrip: function(data) {
console.log("****** ON ENTER UPDATE TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"trip_uploads_id": data.trip_uploads_id,
"origin": data.origin,
"destination": data.destination,
"username": data.username,
"type": data.type,
"datecreated": data.datecreated,
"depart": data.depart,
"arrive": data.arrive,
"mode": data.mode,
"exp": data.exp,
"emotion": data.emotion,
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/update_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
NoTrip: function(data) {
console.log("****** ON ENTER NO TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"id": data.id,
"mode": data.mode,
"date": data.date, // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/no_trip',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
VerifyTrip: function(data) {
console.log("****** ON ENTER VERIFY TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"date": data.date, // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/logger/verify',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
HometoSchoolTravelTimes: function(data) {
console.log("****** ON ENTER HOME TO SCHOOL TRIP DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"start_date": data.start_date, // YYYY-MM-DD
"end_date": data.end_date // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/get_home_to_school_travel_time',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
TripLogGraph: function(data) {
console.log("****** ON ENTER TRIP LOG GRAPH DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"username": data.username,
"month": data.month, // YYYY-MM-DD
"year": data.year // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/trip_log_graph',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
PerformanceSummary: function(data) {
console.log("****** ON ENTER PERFORMANCE SUMMARY DETAILS SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ ENTRY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var requestData = {
"user_id": data.user_id,
"date": data.date, // YYYY-MM-DD
};
$http({
method: 'POST',
url: blazerAPI_V2 + '/index.php/summary/performance',
data: $.param(requestData),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData);
$ionicLoading.hide();
return responseData;
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000 });
});
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
},
/*********** MAP DIRECTIVES ***********/
.service('LocationService', function($q){
var autocompleteService = new google.maps.places.AutocompleteService();
var detailsService = new google.maps.places.PlacesService(document.createElement("input"));
return {
searchAddress: function(input) {
var deferred = $q.defer();
autocompleteService.getPlacePredictions({
input: input
}, function(result, status) {
if(status == google.maps.places.PlacesServiceStatus.OK){
console.log(status);
deferred.resolve(result);
}else{
deferred.reject(status)
}
});
return deferred.promise;
},
getDetails: function(placeId) {
var deferred = $q.defer();
detailsService.getDetails({placeId: placeId}, function(result) {
deferred.resolve(result);
});
return deferred.promise;
} }
};
}) })
.directive('locationSuggestion', function($ionicModal, LocationService){
return { /*********** MAP DIRECTIVES ***********/
restrict: 'A', .service('LocationService', function($q) {
scope: { var autocompleteService = new google.maps.places.AutocompleteService();
location: '=' var detailsService = new google.maps.places.PlacesService(document.createElement("input"));
}, return {
link: function($scope, element){ searchAddress: function(input) {
console.log('locationSuggestion started!'); var deferred = $q.defer();
$scope.search = {};
$scope.search.suggestions = []; autocompleteService.getPlacePredictions({
$scope.search.query = ""; input: input
$ionicModal.fromTemplateUrl('app/offerride/popover/location.html', { }, function(result, status) {
scope: $scope, if (status == google.maps.places.PlacesServiceStatus.OK) {
focusFirstInput: true console.log(status);
}).then(function(modal) { deferred.resolve(result);
$scope.modal = modal; } else {
}); deferred.reject(status)
element[0].addEventListener('focus', function(event) { }
$scope.open(); });
});
$scope.$watch('search.query', function(newValue) { return deferred.promise;
if (newValue) { },
LocationService.searchAddress(newValue).then(function(result) { getDetails: function(placeId) {
$scope.search.error = null; var deferred = $q.defer();
$scope.search.suggestions = result; detailsService.getDetails({ placeId: placeId }, function(result) {
}, function(status){ deferred.resolve(result);
$scope.search.error = "There was an error :( " + status; });
}); return deferred.promise;
}; }
$scope.open = function() {
$scope.modal.show();
};
$scope.close = function() {
$scope.modal.hide();
};
$scope.choosePlace = function(place) {
LocationService.getDetails(place.place_id).then(function(location) {
$scope.location = location;
$scope.close();
});
}; };
}); })
} .directive('locationSuggestion', function($ionicModal, LocationService) {
} return {
}) restrict: 'A',
; scope: {
location: '='
},
link: function($scope, element) {
console.log('locationSuggestion started!');
$scope.search = {};
$scope.search.suggestions = [];
$scope.search.query = "";
$ionicModal.fromTemplateUrl('app/offerride/popover/location.html', {
scope: $scope,
focusFirstInput: true
}).then(function(modal) {
$scope.modal = modal;
});
element[0].addEventListener('focus', function(event) {
$scope.open();
});
$scope.$watch('search.query', function(newValue) {
if (newValue) {
LocationService.searchAddress(newValue).then(function(result) {
$scope.search.error = null;
$scope.search.suggestions = result;
}, function(status) {
$scope.search.error = "There was an error :( " + status;
});
};
$scope.open = function() {
$scope.modal.show();
};
$scope.close = function() {
$scope.modal.hide();
};
$scope.choosePlace = function(place) {
LocationService.getDetails(place.place_id).then(function(location) {
$scope.location = location;
$scope.close();
});
};
});
}
}
});
\ No newline at end of file
var blazerAPI = 'http://blaze.eacomm.com/api'; var blazerAPI = 'http://blaze.eacomm.com/api';
var appVersion = '1.0.0'; var blazerAPI_V2 = 'http://blaze.eacomm.com/api_v2';
var appVersion = '2.0.0';
var buildNumber = '0.0.1'; var buildNumber = '0.0.1';
var maplayer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var maplayer = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
......
(function (factory) { (function(factory) {
'use strict'; 'use strict';
if (typeof exports === 'object') { if (typeof exports === 'object') {
// Node/CommonJS // Node/CommonJS
module.exports = factory( module.exports = factory(
typeof angular !== 'undefined' ? angular : require('angular'), typeof angular !== 'undefined' ? angular : require('angular'),
typeof Chart !== 'undefined' ? Chart : require('chart.js')); typeof Chart !== 'undefined' ? Chart : require('chart.js'));
} else if (typeof define === 'function' && define.amd) { } else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module. // AMD. Register as an anonymous module.
define(['angular', 'chart'], factory); define(['angular', 'chart'], factory);
} else { } else {
// Browser globals // Browser globals
factory(angular, Chart); factory(angular, Chart);
} }
}(function (angular, Chart) { }(function(angular, Chart) {
'use strict'; 'use strict';
Chart.defaults.global.responsive = true; Chart.defaults.global.responsive = true;
Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>';
Chart.defaults.global.colours = [ Chart.defaults.global.colours = [
'#97BBCD', // blue '#97BBCD', // blue
'#DCDCDC', // light grey '#DCDCDC', // light grey
'#F7464A', // red '#F7464A', // red
'#46BFBD', // green '#46BFBD', // green
'#FDB45C', // yellow '#FDB45C', // yellow
'#949FB1', // grey '#949FB1', // grey
'#4D5360' // dark grey '#4D5360' // dark grey
]; ];
var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' && var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' &&
window.G_vmlCanvasManager !== null && window.G_vmlCanvasManager !== null &&
typeof window.G_vmlCanvasManager.initElement === 'function'; typeof window.G_vmlCanvasManager.initElement === 'function';
if (usingExcanvas) Chart.defaults.global.animation = false; if (usingExcanvas) Chart.defaults.global.animation = false;
return angular.module('chart.js', []) return angular.module('chart.js', [])
.provider('ChartJs', ChartJsProvider) .provider('ChartJs', ChartJsProvider)
.factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory]) .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory])
.directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }]) .directive('chartBase', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory(); }])
.directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Line'); }]) .directive('chartLine', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Line'); }])
.directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Bar'); }]) .directive('chartBar', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Bar'); }])
.directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Radar'); }]) .directive('chartRadar', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Radar'); }])
.directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Doughnut'); }]) .directive('chartDoughnut', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Doughnut'); }])
.directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Pie'); }]) .directive('chartPie', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('Pie'); }])
.directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('PolarArea'); }]); .directive('chartPolarArea', ['ChartJsFactory', function(ChartJsFactory) { return new ChartJsFactory('PolarArea'); }]);
/**
* Wrapper for chart.js
* Allows configuring chart js using the provider
*
* angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) {
* ChartJsProvider.setOptions({ responsive: true });
* ChartJsProvider.setOptions('Line', { responsive: false });
* })))
*/
function ChartJsProvider () {
var options = {};
var ChartJs = {
Chart: Chart,
getOptions: function (type) {
var typeOptions = type && options[type] || {};
return angular.extend({}, options, typeOptions);
}
};
/** /**
* Allow to set global options during configuration * Wrapper for chart.js
* Allows configuring chart js using the provider
*
* angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) {
* ChartJsProvider.setOptions({ responsive: true });
* ChartJsProvider.setOptions('Line', { responsive: false });
* })))
*/ */
this.setOptions = function (type, customOptions) { function ChartJsProvider() {
// If no type was specified set option for the global object var options = {};
if (! customOptions) { var ChartJs = {
customOptions = type; Chart: Chart,
options = angular.extend(options, customOptions); getOptions: function(type) {
return; var typeOptions = type && options[type] || {};
} return angular.extend({}, options, typeOptions);
// Set options for the specific chart
options[type] = angular.extend(options[type] || {}, customOptions);
};
this.$get = function () {
return ChartJs;
};
}
function ChartJsFactory (ChartJs, $timeout) {
return function chart (type) {
return {
restrict: 'CA',
scope: {
data: '=?',
labels: '=?',
options: '=?',
series: '=?',
colours: '=?',
getColour: '=?',
chartType: '=',
legend: '@',
click: '=?',
hover: '=?',
chartData: '=?',
chartLabels: '=?',
chartOptions: '=?',
chartSeries: '=?',
chartColours: '=?',
chartLegend: '@',
chartClick: '=?',
chartHover: '=?'
},
link: function (scope, elem/*, attrs */) {
var chart, container = document.createElement('div');
container.className = 'chart-container';
elem.replaceWith(container);
container.appendChild(elem[0]);
if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar (fromName, toName) {
scope.$watch(fromName, function (newVal) {
if (typeof newVal === 'undefined') return;
scope[toName] = newVal;
});
}
/* provide backward compatibility to "old" directive names, by
* having an alias point from the new names to the old names. */
aliasVar('chartData', 'data');
aliasVar('chartLabels', 'labels');
aliasVar('chartOptions', 'options');
aliasVar('chartSeries', 'series');
aliasVar('chartColours', 'colours');
aliasVar('chartLegend', 'legend');
aliasVar('chartClick', 'click');
aliasVar('chartHover', 'hover');
// Order of setting "watch" matter
scope.$watch('data', function (newVal, oldVal) {
if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) return;
var chartType = type || scope.chartType;
if (! chartType) return;
if (chart) {
if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem);
chart.destroy();
} }
};
createChart(chartType);
}, true); /**
* Allow to set global options during configuration
scope.$watch('series', resetChart, true); */
scope.$watch('labels', resetChart, true); this.setOptions = function(type, customOptions) {
scope.$watch('options', resetChart, true); // If no type was specified set option for the global object
scope.$watch('colours', resetChart, true); if (!customOptions) {
customOptions = type;
scope.$watch('chartType', function (newVal, oldVal) { options = angular.extend(options, customOptions);
if (isEmpty(newVal)) return; return;
if (angular.equals(newVal, oldVal)) return;
if (chart) chart.destroy();
createChart(newVal);
});
scope.$on('$destroy', function () {
if (chart) chart.destroy();
});
function resetChart (newVal, oldVal) {
if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return;
var chartType = type || scope.chartType;
if (! chartType) return;
// chart.update() doesn't work for series and labels
// so we have to re-create the chart entirely
if (chart) chart.destroy();
createChart(chartType);
}
function createChart (type) {
if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) {
return $timeout(function () {
createChart(type);
}, 50, false);
} }
if (! scope.data || ! scope.data.length) return; // Set options for the specific chart
scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour; options[type] = angular.extend(options[type] || {}, customOptions);
scope.colours = getColours(type, scope); };
var cvs = elem[0], ctx = cvs.getContext('2d');
var data = Array.isArray(scope.data[0]) ?
getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :
getData(scope.labels, scope.data, scope.colours);
var options = angular.extend({}, ChartJs.getOptions(type), scope.options);
chart = new ChartJs.Chart(ctx)[type](data, options);
scope.$emit('create', chart);
// Bind events
cvs.onclick = scope.click ? getEventHandler(scope, chart, 'click', false) : angular.noop;
cvs.onmousemove = scope.hover ? getEventHandler(scope, chart, 'hover', true) : angular.noop;
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); this.$get = function() {
} return ChartJs;
};
function deprecated (attr) { }
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log; function ChartJsFactory(ChartJs, $timeout) {
if (!! scope[attr]) { return function chart(type) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' + return {
'Please use "chart-%s" instead.', attr, attr); restrict: 'CA',
} scope: {
data: '=?',
labels: '=?',
options: '=?',
series: '=?',
colours: '=?',
getColour: '=?',
chartType: '=',
legend: '@',
click: '=?',
hover: '=?',
chartData: '=?',
chartLabels: '=?',
chartOptions: '=?',
chartSeries: '=?',
chartColours: '=?',
chartLegend: '@',
chartClick: '=?',
chartHover: '=?'
},
link: function(scope, elem /*, attrs */ ) {
var chart, container = document.createElement('div');
container.className = 'chart-container';
elem.replaceWith(container);
container.appendChild(elem[0]);
if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar(fromName, toName) {
scope.$watch(fromName, function(newVal) {
if (typeof newVal === 'undefined') return;
scope[toName] = newVal;
});
}
/* provide backward compatibility to "old" directive names, by
* having an alias point from the new names to the old names. */
aliasVar('chartData', 'data');
aliasVar('chartLabels', 'labels');
aliasVar('chartOptions', 'options');
aliasVar('chartSeries', 'series');
aliasVar('chartColours', 'colours');
aliasVar('chartLegend', 'legend');
aliasVar('chartClick', 'click');
aliasVar('chartHover', 'hover');
// Order of setting "watch" matter
scope.$watch('data', function(newVal, oldVal) {
if (!newVal || !newVal.length || (Array.isArray(newVal[0]) && !newVal[0].length)) return;
var chartType = type || scope.chartType;
if (!chartType) return;
if (chart) {
if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem);
chart.destroy();
}
createChart(chartType);
}, true);
scope.$watch('series', resetChart, true);
scope.$watch('labels', resetChart, true);
scope.$watch('options', resetChart, true);
scope.$watch('colours', resetChart, true);
scope.$watch('chartType', function(newVal, oldVal) {
if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return;
if (chart) chart.destroy();
createChart(newVal);
});
scope.$on('$destroy', function() {
if (chart) chart.destroy();
});
function resetChart(newVal, oldVal) {
if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return;
var chartType = type || scope.chartType;
if (!chartType) return;
// chart.update() doesn't work for series and labels
// so we have to re-create the chart entirely
if (chart) chart.destroy();
createChart(chartType);
}
function createChart(type) {
if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) {
return $timeout(function() {
createChart(type);
}, 50, false);
}
if (!scope.data || !scope.data.length) return;
scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour;
scope.colours = getColours(type, scope);
var cvs = elem[0],
ctx = cvs.getContext('2d');
var data = Array.isArray(scope.data[0]) ?
getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :
getData(scope.labels, scope.data, scope.colours);
var options = angular.extend({}, ChartJs.getOptions(type), scope.options);
chart = new ChartJs.Chart(ctx)[type](data, options);
scope.$emit('create', chart);
// Bind events
cvs.onclick = scope.click ? getEventHandler(scope, chart, 'click', false) : angular.noop;
cvs.onmousemove = scope.hover ? getEventHandler(scope, chart, 'hover', true) : angular.noop;
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
}
function deprecated(attr) {
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log;
if (!!scope[attr]) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' +
'Please use "chart-%s" instead.', attr, attr);
}
}
}
}
};
};
function canUpdateChart(newVal, oldVal) {
if (newVal && oldVal && newVal.length && oldVal.length) {
return Array.isArray(newVal[0]) ?
newVal.length === oldVal.length && newVal.every(function(element, index) {
return element.length === oldVal[index].length;
}) :
oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;
} }
} return false;
} }
};
};
function canUpdateChart (newVal, oldVal) {
if (newVal && oldVal && newVal.length && oldVal.length) {
return Array.isArray(newVal[0]) ?
newVal.length === oldVal.length && newVal.every(function (element, index) {
return element.length === oldVal[index].length; }) :
oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;
}
return false;
}
function sum (carry, val) { function sum(carry, val) {
return carry + val; return carry + val;
} }
function getEventHandler (scope, chart, action, triggerOnlyOnChange) { function getEventHandler(scope, chart, action, triggerOnlyOnChange) {
var lastState = null; var lastState = null;
return function (evt) { return function(evt) {
var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent; var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent;
if (atEvent) { if (atEvent) {
var activePoints = atEvent.call(chart, evt); var activePoints = atEvent.call(chart, evt);
if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) { if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) {
lastState = activePoints; lastState = activePoints;
scope[action](activePoints, evt); scope[action](activePoints, evt);
scope.$apply(); scope.$apply();
} }
}
};
} }
};
}
function getColours (type, scope) { function getColours(type, scope) {
var colours = angular.copy(scope.colours || var colours = angular.copy(scope.colours ||
ChartJs.getOptions(type).colours || ChartJs.getOptions(type).colours ||
Chart.defaults.global.colours Chart.defaults.global.colours
); );
while (colours.length < scope.data.length) { while (colours.length < scope.data.length) {
colours.push(scope.getColour()); colours.push(scope.getColour());
} }
return colours.map(convertColour); return colours.map(convertColour);
} }
function convertColour (colour) { function convertColour(colour) {
if (typeof colour === 'object' && colour !== null) return colour; if (typeof colour === 'object' && colour !== null) return colour;
if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1))); if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1)));
return getRandomColour(); return getRandomColour();
} }
function getRandomColour () { function getRandomColour() {
var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)]; var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)];
return getColour(colour); return getColour(colour);
} }
function getColour (colour) { function getColour(colour) {
return { return {
fillColor: rgba(colour, 0.2), fillColor: rgba(colour, 0.2),
strokeColor: rgba(colour, 1), strokeColor: rgba(colour, 1),
pointColor: rgba(colour, 1), pointColor: rgba(colour, 1),
pointStrokeColor: '#fff', pointStrokeColor: '#fff',
pointHighlightFill: '#fff', pointHighlightFill: '#fff',
pointHighlightStroke: rgba(colour, 0.8) pointHighlightStroke: rgba(colour, 0.8)
}; };
} }
function getRandomInt (min, max) { function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min; return Math.floor(Math.random() * (max - min + 1)) + min;
} }
function rgba (colour, alpha) { function rgba(colour, alpha) {
if (usingExcanvas) { if (usingExcanvas) {
// rgba not supported by IE8 // rgba not supported by IE8
return 'rgb(' + colour.join(',') + ')'; return 'rgb(' + colour.join(',') + ')';
} else { } else {
return 'rgba(' + colour.concat(alpha).join(',') + ')'; return 'rgba(' + colour.concat(alpha).join(',') + ')';
} }
} }
// Credit: http://stackoverflow.com/a/11508164/1190235 // Credit: http://stackoverflow.com/a/11508164/1190235
function hexToRgb (hex) { function hexToRgb(hex) {
var bigint = parseInt(hex, 16), var bigint = parseInt(hex, 16),
r = (bigint >> 16) & 255, r = (bigint >> 16) & 255,
g = (bigint >> 8) & 255, g = (bigint >> 8) & 255,
b = bigint & 255; b = bigint & 255;
return [r, g, b]; return [r, g, b];
} }
function getDataSets (labels, data, series, colours) { function getDataSets(labels, data, series, colours) {
return { return {
labels: labels, labels: labels,
datasets: data.map(function (item, i) { datasets: data.map(function(item, i) {
return angular.extend({}, colours[i], { return angular.extend({}, colours[i], {
label: series[i], label: series[i],
data: item data: item
}); });
}) })
}; };
} }
function getData (labels, data, colours) { function getData(labels, data, colours) {
return labels.map(function (label, i) { return labels.map(function(label, i) {
return angular.extend({}, colours[i], { return angular.extend({}, colours[i], {
label: label, label: label,
value: data[i], value: data[i],
color: colours[i].strokeColor, color: colours[i].strokeColor,
highlight: colours[i].pointHighlightStroke highlight: colours[i].pointHighlightStroke
}); });
}); });
} }
function setLegend (elem, chart) { function setLegend(elem, chart) {
var $parent = elem.parent(), var $parent = elem.parent(),
$oldLegend = $parent.find('chart-legend'), $oldLegend = $parent.find('chart-legend'),
legend = '<chart-legend>' + chart.generateLegend() + '</chart-legend>'; legend = '<chart-legend>' + chart.generateLegend() + '</chart-legend>';
if ($oldLegend.length) $oldLegend.replaceWith(legend); if ($oldLegend.length) $oldLegend.replaceWith(legend);
else $parent.append(legend); else $parent.append(legend);
} }
function updateChart (chart, values, scope, elem) { function updateChart(chart, values, scope, elem) {
if (Array.isArray(scope.data[0])) { if (Array.isArray(scope.data[0])) {
chart.datasets.forEach(function (dataset, i) { chart.datasets.forEach(function(dataset, i) {
(dataset.points || dataset.bars).forEach(function (dataItem, j) { (dataset.points || dataset.bars).forEach(function(dataItem, j) {
dataItem.value = values[i][j]; dataItem.value = values[i][j];
}); });
}); });
} else { } else {
chart.segments.forEach(function (segment, i) { chart.segments.forEach(function(segment, i) {
segment.value = values[i]; segment.value = values[i];
}); });
} }
chart.update(); chart.update();
scope.$emit('update', chart); scope.$emit('update', chart);
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
} }
function isEmpty (value) { function isEmpty(value) {
return ! value || return !value ||
(Array.isArray(value) && ! value.length) || (Array.isArray(value) && !value.length) ||
(typeof value === 'object' && ! Object.keys(value).length); (typeof value === 'object' && !Object.keys(value).length);
} }
function isResponsive (type, scope) { function isResponsive(type, scope) {
var options = angular.extend({}, Chart.defaults.global, ChartJs.getOptions(type), scope.options); var options = angular.extend({}, Chart.defaults.global, ChartJs.getOptions(type), scope.options);
return options.responsive; return options.responsive;
}
} }
} }));
})); \ No newline at end of file
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '',
opacity: 1,
continuousWorld: false,
noWrap: false,
},
// Possible types: SATELLITE, ROADMAP, HYBRID
initialize: function(type, options) {
L.Util.setOptions(this, options);
this._type = google.maps.MapTypeId[type || 'SATELLITE'];
},
onAdd: function(map, insertAtTheBottom) {
this._map = map;
this._insertAtTheBottom = insertAtTheBottom;
// create a container div for tiles
this._initContainer();
this._initMapObject();
// set up events
map.on('viewreset', this._resetCallback, this);
this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);
map.on('move', this._update, this);
//map.on('moveend', this._update, this);
this._reset();
this._update();
},
onRemove: function(map) {
this._map._container.removeChild(this._container);
//this._container = null;
this._map.off('viewreset', this._resetCallback, this);
this._map.off('move', this._update, this);
//this._map.off('moveend', this._update, this);
},
getAttribution: function() {
return this.options.attribution;
},
setOpacity: function(opacity) {
this.options.opacity = opacity;
if (opacity < 1) {
L.DomUtil.setOpacity(this._container, opacity);
}
},
_initContainer: function() {
var tilePane = this._map._container
first = tilePane.firstChild;
if (!this._container) {
this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
this._container.id = "_GMapContainer";
}
if (true) {
tilePane.insertBefore(this._container, first);
this.setOpacity(this.options.opacity);
var size = this._map.getSize();
this._container.style.width = size.x + 'px';
this._container.style.height = size.y + 'px';
}
},
_initMapObject: function() {
this._google_center = new google.maps.LatLng(0, 0);
var map = new google.maps.Map(this._container, {
center: this._google_center,
zoom: 0,
mapTypeId: this._type,
disableDefaultUI: true,
keyboardShortcuts: false,
draggable: false,
disableDoubleClickZoom: true,
scrollwheel: false,
streetViewControl: false
});
var _this = this;
this._reposition = google.maps.event.addListenerOnce(map, "center_changed",
function() { _this.onReposition(); });
map.backgroundColor = '#ff0000';
this._google = map;
},
_resetCallback: function(e) {
this._reset(e.hard);
},
_reset: function(clearOldContainer) {
this._initContainer();
},
_update: function() {
this._resize();
var bounds = this._map.getBounds();
var ne = bounds.getNorthEast();
var sw = bounds.getSouthWest();
var google_bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(sw.lat, sw.lng),
new google.maps.LatLng(ne.lat, ne.lng)
);
var center = this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._google.setCenter(_center);
this._google.setZoom(this._map.getZoom());
//this._google.fitBounds(google_bounds);
},
_resize: function() {
var size = this._map.getSize();
if (this._container.style.width == size.x &&
this._container.style.height == size.y)
return;
this._container.style.width = size.x + 'px';
this._container.style.height = size.y + 'px';
google.maps.event.trigger(this._google, "resize");
},
onReposition: function() {
//google.maps.event.trigger(this._google, "resize");
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment