Commit 8f40d846 authored by Bon Lemuel Dela Cruz's avatar Bon Lemuel Dela Cruz

Offer Ride API - Weekly Survey - Login Creds - Networking Checking - Persistnet Login

parent 09b2d1c6
{"app_id":"173c9de2","api_key":"9956c58a0ec5ca8b9d0d355905b2fb18c78e5acec2d3b216"}
\ No newline at end of file
{ {
"name": "BLAZER", "name": "BLAZER",
"app_id": "", "app_id": "173c9de2",
"browsers": [ "browsers": [
{ {
"platform": "android", "platform": "android",
......
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
{ {
"xml": "<feature name=\"InAppBrowser\"><param name=\"android-package\" value=\"org.apache.cordova.inappbrowser.InAppBrowser\" /></feature>", "xml": "<feature name=\"InAppBrowser\"><param name=\"android-package\" value=\"org.apache.cordova.inappbrowser.InAppBrowser\" /></feature>",
"count": 1 "count": 1
},
{
"xml": "<feature name=\"NetworkStatus\"><param name=\"android-package\" value=\"org.apache.cordova.networkinformation.NetworkManager\" /></feature>",
"count": 1
} }
] ]
} }
...@@ -84,7 +88,7 @@ ...@@ -84,7 +88,7 @@
}, },
{ {
"xml": "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />", "xml": "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />",
"count": 1 "count": 2
}, },
{ {
"xml": "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />", "xml": "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />",
...@@ -133,6 +137,9 @@ ...@@ -133,6 +137,9 @@
}, },
"cordova-plugin-inappbrowser": { "cordova-plugin-inappbrowser": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192" "PACKAGE_NAME": "com.ionicframework.blazerapp561192"
},
"cordova-plugin-network-information": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
} }
}, },
"dependent_plugins": {}, "dependent_plugins": {},
...@@ -199,6 +206,21 @@ ...@@ -199,6 +206,21 @@
"cordova.InAppBrowser.open", "cordova.InAppBrowser.open",
"window.open" "window.open"
] ]
},
{
"file": "plugins/cordova-plugin-network-information/www/network.js",
"id": "cordova-plugin-network-information.network",
"clobbers": [
"navigator.connection",
"navigator.network.connection"
]
},
{
"file": "plugins/cordova-plugin-network-information/www/Connection.js",
"id": "cordova-plugin-network-information.Connection",
"clobbers": [
"Connection"
]
} }
], ],
"plugin_metadata": { "plugin_metadata": {
...@@ -212,6 +234,7 @@ ...@@ -212,6 +234,7 @@
"ionic-plugin-keyboard": "2.2.0", "ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1", "cordova-plugin-dialogs": "1.2.1",
"cordova-plugin-crosswalk-webview": "2.1.0", "cordova-plugin-crosswalk-webview": "2.1.0",
"cordova-plugin-inappbrowser": "1.5.0" "cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-network-information": "1.3.0"
} }
} }
\ No newline at end of file
angular.module('blazer.authenticationcontrollers', []) angular.module('blazer.authenticationcontrollers', [])
.controller('AuthCtrl', function($scope, $state, postBlazer, $timeout, $ionicPopup, $cordovaDialogs, $cordovaInAppBrowser) { .controller('AuthCtrl', function($scope, $state, postBlazer, $timeout, $filter, $ionicPopup, $cordovaDialogs, $cordovaInAppBrowser) {
$scope.user = { // $scope.user = {
username: "blazetestaccount", // username: "blazetestaccount",
password: "blazetestaccount" // password: "blazetestaccount"
}; // };
// $scope.user = {}; $scope.user = {};
$scope.loginUser = function(){ $scope.loginUser = function(){
postBlazer.LoginUser($scope.user) var user = {
username: $filter('lowercase')($scope.user.username),
password: $scope.user.password
}
postBlazer.LoginUser(user)
.success(function(response) { .success(function(response) {
console.log("LOGIN SUCCESS", response); console.log("LOGIN SUCCESS", response);
$state.go('app.map');
localStorage.setItem("username", $scope.user.username); localStorage.setItem("username", $scope.user.username);
localStorage.setItem("password", $scope.user.password);
$scope.user = {};
$state.go('app.map');
}) })
.error(function(response) { .error(function(response) {
console.error("LOGIN ERROR", response); console.error("LOGIN ERROR", response);
......
angular.module('blazer.landingcontrollers', [])
.controller('LandingCtrl', function($scope, $state, $ionicLoading, $ionicHistory) {
/* CHECK IF USER ID EXIST */
$scope.checkAppStats = function(){
$ionicLoading.show();
if(localStorage.getItem("userID") != null){
$state.go('app.map');
$ionicLoading.hide();
$ionicHistory.clearHistory();
}
else {
$state.go('login');
$ionicLoading.hide();
$ionicHistory.clearHistory();
}
}
});
<ion-view hide-header ng-init="checkAppStats();">
<div class="over-lay darkbackground"></div>
<ion-content padding="true">
</ion-content>
</ion-view>
angular.module('blazer.mapcontrollers', []) angular.module('blazer.mapcontrollers', [])
.controller('MapCtrl', function($scope, $cordovaGeolocation, $cordovaDialogs, $stateParams, $ionicModal, $ionicPopup, $ionicLoading, $interval, $filter, $ionicPopover, getBlazer, postBlazer, $ionicSideMenuDelegate, $ionicHistory) { .controller('MapCtrl', function($scope, $cordovaGeolocation, $cordovaDialogs, $stateParams, $ionicModal, $ionicPopup, $ionicLoading, $interval, $filter, $ionicPopover, getBlazer, postBlazer, $ionicSideMenuDelegate, $ionicHistory, $cordovaNetwork) {
// CLEAR HISTORY // CLEAR HISTORY
$ionicHistory.clearHistory(); $ionicHistory.clearHistory();
...@@ -348,6 +348,9 @@ angular.module('blazer.mapcontrollers', []) ...@@ -348,6 +348,9 @@ angular.module('blazer.mapcontrollers', [])
/* END TRIP */ /* END TRIP */
$scope.tripEnd = function(){ $scope.tripEnd = function(){
/* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
$scope.tripStatus = false; $scope.tripStatus = false;
tripStatusRef = false; tripStatusRef = false;
...@@ -367,6 +370,10 @@ angular.module('blazer.mapcontrollers', []) ...@@ -367,6 +370,10 @@ angular.module('blazer.mapcontrollers', [])
$scope.openEndTripSurvey(); // OPEN END TRIP SURVEY $scope.openEndTripSurvey(); // OPEN END TRIP SURVEY
} }
else {
$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(){
......
...@@ -14,15 +14,20 @@ angular.module('blazer.misccontrollers', []) ...@@ -14,15 +14,20 @@ angular.module('blazer.misccontrollers', [])
buttons: [ buttons: [
{ text: '<i class="icon ion-power"></i> Log Out' }, { text: '<i class="icon ion-power"></i> Log Out' },
], ],
titleText: '', titleText: 'Select an option.',
cancelText: 'Cancel', cancelText: 'Cancel',
cancel: function() { cancel: function() {
// add cancel code.. // add cancel code..
}, },
buttonClicked: function(index) { buttonClicked: function(index) {
if(index === 0){ if(index === 0){
$scope.class = "ion-power";
$state.go('login'); $state.go('login');
$scope.class = "ion-power";
localStorage.removeItem("username");
localStorage.removeItem("password");
localStorage.removeItem("userID");
$ionicHistory.clearHistory();
$ionicHistory.clearCache();
} }
return true; return true;
} }
......
angular.module('blazer.offerridecontrollers', []) angular.module('blazer.offerridecontrollers', [])
.controller('OfferRideCtrl', function($scope, $ionicHistory, getBlazer, postBlazer, LocationService, $cordovaGeolocation) { .controller('OfferRideCtrl', function($scope, $ionicHistory, $filter, getBlazer, postBlazer, LocationService, $cordovaGeolocation) {
/* MAP DEFAULTS */ /* MAP DEFAULTS */
var destinationMap = L.map('mapdestination'); var destinationMap = L.map('mapdestination');
...@@ -86,7 +86,7 @@ angular.module('blazer.offerridecontrollers', []) ...@@ -86,7 +86,7 @@ angular.module('blazer.offerridecontrollers', [])
"pickup_lng": pickup_lng, "pickup_lng": pickup_lng,
"dest_lat": dest_lat, "dest_lat": dest_lat,
"dest_lng": dest_lng, "dest_lng": dest_lng,
"assembly_time": $scope.offer.assembly, "assembly_time": $filter('date')($scope.offer.assembly, "MM-dd-yyyy H:mm a"),
"car_model": $scope.offer.carbrand +" "+ $scope.offer.platenumber, "car_model": $scope.offer.carbrand +" "+ $scope.offer.platenumber,
"capacity": $scope.offer.capacity, "capacity": $scope.offer.capacity,
"mobile": $scope.offer.mobile, "mobile": $scope.offer.mobile,
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
<p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific Pick-up Location.</p> <p class="text-dark note-style"><b>Note: </b> Drag the marker to a specific Pick-up Location.</p>
<div class="item item-divider item-light"> Pick-up Location (specify) </div> <div class="item item-divider item-light"> Pick-up Location (specify) </div>
<div id="mappickup"></div> <div id="mappickup"></div>
<div class="item item-stacked-label" ion-datetime-picker am-pm ng-model="datetimeValue" required> <div class="item item-stacked-label" ion-datetime-picker am-pm ng-model="offer.assembly" required>
<span class="input-label">Date and Time</span> <span class="input-label">Date and Time</span>
<p>{{datetimeValue| date: "MMMM dd, yyyy 'at' H:mm:ss a"}}</p> <p>{{offer.assembly| date: "MMMM dd, yyyy 'at' H:mm:ss a"}}</p>
</div> </div>
<label class="item item-input item-stacked-label border-bottom-select"> <label class="item item-input item-stacked-label border-bottom-select">
<span class="input-label"> Car Brand</span> <span class="input-label"> Car Brand</span>
......
...@@ -17,12 +17,15 @@ angular.module('blazer.sharedridecontrollers', []) ...@@ -17,12 +17,15 @@ angular.module('blazer.sharedridecontrollers', [])
/* FILTER RIDES */ /* FILTER RIDES */
for(var i = 0; i < data.length; i ++){ for(var i = 0; i < data.length; i ++){
if(data[i].ride_status == true){ if(data[i].ride_status == true){
$scope.$broadcast('scroll.refreshComplete');
$scope.ridingRide.push(data[i]); $scope.ridingRide.push(data[i]);
} }
else if(data[i].interested_status == true){ else if(data[i].interested_status == true){
$scope.$broadcast('scroll.refreshComplete');
$scope.interestedRides.push(data[i]); $scope.interestedRides.push(data[i]);
} }
else { else {
$scope.$broadcast('scroll.refreshComplete');
$scope.availableRide.push(data[i]); $scope.availableRide.push(data[i]);
} }
} }
......
angular.module('blazer.surveycontrollers', []) angular.module('blazer.surveycontrollers', [])
.controller('SurveyCtrl', function($scope, $ionicModal, $filter, $ionicSlideBoxDelegate, $ionicScrollDelegate, postBlazer) { .controller('SurveyCtrl', function($scope, $ionicModal, $filter, $ionicSlideBoxDelegate, $ionicScrollDelegate, postBlazer, $cordovaNetwork, $cordovaDialogs) {
$scope.closeEndTripModal = function() { $scope.closeEndTripModal = function() {
$scope.modalEndTrip.hide(); $scope.modalEndTrip.hide();
...@@ -12,6 +12,9 @@ angular.module('blazer.surveycontrollers', []) ...@@ -12,6 +12,9 @@ angular.module('blazer.surveycontrollers', [])
$scope.endtrip = {}; $scope.endtrip = {};
$scope.postEndTripSurvey = function(){ $scope.postEndTripSurvey = function(){
/* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var tripID = localStorage.getItem("tripid"); var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime"); var startTime = localStorage.getItem("starttime");
...@@ -43,6 +46,10 @@ angular.module('blazer.surveycontrollers', []) ...@@ -43,6 +46,10 @@ angular.module('blazer.surveycontrollers', [])
console.error("SEND ENDTRIP SURVEY ERROR", response); console.error("SEND ENDTRIP SURVEY ERROR", response);
}); });
} }
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.disableSwipe = function() { $scope.disableSwipe = function() {
$ionicSlideBoxDelegate.enableSlide(false); $ionicSlideBoxDelegate.enableSlide(false);
...@@ -62,6 +69,8 @@ angular.module('blazer.surveycontrollers', []) ...@@ -62,6 +69,8 @@ angular.module('blazer.surveycontrollers', [])
$scope.weekly = {}; $scope.weekly = {};
$scope.postWeeklySurvey = function(){ $scope.postWeeklySurvey = function(){
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var userID = localStorage.getItem("userID"); var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
var newDate = new Date(); var newDate = new Date();
...@@ -73,28 +82,29 @@ angular.module('blazer.surveycontrollers', []) ...@@ -73,28 +82,29 @@ angular.module('blazer.surveycontrollers', [])
/* 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){
angular.forEach($scope.choice1, function(value, key){ angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 3){ else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){ angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 4){ else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){ angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 5){ else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){ angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 'C'){ else if($scope.weekly.main == 'C'){
surveyAnswer = null; surveyAnswer = null;
} }
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyAnswer));
var postdata = { var postdata = {
"user_id": userID, "user_id": userID,
"username": username, "username": username,
...@@ -115,6 +125,10 @@ angular.module('blazer.surveycontrollers', []) ...@@ -115,6 +125,10 @@ angular.module('blazer.surveycontrollers', [])
$scope.closeWeeklyModal(); $scope.closeWeeklyModal();
}); });
} }
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.resetValues = function(){ $scope.resetValues = function(){
$scope.weekly = {}; $scope.weekly = {};
......
...@@ -62,6 +62,21 @@ module.exports = [ ...@@ -62,6 +62,21 @@ module.exports = [
"cordova.InAppBrowser.open", "cordova.InAppBrowser.open",
"window.open" "window.open"
] ]
},
{
"file": "plugins/cordova-plugin-network-information/www/network.js",
"id": "cordova-plugin-network-information.network",
"clobbers": [
"navigator.connection",
"navigator.network.connection"
]
},
{
"file": "plugins/cordova-plugin-network-information/www/Connection.js",
"id": "cordova-plugin-network-information.Connection",
"clobbers": [
"Connection"
]
} }
]; ];
module.exports.metadata = module.exports.metadata =
...@@ -77,7 +92,8 @@ module.exports.metadata = ...@@ -77,7 +92,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0", "ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1", "cordova-plugin-dialogs": "1.2.1",
"cordova-plugin-crosswalk-webview": "2.1.0", "cordova-plugin-crosswalk-webview": "2.1.0",
"cordova-plugin-inappbrowser": "1.5.0" "cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-network-information": "1.3.0"
}; };
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });
\ No newline at end of file
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<!-- your app's js --> <!-- your app's js -->
<script src="js/app.js"></script> <script src="js/app.js"></script>
<script src="app/landing/js/landing.js"></script>
<script src="app/menu/js/menu.js"></script> <script src="app/menu/js/menu.js"></script>
<script src="app/auth/js/auth.js"></script> <script src="app/auth/js/auth.js"></script>
<script src="app/map/js/map.js"></script> <script src="app/map/js/map.js"></script>
......
angular.module('blazer', [ angular.module('blazer', [
'ionic', 'ionic',
'blazer.landingcontrollers',
'blazer.menucontrollers', 'blazer.menucontrollers',
'blazer.authenticationcontrollers', 'blazer.authenticationcontrollers',
'blazer.mapcontrollers', 'blazer.mapcontrollers',
...@@ -34,6 +35,10 @@ angular.module('blazer', [ ...@@ -34,6 +35,10 @@ angular.module('blazer', [
$ionicPickerI18n.okClass = "button-dark button-outline"; $ionicPickerI18n.okClass = "button-dark button-outline";
$ionicPickerI18n.cancelClass = "button-dark button-outline"; $ionicPickerI18n.cancelClass = "button-dark button-outline";
}); });
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
}, 100);
}) })
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) { .config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
...@@ -42,6 +47,13 @@ angular.module('blazer', [ ...@@ -42,6 +47,13 @@ angular.module('blazer', [
$ionicConfigProvider.spinner.icon('lines'); $ionicConfigProvider.spinner.icon('lines');
$stateProvider $stateProvider
/* LANDING */
.state('landing', {
url: '/landing',
templateUrl: 'app/landing/landing.html',
controller: 'LandingCtrl'
})
/* MENU */ /* MENU */
.state('app', { .state('app', {
url: '/app', url: '/app',
...@@ -166,5 +178,5 @@ angular.module('blazer', [ ...@@ -166,5 +178,5 @@ angular.module('blazer', [
} }
} }
}) })
$urlRouterProvider.otherwise('/login'); $urlRouterProvider.otherwise('/landing');
}) })
\ No newline at end of file
...@@ -186,7 +186,7 @@ angular.module('blazer.apiservices', []) ...@@ -186,7 +186,7 @@ angular.module('blazer.apiservices', [])
}).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: responseData.message, duration: 500}); $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){
...@@ -366,7 +366,7 @@ angular.module('blazer.apiservices', []) ...@@ -366,7 +366,7 @@ angular.module('blazer.apiservices', [])
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) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
...@@ -404,7 +404,7 @@ angular.module('blazer.apiservices', []) ...@@ -404,7 +404,7 @@ angular.module('blazer.apiservices', [])
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) { }).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData)); console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error'); deferred.reject('Error');
...@@ -433,13 +433,12 @@ angular.module('blazer.apiservices', []) ...@@ -433,13 +433,12 @@ angular.module('blazer.apiservices', [])
$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,
"dest": data.dest, "pickup_lat": data.pickup_lat,
"rname": data.rname, "pickup_lng": data.pickup_lng,
"loc": data.loc, "dest_lat": data.dest_lat,
"lat": data.lat, "dest_lng": data.dest_lng,
"long": data.long, "assembly_time": data.assembly_time,
"assembly": data.assembly, "car_model": data.car_model,
"model": data.model,
"capacity": data.capacity, "capacity": data.capacity,
"mobile": data.mobile, "mobile": data.mobile,
"other": data.other "other": data.other
...@@ -450,7 +449,7 @@ angular.module('blazer.apiservices', []) ...@@ -450,7 +449,7 @@ angular.module('blazer.apiservices', [])
}).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: "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');
......
...@@ -2,4 +2,5 @@ var blazerAPI = 'http://blaze.eacomm.com/api'; ...@@ -2,4 +2,5 @@ var blazerAPI = 'http://blaze.eacomm.com/api';
var appVersion = '1.0.0'; var appVersion = '1.0.0';
var buildNumber = '1.0.0'; var buildNumber = '1.0.0';
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
cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Network status
*/
module.exports = {
UNKNOWN: "unknown",
ETHERNET: "ethernet",
WIFI: "wifi",
CELL_2G: "2g",
CELL_3G: "3g",
CELL_4G: "4g",
CELL:"cellular",
NONE: "none"
};
});
cordova.define("cordova-plugin-network-information.network", function(require, exports, module) {
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec'),
cordova = require('cordova'),
channel = require('cordova/channel'),
utils = require('cordova/utils');
// Link the onLine property with the Cordova-supplied network info.
// This works because we clobber the navigator object with our own
// object in bootstrap.js.
// Browser platform do not need to define this property, because
// it is already supported by modern browsers
if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') {
utils.defineGetter(navigator, 'onLine', function() {
return this.connection.type != 'none';
});
}
function NetworkConnection() {
this.type = 'unknown';
}
/**
* Get connection info
*
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
*/
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
};
var me = new NetworkConnection();
var timerId = null;
var timeout = 500;
channel.createSticky('onCordovaConnectionReady');
channel.waitForInitialization('onCordovaConnectionReady');
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.type = info;
if (info === "none") {
// set a timer if still offline at the end of timer send the offline event
timerId = setTimeout(function(){
cordova.fireDocumentEvent("offline");
timerId = null;
}, timeout);
} else {
// If there is a current offline event pending clear it
if (timerId !== null) {
clearTimeout(timerId);
timerId = null;
}
cordova.fireDocumentEvent("online");
}
// should only fire this once
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
},
function (e) {
// If we can't get the network info we should still tell Cordova
// to fire the deviceready event.
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
console.log("Error initializing Network Connection: " + e);
});
});
module.exports = me;
});
...@@ -62,6 +62,21 @@ module.exports = [ ...@@ -62,6 +62,21 @@ module.exports = [
"cordova.InAppBrowser.open", "cordova.InAppBrowser.open",
"window.open" "window.open"
] ]
},
{
"file": "plugins/cordova-plugin-network-information/www/network.js",
"id": "cordova-plugin-network-information.network",
"clobbers": [
"navigator.connection",
"navigator.network.connection"
]
},
{
"file": "plugins/cordova-plugin-network-information/www/Connection.js",
"id": "cordova-plugin-network-information.Connection",
"clobbers": [
"Connection"
]
} }
]; ];
module.exports.metadata = module.exports.metadata =
...@@ -77,7 +92,8 @@ module.exports.metadata = ...@@ -77,7 +92,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0", "ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1", "cordova-plugin-dialogs": "1.2.1",
"cordova-plugin-crosswalk-webview": "2.1.0", "cordova-plugin-crosswalk-webview": "2.1.0",
"cordova-plugin-inappbrowser": "1.5.0" "cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-network-information": "1.3.0"
}; };
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });
\ No newline at end of file
cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Network status
*/
module.exports = {
UNKNOWN: "unknown",
ETHERNET: "ethernet",
WIFI: "wifi",
CELL_2G: "2g",
CELL_3G: "3g",
CELL_4G: "4g",
CELL:"cellular",
NONE: "none"
};
});
cordova.define("cordova-plugin-network-information.network", function(require, exports, module) {
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec'),
cordova = require('cordova'),
channel = require('cordova/channel'),
utils = require('cordova/utils');
// Link the onLine property with the Cordova-supplied network info.
// This works because we clobber the navigator object with our own
// object in bootstrap.js.
// Browser platform do not need to define this property, because
// it is already supported by modern browsers
if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') {
utils.defineGetter(navigator, 'onLine', function() {
return this.connection.type != 'none';
});
}
function NetworkConnection() {
this.type = 'unknown';
}
/**
* Get connection info
*
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
*/
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
};
var me = new NetworkConnection();
var timerId = null;
var timeout = 500;
channel.createSticky('onCordovaConnectionReady');
channel.waitForInitialization('onCordovaConnectionReady');
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.type = info;
if (info === "none") {
// set a timer if still offline at the end of timer send the offline event
timerId = setTimeout(function(){
cordova.fireDocumentEvent("offline");
timerId = null;
}, timeout);
} else {
// If there is a current offline event pending clear it
if (timerId !== null) {
clearTimeout(timerId);
timerId = null;
}
cordova.fireDocumentEvent("online");
}
// should only fire this once
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
},
function (e) {
// If we can't get the network info we should still tell Cordova
// to fire the deviceready event.
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
console.log("Error initializing Network Connection: " + e);
});
});
module.exports = me;
});
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
<feature name="InAppBrowser"> <feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" /> <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</feature> </feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" /> <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" /> <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" /> <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
CEE78DECA0244D908F3DD71A /* CDVNotification.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 4F1CDFC6027F4C9296BBBA34 /* CDVNotification.bundle */; }; CEE78DECA0244D908F3DD71A /* CDVNotification.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 4F1CDFC6027F4C9296BBBA34 /* CDVNotification.bundle */; };
A4FD78990AD44E95B64F4A16 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; A4FD78990AD44E95B64F4A16 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
8B4D6C644F1444D885AB9E94 /* CDVInAppBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */; }; 8B4D6C644F1444D885AB9E94 /* CDVInAppBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */; };
F1C4BBEC5D7C4731A27F5532 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = E4EE3C5DF43E488D9AE296C0 /* CDVConnection.m */; };
7434D91954CC4CEAA4065558 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DAE42B485294A8D96EF9C71 /* CDVReachability.m */; };
77A933A39CB4466C806F43C2 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 668CFD6E00B44D52A7D135F0 /* SystemConfiguration.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
58935A934A8E47BD8B980467 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFE41DB246E843FF81A6A110 /* CoreTelephony.framework */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
...@@ -87,6 +91,12 @@ ...@@ -87,6 +91,12 @@
6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */ = {isa = PBXFileReference; name = "AudioToolbox.framework"; path = "System/Library/Frameworks/AudioToolbox.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; }; 6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */ = {isa = PBXFileReference; name = "AudioToolbox.framework"; path = "System/Library/Frameworks/AudioToolbox.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */ = {isa = PBXFileReference; name = "CDVInAppBrowser.m"; path = "cordova-plugin-inappbrowser/CDVInAppBrowser.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; }; 58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */ = {isa = PBXFileReference; name = "CDVInAppBrowser.m"; path = "cordova-plugin-inappbrowser/CDVInAppBrowser.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
CA4EA3DE2EF14385AB38677A /* CDVInAppBrowser.h */ = {isa = PBXFileReference; name = "CDVInAppBrowser.h"; path = "cordova-plugin-inappbrowser/CDVInAppBrowser.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; }; CA4EA3DE2EF14385AB38677A /* CDVInAppBrowser.h */ = {isa = PBXFileReference; name = "CDVInAppBrowser.h"; path = "cordova-plugin-inappbrowser/CDVInAppBrowser.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
E4EE3C5DF43E488D9AE296C0 /* CDVConnection.m */ = {isa = PBXFileReference; name = "CDVConnection.m"; path = "cordova-plugin-network-information/CDVConnection.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
1DAE42B485294A8D96EF9C71 /* CDVReachability.m */ = {isa = PBXFileReference; name = "CDVReachability.m"; path = "cordova-plugin-network-information/CDVReachability.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
492E3584A2214E308AB52472 /* CDVConnection.h */ = {isa = PBXFileReference; name = "CDVConnection.h"; path = "cordova-plugin-network-information/CDVConnection.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
7790BE8BFA234D4D9E2774EB /* CDVReachability.h */ = {isa = PBXFileReference; name = "CDVReachability.h"; path = "cordova-plugin-network-information/CDVReachability.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
668CFD6E00B44D52A7D135F0 /* SystemConfiguration.framework */ = {isa = PBXFileReference; name = "SystemConfiguration.framework"; path = "System/Library/Frameworks/SystemConfiguration.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
DFE41DB246E843FF81A6A110 /* CoreTelephony.framework */ = {isa = PBXFileReference; name = "CoreTelephony.framework"; path = "System/Library/Frameworks/CoreTelephony.framework"; sourceTree = SDKROOT; fileEncoding = undefined; lastKnownFileType = wrapper.framework; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -97,6 +107,8 @@ ...@@ -97,6 +107,8 @@
301BF552109A68D80062928A /* libCordova.a in Frameworks */, 301BF552109A68D80062928A /* libCordova.a in Frameworks */,
3CE3887C122740C68FA53F37 /* CoreLocation.framework in Frameworks */, 3CE3887C122740C68FA53F37 /* CoreLocation.framework in Frameworks */,
A4FD78990AD44E95B64F4A16 /* AudioToolbox.framework in Frameworks */, A4FD78990AD44E95B64F4A16 /* AudioToolbox.framework in Frameworks */,
77A933A39CB4466C806F43C2 /* SystemConfiguration.framework in Frameworks */,
58935A934A8E47BD8B980467 /* CoreTelephony.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -169,6 +181,8 @@ ...@@ -169,6 +181,8 @@
children = ( children = (
EA414E5BD06B48DD87D09393 /* CoreLocation.framework */, EA414E5BD06B48DD87D09393 /* CoreLocation.framework */,
6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */, 6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */,
668CFD6E00B44D52A7D135F0 /* SystemConfiguration.framework */,
DFE41DB246E843FF81A6A110 /* CoreTelephony.framework */,
); );
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -212,6 +226,10 @@ ...@@ -212,6 +226,10 @@
AF69C3230FE247BDB620C8F7 /* CDVNotification.h */, AF69C3230FE247BDB620C8F7 /* CDVNotification.h */,
58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */, 58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */,
CA4EA3DE2EF14385AB38677A /* CDVInAppBrowser.h */, CA4EA3DE2EF14385AB38677A /* CDVInAppBrowser.h */,
E4EE3C5DF43E488D9AE296C0 /* CDVConnection.m */,
1DAE42B485294A8D96EF9C71 /* CDVReachability.m */,
492E3584A2214E308AB52472 /* CDVConnection.h */,
7790BE8BFA234D4D9E2774EB /* CDVReachability.h */,
); );
name = Plugins; name = Plugins;
path = Blaze/Plugins; path = Blaze/Plugins;
...@@ -339,6 +357,8 @@ ...@@ -339,6 +357,8 @@
068A80E3895D40F9B47D4699 /* IonicKeyboard.m in Sources */, 068A80E3895D40F9B47D4699 /* IonicKeyboard.m in Sources */,
BFE42A8C9D57424AA63E0A50 /* CDVNotification.m in Sources */, BFE42A8C9D57424AA63E0A50 /* CDVNotification.m in Sources */,
8B4D6C644F1444D885AB9E94 /* CDVInAppBrowser.m in Sources */, 8B4D6C644F1444D885AB9E94 /* CDVInAppBrowser.m in Sources */,
F1C4BBEC5D7C4731A27F5532 /* CDVConnection.m in Sources */,
7434D91954CC4CEAA4065558 /* CDVReachability.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
#import "CDVReachability.h"
@interface CDVConnection : CDVPlugin {
NSString* type;
NSString* _callbackId;
CDVReachability* internetReach;
}
@property (copy) NSString* connectionType;
@property (strong) CDVReachability* internetReach;
@end
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import "CDVConnection.h"
#import "CDVReachability.h"
@interface CDVConnection (PrivateMethods)
- (void)updateOnlineStatus;
- (void)sendPluginResult;
@end
@implementation CDVConnection
@synthesize connectionType, internetReach;
- (void)getConnectionInfo:(CDVInvokedUrlCommand*)command
{
_callbackId = command.callbackId;
[self sendPluginResult];
}
- (void)sendPluginResult
{
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.connectionType];
[result setKeepCallbackAsBool:YES];
[self.commandDelegate sendPluginResult:result callbackId:_callbackId];
}
- (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
{
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
switch (networkStatus) {
case NotReachable:
return @"none";
case ReachableViaWWAN:
{
BOOL isConnectionRequired = [reachability connectionRequired];
if (isConnectionRequired) {
return @"none";
} else {
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
return @"2g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
return @"2g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
return @"3g";
} else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
return @"4g";
}
}
return @"cellular";
}
}
case ReachableViaWiFi:
return @"wifi";
default:
return @"unknown";
}
}
- (BOOL)isCellularConnection:(NSString*)theConnectionType
{
return [theConnectionType isEqualToString:@"2g"] ||
[theConnectionType isEqualToString:@"3g"] ||
[theConnectionType isEqualToString:@"4g"] ||
[theConnectionType isEqualToString:@"cellular"];
}
- (void)updateReachability:(CDVReachability*)reachability
{
if (reachability) {
// check whether the connection type has changed
NSString* newConnectionType = [self w3cConnectionTypeFor:reachability];
if ([newConnectionType isEqualToString:self.connectionType]) { // the same as before, remove dupes
return;
} else {
self.connectionType = [self w3cConnectionTypeFor:reachability];
}
}
[self sendPluginResult];
}
- (void)updateConnectionType:(NSNotification*)note
{
CDVReachability* curReach = [note object];
if ((curReach != nil) && [curReach isKindOfClass:[CDVReachability class]]) {
[self updateReachability:curReach];
}
}
- (void)onPause
{
[self.internetReach stopNotifier];
}
- (void)onResume
{
[self.internetReach startNotifier];
[self updateReachability:self.internetReach];
}
- (void)pluginInitialize
{
self.connectionType = @"none";
self.internetReach = [CDVReachability reachabilityForInternetConnection];
self.connectionType = [self w3cConnectionTypeFor:self.internetReach];
[self.internetReach startNotifier];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
name:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
name:CTRadioAccessTechnologyDidChangeNotification object:nil];
if (UIApplicationDidEnterBackgroundNotification && UIApplicationWillEnterForegroundNotification) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
}
}
@end
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
Version: 2.2
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software
constitutes acceptance of these terms. If you do not agree with these terms,
please do not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and subject
to these terms, Apple grants you a personal, non-exclusive license, under
Apple's copyrights in this original Apple software (the "Apple Software"), to
use, reproduce, modify and redistribute the Apple Software, with or without
modifications, in source and/or binary forms; provided that if you redistribute
the Apple Software in its entirety and without modifications, you must retain
this notice and the following text and disclaimers in all such redistributions
of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may be used
to endorse or promote products derived from the Apple Software without specific
prior written permission from Apple. Except as expressly stated in this notice,
no other rights or licenses, express or implied, are granted by Apple herein,
including but not limited to any patent rights that may be infringed by your
derivative works or by other works in which the Apple Software may be
incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2010 Apple Inc. All Rights Reserved.
*/
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>
typedef enum {
NotReachable = 0,
ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons
ReachableViaWiFi // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons
} NetworkStatus;
#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
@interface CDVReachability : NSObject
{
BOOL localWiFiRef;
SCNetworkReachabilityRef reachabilityRef;
}
// reachabilityWithHostName- Use to check the reachability of a particular host name.
+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
// reachabilityWithAddress- Use to check the reachability of a particular IP address.
+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
// reachabilityForInternetConnection- checks whether the default route is available.
// Should be used by applications that do not connect to a particular host
+ (CDVReachability*)reachabilityForInternetConnection;
// reachabilityForLocalWiFi- checks whether a local wifi connection is available.
+ (CDVReachability*)reachabilityForLocalWiFi;
// Start listening for reachability notifications on the current run loop
- (BOOL)startNotifier;
- (void)stopNotifier;
- (NetworkStatus)currentReachabilityStatus;
// WWAN may be available, but not active until a connection has been established.
// WiFi may require a connection for VPN on Demand.
- (BOOL)connectionRequired;
@end
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
<feature name="InAppBrowser"> <feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" /> <param name="ios-package" value="CDVInAppBrowser" />
</feature> </feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
<name>Blaze</name> <name>Blaze</name>
<description> <description>
An Ionic Framework and Cordova project. An Ionic Framework and Cordova project.
......
{ {
"CoreLocation.framework": 1, "CoreLocation.framework": 1,
"AudioToolbox.framework": 1 "AudioToolbox.framework": 1,
"SystemConfiguration.framework": 1,
"CoreTelephony.framework": 1
} }
\ No newline at end of file
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
{ {
"xml": "<feature name=\"InAppBrowser\"><param name=\"ios-package\" value=\"CDVInAppBrowser\" /></feature>", "xml": "<feature name=\"InAppBrowser\"><param name=\"ios-package\" value=\"CDVInAppBrowser\" /></feature>",
"count": 1 "count": 1
},
{
"xml": "<feature name=\"NetworkStatus\"><param name=\"ios-package\" value=\"CDVConnection\" /></feature>",
"count": 1
} }
] ]
} }
...@@ -96,6 +100,9 @@ ...@@ -96,6 +100,9 @@
}, },
"cordova-plugin-inappbrowser": { "cordova-plugin-inappbrowser": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192" "PACKAGE_NAME": "com.ionicframework.blazerapp561192"
},
"cordova-plugin-network-information": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
} }
}, },
"dependent_plugins": {}, "dependent_plugins": {},
...@@ -197,6 +204,23 @@ ...@@ -197,6 +204,23 @@
"cordova.InAppBrowser.open", "cordova.InAppBrowser.open",
"window.open" "window.open"
] ]
},
{
"file": "plugins/cordova-plugin-network-information/www/network.js",
"id": "cordova-plugin-network-information.network",
"pluginId": "cordova-plugin-network-information",
"clobbers": [
"navigator.connection",
"navigator.network.connection"
]
},
{
"file": "plugins/cordova-plugin-network-information/www/Connection.js",
"id": "cordova-plugin-network-information.Connection",
"pluginId": "cordova-plugin-network-information",
"clobbers": [
"Connection"
]
} }
], ],
"plugin_metadata": { "plugin_metadata": {
...@@ -210,6 +234,7 @@ ...@@ -210,6 +234,7 @@
"ionic-plugin-keyboard": "2.2.0", "ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1", "cordova-plugin-dialogs": "1.2.1",
"cordova-plugin-crosswalk-webview": "2.1.0", "cordova-plugin-crosswalk-webview": "2.1.0",
"cordova-plugin-inappbrowser": "1.5.0" "cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-network-information": "1.3.0"
} }
} }
\ No newline at end of file
...@@ -97,6 +97,23 @@ module.exports = [ ...@@ -97,6 +97,23 @@ module.exports = [
"cordova.InAppBrowser.open", "cordova.InAppBrowser.open",
"window.open" "window.open"
] ]
},
{
"file": "plugins/cordova-plugin-network-information/www/network.js",
"id": "cordova-plugin-network-information.network",
"pluginId": "cordova-plugin-network-information",
"clobbers": [
"navigator.connection",
"navigator.network.connection"
]
},
{
"file": "plugins/cordova-plugin-network-information/www/Connection.js",
"id": "cordova-plugin-network-information.Connection",
"pluginId": "cordova-plugin-network-information",
"clobbers": [
"Connection"
]
} }
]; ];
module.exports.metadata = module.exports.metadata =
...@@ -112,7 +129,8 @@ module.exports.metadata = ...@@ -112,7 +129,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0", "ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1", "cordova-plugin-dialogs": "1.2.1",
"cordova-plugin-crosswalk-webview": "2.1.0", "cordova-plugin-crosswalk-webview": "2.1.0",
"cordova-plugin-inappbrowser": "1.5.0" "cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-network-information": "1.3.0"
} }
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });
\ No newline at end of file
cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Network status
*/
module.exports = {
UNKNOWN: "unknown",
ETHERNET: "ethernet",
WIFI: "wifi",
CELL_2G: "2g",
CELL_3G: "3g",
CELL_4G: "4g",
CELL:"cellular",
NONE: "none"
};
});
cordova.define("cordova-plugin-network-information.network", function(require, exports, module) {
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec'),
cordova = require('cordova'),
channel = require('cordova/channel'),
utils = require('cordova/utils');
// Link the onLine property with the Cordova-supplied network info.
// This works because we clobber the navigator object with our own
// object in bootstrap.js.
// Browser platform do not need to define this property, because
// it is already supported by modern browsers
if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') {
utils.defineGetter(navigator, 'onLine', function() {
return this.connection.type != 'none';
});
}
function NetworkConnection() {
this.type = 'unknown';
}
/**
* Get connection info
*
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
*/
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
};
var me = new NetworkConnection();
var timerId = null;
var timeout = 500;
channel.createSticky('onCordovaConnectionReady');
channel.waitForInitialization('onCordovaConnectionReady');
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.type = info;
if (info === "none") {
// set a timer if still offline at the end of timer send the offline event
timerId = setTimeout(function(){
cordova.fireDocumentEvent("offline");
timerId = null;
}, timeout);
} else {
// If there is a current offline event pending clear it
if (timerId !== null) {
clearTimeout(timerId);
timerId = null;
}
cordova.fireDocumentEvent("online");
}
// should only fire this once
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
},
function (e) {
// If we can't get the network info we should still tell Cordova
// to fire the deviceready event.
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
console.log("Error initializing Network Connection: " + e);
});
});
module.exports = me;
});
angular.module('blazer.authenticationcontrollers', []) angular.module('blazer.authenticationcontrollers', [])
.controller('AuthCtrl', function($scope, $state, postBlazer, $cordovaDialogs) { .controller('AuthCtrl', function($scope, $state, postBlazer, $timeout, $ionicPopup, $cordovaDialogs, $cordovaInAppBrowser) {
$scope.user = { // $scope.user = {
username: "blazetestaccount", // username: "blazetestaccount",
password: "blazetestaccount" // password: "blazetestaccount"
}; // };
// $scope.user = {}; // $scope.user = {};
$scope.loginUser = function(){ $scope.loginUser = function(){
...@@ -20,8 +20,48 @@ angular.module('blazer.authenticationcontrollers', []) ...@@ -20,8 +20,48 @@ angular.module('blazer.authenticationcontrollers', [])
}); });
} }
$scope.showForgotpassword = function(){ /* FORGOT PASSWORD POPUP */
$scope.showForgotPassword = function(){
$scope.data = {};
// An elaborate, custom popup
var myPopup = $ionicPopup.show({
template: '<input type="email" ng-model="data.email">',
title: 'Reset Password',
subTitle: 'Please enter your email address',
scope: $scope,
buttons: [
{
text: 'Reset',
type: 'button-dark button-outline',
onTap: function() {
console.log('Destination to School');
$scope.postforgotpassword($scope.data.email);
}
},
{
text: 'Cancel',
type: 'button-dark button-outline',
onTap: function() {
console.log('Cancel Reset');
}
}
]
});
}
/* FORGOT PASSWORD */
$scope.postforgotpassword = function(email){
console.debug("[ RESET EMAIL ]", email);
var emailaddress = email;
postBlazer.ForgotPassword(emailaddress)
.success(function(response) {
console.log("FORGOT PASSWORD SUCCESS", response);
})
.error(function(response) {
console.error("FORGOT PASSWORD ERROR", response);
});
} }
$scope.showAbout = function(){ $scope.showAbout = function(){
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<input type="password" ng-model="user.password" placeholder="Password" required> <input type="password" ng-model="user.password" placeholder="Password" required>
</label> </label>
</div> </div>
<a class="form-login-link">Forgot Password?</a> <a class="form-login-link" ng-click="showForgotPassword();">Forgot Password?</a>
<button class="button button-block button-outline button-light login-button" ng-click="loginUser()" ng-disabled="loginForm.$invalid">LOGIN</button> <button class="button button-block button-outline button-light login-button" ng-click="loginUser()" ng-disabled="loginForm.$invalid">LOGIN</button>
<!-- <button class="button button-block button-small button-outline button-light login-button" ng-click="showDialog()">SIGN UP</button> --> <!-- <button class="button button-block button-small button-outline button-light login-button" ng-click="showDialog()">SIGN UP</button> -->
</form> </form>
......
...@@ -68,7 +68,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -68,7 +68,7 @@ angular.module('blazer.mapcontrollers', [])
// REMOVE MARKERS // REMOVE MARKERS
map.removeLayer(markers); map.removeLayer(markers);
$scope.drawTripMarkers(lat, lon); // DRAW TRIP MARKER ] $scope.drawMarkers(lat, lon, 'On Trip'); // DRAW TRIP MARKER ]
} }
/* EVENT LISTENERS */ /* EVENT LISTENERS */
...@@ -247,6 +247,7 @@ angular.module('blazer.mapcontrollers', []) ...@@ -247,6 +247,7 @@ angular.module('blazer.mapcontrollers', [])
$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 = {};
} }
}, },
{ {
...@@ -275,6 +276,10 @@ angular.module('blazer.mapcontrollers', []) ...@@ -275,6 +276,10 @@ angular.module('blazer.mapcontrollers', [])
console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData)); console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData));
$scope.openChart($scope.BarangayData); // LOAD CHART MODAL $scope.openChart($scope.BarangayData); // LOAD CHART MODAL
$scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay); $scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay);
// RESET VALUES
$scope.selectedBarangayData = '';
$scope.currentBarangay = '';
$scope.currentBarangayTime = '';
}) })
.error(function(response) { .error(function(response) {
console.error("BARANGAY ERROR", response); console.error("BARANGAY ERROR", response);
...@@ -331,9 +336,10 @@ angular.module('blazer.mapcontrollers', []) ...@@ -331,9 +336,10 @@ angular.module('blazer.mapcontrollers', [])
map.removeLayer(geojsonLayer); map.removeLayer(geojsonLayer);
$scope.tripStatus = true; $scope.tripStatus = true;
var newDate = new Date();
var newDate = new Date();
startTime = newDate.getTime(); startTime = newDate.getTime();
localStorage.setItem("starttime", startTime);
console.log("START TRIP TIME", startTime); console.log("START TRIP TIME", startTime);
$scope.getUserLocation(); $scope.getUserLocation();
...@@ -344,8 +350,10 @@ angular.module('blazer.mapcontrollers', []) ...@@ -344,8 +350,10 @@ angular.module('blazer.mapcontrollers', [])
$scope.tripEnd = function(){ $scope.tripEnd = function(){
$scope.tripStatus = false; $scope.tripStatus = false;
tripStatusRef = false; tripStatusRef = false;
var newDate = new Date(); var newDate = new Date();
endTime = newDate.getTime(); var endTime = newDate.getTime();
localStorage.setItem("endtime", endTime);
console.log("END TRIP TIME", endTime); console.log("END TRIP TIME", endTime);
// TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG // TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<h3 class="text-light"><center>BLAZE</center></h3> <h3 class="text-light"><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/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/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>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<div class="item item-text-wrap border-bottom" id="dashboards"> <div class="item item-text-wrap border-bottom" id="dashboards">
<img id="profile-photo" ng-src="img/default-user-{{user.gender}}.png" alt="Profile Picture" ng-if="user.gender"> <img id="profile-photo" ng-src="img/default-user-{{user.gender}}.png" alt="Profile Picture" ng-if="user.gender">
<img id="profile-photo" ng-src="img/default-user.png" alt="Profile Picture" ng-if="!user.gender"> <img id="profile-photo" ng-src="img/default-user.png" alt="Profile Picture" ng-if="!user.gender">
<!-- <img id="profile-photo" ng-src="{{user.avatar}}" alt="Profile Picture"> -->
<h3 id="font-head-large">{{user.name}}</h3> <h3 id="font-head-large">{{user.name}}</h3>
</div> </div>
<i class="item"> <i class="item">
......
angular.module('blazer.offerridecontrollers', []) angular.module('blazer.offerridecontrollers', [])
.controller('OfferRideCtrl', function($scope, getBlazer, postBlazer, LocationService, $cordovaGeolocation) { .controller('OfferRideCtrl', function($scope, $ionicHistory, getBlazer, postBlazer, LocationService, $cordovaGeolocation) {
/* MAP DEFAULTS */ /* MAP DEFAULTS */
var destinationMap = L.map('mapdestination'); var destinationMap = L.map('mapdestination');
...@@ -97,9 +97,11 @@ angular.module('blazer.offerridecontrollers', []) ...@@ -97,9 +97,11 @@ angular.module('blazer.offerridecontrollers', [])
console.log("OFFER RIDE SUCCESS", response); console.log("OFFER RIDE SUCCESS", response);
data = {}; data = {};
$scope.offer ={}; $scope.offer ={};
$ionicHistory.goBack(-1);
}) })
.error(function(response) { .error(function(response) {
console.error("OFFER RIDE ERROR", response); console.error("OFFER RIDE ERROR", response);
$ionicHistory.goBack(-1);
}); });
} }
......
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
<div id="mapidpanel"></div> <div id="mapidpanel"></div>
<div class="list"> <div class="list">
<div class="item item-thumbnail-left"> <div class="item item-thumbnail-left">
<img ng-src="img/default-user.png"> <!-- <img ng-src="img/default-user.png"> -->
<img ng-src="{{details.avatar}}">
<p><b> {{ details.createdby }}</b></p> <p><b> {{ details.createdby }}</b></p>
<p> {{ (details.assemblytime).split(" ")[0] | date: "MMMM dd, yyyy"}} at {{ (details.assemblytime).split(" ")[1] }}</p> <p> {{ (details.assemblytime).split(" ")[0] | date: "MMMM dd, yyyy"}} at {{ (details.assemblytime).split(" ")[1] }}</p>
<!--<p> going to {{ details.destination }} </p>--> <!--<p> going to {{ details.destination }} </p>-->
</div> </div>
<div class="button-bar"> <div class="button-bar">
<a class="button icon ion-android-call" ng-href="tel:details.mobilenum"> Call</a> <a class="button icon ion-android-call" ng-href="tel:{{details.mobilenum}}"> Call</a>
<a class="button icon ion-android-mail" ng-href="sms:details.mobilenum"> Message</a> <a class="button icon ion-android-mail" ng-href="sms:{{details.mobilenum}}"> Message</a>
</div> </div>
</div> </div>
<div class="list list-inset"> <div class="list list-inset">
......
<ion-view view-title="Take a Shared Ride" ng-init="getSharedRideData();"> <ion-view view-title="Shared Ride" ng-init="getSharedRideData();">
<ion-header-bar> <ion-nav-buttons side="right">
<h1 class="title">Take a Shared Ride</h1> <button class="button button-outline button-icon button-light" ui-sref='app.offerride'>
</ion-header-bar> Offer
</button>
</ion-nav-buttons>
<ion-content> <ion-content>
<ion-tabs class="tabs-clear tabs-icon-top"> <ion-tabs class="tabs-clear tabs-icon-top">
<ion-tab title="Available" class="text-light darkblue" badge="availableRide.length" badge-style="badge-assertive" icon-on="light ion-android-car" <ion-tab title="Available" class="text-light darkblue" badge="availableRide.length" badge-style="badge-assertive" icon-on="light ion-android-car"
icon-off="light ion-android-car"> icon-off="light ion-android-car">
<ion-content class="background-feed"> <ion-content class="background-feed">
...@@ -15,7 +18,8 @@ ...@@ -15,7 +18,8 @@
<i class="icon ion-android-more-vertical"></i> Ride Information <i class="icon ion-android-more-vertical"></i> Ride Information
</a> </a>
<div class="item item-thumbnail-left"> <div class="item item-thumbnail-left">
<img ng-src="img/default-user.png"> <!-- <img ng-src="img/default-user.png"> -->
<img ng-src="{{ride.avatar}}">
<p><b> {{ ride.createdby }}</b></p> <p><b> {{ ride.createdby }}</b></p>
<!--<p> "{{ ride.ridename }}"</p> --> <!--<p> "{{ ride.ridename }}"</p> -->
<p> {{ (ride.assemblytime).split(" ")[0] }} at {{ (ride.assemblytime).split(" ")[1] }}</p> <p> {{ (ride.assemblytime).split(" ")[0] }} at {{ (ride.assemblytime).split(" ")[1] }}</p>
...@@ -48,7 +52,8 @@ ...@@ -48,7 +52,8 @@
<i class="icon ion-android-more-vertical"></i> Ride Information <i class="icon ion-android-more-vertical"></i> Ride Information
</a> </a>
<div class="item item-thumbnail-left"> <div class="item item-thumbnail-left">
<img ng-src="img/default-user.png"> <!-- <img ng-src="img/default-user.png"> -->
<img ng-src="{{ride.avatar}}">
<p><b> {{ ride.createdby }}</b></p> <p><b> {{ ride.createdby }}</b></p>
<!--<p> "{{ ride.ridename }}"</p> --> <!--<p> "{{ ride.ridename }}"</p> -->
<p> {{ (ride.assemblytime).split(" ")[0] }} at {{ (ride.assemblytime).split(" ")[1] }}</p> <p> {{ (ride.assemblytime).split(" ")[0] }} at {{ (ride.assemblytime).split(" ")[1] }}</p>
...@@ -81,7 +86,8 @@ ...@@ -81,7 +86,8 @@
<i class="icon ion-android-more-vertical"></i> Ride Information <i class="icon ion-android-more-vertical"></i> Ride Information
</a> </a>
<div class="item item-thumbnail-left"> <div class="item item-thumbnail-left">
<img ng-src="img/default-user.png"> <!-- <img ng-src="img/default-user.png"> -->
<img ng-src="{{ride.avatar}}">
<p><b> {{ ride.createdby }}</b></p> <p><b> {{ ride.createdby }}</b></p>
<!--<p> "{{ ride.ridename }}"</p> --> <!--<p> "{{ ride.ridename }}"</p> -->
<p> {{ (ride.assemblytime).split(" ")[0] | date: "MMMM dd, yyyy" }} at {{ (ride.assemblytime).split(" ")[1] }}</p> <p> {{ (ride.assemblytime).split(" ")[0] | date: "MMMM dd, yyyy" }} at {{ (ride.assemblytime).split(" ")[1] }}</p>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<p class="text-dark">You've just finished a trip. Please take this short survey.</p> <p class="text-dark">You've just finished a trip. Please take this short survey.</p>
</div> </div>
<div class="item item-light item-text-wrap"> <!-- <div class="item item-light item-text-wrap">
<p class="text-dark">This trip is made as part of tour:</p> <p class="text-dark">This trip is made as part of tour:</p>
</div> </div>
<label class="item item-input item-select item-text-wrap item-stable"> <label class="item item-input item-select item-text-wrap item-stable">
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
<option value="trip1">Going Home</option> <option value="trip1">Going Home</option>
<option value="trip2">Going to School</option> <option value="trip2">Going to School</option>
</select> </select>
</label> </label> -->
<div class="item item-light item-text-wrap" ng-if="endtrip.destination"> <div class="item item-light item-text-wrap">
<p class="text-dark">What was the main mode of transport used?</p> <p class="text-dark">What was the main mode of transport used?</p>
</div> </div>
<label class="item item-input item-select item-text-wrap item-stable" ng-if="endtrip.destination"> <label class="item item-input item-select item-text-wrap item-stable">
&nbsp &nbsp
<div class="input-label"> <div class="input-label">
</div> </div>
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
</select> </select>
</label> </label>
<div class="item item-light item-text-wrap" ng-if="endtrip.mode && endtrip.mode"> <div class="item item-light item-text-wrap" ng-if="endtrip.mode">
<p class="text-dark">You made this trip by <p class="text-dark">You made this trip by
<u><b> {{endtrip.mode}} </b></u>. Overall, how would you evaluate this experience?</p> <u><b> {{endtrip.mode}} </b></u>. Overall, how would you evaluate this experience?</p>
</div> </div>
<label class="item item-input item-select item-text-wrap item-stable" ng-if="endtrip.mode && endtrip.mode"> <label class="item item-input item-select item-text-wrap item-stable" ng-if="endtrip.mode">
&nbsp &nbsp
<div class="input-label"> <div class="input-label">
</div> </div>
......
...@@ -10,9 +10,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -10,9 +10,7 @@ angular.module('blazer.surveycontrollers', [])
$scope.modalWeeklyTrip.hide(); $scope.modalWeeklyTrip.hide();
}; };
$scope.endtrip = { $scope.endtrip = {};
destination: localStorage.getItem("currentTrip")
};
$scope.postEndTripSurvey = function(){ $scope.postEndTripSurvey = function(){
var tripID = localStorage.getItem("tripid"); var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username"); var username = localStorage.getItem("username");
...@@ -20,6 +18,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -20,6 +18,7 @@ angular.module('blazer.surveycontrollers', [])
var endTime = localStorage.getItem("endtime"); var endTime = localStorage.getItem("endtime");
var newDate = new Date(); var newDate = new Date();
var timeStamp = newDate.getTime(); var timeStamp = newDate.getTime();
var currentTrip = localStorage.getItem("currentTrip");
var postdata = { var postdata = {
"trip_id" : tripID, "trip_id" : tripID,
...@@ -29,7 +28,7 @@ angular.module('blazer.surveycontrollers', []) ...@@ -29,7 +28,7 @@ angular.module('blazer.surveycontrollers', [])
"mode": $scope.endtrip.mode, "mode": $scope.endtrip.mode,
"exp": $scope.endtrip.overallxp, "exp": $scope.endtrip.overallxp,
"emotion": $scope.endtrip.emotion, "emotion": $scope.endtrip.emotion,
"type": $scope.endtrip.destination "type": currentTrip
} }
console.log("[ POST END TRIP SURVEY ]"); console.log("[ POST END TRIP SURVEY ]");
postBlazer.EndTripSurvey(postdata) postBlazer.EndTripSurvey(postdata)
...@@ -74,28 +73,29 @@ angular.module('blazer.surveycontrollers', []) ...@@ -74,28 +73,29 @@ angular.module('blazer.surveycontrollers', [])
/* 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){
angular.forEach($scope.choice1, function(value, key){ angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 3){ else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){ angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 4){ else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){ angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 5){ else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){ angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(value); surveyAnswer.push(parseInt(value));
}) })
} }
else if($scope.weekly.main == 'C'){ else if($scope.weekly.main == 'C'){
surveyAnswer = null; surveyAnswer = null;
} }
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyAnswer));
var postdata = { var postdata = {
"user_id": userID, "user_id": userID,
"username": username, "username": username,
......
This diff is collapsed.
...@@ -97,6 +97,23 @@ module.exports = [ ...@@ -97,6 +97,23 @@ module.exports = [
"cordova.InAppBrowser.open", "cordova.InAppBrowser.open",
"window.open" "window.open"
] ]
},
{
"file": "plugins/cordova-plugin-network-information/www/network.js",
"id": "cordova-plugin-network-information.network",
"pluginId": "cordova-plugin-network-information",
"clobbers": [
"navigator.connection",
"navigator.network.connection"
]
},
{
"file": "plugins/cordova-plugin-network-information/www/Connection.js",
"id": "cordova-plugin-network-information.Connection",
"pluginId": "cordova-plugin-network-information",
"clobbers": [
"Connection"
]
} }
]; ];
module.exports.metadata = module.exports.metadata =
...@@ -112,7 +129,8 @@ module.exports.metadata = ...@@ -112,7 +129,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0", "ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1", "cordova-plugin-dialogs": "1.2.1",
"cordova-plugin-crosswalk-webview": "2.1.0", "cordova-plugin-crosswalk-webview": "2.1.0",
"cordova-plugin-inappbrowser": "1.5.0" "cordova-plugin-inappbrowser": "1.5.0",
"cordova-plugin-network-information": "1.3.0"
} }
// BOTTOM OF METADATA // BOTTOM OF METADATA
}); });
\ No newline at end of file
...@@ -230,6 +230,7 @@ color: #fff; ...@@ -230,6 +230,7 @@ color: #fff;
margin-right: 10%; margin-right: 10%;
margin-left: 25%; margin-left: 25%;
margin-bottom: 5%; margin-bottom: 5%;
margin-top: 5%;
font-size: 12px !important; font-size: 12px !important;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<script src="lib/chart/angular-chart.js"></script> <script src="lib/chart/angular-chart.js"></script>
<!-- cordova script (this will be a 404 during development) --> <!-- cordova script (this will be a 404 during development) -->
<script src="lib/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 type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
......
...@@ -38,6 +38,8 @@ angular.module('blazer', [ ...@@ -38,6 +38,8 @@ angular.module('blazer', [
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) { .config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top $ionicConfigProvider.tabs.position('bottom'); // other values: top
$ionicConfigProvider.tabs.style('standard');
$ionicConfigProvider.spinner.icon('lines');
$stateProvider $stateProvider
/* MENU */ /* MENU */
......
...@@ -199,7 +199,7 @@ angular.module('blazer.apiservices', []) ...@@ -199,7 +199,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: "Unexpected Error!", duration: 500}); $ionicLoading.show({ template: "Check your connection!", duration: 500});
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -292,7 +292,7 @@ angular.module('blazer.apiservices', []) ...@@ -292,7 +292,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: "Try Again!", duration: 1000});
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -328,12 +328,12 @@ angular.module('blazer.apiservices', []) ...@@ -328,12 +328,12 @@ angular.module('blazer.apiservices', [])
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: "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: "Sending Error!", duration: 1000}); $ionicLoading.show({ template: "Try Again!", duration: 1000});
}); });
promise.success = function(fn) { promise.success = function(fn) {
...@@ -357,7 +357,7 @@ angular.module('blazer.apiservices', []) ...@@ -357,7 +357,7 @@ angular.module('blazer.apiservices', [])
$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,
"username": 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),
...@@ -433,13 +433,12 @@ angular.module('blazer.apiservices', []) ...@@ -433,13 +433,12 @@ angular.module('blazer.apiservices', [])
$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,
"dest": data.dest, "pickup_lat": data.pickup_lat,
"rname": data.rname, "pickup_lng": data.pickup_lng,
"loc": data.loc, "dest_lat": data.dest_lat,
"lat": data.lat, "dest_lng": data.dest_lng,
"long": data.long, "assembly_time": data.assembly_time,
"assembly": data.assembly, "car_model": data.car_model,
"model": data.model,
"capacity": data.capacity, "capacity": data.capacity,
"mobile": data.mobile, "mobile": data.mobile,
"other": data.other "other": data.other
...@@ -506,7 +505,44 @@ angular.module('blazer.apiservices', []) ...@@ -506,7 +505,44 @@ angular.module('blazer.apiservices', [])
return promise; return promise;
} }
return promise; return promise;
},
ForgotPassword: function(data) {
console.log("****** ON ENTER FORGOT PASSWORD SERVICE ******");
var deferred = $q.defer();
var promise = deferred.promise;
console.log("[ EMAIL DATA ] -> ", JSON.stringify(data));
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000});
var emailData = {
"email_address": data.email_address,
};
$http({method: 'POST', url: 'http://blaze.eacomm.com/send_password.php',
data: $.param(emailData),
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
$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;
},
} }
}) })
......
This source diff could not be displayed because it is too large. You can view the blob instead.
cordova.define("cordova-plugin-network-information.Connection", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Network status
*/
module.exports = {
UNKNOWN: "unknown",
ETHERNET: "ethernet",
WIFI: "wifi",
CELL_2G: "2g",
CELL_3G: "3g",
CELL_4G: "4g",
CELL:"cellular",
NONE: "none"
};
});
cordova.define("cordova-plugin-network-information.network", function(require, exports, module) {
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec'),
cordova = require('cordova'),
channel = require('cordova/channel'),
utils = require('cordova/utils');
// Link the onLine property with the Cordova-supplied network info.
// This works because we clobber the navigator object with our own
// object in bootstrap.js.
// Browser platform do not need to define this property, because
// it is already supported by modern browsers
if (cordova.platformId !== 'browser' && typeof navigator != 'undefined') {
utils.defineGetter(navigator, 'onLine', function() {
return this.connection.type != 'none';
});
}
function NetworkConnection() {
this.type = 'unknown';
}
/**
* Get connection info
*
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
*/
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
};
var me = new NetworkConnection();
var timerId = null;
var timeout = 500;
channel.createSticky('onCordovaConnectionReady');
channel.waitForInitialization('onCordovaConnectionReady');
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
me.type = info;
if (info === "none") {
// set a timer if still offline at the end of timer send the offline event
timerId = setTimeout(function(){
cordova.fireDocumentEvent("offline");
timerId = null;
}, timeout);
} else {
// If there is a current offline event pending clear it
if (timerId !== null) {
clearTimeout(timerId);
timerId = null;
}
cordova.fireDocumentEvent("online");
}
// should only fire this once
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
},
function (e) {
// If we can't get the network info we should still tell Cordova
// to fire the deviceready event.
if (channel.onCordovaConnectionReady.state !== 2) {
channel.onCordovaConnectionReady.fire();
}
console.log("Error initializing Network Connection: " + e);
});
});
module.exports = me;
});
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
}, },
"cordova-plugin-inappbrowser": { "cordova-plugin-inappbrowser": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192" "PACKAGE_NAME": "com.ionicframework.blazerapp561192"
},
"cordova-plugin-network-information": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
} }
}, },
"dependent_plugins": { "dependent_plugins": {
......
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Contributing to Apache Cordova
Anyone can contribute to Cordova. And we need your contributions.
There are multiple ways to contribute: report bugs, improve the docs, and
contribute code.
For instructions on this, start with the
[contribution overview](http://cordova.apache.org/contribute/).
The details are explained there, but the important items are:
- Sign and submit an Apache ICLA (Contributor License Agreement).
- Have a Jira issue open that corresponds to your contribution.
- Run the tests so your patch doesn't break existing functionality.
We look forward to your contributions!
This diff is collapsed.
Apache Cordova
Copyright 2012 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
This product includes software developed by Apple Inc. License can be found in the header of the affected files. (src/ios/CDVReachability.h, src/ios/CDVReachability.m)
This diff is collapsed.
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Release Notes
### 1.3.0 (Sep 08, 2016)
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
* [CB-11734](https://issues.apache.org/jira/browse/CB-11734) Network Plugin uses `Android Log class` and not `Cordova LOG class`
* [CB-11300](https://issues.apache.org/jira/browse/CB-11300) (**android**) Recognize `2G`, `3G` and `4G` network connection subtype names
* Update `NetworkManager.java`
* Detection of Ethernet Network Type on **Android**
* fixed two potential memory leaks when doing Analyze on **iOS 9**
* [CB-11384](https://issues.apache.org/jira/browse/CB-11384) **android**: Does not pass sonarqube scan
* Add badges for paramedic builds on Jenkins
* Add pull request template.
* Readme: Add fenced code blocks with langauage hints
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
### 1.2.1 (Apr 15, 2016)
* [CB-10763](https://issues.apache.org/jira/browse/CB-10763) Remove emoji in `cordova-plugin-network-information`
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
### 1.2.0 (Jan 15, 2016)
* Adding `CoreTelephony` to `plugin.xml`
* Adding notification for `CT radio` information
* Adding `CT radio` information
* [CB-10160](https://issues.apache.org/jira/browse/CB-10160) Fixed the case mismatch issue
### 1.1.0 (Nov 18, 2015)
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
* Fixing contribute link.
* These notifications are objects so their address always evaluates to true.
* Update `NetworkManager.java`
* [CB-9542](https://issues.apache.org/jira/browse/CB-9542) `Browser Proxy` not defined correctly
* Solved `toLowerCase` issue with `Locale.US`
### 1.0.1 (Jun 17, 2015)
* Adding .ratignore file.
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-network-information documentation translation: cordova-plugin-network-information
* fix npm md issue
### 1.0.0 (Apr 15, 2015)
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Fixes typo in `cordova.platformId`
* Use TRAVIS_BUILD_DIR, install paramedic by npm
* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Use `navigator.onLine` as connection information source on browser platform
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method
* [CB-8573](https://issues.apache.org/jira/browse/CB-8573) Integrate TravisCI
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-network-information documentation translation: cordova-plugin-network-information
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
### 0.2.15 (Feb 04, 2015)
* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Network status change support on Windows
* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Fixes the way we detect online status on Windows
* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows platform quirks
* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows section to Network Information plugin
### 0.2.14 (Dec 02, 2014)
* [CB-7976](https://issues.apache.org/jira/browse/CB-7976) **Android**: Use webView's context rather than Activity's context for intent receiver
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-network-information documentation translation: cordova-plugin-network-information
### 0.2.13 (Oct 03, 2014)
* [CB-7595](https://issues.apache.org/jira/browse/CB-7595): Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented
### 0.2.12 (Sep 17, 2014)
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-network-information documentation translation
* Fix network information type exception on fxos 2
* Added support for the browser
* [CB-6724](https://issues.apache.org/jira/browse/CB-6724) added documentation for manual tests
* remove reference to test assets, they are optional
* Renamed test dir and added nested plugin.xml
* [CB-6964](https://issues.apache.org/jira/browse/CB-6964) ported manual tests
* Port network tests to plugin-test-framework
* Fix naviagtor typo
### 0.2.11 (Aug 06, 2014)
* **FFOS** update NetworkProxy.js
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
* [CB-7019](https://issues.apache.org/jira/browse/CB-7019) Updated version and RELEASENOTES.md for release 0.2.10
* Fixed docs for online/offline event being backwards
### 0.2.10 (Jun 24, 2014)
* [CB-6907](https://issues.apache.org/jira/browse/CB-6907): [android] Don't crash on startup if no networks available
### 0.2.9 (Jun 05, 2014)
* updated notice file to include missing license
* Cached extra info to better detect changes.
* [CB-6809](https://issues.apache.org/jira/browse/CB-6809) Add license to CONTRIBUTING.md
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
* [CB-6350](https://issues.apache.org/jira/browse/CB-6350) - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8)
* Initial version of firefox os network information plugin
* there was an error in the object definition
### 0.2.8 (Apr 17, 2014)
* [CB-6342](https://issues.apache.org/jira/browse/CB-6342): [iOS] iOS reports a cellular connection even when in Airplane mode
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code
* Add NOTICE file
### 0.2.7 (Feb 05, 2014)
* Initial implementation of Tizen plugin.
### 0.2.6 (Jan 02, 2014)
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for netinfo plugin
### 0.2.5 (Dec 4, 2013)
* [ubuntu] specify policy_group
* add ubuntu platform
* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
### 0.2.4 (Oct 28, 2013)
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for network information plugin
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
### 0.2.3 (Sept 25, 2013)
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
* [windows8] commandProxy was moved
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information
* removed duplicate comment line from plugin.xml
* added Network APIs for FirefoxOS
* Rename CHANGELOG.md -> RELEASENOTES.md
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
### 0.2.1 (Sept 5, 2013)
* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change
<!--
# license: Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-->
# cordova-plugin-network-information
[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information)
Dieses Plugin stellt eine Implementierung einer alten Version der [Netzwerk-Informationen-API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/). Es werden Informationen über das Gerät Mobilfunk und Wifi-Anschluss, und ob das Gerät über eine Internetverbindung verfügt.
## Installation
cordova plugin add cordova-plugin-network-information
## Unterstützte Plattformen
* Amazon Fire OS
* Android
* BlackBerry 10
* Browser
* iOS
* Windows Phone 7 und 8
* Tizen
* Windows
* Firefox OS
# Connection
> Das `connection` Objekt, verfügbar gemachten über `navigator.connection`, enthält Informationen über die Mobilfunk- und Wi-Fi-Verbindung des Gerätes.
## Eigenschaften
* connection.type
## Konstanten
* Connection.UNKNOWN
* Connection.ETHERNET
* Connection.WIFI
* Connection.CELL_2G
* Connection.CELL_3G
* Connection.CELL_4G
* Connection.CELL
* Connection.NONE
## connection.type
Diese Eigenschaft bietet eine schnelle Möglichkeit, um den Netzwerkverbindungsstatus und die Art der Verbindung zu bestimmen.
### Kurzes Beispiel
function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}
checkConnection();
### API Änderung
Bis Cordova 2.3.0 wurde auf das `Connection` Objekt über `navigator.network.connection` zugegriffen, danach wurde der Zugriff auf `navigator.connection` geändert, um der W3C-Spezifikation zu entsprechen. Es steht immer noch an seiner ursprünglichen Stelle, aber ist veraltet und wird schliesslich entfernt.
### iOS Macken
* iOS kann Mobilfunknetz Verbindungstyp nicht erkennen.
* `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten.
### Windows Phone Macken
* Wenn im Emulator ausgeführt wird, erkennt immer `navigator.connection.type` als`Connection.UNKNOWN`.
* Windows Phone kann Mobilfunknetz Verbindungstyp nicht erkennen.
* `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten.
### Windows-Eigenheiten
* Wenn im Telefon 8.1 Emulator ausgeführt wird, erkennt immer `navigator.connection.type` als `Connection.ETHERNET`.
### Tizen Macken
* Tizen kann nur ein WiFi oder Mobilfunkverbindung erkennen.
* `Navigator.Connection.Type` ist für alle Handy-Daten auf `Connection.CELL_2G` festgelegt.
### Firefox OS Macken
* Firefox-OS kann Mobilfunknetz Verbindungstyp nicht erkennen.
* `navigator.connection.type`auf festgelegt ist `Connection.CELL` für alle Handy-Daten.
### Browser-Eigenheiten
* Browser kann die Art der Netzwerkverbindung nicht erkennen. `navigator.connection.type` ist immer auf `Connection.UNKNOWN` beim online gesetzt.
# Netzwerk-Veranstaltungen
## offline
Das Ereignis wird ausgelöst, wenn eine Anwendung offline geht, und das Gerät nicht mit dem Internet verbunden ist.
document.addEventListener("offline", yourCallbackFunction, false);
### Details
Das `offline` -Ereignis wird ausgelöst, wenn ein bereits angeschlossenes Gerät eine Netzwerkverbindung verliert, so dass eine Anwendung nicht mehr auf das Internet zugreifen kann. Es stützt sich auf die gleichen Informationen wie die Verbindung-API und wird ausgelöst, wenn der Wert des `connection.type` wird`NONE`.
Anwendungen sollten in der Regel verwenden `document.addEventListener` einmal einen Ereignis-Listener hinzufügen das `deviceready` -Ereignis ausgelöst.
### Kurzes Beispiel
document.addEventListener("offline", onOffline, false);
function onOffline() {
// Handle the offline event
}
### iOS Macken
Beim ersten Start dauert das erste offline-Event (falls zutreffend) mindestens eine Sekunde zu schießen.
### Windows Phone 7 Macken
Bei der Ausführung im Emulator, der `connection.status` ist immer unbekannt, so dass dieses Ereignis *nicht* Feuer.
### Windows Phone 8 Macken
Der Emulator meldet den Verbindungstyp als `Cellular` , die wird nicht geändert, so dass das Ereignis *nicht* Feuer.
## online
Dieses Ereignis wird ausgelöst, wenn eine Anwendung online geht, und das Gerät wird mit dem Internet verbunden.
document.addEventListener("online", yourCallbackFunction, false);
### Details
Das `online` -Ereignis wird ausgelöst, wenn ein zuvor unverbundenen Gerät eine Netzwerkverbindung zu einem Anwendung Zugriff auf das Internet empfängt. Es stützt sich auf die gleichen Informationen wie die Verbindung-API und wird ausgelöst, wenn die `connection.type` ändert sich von `NONE` auf einen anderen Wert.
Anwendungen sollten in der Regel verwenden `document.addEventListener` einmal einen Ereignis-Listener hinzufügen das `deviceready` -Ereignis ausgelöst.
### Kurzes Beispiel
document.addEventListener("online", onOnline, false);
function onOnline() {
// Handle the online event
}
### iOS Macken
Beim ersten Start die erste `online` Ereignis (falls zutreffend) dauert mindestens eine Sekunde vor dem Feuer `connection.type` ist`UNKNOWN`.
### Windows Phone 7 Macken
Bei der Ausführung im Emulator, der `connection.status` ist immer unbekannt, so dass dieses Ereignis *nicht* Feuer.
### Windows Phone 8 Macken
Der Emulator meldet den Verbindungstyp als `Cellular` , die wird nicht geändert, so dass Ereignisse *nicht* Feuer.
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
#import "CDVReachability.h"
@interface CDVConnection : CDVPlugin {
NSString* type;
NSString* _callbackId;
CDVReachability* internetReach;
}
@property (copy) NSString* connectionType;
@property (strong) CDVReachability* internetReach;
@end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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