File manager - Edit - /home/autoph/public_html/projects/Rating-AutoHub/public/css/template.tar
Back
edit.js 0000644 00000005612 15024756716 0006050 0 ustar 00 (function(e){ "use strict"; var questionArr = []; var url = ""; function submitTemplate(){ $('#template_save').on('click', function(e){ e.preventDefault(); questionArr = []; $(this).attr('disabled',true); $('input[type="checkbox"]:checked').each(function(){ questionArr.push(this.value); }); //push the question id's into an array var formData = new FormData(); formData.append('id',template.id); url = "/templates/update"; formData.append('title',$('#template_name').val()); formData.append('questionArr',questionArr); $.ajax({ type: "POST", url: url, dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ toastRWithTime("success","success"); location.replace('/templates'); }, error: function(error){ toastRWithTime(error.responseJSON.message,"error") } }); }); } $(function(){ var qs = template.q_id; $('#template_name').val(template.title); questions.forEach(function(item){ if(qs.includes(item.id.toString())){ $('.questions-list').append(`<div class="form-check"><input class="form-check-input mt-1" type="checkbox" id="`+item.title+`" value="`+item.id+`" checked="">\n<label class="form-check-label" for="`+item.title+`" style="font-size: 1rem">`+item.title+`</label></div>`); } else { $('.questions-list').append(`<div class="form-check"><input class="form-check-input mt-1" type="checkbox" id="`+item.title+`" value="`+item.id+`">\n<label class="form-check-label" for="`+item.title+`" style="font-size: 1rem">`+item.title+`</label></div>`); } }); $('input[type="checkbox"]').change(function(){ questionArr = []; }); $('#clear_selection').on('click', function(e){ e.preventDefault(); $('input[type="checkbox"]').each(function(){ this.checked = false; }); toastRWithTime("Selection Cleared","info"); }); $('#select_all').on('click', function(e){ e.preventDefault(); $('input[type="checkbox"]').each(function(){ this.checked = true; }); toastRWithTime("Selected all","info"); }); $('#template_cancel').on('click', function(e){ location.replace('/templates'); }); submitTemplate(); }); })(); create.js 0000644 00000004406 15024756716 0006366 0 ustar 00 (function(e){ "use strict"; var questionArr = []; var id = null; var url = null; function submitTemplate(){ $('#template_save').on('click', function(e){ e.preventDefault(); questionArr = []; // $(this).attr('disabled',true); $('input[type="checkbox"]:checked').each(function(){ questionArr.push(this.value); }); //push the question id's into an array var id = $('[name="edit_id"]').val(); var formData = new FormData(); url = "/templates/store"; if(id){ formData.append('id',id); url = "templates/update"; } formData.append('title',$('#template_name').val()); formData.append('questionArr',questionArr); $.ajax({ type: "POST", url: url, dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ toastRWithTime("success","success"); window.location.href = '/templates'; }, error: function(error){ toastRWithTime(error.responseJSON.message,"error"); } }); }); } $(function(){ submitTemplate(); $('input[type="checkbox"]').change(function(){ questionArr = []; }); $('#clear_selection').on('click', function(e){ e.preventDefault(); $('input[type="checkbox"]').each(function(){ this.checked = false; }); toastRWithTime("Selection Cleared","info"); }); $('#select_all').on('click', function(e){ e.preventDefault(); $('input[type="checkbox"]').each(function(){ this.checked = true; }); toastRWithTime("Selected all","info"); }); $('#template_back').on('click', function(e){ window.location.href = "/templates"; }); }); })(); template.js 0000644 00000021713 15024756716 0006736 0 ustar 00 (function(e){ "use strict"; var search_type_filter = []; var templateList = null; var id = null; var url = null; function delay(callback, ms) { var timer = 0; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { callback.apply(context, args); }, ms || 0); }; } function initActionUpdate(){ $("[data-action-update]").each(function () { $(this).on("click", function () { var row = $(this).closest("tr"); id = templateList.row(row).data().id; window.location.href = "/templates/" + id; // var formData = new FormData(); // formData.append("id",id); // $.ajax({ // type: "POST", // url: "/templates/get", // dataType: 'json', // data: formData, // processData: false, // contentType: false, // headers: { // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') // }, // success: function(result){ // console.log(result); // $('#templateName').val(result.title); // $('#templateModal').append(`<input type="hidden" name="edit_id" value="`+result.id+`">`); // $('#templateModalTitle').text("EDIT"); // $('#templateModal').modal('show'); // }, // error: function(error){ // } // }); }); }); } function initActionRemove(){ $("[data-action-remove]").each(function () { $(this).on("click", function () { var row = $(this).closest("tr"); id = templateList.row(row).data().id; swal.fire({ title: 'Are you sure you want to delete this item?', icon: 'warning', iconColor: 'red', showDenyButton: true, confirmButtonColor: '#3085d6', confirmButtonText: 'Confirm', denyButtonText: `Cancel`, }).then((result) => { var formData = new FormData(); formData.append("id",id); if(result.isConfirmed){ $.ajax({ type: "POST", url: "/templates/destroy", dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ toastRWithTime("success","success"); templateList.draw(false); }, error: function(error){ toastRWithTime(error.responseJSON.message,"error") } }); } else if (result.isDenied){ toastRWithTime('changes not saved','info'); return; } }); }); }); } function getDataTableData(){ var data = {}; return data; } function initList(){ $('.txt_search').on("keyup",delay(function(e){ templateList.search($('.txt_search').val()).draw() },500)); const search_type_default = "Template Name"; const search_types = ["Template Name"]; $.each(search_types, function (i, n) { $(".system-search-type").append( `<li class="dropdown-item cursor-pointer py-0"><span class="text-sm">` + n + `</span></li>` ); }); $(".system-search-type li").each(function () { if ($(this).text() == search_type_default) { $(this).removeClass("active").addClass("active"); var active_items_arr = []; active_items_arr.push(search_type_default); search_type_filter = JSON.stringify(active_items_arr); } $(this).on("click", function () { //remove all selected menu $(".system-search-type") .find("li.active") .map(function () { $(this).removeClass("active"); }); $(this).toggleClass("active"); var active_items = $(".system-search-type") .find("li.active") .map(function () { var item = {}; // item.id = this.value; item.status = $(this).text(); return item; }); var active_items_arr = []; $.each(active_items, function (i, n) { active_items_arr.push(n.status); }); search_type_filter = JSON.stringify(active_items_arr); // refreshOrcrPlateTable(); // if ($('#txt_search').val() != '') { templateList.draw(false); // } }); }); var cols = [ { title: "ID", data: 'id', className: 'align-middle p-1 dt-left', orderable: true, width: "5%", }, { title: "Template Name", data: 'title', className: 'align-middle p-1 dt-left', orderable: true, width: "40%", }, { title: "Action", data: null, orderable: false, width: "20%", className: "align-middle p-1 dt-center", render: function (data, type, row, meta) { return ` <div class="row justify-content-center"> <a data-action-update style="cursor:pointer; width: fit-content;" class="m-1 btn btn-sm btn-primary btn-icon" title="Edit"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit</a> <a data-action-remove style="cursor:pointer; width: fit-content;" class="m-1 btn btn-sm btn-danger btn-icon" title="Remove"><i class="fa fa-trash" aria-hidden="true"></i> Remove</a> </div> `; }, }, ]; templateList = $('#templateTable').DataTable({ fnDrawCallback: function () { initActionRemove(); initActionUpdate(); }, order: [[0, "desc"]], retrieve: true, columns: cols, paging: true, lengthChange: false, searching: true, pageLength: 5, info: true, autoWidth: true, responsive: true, processing: true, serverSide: true, autoWidth: true, columnDefs: [ { width: '20%', targets: 0 } ], fixedColumns: true, ajax: { url:'/templates/fetchall', data: function (d){ return $.extend({},d,{ search_type: search_type_filter, data: getDataTableData(), }) } }, sDom: "lrtip", }); } function submitTemplate(){ $('#template_save').on('click', function(e){ var id = $('[name="edit_id"]').val(); var formData = new FormData(); url = "/templates/store"; if(id){ formData.append('id',id); url = "templates/update"; } formData.append('title',$('#templateName').val()); $.ajax({ type: "POST", url: url, dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ $('#templateModal').modal('hide'); toastRWithTime("success","success"); templateList.draw(false); }, error: function(error){ } }); }); } $(function(){ initList(); submitTemplate(); $('#reload_list').on('click', function(e){ templateList.draw(false); }); $('#t_create').on('click', function(e){ e.preventDefault(); window.location.href = "/templates/create"; }); }); })();
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings