File manager - Edit - /home/autoph/public_html/projects/Rating-AutoHub/public/js/verify.js
Back
(function(e){ "use strict"; var starsArr = []; // var Arr = []; var options = { max_value: 5, step_size: 1, } // function createAnswerField(){ // $.each(questions.questions, function(key,value){ // $('.container-fluid', function(){ // $('.q-list2').append('<div class="rating-div col-md-8" id="rating'+value.qst_id+'"><label style="font-size:1.5rem;" id="'+value.qst_id+'">'+value.title+'</label></br><div class="rating-'+key+' starsRating" style="font-size: 4.5rem;"></div></div><hr class="dashed">'); $('.rating-'+key+'').rate(options); // $(this).on('change','.rating-'+key+'', function(e, data){ // // $("#output-"+qst_id).val(data.to); // var name = "Arr"+value.qst; // name = []; // starsArr.push(name = [ // value.qst_id, // data.to // ]); // }); // }); // }); // } function createAnswerField(){ $.each(questions.questions, function(key,value){ var count = key + 1; var formattedQ = value.title.replace(/\\n/g,"<br> "); $('.container-fluid', function(){ $('.q-list2').append('<div class="rating-div col-md-12" id="rating'+value.qst_id+'"><label class="q-label" style="font-size:20px; color:#000;" id="'+value.qst_id+'">'+count+". "+formattedQ+'</label></br><div class="rating-'+key+' starsRating" ></div></div><hr class="dashed">'); $('.rating-'+key+'').rate(options); $(this).on('change','.rating-'+key+'', function(e, data){ // Find the index of the current question in the array var index = starsArr.findIndex(function(element){ return element[0] == value.qst_id; }); // Update the existing array element or create a new one if(index == -1){ var name = "Arr"+value.qst; name = []; starsArr.push(name = [ value.qst_id, data.to ]); } else{ starsArr[index][1] = data.to; } }); }); // var count = key + 1; // var formattedQ = value.title.replace(/\\n/g, "<br>"); // var questionDiv = $('<div class="rating-div col-md-12"></div>'); // var questionLabel = $('<label style="font-size: 20px;"></label>').attr("id", value.qst_id).html(count + ". " + formattedQ); // var ratingDiv = $('<div class="rating-' + key + ' starsRating" style="font-size: 4.5rem;"></div>').rate(options); // questionDiv.append(questionLabel, '<br>', ratingDiv); // $('.q-list2').append(questionDiv, '<hr class="dashed">'); // ratingDiv.on('change', function(e, data) { // var index = starsArr.findIndex(function(element) { // return element[0] == value.qst_id; // }); // if (index == -1) { // starsArr.push([value.qst_id, data.to]); // } else { // starsArr[index][1] = data.to; // } // }); }); } function automaticLogout(){ $.ajax({ type: "POST", url: "/customLogout", dataType: 'json', data: null, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ window.location.href = "/thankyou"; }, error: function(error){ } }); } // function SubmitReview(){ // $('#submitReview').on('click', function(e){ // e.preventDefault(); // var formData = new FormData(); // formData.append('t_id',t_id); // formData.append('s_id',s_id); // formData.append('q_id',qst_id); // formData.append('stars',JSON.stringify(starsArr)); // formData.append('comment',$('#comment').val()); // if(starsArr.length < questions.questions.length){ // Swal.fire({ // title: 'Error!', // text: 'Please rate every question', // }); // return; // } else { // Swal.fire({ // title: 'Loading...', // allowOutsideClick: false, // didOpen: () => { // Swal.showLoading() // // $('#submitReview').attr('disabled',true); // } // }); // $.ajax({ // type: "POST", // url: "/response", // dataType: 'json', // data: formData, // processData: false, // contentType: false, // headers: { // 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') // }, // beforeSend: function() { // console.log("loading"); // if (!Swal.isLoading()) { // Swal.showLoading(); // } // }, // success: function(success){ // Swal.close(); // Swal.fire({ // title: 'Success!', // text: 'Thank you for your response', // }); // automaticLogout(); // setTimeout(() => { // window.location.href = "/thankyou"; // },3000); // }, // error: function(error){ // Swal.close(); // Swal.fire({ // title: 'Error', // text: error.message // }); // } // }); // } // }); // } // 2974 function SubmitReview() { $('#submitReview').on('click', function(e) { e.preventDefault(); var formData = new FormData(); formData.append('t_id', t_id); formData.append('s_id', s_id); formData.append('q_id', qst_id); formData.append('stars', JSON.stringify(starsArr)); formData.append('comment', $('#comment').val()); var unfilledQuestions = []; // Check if all questions have been answered for (var i = 0; i < questions.questions.length; i++) { if (!starsArr.some(a => a[0] === questions.questions[i].qst_id)) { unfilledQuestions.push(questions.questions[i].qst_id); } } if (unfilledQuestions.length > 0) { var unfilledQuestionIds = "#" + unfilledQuestions.join(", #"); var firstUnfilledQuestionId = "#" + unfilledQuestions[0]; var offset = $(unfilledQuestionIds).first().offset().top; $('html, body').animate({ scrollTop: offset - 50 }, 500, function() { $(firstUnfilledQuestionId).focus(); }); toastRWithTime("Please rate the following questions:<br><b>' + unfilledQuestions.join(", ") + '</b>'",'error'); return; } Swal.fire({ title: 'Loading...', allowOutsideClick: false, didOpen: () => { Swal.showLoading() // $('#submitReview').attr('disabled',true); } }); $.ajax({ type: "POST", url: "/response", dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, beforeSend: function() { console.log("loading"); if (!Swal.isLoading()) { Swal.showLoading(); } }, success: function(success) { Swal.close(); Swal.fire({ title: 'Success!', text: 'Thank you for your response', }); automaticLogout(); setTimeout(() => { window.location.href = "/thankyou"; }, 3000); }, error: function(error) { Swal.close(); Swal.fire({ title: 'Error', text: error.message }); } }); }); } $(function(){ createAnswerField(); SubmitReview(); // $('#proceed_rating').on('click', (e) => { // e.preventDefault(); // if($('#data-privacy').prop("checked")){ // $('.data-privacy').hide(); // $('.q-list').show(); // }else{ // toastRWithTime('Please agree to the terms and agreements first','error'); // } // }); }); })();
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings