Commit 30d09023 by Alfiro Pratama

fix preview video proposal (mhs)

parent 99efbd1b
@extends('layouts.master') @extends('layouts.master')
@section('css') @section('css')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"> {{-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"> --}}
@endsection @endsection
@section('title') @section('title')
...@@ -59,12 +59,6 @@ ...@@ -59,12 +59,6 @@
<div class="table-responsive"> <div class="table-responsive">
<table id="datatable" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;"> <table id="datatable" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
<thead style="text-align: center; vertical-align: middle;"> <thead style="text-align: center; vertical-align: middle;">
{{-- <style>
th {
text-align: center;
vertical-align: middle;
}
</style> --}}
<tr> <tr>
<th>No</th> <th>No</th>
<th width="5%">Kode Kelompok</th> <th width="5%">Kode Kelompok</th>
...@@ -72,7 +66,7 @@ ...@@ -72,7 +66,7 @@
<th>Identitas Dosen Pembimbing</th> <th>Identitas Dosen Pembimbing</th>
<th>Kategori PMW</th> <th>Kategori PMW</th>
<th>Judul Proposal</th> <th>Judul Proposal</th>
<th>Usulan Dana</th> <th>Usulan Anggaran</th>
<th>Status</th> <th>Status</th>
<th>Aksi</th> <th>Aksi</th>
</tr> </tr>
...@@ -179,6 +173,7 @@ ...@@ -179,6 +173,7 @@
@dd($item->rProposalUrl->url); @dd($item->rProposalUrl->url);
@endphp --}} @endphp --}}
<button id="preview-video" class="btn btn-success btn-sm" data-video="{{ $item->rProposalUrl->url }}"> <button id="preview-video" class="btn btn-success btn-sm" data-video="{{ $item->rProposalUrl->url }}">
{{-- <button id="preview-video" class="btn btn-success btn-sm" data-video="https://youtu.be/9CHu8iOsxDE?feature=shared"> --}}
<i class="far fa-eye"></i> Lihat Video <i class="far fa-eye"></i> Lihat Video
</button> </button>
@else @else
...@@ -256,10 +251,18 @@ ...@@ -256,10 +251,18 @@
$(document).ready(function() { $(document).ready(function() {
// Event handler untuk tombol "Lihat Video" dengan ID preview-video // Event handler untuk tombol "Lihat Video" dengan ID preview-video
$('#preview-video').on('click', function() { $('#preview-video').on('click', function() {
var videoUrl = $(this).data('video'); var videoUrl = $(this).attr('data-video');
// console.log(videoUrl);
if (videoUrl) { if (videoUrl) {
// Buka video dalam Magnific Popup // Buka video dalam Magnific Popup
if (videoUrl.includes('youtu.be')) {
// Konversi ke format youtube.com/watch?v=xxxxx
videoUrl = videoUrl.replace('youtu.be/', 'youtube.com/watch?v=');
}
// Buka video dalam Magnific Popup jika valid, buka di tab baru jika tidak
if (isValidYouTubeUrl(videoUrl)) {
$.magnificPopup.open({ $.magnificPopup.open({
items: { items: {
src: videoUrl src: videoUrl
...@@ -298,9 +301,16 @@ ...@@ -298,9 +301,16 @@
}); });
} else { } else {
// Tampilkan pesan kesalahan jika URL video tidak valid // Tampilkan pesan kesalahan jika URL video tidak valid
window.open(videoUrl, '_blank');
}
} else {
console.error('URL video tidak valid:', videoUrl); console.error('URL video tidak valid:', videoUrl);
} }
}); });
function isValidYouTubeUrl(url) {
// Lakukan validasi sederhana menggunakan ekspresi reguler
return /^(http(s)?:\/\/)?((w){3}.)?youtu(be|.be)?(\.com)?\/.+/gm.test(url);
}
}); });
</script> </script>
......
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