Compare commits
2 commits
f269b2cd8c
...
3e62eb8d37
Author | SHA1 | Date | |
---|---|---|---|
3e62eb8d37 | |||
1cf3c3004b |
3 changed files with 23 additions and 31 deletions
|
@ -60,13 +60,13 @@ details h2 {
|
||||||
.other-links li {
|
.other-links li {
|
||||||
background-color: #5adefc;
|
background-color: #5adefc;
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 1.5em;
|
margin-left: 1.5em;
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.other-links li:first-of-type {
|
.other-links li:first-of-type {
|
||||||
margin-right: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.other-links li:hover {
|
.other-links li:hover {
|
||||||
|
@ -113,6 +113,7 @@ details h2 {
|
||||||
grid-column-start: 1;
|
grid-column-start: 1;
|
||||||
grid-column-end: 3;
|
grid-column-end: 3;
|
||||||
border-top: 5px solid black;
|
border-top: 5px solid black;
|
||||||
|
padding: 0 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkin {
|
.checkin {
|
||||||
|
|
|
@ -65,8 +65,8 @@
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ol>
|
</ol>
|
||||||
@if ($trip->is_active)
|
@if (!$showAllCheckins)
|
||||||
<p><a id="allCheckinsLink" href="#">Show all checkins</a></p>
|
<p><a id="allCheckinsLink" href="?show=all">Show all checkins</a></p>
|
||||||
@endif
|
@endif
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
@ -141,11 +141,6 @@
|
||||||
).addTo(map).setZIndexOffset(1000);
|
).addTo(map).setZIndexOffset(1000);
|
||||||
currLocation.bindPopup('<p>Current location</p>').openPopup();
|
currLocation.bindPopup('<p>Current location</p>').openPopup();
|
||||||
|
|
||||||
/*
|
|
||||||
* Add all checkins link href.
|
|
||||||
*/
|
|
||||||
document.getElementById("allCheckinsLink").href = window.location.pathname + '/all';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Changes the currently-selected popup.
|
* Changes the currently-selected popup.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,38 +1,34 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use GuzzleHttp\Client;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Web Routes
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here is where you can register web routes for your application. These
|
|
||||||
| routes are loaded by the RouteServiceProvider within a group which
|
|
||||||
| contains the "web" middleware group. Now create something great!
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
Route::get('/past-trips', function () {
|
Route::get('/past-trips', function () {
|
||||||
return view('past-trips');
|
return view('past-trips');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false) {
|
Route::get('/{tripId?}', function (Request $request, $tripId = null) {
|
||||||
if (!$tripId && !config('app.current_trip_id')) return view('no-trip');
|
if (!$tripId && !config('app.current_trip_id')) return view('no-trip');
|
||||||
|
|
||||||
|
$viewMode = $request->input('show', null);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is a file in the local cache that is less than 5 hours old,
|
* If there is a file in the local cache that is less than 3 hours old,
|
||||||
* use that.
|
* use that.
|
||||||
*/
|
*/
|
||||||
$tripFileName = $tripId ?? config('app.current_trip_id') . '.json';
|
$tripFileName = ( $tripId ?? config('app.current_trip_id') ) . '.json';
|
||||||
if (Storage::disk('local')->exists($tripFileName)) {
|
if (Storage::disk('local')->exists($tripFileName)) {
|
||||||
$cachedData = json_decode(Storage::disk('local')->get($tripFileName));
|
$cachedData = json_decode(Storage::disk('local')->get($tripFileName));
|
||||||
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
|
if ($cachedData->trip->is_active) {
|
||||||
$now = new DateTime();
|
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
|
||||||
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) {
|
$now = new DateTime();
|
||||||
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($showAll === 'all')]);
|
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 3) {
|
||||||
|
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +57,8 @@ Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($showAll === 'all')]);
|
return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($viewMode === 'all')]);
|
||||||
} else {
|
} else {
|
||||||
return 'Something went wrong';
|
return 'Something went wrong';
|
||||||
}
|
}
|
||||||
});
|
})->where('tripId', '[0-9a-z]{20}');
|
||||||
|
|
Loading…
Reference in a new issue