- UI Vuexy biru UNTAN; 5 peran + pengalih peran; dasbor kaprodi (KPI), dosen (task-first), wali, mahasiswa - Raport CPL per mahasiswa/angkatan dengan rumus resmi Dokumen Kurikulum 2026 (skor maks CPMK), radar perjalanan CPL - CQI tiga loop + Laporan Pengukuran CPL (.docx) - Data Master: periode buka/tutup/kunci, dosen, mahasiswa, kelas & pengajar (papan seret), KRS, dosen wali, impor pratinjau - Kurikulum berversi dari PDF resmi (tools/extract_dokumen.py), halaman Kurikulum, revisi draf→berlaku, pemeriksa keselarasan, ekspor tabel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
3.3 KiB
JavaScript
79 lines
3.3 KiB
JavaScript
/* Pencarian cepat (Ctrl/⌘ + K): MK, mahasiswa, CPL, dan halaman — sesuai hak akses.
|
|
Data dari GET /cari?q= ; navigasi keyboard ↑ ↓ Enter, Esc menutup. */
|
|
(function () {
|
|
"use strict";
|
|
var modalEl = document.getElementById("modal-cari");
|
|
if (!modalEl) return;
|
|
var input = document.getElementById("cari-input");
|
|
var daftar = document.getElementById("cari-hasil");
|
|
var hasil = [], pilih = 0, timer = null, nomor = 0;
|
|
|
|
var IKON = { "Halaman": "layout-grid", "Mata Kuliah": "books", "Mahasiswa": "school", "CPL": "target" };
|
|
|
|
function esc(t) {
|
|
var d = document.createElement("div");
|
|
d.textContent = t || "";
|
|
return d.innerHTML;
|
|
}
|
|
|
|
function gambar() {
|
|
if (!hasil.length) {
|
|
daftar.innerHTML = '<div class="text-center text-body-secondary py-5">Tidak ada yang cocok.</div>';
|
|
return;
|
|
}
|
|
daftar.innerHTML = hasil.map(function (h, i) {
|
|
return '<a href="' + esc(h.href) + '" role="option" id="cari-' + i + '" aria-selected="' + (i === pilih) + '"' +
|
|
' class="list-group-item list-group-item-action d-flex align-items-center gap-3 py-3' + (i === pilih ? " active" : "") + '">' +
|
|
'<i class="icon-base ti tabler-' + (IKON[h.jenis] || "arrow-right") + ' icon-md flex-shrink-0"></i>' +
|
|
'<span class="flex-grow-1 text-truncate"><span class="fw-medium">' + esc(h.label) + "</span>" +
|
|
(h.sub ? '<small class="d-block text-truncate opacity-75">' + esc(h.sub) + "</small>" : "") + "</span>" +
|
|
'<span class="badge bg-label-secondary">' + esc(h.jenis) + "</span></a>";
|
|
}).join("");
|
|
var aktif = document.getElementById("cari-" + pilih);
|
|
if (aktif) aktif.scrollIntoView({ block: "nearest" });
|
|
}
|
|
|
|
function muat() {
|
|
var ke = ++nomor;
|
|
fetch("/cari?q=" + encodeURIComponent(input.value), { headers: { Accept: "application/json" } })
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (d) {
|
|
if (ke !== nomor) return; // abaikan respons lama
|
|
hasil = d.hasil || [];
|
|
pilih = 0;
|
|
gambar();
|
|
})
|
|
.catch(function () {});
|
|
}
|
|
|
|
input.addEventListener("input", function () {
|
|
clearTimeout(timer);
|
|
timer = setTimeout(muat, 150);
|
|
});
|
|
input.addEventListener("keydown", function (e) {
|
|
if (e.key === "ArrowDown") { pilih = Math.min(pilih + 1, hasil.length - 1); gambar(); e.preventDefault(); }
|
|
else if (e.key === "ArrowUp") { pilih = Math.max(pilih - 1, 0); gambar(); e.preventDefault(); }
|
|
else if (e.key === "Enter" && hasil[pilih]) { location.href = hasil[pilih].href; e.preventDefault(); }
|
|
});
|
|
// kosongkan & fokus SEKETIKA saat modal mulai dibuka (bukan setelah animasi),
|
|
// agar huruf yang langsung diketik setelah Ctrl+K tidak jatuh ke isian form di belakang
|
|
modalEl.addEventListener("show.bs.modal", function () {
|
|
input.value = "";
|
|
hasil = []; pilih = 0;
|
|
daftar.innerHTML = "";
|
|
input.focus();
|
|
muat();
|
|
});
|
|
modalEl.addEventListener("shown.bs.modal", function () {
|
|
if (document.activeElement !== input) input.focus();
|
|
});
|
|
document.addEventListener("keydown", function (e) {
|
|
if ((e.ctrlKey || e.metaKey) && (e.key === "k" || e.key === "K")) {
|
|
e.preventDefault();
|
|
if (document.activeElement && document.activeElement !== input) document.activeElement.blur();
|
|
bootstrap.Modal.getOrCreateInstance(modalEl).show();
|
|
input.focus();
|
|
}
|
|
});
|
|
})();
|