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
...@@ -7,14 +7,19 @@ angular.module('blazer.mapcontrollers', []) ...@@ -7,14 +7,19 @@ angular.module('blazer.mapcontrollers', [])
/* 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 = 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,
...@@ -24,19 +29,19 @@ angular.module('blazer.mapcontrollers', []) ...@@ -24,19 +29,19 @@ angular.module('blazer.mapcontrollers', [])
/* MAP COMPONENTS */ /* MAP COMPONENTS */
var markers, circles, line; var markers, circles, line;
$scope.drawMarkers = function(lat, lon, message){ $scope.drawMarkers = function(lat, lon, message) {
markers = new L.marker([lat, lon]).addTo(map); markers = new L.marker([lat, lon]).addTo(map);
markers.bindPopup(message).openPopup(); markers.bindPopup(message).openPopup();
} }
/* Draw Trip Marker */ /* Draw Trip Marker */
$scope.drawTripMarkers = function(lat, lon){ $scope.drawTripMarkers = function(lat, lon) {
markers = new L.marker([lat, lon]).addTo(map); markers = new L.marker([lat, lon]).addTo(map);
markers.bindPopup('On Trip').openPopup(); markers.bindPopup('On Trip').openPopup();
} }
/* Draw Radius */ /* Draw Radius */
$scope.drawCircle = function(lat, lon){ $scope.drawCircle = function(lat, lon) {
circle = L.circle([lat, lon], 500, { circle = L.circle([lat, lon], 500, {
color: '', color: '',
fillColor: '#165c5b', fillColor: '#165c5b',
...@@ -48,7 +53,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -48,7 +53,7 @@ angular.module('blazer.mapcontrollers', [])
var logCoordinates = []; // FOR LOGGING TRIP var logCoordinates = []; // FOR LOGGING TRIP
var setLatLng; var setLatLng;
var coords; var coords;
$scope.drawLineTrack = function(lat, lon){ $scope.drawLineTrack = function(lat, lon) {
var polylineOptions = { var polylineOptions = {
color: '#185c82', color: '#185c82',
weight: 6, weight: 6,
...@@ -73,10 +78,12 @@ angular.module('blazer.mapcontrollers', []) ...@@ -73,10 +78,12 @@ angular.module('blazer.mapcontrollers', [])
/* EVENT LISTENERS */ /* EVENT LISTENERS */
$scope.mapButton = true; $scope.mapButton = true;
function onMapDrag(e) { function onMapDrag(e) {
$scope.mapButton = false; $scope.mapButton = false;
console.log("Map Drag ", $scope.mapButton); console.log("Map Drag ", $scope.mapButton);
} }
function onMapDragEnd(e) { function onMapDragEnd(e) {
$scope.mapButton = true; $scope.mapButton = true;
console.log("Map Drag ", $scope.mapButton); console.log("Map Drag ", $scope.mapButton);
...@@ -84,11 +91,11 @@ angular.module('blazer.mapcontrollers', []) ...@@ -84,11 +91,11 @@ angular.module('blazer.mapcontrollers', [])
map.on('move', onMapDrag); // FIRE MAPDRAG map.on('move', onMapDrag); // FIRE MAPDRAG
map.on('moveend', onMapDragEnd); // FIRE MAPDRAG END map.on('moveend', onMapDragEnd); // FIRE MAPDRAG END
$scope.clearPolylines = function(){ $scope.clearPolylines = function() {
console.debug("********** Clear Polylines **********"); console.debug("********** Clear Polylines **********");
for(var i = 0; i < coordinates.length; i ++){ for (var i = 0; i < coordinates.length; i++) {
map.removeLayer(line._latlngs[i]); map.removeLayer(line._latlngs[i]);
console.error("[ CHECK LOOP ]", i +" "+coordinates.length); console.error("[ CHECK LOOP ]", i + " " + coordinates.length);
console.log("[ DELETE LINES ]", line._latlngs[i]); console.log("[ DELETE LINES ]", line._latlngs[i]);
// coordinates.splice(i, 1); // REMOVE AN ITEM ON AN ARRAY // coordinates.splice(i, 1); // REMOVE AN ITEM ON AN ARRAY
} }
...@@ -96,17 +103,16 @@ angular.module('blazer.mapcontrollers', []) ...@@ -96,17 +103,16 @@ angular.module('blazer.mapcontrollers', [])
/* LOAD USER ON MAP WITH RADIUS */ /* LOAD USER ON MAP WITH RADIUS */
var userLocated = false; var userLocated = false;
$scope.initializedLocateUser = function(){ $scope.initializedLocateUser = function() {
console.debug("********** Initialized Location **********"); console.debug("********** Initialized Location **********");
var posOptions = {enableHighAccuracy: true}; var posOptions = { enableHighAccuracy: true };
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) { $cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) {
map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15); // SET MAP VIEW map.setView(new L.LatLng(position.coords.latitude, position.coords.longitude), 15); // SET MAP VIEW
if(userLocated == false){ if (userLocated == false) {
$scope.drawMarkers(position.coords.latitude, position.coords.longitude, 'Your current location'); // DRAW MARKERS $scope.drawMarkers(position.coords.latitude, position.coords.longitude, 'Your current location'); // DRAW MARKERS
$scope.drawCircle(position.coords.latitude, position.coords.longitude); // DRAW CIRCLE RADIUS $scope.drawCircle(position.coords.latitude, position.coords.longitude); // DRAW CIRCLE RADIUS
userLocated = true; userLocated = true;
} } else {
else {
console.log("USER ALREADY LOCATED"); console.log("USER ALREADY LOCATED");
userLocated = true; userLocated = true;
} }
...@@ -116,29 +122,29 @@ angular.module('blazer.mapcontrollers', []) ...@@ -116,29 +122,29 @@ angular.module('blazer.mapcontrollers', [])
} }
/* Calculate Distance between points */ /* Calculate Distance between points */
$scope.getDistanceFromLatLonInKm = function(lat1,lon1,lat2,lon2) { $scope.getDistanceFromLatLonInKm = function(lat1, lon1, lat2, lon2) {
var R = 6371; // Radius of the earth in km var R = 6371; // Radius of the earth in km
var dLat = deg2rad(lat2-lat1); // deg2rad function var dLat = deg2rad(lat2 - lat1); // deg2rad function
var dLon = deg2rad(lon2-lon1); 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 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)); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c; // Distance in km var d = R * c; // Distance in km
console.log("[ DISTANCE BETWEEN COORDINDATES ]", d); console.log("[ DISTANCE BETWEEN COORDINDATES ]", d);
return d; return d;
} }
function deg2rad(deg) { function deg2rad(deg) {
return deg * (Math.PI/180) return deg * (Math.PI / 180)
} }
/* MAIN ALGORITHM */ /* MAIN ALGORITHM */
var tripStatusRef = false; var tripStatusRef = false;
$scope.getUserLocation = function(){ $scope.getUserLocation = function() {
console.debug("********** Trip Location **********"); console.debug("********** Trip Location **********");
var posOptions = {enableHighAccuracy: true}; var posOptions = { enableHighAccuracy: true };
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) { $cordovaGeolocation.getCurrentPosition(posOptions).then(function(position) {
console.log("[ CURRENT LOCATION ]", position.coords); console.log("[ CURRENT LOCATION ]", position.coords);
if(!tripStatusRef){ if (!tripStatusRef) {
$scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // INITIAL LINE ON TRIP $scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // INITIAL LINE ON TRIP
tripStatusRef = true; tripStatusRef = true;
} }
...@@ -149,21 +155,16 @@ angular.module('blazer.mapcontrollers', []) ...@@ -149,21 +155,16 @@ angular.module('blazer.mapcontrollers', [])
lng: position.coords.longitude lng: position.coords.longitude
} }
if(logCoordinates.length > 0) // CHECK IF ARAY IS EMPTY if (logCoordinates.length > 0) // CHECK IF ARAY IS EMPTY
{
if($scope.getDistanceFromLatLonInKm(locationData.lat, locationData.lng, logCoordinates[0].lat, logCoordinates[0].lng) > 0.03)
{ {
if ($scope.getDistanceFromLatLonInKm(locationData.lat, locationData.lng, logCoordinates[0].lat, logCoordinates[0].lng) > 0.03) {
logCoordinates.splice(0, 0, locationData); logCoordinates.splice(0, 0, locationData);
console.log("[ LOCATION ARRAY ]", logCoordinates); console.log("[ LOCATION ARRAY ]", logCoordinates);
$scope.drawLineTrack(position.coords.latitude, position.coords.longitude); // DRAW LINE ON TRIP $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); console.error("[ You need to be 500 meters away from your current position ]", logCoordinates);
} }
} } else {
else
{
logCoordinates.splice(0, 0, locationData); logCoordinates.splice(0, 0, locationData);
console.log("[ INITIAL LOCATION ARRAY ]", logCoordinates); console.log("[ INITIAL LOCATION ARRAY ]", logCoordinates);
} }
...@@ -173,9 +174,9 @@ angular.module('blazer.mapcontrollers', []) ...@@ -173,9 +174,9 @@ angular.module('blazer.mapcontrollers', [])
}); });
} }
$scope.refreshMap = function(){ $scope.refreshMap = function() {
console.debug("********** Refresh Map **********"); console.debug("********** Refresh Map **********");
if(userLocated == true){ if (userLocated == true) {
map.removeLayer(markers); map.removeLayer(markers);
map.removeLayer(circle); map.removeLayer(circle);
map.removeLayer(geojsonLayer); map.removeLayer(geojsonLayer);
...@@ -188,13 +189,12 @@ angular.module('blazer.mapcontrollers', []) ...@@ -188,13 +189,12 @@ angular.module('blazer.mapcontrollers', [])
} }
/* CONFIRM TRIP DESTINATION */ /* CONFIRM TRIP DESTINATION */
$scope.confirmTripDestination = function(){ $scope.confirmTripDestination = function() {
var tripPopup = $ionicPopup.show({ var tripPopup = $ionicPopup.show({
title: 'Trip Destination', title: 'Trip Destination',
subTitle: 'Select your destination', subTitle: 'Select your destination',
scope: $scope, scope: $scope,
buttons: [ buttons: [{
{
text: 'School', text: 'School',
type: 'button-dark button-outline', type: 'button-dark button-outline',
onTap: function() { onTap: function() {
...@@ -218,9 +218,9 @@ angular.module('blazer.mapcontrollers', []) ...@@ -218,9 +218,9 @@ angular.module('blazer.mapcontrollers', [])
/* 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));
}); });
...@@ -229,7 +229,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -229,7 +229,7 @@ angular.module('blazer.mapcontrollers', [])
$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({
...@@ -237,14 +237,13 @@ angular.module('blazer.mapcontrollers', []) ...@@ -237,14 +237,13 @@ angular.module('blazer.mapcontrollers', [])
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 = {};
...@@ -263,7 +262,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -263,7 +262,7 @@ angular.module('blazer.mapcontrollers', [])
/* 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,
...@@ -292,7 +291,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -292,7 +291,7 @@ angular.module('blazer.mapcontrollers', [])
]; ];
$scope.value = ''; $scope.value = '';
$scope.loadValue = function(val){ $scope.loadValue = function(val) {
$scope.value = val; $scope.value = val;
} }
...@@ -330,7 +329,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -330,7 +329,7 @@ angular.module('blazer.mapcontrollers', [])
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);
...@@ -347,10 +346,10 @@ angular.module('blazer.mapcontrollers', []) ...@@ -347,10 +346,10 @@ angular.module('blazer.mapcontrollers', [])
} }
/* 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;
...@@ -369,14 +368,13 @@ angular.module('blazer.mapcontrollers', []) ...@@ -369,14 +368,13 @@ angular.module('blazer.mapcontrollers', [])
$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)
...@@ -391,14 +389,24 @@ angular.module('blazer.mapcontrollers', []) ...@@ -391,14 +389,24 @@ angular.module('blazer.mapcontrollers', [])
} }
/* 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.getBlazersData = function(){ $scope.getBlazersDataV2 = function() {
getBlazer.getBlazerDataInfo().then(function(data){ getBlazer.getMapData().then(function(data) {
$scope.blazersData = data;
console.log("[ Blazer Data V2 ]", JSON.stringify($scope.blazersData));
$scope.plotBlazers();
});
}
/* Show Blazers Data */
$scope.blazersData = {};
$scope.getBlazersData = function() {
getBlazer.getBlazerDataInfo().then(function(data) {
$scope.blazersData = data; $scope.blazersData = data;
console.log("[ Blazer Data ]", JSON.stringify($scope.blazersData)); console.log("[ Blazer Data ]", JSON.stringify($scope.blazersData));
$scope.plotBlazers(); $scope.plotBlazers();
...@@ -408,78 +416,107 @@ angular.module('blazer.mapcontrollers', []) ...@@ -408,78 +416,107 @@ angular.module('blazer.mapcontrollers', [])
/* Plot Blazers Data on Map */ /* Plot Blazers Data on Map */
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.barangay_name) {
if (feature.properties && feature.properties.username) layer.bindPopup('<div class="pop-up-containter">' + feature.properties.barangay_name + '</div>');
{
layer.bindPopup('<div class="pop-up-containter">Blazer</h4><div style="font-size: 15px">'+feature.properties.username+'</div></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());
} }
/* Weekly Survey Call */ /* Weekly Survey Call */
$scope.loadWeeklySurvey = function(){ $scope.loadWeeklySurvey = function() {
console.debug("********** Open Weekly Survey **********"); console.debug("********** Open Weekly Survey **********");
var newDate = new Date(); var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww'); var currentDate = $filter('date')(newDate, 'yyyyMMww');
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 + '!',
subTitle: 'Take the weekly survey. You are awesome!', subTitle: 'Take the weekly survey. You are awesome!',
scope: $scope, scope: $scope,
buttons: [ buttons: [{
{
text: 'Let\s go!', text: 'Let\s go!',
type: 'button-dark button-outline', type: 'button-dark button-outline',
onTap: function(e) { onTap: function(e) {
...@@ -500,20 +537,20 @@ angular.module('blazer.mapcontrollers', []) ...@@ -500,20 +537,20 @@ angular.module('blazer.mapcontrollers', [])
} }
} }
$scope.triggerWeeklySurvey = function(){ $scope.triggerWeeklySurvey = function() {
console.debug("********** Trigger Weekly Survey **********"); console.debug("********** Trigger Weekly Survey **********");
var newDate = new Date(); var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww'); var currentDate = $filter('date')(newDate, 'yyyyMMww');
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') {
if (localStorage.getItem(currentDate) === null) {
var tripPopup = $ionicPopup.show({ var tripPopup = $ionicPopup.show({
title: 'Hey it\'s '+dayToday+'!', title: 'Hey it\'s ' + dayToday + '!',
subTitle: 'Take the weekly survey. You are awesome!', subTitle: 'Take the weekly survey. You are awesome!',
scope: $scope, scope: $scope,
buttons: [ buttons: [{
{
text: 'Let\s go!', text: 'Let\s go!',
type: 'button-dark button-outline', type: 'button-dark button-outline',
onTap: function(e) { onTap: function(e) {
...@@ -530,10 +567,13 @@ angular.module('blazer.mapcontrollers', []) ...@@ -530,10 +567,13 @@ angular.module('blazer.mapcontrollers', [])
} }
] ]
}); });
} } else {
else {
$cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY"); $cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY");
} }
} 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 */ /* Popover Methods */
...@@ -563,7 +603,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -563,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) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<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">
......
<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="loadHeatMap();" class="item item-icon-left">
<i class="icon ion-android-pin"></i>
Load Heatmap
</a>-->
<a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left"> <a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left">
<i class="icon ion-android-clipboard"></i> <i class="icon ion-android-clipboard"></i> Weekly Survey
Weekly Survey
</a> </a>
</div> </div>
</ion-content> </ion-content>
......
...@@ -11,12 +11,20 @@ ...@@ -11,12 +11,20 @@
</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>
</h3>
<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>
<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-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-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/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/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>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
</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>
...@@ -15,33 +15,14 @@ ...@@ -15,33 +15,14 @@
<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>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_best}}</b></i>-->
</div> </div>
<!--<div class="item item-thumbnail-left item-borderless">
<img ng-src="img/info.png">
<i> Latest </i>
<p>Transportation: <i ng-if="!blazersStats.mode_latest">NULL</i>{{ blazersStats.mode_latest }}</p>
<p>Mood: <i ng-if="!blazersStats.emo_latest">NULL</i>{{ blazersStats.emo_latest }}</p>
</div> </div>
<div class="item item-thumbnail-left item-borderless"> <div class="list card">
<img ng-src="img/info.png">
<i>Frequently Used</i>
<p>Transportation: <i ng-if="!blazersStats.mode_frequent">NULL</i>{{ blazersStats.mode_frequent }}</p>
<p>Mood: <i ng-if="!blazersStats.emo_frequent">NULL</i>{{ blazersStats.emo_frequent }}</p>
</div>
<div class="item item-thumbnail-left item-borderless">
<img ng-src="img/info.png">
<i>Low-Carbon</i>
<p>Transportation: <i ng-if="!blazersStats.mode_best">NULL</i>{{ blazersStats.mode_best }}</p>
<p>Mood: <i ng-if="!blazersStats.emo_frequent_positive">NULL</i>{{ blazersStats.emo_frequent_positive }}</p>
</div>-->
<div class="item item-divider"> Time </div> <div class="item item-divider"> Time </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>
...@@ -55,21 +36,6 @@ ...@@ -55,21 +36,6 @@
<i class="button button-block button-clear bgbluegreen text-light">Best</i> <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> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_best }}</b></i>
</div> </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> </div>
</ion-content> </ion-content>
</ion-view> </ion-view>
\ No newline at end of file
...@@ -11,10 +11,10 @@ angular.module('blazer.surveycontrollers', []) ...@@ -11,10 +11,10 @@ angular.module('blazer.surveycontrollers', [])
}; };
$scope.endtrip = {}; $scope.endtrip = {};
$scope.postEndTripSurvey = function(){ $scope.postEndTripSurvey = 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) {
var tripID = localStorage.getItem("tripid"); var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime"); var startTime = localStorage.getItem("starttime");
...@@ -24,7 +24,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -24,7 +24,7 @@ angular.module('blazer.surveycontrollers', [])
var currentTrip = localStorage.getItem("currentTrip"); var currentTrip = localStorage.getItem("currentTrip");
var postdata = { var postdata = {
"trip_id" : tripID, "trip_id": tripID,
"username": username, "username": username,
"depart": startTime, "depart": startTime,
"arrive": endTime, "arrive": endTime,
...@@ -45,8 +45,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -45,8 +45,7 @@ angular.module('blazer.surveycontrollers', [])
$scope.endtrip = {}; $scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response); console.error("SEND ENDTRIP SURVEY ERROR", response);
}); });
} } else {
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY"); $cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
} }
} }
...@@ -55,22 +54,22 @@ angular.module('blazer.surveycontrollers', []) ...@@ -55,22 +54,22 @@ angular.module('blazer.surveycontrollers', [])
$ionicSlideBoxDelegate.enableSlide(false); $ionicSlideBoxDelegate.enableSlide(false);
}; };
$scope.currentIndex = ''; $scope.currentIndex = '';
$scope.backSlide = function(){ $scope.backSlide = function() {
$ionicScrollDelegate.scrollTop(true); $ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.previous(); $ionicSlideBoxDelegate.previous();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex(); $scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
} }
$scope.nextPageSlide = function(){ $scope.nextPageSlide = function() {
$ionicScrollDelegate.scrollTop(true); $ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.next(); $ionicSlideBoxDelegate.next();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex(); $scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
} }
$scope.weekly = {}; $scope.weekly = {};
$scope.postWeeklySurvey = function(){ $scope.postWeeklySurvey = function() {
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) {
var userID = localStorage.getItem("userID"); var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
var newDate = new Date(); var newDate = new Date();
...@@ -80,33 +79,18 @@ angular.module('blazer.surveycontrollers', []) ...@@ -80,33 +79,18 @@ angular.module('blazer.surveycontrollers', [])
var surveyAnswer = []; var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */ /* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){ 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){ angular.forEach($scope.choice1, function(value, key) {
surveyAnswer.push(parseInt(value)); if (value == 'N/A') {
}) surveyAnswer.push(value);
} } else {
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(parseInt(value)); 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 == 'C') {
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; surveyAnswer = null;
} }
// var surveyAns = surveyAnswer;
// var surveyAnsStr = surveyAns.join(",");
var surveyString = surveyAnswer.toString(); var surveyString = surveyAnswer.toString();
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString)); console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString));
...@@ -129,13 +113,12 @@ angular.module('blazer.surveycontrollers', []) ...@@ -129,13 +113,12 @@ angular.module('blazer.surveycontrollers', [])
$scope.resetValues(); $scope.resetValues();
$scope.closeWeeklyModal(); $scope.closeWeeklyModal();
}); });
} } else {
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY"); $cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
} }
} }
$scope.resetValues = function(){ $scope.resetValues = function() {
$scope.weekly = {}; $scope.weekly = {};
$scope.choice1 = { $scope.choice1 = {
one: "0", one: "0",
...@@ -253,9 +236,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -253,9 +236,7 @@ angular.module('blazer.surveycontrollers', [])
{ number: 13 }, { number: 13 },
{ number: 14 }, { number: 14 },
{ number: 15 } { number: 15 }
]; ];
$scope.selectedItem = $scope.items[2]; $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
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
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 {
...@@ -30,45 +33,76 @@ ...@@ -30,45 +33,76 @@
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;
...@@ -83,40 +117,51 @@ ...@@ -83,40 +117,51 @@
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;
} }
...@@ -132,17 +177,19 @@ ...@@ -132,17 +177,19 @@
-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 {
...@@ -162,14 +209,17 @@ ...@@ -162,14 +209,17 @@
.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;
...@@ -184,19 +234,23 @@ ...@@ -184,19 +234,23 @@
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;
} }
...@@ -205,9 +259,10 @@ ...@@ -205,9 +259,10 @@
/* 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;
...@@ -220,24 +275,29 @@ ...@@ -220,24 +275,29 @@
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;
...@@ -258,6 +318,7 @@ ...@@ -258,6 +318,7 @@
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;
} }
...@@ -265,6 +326,7 @@ ...@@ -265,6 +326,7 @@
.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;
} }
...@@ -273,44 +335,53 @@ ...@@ -273,44 +335,53 @@
/* 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;
...@@ -325,27 +396,34 @@ ...@@ -325,27 +396,34 @@
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;
...@@ -356,15 +434,16 @@ ...@@ -356,15 +434,16 @@
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;
} }
...@@ -374,9 +453,10 @@ ...@@ -374,9 +453,10 @@
.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;
} }
...@@ -387,18 +467,22 @@ ...@@ -387,18 +467,22 @@
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;
...@@ -406,25 +490,25 @@ ...@@ -406,25 +490,25 @@
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.leaflet-popup-tip { .leaflet-popup-tip {
width: 17px; width: 17px;
height: 17px; height: 17px;
padding: 1px; padding: 1px;
margin: -10px auto 0; margin: -10px auto 0;
-webkit-transform: rotate(45deg); -webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg); -moz-transform: rotate(45deg);
-ms-transform: rotate(45deg); -ms-transform: rotate(45deg);
-o-transform: rotate(45deg); -o-transform: rotate(45deg);
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;
...@@ -439,9 +523,11 @@ ...@@ -439,9 +523,11 @@
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;
...@@ -451,13 +537,14 @@ ...@@ -451,13 +537,14 @@
.leaflet-oldie .leaflet-popup-content-wrapper { .leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1; zoom: 1;
} }
.leaflet-oldie .leaflet-popup-tip { .leaflet-oldie .leaflet-popup-tip {
width: 24px; width: 24px;
margin: 0 auto; margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; -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); 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;
} }
......
<!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" />-->
...@@ -28,7 +29,8 @@ ...@@ -28,7 +29,8 @@
<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>
...@@ -56,9 +59,12 @@ ...@@ -56,9 +59,12 @@
<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
...@@ -10,6 +10,7 @@ angular.module('blazer', [ ...@@ -10,6 +10,7 @@ angular.module('blazer', [
'blazer.tripcontrollers', 'blazer.tripcontrollers',
'blazer.misccontrollers', 'blazer.misccontrollers',
'blazer.surveycontrollers', 'blazer.surveycontrollers',
'blazer.diarycontrollers',
'blazer.apiservices', 'blazer.apiservices',
'blazer.rideinformation', 'blazer.rideinformation',
'blazer.composemessage', 'blazer.composemessage',
...@@ -36,7 +37,7 @@ angular.module('blazer', [ ...@@ -36,7 +37,7 @@ angular.module('blazer', [
$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);
}) })
...@@ -178,5 +179,16 @@ angular.module('blazer', [ ...@@ -178,5 +179,16 @@ angular.module('blazer', [
} }
} }
}) })
/* DIARY */
.state('app.diary', {
url: '/diary',
views: {
'menuContent': {
templateUrl: 'app/diary/diary.html',
controller: 'DiaryCtrl'
}
}
})
$urlRouterProvider.otherwise('/landing'); $urlRouterProvider.otherwise('/landing');
}) })
\ No newline at end of file
...@@ -4,30 +4,24 @@ ...@@ -4,30 +4,24 @@
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 = [];
var AllSharedRideData = [];
var DetailedSharedRide = {};
var AllModesofTransport = {};
var AllBarangay = [];
return { return {
getBlazerDataInfo: function(){ getBlazerDataInfo: function() {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI + '/blazer_data.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { return $http.get(blazerAPI + '/blazer_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllBlazerData = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllBlazerData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -35,15 +29,15 @@ angular.module('blazer.apiservices', []) ...@@ -35,15 +29,15 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET USER PROFILE SERVICE ******"); console.log("****** ON ENTER GET USER PROFILE SERVICE ******");
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); // $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) { 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)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllUserData = response.data[0]; TempData = response.data[0];
$ionicLoading.hide(); $ionicLoading.hide();
return AllUserData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -51,18 +45,18 @@ angular.module('blazer.apiservices', []) ...@@ -51,18 +45,18 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******"); console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******");
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); // $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) { 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)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllTravelStatus = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllTravelStatus; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
/* NOT USED */ /* NOT USED */
...@@ -70,15 +64,15 @@ angular.module('blazer.apiservices', []) ...@@ -70,15 +64,15 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET SHARED RIDE SERVICE ******"); console.log("****** ON ENTER GET SHARED RIDE SERVICE ******");
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); // $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) { return $http.get(blazerAPI + '/take_shared_ride_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllSharedRideData = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllSharedRideData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -86,15 +80,15 @@ angular.module('blazer.apiservices', []) ...@@ -86,15 +80,15 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******"); console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******");
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); // $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) { 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)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllSharedRideData = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllSharedRideData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -102,11 +96,11 @@ angular.module('blazer.apiservices', []) ...@@ -102,11 +96,11 @@ angular.module('blazer.apiservices', [])
DetailedSharedRide = {}; DetailedSharedRide = {};
console.log("[ RIDE ID ]", rideID); console.log("[ RIDE ID ]", rideID);
console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******"); console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******");
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); $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) { 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)); // console.log('[ SUCCESS ]', JSON.stringify(response));
AllSharedRideData = response.data; TempData = response.data;
angular.forEach(AllSharedRideData, function(value, key) { angular.forEach(TempData, function(value, key) {
if (value.id === rideID) { if (value.id === rideID) {
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 } 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 }
console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide)); console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide));
...@@ -117,50 +111,123 @@ angular.module('blazer.apiservices', []) ...@@ -117,50 +111,123 @@ angular.module('blazer.apiservices', [])
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
/* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */ /* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */
getModeofTransportation: function(rideID) { getModeofTransportation: function(rideID) {
console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******"); console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******");
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); $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) { 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)); // console.log('[ SUCCESS ]', JSON.stringify(response));
AllModesofTransport = response.data; TempData = response.data;
angular.forEach(AllModesofTransport, function(value, key) { angular.forEach(TempData, function(value, key) {
if (value.id === rideID) { if (value.id === rideID) {
AllModesofTransport = {}; TempData = {};
console.log("[ MODE OF TRANSPORT ]", JSON.stringify(AllModesofTransport)); console.log("[ MODE OF TRANSPORT ]", JSON.stringify(TempData));
$ionicLoading.hide(); $ionicLoading.hide();
} }
}); });
return AllModesofTransport; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
getAllBarangay: function(){ getAllBarangay: function() {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI + '/get_barangay.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { return $http.get(blazerAPI + '/get_barangay.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllBarangay = response.data; TempData = response.data;
// LOOP BARANGAY DATA // LOOP BARANGAY DATA
var BarangayData = []; var BarangayData = [];
for(var i = 0; i < AllBarangay.length; i++){ for (var i = 0; i < TempData.length; i++) {
console.log("Barangay "+i,AllBarangay[i]); console.log("Barangay " + i, TempData[i]);
BarangayData.push({"name":AllBarangay[i]}); BarangayData.push({ "name": TempData[i] });
} }
$ionicLoading.hide(); $ionicLoading.hide();
return BarangayData; return BarangayData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
})
},
getMapData: function() {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
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;
}) })
}, },
...@@ -178,18 +245,19 @@ angular.module('blazer.apiservices', []) ...@@ -178,18 +245,19 @@ angular.module('blazer.apiservices', [])
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({
method: 'POST',
url: blazerAPI + '/login.php',
data: $.param(user), data: $.param(user),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData)); console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData));
if(responseData.status == 0){ if (responseData.status == 0) {
$ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000}); $ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000 });
deferred.reject('Error'); deferred.reject('Error');
} } else if (responseData.status == 1) {
else if(responseData.status == 1){
deferred.resolve('Success'); deferred.resolve('Success');
// $ionicLoading.show({ template: "Success!", duration: 500}); // $ionicLoading.show({ template: "Success!", duration: 500});
$ionicLoading.hide(); $ionicLoading.hide();
...@@ -199,7 +267,7 @@ angular.module('blazer.apiservices', []) ...@@ -199,7 +267,7 @@ angular.module('blazer.apiservices', [])
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Check your connection!", duration: 500}); $ionicLoading.show({ template: "Check your connection!", duration: 500 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -219,7 +287,7 @@ angular.module('blazer.apiservices', []) ...@@ -219,7 +287,7 @@ angular.module('blazer.apiservices', [])
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; 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 logTrip = {};
var currentTrip = localStorage.getItem("currentTrip"); var currentTrip = localStorage.getItem("currentTrip");
...@@ -232,9 +300,11 @@ angular.module('blazer.apiservices', []) ...@@ -232,9 +300,11 @@ angular.module('blazer.apiservices', [])
console.log("[ TRIP JSON ]", JSON.stringify(logTrip)); console.log("[ TRIP JSON ]", JSON.stringify(logTrip));
$http({ method: 'POST', url: blazerAPI + '/log_trip.php', $http({
method: 'POST',
url: blazerAPI + '/log_trip.php',
data: $.param(logTrip), data: $.param(logTrip),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
localStorage.setItem("tripid", responseData.trip_id); localStorage.setItem("tripid", responseData.trip_id);
...@@ -245,7 +315,7 @@ angular.module('blazer.apiservices', []) ...@@ -245,7 +315,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Sending Error!", duration: 1000}); $ionicLoading.show({ template: "Sending Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -265,7 +335,7 @@ angular.module('blazer.apiservices', []) ...@@ -265,7 +335,7 @@ angular.module('blazer.apiservices', [])
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
var endtripdata = { var endtripdata = {
"trip_id" : data.trip_id, "trip_id": data.trip_id,
"username": data.username, "username": data.username,
"depart": data.depart, "depart": data.depart,
"arrive": data.arrive, "arrive": data.arrive,
...@@ -278,21 +348,23 @@ angular.module('blazer.apiservices', []) ...@@ -278,21 +348,23 @@ angular.module('blazer.apiservices', [])
var stringendtripdata = angular.fromJson(endtripdata); var stringendtripdata = angular.fromJson(endtripdata);
console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data)); console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data));
$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 + '/end_trip.php', $http({
method: 'POST',
url: blazerAPI + '/end_trip.php',
data: $.param(stringendtripdata), data: $.param(stringendtripdata),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Submitted!", duration: 1000}); $ionicLoading.show({ template: "Submitted!", duration: 1000 });
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Try Again!", duration: 1000}); $ionicLoading.show({ template: "Try Again!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -313,7 +385,7 @@ angular.module('blazer.apiservices', []) ...@@ -313,7 +385,7 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data)); console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var weeklysurveydata = { var weeklysurveydata = {
"user_id": data.user_id, "user_id": data.user_id,
"username": data.username, "username": data.username,
...@@ -321,19 +393,21 @@ angular.module('blazer.apiservices', []) ...@@ -321,19 +393,21 @@ angular.module('blazer.apiservices', [])
"survey_ans": data.survey_ans, "survey_ans": data.survey_ans,
"date_created": data.date_created "date_created": data.date_created
}; };
$http({method: 'POST', url: blazerAPI + '/weekly_survey.php', $http({
method: 'POST',
url: blazerAPI + '/weekly_survey.php',
data: $.param(weeklysurveydata), data: $.param(weeklysurveydata),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Submitted!", duration: 1000}); $ionicLoading.show({ template: "Submitted!", duration: 1000 });
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Try Again!", duration: 1000}); $ionicLoading.show({ template: "Try Again!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -354,14 +428,16 @@ angular.module('blazer.apiservices', []) ...@@ -354,14 +428,16 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data)); console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var sharedRideData = { var sharedRideData = {
"ride_id": data.ride_id, "ride_id": data.ride_id,
"user": data.username "user": data.username
}; };
$http({method: 'POST', url: blazerAPI + '/take_shared_ride_post.php', $http({
method: 'POST',
url: blazerAPI + '/take_shared_ride_post.php',
data: $.param(sharedRideData), data: $.param(sharedRideData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
...@@ -371,7 +447,7 @@ angular.module('blazer.apiservices', []) ...@@ -371,7 +447,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -392,14 +468,16 @@ angular.module('blazer.apiservices', []) ...@@ -392,14 +468,16 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data)); console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var interestedRideData = { var interestedRideData = {
"ride_id": data.ride_id, "ride_id": data.ride_id,
"username": data.username "username": data.username
}; };
$http({method: 'POST', url: blazerAPI + '/interested_ride_post.php', $http({
method: 'POST',
url: blazerAPI + '/interested_ride_post.php',
data: $.param(interestedRideData), data: $.param(interestedRideData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
...@@ -409,7 +487,7 @@ angular.module('blazer.apiservices', []) ...@@ -409,7 +487,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -430,7 +508,7 @@ angular.module('blazer.apiservices', []) ...@@ -430,7 +508,7 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ OFFER DATA ] -> ", JSON.stringify(data)); console.log("[ OFFER DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var offerRiderData = { var offerRiderData = {
"name": data.name, "name": data.name,
"pickup_lat": data.pickup_lat, "pickup_lat": data.pickup_lat,
...@@ -443,17 +521,19 @@ angular.module('blazer.apiservices', []) ...@@ -443,17 +521,19 @@ angular.module('blazer.apiservices', [])
"mobile": data.mobile, "mobile": data.mobile,
"other": data.other "other": data.other
}; };
$http({method: 'POST', url: blazerAPI + '/offer_ride.php', $http({
method: 'POST',
url: blazerAPI + '/offer_ride.php',
data: $.param(offerRiderData), data: $.param(offerRiderData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Ride Offered", duration: 1000}); $ionicLoading.show({ template: "Ride Offered", duration: 1000 });
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData)); console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -474,16 +554,18 @@ angular.module('blazer.apiservices', []) ...@@ -474,16 +554,18 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data)); console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var selectedBarangay = { var selectedBarangay = {
"barangay": data.barangay, "barangay": data.barangay,
"time": data.time "time": data.time
}; };
$http({method: 'POST', url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php', $http({
method: 'POST',
url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php',
data: $.param(selectedBarangay), data: $.param(selectedBarangay),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData); deferred.resolve(responseData);
...@@ -493,7 +575,7 @@ angular.module('blazer.apiservices', []) ...@@ -493,7 +575,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -514,23 +596,426 @@ angular.module('blazer.apiservices', []) ...@@ -514,23 +596,426 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ EMAIL DATA ] -> ", JSON.stringify(data)); console.log("[ EMAIL DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var emailData = { var emailData = {
"email_address": data.email_address, "email_address": data.email_address,
}; };
$http({method: 'POST', url: 'http://blaze.eacomm.com/send_password.php', $http({
method: 'POST',
url: 'http://blaze.eacomm.com/send_password.php',
data: $.param(emailData), data: $.param(emailData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Success!", duration: 1000}); $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) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $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.success = function(fn) {
...@@ -548,7 +1033,7 @@ angular.module('blazer.apiservices', []) ...@@ -548,7 +1033,7 @@ angular.module('blazer.apiservices', [])
}) })
/*********** MAP DIRECTIVES ***********/ /*********** MAP DIRECTIVES ***********/
.service('LocationService', function($q){ .service('LocationService', function($q) {
var autocompleteService = new google.maps.places.AutocompleteService(); var autocompleteService = new google.maps.places.AutocompleteService();
var detailsService = new google.maps.places.PlacesService(document.createElement("input")); var detailsService = new google.maps.places.PlacesService(document.createElement("input"));
return { return {
...@@ -558,10 +1043,10 @@ angular.module('blazer.apiservices', []) ...@@ -558,10 +1043,10 @@ angular.module('blazer.apiservices', [])
autocompleteService.getPlacePredictions({ autocompleteService.getPlacePredictions({
input: input input: input
}, function(result, status) { }, function(result, status) {
if(status == google.maps.places.PlacesServiceStatus.OK){ if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log(status); console.log(status);
deferred.resolve(result); deferred.resolve(result);
}else{ } else {
deferred.reject(status) deferred.reject(status)
} }
}); });
...@@ -570,20 +1055,20 @@ angular.module('blazer.apiservices', []) ...@@ -570,20 +1055,20 @@ angular.module('blazer.apiservices', [])
}, },
getDetails: function(placeId) { getDetails: function(placeId) {
var deferred = $q.defer(); var deferred = $q.defer();
detailsService.getDetails({placeId: placeId}, function(result) { detailsService.getDetails({ placeId: placeId }, function(result) {
deferred.resolve(result); deferred.resolve(result);
}); });
return deferred.promise; return deferred.promise;
} }
}; };
}) })
.directive('locationSuggestion', function($ionicModal, LocationService){ .directive('locationSuggestion', function($ionicModal, LocationService) {
return { return {
restrict: 'A', restrict: 'A',
scope: { scope: {
location: '=' location: '='
}, },
link: function($scope, element){ link: function($scope, element) {
console.log('locationSuggestion started!'); console.log('locationSuggestion started!');
$scope.search = {}; $scope.search = {};
$scope.search.suggestions = []; $scope.search.suggestions = [];
...@@ -602,7 +1087,7 @@ angular.module('blazer.apiservices', []) ...@@ -602,7 +1087,7 @@ angular.module('blazer.apiservices', [])
LocationService.searchAddress(newValue).then(function(result) { LocationService.searchAddress(newValue).then(function(result) {
$scope.search.error = null; $scope.search.error = null;
$scope.search.suggestions = result; $scope.search.suggestions = result;
}, function(status){ }, function(status) {
$scope.search.error = "There was an error :( " + status; $scope.search.error = "There was an error :( " + status;
}); });
}; };
...@@ -621,5 +1106,4 @@ angular.module('blazer.apiservices', []) ...@@ -621,5 +1106,4 @@ angular.module('blazer.apiservices', [])
}); });
} }
} }
}) });
; \ 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
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// 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;
...@@ -37,13 +37,13 @@ ...@@ -37,13 +37,13 @@
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 * Wrapper for chart.js
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
* ChartJsProvider.setOptions('Line', { responsive: false }); * ChartJsProvider.setOptions('Line', { responsive: false });
* }))) * })))
*/ */
function ChartJsProvider () { function ChartJsProvider() {
var options = {}; var options = {};
var ChartJs = { var ChartJs = {
Chart: Chart, Chart: Chart,
getOptions: function (type) { getOptions: function(type) {
var typeOptions = type && options[type] || {}; var typeOptions = type && options[type] || {};
return angular.extend({}, options, typeOptions); return angular.extend({}, options, typeOptions);
} }
...@@ -67,9 +67,9 @@ ...@@ -67,9 +67,9 @@
/** /**
* Allow to set global options during configuration * Allow to set global options during configuration
*/ */
this.setOptions = function (type, customOptions) { this.setOptions = function(type, customOptions) {
// If no type was specified set option for the global object // If no type was specified set option for the global object
if (! customOptions) { if (!customOptions) {
customOptions = type; customOptions = type;
options = angular.extend(options, customOptions); options = angular.extend(options, customOptions);
return; return;
...@@ -78,13 +78,13 @@ ...@@ -78,13 +78,13 @@
options[type] = angular.extend(options[type] || {}, customOptions); options[type] = angular.extend(options[type] || {}, customOptions);
}; };
this.$get = function () { this.$get = function() {
return ChartJs; return ChartJs;
}; };
} }
function ChartJsFactory (ChartJs, $timeout) { function ChartJsFactory(ChartJs, $timeout) {
return function chart (type) { return function chart(type) {
return { return {
restrict: 'CA', restrict: 'CA',
scope: { scope: {
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
chartClick: '=?', chartClick: '=?',
chartHover: '=?' chartHover: '=?'
}, },
link: function (scope, elem/*, attrs */) { link: function(scope, elem /*, attrs */ ) {
var chart, container = document.createElement('div'); var chart, container = document.createElement('div');
container.className = 'chart-container'; container.className = 'chart-container';
elem.replaceWith(container); elem.replaceWith(container);
...@@ -117,8 +117,9 @@ ...@@ -117,8 +117,9 @@
if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated); ['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar (fromName, toName) {
scope.$watch(fromName, function (newVal) { function aliasVar(fromName, toName) {
scope.$watch(fromName, function(newVal) {
if (typeof newVal === 'undefined') return; if (typeof newVal === 'undefined') return;
scope[toName] = newVal; scope[toName] = newVal;
}); });
...@@ -136,10 +137,10 @@ ...@@ -136,10 +137,10 @@
// Order of setting "watch" matter // Order of setting "watch" matter
scope.$watch('data', function (newVal, oldVal) { scope.$watch('data', function(newVal, oldVal) {
if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) return; if (!newVal || !newVal.length || (Array.isArray(newVal[0]) && !newVal[0].length)) return;
var chartType = type || scope.chartType; var chartType = type || scope.chartType;
if (! chartType) return; if (!chartType) return;
if (chart) { if (chart) {
if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem); if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem);
...@@ -154,22 +155,22 @@ ...@@ -154,22 +155,22 @@
scope.$watch('options', resetChart, true); scope.$watch('options', resetChart, true);
scope.$watch('colours', resetChart, true); scope.$watch('colours', resetChart, true);
scope.$watch('chartType', function (newVal, oldVal) { scope.$watch('chartType', function(newVal, oldVal) {
if (isEmpty(newVal)) return; if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return; if (angular.equals(newVal, oldVal)) return;
if (chart) chart.destroy(); if (chart) chart.destroy();
createChart(newVal); createChart(newVal);
}); });
scope.$on('$destroy', function () { scope.$on('$destroy', function() {
if (chart) chart.destroy(); if (chart) chart.destroy();
}); });
function resetChart (newVal, oldVal) { function resetChart(newVal, oldVal) {
if (isEmpty(newVal)) return; if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return; if (angular.equals(newVal, oldVal)) return;
var chartType = type || scope.chartType; var chartType = type || scope.chartType;
if (! chartType) return; if (!chartType) return;
// chart.update() doesn't work for series and labels // chart.update() doesn't work for series and labels
// so we have to re-create the chart entirely // so we have to re-create the chart entirely
...@@ -178,16 +179,17 @@ ...@@ -178,16 +179,17 @@
createChart(chartType); createChart(chartType);
} }
function createChart (type) { function createChart(type) {
if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) { if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) {
return $timeout(function () { return $timeout(function() {
createChart(type); createChart(type);
}, 50, false); }, 50, false);
} }
if (! scope.data || ! scope.data.length) return; if (!scope.data || !scope.data.length) return;
scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour; scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour;
scope.colours = getColours(type, scope); scope.colours = getColours(type, scope);
var cvs = elem[0], ctx = cvs.getContext('2d'); var cvs = elem[0],
ctx = cvs.getContext('2d');
var data = Array.isArray(scope.data[0]) ? var data = Array.isArray(scope.data[0]) ?
getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) : getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :
getData(scope.labels, scope.data, scope.colours); getData(scope.labels, scope.data, scope.colours);
...@@ -202,10 +204,10 @@ ...@@ -202,10 +204,10 @@
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
} }
function deprecated (attr) { function deprecated(attr) {
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') { if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log; var warn = typeof console.warn === 'function' ? console.warn : console.log;
if (!! scope[attr]) { if (!!scope[attr]) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' + warn.call(console, '"%s" is deprecated and will be removed in a future version. ' +
'Please use "chart-%s" instead.', attr, attr); 'Please use "chart-%s" instead.', attr, attr);
} }
...@@ -215,23 +217,24 @@ ...@@ -215,23 +217,24 @@
}; };
}; };
function canUpdateChart (newVal, oldVal) { function canUpdateChart(newVal, oldVal) {
if (newVal && oldVal && newVal.length && oldVal.length) { if (newVal && oldVal && newVal.length && oldVal.length) {
return Array.isArray(newVal[0]) ? return Array.isArray(newVal[0]) ?
newVal.length === oldVal.length && newVal.every(function (element, index) { newVal.length === oldVal.length && newVal.every(function(element, index) {
return element.length === oldVal[index].length; }) : return element.length === oldVal[index].length;
}) :
oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false; oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;
} }
return 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);
...@@ -244,7 +247,7 @@ ...@@ -244,7 +247,7 @@
}; };
} }
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
...@@ -255,18 +258,18 @@ ...@@ -255,18 +258,18 @@
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),
...@@ -277,11 +280,11 @@ ...@@ -277,11 +280,11 @@
}; };
} }
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(',') + ')';
...@@ -291,7 +294,7 @@ ...@@ -291,7 +294,7 @@
} }
// 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,
...@@ -300,10 +303,10 @@ ...@@ -300,10 +303,10 @@
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
...@@ -312,8 +315,8 @@ ...@@ -312,8 +315,8 @@
}; };
} }
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],
...@@ -323,7 +326,7 @@ ...@@ -323,7 +326,7 @@
}); });
} }
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>';
...@@ -331,15 +334,15 @@ ...@@ -331,15 +334,15 @@
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];
}); });
} }
...@@ -348,13 +351,13 @@ ...@@ -348,13 +351,13 @@
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;
} }
......
/*
* 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,6 +544,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -497,6 +544,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' || 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 + '!',
...@@ -522,6 +570,10 @@ angular.module('blazer.mapcontrollers', []) ...@@ -522,6 +570,10 @@ angular.module('blazer.mapcontrollers', [])
} else { } else {
$cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY"); $cordovaDialogs.alert('You\'ve already taken this weeks\' weekly survey. Thank you.', 'Weekly Survey', "OKAY");
} }
} 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 */ /* Popover Methods */
...@@ -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) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<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">
......
<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="loadHeatMap();" class="item item-icon-left">
<i class="icon ion-android-pin"></i>
Load Heatmap
</a>-->
<a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left"> <a ng-click="triggerWeeklySurvey();closePopover($event);" class="item item-icon-left">
<i class="icon ion-android-clipboard"></i> <i class="icon ion-android-clipboard"></i> Weekly Survey
Weekly Survey
</a> </a>
</div> </div>
</ion-content> </ion-content>
......
...@@ -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>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
</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>
...@@ -15,33 +15,14 @@ ...@@ -15,33 +15,14 @@
<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>
<!--<i class="button button-block icon-left ion-android-time"><b>{{blazersStats.time_best}}</b></i>-->
</div> </div>
<!--<div class="item item-thumbnail-left item-borderless">
<img ng-src="img/info.png">
<i> Latest </i>
<p>Transportation: <i ng-if="!blazersStats.mode_latest">NULL</i>{{ blazersStats.mode_latest }}</p>
<p>Mood: <i ng-if="!blazersStats.emo_latest">NULL</i>{{ blazersStats.emo_latest }}</p>
</div> </div>
<div class="item item-thumbnail-left item-borderless"> <div class="list card">
<img ng-src="img/info.png">
<i>Frequently Used</i>
<p>Transportation: <i ng-if="!blazersStats.mode_frequent">NULL</i>{{ blazersStats.mode_frequent }}</p>
<p>Mood: <i ng-if="!blazersStats.emo_frequent">NULL</i>{{ blazersStats.emo_frequent }}</p>
</div>
<div class="item item-thumbnail-left item-borderless">
<img ng-src="img/info.png">
<i>Low-Carbon</i>
<p>Transportation: <i ng-if="!blazersStats.mode_best">NULL</i>{{ blazersStats.mode_best }}</p>
<p>Mood: <i ng-if="!blazersStats.emo_frequent_positive">NULL</i>{{ blazersStats.emo_frequent_positive }}</p>
</div>-->
<div class="item item-divider"> Time </div> <div class="item item-divider"> Time </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>
...@@ -55,21 +36,6 @@ ...@@ -55,21 +36,6 @@
<i class="button button-block button-clear bgbluegreen text-light">Best</i> <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> <i class="button button-block icon-left ion-android-time"><b>{{ blazersStats.time_best }}</b></i>
</div> </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> </div>
</ion-content> </ion-content>
</ion-view> </ion-view>
\ No newline at end of file
...@@ -11,10 +11,10 @@ angular.module('blazer.surveycontrollers', []) ...@@ -11,10 +11,10 @@ angular.module('blazer.surveycontrollers', [])
}; };
$scope.endtrip = {}; $scope.endtrip = {};
$scope.postEndTripSurvey = function(){ $scope.postEndTripSurvey = 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) {
var tripID = localStorage.getItem("tripid"); var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime"); var startTime = localStorage.getItem("starttime");
...@@ -24,7 +24,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -24,7 +24,7 @@ angular.module('blazer.surveycontrollers', [])
var currentTrip = localStorage.getItem("currentTrip"); var currentTrip = localStorage.getItem("currentTrip");
var postdata = { var postdata = {
"trip_id" : tripID, "trip_id": tripID,
"username": username, "username": username,
"depart": startTime, "depart": startTime,
"arrive": endTime, "arrive": endTime,
...@@ -45,8 +45,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -45,8 +45,7 @@ angular.module('blazer.surveycontrollers', [])
$scope.endtrip = {}; $scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response); console.error("SEND ENDTRIP SURVEY ERROR", response);
}); });
} } else {
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY"); $cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
} }
} }
...@@ -55,22 +54,22 @@ angular.module('blazer.surveycontrollers', []) ...@@ -55,22 +54,22 @@ angular.module('blazer.surveycontrollers', [])
$ionicSlideBoxDelegate.enableSlide(false); $ionicSlideBoxDelegate.enableSlide(false);
}; };
$scope.currentIndex = ''; $scope.currentIndex = '';
$scope.backSlide = function(){ $scope.backSlide = function() {
$ionicScrollDelegate.scrollTop(true); $ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.previous(); $ionicSlideBoxDelegate.previous();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex(); $scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
} }
$scope.nextPageSlide = function(){ $scope.nextPageSlide = function() {
$ionicScrollDelegate.scrollTop(true); $ionicScrollDelegate.scrollTop(true);
$ionicSlideBoxDelegate.next(); $ionicSlideBoxDelegate.next();
$scope.currentIndex = $ionicSlideBoxDelegate.currentIndex(); $scope.currentIndex = $ionicSlideBoxDelegate.currentIndex();
} }
$scope.weekly = {}; $scope.weekly = {};
$scope.postWeeklySurvey = function(){ $scope.postWeeklySurvey = function() {
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) {
var userID = localStorage.getItem("userID"); var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
var newDate = new Date(); var newDate = new Date();
...@@ -80,33 +79,18 @@ angular.module('blazer.surveycontrollers', []) ...@@ -80,33 +79,18 @@ angular.module('blazer.surveycontrollers', [])
var surveyAnswer = []; var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */ /* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){ 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){ angular.forEach($scope.choice1, function(value, key) {
surveyAnswer.push(parseInt(value)); if (value == 'N/A') {
}) surveyAnswer.push(value);
} } else {
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(parseInt(value)); 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 == 'C') {
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; surveyAnswer = null;
} }
// var surveyAns = surveyAnswer;
// var surveyAnsStr = surveyAns.join(",");
var surveyString = surveyAnswer.toString(); var surveyString = surveyAnswer.toString();
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString)); console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyString));
...@@ -129,13 +113,12 @@ angular.module('blazer.surveycontrollers', []) ...@@ -129,13 +113,12 @@ angular.module('blazer.surveycontrollers', [])
$scope.resetValues(); $scope.resetValues();
$scope.closeWeeklyModal(); $scope.closeWeeklyModal();
}); });
} } else {
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY"); $cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
} }
} }
$scope.resetValues = function(){ $scope.resetValues = function() {
$scope.weekly = {}; $scope.weekly = {};
$scope.choice1 = { $scope.choice1 = {
one: "0", one: "0",
...@@ -253,9 +236,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -253,9 +236,7 @@ angular.module('blazer.surveycontrollers', [])
{ number: 13 }, { number: 13 },
{ number: 14 }, { number: 14 },
{ number: 15 } { number: 15 }
]; ];
$scope.selectedItem = $scope.items[2]; $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
...@@ -18,10 +18,13 @@ ...@@ -18,10 +18,13 @@
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 {
...@@ -30,45 +33,76 @@ ...@@ -30,45 +33,76 @@
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;
...@@ -83,40 +117,51 @@ ...@@ -83,40 +117,51 @@
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;
} }
...@@ -132,17 +177,19 @@ ...@@ -132,17 +177,19 @@
-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 {
...@@ -162,14 +209,17 @@ ...@@ -162,14 +209,17 @@
.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;
...@@ -184,19 +234,23 @@ ...@@ -184,19 +234,23 @@
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;
} }
...@@ -205,9 +259,10 @@ ...@@ -205,9 +259,10 @@
/* 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;
...@@ -220,24 +275,29 @@ ...@@ -220,24 +275,29 @@
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;
...@@ -258,6 +318,7 @@ ...@@ -258,6 +318,7 @@
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;
} }
...@@ -265,6 +326,7 @@ ...@@ -265,6 +326,7 @@
.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;
} }
...@@ -273,44 +335,53 @@ ...@@ -273,44 +335,53 @@
/* 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;
...@@ -325,27 +396,34 @@ ...@@ -325,27 +396,34 @@
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;
...@@ -356,15 +434,16 @@ ...@@ -356,15 +434,16 @@
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;
} }
...@@ -374,9 +453,10 @@ ...@@ -374,9 +453,10 @@
.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;
} }
...@@ -387,18 +467,22 @@ ...@@ -387,18 +467,22 @@
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;
...@@ -406,25 +490,25 @@ ...@@ -406,25 +490,25 @@
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.leaflet-popup-tip { .leaflet-popup-tip {
width: 17px; width: 17px;
height: 17px; height: 17px;
padding: 1px; padding: 1px;
margin: -10px auto 0; margin: -10px auto 0;
-webkit-transform: rotate(45deg); -webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg); -moz-transform: rotate(45deg);
-ms-transform: rotate(45deg); -ms-transform: rotate(45deg);
-o-transform: rotate(45deg); -o-transform: rotate(45deg);
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;
...@@ -439,9 +523,11 @@ ...@@ -439,9 +523,11 @@
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;
...@@ -451,13 +537,14 @@ ...@@ -451,13 +537,14 @@
.leaflet-oldie .leaflet-popup-content-wrapper { .leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1; zoom: 1;
} }
.leaflet-oldie .leaflet-popup-tip { .leaflet-oldie .leaflet-popup-tip {
width: 24px; width: 24px;
margin: 0 auto; margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; -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); 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;
} }
......
<!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" />-->
...@@ -28,7 +29,8 @@ ...@@ -28,7 +29,8 @@
<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>
...@@ -56,9 +59,12 @@ ...@@ -56,9 +59,12 @@
<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
...@@ -10,6 +10,7 @@ angular.module('blazer', [ ...@@ -10,6 +10,7 @@ angular.module('blazer', [
'blazer.tripcontrollers', 'blazer.tripcontrollers',
'blazer.misccontrollers', 'blazer.misccontrollers',
'blazer.surveycontrollers', 'blazer.surveycontrollers',
'blazer.diarycontrollers',
'blazer.apiservices', 'blazer.apiservices',
'blazer.rideinformation', 'blazer.rideinformation',
'blazer.composemessage', 'blazer.composemessage',
...@@ -36,7 +37,7 @@ angular.module('blazer', [ ...@@ -36,7 +37,7 @@ angular.module('blazer', [
$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);
}) })
...@@ -178,5 +179,16 @@ angular.module('blazer', [ ...@@ -178,5 +179,16 @@ angular.module('blazer', [
} }
} }
}) })
/* DIARY */
.state('app.diary', {
url: '/diary',
views: {
'menuContent': {
templateUrl: 'app/diary/diary.html',
controller: 'DiaryCtrl'
}
}
})
$urlRouterProvider.otherwise('/landing'); $urlRouterProvider.otherwise('/landing');
}) })
\ No newline at end of file
...@@ -4,30 +4,24 @@ ...@@ -4,30 +4,24 @@
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 = [];
var AllSharedRideData = [];
var DetailedSharedRide = {};
var AllModesofTransport = {};
var AllBarangay = [];
return { return {
getBlazerDataInfo: function(){ getBlazerDataInfo: function() {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI + '/blazer_data.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { return $http.get(blazerAPI + '/blazer_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllBlazerData = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllBlazerData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -35,15 +29,15 @@ angular.module('blazer.apiservices', []) ...@@ -35,15 +29,15 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET USER PROFILE SERVICE ******"); console.log("****** ON ENTER GET USER PROFILE SERVICE ******");
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); // $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) { 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)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllUserData = response.data[0]; TempData = response.data[0];
$ionicLoading.hide(); $ionicLoading.hide();
return AllUserData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -51,18 +45,18 @@ angular.module('blazer.apiservices', []) ...@@ -51,18 +45,18 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******"); console.log("****** ON ENTER GET USER TRAVEL STATUS SERVICE ******");
// $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); // $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) { 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)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllTravelStatus = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllTravelStatus; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
/* NOT USED */ /* NOT USED */
...@@ -70,15 +64,15 @@ angular.module('blazer.apiservices', []) ...@@ -70,15 +64,15 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET SHARED RIDE SERVICE ******"); console.log("****** ON ENTER GET SHARED RIDE SERVICE ******");
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); // $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) { return $http.get(blazerAPI + '/take_shared_ride_data.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllSharedRideData = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllSharedRideData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -86,15 +80,15 @@ angular.module('blazer.apiservices', []) ...@@ -86,15 +80,15 @@ angular.module('blazer.apiservices', [])
console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******"); console.log("****** ON ENTER GET TAKE A SHARED RIDE SERVICE ******");
// $ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); // $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) { 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)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllSharedRideData = response.data; TempData = response.data;
$ionicLoading.hide(); $ionicLoading.hide();
return AllSharedRideData; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
...@@ -102,11 +96,11 @@ angular.module('blazer.apiservices', []) ...@@ -102,11 +96,11 @@ angular.module('blazer.apiservices', [])
DetailedSharedRide = {}; DetailedSharedRide = {};
console.log("[ RIDE ID ]", rideID); console.log("[ RIDE ID ]", rideID);
console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******"); console.log("****** ON ENTER GET DETAILED SHARED RIDE SERVICE ******");
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); $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) { 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)); // console.log('[ SUCCESS ]', JSON.stringify(response));
AllSharedRideData = response.data; TempData = response.data;
angular.forEach(AllSharedRideData, function(value, key) { angular.forEach(TempData, function(value, key) {
if (value.id === rideID) { if (value.id === rideID) {
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 } 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 }
console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide)); console.log("[ DETAILED SHARED RIDE ]", JSON.stringify(DetailedSharedRide));
...@@ -117,50 +111,123 @@ angular.module('blazer.apiservices', []) ...@@ -117,50 +111,123 @@ angular.module('blazer.apiservices', [])
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
/* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */ /* PENDING PENDING PENDING PENDING PENDING PENDING PENDING */
getModeofTransportation: function(rideID) { getModeofTransportation: function(rideID) {
console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******"); console.log("****** ON ENTER MODE OF TRANSPORT SERVICE ******");
$ionicLoading.show( { template: '<ion-spinner icon="crescent"></ion-spinner>'} ); $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) { 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)); // console.log('[ SUCCESS ]', JSON.stringify(response));
AllModesofTransport = response.data; TempData = response.data;
angular.forEach(AllModesofTransport, function(value, key) { angular.forEach(TempData, function(value, key) {
if (value.id === rideID) { if (value.id === rideID) {
AllModesofTransport = {}; TempData = {};
console.log("[ MODE OF TRANSPORT ]", JSON.stringify(AllModesofTransport)); console.log("[ MODE OF TRANSPORT ]", JSON.stringify(TempData));
$ionicLoading.hide(); $ionicLoading.hide();
} }
}); });
return AllModesofTransport; return TempData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
}) })
}, },
getAllBarangay: function(){ getAllBarangay: function() {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>'}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
return $http.get(blazerAPI + '/get_barangay.php', {headers : {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(response) { return $http.get(blazerAPI + '/get_barangay.php', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }).then(function(response) {
console.log('[ SUCCESS ]', JSON.stringify(response)); console.log('[ SUCCESS ]', JSON.stringify(response));
AllBarangay = response.data; TempData = response.data;
// LOOP BARANGAY DATA // LOOP BARANGAY DATA
var BarangayData = []; var BarangayData = [];
for(var i = 0; i < AllBarangay.length; i++){ for (var i = 0; i < TempData.length; i++) {
console.log("Barangay "+i,AllBarangay[i]); console.log("Barangay " + i, TempData[i]);
BarangayData.push({"name":AllBarangay[i]}); BarangayData.push({ "name": TempData[i] });
} }
$ionicLoading.hide(); $ionicLoading.hide();
return BarangayData; return BarangayData;
}, function(err) { }, function(err) {
console.error('[ ERROR ]', JSON.stringify(err)); console.error('[ ERROR ]', JSON.stringify(err));
$ionicLoading.hide(); $ionicLoading.hide();
return ; return;
})
},
getMapData: function() {
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>' });
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;
}) })
}, },
...@@ -178,18 +245,19 @@ angular.module('blazer.apiservices', []) ...@@ -178,18 +245,19 @@ angular.module('blazer.apiservices', [])
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({
method: 'POST',
url: blazerAPI + '/login.php',
data: $.param(user), data: $.param(user),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData)); console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData));
if(responseData.status == 0){ if (responseData.status == 0) {
$ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000}); $ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000 });
deferred.reject('Error'); deferred.reject('Error');
} } else if (responseData.status == 1) {
else if(responseData.status == 1){
deferred.resolve('Success'); deferred.resolve('Success');
// $ionicLoading.show({ template: "Success!", duration: 500}); // $ionicLoading.show({ template: "Success!", duration: 500});
$ionicLoading.hide(); $ionicLoading.hide();
...@@ -199,7 +267,7 @@ angular.module('blazer.apiservices', []) ...@@ -199,7 +267,7 @@ angular.module('blazer.apiservices', [])
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Check your connection!", duration: 500}); $ionicLoading.show({ template: "Check your connection!", duration: 500 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -219,7 +287,7 @@ angular.module('blazer.apiservices', []) ...@@ -219,7 +287,7 @@ angular.module('blazer.apiservices', [])
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; 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 logTrip = {};
var currentTrip = localStorage.getItem("currentTrip"); var currentTrip = localStorage.getItem("currentTrip");
...@@ -232,9 +300,11 @@ angular.module('blazer.apiservices', []) ...@@ -232,9 +300,11 @@ angular.module('blazer.apiservices', [])
console.log("[ TRIP JSON ]", JSON.stringify(logTrip)); console.log("[ TRIP JSON ]", JSON.stringify(logTrip));
$http({ method: 'POST', url: blazerAPI + '/log_trip.php', $http({
method: 'POST',
url: blazerAPI + '/log_trip.php',
data: $.param(logTrip), data: $.param(logTrip),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
localStorage.setItem("tripid", responseData.trip_id); localStorage.setItem("tripid", responseData.trip_id);
...@@ -245,7 +315,7 @@ angular.module('blazer.apiservices', []) ...@@ -245,7 +315,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Sending Error!", duration: 1000}); $ionicLoading.show({ template: "Sending Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -265,7 +335,7 @@ angular.module('blazer.apiservices', []) ...@@ -265,7 +335,7 @@ angular.module('blazer.apiservices', [])
var deferred = $q.defer(); var deferred = $q.defer();
var promise = deferred.promise; var promise = deferred.promise;
var endtripdata = { var endtripdata = {
"trip_id" : data.trip_id, "trip_id": data.trip_id,
"username": data.username, "username": data.username,
"depart": data.depart, "depart": data.depart,
"arrive": data.arrive, "arrive": data.arrive,
...@@ -278,21 +348,23 @@ angular.module('blazer.apiservices', []) ...@@ -278,21 +348,23 @@ angular.module('blazer.apiservices', [])
var stringendtripdata = angular.fromJson(endtripdata); var stringendtripdata = angular.fromJson(endtripdata);
console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data)); console.log("[ END TRIP SURVEY ] -> ", JSON.stringify(data));
$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 + '/end_trip.php', $http({
method: 'POST',
url: blazerAPI + '/end_trip.php',
data: $.param(stringendtripdata), data: $.param(stringendtripdata),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Submitted!", duration: 1000}); $ionicLoading.show({ template: "Submitted!", duration: 1000 });
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Try Again!", duration: 1000}); $ionicLoading.show({ template: "Try Again!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -313,7 +385,7 @@ angular.module('blazer.apiservices', []) ...@@ -313,7 +385,7 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data)); console.log("[ WEEKLY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var weeklysurveydata = { var weeklysurveydata = {
"user_id": data.user_id, "user_id": data.user_id,
"username": data.username, "username": data.username,
...@@ -321,19 +393,21 @@ angular.module('blazer.apiservices', []) ...@@ -321,19 +393,21 @@ angular.module('blazer.apiservices', [])
"survey_ans": data.survey_ans, "survey_ans": data.survey_ans,
"date_created": data.date_created "date_created": data.date_created
}; };
$http({method: 'POST', url: blazerAPI + '/weekly_survey.php', $http({
method: 'POST',
url: blazerAPI + '/weekly_survey.php',
data: $.param(weeklysurveydata), data: $.param(weeklysurveydata),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Submitted!", duration: 1000}); $ionicLoading.show({ template: "Submitted!", duration: 1000 });
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Try Again!", duration: 1000}); $ionicLoading.show({ template: "Try Again!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -354,14 +428,16 @@ angular.module('blazer.apiservices', []) ...@@ -354,14 +428,16 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data)); console.log("[ TAKE A SHAREDRIDE DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var sharedRideData = { var sharedRideData = {
"ride_id": data.ride_id, "ride_id": data.ride_id,
"user": data.username "user": data.username
}; };
$http({method: 'POST', url: blazerAPI + '/take_shared_ride_post.php', $http({
method: 'POST',
url: blazerAPI + '/take_shared_ride_post.php',
data: $.param(sharedRideData), data: $.param(sharedRideData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
...@@ -371,7 +447,7 @@ angular.module('blazer.apiservices', []) ...@@ -371,7 +447,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -392,14 +468,16 @@ angular.module('blazer.apiservices', []) ...@@ -392,14 +468,16 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data)); console.log("[ INTERESTED DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var interestedRideData = { var interestedRideData = {
"ride_id": data.ride_id, "ride_id": data.ride_id,
"username": data.username "username": data.username
}; };
$http({method: 'POST', url: blazerAPI + '/interested_ride_post.php', $http({
method: 'POST',
url: blazerAPI + '/interested_ride_post.php',
data: $.param(interestedRideData), data: $.param(interestedRideData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
...@@ -409,7 +487,7 @@ angular.module('blazer.apiservices', []) ...@@ -409,7 +487,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -430,7 +508,7 @@ angular.module('blazer.apiservices', []) ...@@ -430,7 +508,7 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ OFFER DATA ] -> ", JSON.stringify(data)); console.log("[ OFFER DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var offerRiderData = { var offerRiderData = {
"name": data.name, "name": data.name,
"pickup_lat": data.pickup_lat, "pickup_lat": data.pickup_lat,
...@@ -443,17 +521,19 @@ angular.module('blazer.apiservices', []) ...@@ -443,17 +521,19 @@ angular.module('blazer.apiservices', [])
"mobile": data.mobile, "mobile": data.mobile,
"other": data.other "other": data.other
}; };
$http({method: 'POST', url: blazerAPI + '/offer_ride.php', $http({
method: 'POST',
url: blazerAPI + '/offer_ride.php',
data: $.param(offerRiderData), data: $.param(offerRiderData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Ride Offered", duration: 1000}); $ionicLoading.show({ template: "Ride Offered", duration: 1000 });
}).error(function(responseData) { }).error(function(responseData) {
console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData)); console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -474,16 +554,18 @@ angular.module('blazer.apiservices', []) ...@@ -474,16 +554,18 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data)); console.log("[ BARANGAY DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var selectedBarangay = { var selectedBarangay = {
"barangay": data.barangay, "barangay": data.barangay,
"time": data.time "time": data.time
}; };
$http({method: 'POST', url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php', $http({
method: 'POST',
url: 'http://blaze.eacomm.com/includes/barangay/barangay_percentage.php',
data: $.param(selectedBarangay), data: $.param(selectedBarangay),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve(responseData); deferred.resolve(responseData);
...@@ -493,7 +575,7 @@ angular.module('blazer.apiservices', []) ...@@ -493,7 +575,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $ionicLoading.show({ template: "Request Error!", duration: 1000 });
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -514,23 +596,426 @@ angular.module('blazer.apiservices', []) ...@@ -514,23 +596,426 @@ angular.module('blazer.apiservices', [])
var promise = deferred.promise; var promise = deferred.promise;
console.log("[ EMAIL DATA ] -> ", JSON.stringify(data)); console.log("[ EMAIL DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000}); $ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000 });
var emailData = { var emailData = {
"email_address": data.email_address, "email_address": data.email_address,
}; };
$http({method: 'POST', url: 'http://blaze.eacomm.com/send_password.php', $http({
method: 'POST',
url: 'http://blaze.eacomm.com/send_password.php',
data: $.param(emailData), data: $.param(emailData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'} headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(responseData) { }).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData)); console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success'); deferred.resolve('Success');
$ionicLoading.show({ template: "Success!", duration: 1000}); $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) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
$ionicLoading.show({ template: "Request Error!", duration: 1000}); $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.success = function(fn) {
...@@ -548,7 +1033,7 @@ angular.module('blazer.apiservices', []) ...@@ -548,7 +1033,7 @@ angular.module('blazer.apiservices', [])
}) })
/*********** MAP DIRECTIVES ***********/ /*********** MAP DIRECTIVES ***********/
.service('LocationService', function($q){ .service('LocationService', function($q) {
var autocompleteService = new google.maps.places.AutocompleteService(); var autocompleteService = new google.maps.places.AutocompleteService();
var detailsService = new google.maps.places.PlacesService(document.createElement("input")); var detailsService = new google.maps.places.PlacesService(document.createElement("input"));
return { return {
...@@ -558,10 +1043,10 @@ angular.module('blazer.apiservices', []) ...@@ -558,10 +1043,10 @@ angular.module('blazer.apiservices', [])
autocompleteService.getPlacePredictions({ autocompleteService.getPlacePredictions({
input: input input: input
}, function(result, status) { }, function(result, status) {
if(status == google.maps.places.PlacesServiceStatus.OK){ if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log(status); console.log(status);
deferred.resolve(result); deferred.resolve(result);
}else{ } else {
deferred.reject(status) deferred.reject(status)
} }
}); });
...@@ -570,20 +1055,20 @@ angular.module('blazer.apiservices', []) ...@@ -570,20 +1055,20 @@ angular.module('blazer.apiservices', [])
}, },
getDetails: function(placeId) { getDetails: function(placeId) {
var deferred = $q.defer(); var deferred = $q.defer();
detailsService.getDetails({placeId: placeId}, function(result) { detailsService.getDetails({ placeId: placeId }, function(result) {
deferred.resolve(result); deferred.resolve(result);
}); });
return deferred.promise; return deferred.promise;
} }
}; };
}) })
.directive('locationSuggestion', function($ionicModal, LocationService){ .directive('locationSuggestion', function($ionicModal, LocationService) {
return { return {
restrict: 'A', restrict: 'A',
scope: { scope: {
location: '=' location: '='
}, },
link: function($scope, element){ link: function($scope, element) {
console.log('locationSuggestion started!'); console.log('locationSuggestion started!');
$scope.search = {}; $scope.search = {};
$scope.search.suggestions = []; $scope.search.suggestions = [];
...@@ -602,7 +1087,7 @@ angular.module('blazer.apiservices', []) ...@@ -602,7 +1087,7 @@ angular.module('blazer.apiservices', [])
LocationService.searchAddress(newValue).then(function(result) { LocationService.searchAddress(newValue).then(function(result) {
$scope.search.error = null; $scope.search.error = null;
$scope.search.suggestions = result; $scope.search.suggestions = result;
}, function(status){ }, function(status) {
$scope.search.error = "There was an error :( " + status; $scope.search.error = "There was an error :( " + status;
}); });
}; };
...@@ -621,5 +1106,4 @@ angular.module('blazer.apiservices', []) ...@@ -621,5 +1106,4 @@ angular.module('blazer.apiservices', [])
}); });
} }
} }
}) });
; \ 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
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// 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;
...@@ -37,13 +37,13 @@ ...@@ -37,13 +37,13 @@
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 * Wrapper for chart.js
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
* ChartJsProvider.setOptions('Line', { responsive: false }); * ChartJsProvider.setOptions('Line', { responsive: false });
* }))) * })))
*/ */
function ChartJsProvider () { function ChartJsProvider() {
var options = {}; var options = {};
var ChartJs = { var ChartJs = {
Chart: Chart, Chart: Chart,
getOptions: function (type) { getOptions: function(type) {
var typeOptions = type && options[type] || {}; var typeOptions = type && options[type] || {};
return angular.extend({}, options, typeOptions); return angular.extend({}, options, typeOptions);
} }
...@@ -67,9 +67,9 @@ ...@@ -67,9 +67,9 @@
/** /**
* Allow to set global options during configuration * Allow to set global options during configuration
*/ */
this.setOptions = function (type, customOptions) { this.setOptions = function(type, customOptions) {
// If no type was specified set option for the global object // If no type was specified set option for the global object
if (! customOptions) { if (!customOptions) {
customOptions = type; customOptions = type;
options = angular.extend(options, customOptions); options = angular.extend(options, customOptions);
return; return;
...@@ -78,13 +78,13 @@ ...@@ -78,13 +78,13 @@
options[type] = angular.extend(options[type] || {}, customOptions); options[type] = angular.extend(options[type] || {}, customOptions);
}; };
this.$get = function () { this.$get = function() {
return ChartJs; return ChartJs;
}; };
} }
function ChartJsFactory (ChartJs, $timeout) { function ChartJsFactory(ChartJs, $timeout) {
return function chart (type) { return function chart(type) {
return { return {
restrict: 'CA', restrict: 'CA',
scope: { scope: {
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
chartClick: '=?', chartClick: '=?',
chartHover: '=?' chartHover: '=?'
}, },
link: function (scope, elem/*, attrs */) { link: function(scope, elem /*, attrs */ ) {
var chart, container = document.createElement('div'); var chart, container = document.createElement('div');
container.className = 'chart-container'; container.className = 'chart-container';
elem.replaceWith(container); elem.replaceWith(container);
...@@ -117,8 +117,9 @@ ...@@ -117,8 +117,9 @@
if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);
['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated); ['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar (fromName, toName) {
scope.$watch(fromName, function (newVal) { function aliasVar(fromName, toName) {
scope.$watch(fromName, function(newVal) {
if (typeof newVal === 'undefined') return; if (typeof newVal === 'undefined') return;
scope[toName] = newVal; scope[toName] = newVal;
}); });
...@@ -136,10 +137,10 @@ ...@@ -136,10 +137,10 @@
// Order of setting "watch" matter // Order of setting "watch" matter
scope.$watch('data', function (newVal, oldVal) { scope.$watch('data', function(newVal, oldVal) {
if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) return; if (!newVal || !newVal.length || (Array.isArray(newVal[0]) && !newVal[0].length)) return;
var chartType = type || scope.chartType; var chartType = type || scope.chartType;
if (! chartType) return; if (!chartType) return;
if (chart) { if (chart) {
if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem); if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope, elem);
...@@ -154,22 +155,22 @@ ...@@ -154,22 +155,22 @@
scope.$watch('options', resetChart, true); scope.$watch('options', resetChart, true);
scope.$watch('colours', resetChart, true); scope.$watch('colours', resetChart, true);
scope.$watch('chartType', function (newVal, oldVal) { scope.$watch('chartType', function(newVal, oldVal) {
if (isEmpty(newVal)) return; if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return; if (angular.equals(newVal, oldVal)) return;
if (chart) chart.destroy(); if (chart) chart.destroy();
createChart(newVal); createChart(newVal);
}); });
scope.$on('$destroy', function () { scope.$on('$destroy', function() {
if (chart) chart.destroy(); if (chart) chart.destroy();
}); });
function resetChart (newVal, oldVal) { function resetChart(newVal, oldVal) {
if (isEmpty(newVal)) return; if (isEmpty(newVal)) return;
if (angular.equals(newVal, oldVal)) return; if (angular.equals(newVal, oldVal)) return;
var chartType = type || scope.chartType; var chartType = type || scope.chartType;
if (! chartType) return; if (!chartType) return;
// chart.update() doesn't work for series and labels // chart.update() doesn't work for series and labels
// so we have to re-create the chart entirely // so we have to re-create the chart entirely
...@@ -178,16 +179,17 @@ ...@@ -178,16 +179,17 @@
createChart(chartType); createChart(chartType);
} }
function createChart (type) { function createChart(type) {
if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) { if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) {
return $timeout(function () { return $timeout(function() {
createChart(type); createChart(type);
}, 50, false); }, 50, false);
} }
if (! scope.data || ! scope.data.length) return; if (!scope.data || !scope.data.length) return;
scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour; scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour;
scope.colours = getColours(type, scope); scope.colours = getColours(type, scope);
var cvs = elem[0], ctx = cvs.getContext('2d'); var cvs = elem[0],
ctx = cvs.getContext('2d');
var data = Array.isArray(scope.data[0]) ? var data = Array.isArray(scope.data[0]) ?
getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) : getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :
getData(scope.labels, scope.data, scope.colours); getData(scope.labels, scope.data, scope.colours);
...@@ -202,10 +204,10 @@ ...@@ -202,10 +204,10 @@
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
} }
function deprecated (attr) { function deprecated(attr) {
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') { if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log; var warn = typeof console.warn === 'function' ? console.warn : console.log;
if (!! scope[attr]) { if (!!scope[attr]) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' + warn.call(console, '"%s" is deprecated and will be removed in a future version. ' +
'Please use "chart-%s" instead.', attr, attr); 'Please use "chart-%s" instead.', attr, attr);
} }
...@@ -215,23 +217,24 @@ ...@@ -215,23 +217,24 @@
}; };
}; };
function canUpdateChart (newVal, oldVal) { function canUpdateChart(newVal, oldVal) {
if (newVal && oldVal && newVal.length && oldVal.length) { if (newVal && oldVal && newVal.length && oldVal.length) {
return Array.isArray(newVal[0]) ? return Array.isArray(newVal[0]) ?
newVal.length === oldVal.length && newVal.every(function (element, index) { newVal.length === oldVal.length && newVal.every(function(element, index) {
return element.length === oldVal[index].length; }) : return element.length === oldVal[index].length;
}) :
oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false; oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;
} }
return 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);
...@@ -244,7 +247,7 @@ ...@@ -244,7 +247,7 @@
}; };
} }
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
...@@ -255,18 +258,18 @@ ...@@ -255,18 +258,18 @@
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),
...@@ -277,11 +280,11 @@ ...@@ -277,11 +280,11 @@
}; };
} }
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(',') + ')';
...@@ -291,7 +294,7 @@ ...@@ -291,7 +294,7 @@
} }
// 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,
...@@ -300,10 +303,10 @@ ...@@ -300,10 +303,10 @@
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
...@@ -312,8 +315,8 @@ ...@@ -312,8 +315,8 @@
}; };
} }
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],
...@@ -323,7 +326,7 @@ ...@@ -323,7 +326,7 @@
}); });
} }
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>';
...@@ -331,15 +334,15 @@ ...@@ -331,15 +334,15 @@
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];
}); });
} }
...@@ -348,13 +351,13 @@ ...@@ -348,13 +351,13 @@
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;
} }
......
/*
* 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