Content Security Policy (CSP) compatibility beta.
This commit is contained in:
40
pub/src/js/sentri/response.js
Normal file
40
pub/src/js/sentri/response.js
Normal file
@@ -0,0 +1,40 @@
|
||||
document.addEventListener("DOMContentLoaded", async function () {
|
||||
try {
|
||||
const response = await fetch("/api/v1/frontend/response/");
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!Object.keys(data).length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const title = Object.keys(data)[0];
|
||||
const messageKey = data[title];
|
||||
|
||||
$.notify({
|
||||
icon: "fa fa-bell",
|
||||
title: title.charAt(0).toUpperCase() + title.slice(1),
|
||||
message: __(messageKey)
|
||||
}, {
|
||||
type: title === "error" ? "danger" : title,
|
||||
placement: {
|
||||
from: "top",
|
||||
align: "right"
|
||||
},
|
||||
delay: 3000
|
||||
});
|
||||
|
||||
if ($.fn.select2) {
|
||||
$("#multiple").select2({
|
||||
theme: "bootstrap"
|
||||
});
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error("Failed to retrieve response message:", err);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user