1(function ($) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 32 $(document).ready(function () { 33 34 35 var mouseX = 0; 36 var mouseY = 0; 37 var current_user_id = tlms_ajax_url.sessionValue; 38 document.addEventListener("mousemove", function(e) { 39 mouseX = e.clientX; 40 mouseY = e.clientY; 41 // document.getElementById("coordinates").innerHTML = "<br />X: " + e.clientX + "px<br />Y: " + e.clientY + "px"; 42 }); 43 44 var ajaxRequestSent = false; 45 var tracking_option = tlms_ajax_url.user_tr_option; 46 if(tracking_option=='on'){ 47 jQuery(document).mousemove(function (event) { 48 49 var mouseY = event.pageY; 50 var mouseX = event.pageX; 51 var roles = tlms_ajax_url.user_role; 52 var hasSubscriber = roles.includes('subscriber'); 53 var hasCustomer = roles.includes('customer'); 54 var value = tlms_ajax_url.sessionValue; 55 56 if (!ajaxRequestSent && value !== 'true' && mouseY < 130 && mouseX > $(window).width() - 200 && (hasSubscriber || hasCustomer)) { 57 ajaxRequestSent = true; 58 $.post(tlms_ajax_url.ajax_url, { action: 'update_session', value: true }, function(response) { 59 if (response.success) { 60 console.log(response.success); 61 if (value !== 'true'){ 62 value = true; 63 } 64 } else { 65 alert('Error: ' + response.data); 66 } 67 }); 68 } 69 }); 70 } 71 72 $(".chosen-select").chosen({ 73 no_results_text: "Oops, nothing found!" 74 }) 75 $(".search-choice-close").text("X"); 76 $('#tlms-mark-attendance-user').submit(function (e) { 77 e.preventDefault(); 78 var attendance_button = $('#tlms-mark-attendance-user button'); 79 80 attendance_button.attr('disabled', true); 81 82 const formData = new FormData(this); 83 $.ajax({ 84 url: tlms_ajax_url.ajax_url, 85 type: 'POST', 86 data: formData, 87 contentType: false, // prevent jQuery from using an incorrect Content-type header 88 processData: false, 89 success: function (response) { 90 if (response['status'] == 'error') { 91 alert(response['message']); 92 attendance_button.attr('disabled', false); 93 94 } else { 95 attendance_button.hide(); 96 console.log(response); 97 } 98 } 99 }) 100 }) 101 102 $('#tlmsat-mark-attendance-form').submit(function (e) { 103 e.preventDefault(); 104 $('#tlms_at_failed').hide(); 105 $('#tlms_at_success').hide(); 106 107 const formData = new FormData(this); 108 $.ajax({ 109 url: tlms_ajax_url.ajax_url, 110 type: 'POST', 111 data: formData, 112 contentType: false, // prevent jQuery from using an incorrect Content-type header 113 processData: false, 114 success: function (response) { 115 $('#tlmsat-mark-attendance-form').trigger("reset"); 116 $('#tlmsat_mark_attendance_users').val('').trigger('chosen:updated'); 117 $('.chosen-choices') 118 if (response['status'] == 'error') { 119 $('#tlms_at_failed').text(response['message']); 120 $('#tlms-at_front_msg-box').show(); 121 $('#tlms_at_failed').show(); 122 } 123 if (response['status'] == 'success') { 124 $('#tlms-at_front_msg-box').show(); 125 $('#tlms_at_success').show(); 126 } 127 } 128 }) 129 }) 130 131 $(document).on("input", ".tlms_attendance_input", function () { 132 let value = $(this).val(); 133 if (value === "" || value < 0) { 134 $(this).val(0); 135 } 136 }); 137 138 if (window.location.href.indexOf('/dashboard/my-courses/') > -1) { 139 $('body').addClass('tutor-course-page'); 140 } 141 if ($('body').hasClass('tutor-course-page')) { 142 $('.tutor-dropdown').each(function() { 143 144 var parentId = $(this).closest('[id^="table-dashboard-course-list-"]').attr('id'); 145 146 147 var courseId = parentId.replace('table-dashboard-course-list-', ''); 148 149 150 var newItem = $('<a>', { 151 class: 'tutor-dropdown-item tutor-minimum-attendance', 152 href: 'javascript:void(0)', 153 'data-course-id': courseId, 154 html: '<i class="tutor-icon-gear tutor-mr-8" aria-hidden="true"></i><span>Minimum Attendance</span>' 155 }); 156 157 158 $(this).append(newItem); 159 }); 160 } 161 162 163 $(".tutor-minimum-attendance").on("click", function (e) { 164 e.preventDefault(); 165
166 var courseId = $(this).data("course-id"); 167 168 169 $.ajax({ 170 url: tlms_ajax_url.ajax_url, 171 type: 'POST', 172 data: { 173 action: 'get_minimum_attendance', 174 course_id: courseId, 175 }, 176 success: function(response) { 177 if (response.success) { 178 var currentValue = response.data.minimum_attendance || ''; 179 180 181 Swal.fire({ 182 title: 'Minimum Attendance', 183 html: `<input type="number" id="minimum-attendance-input" class="swal2-input tlms_attendance_input" placeholder="Enter minimum attendance" value="${currentValue}">`, 184 showCancelButton: true, 185 showCloseButton:true, 186 confirmButtonText: 'Save', 187 cancelButtonText: 'Cancel', 188 customClass: { 189 title: 'tlms_attendance_title', 190 confirmButton: 'tlms_attendance_button', 191 }, 192 preConfirm: () => { 193 var value = $('#minimum-attendance-input').val(); 194 if (value < 0) { 195 Swal.showValidationMessage('Please enter a correct value'); 196 return false; 197 } 198 return value; 199 }, 200 }).then((result) => { 201 if (result.isConfirmed) { 202 var newValue = result.value; 203 204 $.ajax({ 205 url: tlms_ajax_url.ajax_url, 206 type: 'POST', 207 data: { 208 action: 'save_minimum_attendance', 209 course_id: courseId, 210 minimum_attendance: newValue, 211 }, 212 success: function(response) { 213 if (response.success) { 214 215 tutor_toast("Success", response.data.message, "success"); 216 } else { 217 218 tutor_toast("error", response.data.message, "error"); 219 } 220 }, 221 error: function() { 222 Swal.fire({ 223 icon: 'error', 224 title: 'Error', 225 text: 'An error occurred while saving.', 226 }); 227 }, 228 }); 229 230 } 231 }); 232 } else { 233 Swal.fire({ 234 icon: 'error', 235 title: 'Error', 236 text: 'Failed to fetch current value.', 237 }); 238 } 239 }, 240 error: function() { 241 Swal.fire({ 242 icon: 'error', 243 title: 'Error', 244 text: 'An error occurred while fetching data.', 245 }); 246 }, 247 }); 248 249 }); 250 251 }) 252 253 254})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.