From a17961a9249631d9f9faba92d5f4cc4b90ef28ab Mon Sep 17 00:00:00 2001 From: Abram Situmorang <abram.perdanaputra@gmail.com> Date: Fri, 8 Feb 2019 12:15:02 +0700 Subject: [PATCH] Added new alert style --- addMateri.php | 1 + addQuote.php | 2 +- admin/css/alert.css | 23 +++++++++++++++++++++++ admin/home.html | 4 ++-- admin/index.html | 4 ++++ admin/js/alert.js | 12 ++++++++++++ admin/kalender.html | 2 +- admin/kegiatan.html | 2 +- admin/materi.html | 2 +- admin/notifikasi.html | 2 +- admin/peng-tambah.html | 2 +- admin/quotes.html | 2 +- sendNotif.php | 2 +- 13 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 admin/css/alert.css create mode 100644 admin/js/alert.js diff --git a/addMateri.php b/addMateri.php index ce46a17..2c7d6b6 100755 --- a/addMateri.php +++ b/addMateri.php @@ -124,6 +124,7 @@ if ($judul == "") { if ($topik == "") { echo 'Field Topik tidak boleh kosong'; + exit(); } $stmt->bind_param("sssss", $topik, $judul, $konten_text, $videoAddr, $pdfAddr); diff --git a/addQuote.php b/addQuote.php index ad1691e..73e1875 100755 --- a/addQuote.php +++ b/addQuote.php @@ -39,7 +39,7 @@ if ($konten == "") { date_default_timezone_set(date_default_timezone_get()); $date = date('Y/m/d H:i:s', time()); $temp_tanggal = implode("", $res[0]); -print($temp_tanggal); +// print($temp_tanggal); $date = date_create($temp_tanggal); date_add($date, date_interval_create_from_date_string('7 days')); diff --git a/admin/css/alert.css b/admin/css/alert.css new file mode 100644 index 0000000..1ebb420 --- /dev/null +++ b/admin/css/alert.css @@ -0,0 +1,23 @@ +.auth-info-message-container { + position: fixed; + width: fit-content; + height: 36px; + padding: 0px 18px; + top: 7%; + left: 50%; + transform: translate(-50%, 0%); + display: flex; + justify-content: center; + align-items: center; + border-radius: 20px; + box-shadow: 0 0px 10px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + background-color: #54c0ff; + color: white; + opacity: 0; + -webkit-transition-duration: 0.25s; + transition-duration: 0.25s; + } + + .auth-info-message-container.visible { + opacity: 1; + } \ No newline at end of file diff --git a/admin/home.html b/admin/home.html index 5059e75..12b1939 100755 --- a/admin/home.html +++ b/admin/home.html @@ -101,7 +101,7 @@ if (confirm("Yakin ingin menghapus pengumuman " + judul.innerHTML + " ?")){ var id = this.id.split('-'); $.get("../deletePengumuman.php",{"id" : id[1]}, function(data) { - alert(data); + showAlert(data); location.reload(); }); } @@ -221,7 +221,7 @@ if (confirm("Yakin ingin menghapus materi " + judul.innerHTML + " ?")){ var id = this.id.split('-'); $.get("../deleteMateri.php",{"id" : id[1]}, function(data) { - alert(data); + showAlert(data); location.reload(); }); } diff --git a/admin/index.html b/admin/index.html index 17911a6..a11cb61 100755 --- a/admin/index.html +++ b/admin/index.html @@ -15,6 +15,7 @@ <!-- Custom styles for this template --> <link href="css/dashboard.css" rel="stylesheet"> + <link href="css/alert.css" rel="stylesheet"> </head> <body> @@ -70,6 +71,8 @@ </nav> <div class="col-2 col-sm-4 col-md-3 col-lg-2"></div> + <div id='alertMessage' class='auth-info-message-container'> + </div> <main role="main" class="col-10 col-sm-8 col-md-9 col-lg-10 pt-4 pr-4"> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom"> <h1 class="h2">Selamat datang, Admin</h1> @@ -103,6 +106,7 @@ }); </script> <script src="js/main.js"></script> + <script src="js/alert.js"></script> <!-- Icons --> diff --git a/admin/js/alert.js b/admin/js/alert.js new file mode 100644 index 0000000..82972b8 --- /dev/null +++ b/admin/js/alert.js @@ -0,0 +1,12 @@ +function showAlert(data) { + setTimeout(() => { + const alertMessage = $('#alertMessage')[0]; + alertMessage.innerHTML = data + alertMessage.classList.add('visible'); + }, 250); + + setTimeout(() => { + const alertMessage = $('#alertMessage')[0]; + alertMessage.classList.remove('visible'); + }, 5000); + } \ No newline at end of file diff --git a/admin/kalender.html b/admin/kalender.html index 7bb5581..0915fd8 100755 --- a/admin/kalender.html +++ b/admin/kalender.html @@ -22,7 +22,7 @@ $('#upload_form').on('submit', function(e){ e.preventDefault(); $.post("../addKalender.php", $("#upload_form").serialize() ).done(function (data) { - alert(data); + showAlert(data); $("#upload_form")[0].reset(); }); }); diff --git a/admin/kegiatan.html b/admin/kegiatan.html index bcbd976..a9a0413 100755 --- a/admin/kegiatan.html +++ b/admin/kegiatan.html @@ -61,7 +61,7 @@ e.preventDefault(); att = $("upload_form").attr("action") ; $.post("../addKegiatan.php", $("#upload_form").serialize() ).done(function (data) { - alert(data); + showAlert(data); }); }); </script> diff --git a/admin/materi.html b/admin/materi.html index db55b2c..f7efeb3 100755 --- a/admin/materi.html +++ b/admin/materi.html @@ -116,7 +116,7 @@ complete: function(xhr) { $('#progbar').addClass('d-none'); $('#upload_form').removeClass('d-none'); - alert(xhr.responseText); + showAlert(xhr.responseText); } }); // $("#upload_form").on("submit", function(e){ diff --git a/admin/notifikasi.html b/admin/notifikasi.html index 26ddf02..8128a53 100755 --- a/admin/notifikasi.html +++ b/admin/notifikasi.html @@ -82,7 +82,7 @@ processData:false, // To send DOMDocument or non processed data file it is set to false success: function(data) // A function to be called if request succeeds { - alert(data); + showAlert(data); } }); }); diff --git a/admin/peng-tambah.html b/admin/peng-tambah.html index e1458d5..71c49bf 100755 --- a/admin/peng-tambah.html +++ b/admin/peng-tambah.html @@ -58,7 +58,7 @@ success: function(data) // A function to be called if request succeeds { // lakukan pemanggilan api notifikasi - alert(data); + showAlert(data); } }); }); diff --git a/admin/quotes.html b/admin/quotes.html index 7d39252..04d5759 100755 --- a/admin/quotes.html +++ b/admin/quotes.html @@ -23,7 +23,7 @@ $('#upload_form').on('submit', function(e){ e.preventDefault(); $.post("../addQuote.php", $("#upload_form").serialize() ).done(function (data) { - alert(data); + showAlert(data); $("#upload_form")[0].reset(); }); }); diff --git a/sendNotif.php b/sendNotif.php index 7c520d9..be0121a 100755 --- a/sendNotif.php +++ b/sendNotif.php @@ -43,7 +43,7 @@ class FirebaseNotif "id" => $id ] ]; - echo json_encode($vars, JSON_UNESCAPED_SLASHES); + // echo json_encode($vars, JSON_UNESCAPED_SLASHES); // $cat = $_POST["kategori"]; // if ($cat == "pengumuman" ) { -- GitLab