1jQuery(document).ready(function () { 2 3 4 $bgColor = $('.blog-masthead').css("background-color"); 5 6 $(document).on('click', '.PluginLoadLink', function (e) { 7 8 if ($(this).attr('id') == 'ChangePasswordO365') { 9 e.preventDefault(); 10 return; 11 } 12 13 var action = $(this).attr('href'); 14 15 e.preventDefault(); 16 17 LoadPluginContent(action, true, $(this)); 18 }); 19 20 $.ajaxSetup({ 21 // Disable caching of AJAX responses 22 cache: false 23 }); 24 25 $(document).on('click', '#ChangePasswordO365', function (e) { 26 $('#changePasswordO365Dialog').modal('show'); 27 }); 28 29 //$(document).ajaxStart(function (e) { 30 // e.preventDefault(); 31 // checkAuth(); 32 //}); 33 34 //setInterval(checkAuth, 300000); //every 5 minutes 35 36 $(document).ajaxError(function (event, request, settings, xhr) { 37 if (xhr == "ForbiddenImpersonation") { 38 $modal = $("#AccessDeniedImpersonationModal"); 39 var template = $("#AccessDeniedImpersonationTemplate").tmpl(); 40 $modal.html(template); 41 $modal.modal('show'); 42 return false; 43 } 44 else if (request.status == 403) { 45 location.reload(); 46 } 47 }); 48 49 $('#AccessDeniedImpersonationModal').on('hidden.bs.modal', function (e) { 50 location.reload(); 51 }); 52 53 var lang = getLang(); 54 55 /*-----------------------------------------------------------*/ 56 /* Panel actions */ 57 /*-----------------------------------------------------------*/ 58 59 $(document).on('click', 'div.panel-heading', function () { 60 if ($(this).find(".panelArrow").hasClass("glyphicon-chevron-down")) 61 $(this).find(".panelArrow").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"); 62 else 63 $(this).find(".panelArrow").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"); 64 }); 65 66 /*-----------------------------------------------------------*/ 67 /* Action items - modal dialog show */ 68 /*-----------------------------------------------------------*/ 69 70 $(".modal_dialog").click(function () { 71 var id = "#" + $(this).attr("modal_id"); 72 $(id).modal(); 73 }); 74 75 $('body').popover({ 76 selector: '.has-tooltip', 77 placement: 'top', 78 container: 'body', 79 trigger: 'hover', 80 html: true 81 }); 82 83 $('.tooltip-info[data-toggle="tooltip"]').tooltip({ 84 html: true, 85 selector: '', 86 placement: 'top', 87 container: 'body' 88 }); 89 90 $(".dropdown-toggle-role").click(function (event) { 91 $(".dropdown-mobile").find('.nav-dropdown-item').toggle(); 92 $(".dropdown-mobile").find('.dropdown-head').not('.role-head').toggle(); 93 $(".role-submenu").toggle(); 94 $('.dropdown-mobile').find('.caret').toggleClass('caret-up'); 95 return false; 96 }); 97 98 $('.dropdown-menu-mobile').on('hide.bs.dropdown', function () { 99 $(".dropdown-mobile").find('.nav-dropdown-item').show(); 100 $(".dropdown-mobile").find('.dropdown-head').show(); 101 $(".role-submenu").hide(); 102 $('.dropdown-mobile').find('.caret').removeClass('caret-up'); 103 }); 104 105 /*-----------------------------------------------------------*/ 106 /* Form validation - custom validators */ 107 /*-----------------------------------------------------------*/ 108 109 $.formUtils.addValidator({ 110 name: 'radiobutton_group', 111 validatorFunction: function (val, $el, conf, lang, $form) { 112 // preset return var 113 var isValid = true, 114 // get name of element. since it is a checkbox group, all checkboxes will have same name 115 elname = $el.attr('name'), 116 // get checkboxes and count the checked ones 117 $checkBoxes = $("input[type=radio][name^='" + elname + "']", $form), 118 checkedCount = $checkBoxes.filter(':checked').length, 119 // get el attr that specs qty required / allowed 120 qtyAllowed = 'min1'; 121 122 // call Utility function to check if count is above min, below max, within range etc. 123 var qtyCheckResults = $.formUtils.numericRangeCheck(checkedCount, qtyAllowed); 124 125 // results will be array, [0]=result str, [1]=qty int 126 switch (qtyCheckResults[0]) { 127 // outside allowed range 128 case "out": 129 this.errorMessage = lang.groupCheckedRangeStart + qtyAllowed + lang.groupCheckedEnd; 130 isValid = false; 131 break; 132 // below min qty 133 case "min": 134 this.errorMessage = lang.groupCheckedTooFewStart + qtyCheckResults[1] + lang.groupCheckedEnd; 135 isValid = false; 136 break; 137 // above max qty 138 case "max": 139 this.errorMessage = lang.groupCheckedTooManyStart + qtyCheckResults[1] + lang.groupCheckedEnd; 140 isValid = false; 141 break; 142 // ok 143 default: 144 isValid = true; 145 } 146 147 if (!isValid) { 148 var _triggerOnBlur = function () { 149 $checkBoxes.unbind('click', _triggerOnBlur); 150 $checkBoxes.filter('*[data-validation]').eq(0).val
150idateInputOnBlur(lang, conf, false, 'blur'); 151 }; 152 //$checkBoxes.bind('click', _triggerOnBlur); 153 } 154 155 return isValid; 156 } 157 }); 158 159 /*-----------------------------------------------------------*/ 160 /* Select2 keypress event fix */ 161 /*-----------------------------------------------------------*/ 162 163 $(document).on("keypress", ".select2-container", function (e) { 164 if ($(this).find('.select2-selection--multiple').length == 0) { 165 166 var key = e.which; 167 168 var irrelevantKeys = [ 169 8, // DELETE 170 9, // TAB 171 13, // ENTER 172 16, // SHIFT 173 17, // CTRL 174 18, // OPT/ALT 175 20, // CAPS 176 27, // ESC 177 32, // SPACE 178 37, // LEFT 179 38, // UP 180 39, // RIGHT 181 40, // DOWN 182 91, // L-CMD 183 93 // R-CMD 184 ]; 185 186 if (irrelevantKeys.indexOf(key) === -1) { 187 188 $select = $(this).prev(); 189 190 if ($(this).prev().get(0).tagName != "SELECT") 191 return; 192 193 $select.select2('open'); 194 195 var $search = $select.data('select2').dropdown.$search || $select.data('select2').selection.$search; 196 $search.val(String.fromCharCode(key)); 197 // Timeout seems to be required for Blink 198 setTimeout(function () { 199 $search.get(0).setSelectionRange(1, 1); 200 $search.trigger('keyup'); 201 }, 0); 202 } 203 } 204 }); 205 206 $(document).on('click', '.btnMenuGenQR', function (e) { 207 showWait($('#wrap')); 208 const eventB64 = null; 209 const qrUrl = `${window.location.protocol}//${window.location.host}/TimeTable/TimeTable/GenerateQR/`; 210 $.post(qrUrl, { evtB64: eventB64 }) 211 .done(function (response) { 212 hideWait($('#wrap')); 213 //window.open(response, '_blank'); 214 const newWindow = window.open(); 215 newWindow.document.write(response); 216 newWindow.document.close(); 217 }) 218 }); 219 220 //ShowPopUpWithAvailableSurveys(); 221 //FShowPortalApprovalForm(); 222 223 $(function () { 224 var surveyReq = GetSurveysListJs(); 225 surveyReq.done(function (result) { 226 ShowSurveyPopUp(result); 227 }); 228 }); 229}); 230 231 232function getLang() 233{ 234 var lang = ""; 235 if (typeof $.cookie("lang") === 'undefined') 236 lang = "en"; 237 else 238 lang = $.cookie("lang"); 239 240 lang = lang.split('-')[0]; 241 242 return lang; 243} 244 245function checkPulse(XMLHttpRequest) 246{ 247 if (window.location.href.indexOf("StudentManager/StudentManager") != -1 || window.location.href.indexOf("Account/Login") != -1) { 248 return true; 249 } 250 251 showWait($('#wrap')); 252 var roleid = $(".RoleDescription").data("role-id"); 253 254 var LoggedIn = false; 255 256 $.ajax({
257 url: "/CheckPulse/CheckPulse", 258 type: 'GET', 259 async: false, 260 beforeSend: null, 261 data: { 262 roleid: roleid 263 }, 264 success: function (result, textStatus, xhr) { 265 if (result != "") { 266 if (XMLHttpRequest != null) 267 XMLHttpRequest.abort(); 268 269 if ($("#login").html() == "") { 270 $("#login").replaceWith(result); 271 } 272 $('#login').modal('show'); 273 } 274 else { 275 LoggedIn = true; 276 } 277 278 hideWait($('#wrap')); 279 }, 280 error: function(){ 281 hideWait($('#wrap')); 282 } 283 }); 284 285 return LoggedIn; 286} 287 288function checkAuth() 289{ 290 showWait($('#wrap')); 291 var roleid = $(".RoleDescription").data("role-id"); 292 293 var LoggedIn = false; 294 295 $.ajax({ 296 url: "/CheckPulse/CheckPulse", 297 type: 'GET', 298 async: false, 299 beforeSend: null, 300 data: { 301 roleid: roleid 302 }, 303 success: function (result, textStatus, xhr) { 304 if (result != "") { 305 306 if ($("#login").html() == "") { 307 $("#login").replaceWith(result); 308 } 309 $('#login').modal('show'); 310 } 311 else { 312 LoggedIn = true; 313 } 314 315 hideWait($('#wrap')); 316 }, 317 error: function () { 318 hideWait($('#wrap')); 319 } 320 }); 321 322 return LoggedIn; 323} 324 325function generateUUID() { 326 var d = new Date().getTime(); 327 var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 328 var r = (d + Math.random() * 16) % 16 | 0; 329 d = Math.floor(d / 16); 330 return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); 331 }); 332 return uuid; 333}; 334 335function showWait(element) 336{ 337 if ($(element).find('#ShortcutMenu').length) 338 $('#ShortcutMenu').hide(); 339 340 element.waitMe({ 341 effect : 'progressBar', 342 text: RES_Validation.PleaseWait, 343 bg : 'rgba(255,255,255,0.7)', 344 color: $bgColor, 345 maxSize : '', 346 textPos : 'vertical', 347 fontSize : '', 348 source : '' 349 }); 350} 351 352function addOverlay(element, text) { 353 if ($(element).find('#ShortcutMenu').length) 354 $('#ShortcutMenu').hide(); 355 356 element.waitMe({ 357 effect: 'none', 358 text: text, 359 bg: 'rgba(255,255,255,0.7)', 360 color: $bgColor, 361 maxSize: '', 362 textPos: 'vertical', 363 fontSize: '', 364 source: '' 365 }); 366 367 element.find(".waitMe").css("cursor", "default"); 368} 369 370function hideWait(element) 371{ 372 element.waitMe('hide'); 373 if ($(element).find('#ShortcutMenu').length) 374 $('#ShortcutMenu').show(); 375} 376 377function showErrorModal(text) { 378 var msg = text; 379 if (msg == "" || msg == " ") 380 msg = RES_Validation.GenericErrorMessage; 381 382 var content = { Message: msg }; 383 384 $modal = $("#ErrorModal"); 385 var template = $("#ErrorModalTemplate").tmpl(content); 386 $modal.html(template); 387 $modal.modal('show'); 388} 389 390function showRawErrorModal(text) { 391 var msg = htmlDecode(text); 392 if (msg == "" || msg == " ") { 393 msg = RES_Validation.GenericErrorMessage; 394 showErrorModal(msg); 395 return; 396 } 397 398 399 var content = { Message: msg }; 400 401 402 $modal = $("#ErrorModal"); 403 var template = $("#ErrorModal_rawHtml").tmpl(content); 404 $modal.html(template); 405 $modal.modal('show'); 406} 407 408function htmlDecode(input) { 409 var e = document.createElement('textarea'); 410 e.innerHTML = input; 411 // handle case of empty input 412 return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; 413} 414 415function parseErrorResponse(xhr) { 416 417 if (!xhr || !xhr.responseText.length) return ''; 418 419 var response = $($.parseHTML(xhr.responseText)).filter('title:eq(0)').text(); 420 421 if (response.length) return response; 422 423 return ''; 424} 425 426function showDeleteModal(text, actionLink, elementID) { 427 var content = { Message: text, ActionLink: actionLink, ElementID: elementID}; 428 429 $modal = $("#DeleteModal"); 430 var template = $("#DeleteModalTemplate").tmpl(content); 431 $modal.html(template); 432 $modal.modal('show'); 433} 434 435function showLinkModal(text, actionLink, elementID) { 436 var content = { Message: text, ActionLink: actionLink, ElementID: elementID }; 437 438 $modal = $("#ConfirmWithLinkModal"); 439 var template = $("#ConfirmWithLinkModalTemplate").tmpl(content); 440 $modal.html(template); 441 $modal.modal('show'); 442} 443 444function showDeleteCallbackModal(text, deleteRecordFunction, elementID, additionalData) { 445 var content = { Message: text, deleteRecordFunction: deleteRecordFunction, ElementID: elementID, additionalData: additionalData }; 446 447 $modal = $("#DeleteModal"); 448 var template = $("#DeleteModalCallbackTemplate").tmpl(content); 449 $modal.html(template); 450 $modal.modal('show'); 451} 452 453function showInfoModal(text) { 454 var content = { Message: text }; 455 456 $modal = $("#InfoModal"); 457 var template = $("#InfoModalTemplate").tmpl(content); 458 $modal.html(template); 459 $modal.modal('show'); 460} 461 462function showInfoModalMailto(text, email, mailtoText) { 463 var content = { Message: text, Email: email, MailtoText: mailtoText }; 464 465 $modal = $("#InfoModalMailto"); 466 var template = $("#InfoModalMailtoTemplate").tmpl(content); 467 $modal.html(template); 468 $modal.modal('show'); 469} 470 471function showConfirmModal(text, confirmFunction) { 472 var content = { Message: text, confirmFunction: confirmFunction }; 473 474 $modal = $("#ConfirmModal"); 475 var template = $("#ConfirmModalTemplate").tmpl(content); 476 $modal.html(template); 477 $modal.modal('show'); 478} 479 480function LoadPluginContent(action, saveState, link) 481{ 482 $.ajax({
483 url: action, 484 beforeSend: function (xhr) { 485 if (action.indexOf("StudentManager/StudentManager") != -1) { 486 return true 487 } 488 489 if (checkPulse(xhr)) { 490 showWait($('#wrap')); 491 } 492 else 493 return false; 494 }, // pre-submit callback 495 success: function (data) { 496 if (saveState) 497 SaveHistoryState(action); 498 LoadSubmenu(data, action, link); 499 select2Cleanup(); 500 }, 501 type: 'GET', 502 error: function (data) { 503 hideWait($('#wrap')); 504 showErrorModal(RES_Validation.GenericErrorMessage); 505 } 506 }); 507} 508 509function LoadSubmenu(plugin, action, link) 510{ 511 var surveyReq = GetSurveysListJs(); 512 513 $.ajax({ 514 url: '/Layout/_SubMenu/', // pre-submit callback, 515 data: { 516 requestAction: action 517 }, 518 success: function (data) { 519 $('#Submenu').html(data); 520 document.title = link.data('title'); 521 SetActiveTab(action); 522 $('#plugin-content').html(plugin); 523 524 surveyReq.done(function (result) { 525 ShowSurveyPopUp(result); 526 }); 527 528 hideWait($('#wrap')); 529 }, 530 type: 'GET', 531 error: function (data) { 532 hideWait($('#wrap')); 533 showErrorModal(RES_Validation.GenericErrorMessage); 534 } 535 }); 536 537 //ShowPopUpWithAvailableSurveys(); 538} 539 540function SetActiveTab(action) 541{ 542 $('a.PluginLoadLink').removeClass("active"); 543 $('a.PluginLoadLink[href$="' + action + '"]').addClass("active"); 544 545 $('a.PluginLoadLink').parent().removeClass("active"); 546 $('a.PluginLoadLink[href$="' + action + '"]').parent().addClass("active"); 547} 548 549function select2Cleanup() { 550 $("[class^='select2-']").remove(); 551} 552 553function FormatPeriod(optdata) { 554 555 if (optdata.element == null || optdata.element.attributes['data-padding'] == null) return optdata.text; 556 557 var $optdata = $('<span class="select2opttext" style="margin-left:' + optdata.element.attributes['data-padding'].value + '" data-headtext="' + optdata.element.attributes['data-grouphead'].value + '">' + optdata.text + '</span>'); 558 559 return $optdata; 560} 561 562function FormatCourse(optdata) { 563 564 if (optdata.extra == null) return optdata; 565 566 var $optdata = "[" + optdata.extra.Code + "] " + optdata.text; 567 568 return $optdata; 569} 570 571function FormatCourseGroup(optdata) { 572 573 if (optdata.extra == null) return optdata; 574 575 var iconUrl = optdata.extra.iconUrl; 576 577 var $optdata = optdata.text; 578 579 if (iconUrl != "") 580 $optdata = $("<span><img src=\"" + iconUrl + "\" class=\"svgIco\" title=\"\" />" + optdata.text + "</span>"); 581 582 return $optdata; 583} 584 585function FormatDefault(optdata) { 586 587 var $optdata = optdata.text; 588 589 return $optdata; 590} 591 592function SaveHistoryState(url) { 593 window.history.pushState({ path: url }, '', url); 594} 595 596function getMomenJSDateFormat(format) 597{ 598 var momentFomat = format.replace(/d/g, 'D').replace(/y/g, 'Y'); 599 600 return momentFomat; 601} 602 603function reclcMinMaxInput(Min, Max, TotalRow) { 604 605 var _min = 0; 606 if (Min != null || Min != "") 607 _min = parseFloat(Min); 608 609 610 var _max = 0; 611 if (Max != null || Max != "") 612 _max = parseFloat(Max); 613 614 if (_min > _max) 615 $(TotalRow).addClass("hasError"); 616 else 617 $(TotalRow).removeClass("hasError"); 618} 619 620function selectElementFromFilter(FromElement, ToElement) { 621 if (FromElement == null || ToElement == null) return; 622 if ($(ToElement).length == 0 || $(FromElement) == 0) return; 623 if ($(ToElement).prop("tagName").toLowerCase() == "input") return; 624 625 var selectedItems = $(FromElement).select2('data'); 626 if (selectedItems != null && selectedItems.length == 1) { 627 if ($(ToElement).find("option[value='" + selectedItems[0].id + "']").length) { 628 $(ToElement).val(selectedItems[0].id).trigger('change'); 629 } else { 630 var newOption = new Option(selectedItems[0].text, selectedItems[0].id, true, true); 631 $(ToElement).append(newOption).trigger('change'); 632 } 633 } 634} 635 636function DisableAllInputFields(container) 637{ 638 container.find("input").prop("disabled", true); 639 container.find("textarea").prop("disabled", true); 640 container.find("select").prop("disabled", true); 641} 642 643function ShowPopUpWithAvailableSurveys() { 644 var roleinf = $(".RoleDescription"); 645 if (roleinf != null && roleinf.text().trim().toLowerCase().startsWith("stud")) { 646 $.ajax({
647 url: '/Layout/GetSurveysList/', 648 beforeSend: function (xhr) { 649 return true; 650 }, // pre-submit callback 651 success: function (result, textStatus, xhr) { 652 var currentPage = window.location.href; 653 654 if (result != "" && !currentPage.includes("survey") && !currentPage.includes("Survey") && !currentPage.includes("SubjectSurvey") && !currentPage.includes("TimeTable")) { 655 var SurveyListModal = $("#SurveyListModal"); 656 SurveyListModal.html(result); 657 SurveyListModal.modal('show'); 658 } 659 //console.log(data); 660 }, 661 type: 'GET', 662 error: function (data) { 663 //hideWait($('#wrap')); 664 //showErrorModal(RES_Validation.GenericErrorMessage); 665 } 666 }); 667 } 668} 669 670function GetSurveysListJs() { 671 var roleinf = $(".RoleDescription"); 672 673 var isStudent = roleinf && roleinf.text().trim().toLowerCase().indexOf("stud") === 0; 674 var isTeacher = roleinf && roleinf.text().trim().toLowerCase().indexOf("lect") === 0; 675 676 if (!isStudent && !isTeacher) { 677 return $.Deferred().resolve("").promise(); 678 } 679 680 return $.ajax({ 681 url: '/Layout/GetSurveysList/', 682 type: 'GET' 683 }); 684} 685 686function ShowSurveyPopUp(result) { 687 var currentPage = window.location.href; 688 if (result != "" && !currentPage.includes("survey") && !currentPage.includes("Survey") && !currentPage.includes("SubjectSurvey") && !currentPage.includes("TimeTable")) { 689 var SurveyListModal = $("#SurveyListModal"); 690 SurveyListModal.html(result); 691 SurveyListModal.modal('show'); 692 } 693} 694 695//Site approval 696//function ShowPortalApprovalForm() { 697// $.ajax({
698// url: '/Approval/GetApprovalForm/', 699// beforeSend: function (xhr) { 700// return true; 701// }, // pre-submit callback 702// success: function (result, textStatus, xhr) { 703// //debugger; 704// if (result != "" && result != null) { 705 706// $modal = $("#ApprovalModal"); 707// var data = result; 708 709// var template = $("#ApprovalModalTemplate").tmpl(data[0]); 710 711// $modal.html(template); 712 713// var modalBody = $("#approvalContent"); 714// modalBody.html(modalBody[0].innerText); 715// $modal.modal('show'); 716 717// $('#submitApprovalBtn').click(function () { 718 719// }); 720// } 721// //console.log(data); 722// }, 723// type: 'GET', 724// error: function (data) { 725// //hideWait($('#wrap')); 726// //showErrorModal(RES_Validation.GenericErrorMessage); 727// } 728// }); 729//} 730 731//function submitApproval(approvalId, approved) { 732// //Send apprId and choise to controller method 733 734 735//} 736
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.