1// https://stackoverflow.com/questions/13261970/how-to-get-the-absolute-path-of-the-current-javascript-file-name/13262027#13262027 2// Untuk mendapatkan base_url, karena aplikasi bisa terinstall di subfolder 3var scripts = document.getElementsByTagName("script"); 4var last_script = scripts[scripts.length - 1]; 5var file_ini = last_script.src; 6// Harus mengetahui lokasi & nama file script ini 7var base_url = file_ini.replace("assets/js/script.js", ""); 8 9$(window).on("load", function () { 10 // Scroll ke menu aktif perlu dilakukan di onload sesudah semua loading halaman selesai 11 // Tidak bisa di document.ready 12 // preparing var for scroll via query selector 13 var activated_menu = $("li.treeview.active.menu-open")[0]; 14 // autscroll to activated menu/sub menu 15 if (activated_menu) { 16 activated_menu.scrollIntoView({ behavior: "smooth" }); 17 } 18}); 19 20$(document).ready(function () { 21 // Fungsi untuk tombol kembali ke atas 22 $(window).on("scroll", function () { 23 if ($(this).scrollTop() > 100) { 24 $(".scrollToTop").fadeIn(); 25 } else { 26 $(".scrollToTop").fadeOut(); 27 } 28 }); 29 30 $(".scrollToTop").on("click", function (e) { 31 $("html, body").animate({ scrollTop: 0 }, 500); 32 return false; 33 }); 34 35 $(function() { 36 $(document).on("keydown", ":input:not(textarea):not(:submit)", function(event) { 37 if (event.key === "Enter" && !$("#validasi").valid()) { 38 event.preventDefault(); 39 return false; 40 } 41 }); 42 }); 43 44 // Tombol reset form select2 45 $(".btn-reset").on("click", function () { 46 $(this) 47 .closest("form") 48 .find("select.select2[data-old]") 49 .each(function (index, el) { 50 $(el).val($(el).data("old")).trigger("change"); 51 }); 52 }); 53 54 // Fungsi untuk filter menu 55 $("#cari-menu").on("keyup keypress", function () { 56 let hideParentMenu = $(".sidebar-menu li.treeview"); 57 let search = $("#cari-menu").val(); 58 59 if (search !== "") { 60 hideParentMenu.removeClass("hidden"); 61 $(".sidebar-menu li").each(function (index, el) { 62 // abaikan header dan menu yg memiliki submenu 63 if ($(el).hasClass("header")) { 64 return; 65 } 66 67 if ( 68 el.innerText 69 .trim() 70 .toUpperCase() 71 .includes($("#cari-menu").val().toUpperCase()) 72 ) { 73 $(el).removeClass("hidden"); 74 } else { 75 $(el).addClass("hidden"); 76 } 77 if ($(el).parent().parent().hasClass("treeview")) { 78 hideParentMenu.each(function (indexParent, elParent) { 79 if (elParent === $(el).parent().parent()[0]) { 80 hideParentMenu.splice(indexParent, 1); 81 } 82 }); 83 $(el).parent().parent().addClass("menu-open"); 84 $(el).parent().show(); 85 } 86 }); 87 hideParentMenu.addClass("hidden"); 88 // untuk semua parent menu yg muncul 89 $(".sidebar-menu li.treeview:not(.hidden)").each(function (index, el) { 90 // jika jumlah semua parent menu yg muncul kurang dari 4, munculkan semua sub menu 91 if ($(".sidebar-menu li.treeview:not(.hidden)").length < 4) { 92 $(el).find("li").removeClass("hidden"); 93 } 94 // jika tidak memiliki sub menu yg dicari, tampilkan semua sub menu 95 else { 96 if ($(el).find("li:not(.hidden)").length == 0) { 97 $(el).find("li").removeClass("hidden"); 98 } 99 } 100 }); 101 } else { 102 $(".sidebar-menu li").each(function (index, el) { 103 $(el).removeClass("hidden"); 104 if ($(el).parent().parent().hasClass("treeview")) { 105 $(el).parent().parent().removeClass("menu-open"); 106 $(el).parent().hide(); 107 } 108 }); 109 } 110 }); 111 //CheckBox All Selected 112 checkAll(); 113 $("table").on("click", "input[name='id_cb[]']", function () { 114 enableHapusTerpilih(); 115 }); 116 enableHapusTerpilih(); 117 118 //Display dialog 119 mapBox(); 120 cetakBox(); 121 122 $("#modalBox").on("shown.bs.modal", function (e) { 123 var link = $(e.relatedTarget); 124 var title = link.data("title"); 125 var size = link.data("size") ?? ""; 126 var modal = $(this); 127 // tampilkan halaman loading 128
129 modal.find(".modal-title").text(title); 130 modal.find(".modal-dialog").addClass(size); 131 $(this).find(".fetched-data").load(link.attr("href")); 132 // tambahkan csrf token kalau ada form 133 if (modal.find("form")[0]) { 134 setTimeout(function () { 135 addCsrfField(modal.find("form")[0]); 136 }, 500); 137 } 138 }); 139 140 $("#modalBox").on("hidden.bs.modal ", function (e) { 141 var modal = $(this); 142 $(this).find(".fetched-data").html(``); 143 modal.find(".modal-title").text(""); 144 }); 145 146 //Confirm Delete Modal 147 $("#confirm-delete").on("show.bs.modal", function (e) { 148 var string = document.getElementById("confirm-delete").innerHTML; 149 var hasil = string.replace( 150 "fa fa-text-width text-yellow", 151 "fa fa-exclamation-triangle text-red" 152 ); 153 document.getElementById("confirm-delete").innerHTML = hasil; 154 155 var string2 = document.getElementById("confirm-delete").innerHTML; 156 var hasil2 = string2.replace("Konfirmasi", " Konfirmasi"); 157 document.getElementById("confirm-delete").innerHTML = hasil2; 158 $(this).find(".btn-ok").attr("href", $(e.relatedTarget).data("href")); 159 }); 160 161 $("#confirm-status").on("show.bs.modal", function (e) { 162 $(this).find(".btn-ok").attr("href", $(e.relatedTarget).data("href")); 163 $(this).find(".modal-body").html($(e.relatedTarget).data("body")); 164 }); 165 166 //File Upload 167 $("#file_browser").click(function (e) { 168 e.preventDefault(); 169 $("#file").click(); 170 }); 171 $("#file").change(function () { 172 $("#file_path").val($(this).val()); 173 if ($(this).val() == "") { 174 $("#" + $(this).data("submit")).attr("disabled", "disabled"); 175 } else { 176 $("#" + $(this).data("submit")).removeAttr("disabled"); 177 } 178 }); 179 $("#file_path").click(function () { 180 $("#file_browser").click(); 181 }); 182 183 $("#file_browser1").click(function (e) { 184 e.preventDefault(); 185 $("#file1").click(); 186 }); 187 $("#file1").change(function () { 188 $("#file_path1").val($(this).val()); 189 if ($(this).val() == "") { 190 $("#" + $(this).data("submit")).attr("disabled", "disabled"); 191 } else { 192 $("#" + $(this).data("submit")).removeAttr("disabled"); 193 } 194 }); 195 $("#file_path1").click(function () { 196 $("#file_browser1").click(); 197 }); 198 199 $("#file_browser2").click(function (e) { 200 e.preventDefault(); 201 $("#file2").click(); 202 }); 203 $("#file2").change(function () { 204 $("#file_path2").val($(this).val()); 205 }); 206 $("#file_path2").click(function () { 207 $("#file_browser2").click(); 208 }); 209 210 $("#file_browser3").click(function (e) { 211 e.preventDefault(); 212 $("#file3").click(); 213 }); 214 $("#file3").change(function () { 215 $("#file_path3").val($(this).val()); 216 }); 217 $("#file_path3").click(function () { 218 $("#file_browser3").click(); 219 }); 220 221 $("#file_browser4").click(function (e) { 222 e.preventDefault(); 223 $("#file4").click(); 224 }); 225 $("#file4").change(function () { 226 $("#file_path4").val($(this).val()); 227 }); 228 $("#file_path4").click(function () { 229 $("#file_browser4").click(); 230 }); 231 232 $("#file_browser5").click(function (e) { 233 e.preventDefault(); 234 $("#file5").click(); 235 }); 236 $("#file5").change(function () { 237 $("#file_path5").val($(this).val()); 238 }); 239 $("#file_path5").click(function () { 240 $("#file_browser5").click(); 241 }); 242 243 $("#hapus_file").click(function (e) { 244 var hapus_lampiran = document.getElementById("hapus_lampiran").value; 245 var icon = this.querySelector("i"); 246 var link_dokumen = document.getElementById("link_dokumen").value; 247 248 if (link_dokumen) { 249 if (hapus_lampiran !== "true") { 250 document.getElementById("hapus_lampiran").value = "true"; 251 document.getElementById("file_path4").disabled = true; 252 document.getElementById("file_browser4").disabled = true; 253 document.getElementById("link_dokumen").disabled = true; 254 icon.classList.remove("fa-stop"); 255 icon.classList.add("fa-check"); 256 } else { 257 document.getElementById("hapus_lampiran").value = "false"; 258 document.getElementById("file_path4").disabled = false; 259 document.getElementById("file_browser4").disabled = false;
260 document.getElementById("link_dokumen").disabled = false; 261 icon.classList.remove("fa-check"); 262 icon.classList.add("fa-stop"); 263 } 264 } 265 }); 266 267 $('[data-rel="popover"]').popover({ 268 html: true, 269 trigger: "hover", 270 }); 271 272 /* set otomatis hari */ 273 $(".datepicker.data_hari").change(function () { 274 var hari = { 275 0: "Minggu", 276 1: "Senin", 277 2: "Selasa", 278 3: "Rabu", 279 4: "Kamis", 280 5: "Jumat", 281 6: "Sabtu", 282 }; 283 var t = $(this).datepicker("getDate"); 284 var i = t.getDay(); 285 $(this).closest(".form-group").find(".hari").val(hari[i]); 286 }); 287 288 $('[checked="checked"]').parent().addClass("active"); 289 290 //color picker with addon 291 if ($(".my-colorpicker2").length > 0) $(".my-colorpicker2").colorpicker(); 292 //Text Editor with addon 293 if ($("#min-textarea").length > 0) $("#min-textarea").wysihtml5(); 294 295 $("ul.sidebar-menu").on("expanded.tree", function (e) { 296 // Manipulasi menu perlu ada tenggang waktu -- supaya dilakukan sesudah 297 // event lain selesai 298 e.stopImmediatePropagation(); 299 setTimeout(scrollTampil($("li.treeview.menu-open")[0]), 500); 300 }); 301 302 // ========== Tanda tangan laporan dan surat 303 $("select[name=pamong_ttd]").change(function (e) { 304 $("input[name=jabatan_ttd]").val($(this).find(":selected").data("jabatan")); 305 }); 306 $("select[name=pamong_ketahui]").change(function (e) { 307 $("input[name=jabatan_ketahui]").val( 308 $(this).find(":selected").data("jabatan") 309 ); 310 }); 311 $("select[name=pamong_ttd]").trigger("change"); 312 $("select[name=pamong_ketahui]").trigger("change"); 313 314 // Untuk input rupiah di form surat 315 // Tambahkan 'Rp.' pada saat form di ketik 316 // gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka 317 $(".rupiah").keyup(function (e) { 318 var nilai = formatRupiah($(this).val(), "Rp. "); 319 $(this).val(nilai); 320 }); 321 322 $(".pop-up-images").on("click", function () { 323 Swal.fire({ 324 title: $(this).data("title"), 325 imageUrl: $(this).data("url"), 326 imageAlt: $(this).data("title"), 327 customClass: { 328 popup: "swal-lg", 329 }, 330 }); 331 }); 332 333 $(".pop-up-pdf").on("click", function () { 334 var url = $(this).data("url"); 335 Swal.fire({ 336 customClass: { 337 popup: "swal-lg", 338 }, 339 title: $(this).data("title"), 340 html: `<object data="${url}" style="width: 100%;min-height: 400px;" type="application/pdf"></object>`, 341 }); 342 }); 343}); 344 345/* Fungsi formatRupiah untuk form surat */ 346function formatRupiah(angka, prefix, nol_sen = true) { 347 var number_string = angka.replace(/[^,\d]/g, "").toString(), 348 split = number_string.split(","), 349 sisa = split[0].length % 3, 350 rupiah = split[0].substr(0, sisa), 351 ribuan = split[0].substr(sisa).match(/\d{3}/gi); 352 353 // tambahkan titik jika yang di input sudah menjadi angka ribuan 354 if (ribuan) { 355 separator = sisa ? "." : ""; 356 rupiah += separator + ribuan.join("."); 357 } 358 359 rupiah = 360 split[1] != undefined ? rupiah + (nol_sen ? "" : "," + split[1]) : rupiah; 361 return prefix == undefined ? rupiah : rupiah ? "Rp. " + rupiah : ""; 362} 363 364function scrollTampil(elem) { 365 elem.scrollIntoView({ behavior: "smooth" }); 366} 367 368function checkAll(id = "#checkall") { 369 $("table").on("click", id, function () { 370 if ($(this).is(":checked")) { 371 $(".table input[type=checkbox]").each(function () { 372 $(this).prop("checked", true); 373 }); 374 } else { 375 $(".table input[type=checkbox]").each(function () { 376 $(this).prop("checked", false); 377 }); 378 } 379 $(".table input[type=checkbox]").change(); 380 enableHapusTerpilih(); 381 }); 382 $("[data-toggle=tooltip]").tooltip(); 383} 384 385function enableHapusTerpilih() { 386 // cek jika ada tombol hapus ter disable. 387 var disable = $("input[name='id_cb[]']:checked:not(:disabled)").filter( 388 function (index) { 389 return $(this).data("deletable") == 0; 390 } 391 ); 392 393 if ($("input[name='id_cb[]']:checked:not(:disabled)").length <= 0) { 394 // cek disable hapus 395 $(".aksi-terpilih").addClass("disabled"); 396 $(".hapus-terpilih").addClass("disabled"); 397 $(".hapus-terpilih").attr("href", "#"); 398 } else { 399 $(".aksi-terpilih").removeClass("disabled"); 400 $(".hapus-terpilih").removeClass("disabled"); 401 $(".hapus-terpilih").attr("href", "#confirm-delete"); 402 if (disable.length != 0) { 403 $(".hapus-terpilih").addClass("disabled"); 404 $(".hapus-terpilih").attr("href", "#"); 405 } 406 } 407} 408 409function deleteAllBox(idForm, action) { 410 $("#confirm-delete").modal("show"); 411 $("#ok-delete").click(function () { 412 $("#" + idForm).attr("action", action); 413 addCsrfField($("#" + idForm)[0]); 414 $("#" + idForm).submit(); 415 }); 416 return false;
417} 418 419function aksiBorongan(idForm, action) { 420 $("#confirm-status").modal("show"); 421 $("#ok-status").click(function () { 422 $("#" + idForm).attr("action", action); 423 addCsrfField($("#" + idForm)[0]); 424 $("#" + idForm).submit(); 425 }); 426 return false; 427} 428 429function cetakBox() { 430 $("#cetakBox").on("show.bs.modal", function (e) { 431 var link = $(e.relatedTarget); 432 var title = link.data("title"); 433 var aksi = link.data("aksi"); 434 var form_action = link.data("href"); 435 var modal = $(this); 436 modal.find(".title").text(title); 437 modal.find(".aksi").text(aksi); 438 modal.find("form").attr("action", form_action); 439 setTimeout(function () { 440 // tambahkan csrf token 441 addCsrfField(modal.find("form")[0]); 442 }, 500); 443 }); 444 return false; 445} 446 447function mapBox() { 448 $("#mapBox").on("show.bs.modal", function (e) { 449 var link = $(e.relatedTarget); 450 $(".modal-header #myModalLabel").html(link.attr("data-title")); 451 $(this).find(".fetched-data").load(link.attr("href")); 452 }); 453} 454function formAction(idForm, action, target = "") { 455 csrf_semua_form(); 456 if (target != "") { 457 $("#" + idForm).attr("target", target); 458 } 459 $("#" + idForm).attr("action", action); 460 $("#" + idForm).submit(); 461} 462 463//Delay Alert 464setTimeout(function () { 465 $("#notification").fadeIn("slow"); 466}, 500); 467setTimeout(function () { 468 $("#notification").fadeOut("slow"); 469}, 3000); 470 471function notification(type, message) { 472 if (type == "") { 473 return; 474 } 475 $("#maincontent").prepend( 476 "" + 477 '<div id="notification" class="alert alert-' + 478 type + 479 ' alert-dismissible">' + 480 '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + 481 message + 482 "" + 483 "</div>" + 484 "" 485 ); 486} 487 488function cek_koneksi() { 489 $("#maincontent").prepend( 490 '<div class = "callout callout-warning">' + 491 '<h4><i class="fa fa-warning"></i> Informasi</h4 >' + 492 "<p> Aplikasi tidak dapat terhubung dengan koneksi internet, beberapa modul mungkin tidak berjalan dengan baik. </a></p>" + 493 "</div>" 494 ); 495} 496 497function cari_nik() { 498 $("#cari_nik").change(function () { 499 $("#" + "main").submit(); 500 }); 501 502 $("#cari_nik_suami").change(function () { 503 $("#" + "main").submit(); 504 }); 505 506 $("#cari_nik_istri").change(function () { 507 $("#" + "main").submit(); 508 }); 509} 510 511// Ganti pilihan RW dan RT di form penduduk 512function select_options(select, params) { 513 var url_data = select.attr("data-source") + params; 514 select.find("option").not(".placeholder").remove().end(); 515 516 $.ajax({ 517 url: url_data, 518 }).then(function (options) { 519 JSON.parse(options).forEach((option) => { 520 var option_elem = $("<option>"); 521 522 option_elem 523 .val(option[select.attr("data-valueKey")]) 524 .text(option[select.attr("data-displayKey")]); 525 526 select.append(option_elem); 527 }); 528 }); 529} 530 531$(function () { 532 $("#op_item input:checked") 533 .parent() 534 .css({ background: "#c9cdff", border: "0.5px solid #7a82eb" }); 535 $("#op_item input").change(function () { 536 if ($(this).is("input:checked")) { 537 $("#op_item input").parent().css({ background: "#fafafa" }); 538 $("#op_item input:checked") 539 .parent() 540 .css({ background: "#c9cdff", border: "0.5px solid #7a82eb" }); 541 $(this).parent().css({ background: "#c9cdff" }); 542 } else { 543 $(this).parent().css({ background: "#fafafa", border: "0px" }); 544 } 545 }); 546 $("#op_item label").click(function () { 547 $(this).prev().trigger("click"); 548 }); 549}); 550 551function _calculateAge(birthday) { 552 // birthday is a date (dd-mm-yyyy) 553 if (birthday) { 554 var parts = birthday.split("-"); 555 // Ubah menjadi format ISO yyyy-mm-dd 556 // please put attention to the month (parts[0]), Javascript counts months from 0: 557 // January - 0, February - 1, etc 558 // https://stackoverflow.com/questions/5619202/converting-string-to-date-in-js 559 var birthdate = new Date(parts[2], parts[1] - 1, parts[0]); 560 var ageDifMs = new Date().getTime() - birthdate.getTime(); 561 var ageDate = new Date(ageDifMs); // miliseconds from epoch 562 return Math.abs(ageDate.getUTCFullYear() - 1970); 563 } 564} 565 566// https://stackoverflow.com/questions/332872/encode-url-in-javascript 567// Menyamakan dengan PHP urlencode supaya kurung '()' juga diencode 568// Digunakan untuk mengirim nama dusun sebagai parameter url query 569function urlencode(str) { 570 str = (str + "").toString(); 571 572 // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current 573 // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following. 574 return encodeURIComponent(str) 575 .replace(/!/g, "%21") 576 .replace(/'/g, "%27") 577 .replace(/\(/g, "%28") 578 .replace(/\)/g, "%29") 579 .replace(/\*/g, "%2A"); 580 // .replace(/%20/g, '+'); 581} 582 583// https://stackoverflow.com/questions/26018756/bootstrap-button-drop-down-inside-responsive-table-not-visible-because-of-scroll 584$("document").ready(function () { 585 $(".table-responsive").on("show.bs.dropdown", function (e) { 586 var table = $(this), 587 menu = $(e.target).find(".dropdown-menu"), 588 tableOffsetHeight = table.offset().top + table.height(), 589 menuOffsetHeight = 590 $(e.target).offset().top + 591 $(e.target).outerHeight(true) + 592 menu.outerHeight(true); 593 594 if (menuOffsetHeight > tableOffsetHeight) { 595 table.css("padding-bottom", menuOffsetHeight - tableOffsetHeight); 596 $(".table-responsive")[0].scrollIntoView(false); 597 } 598 }); 599 600 $(".table-responsive").on("hide.bs.dropdown", function () { 601 $(this).css("padding-bottom", 0); 602 }); 603}); 604 605// Notifikasi 606function tampil_badge(elem, url) { 607 elem.load(url); 608 setTimeout(function () { 609 if (elem.text().trim().length) elem.show(); 610 else elem.hide(); 611 }, 500); 612} 613 614function refresh_badge(elem, url) { 615 if (!elem.length) return; 616 617 tampil_badge(elem, url); 618 var refreshInbox = setInterval(function () { 619 tampil_badge(elem, url); 620 }, 10000); 621} 622 623function huruf_awal_besar(str) { 624 return str.replace( 625 /\S+/g, 626 (str) => str.charAt(0).toUpperCase() + str.substr(1).toLowerCase() 627 ); 628} 629 630// cek suport es6/es2015 631var supportsES6 = (function () { 632 try { 633 new Function("(a = 0) => a"); 634 return true; 635 } catch (err) { 636 return false;
637 } 638})(); 639 640function ditolak( 641 id, 642 ajax_url, 643 redirect, 644 title = "Alasan Ditolak", 645 text, 646 placeHolders 647) { 648 Swal.fire({ 649 title: title, 650 input: "textarea", 651 inputPlaceholder: placeHolders, 652 text: text, 653 inputValidator: (value) => { 654 if (!value) { 655 return "Kolom keterangan tidak boleh kosong"; 656 } 657 }, 658 customClass: { 659 popup: "swal-lg", 660 htmlContainer: "swal-left swal-bold", 661 }, 662 showCancelButton: true, 663 confirmButtonText: "Kirim", 664 cancelButtonText: "Tutup", 665 showLoaderOnConfirm: true, 666 preConfirm: (alasan) => { 667 const formData = new FormData(); 668 formData.append("sidcsrf", getCsrfToken()); 669 formData.append("id", id); 670 formData.append("alasan", alasan); 671 672 return fetch(ajax_url, { 673 method: "POST", 674 body: formData, 675 }) 676 .then((response) => { 677 if (!response.ok) { 678 throw new Error(response.statusText); 679 } 680 return response.json(); 681 }) 682 .catch((error) => { 683 console.log(error); 684 Swal.showValidationMessage(`Request failed: ${error}`); 685 }); 686 }, 687 }).then((result) => { 688 if (result.isConfirmed) { 689 if (result.value.status == true) { 690 swal2_success(redirect, "Berhasil dikembalikan"); 691 } else { 692 Swal.fire({ icon: "error", title: result.value.message }); 693 } 694 } 695 }); 696} 697 698function swal2_success(to, message = "Berhasil disimpan") { 699 Swal.fire({ 700 icon: "success", 701 title: message,
702 showConfirmButton: false, 703 timer: 1500, 704 }).then((result) => { 705 window.location.replace(to); 706 }); 707} 708 709function swal2_question(url_ajax, redirect, message, data, tolak = false) { 710 Swal.fire({ 711 title: message, 712 icon: "question", 713 showCancelButton: true, 714 confirmButtonColor: "#3085d6", 715 cancelButtonColor: "#d73925", 716 confirmButtonText: "Ya", 717 showDenyButton: tolak, 718 denyButtonColor: "#ffc107", 719 denyButtonText: `Tolak`, 720 cancelButtonText: `Tutup`, 721 }).then((result) => { 722 if (result.isConfirmed) { 723 Swal.fire({ 724 title: "Sedang Memproses", 725 allowOutsideClick: false, 726 allowEscapeKey: false, 727 showConfirmButton: false, 728 didOpen: () => { 729 Swal.showLoading(); 730 }, 731 }); 732 $.ajax({ 733 url: url_ajax.confirm, 734 type: "Post", 735 data: data, 736 }) 737 .done(function () { 738 window.location.replace(redirect.confirm); 739 }) 740 .fail(function (e) { 741 Swal.fire({ 742 icon: "error", 743 text: e.statusText, 744 }); 745 }); 746 } else if (result.isDenied) { 747 ditolak(data.id, url_ajax.denied, redirect.denied); 748 } 749 }); 750} 751 752function parseJwt(token) { 753 var base64Url = token.split(".")[1]; 754 var base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/"); 755 var jsonPayload = decodeURIComponent( 756 window 757 .atob(base64) 758 .split("") 759 .map(function (c) { 760 return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2); 761 }) 762 .join("") 763 ); 764 765 return JSON.parse(jsonPayload); 766}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.