Added option to get calendar data

- Changed ?data GET parameter to ?location
- Added ?calendar GET parameter
- Will fetch calendar data from internal.jnf.me
This commit is contained in:
Jason Williams 2018-08-19 15:13:11 -06:00
parent 2fee359ec0
commit 5d9c995762
1 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<?php
if (isset($_GET["data"])):
if (isset($_GET["location"])):
$options = array(
'http' => array(
'method' => 'GET',
@ -18,6 +18,18 @@
echo json_encode($output['device_tracker.jasonsphone_jason']);
exit();
elseif (isset($_GET["calendar"])):
$options = array(
'http' => array(
'header' => 'Host: internal.jnf.me'
)
);
$context = stream_context_create($options);
header('Content-Type: application/json');
echo file_get_contents("http://192.168.0.25/public/pages/display/calendar.php?location", false, $context);
else:
?>
@ -60,7 +72,7 @@
});
function updateLocation() {
$.getJSON('?data', function(data) {
$.getJSON('?location', function(data) {
$('h1').html((data.state == 'not_home') ? 'Nobody Knows' : 'At ' + data.state.replace(/^\w/, c => c.toUpperCase()));
var locLive = new google.maps.LatLng(data.attributes.latitude, data.attributes.longitude);
map.setCenter(locLive);