OverLord Shell
currPage = $(location).attr('href').split('?')[0].split('/');
currPage = currPage[currPage.length - 1];
currPageNm = currPage.substr(0, currPage.length - 4);
currPageAdd = currPage.substr(0, currPage.length - 7);
currPageEdit = currPage.substr(0, currPage.length - 8);
function valAdd() {
$.validate({
modules: 'file,security',
form: '#addform',
scrollToTopOnError: false,
onSuccess: function() {
$('#addform button[type=submit]').button('loading');
$('#addform button[type=reset]').attr('disabled', 'disabled');
$('.note-danger').html('').hide();
$.ajax({
type: 'POST',
url: currPageAdd + 'add_save.php',
data: new FormData($('#addform')[0]),
contentType: false,
processData: false,
success: function(data) {
if (data == 'success') {
$('#addform')[0].reset();
location = currPageAdd + '.php?msg=add_success';
} else if (data.substr(data.length - 4) == '.php') location = data;
else {
$('.note-danger').html(data).show();
$('#addform button[type=submit]').button('reset');
$('#addform button[type=reset]').removeAttr('disabled');
}
}
});
return false;
}
});
}
valAdd();
function valEdit() {
$.validate({
modules: 'file,security',
form: '#updateform',
scrollToTopOnError: false,
onSuccess: function() {
$('#updateform button[type=submit]').button('loading');
$('#updateform button[type=reset]').attr('disabled', 'disabled');
$('.note-danger').html('').hide();
$.ajax({
type: 'POST',
url: currPageEdit + 'edit_save.php',
data: new FormData($('#updateform')[0]),
contentType: false,
processData: false,
success: function(data) {
alert(data);
var res = data.split(".");
if ($.trim(data)=='success') {
$('#updateform')[0].reset();
location = currPageEdit + '.php?msg=add_success';
} else if ($.trim(res[0])== 'success') {
$('#updateform')[0].reset();
location = currPage + '?msg=add_success';
}
else if (data.substr(data.length - 4) == '.php') location = data;
else {
$('.note-danger').html(data).show();
$('#updateform button[type=submit]').button('reset');
$('#updateform button[type=reset]').removeAttr('disabled');
}
}
});
return false;
}
});
}
valEdit();
$('.delbtn').click(function() {
if (confirm("Are you sure, do you want to change status of this record?")) {
$this = $(this);
if (($this.html()).indexOf('Disable') != -1) btnval = 'n';
else btnval = 'y';
$.post(currPageNm + '_lock.php', {
action: btnval,
id: $this.val()
}, function(data) {
if (data.trim()== 'y'){ $this.html('Make Disable<i class="fa fa-close mlm"></i>').removeClass('btn-success').addClass('btn-danger');
}else if(data.trim() == 'n') {$this.html('Make Enable<i class="fa fa-check mlm"></i>').removeClass('btn-danger').addClass('btn-success');
}else if(data.substr(data.length - 4) == '.php') { location = data;
}else{ alert(data);}
});
} else return false;
});
$('.recyclebtn').click(function() {
if (confirm('Do you want to delete this record?')) {
$this = $(this);
if (($this.html()).indexOf('Disable') != -1) btnval = 'n';
else btnval = 'y'; $.post(currPageNm + '_recycle.php', {
// action: btnval,
id: $this.val()
}, function(data) {
if(data.trim() == "Success")
{
window.location = currPage + '?msg=delete_success';
}
});
} else return false;
});
$('.featured').click(function() {
if (confirm('Do you want to make this record default?')) {
$this = $(this);
if (($this.html()).indexOf('Disable') != -1) btnval = 'n';
else btnval = 'y';
$.post(currPageNm + '_default.php', {
id: $this.val()
}, function(data) {
//alert(data.trim());
if(data.trim() == "success"){
window.location = currPage + '?msg=default_success';
}
});
} else return false;
});
$('.approved').click(function() {
if (confirm("Are you sure, do you want to change status of this record?")) {
$this = $(this);
if (($this.html()).indexOf('Mark as') != -1) btnval = '1';
else btnval = '0';
$.post(currPageNm + '_approved.php', {
action: btnval,
id: $this.val()
}, function(data) {
alert(btnval);
if (data.trim() == '0') $this.html('Mark as Approved<i class="fa fa-thumbs-o-up mlm"></i>').removeClass('btn-info').addClass('btn-default');
else if (data.trim() == '1') $this.html('Approved<i class="fa fa-thumbs-up mlm"></i>').removeClass('btn-default').addClass('btn-info');
else if (data.substr(data.length - 4) == '.php') location = data.trim();
else alert(data);
});
} else return false;
});
$('.verified').click(function() {
if (confirm("Are you sure, do you want to change status of this record?")) {
$this = $(this);
if (($this.html()).indexOf('Mark as') != -1) btnval = '1';
else btnval = '0';
$.post(currPageNm + '_verified.php', {
action: btnval,
id: $this.val()
}, function(data) {
if (data.trim() == '0') $this.html('Mark as Verified<i class="fa fa-check-square-o mlm"></i>').removeClass('btn-success').addClass('btn-purple');
else if (data.trim() == '1') $this.html('Verified<i class="fa fa-check-square mlm"></i>').removeClass('btn-purple').addClass('btn-success');
else if (data.trim().substr(data.trim().length - 4) == '.php') location = data.trim();
else alert(data.trim());
});
} else return false;
});
xRyukZ - Copyright 2k19