| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/laragon4/www/wa-gateway/public/js/ |
Upload File : |
$("#type").on("change", () => {
const type = $("#type").val();
$.ajax({
url: `/form-message/${type}`,
type: "GET",
dataType: "html",
success: (result) => {
$(".ajaxplace").html(result);
},
error: (error) => {
console.log(error);
},
});
});
function viewReply(id) {
$.ajax({
url: `/preview-message`,
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
type: "POST",
data: {
id: id,
table: "autoreplies",
column: "reply",
},
dataType: "html",
success: (result) => {
$(".showReply").html(result);
$("#modalView").modal("show");
},
error: (error) => {
console.log(error);
},
});
//
}
$(".toggle-status").on("click", function () {
let dataId = $(this).data("id");
let isChecked = $(this).is(":checked");
let url = $(this).data("url");
$.ajax({
url: url,
type: "POST",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
data: {
status: isChecked ? "Active" : "Inactive",
id: dataId,
},
success: function (result) {
if (!result.error) {
// find label
let label = $(`.toggle-status[data-id=${dataId}]`)
.parent()
.find("label");
// change label
if (isChecked) {
label.text("Active");
} else {
label.text("Inactive");
}
toastr["success"](result.msg);
}
},
});
});
$(".toggle-quoted").on("click", function () {
let dataId = $(this).data("id");
let isChecked = $(this).is(":checked");
let url = $(this).data("url");
$.ajax({
url: url,
type: "POST",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
data: {
quoted: isChecked ? "1" : "0",
id: dataId,
},
success: function (result) {
if (!result.error) {
// find label
let label = $(`.toggle-quoted[data-id=${dataId}]`)
.parent()
.find("label");
// change label
if (isChecked) {
label.text("Yes");
} else {
label.text("No");
}
toastr["success"](result.msg);
}
},
});
});
$(".toggle-read").on("click", function () {
let dataId = $(this).data("id");
let isChecked = $(this).is(":checked");
let url = $(this).data("url");
$.ajax({
url: url,
type: "POST",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
data: {
read: isChecked ? "1" : "0",
id: dataId,
},
success: function (result) {
if (!result.error) {
// find label
let label = $(`.toggle-read[data-id=${dataId}]`).parent().find("label");
// change label
if (isChecked) {
label.text("Yes");
} else {
label.text("No");
}
toastr["success"](result.msg);
}
},
});
});
$(".toggle-typing").on("click", function () {
let dataId = $(this).data("id");
let isChecked = $(this).is(":checked");
let url = $(this).data("url");
$.ajax({
url: url,
type: "POST",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
data: {
typing: isChecked ? "1" : "0",
id: dataId,
},
success: function (result) {
if (!result.error) {
// find label
let label = $(`.toggle-typing[data-id=${dataId}]`)
.parent()
.find("label");
// change label
if (isChecked) {
label.text("Yes");
} else {
label.text("No");
}
toastr["success"](result.msg);
}
},
});
});
$(".keyword-update").on("keyup", function () {
// debouncing
let timer;
clearTimeout(timer);
timer = setTimeout(() => {
let keyword = $(this).val();
let url = $(this).data("url");
$.ajax({
url: url,
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
type: "POST",
data: {
keyword: keyword,
},
success: (result) => {
toastr["success"](result.msg);
},
error: (error) => {
console.log(error);
},
});
}, 1000);
});
$(".delay-update").on("keyup", function () {
// debouncing
let timer;
clearTimeout(timer);
timer = setTimeout(() => {
let delay = $(this).val();
let url = $(this).data("url");
let dataId = $(this).data("id");
$.ajax({
url: url,
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
type: "POST",
data: {
delay: delay,
id: dataId,
},
success: (result) => {
toastr["success"](result.msg);
},
error: (error) => {
console.log(error);
},
});
}, 1000);
});