()
| 54 | } |
| 55 | |
| 56 | function initAddSite() { |
| 57 | let addSiteBtn = document.querySelector("#add-site"); |
| 58 | addSiteBtn.innerHTML = t({ |
| 59 | vi: '<i class="fa-solid fa-plus fa-lg"></i> Thêm trang web', |
| 60 | en: '<i class="fa-solid fa-plus fa-lg"></i> Add website', |
| 61 | }); |
| 62 | addSiteBtn.addEventListener("click", () => { |
| 63 | Swal.fire({ |
| 64 | title: t({ vi: "Khoá trang web", en: "Lock website" }), |
| 65 | inputLabel: t({ |
| 66 | vi: |
| 67 | "Nhập link/tên trang web muốn khoá\n" + |
| 68 | "Ví dụ:\n" + |
| 69 | " facebook\n" + |
| 70 | " *.facebook.com\n" + |
| 71 | " https://www.facebook.com", |
| 72 | en: |
| 73 | "Enter website url/name want to lock\n" + |
| 74 | "Example:\n" + |
| 75 | " facebook\n" + |
| 76 | " *.facebook.com\n" + |
| 77 | " https://www.facebook.com", |
| 78 | }), |
| 79 | input: "text", |
| 80 | inputAttributes: { |
| 81 | autocapitalize: "off", |
| 82 | autocorrect: "off", |
| 83 | }, |
| 84 | showCancelButton: true, |
| 85 | confirmButtonText: t({ vi: "Khoá", en: "Lock" }), |
| 86 | cancelButtonText: t({ vi: "Huỷ", en: "Cancel" }), |
| 87 | inputValidator: (value) => { |
| 88 | if (!value) { |
| 89 | return t({ |
| 90 | vi: "Vui lòng nhập trang web", |
| 91 | en: "Please enter website url", |
| 92 | }); |
| 93 | } |
| 94 | }, |
| 95 | }).then(({ isConfirmed, value }) => { |
| 96 | if (!isConfirmed) return; |
| 97 | |
| 98 | let hostname = value; |
| 99 | // try { |
| 100 | // let url = new URL(value); |
| 101 | // hostname = url.hostname; |
| 102 | // } catch (error) { |
| 103 | // console.log(error); |
| 104 | // } |
| 105 | locker.sites.add(hostname); |
| 106 | }); |
| 107 | }); |
| 108 | } |
| 109 | |
| 110 | function initChangePass() { |
| 111 | let changePassBtn = document.querySelector("#change-pass"); |
no test coverage detected