Liveblog basic functionality
This commit is contained in:
@@ -112,12 +112,18 @@ class NewsController extends Controller
|
||||
|
||||
public function liveblog(Request $request, $id)
|
||||
{
|
||||
|
||||
parent::registerView($request, 'blog', $id);
|
||||
|
||||
$blog = $this->API('nieuws/liveblog/' . (int) $id);
|
||||
foreach ($blog->artikelen as &$item) {
|
||||
$item = new \Model\NewsItem($item);
|
||||
}
|
||||
|
||||
if (request()->ajax()) {
|
||||
return $blog;
|
||||
}
|
||||
|
||||
if (count($blog->artikelen)) {
|
||||
return view('blog', ['blog' => $blog]);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
<div id="updates-box" class="box full-width" style="display: none;">
|
||||
<b>Er zijn updates van dit liveblog.</b>
|
||||
<a href="{{Request::getPathInfo()}}" class="btn" onclick="$(this).attr('disabled', 'disabled');"><span class="fa fa-undo"
|
||||
class="btn"></span><span>Laad de nieuwste berichten.</span></a>
|
||||
</div>
|
||||
|
||||
<h3 class="excerpt">
|
||||
@if($blog->is_actief)
|
||||
<span style="font-family: sans-serif; padding: 3px; color: white; background-color: #BD0013; border-radius: 5px;"
|
||||
@@ -55,4 +61,20 @@
|
||||
{{-- @yield('controls')
|
||||
<p class="center">(Pagina {{$pagina}})</p> --}}
|
||||
|
||||
<script>
|
||||
var laatste_update = Date.parse("{{ $blog->bijgewerkt }}");
|
||||
// alert(laatste_update);
|
||||
var auto_update = setInterval(function() {
|
||||
$.ajax({
|
||||
url: '{{ Request::getPathInfo() }}',
|
||||
success: function (data) {
|
||||
var nieuwe_update = Date.parse(data.bijgewerkt);
|
||||
if( nieuwe_update <= laatste_update) return;
|
||||
$('#updates-box').slideDown();
|
||||
laatste_update = nieuwe_update;
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
@@ -15,6 +15,11 @@ Home
|
||||
<span class="bi bi-blog"></span>
|
||||
<b>Liveblog: {{$liveblog->titel}}</b>
|
||||
</a>
|
||||
@foreach($liveblog->artikelen as $artikel)
|
||||
• {{ $artikel->titel }}
|
||||
@if($loop->index == 2) @break @endif
|
||||
@endforeach
|
||||
@break
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user