1(function ($) { 2 'use strict'; 3 $(document).ready(function () { 4 var html_class_prefix = 'ays-quiz-user-dashboard-'; 5 var $html_id_prefix = '#ays-user-dashboard-'; 6 var html_name_prefix = 'ays-quiz-'; 7 var name_prefix = 'ays_quiz_'; 8 var unique_id; 9 var unique_id_in_class; 10 11 // for details 12 $.fn.aysModal = function(action){ 13 var $this = $(this); 14 switch(action){ 15 case 'hide': 16 $(this).find('.ays-modal-content').css('animation-name', 'zoomOut'); 17 setTimeout(function(){ 18 $(document).find('html, body').removeClass('modal-open'); 19 $(document).find('.ays-modal-backdrop').remove(); 20 $this.hide(); 21 }, 250); 22 break; 23 case 'show': 24 default: 25 $this.show(); 26 $(this).find('.ays-modal-content').css('animation-name', 'zoomIn'); 27 $(document).find('.modal-backdrop').remove(); 28 $(document.body).append('<div class="ays-modal-backdrop"></div>'); 29 $(document).find('html, body').addClass('modal-open'); 30 break; 31 } 32 } 33 34 $(document).on("keydown", function(e){ 35 if(e.keyCode === 27){ 36 $(document).find('.ays-modal').aysModal('hide'); 37 return false; 38 } 39 }); 40 41 $(document).find('div.ays-modal').appendTo($(document.body)); 42 43 // Modal close 44 $(document).on('click', '.ays-close', function () { 45 var _this = $(this); 46 _this.parents('.ays-modal').aysModal('hide'); 47 }); 48 49 /* 50 ========================================== 51 User History 52 ========================================== 53 */ 54 55 // User History by Quiz 56 $(document).on('change', '.'+html_class_prefix+'quizzes', function(){ 57 var $_this = $(this); 58 var userID = $(this).attr('data-user'); 59 var quizID = $(this).find(':selected').attr('data-id'); 60 var uniqueID = $(this).parent().find('input[type="hidden"]').attr('data-unique'); 61 var uniqueIdInClass = $(this).parent().find('input[type="hidden"]').attr('data-class'); 62 var parent = $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('.'+html_class_prefix+'result-by-quiz') 63 var quizResultsDiv = $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('.'+html_class_prefix+'result-by-quiz').find('div.'+html_class_prefix+'results-by-quiz-tables'); 64 65 var userData = {}; 66 67 $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('div.ays-quiz-user-dashboard-preloader').css('display', 'flex'); 68 69 userData.action = 'get_results_by_quiz'; 70 userData.user_id = userID; 71 userData.quiz_id = quizID; 72 userData.unique_id = uniqueID; 73 74 $.ajax({ 75 url: user_dashboard_public_ajax.ajax_url, 76 method: 'post', 77 dataType: 'json', 78 data: userData, 79 success: function (response) { 80 if(response.status){ 81 $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 82 83 quizResultsDiv.first().remove(); 84 parent.append(response.content); 85 var emptyData = $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('.'+html_class_prefix+'result-by-quiz table#ays_quiz_user_dashboard_results_by_quiz_'+quizID+'').attr('data-result'); 86 87 if(emptyData == 'not_empty'){ 88 $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('#ays_quiz_user_dashboard_results_by_quiz_'+quizID+'').DataTable({ 89 "language": { 90 "sEmptyTable": quizUserDashboardLangDataTableObj.sEmptyTable, 91 "sInfo": quizUserDashboardLangDataTableObj.sInfo, 92 "sInfoEmpty": quizUserDashboardLangDataTableObj.sInfoEmpty, 93 "sInfoFiltered": quizUserDashboardLangDataTableObj.sInfoFiltered, 94 "sInfoPostFix": "", 95 "sInfoThousands": ",", 96 "sLengthMenu": quizUserDashboardLangDataTableObj.sLengthMenu, 97 "sLoadingRecords": quizUserDashboardLangDataTableObj.sLoadingRecords, 98 "sProcessing": quizUserDashboardLangDataTableObj.sProcessing, 99 "sSearch": quizUserDashboardLangDataTableObj.sSearch, 100 "sUrl": "", 101 "sZeroRecords": quizUserDashboardLangDataTableObj.sZeroRecords, 102 "oPaginate": { 103 "sFirst": quizUserDashboardLangDataTableObj.sFirst, 104 "sLast": quizUserDashboardLangDataTableObj.sLast, 105 "sNext": quizUserDashboardLangDataTableObj.sNext, 106 "sPrevious": quizUserDashboardLangDataTableObj.sPrevious, 107 }, 108 "oAria": { 109 "sSortAscending": quizUserDashboardLangDataTableObj.sSortAscending, 110 "sSortDescending": quizUserDashboardLangDataTableObj.sSortDescending 111 } 112 } 113 }); 114 115 } 116 117 }else{
118 $_this.parents('.'+html_class_prefix+'content-result-by-quiz').find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 119 } 120 } 121 }); 122 123 }); 124 125 //User History Details 126 $(document).on('click', '.'+html_class_prefix+'details', function(){ 127 var $_this = $(this); 128 var userData = {}; 129 var resultId = $_this.attr('data-id'); 130 var resultsContainer = $_this.parents('.ays-quiz-user-results-container'); 131 var uniqueID = resultsContainer.attr('data-id'); 132 var parent = $(document).find( '.ays-results-modal-'+uniqueID); 133 134 parent.find('div.ays-quiz-user-dashboard-preloader').css('display', 'flex'); 135 parent.aysModal('show'); 136 137 138 userData.action = 'get_user_reports_info_popup_ajax'; 139 userData.result_id = resultId; 140 userData.unique_id = uniqueID; 141 142 $.ajax({ 143 url: user_dashboard_public_ajax.ajax_url, 144 method: 'post', 145 dataType: 'json', 146 data: userData, 147 success: function (response) { 148 if(response.status){ 149 parent.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 150 parent.find('div.ays-modal-body').html(response.details); 151 }else{ 152 swal.fire({ 153 type: 'info', 154 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 155 }).then(function(response){ 156 parent.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 157 parent.aysModal('hide'); 158 }); 159 } 160 }, 161 error: function(){ 162 swal.fire({ 163 type: 'info', 164 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 165 }).then(function(response){ 166 parent.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 167 parent.aysModal('hide'); 168 }); 169 } 170 }); 171 172 }); 173 174 // Export result to pdf 175 $(document).on('click','.ays-quiz-user-dasboard-export-pdf', function (e) { 176 e.preventDefault(); 177 178 var $this = $(this); 179 var parent = $this.parents('.ays-modal'); 180 var uniqueID = parent.attr('data-id'); 181 var result_id = $this.attr('data-result'); 182 var pdf_uniqueID = $this.attr('data-unique-id'); 183 var action = 'get_user_reports_pdf_ajax'; 184 185 $this.parents('.ays-modal').find('div.ays-quiz-user-dashboard-preloader').css('display', 'flex'); 186 $this.attr('disabled'); 187 188 189 if ( uniqueID === pdf_uniqueID ) { 190 $.ajax({ 191 url: user_dashboard_public_ajax.ajax_url, 192 method: 'post', 193 dataType: 'json', 194 data: { 195 action: action, 196 result: result_id, 197 }, 198 success: function (response) { 199 if (response.status) { 200 $this.parent().find('#downloadFileF').attr({ 201 'href': response.result.fileUrl, 202 'download': response.result.fileName, 203 })[0].click(); 204 window.URL.revokeObjectURL(response.result.fileUrl); 205 }else{ 206 swal.fire({ 207 type: 'info', 208 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 209 }) 210 } 211 $this.parents('.ays-modal').find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 212 $this.removeClass('disabled'); 213 } 214 }); 215 } else { 216 swal.fire({ 217 type: 'info', 218 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 219 }) 220 $this.parents('.ays-modal').find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 221 $this.removeClass('disabled'); 222 } 223 224 }); 225 226 /* 227 ========================================== 228 Best Score 229 ========================================== 230 */ 231 var mode = 'Percentage'; 232 var quizID = ''; 233 234 $(document).on('change', '.'+html_class_prefix+'mode', function(){ 235 mode = $(this).val(); 236 }); 237 238 $(document).on('change', '.'+html_class_prefix+'best-score-quizzes', function(){ 239 var $_this = $(this); 240 quizID = $(this).find(':selected').attr('data-id'); 241 }); 242 243 $(document).on('click', '.'+html_class_prefix+'check', function(){ 244 var $_this = $(this); 245 var userData = {}; 246 var quizMode = mode; 247 var userID = $_this.attr('data-user'); 248 var quizId = quizID; 249 var parentDiv = $_this.parents('.'+html_class_prefix+'c
249ontent-best-score').find('div.'+html_class_prefix+'best-score'); 250 251 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'flex'); 252 253 userData.action = 'user_best_score_by_quiz_ajax'; 254 userData.user_id = userID; 255 userData.quiz_id = quizId; 256 userData.mode = quizMode; 257 258 $.ajax({ 259 url: user_dashboard_public_ajax.ajax_url, 260 method: 'post', 261 dataType: 'json', 262 data: userData, 263 success: function (response) { 264 if(response.status){ 265 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 266 parentDiv.children().first().remove(); 267 parentDiv.append(response.result); 268 }else{ 269 swal.fire({ 270 type: 'info', 271 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 272 }).then(function(response){ 273 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 274 }); 275 } 276 }, 277 error: function(){ 278 swal.fire({ 279 type: 'info', 280 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 281 }).then(function(response){ 282 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 283 }); 284 } 285 }); 286 }); 287 288 /* 289 ========================================== 290 User Progress 291 ========================================== 292 */ 293 294 var userProgressMode = 'Score'; 295 var userProgressQuizID = ''; 296 297 $(document).on('change', '.'+html_class_prefix+'user-progress-mode', function(){ 298 userProgressMode = $(this).val(); 299 }); 300 301 $(document).on('change', '.'+html_class_prefix+'user-progress-quizzes', function(){ 302 var $_this = $(this); 303 userProgressQuizID = $(this).find(':selected').attr('data-id'); 304 }); 305 306 $(document).on('click', '.'+html_class_prefix+'user-progress-check', function(){ 307 var $_this = $(this); 308 var userData = {}; 309 var userID = $_this.attr('data-user'); 310 var uniqueID = $(this).parents('.'+html_class_prefix+'content-user-progress').attr('data-id'); 311 var quizId = userProgressQuizID; 312 var quizMode = userProgressMode; 313 var parentDiv = $_this.parents('.'+html_class_prefix+'content-user-progress').find('div.'+html_class_prefix+'user-progress'); 314 315 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'flex'); 316 317 userData.action = 'user_progress_by_quiz_ajax'; 318 userData.user_id = userID; 319 userData.quiz_id = quizId; 320 userData.mode = quizMode; 321 userData.unique_id = uniqueID; 322 323 $.ajax({ 324 url: user_dashboard_public_ajax.ajax_url, 325 method: 'post', 326 dataType: 'json', 327 data: userData, 328 success: function (response) { 329 if(response.status){ 330 parentDiv.find('.'+html_class_prefix+'user-progress-container').first().remove(); 331 if(response.result != ''){ 332 if (typeof google != undefined) { 333 google.charts.load('current', {packages: ['corechart']}); 334 google.charts.setOnLoadCallback(drawBasic); 335 } 336 337 $(document).find( '.'+html_class_prefix+'user-progress-container' ).hover( function(e){ 338 var _this = $(this); 339 340 var circle = _this.find('svg circle'); 341 if (circle.length == 1) { 342 circle.attr('r',5); 343 circle.attr('fill-opacity',1); 344 } 345 346 }, function(e) { 347 var _this = $(this); 348 349 var circle = _this.find('svg circle'); 350 if (circle.length == 1) { 351 circle.attr('r',5); 352 circle.attr('fill-opacity',1); 353 } 354 }); 355 356 function drawBasic() { 357 var quizUserProgressConainter = $(document).find( '.'+html_class_prefix+ 'user-progress-container'); 358 quizUserProgressConainter.each( function( e, i ) { 359 var _this = $(this); 360 361 var uniqueId = _this.attr( 'data-id' ); 362 var mode = _this.attr( 'data-mode' ); 363 364 var thisAysQuizPublicChartData = JSON.parse( atob( window.aysQuizPublicUserProgressData[ uniqueId ] ) ); 365 366 var divId = $html_id_prefix + 'user-progress-chart-' + mode + '-' + uniqueId; 367 var divClass = '.'+html_class_prefix+ 'user-progress-box'; 368 369 var chartDivId = _this.find( divId ); 370 var chartDivIdAttr = _this.find( divClass ).attr('id'); 371 372 var modeText = mode.charAt(0).toUpperCase() + mode.slice(1); 373 374 var viewWindow = {}; 375 if (mode == 'Score') { 376 var viewWindow = { 377 max: 100, 378 min: 0, 379 } 380 } 381 382 var data = new google.visualization.DataTable(); 383 data.addColumn('number', AysQuizUserDashboardObj.attempt); 384 data.addColumn('number', mode); 385 // data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}}); 386 387 data.addRows( 388 thisAysQuizPublicChartData 389 ); 390 391 var options = { 392 height: 300, 393 // tooltip: { 394 // isHtml: true 395 // }, 396 hAxis: { 397 title: AysQuizUserDashboardObj.attempt 398 }, 399 vAxis: { 400 title: modeText, 401 viewWindow, 402 // format: '0', 403 }, 404 legend: {position: 'none'} 405 }; 406 407 var logChart = new google.visualization.LineChart(document.getElementById( chartDivIdAttr )); 408 logChart.draw(data, options); 409 410 if (thisAysQuizPublicChartData.length == 1) { 411 setTimeout(function(){ 412 var chartCircle = chartDivId.find( 'svg circl e' ); 413 chartCircle.attr('r',5); 414 chartCircle.attr('fill-opacity',1); 415 },500); 416 } 417 }); 418 } 419 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 420 parentDiv.append(response.result); 421 }else{ 422 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 423 var noResult = '<div class="'+html_class_prefix+'user-progress-container"><p>There is no result yet</p></div>'; 424 parentDiv.append(noResult); 425 } 426 }else{ 427 swal.fire({ 428 type: 'info', 429 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 430 }).then(function(response){ 431 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 432 }); 433 } 434 }, 435 error: function(){ 436 swal.fire({ 437 type: 'info', 438 html: "<h2>"+ AysQuizUserDashboardObj.loadResource +"</h2><br><h4>"+ AysQuizUserDashboardObj.dataDeleted +"</h4>", 439 }).then(function(response){ 440 parentDiv.find('div.ays-quiz-user-dashboard-preloader').css('display', 'none'); 441 }); 442 } 443 }); 444 }); 445 }); 446 447})(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.