Last active
August 1, 2016 19:25
-
-
Save fitodac/480d855b53f325ee779232e316d9d0a9 to your computer and use it in GitHub Desktop.
geolocation agroclima
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $lat, | |
$lon, | |
$ini = 0, | |
$ini_data_error = false; | |
/*------------------------------------*/ | |
/* DATOS ACTUALES */ | |
/*------------------------------------*/ | |
var date = new Date(), | |
dateYear = date.getFullYear(), | |
dateDay = date.getDate(), | |
dateMonth = date.getMonth(), | |
dateYear = date.getFullYear(), | |
dateHour = date.getHours(), | |
dateMin = date.getMinutes(); | |
var weekday = new Array(7); | |
weekday[0] = 'Domingo'; | |
weekday[1] = 'Lunes'; | |
weekday[2] = 'Martes'; | |
weekday[3] = 'Miércoles'; | |
weekday[4] = 'Jueves'; | |
weekday[5] = 'Viernes'; | |
weekday[6] = 'Sábado'; | |
var dateDayName = weekday[date.getDay()]; | |
function onSuccess(position) { | |
alert('xoxo'); | |
console.log('Latitude: ' + position.coords.latitude + '\n' + | |
'Longitude: ' + position.coords.longitude + '\n' + | |
'Altitude: ' + position.coords.altitude + '\n' + | |
'Accuracy: ' + position.coords.accuracy + '\n' + | |
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + | |
'Heading: ' + position.coords.heading + '\n' + | |
'Speed: ' + position.coords.speed + '\n' + | |
'Timestamp: ' + position.timestamp + '\n'); | |
$lat = position.coords.latitude, | |
$lon = position.coords.longitude; | |
getUser(); | |
navigator.splashscreen.hide(); | |
}; | |
// onError Callback receives a PositionError object | |
function onError(error){ | |
alert('code: '+ error.code +'\n'+'message: '+ error.message +'\n'); | |
var $geolocation = error.message.indexOf('geolocation'), | |
$permissions = error.message.indexOf('permissions'); | |
if( $geolocation > -1 && $permissions > -1 ){ | |
alert('Necesitamos que nos permitas conocer tu ubicación. Porfavor, revisá los permisos de geolocación de la app.') | |
} | |
} | |
function onDeviceReady(){ | |
navigator.geolocation.getCurrentPosition(onSuccess, onError); | |
myApp.init(); | |
AndroidFullScreen.immersiveMode(); | |
}//OnDeviceReady() | |
document.addEventListener('DOMContentLoaded', function(){ | |
window.isphone = false; | |
if(document.URL.indexOf("http://") === -1 | |
&& document.URL.indexOf("https://") === -1) { | |
window.isphone = true; | |
} | |
if( window.isphone ) { | |
document.addEventListener("deviceready", onDeviceReady, false); | |
} else { | |
onDeviceReady(); | |
} | |
}); | |
/*------------------------------------*/ | |
/* INITIALIZE APP */ | |
/*------------------------------------*/ | |
var myApp = new Framework7({ | |
material: true, | |
template7Pages: true, | |
precompileTemplates: true, | |
init: false, | |
externalLinks: '.external' | |
}); | |
var $$ = Dom7; | |
// Add view | |
var mainView = myApp.addView('.view-main', { | |
dynamicNavbar: true | |
}); | |
var jsonURL = 'http://www.agroclima.com.py/mobile'; | |
// Close panel on page load | |
$$(document).on('pageInit', function(e){ | |
myApp.closePanel(); | |
}); | |
$$(document).on('ajaxStart', function(){ | |
myApp.showIndicator(); | |
}); | |
$$(document).on('ajaxComplete', function(){ | |
myApp.hideIndicator(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment