1function loadSweetAlert(callback) { 2 if (typeof Swal !== 'undefined') { 3 callback(); 4 return; 5 } 6 var link = document.createElement('link'); 7 link.rel = 'stylesheet'; 8 link.href = 'https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css'; 9 document.head.appendChild(link); 10 11 var script = document.createElement('script'); 12 script.src = 'https://cdn.jsdelivr.net/npm/sweetalert2@11'; 13 script.onload = callback; 14 document.head.appendChild(script); 15} 16 17(function ($) { 18 $(document).ready(function () { 19 var savedMessage = sessionStorage.getItem('classroomMessage'); 20 var messageType = sessionStorage.getItem('classroomMessageType'); 21 22 if (savedMessage) { 23 if (messageType === 'success') { 24 loadSweetAlert(function() { 25 Swal.fire({ 26 title: 'Success!', 27 text: savedMessage, 28 icon: 'success', 29 confirmButtonText: 'OK', 30 confirmButtonColor: '#28a745' 31 }); 32 }); 33 } 34 sessionStorage.removeItem('classroomMessage'); 35 sessionStorage.removeItem('classroomMessageType'); 36 } 37 38 jQuery('button[data-section="goGroupInfo"]').click(); 39 40 41 42 43 // Exit button function for classroom name change modal 44 jQuery('#group-name-confirm-change-btn-close').click(function () { 45 jQuery('#updateGroupNameModal').removeClass('is-active'); 46 jQuery('html').removeClass('is-clipped'); 47 }); 48 49 // Exit button function for classroom removal modal 50 jQuery('#group-remove-confirm-btn-close').click(function () { 51 jQuery('#removeGroupModal').removeClass('is-active'); 52 jQuery('html').removeClass('is-clipped'); 53 }); 54 55 // Exit button function for classroom add modal 56 jQuery('#group-confirm-add-btn-close').click(function () { 57 jQuery('#newGroupModal').removeClass('is-active'); 58 jQuery('html').removeClass('is-clipped'); 59 }); 60 61 // Exit button function for request licenses modal 62 jQuery('#license-request-add-btn-close').click(function () { 63 jQuery('#requestLicensesModal').removeClass('is-active'); 64 jQuery('html').removeClass('is-clipped'); 65 }); 66 67 // // onClick event for updating classroom registrations 68 $('#group-registrations-confirm-change-btn').on('click', function (evt) { 69 evt.preventDefault(); 70 evt.stopPropagation(); 71 72 let postId = $('#updateGroupRegistrationsModal input[name="post_id"]').val(); 73 let groupLeaderID = $('#updateGroupRegistrationsModal input[name="group_leader_id"]').val(); 74 75 // Check if licenses allowed input has green border (validated) 76 let licensesValid = $('#updateLicensesInput').css("border"); 77 //if (licensesValid == "4px solid rgb(144, 238, 144)") { 78 // fix for Lissett 79 if (licensesValid.indexOf("rgb(144, 238, 144)") >= 0) { 80 81 // Grab new count the user typed in after validation is checked 82 var newCount = $('#updateLicensesInput').val(); 83 if (updateGroupRegistrations(postId, newCount, groupLeaderID)) { 84 $('input[name="post_id"]').val(""); 85 $('#updateGroupRegistrationsModal').removeClass('is-active'); 86 $('html').removeClass('is-clipped'); 87 } 88 } else { 89 alert("Please enter a valid number of licenses - " + licensesValid); 90 } 91 return false; 92 }); 93 94 // Confirm button function for classroom registration count update modal 95 jQuery('#group-registrations-confirm-change-btn-close').click(function () { 96 jQuery('#updateGroupRegistrationsModal').removeClass('is-active'); 97 jQuery('html').removeClass('is-clipped'); 98 }); 99 100 // Exit functions for all modals when x is pressed 101 jQuery('.modal .delete').click(function (evt) { 102 jQuery('#updateGroupNameModal').removeClass('is-active'); 103 jQuery('#newGroupModal').removeClass('is-active'); 104 jQuery('#requestLicensesModal').removeClass('is-active'); 105 jQuery('#removeGroupModal').removeClass('is-active'); 106 jQuery('#updateGroupRegistrationsModal').removeClass('is-active');
107 jQuery('html').removeClass('is-clipped'); 108 }); 109 110 // Exit functions for the modal-close class 111 jQuery('.modal-close').click(function (evt) { 112 jQuery('.modal').removeClass('is-active'); 113 jQuery('html').removeClass('is-clipped'); 114 }); 115 116 jQuery('#package_select').change(function() { 117 var val = jQuery('#package_select').val(); 118 jQuery('.totalLicensesUsedAdd').attr( "style", "display: none !important;" ); 119 jQuery('.totalLicensesUsedAdd_' + val).attr( "style", "display: block !important;" ); 120 }); 121 122 jQuery('#package_select_request').change(function() { 123 var val = jQuery('#package_select_request').val(); 124 jQuery('.totalLicensesUsedRequest').attr( "style", "display: none !important;" ); 125 jQuery('.totalLicensesUsedRequest_' + val).attr( "style", "display: block !important;" ); 126 jQuery('#licensesAllowedInputReq').attr( "style", "display: block !important;" ); 127 }); 128 129 // Turn "Add Group" input border red or green based on input compared to max and min allowed by bbLicenses and bbLicensesUsed 130 jQuery('#licensesAllowedInput').on("input", function () { 131 var bbGroup = jQuery('#package_select').val(); 132 var bbLicenses = parseInt(jQuery("#bbLicenses_" + bbGroup).text(), 10); 133 var bbLicensesUsed = parseInt(jQuery("#bbLicensesUsed_" + bbGroup).text(), 10); 134 var bbLicensesAllowed = bbLicenses - bbLicensesUsed; 135 var licensesTyped = jQuery('#licensesAllowedInput').val(); 136 if ((licensesTyped <= bbLicensesAllowed) && (licensesTyped > 0)) { 137 jQuery('#licensesAllowedInput').css("border", "4px solid rgb(144, 238, 144)"); 138 } else { 139 jQuery('#licensesAllowedInput').css("border", "4px solid red"); 140 } 141 }); 142 143 // Turn "Request Licenses" input border red or green based on input compared to max and min allowed by bbLicenses and bbLicensesUsed 144 jQuery('#licensesAllowedInputReq').on("input", function () { 145 var bbGroup = jQuery('#package_select_request').val(); 146 var bbLicensesLeft = parseInt(jQuery("#bbLicensesLeft_" + bbGroup).text(), 10); 147 var licensesTyped = jQuery('#licensesAllowedInputReq').val(); 148 if ((licensesTyped <= bbLicensesLeft) && (licensesTyped > 0)) { 149 jQuery('#licensesAllowedInputReq').css("border", "4px solid rgb(144, 238, 144)"); 150 } else { 151 jQuery('#licensesAllowedInputReq').css("border", "4px solid red"); 152 } 153 }); 154 155 // Turn "Update Group Registrations" input border red or green based on input compared to max and min allowed by bbLicenses and bbLicensesUsed 156 jQuery('#updateLicensesInput').on("input", function () { 157 var bbGroup = jQuery('.pg').text(); 158 var bbLicenses = parseInt(jQuery("#bbLicenses_" + bbGroup).text(), 10); 159 var bbLicensesUsed = parseInt(jQuery("#bbLicensesUsed_" + bbGroup).text(), 10); 160 var bbLicensesAllowed = bbLicenses - bbLicensesUsed; 161 var licensesTyped = jQuery('#updateLicensesInput').val(); 162 var licensesInCurrentGroup = parseInt(jQuery('.totalClassRegistrations').text(), 10); 163 var studentsInClass = parseInt(jQuery('.studentsInClass').text(), 10); 164 console.log("bbLicenses: " + bbLicenses); 165 console.log("bbLicensesUsed: " + bbLicensesUsed); 166 console.log("bbLicensesAllowed: " + bbLicensesAllowed); 167 console.log("licensesTyped: " + licensesTyped); 168 console.log("licensesInCurrentGroup: " + licensesInCurrentGroup); 169 console.log("studentsInClass: " + studentsInClass); 170 171 console.log("bbLicensesAllowed + licensesInCurrentGroup: " + (bbLicensesAllowed + licensesInCurrentGroup)); 172 if ((licensesTyped <= (bbLicensesAllowed + licensesInCurrentGroup)) && (licensesTyped > 0) && (licensesTyped >= studentsInClass)) { 173 jQuery('#updateLicensesInput').css("border", "4px solid rgb(144, 238, 144)"); 174 } else { 175 jQuery('#updateLicensesInput').css("border", "4px solid red"); 176 } 177 }); 178 if (typeof tippy !== 'undefined') { 179 tippy('#requestLicensesButton', { 180 content: "Use this feature to pull more licenses from your school's package. If you're seeing this button, that means you've been given permission!", 181 placement: 'bottom', 182 animation: 'scale', 183 }); 184 } 185 }); 186 187})(jQuery); 188 189function dispatchEvents(evt) { 190 verifyGroupNameUpdate(evt); 191 verifyRemoveGroup(evt); 192 verifyAddNewGroup(evt); 193 verifyRequestMoreLicenses(evt); 194 verifyUpdateGroupRegistrations(evt); 195 updateGroupRegistrations(evt); 196 updateGroupName(evt); 197 removeGroup(evt); 198 addNewGroup(evt); 199 requestMoreLicenses(evt); 200} 201 202// function for Welcome Video modal 203function videoModal(postId) { 204 jQuery('#videoModal' + postId).addClass('is-active');
205 jQuery('html').addClass('is-clipped'); 206} 207 208// TODO: finish coding and testing all these functions here and in the rest routes 209 210// JS Validation function for Group Name update 211// postId comes from the actual group post ID the edit button is attached to when printed in the PHP 212function verifyGroupNameUpdate(postId, groupLimit) { 213 214 // Open modal 215 jQuery('#updateGroupNameModal').addClass('is-active'); 216 jQuery('html').addClass('is-clipped'); 217 jQuery('input[name="post_id"]').val(postId); 218 jQuery('input[name="group_name_group_limit"]').val(groupLimit); 219 220 // onClick event for confirm name change button 221 jQuery('#group-name-confirm-change-btn').click(function (evt) { 222 evt.preventDefault(); 223 evt.stopPropagation(); 224 225 // This will run the function that makes the ajax call to change the name of the group 226 // If it fails, the items inside the if statement will not run 227 if (updateGroupName()) { 228 jQuery('input[name="group_name"]').val(""); 229 jQuery('input[name="post_id"]').val(""); 230 jQuery('#updateGroupNameModal').removeClass('is-active'); 231 jQuery('html').removeClass('is-clipped'); 232 } 233 234 return false; 235 }); 236 237 return false; 238} 239 240// JS Validation function for Classroom Removal - Prompts user for a confirmation 241// post_id comes from the actual group post ID the 'X' is attached to when printed in the PHP 242// groupLeaderId comes from the current user meta 243function verifyRemoveGroup(post_id, groupLeaderId) { 244 245 // Open modal 246 jQuery('#removeGroupModal').addClass('is-active'); 247 jQuery('html').addClass('is-clipped'); 248 249 // onClick event for confirm name change button 250 jQuery('#group-remove-confirm-btn').one('click', function (evt) { 251 evt.preventDefault(); 252 evt.stopPropagation(); 253 254 // This will run the function that makes the ajax call to remove the classroom post 255 // If it fails, the items inside the if statement will not run 256 // Parameters are the same as those passed into this function 257 if (removeGroup(post_id, groupLeaderId)) { 258 jQuery('#removeGroupModal').removeClass('is-active'); 259 jQuery('html').removeClass('is-clipped'); 260 } 261 262 return false; 263 }); 264 265 return false; 266} 267 268// JS Validation function for Classroom Addition - Prompts user for Classroom name and Registration count 269function verifyAddNewGroup() { 270 271 var bbGroup = jQuery('#package_select').val(); 272 var bbLicenses = parseInt(jQuery(".bbLicenses_" + bbGroup).text(), 10); 273 var bbLicensesUsed = parseInt(jQuery(".bbLicensesUsed_" + bbGroup).text(), 10); 274 var val = jQuery('#package_select').val(); 275 jQuery('.totalLicensesUsedAdd').attr( "style", "display: none !important;" ); 276 jQuery('.totalLicensesUsedAdd_' + val).attr( "style", "display: block !important;" ); 277 // Check licenses available to the teacher by comparing the licenses printed from the PHP into the JS. Return if 0. 278 if (bbLicenses == bbLicensesUsed) { 279 alert("You have already allotted all of your licenses to other classrooms. Please edit the number of registrations on your other classrooms to make space for a new classroom.") 280 return; 281 } 282 283 // Open Modal 284 jQuery('#newGroupModal').addClass('is-active'); 285 jQuery('html').addClass('is-clipped'); 286 287 // onClick event for confirm add classroom button 288 jQuery('#group-confirm-add-btn').one('click', function (evt) { 289 evt.preventDefault(); 290 evt.stopPropagation(); 291 292 // Check if licenses allowed input has green border (validated) 293 var licensesValid = jQuery('#licensesAllowedInput').css("border"); 294 295 if (checkBorder(licensesValid)) { 296 297 // This will run the function that makes the ajax call to add the classroom 298 // If it fails, the items inside the if statement will not run 299 if (addNewGroup()) { 300 jQuery('input[name="group_name"]').val(""); 301 jQuery('input[name="licenses_allowed"]').val(""); 302 jQuery('#newGroupModal').removeClass('is-active');
303 jQuery('html').removeClass('is-clipped'); 304 } 305 306 } else { 307 alert("Please enter a valid number of licenses"); 308 } 309 310 return false; 311 }); 312 313 return false; 314} 315 316function verifyRequestMoreLicenses(groupLeaderId) { 317 // Open Modal 318 jQuery('#requestLicensesModal').addClass('is-active'); 319 jQuery('html').addClass('is-clipped'); 320 321 // onClick event for confirm add classroom button 322 jQuery('#group-confirm-req-btn').one('click', function (evt) { 323 evt.preventDefault(); 324 evt.stopPropagation(); 325 326 // Check if licenses allowed input has green border (validated) 327 var licensesValid = jQuery('#licensesAllowedInputReq').css("border"); 328 329 if (checkBorder(licensesValid) == true) { 330 console.log(licensesValid); 331 332 // This will run the function that makes the ajax call to add the classroom 333 // If it fails, the items inside the if statement will not run 334 if (requestMoreLicenses(groupLeaderId)) { 335 jQuery('input[name="licenses_allowed_request"]').val(""); 336 jQuery('#requestLicensesModal').removeClass('is-active'); 337 jQuery('html').removeClass('is-clipped'); 338 } 339 340 } else { 341 alert("Your group does not have that many licenses left. Please contact your license manager or BrainBuffet representative."); 342 } 343 344 return false; 345 }); 346 return false; 347} 348 349function checkBorder(licensesValid) { 350 //4px solid lightgreen 351 if (licensesValid == "4px solid rgb(144, 238, 144)") { 352 return true; 353 } else if (licensesValid.indexOf("rgb(144, 238, 144)")) { 354 return true; 355 } 356 357 return false; 358} 359// JS Validation function for Updating Classroom Registrations - Prompts user for a new count 360// postId comes from the actual group post ID the 'X' is attached to when printed in the PHP 361// groupLeaderId comes from the current user meta 362// userCount is the current number of students in the class 363// limit is the actual wdm_group_users_limit_.$group_id of the classroom in context 364// title is the name of the post, used to display in the outcome div after ajax is complete 365function verifyUpdateGroupRegistrations(postId, groupLeaderID, userCount, limit, title, parentGroup) { 366 // Open Modal 367 jQuery('#updateGroupRegistrationsModal').addClass('is-active'); 368 jQuery('html').addClass('is-clipped'); 369 370 // Fill variables in for user to see & validation 371 jQuery('input[name="post_id"]').val(postId); 372 jQuery('input[name="group_leader_id"]').val(groupLeaderID); 373 jQuery('.classroomName').text(title); 374 var val = parentGroup; 375 console.log("User count: " + userCount); 376 jQuery('.pg').text(val); 377 jQuery('.studentsInClass').text(userCount); 378 jQuery('.totalLicensesUsed').attr( "style", "display: none !important;" ); 379 jQuery('.totalLicensesUsed_' + val).attr( "style", "display: block !important;" ); 380 jQuery('.totalLicensesUsedAdd').attr( "style", "display: none !important;" ); 381 jQuery('.totalLicensesUsedAdd_' + val).attr( "style", "display: block !important;" ); 382 var totalClassRegistrations = parseInt(limit, 10) + parseInt(userCount, 10); 383 jQuery('.totalClassRegistrations').text(totalClassRegistrations); 384 385 return false; 386} 387 388// This function contains the AJAX call to update the actual classroom registration count 389// Parameters are 1:1 with the respective verifyX version of this function 390function updateGroupRegistrations(postId, newCount, groupLeaderID) { 391 392 // Check all variables are defined and set 393 if ('undefined' === typeof newCount || '' === newCount) { 394 console.log('No title, modal stays open.'); 395 return false; 396 } 397 398 if ('undefined' === typeof postId || '' === postId) { 399 console.log('No postid! Fatal error, please contact support.'); 400 return false; 401 } 402 403 if ('undefined' === typeof groupLeaderID || '' === groupLeaderID) { 404 console.log('No group leader! Fatal error, please contact support.'); 405 return false; 406 } 407 var body = jQuery('body'); 408 body.addClass('process-loading'); 409 // Call the updategroupregistrations route, which routes to the bb_get_endpoint_my_class_update_regs_phrase callback 410 jQuery.ajax({ 411 url: bb_ajax_my_class.ajaxurl + 'bbgroupapi/v1/updategroupregistrations', 412 method: 'GET', 413 beforeSend: function (xhr) { 414 xhr.setRequestHeader('X-WP-Nonce', bb_ajax_my_class.ajaxnonce); 415 }, 416 async: false, 417 data: { 418 ID: postId, 419 newCount: newCount, 420 groupLeaderID: groupLeaderID, 421 }, 422 success: function (data, status, jqXHR) { 423 body.removeClass('process-loading'); 424 data = JSON.parse(data); 425 if (data.err === '-1') { 426 console.log('Group registrations update failed.'); 427 jQuery('#group-registrations-update-result').html(`<div class="notification is-danger is-light"> 428 Classroom update failed: ` + data.newCount + ` not valid - not enough licenses left in package. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 429 } 430 else if (data.err === '-2') { 431 jQuery('#group-registrations-update-result').html(`<div class="notification is-danger is-light"> 432 Classroom update failed at end of process: ` + data.newCount + ` not valid. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 433 } 434 else if (data.err === '-3') { 435 jQuery('#group-registrations-update-result').html(`<div class="notification is-danger is-light"> 436 Classroom update failed at end of process: ` + data.newCount + ` not valid - teacher has already alloted this amount of licenses or more (` + data.oldCount +`). Please ask them to decrease the amount allotted, or remove them from the package. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 437 } 438 else if (data.err === '-4') { 439 jQuery('#group-registrations-update-result').html(`<div class="notification is-danger is-light"> 440 Classroom update failed: ` + data.newCount + ` is fewer than the ` + data.numMembers + ` students currently enrolled in this classroom. Remove students first, or choose a higher seat count. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 441 }else{ 442 // Fill in content on the update result div 443 jQuery('#group-registrations-update-result').html(`<div class="notification is-success is-light"> 444 Group registration count saved as '<b>` + data.newCount + `</b>'. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 445 } 446 return true; 447 } 448 }); 449 450 return true; 451} 452 453// This function contains the AJAX call to update the actual classroom registration count 454function updateGroupName() { 455 456 // Grab the title and postId from the DOM 457 var title = jQuery('input[name="group_name"]').val(); 458 var postId = jQuery('input[name="post_id"]').val(); 459 var groupLimit = jQuery('input[name="group_name_group_limit"]').val(); 460 461 // Check all variables are defined and set 462 if ('undefined' === typeof title || '' === title) { 463 console.log('No title, modal stays open.'); 464 return false;
465 } 466 467 if ('undefined' === typeof postId || '' === postId) { 468 console.log('No postid! Fatal error, please contact support.'); 469 return false; 470 } 471 var body = jQuery('body'); 472 body.addClass('process-loading'); 473 // Call the updategroupname route, which routes to the bb_get_endpoint_my_class_phrase callback 474 jQuery.ajax({ 475 url: bb_ajax_my_class.ajaxurl + 'bbgroupapi/v1/updategroupname', 476 method: 'GET', 477 beforeSend: function (xhr) { 478 xhr.setRequestHeader('X-WP-Nonce', bb_ajax_my_class.ajaxnonce); 479 }, 480 async: false, 481 data: { 482 ID: postId, 483 group_name: title, 484 group_limit: groupLimit 485 }, 486 success: function (data, status, jqXHR) { 487 body.removeClass('process-loading'); 488 data = JSON.parse(data); 489 if (data.err === '-1') { 490 console.log('Group name update failed.'); 491 } 492 493 // Fill in content on the update result div 494 jQuery('#group-name-update-result').html(`<div class="notification is-success is-light"> 495 Group name saved as '<b>` + data.group_name + `</b>'. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 496 497 return true; 498 } 499 500 }); 501 502 return true; 503} 504 505// This function contains the AJAX call to remove the classroom 506// Parameters are 1:1 with the respective verifyX version of this function 507function removeGroup(post_id, groupLeaderId) { 508 509 // Check all variables are defined and set 510 if ('undefined' === typeof post_id || '' === post_id) { 511 console.log('No postid! Fatal error, please contact support.'); 512 return false; 513 } 514 515 if ('undefined' === typeof groupLeaderId || '' === groupLeaderId) { 516 console.log('No group leader ID! Fatal error, please contact support.'); 517 return false; 518 } 519 var body = jQuery('body'); 520 body.addClass('process-loading'); 521 // Call the removegroup route, which routes to the bb_get_endpoint_my_class_remove_phrase callback 522 jQuery.ajax({ 523 url: bb_ajax_my_class.ajaxurl + 'bbgroupapi/v1/removegroup', 524 method: 'GET', 525 beforeSend: function (xhr) { 526 xhr.setRequestHeader('X-WP-Nonce', bb_ajax_my_class.ajaxnonce); 527 }, 528 async: false, 529 data: { 530 post_id: post_id, 531 groupLeaderId: groupLeaderId, 532 }, 533 success: function (data, status, jqXHR) { 534 body.removeClass('process-loading'); 535 data = JSON.parse(data); 536 if (data.err === '-1') { 537 console.log('Group removal failed:' + data.post_id + ', ' + data.groupLeaderId); 538 alert('Group removal failed. Please try again.'); 539 } else { 540 sessionStorage.setItem('classroomMessage', 'Group removed successfully!'); 541 sessionStorage.setItem('classroomMessageType', 'success'); 542 location.reload(); 543 } 544 545 return true; 546 } 547 548 }); 549 550 return true; 551} 552 553// This function contains the AJAX call to add the classroom 554// Parameters are 1:1 with the respective verifyX version of this function 555function addNewGroup() { 556 var title = jQuery('input[name="new_group_name"]').val(); 557 var licenses_allowed = jQuery('input[name="licenses_allowed"]').val(); 558 var package_selected = jQuery('#package_select').find(":selected").val(); 559 var teacher_email = jQuery('#teacherEmail').text(); 560 561 // Check all variables are defined and set 562 if ('undefined' === typeof title || '' === title) { 563 console.log('No title, modal stays open.'); 564 return false; 565 } 566 var body = jQuery('body'); 567 body.addClass('process-loading'); 568 // Call the addnewgroup route, which routes to the bb_get_endpoint_my_class_add_phrase callback 569 jQuery.ajax({ 570 url: bb_ajax_my_class.ajaxurl + 'bbgroupapi/v1/addnewgroup', 571 method: 'GET', 572 dataType: 'JSON', 573 beforeSend: function (xhr) { 574 xhr.setRequestHeader('X-WP-Nonce', bb_ajax_my_class.ajaxnonce); 575 }, 576 async: false, 577 data: { 578 licenses_allowed: licenses_allowed, 579 group_name: title, 580 teacher_email: teacher_email, 581 parent_group: package_selected, 582 }, 583 success: function (data, status, jqXHR) { 584 body.removeClass('process-loading'); 585 data = JSON.parse(data); 586 if (data.err === '-1') { 587 console.log('Group add failed.'); 588 alert('Classroom creation failed: ' + data.group_name); 589 } else { 590 loadSweetAlert(function() { 591 Swal.fire({ 592 title: 'Success!', 593 text: 'Classroom created as "' + data.group_name + '" successfully!', 594 icon: 'success', 595 confirmButtonText: 'OK', 596 confirmButtonColor: '#28a745' 597 }); 598 }); 599 location.reload(); 600 } 601 602 jQuery('#newGroupButton').hide().prop('disabled', true); 603 604 return true; 605 } 606 607 }); 608 609 return true; 610} 611 612jQuery( document ).ready(function() { 613 jQuery('button[data-section="goGroupInfo"]').click(); 614 615 // My class Select groups ajax 616 let select_groups = jQuery('.wds-change-group-management-form'); 617 select_groups.on('change', function(e) { 618 let thisSelect = jQuery(this); 619 let selected = thisSelect.find(":selected"); 620 let selectedVal = thisSelect.find(":selected").val(); 621 if( selectedVal === 'load_more' ){ 622 selected.text('Loading...'); 623 jQuery.ajax({ 624 url: wdsajax.ajaxurl, 625 data: { 626 action: 'groups_load_more', 627 query_vars: wdsajax.query_vars 628 }, 629 type: 'post', 630 dataType: 'html', 631 success: function (data) { 632 thisSelect.append(data); 633 selected.text('Loaded all groups.'); 634 selected.attr('disabled','disabled'); 635 selected.insertAfter(thisSelect.find('option:last-child')); 636 } 637 }); 638 } 639 }); 640}); 641 642function requestMoreLicenses(groupLeaderId) { 643 var licenses_allowed = jQuery('input[name="licenses_allowed_req"]').val(); 644 var package_selected = jQuery('#package_select_request').find(":selected").val(); 645 646 var body = jQuery('body'); 647 body.addClass('process-loading'); 648 jQuery.ajax({ 649 url: bb_ajax_my_class.ajaxurl + 'bbgroupapi/v1/requestmorelicenses', 650 method: 'GET', 651 dataType: 'JSON', 652 beforeSend: function (xhr) { 653 xhr.setRequestHeader('X-WP-Nonce', bb_ajax_my_class.ajaxnonce); 654 }, 655 async: false, 656 data: { 657 licenses_allowed: licenses_allowed, 658 parent_group: package_selected, 659 teacher: groupLeaderId, 660 }, 661 success: function (data, status, jqXHR) { 662 body.removeClass('process-loading'); 663 data = JSON.parse(data); 664 console.log(data.err); 665 console.log(data.teacher); 666 console.log(data.newlic); 667 if (data.err === '-1') { 668 jQuery('#group-registrations-update-result').html(`<div class="notification is-danger is-light"> 669 Your package does not have enough registrations to distribute what you have requested. Please contact your license manager or Sales Representative.<a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 670 } else { 671 jQuery('#group-registrations-update-result').html(`<div class="notification is-success is-light"> 672 Your max registrations have been updated. <a href="javascript: location.reload();">Please Click Here</a> to refresh data.</div>`); 673 } 674 return true; 675 } 676 677 }); 678 679 return true; 680}
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.