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",
"app_id": "",
"app_id": "173c9de2",
"browsers": [
{
"platform": "android",
......
......@@ -67,6 +67,10 @@
{
"xml": "<feature name=\"InAppBrowser\"><param name=\"android-package\" value=\"org.apache.cordova.inappbrowser.InAppBrowser\" /></feature>",
"count": 1
},
{
"xml": "<feature name=\"NetworkStatus\"><param name=\"android-package\" value=\"org.apache.cordova.networkinformation.NetworkManager\" /></feature>",
"count": 1
}
]
}
......@@ -84,7 +88,7 @@
},
{
"xml": "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />",
"count": 1
"count": 2
},
{
"xml": "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />",
......@@ -133,6 +137,9 @@
},
"cordova-plugin-inappbrowser": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
},
"cordova-plugin-network-information": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
}
},
"dependent_plugins": {},
......@@ -199,6 +206,21 @@
"cordova.InAppBrowser.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": {
......@@ -212,6 +234,7 @@
"ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1",
"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', [])
.controller('AuthCtrl', function($scope, $state, postBlazer, $timeout, $ionicPopup, $cordovaDialogs, $cordovaInAppBrowser) {
.controller('AuthCtrl', function($scope, $state, postBlazer, $timeout, $filter, $ionicPopup, $cordovaDialogs, $cordovaInAppBrowser) {
$scope.user = {
username: "blazetestaccount",
password: "blazetestaccount"
};
// $scope.user = {
// username: "blazetestaccount",
// password: "blazetestaccount"
// };
// $scope.user = {};
$scope.user = {};
$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) {
console.log("LOGIN SUCCESS", response);
$state.go('app.map');
localStorage.setItem("username", $scope.user.username);
localStorage.setItem("password", $scope.user.password);
$scope.user = {};
$state.go('app.map');
})
.error(function(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', [])
.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
$ionicHistory.clearHistory();
......@@ -348,24 +348,31 @@ angular.module('blazer.mapcontrollers', [])
/* END TRIP */
$scope.tripEnd = function(){
$scope.tripStatus = false;
tripStatusRef = false;
var newDate = new Date();
var endTime = newDate.getTime();
localStorage.setItem("endtime", endTime);
console.log("END TRIP TIME", endTime);
// TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG
$scope.clearPolylines();
map.removeLayer(line); // REMOVE LINE TRACK
parsedData = []; // CLEAR BLAZER MARKER ARRAY
/* 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;
tripStatusRef = false;
var newDate = new Date();
var endTime = newDate.getTime();
localStorage.setItem("endtime", endTime);
console.log("END TRIP TIME", endTime);
$interval.cancel(intervalTrigger); // CANCEL FUNCTION CALL
// TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG
$scope.clearPolylines();
map.removeLayer(line); // REMOVE LINE TRACK
parsedData = []; // CLEAR BLAZER MARKER ARRAY
$scope.sendTrackingLocation(); // SEND LOCATION DATA
$interval.cancel(intervalTrigger); // CANCEL FUNCTION CALL
$scope.sendTrackingLocation(); // SEND LOCATION DATA
$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 */
......
......@@ -14,15 +14,20 @@ angular.module('blazer.misccontrollers', [])
buttons: [
{ text: '<i class="icon ion-power"></i> Log Out' },
],
titleText: '',
titleText: 'Select an option.',
cancelText: 'Cancel',
cancel: function() {
// add cancel code..
},
buttonClicked: function(index) {
if(index === 0){
$scope.class = "ion-power";
$state.go('login');
$scope.class = "ion-power";
localStorage.removeItem("username");
localStorage.removeItem("password");
localStorage.removeItem("userID");
$ionicHistory.clearHistory();
$ionicHistory.clearCache();
}
return true;
}
......
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 */
var destinationMap = L.map('mapdestination');
......@@ -86,7 +86,7 @@ angular.module('blazer.offerridecontrollers', [])
"pickup_lng": pickup_lng,
"dest_lat": dest_lat,
"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,
"capacity": $scope.offer.capacity,
"mobile": $scope.offer.mobile,
......
......@@ -14,9 +14,9 @@
<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 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>
<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>
<label class="item item-input item-stacked-label border-bottom-select">
<span class="input-label"> Car Brand</span>
......
......@@ -17,12 +17,15 @@ angular.module('blazer.sharedridecontrollers', [])
/* FILTER RIDES */
for(var i = 0; i < data.length; i ++){
if(data[i].ride_status == true){
$scope.$broadcast('scroll.refreshComplete');
$scope.ridingRide.push(data[i]);
}
else if(data[i].interested_status == true){
$scope.$broadcast('scroll.refreshComplete');
$scope.interestedRides.push(data[i]);
}
else {
$scope.$broadcast('scroll.refreshComplete');
$scope.availableRide.push(data[i]);
}
}
......
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.modalEndTrip.hide();
......@@ -12,36 +12,43 @@ angular.module('blazer.surveycontrollers', [])
$scope.endtrip = {};
$scope.postEndTripSurvey = function(){
var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime");
var endTime = localStorage.getItem("endtime");
var newDate = new Date();
var timeStamp = newDate.getTime();
var currentTrip = localStorage.getItem("currentTrip");
var postdata = {
"trip_id" : tripID,
"username": username,
"depart": startTime,
"arrive": endTime,
"mode": $scope.endtrip.mode,
"exp": $scope.endtrip.overallxp,
"emotion": $scope.endtrip.emotion,
"type": currentTrip
}
console.log("[ POST END TRIP SURVEY ]");
postBlazer.EndTripSurvey(postdata)
.success(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.log("SEND ENDTRIP SURVEY SUCCESS", response);
})
.error(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response);
});
/* CHECK IF MOBILE IS ONLINE */
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username");
var startTime = localStorage.getItem("starttime");
var endTime = localStorage.getItem("endtime");
var newDate = new Date();
var timeStamp = newDate.getTime();
var currentTrip = localStorage.getItem("currentTrip");
var postdata = {
"trip_id" : tripID,
"username": username,
"depart": startTime,
"arrive": endTime,
"mode": $scope.endtrip.mode,
"exp": $scope.endtrip.overallxp,
"emotion": $scope.endtrip.emotion,
"type": currentTrip
}
console.log("[ POST END TRIP SURVEY ]");
postBlazer.EndTripSurvey(postdata)
.success(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.log("SEND ENDTRIP SURVEY SUCCESS", response);
})
.error(function(response) {
$scope.closeEndTripModal();
$scope.endtrip = {};
console.error("SEND ENDTRIP SURVEY ERROR", response);
});
}
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.disableSwipe = function() {
......@@ -62,58 +69,65 @@ angular.module('blazer.surveycontrollers', [])
$scope.weekly = {};
$scope.postWeeklySurvey = function(){
var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username");
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE');
var dateCreated = $filter('date')(newDate, 'yyyy - MM - dd HH: mm: ss');
var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){
angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(value);
})
}
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(value);
})
}
else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(value);
})
}
else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(value);
})
}
else if($scope.weekly.main == 'C'){
surveyAnswer = null;
}
console.log("[ NETWORK STATUS ]", $cordovaNetwork.getNetwork());
if($cordovaNetwork.getNetwork() == Connection.WIFI || $cordovaNetwork.getNetwork() == Connection.CELL_2G || $cordovaNetwork.getNetwork() == Connection.CELL_3G ||$cordovaNetwork.getNetwork() == Connection.CELL_4G){
var userID = localStorage.getItem("userID");
var username = localStorage.getItem("username");
var newDate = new Date();
var currentDate = $filter('date')(newDate, 'yyyyMMww');
var dayToday = $filter('date')(newDate, 'EEEE');
var dateCreated = $filter('date')(newDate, 'yyyy - MM - dd HH: mm: ss');
var surveyAnswer = [];
/* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){
angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 'C'){
surveyAnswer = null;
}
var postdata = {
"user_id": userID,
"username": username,
"choice": $scope.weekly.main,
"survey_ans": surveyAnswer,
"date_created": dateCreated
}
postBlazer.WeeklySurvey(postdata)
.success(function(response) {
console.log("SEND WEEKLY SURVEY SUCCESS", response);
localStorage.setItem(currentDate, currentDate);
$scope.resetValues();
$scope.closeWeeklyModal();
})
.error(function(response) {
console.error("SEND WEEKLY SURVEY ERROR", response);
$scope.resetValues();
$scope.closeWeeklyModal();
});
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyAnswer));
var postdata = {
"user_id": userID,
"username": username,
"choice": $scope.weekly.main,
"survey_ans": surveyAnswer,
"date_created": dateCreated
}
postBlazer.WeeklySurvey(postdata)
.success(function(response) {
console.log("SEND WEEKLY SURVEY SUCCESS", response);
localStorage.setItem(currentDate, currentDate);
$scope.resetValues();
$scope.closeWeeklyModal();
})
.error(function(response) {
console.error("SEND WEEKLY SURVEY ERROR", response);
$scope.resetValues();
$scope.closeWeeklyModal();
});
}
else {
$cordovaDialogs.alert('Network Connection is required before taking this action. Thank you!', 'Ooops', "OKAY");
}
}
$scope.resetValues = function(){
......
......@@ -62,6 +62,21 @@ module.exports = [
"cordova.InAppBrowser.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 =
......@@ -77,7 +92,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1",
"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
});
\ No newline at end of file
......@@ -33,6 +33,7 @@
<!-- your app's js -->
<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/auth/js/auth.js"></script>
<script src="app/map/js/map.js"></script>
......
angular.module('blazer', [
'ionic',
'blazer.landingcontrollers',
'blazer.menucontrollers',
'blazer.authenticationcontrollers',
'blazer.mapcontrollers',
......@@ -34,6 +35,10 @@ angular.module('blazer', [
$ionicPickerI18n.okClass = "button-dark button-outline";
$ionicPickerI18n.cancelClass = "button-dark button-outline";
});
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
}, 100);
})
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
......@@ -42,6 +47,13 @@ angular.module('blazer', [
$ionicConfigProvider.spinner.icon('lines');
$stateProvider
/* LANDING */
.state('landing', {
url: '/landing',
templateUrl: 'app/landing/landing.html',
controller: 'LandingCtrl'
})
/* MENU */
.state('app', {
url: '/app',
......@@ -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', [])
}).success(function(responseData) {
console.log("[ LOGIN RESPONSE ]", JSON.stringify(responseData));
if(responseData.status == 0){
$ionicLoading.show({ template: responseData.message, duration: 500});
$ionicLoading.show({ template: 'Invalid Credentials. Try again!', duration: 1000});
deferred.reject('Error');
}
else if(responseData.status == 1){
......@@ -366,7 +366,7 @@ angular.module('blazer.apiservices', [])
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
$ionicLoading.show({ template: "Success!", duration: 1000});
// $ionicLoading.show({ template: "Success!", duration: 1000});
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
......@@ -404,7 +404,7 @@ angular.module('blazer.apiservices', [])
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
$ionicLoading.show({ template: "Success!", duration: 1000});
// $ionicLoading.show({ template: "Success!", duration: 1000});
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
......@@ -433,13 +433,12 @@ angular.module('blazer.apiservices', [])
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000});
var offerRiderData = {
"name": data.name,
"dest": data.dest,
"rname": data.rname,
"loc": data.loc,
"lat": data.lat,
"long": data.long,
"assembly": data.assembly,
"model": data.model,
"pickup_lat": data.pickup_lat,
"pickup_lng": data.pickup_lng,
"dest_lat": data.dest_lat,
"dest_lng": data.dest_lng,
"assembly_time": data.assembly_time,
"car_model": data.car_model,
"capacity": data.capacity,
"mobile": data.mobile,
"other": data.other
......@@ -450,7 +449,7 @@ angular.module('blazer.apiservices', [])
}).success(function(responseData) {
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
$ionicLoading.show({ template: "Success!", duration: 1000});
$ionicLoading.show({ template: "Ride Offered", duration: 1000});
}).error(function(responseData) {
console.error("[ OFFER RIDE ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
......
......@@ -2,4 +2,5 @@ var blazerAPI = 'http://blaze.eacomm.com/api';
var appVersion = '1.0.0';
var buildNumber = '1.0.0';
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'
\ 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 = [
"cordova.InAppBrowser.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 =
......@@ -77,7 +92,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1",
"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
});
\ 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 @@
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</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="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
......
......@@ -27,6 +27,10 @@
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, ); }; };
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 */
/* Begin PBXContainerItemProxy section */
......@@ -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; };
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; };
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 */
/* Begin PBXFrameworksBuildPhase section */
......@@ -97,6 +107,8 @@
301BF552109A68D80062928A /* libCordova.a in Frameworks */,
3CE3887C122740C68FA53F37 /* CoreLocation.framework in Frameworks */,
A4FD78990AD44E95B64F4A16 /* AudioToolbox.framework in Frameworks */,
77A933A39CB4466C806F43C2 /* SystemConfiguration.framework in Frameworks */,
58935A934A8E47BD8B980467 /* CoreTelephony.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -169,6 +181,8 @@
children = (
EA414E5BD06B48DD87D09393 /* CoreLocation.framework */,
6B0F4F11EC784D5282C56794 /* AudioToolbox.framework */,
668CFD6E00B44D52A7D135F0 /* SystemConfiguration.framework */,
DFE41DB246E843FF81A6A110 /* CoreTelephony.framework */,
);
name = Frameworks;
sourceTree = "<group>";
......@@ -212,6 +226,10 @@
AF69C3230FE247BDB620C8F7 /* CDVNotification.h */,
58539E6865DA4FB4994ADFD6 /* CDVInAppBrowser.m */,
CA4EA3DE2EF14385AB38677A /* CDVInAppBrowser.h */,
E4EE3C5DF43E488D9AE296C0 /* CDVConnection.m */,
1DAE42B485294A8D96EF9C71 /* CDVReachability.m */,
492E3584A2214E308AB52472 /* CDVConnection.h */,
7790BE8BFA234D4D9E2774EB /* CDVReachability.h */,
);
name = Plugins;
path = Blaze/Plugins;
......@@ -339,6 +357,8 @@
068A80E3895D40F9B47D4699 /* IonicKeyboard.m in Sources */,
BFE42A8C9D57424AA63E0A50 /* CDVNotification.m in Sources */,
8B4D6C644F1444D885AB9E94 /* CDVInAppBrowser.m in Sources */,
F1C4BBEC5D7C4731A27F5532 /* CDVConnection.m in Sources */,
7434D91954CC4CEAA4065558 /* CDVReachability.m in Sources */,
);
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 @@
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
<name>Blaze</name>
<description>
An Ionic Framework and Cordova project.
......
{
"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 @@
{
"xml": "<feature name=\"InAppBrowser\"><param name=\"ios-package\" value=\"CDVInAppBrowser\" /></feature>",
"count": 1
},
{
"xml": "<feature name=\"NetworkStatus\"><param name=\"ios-package\" value=\"CDVConnection\" /></feature>",
"count": 1
}
]
}
......@@ -96,6 +100,9 @@
},
"cordova-plugin-inappbrowser": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
},
"cordova-plugin-network-information": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
}
},
"dependent_plugins": {},
......@@ -197,6 +204,23 @@
"cordova.InAppBrowser.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": {
......@@ -210,6 +234,7 @@
"ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1",
"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 = [
"cordova.InAppBrowser.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 =
......@@ -112,7 +129,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1",
"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
});
\ 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', [])
.controller('AuthCtrl', function($scope, $state, postBlazer, $cordovaDialogs) {
.controller('AuthCtrl', function($scope, $state, postBlazer, $timeout, $ionicPopup, $cordovaDialogs, $cordovaInAppBrowser) {
$scope.user = {
username: "blazetestaccount",
password: "blazetestaccount"
};
// $scope.user = {
// username: "blazetestaccount",
// password: "blazetestaccount"
// };
// $scope.user = {};
$scope.loginUser = function(){
......@@ -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(){
......
......@@ -12,7 +12,7 @@
<input type="password" ng-model="user.password" placeholder="Password" required>
</label>
</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-small button-outline button-light login-button" ng-click="showDialog()">SIGN UP</button> -->
</form>
......
......@@ -68,7 +68,7 @@ angular.module('blazer.mapcontrollers', [])
// REMOVE MARKERS
map.removeLayer(markers);
$scope.drawTripMarkers(lat, lon); // DRAW TRIP MARKER ]
$scope.drawMarkers(lat, lon, 'On Trip'); // DRAW TRIP MARKER ]
}
/* EVENT LISTENERS */
......@@ -247,6 +247,7 @@ angular.module('blazer.mapcontrollers', [])
$scope.selectedBarangayData = $scope.data.selectedBarangay +" "+ $scope.data.selectedBarangayTime;
$scope.currentBarangay = $scope.data.selectedBarangay;
$scope.currentBarangayTime = $scope.data.selectedBarangayTime;
$scope.data = {};
}
},
{
......@@ -275,6 +276,10 @@ angular.module('blazer.mapcontrollers', [])
console.log('[ BARANGAY DETAILS ]', JSON.stringify($scope.BarangayData));
$scope.openChart($scope.BarangayData); // LOAD CHART MODAL
$scope.drawMarkers($scope.BarangayData.lat, $scope.BarangayData.lng, $scope.currentBarangay);
// RESET VALUES
$scope.selectedBarangayData = '';
$scope.currentBarangay = '';
$scope.currentBarangayTime = '';
})
.error(function(response) {
console.error("BARANGAY ERROR", response);
......@@ -331,9 +336,10 @@ angular.module('blazer.mapcontrollers', [])
map.removeLayer(geojsonLayer);
$scope.tripStatus = true;
var newDate = new Date();
var newDate = new Date();
startTime = newDate.getTime();
localStorage.setItem("starttime", startTime);
console.log("START TRIP TIME", startTime);
$scope.getUserLocation();
......@@ -344,8 +350,10 @@ angular.module('blazer.mapcontrollers', [])
$scope.tripEnd = function(){
$scope.tripStatus = false;
tripStatusRef = false;
var newDate = new Date();
endTime = newDate.getTime();
var endTime = newDate.getTime();
localStorage.setItem("endtime", endTime);
console.log("END TRIP TIME", endTime);
// TRIGGER CLEAR FUNCTION OF REMOVE LINE -- NEEDS TO DEBUG
......
......@@ -14,7 +14,7 @@
<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/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/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>
......
......@@ -4,6 +4,7 @@
<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.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>
</div>
<i class="item">
......
angular.module('blazer.offerridecontrollers', [])
.controller('OfferRideCtrl', function($scope, getBlazer, postBlazer, LocationService, $cordovaGeolocation) {
.controller('OfferRideCtrl', function($scope, $ionicHistory, getBlazer, postBlazer, LocationService, $cordovaGeolocation) {
/* MAP DEFAULTS */
var destinationMap = L.map('mapdestination');
......@@ -97,9 +97,11 @@ angular.module('blazer.offerridecontrollers', [])
console.log("OFFER RIDE SUCCESS", response);
data = {};
$scope.offer ={};
$ionicHistory.goBack(-1);
})
.error(function(response) {
console.error("OFFER RIDE ERROR", response);
$ionicHistory.goBack(-1);
});
}
......
......@@ -3,14 +3,15 @@
<div id="mapidpanel"></div>
<div class="list">
<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> {{ (details.assemblytime).split(" ")[0] | date: "MMMM dd, yyyy"}} at {{ (details.assemblytime).split(" ")[1] }}</p>
<!--<p> going to {{ details.destination }} </p>-->
</div>
<div class="button-bar">
<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-call" ng-href="tel:{{details.mobilenum}}"> Call</a>
<a class="button icon ion-android-mail" ng-href="sms:{{details.mobilenum}}"> Message</a>
</div>
</div>
<div class="list list-inset">
......
<ion-view view-title="Take a Shared Ride" ng-init="getSharedRideData();">
<ion-header-bar>
<h1 class="title">Take a Shared Ride</h1>
</ion-header-bar>
<ion-view view-title="Shared Ride" ng-init="getSharedRideData();">
<ion-nav-buttons side="right">
<button class="button button-outline button-icon button-light" ui-sref='app.offerride'>
Offer
</button>
</ion-nav-buttons>
<ion-content>
<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"
icon-off="light ion-android-car">
<ion-content class="background-feed">
......@@ -15,7 +18,8 @@
<i class="icon ion-android-more-vertical"></i> Ride Information
</a>
<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> "{{ ride.ridename }}"</p> -->
<p> {{ (ride.assemblytime).split(" ")[0] }} at {{ (ride.assemblytime).split(" ")[1] }}</p>
......@@ -48,7 +52,8 @@
<i class="icon ion-android-more-vertical"></i> Ride Information
</a>
<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> "{{ ride.ridename }}"</p> -->
<p> {{ (ride.assemblytime).split(" ")[0] }} at {{ (ride.assemblytime).split(" ")[1] }}</p>
......@@ -81,7 +86,8 @@
<i class="icon ion-android-more-vertical"></i> Ride Information
</a>
<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> "{{ ride.ridename }}"</p> -->
<p> {{ (ride.assemblytime).split(" ")[0] | date: "MMMM dd, yyyy" }} at {{ (ride.assemblytime).split(" ")[1] }}</p>
......
......@@ -13,7 +13,7 @@
<p class="text-dark">You've just finished a trip. Please take this short survey.</p>
</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>
</div>
<label class="item item-input item-select item-text-wrap item-stable">
......@@ -25,12 +25,12 @@
<option value="trip1">Going Home</option>
<option value="trip2">Going to School</option>
</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>
</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
<div class="input-label">
</div>
......@@ -50,11 +50,11 @@
</select>
</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
<u><b> {{endtrip.mode}} </b></u>. Overall, how would you evaluate this experience?</p>
</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
<div class="input-label">
</div>
......
......@@ -10,9 +10,7 @@ angular.module('blazer.surveycontrollers', [])
$scope.modalWeeklyTrip.hide();
};
$scope.endtrip = {
destination: localStorage.getItem("currentTrip")
};
$scope.endtrip = {};
$scope.postEndTripSurvey = function(){
var tripID = localStorage.getItem("tripid");
var username = localStorage.getItem("username");
......@@ -20,6 +18,7 @@ angular.module('blazer.surveycontrollers', [])
var endTime = localStorage.getItem("endtime");
var newDate = new Date();
var timeStamp = newDate.getTime();
var currentTrip = localStorage.getItem("currentTrip");
var postdata = {
"trip_id" : tripID,
......@@ -29,7 +28,7 @@ angular.module('blazer.surveycontrollers', [])
"mode": $scope.endtrip.mode,
"exp": $scope.endtrip.overallxp,
"emotion": $scope.endtrip.emotion,
"type": $scope.endtrip.destination
"type": currentTrip
}
console.log("[ POST END TRIP SURVEY ]");
postBlazer.EndTripSurvey(postdata)
......@@ -74,28 +73,29 @@ angular.module('blazer.surveycontrollers', [])
/* LOOP SCOPE OF CHOICES */
if($scope.weekly.main == 1 || $scope.weekly.main == 2){
angular.forEach($scope.choice1, function(value, key){
surveyAnswer.push(value);
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 3){
angular.forEach($scope.choice3, function(value, key){
surveyAnswer.push(value);
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 4){
angular.forEach($scope.choice4, function(value, key){
surveyAnswer.push(value);
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 5){
angular.forEach($scope.choice5, function(value, key){
surveyAnswer.push(value);
surveyAnswer.push(parseInt(value));
})
}
else if($scope.weekly.main == 'C'){
surveyAnswer = null;
}
console.log("[ WEEKLY SURVEY ANSWERS ]", JSON.stringify(surveyAnswer));
var postdata = {
"user_id": userID,
"username": username,
......
This diff is collapsed.
......@@ -97,6 +97,23 @@ module.exports = [
"cordova.InAppBrowser.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 =
......@@ -112,7 +129,8 @@ module.exports.metadata =
"ionic-plugin-keyboard": "2.2.0",
"cordova-plugin-dialogs": "1.2.1",
"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
});
\ No newline at end of file
......@@ -230,6 +230,7 @@ color: #fff;
margin-right: 10%;
margin-left: 25%;
margin-bottom: 5%;
margin-top: 5%;
font-size: 12px !important;
}
......
......@@ -25,7 +25,7 @@
<script src="lib/chart/angular-chart.js"></script>
<!-- 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 type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
......
......@@ -38,6 +38,8 @@ angular.module('blazer', [
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); // other values: top
$ionicConfigProvider.tabs.style('standard');
$ionicConfigProvider.spinner.icon('lines');
$stateProvider
/* MENU */
......
......@@ -199,7 +199,7 @@ angular.module('blazer.apiservices', [])
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Unexpected Error!", duration: 500});
$ionicLoading.show({ template: "Check your connection!", duration: 500});
});
promise.success = function(fn) {
......@@ -292,7 +292,7 @@ angular.module('blazer.apiservices', [])
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Sending Error!", duration: 1000});
$ionicLoading.show({ template: "Try Again!", duration: 1000});
});
promise.success = function(fn) {
......@@ -328,12 +328,12 @@ angular.module('blazer.apiservices', [])
console.log("[ SUCCESS ]", JSON.stringify(responseData));
deferred.resolve('Success');
$ionicLoading.show({ template: "Success!", duration: 1000});
$ionicLoading.show({ template: "Submitted!", duration: 1000});
}).error(function(responseData) {
console.error("[ ERROR ]", JSON.stringify(responseData));
deferred.reject('Error');
$ionicLoading.show({ template: "Sending Error!", duration: 1000});
$ionicLoading.show({ template: "Try Again!", duration: 1000});
});
promise.success = function(fn) {
......@@ -357,7 +357,7 @@ angular.module('blazer.apiservices', [])
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000});
var sharedRideData = {
"ride_id": data.ride_id,
"username": data.username
"user": data.username
};
$http({method: 'POST', url: blazerAPI + '/take_shared_ride_post.php',
data: $.param(sharedRideData),
......@@ -433,13 +433,12 @@ angular.module('blazer.apiservices', [])
$ionicLoading.show({ template: '<ion-spinner icon="crescent"></ion-spinner>', duration: 30000});
var offerRiderData = {
"name": data.name,
"dest": data.dest,
"rname": data.rname,
"loc": data.loc,
"lat": data.lat,
"long": data.long,
"assembly": data.assembly,
"model": data.model,
"pickup_lat": data.pickup_lat,
"pickup_lng": data.pickup_lng,
"dest_lat": data.dest_lat,
"dest_lng": data.dest_lng,
"assembly_time": data.assembly_time,
"car_model": data.car_model,
"capacity": data.capacity,
"mobile": data.mobile,
"other": data.other
......@@ -506,7 +505,44 @@ angular.module('blazer.apiservices', [])
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 @@
},
"cordova-plugin-inappbrowser": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
},
"cordova-plugin-network-information": {
"PACKAGE_NAME": "com.ionicframework.blazerapp561192"
}
},
"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
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.
{
"name": "cordova-plugin-network-information",
"version": "1.3.0",
"description": "Cordova Network Information Plugin",
"cordova": {
"id": "cordova-plugin-network-information",
"platforms": [
"firefoxos",
"android",
"amazon-fireos",
"ubuntu",
"ios",
"blackberry10",
"wp7",
"wp8",
"windows8",
"windows",
"tizen",
"browser"
]
},
"repository": {
"type": "git",
"url": "https://github.com/apache/cordova-plugin-network-information"
},
"keywords": [
"cordova",
"network",
"information",
"ecosystem:cordova",
"cordova-firefoxos",
"cordova-android",
"cordova-amazon-fireos",
"cordova-ubuntu",
"cordova-ios",
"cordova-blackberry10",
"cordova-wp7",
"cordova-wp8",
"cordova-windows8",
"cordova-windows",
"cordova-tizen",
"cordova-browser"
],
"scripts": {
"test": "npm run jshint",
"jshint": "jshint www && jshint src && jshint tests"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"engines": {
"cordovaDependencies": {
"2.0.0": {
"cordova": ">100"
}
}
},
"devDependencies": {
"jshint": "^2.6.0"
}
}
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.
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