File: /var/www/vhost/disk-apps/agile-selling-orl/public/js/radio.js
function createRadio() {
$('#createRadio').validator('update');
$("#createRadio").validator('update').on('submit', function (e) {
if (e.isDefaultPrevented()) {} else {
e.preventDefault();
$("#btn-create-radio").addClass('displayNone');
$("#spinnerButton").removeClass('displayNone');
var info = {
"title": $(" #createRadio input[name='name']").val(),
"link": $(" #createRadio input[name='link']").val(),
};
swal(Lang.get("messagesClient.radio_tag3"), {
buttons: {
cancel: "No",
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
$.ajax({
url: "/radio_embed/create",
type: "POST",
contentType: 'application/json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
'Content-Type': 'application/json'
},
data: JSON.stringify(info),
success: function (r) {
if (r.r) {
$(location).attr('href', '/radio_embed');
} else {
swal(r.m, "error");
$("#btn-create-radio").removeClass('displayNone');
$("#spinnerButton").addClass('displayNone');
}
},
error: function (e) {
swal(Lang.get("messagesClient.radio_tag4"), "error");
$("#btn-create-radio").removeClass('displayNone');
$("#spinnerButton").addClass('displayNone');
}
});
} else {
$("#btn-create-radio").removeClass('displayNone');
$("#spinnerButton").addClass('displayNone');
}
});
}
});
}
function clickEditRadio(value) {
_table = $("#example2").DataTable();
index = _table.page();
localStorage.setItem("RadioTableIndex", index);
$(location).attr('href', '/radio_embed/edit/' + value);
}
function editRadio() {
$('#editRadio').validator('update');
$("#editRadio").validator('update').on('submit', function (e) {
if (e.isDefaultPrevented()) {} else {
e.preventDefault();
$("#btn-edit-radio").addClass('displayNone');
$("#spinnerButton").removeClass('displayNone');
var info = {
"id": $("#btn-edit-radio").attr("data-id"),
"title": $(" #editRadio input[name='name']").val(),
"link": $(" #editRadio input[name='link']").val(),
};
swal(Lang.get("messagesClient.radio_tag5"), {
buttons: {
cancel: "No",
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
$.ajax({
url: "/radio_embed/update",
type: "PUT",
contentType: 'application/json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
'Content-Type': 'application/json'
},
data: JSON.stringify(info),
success: function (r) {
if (r.r) {
$(location).attr('href', '/radio_embed');
} else {
swal(r.m, "error");
$("#btn-edit-radio").removeClass('displayNone');
$("#spinnerButton").addClass('displayNone');
}
},
error: function (e) {
swal(Lang.get("messagesClient.radio_tag6"), "error");
$("#btn-edit-radio").removeClass('displayNone');
$("#spinnerButton").addClass('displayNone');
}
});
} else {
$("#btn-edit-radio").removeClass('displayNone');
$("#spinnerButton").addClass('displayNone');
}
});
}
});
}
function setPageTable() {
localStorage.setItem("setPageTable", true);
$(location).attr('href', '/banners');
}
/**Activar/Desactivar Banner usando switch*/
function chkRadio(value) {
var state;
if ($('#Checkactive' + value).is(':checked')) {
state = 1;
} else {
state = 0;
}
var info = {
"id": value,
"state": state
};
$.ajax({
url: "/radio_embed/active",
type: "POST",
contentType: 'application/json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
'Content-Type': 'application/json'
},
data: JSON.stringify(info),
success: function (r) {
if (r.r) {
swal("Ok", r.m);
} else {
swal("Error", r.m, "error");
}
},
error: function (e) {
swal("Error", Lang.get("messagesClient.radio_tag7"), "error");
}
});
}