1function toggleMainNav() { 2 if ($('#mv_main_nav').css('left') == '0px') { 3 $('#mv_main_nav').animate({ left: '-100%' }); 4 unlockScroll(); 5 } else { 6 $('#mv_main_nav').animate({ left: '0px' }); 7 lockScroll(); 8 } 9} 10 11function switchMainNav(p_sSection) { 12 if (p_sSection == 'my') { 13 $('#mv_main_nav_my_link').removeClass('border-b').addClass('border-b-2 mv_custom_text mv_custom_border font-semibold'); 14 $('#mv_main_nav_available_link').removeClass('border-b-2 mv_custom_text mv_custom_border font-semibold').addClass('border-b'); 15 16 $('#mv_main_nav_available_content').hide(); 17 $('#mv_main_nav_my_content').show(); 18 } else { 19 $('#mv_main_nav_my_link').removeClass('border-b-2 mv_custom_text mv_custom_border font-semibold').addClass('border-b'); 20 $('#mv_main_nav_available_link').removeClass('border-b').addClass('border-b-2 mv_custom_text mv_custom_border font-semibold'); 21 22 $('#mv_main_nav_available_content').show(); 23 $('#mv_main_nav_my_content').hide(); 24 } 25 26} 27 28function closeAnnouncement() { 29 $('#mv_announcement').slideUp(function() { 30 resizeCleanUp(); 31 }); 32 setCookie('mv_announcement_close', true, 7); 33} 34 35function toggleLeaderboardNav() { 36 if ($('#mv_leaderboard_nav').css('bottom') == '0px') { 37 $('#mv_leaderboard_nav').animate({ bottom: '-200%' }); 38 unlockScroll(); 39 } else { 40 $('#mv_leaderboard_nav').animate({ bottom: '0px' }); 41 lockScroll(); 42 } 43} 44 45function toggleCelebrateNav() { 46 if ($('#mv_celebrate_nav').css('bottom') == '0px') { 47 $('#mv_celebrate_nav').animate({ bottom: '-200%' }); 48 unlockScroll(); 49 } else { 50 $('#mv_celebrate_nav').animate({ bottom: '0px' }); 51 lockScroll(); 52 } 53} 54 55 56function toggleUserNav() { 57 if ($('#mv_user_nav').css('display') == 'block') { 58 $('#mv_user_nav').hide(); 59 } else { 60 $('#mv_user_nav').show(); 61 62 $.ajax({ 63 method: "POST", 64 url: "/products/notifications/clear_notifications" 65 }) 66 .done(function(msg) { 67 $('#mv_notifications_new').hide(); 68 }); 69 } 70} 71 72function toggleTextSize() { 73 if ($('#mv_text_nav').css('display') == 'block') { 74 $('#mv_text_nav').hide(); 75 $('.mv_text_button').removeClass('border-b'); 76 } else { 77 $('#mv_text_nav').show(); 78 $('.mv_text_button').addClass('border-b'); 79 } 80} 81 82function toggleTextSizeMobile() { 83 toggleTextSize(); 84 toggleMainNav(); 85} 86 87function toggleSignup() { 88 if ($('#mv_signup').css('right') == '0px') { 89 $('#mv_signup').animate({ right: '-100%' }); 90 unlockScroll(); 91 } else { 92 $('#mv_signup').animate({ right: '0px' }); 93 lockScroll(); 94 } 95} 96 97function toggleSignupCoupon() { 98 if ($('#mv_signup_coupon').css('display') == 'block') { 99 $('#mv_signup_coupon').hide(); 100 $('#mv_signup_coupon_link').show(); 101 } else { 102 $('#mv_signup_coupon').show(); 103 $('#mv_signup_coupon_link').hide(); 104 } 105} 106 107 108 109function toggleLogin() { 110 if ($('#mv_login').css('right') == '0px') { 111 $('#mv_login').animate({ right: '-100%' }); 112 unlockScroll(); 113 } else { 114 $('#mv_login').animate({ right: '0px' }); 115 lockScroll(); 116 } 117} 118 119function toggleForgot() { 120 if ($('#mv_login').css('right') == '0px') { 121 $('#mv_login').animate({ right: '-100%' }); 122 unlockScroll(); 123 } else { 124 $('#mv_login').animate({ right: '0px' }); 125 toggleLoginForgot(); 126 lockScroll(); 127 } 128} 129 130 131function toggleReset() { 132 if ($('#mv_reset').css('right') == '0px') { 133 $('#mv_reset').animate({ right: '-100%' }); 134 unlockScroll(); 135 } else { 136 $('#mv_reset').animate({ right: '0px' }); 137 lockScroll(); 138 } 139} 140 141function changeTextSize(p_nSize) { 142 $('html').css('fontSize', p_nSize + '%'); 143 $('.mv_text_nav_dot').html('<i class="far fa-circle"></i>'); 144 $('#mv_text_nav_dot_' + p_nSize).html('<i class="far fa-dot-circle"></i>'); 145 146 setCookie('mv_font_size', p_nSize, 30); 147 toggleTextSize(); 148} 149 150/**************** Module Navigation ******************/ 151 152function toggleModuleNav() { 153 if ($('#mv_modules_nav').css('display') == 'block') { 154 $('#mv_modules_nav').hide(); 155 unlockScroll(); 156 } else { 157 $('#mv_modules_nav').show(); 158 lockScroll(); 159 } 160} 161 162function toggleModuleShowLessons(p_nId) { 163 if ($('#mv_modules_lessons_' + p_nId).css('height') == '0px') { 164 var l_sHeight = $('#mv_modules_lessons_container_' + p_nId).height() + 'px'; 165 $('#mv_modules_lessons_' + p_nId).animate({ height: l_sHeight }); 166 $('#mv_modules_lessons_button_' + p_nId).removeClass('fa-angle-down').addClass('fa-angle-up'); 167 } else { 168 $('#mv_modules_lessons_' + p_nId).animate({ height: '0px' }); 169 $('#mv_modules_lessons_button_' + p_nId).removeClass('fa-angle-up').addClass('fa-angle-down'); 170 } 171} 172 173/**************** Lessons Navigation ******************/ 174 175function toggleLessonNav() { 176 if ($('#mv_lessons_nav').css('display') == 'block') { 177 $('#mv_lessons_nav').hide(); 178 unlockScroll(); 179 } else { 180 $('#mv_lessons_nav').show(); 181 lockScroll(); 182 } 183} 184 185 186var g_nCurrentModuleScroll = 0; 187 188function scrollModuleRight() { 189 g_nCurrentModuleScroll++; 190 if (g_nCurrentModuleScroll >= g_nMaxModuleScroll) { 191 g_nCurrentModuleScroll = g_nMaxModuleScroll - 1; 192 return; 193 } 194 195 $('#mv_modules_nav_left').removeClass('opacity-25'); 196 if (g_nCurrentModuleScroll >= (g_nMaxModuleScroll - 1)) { 197 $('#mv_modules_nav_right').addClass('opacity-25'); 198 } 199 200 var l_nWidth = $('#mv_modules_nav_items .float-left').first().width(); 201 var l_nScrollTo = (g_nCurrentModuleScroll * l_nWidth) + (16 * g_nCurrentModuleScroll); 202 203 $('#mv_modules_nav_items').animate({ 204 scrollLeft: l_nScrollTo 205 }); 206} 207 208function scrollModuleLeft() { 209 g_nCurrentModuleScroll--; 210 if (g_nCurrentModuleScroll < 0) { 211 g_nCurrentModuleScroll = 0; 212 return; 213 } 214 215 $('#mv_modules_nav_right').removeClass('opacity-25'); 216 if (g_nCurrentModuleScroll < 1) { 217 $('#mv_modules_nav_left').addClass('opacity-25'); 218 } 219 220 var l_nWidth = $('#mv_modules_nav_items .float-left').first().width(); 221 var l_nScrollTo = (g_nCurrentModuleScroll * l_nWidth) + (16 * g_nCurrentModuleScroll); 222 223 $('#mv_modules_nav_items').animate({ 224 scrollLeft: l_nScrollTo 225 }); 226} 227 228 229function lockScroll() { 230 // Fade in the cover overlay and disable page scrolling 231 $('#mv_cover').fadeIn(function() { 232 // Set overflow to hidden after fade completes 233 $('html, body').css('overflow', 'hidden'); 234 }); 235} 236 237function unlockScroll() { 238 // Fade out the cover overlay and re-enable page scrolling 239 $('#mv_cover').fadeOut(function() { 240 // Restore scrolling after fade completes 241 $('html, body').css('overflow', 'auto'); 242 }); 243} 244 245function update_ep() { 246 $.ajax({ 247 method: "POST", 248 url: "/products/profile/ep" 249 }) 250 .done(function(msg) { 251 var l_nOldTotal = $('#g_EpTotal').html(); 252 var l_nEp = msg; 253 254 if (l_nEp != l_nOldTotal) { 255 //$('#g_EpTotal').html( l_nEp ); 256 //$('#ep_total_button').removeClass('label-success').addClass('label-danger').switchClass( 'label-danger', 'label-success', 1500 ); 257 } 258 }); 259} 260 261 262/**************** Quiz Stuff ******************/ 263 264function addToQuiz(p_nQuestionId, p_sAnswer) { 265 console.log(p_nQuestionId); 266 console.log(p_sAnswer); 267 $.ajax({ 268 method: "POST", 269 url: "/products/lessons/add_quiz", 270 data: { question_id: p_nQuestionId, answer: p_sAnswer } 271 }) 272 .done(function(p_xReturn) { 273 $('#question_new_followup_' + p_nQuestionId).val(''); 274 $('#question_quiz_temp_' + p_nQuestionId).append('<div class="inline-block essay w-full border rounded-lg p-4 text-gray-800 text-left whitespace-pre-line bg-white">' + p_sAnswer + '</div>'); 275 $('#question_quiz_temp_' + p_nQuestionId).append('<div class="row text-right italic mb-4">(answered just now)</div>'); 276 }); 277} 278 279function addToQuestions(p_nLessonId, p_nAnswerId, l_sAnswer) { 280 $.ajax({ 281 method: "POST", 282 url: "/products/lessons/add_answer", 283 data: { lesson_id: p_nLessonId, quiz_answers_id: p_nAnswerId, answer: l_sAnswer } 284 }) 285 .done(function(p_xReturn) { 286 $('#question_followup_' + p_nAnswerId).val(''); 287 $('#question_replies_temp_' + p_nAnswerId).append('<div class="inline-block essay w-full border rounded-lg p-4 text-gray-800 text-left whitespace-pre-line bg-white">' + l_sAnswer + '</div>'); 288 $('#question_replies_temp_' + p_nAnswerId).append('<div class="row text-right italic mb-4">(replied just now)</div>'); 289 }); 290 291} 292 293function saveQuestions(p_nLessonId, l_axQuestions) { 294 295 $.each(l_axQuestions, function(key, value) { 296 if ($('.' + key).hasClass('multi')) { 297 var temp = []; 298 $('.' + key + ':checked').each(function(i) { 299 temp[i] = $(this).val(); 300 }); 301 l_axQuestions[key] = temp; 302 } else { 303 l_axQuestions[key] = $('.' + key).val(); 304 } 305 }); 306 307 $.ajax({ 308 method: "POST", 309 url: "/products/lessons/save_quiz", 310 data: { lesson_id: p_nLessonId, questions: l_axQuestions } 311 }) 312 .done(function(p_xReturn) { 313 alert("Save Complete"); 314 }); 315} 316 317function checkQuestions(p_nLessonId, l_axQuestions, p_sLink) { 318 319 $.each(l_axQuestions, function(key, value) { 320 if ($('.' + key).hasClass('multi')) { 321 var temp = [] 322 $('.' + key + ':checked').each(function(i) { 323 temp[i] = $(this).val(); 324 }); 325 l_axQuestions[key] = temp; 326 } else { 327 l_axQuestions[key] = $('.' + key).val(); 328 } 329 }); 330 331 console.log(l_axQuestions); 332 333 $.ajax({ 334 method: "POST", 335 url: "/products/lessons/check_quiz", 336 data: { lesson_id: p_nLessonId, questions: l_axQuestions } 337 }) 338 .done(function(p_xReturn) { 339 $('.text-red-800').removeClass('text-red-800'); 340 $('.mv_question_title .fa-times').hide(); 341 342 var l_xJson = JSON.parse(p_xReturn); 343 if (l_xJson.incorrect.length > 0) { 344 $.each(l_xJson.incorrect, function(key, value) { 345 $('#question_title_' + value).addClass('text-red-800'); 346 $('#question_mark_' + value).addClass('fas'); 347 $('#question_mark_' + value).addClass('fa-times'); 348 349 $('#question_title_' + value + ' .fa-times').show(); 350 }); 351 $('.question_' + l_xJson.incorrect[0]).focus(); 352 errorAlert("Some questions were incorrect or not filled out. Please correct questions in red and resubmit."); 353 } else { 354 markAsComplete(p_nLessonId, p_sLink); 355 } 356 }); 357} 358 359function markAsComplete(p_nLessonId, p_sLink) { 360 $.ajax({ 361 method: "POST", 362 url: "/products/lessons/mark", 363 data: { lesson_id: p_nLessonId } 364 }) 365 .done(function(msg) { 366 if (p_sLink) { 367 window.location = p_sLink; 368 } else { 369 window.location = '/products'; 370 } 371 }); 372} 373 374 375/**************** General ******************/ 376 377 378function cleanEmail(email) { 379 var l_sCleanEmail = String(email).toLowerCase(); 380 return l_sCleanEmail.replace(/\s+/g, ''); 381} 382 383function validateEmail(email) { 384 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 385 return re.test(String(email).toLowerCase()); 386} 387 388function numberWithCommas(x) { 389 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); 390} 391 392function setCookie(cname, cvalue, exdays) { 393 var d = new Date(); 394 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 395 var expires = 'expires=' + d.toUTCString(); 396 document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'; 397} 398 399function getCookie(cname) { 400 var name = cname + '='; 401 var decodedCookie = decodeURIComponent(document.cookie); 402 var ca = decodedCookie.split(';'); 403 for (var i = 0; i < ca.length; i++) { 404 var c = ca[i]; 405 while (c.charAt(0) == ' ') { 406 c = c.substring(1); 407 } 408 if (c.indexOf(name) == 0) { 409 return c.substring(name.length, c.length); 410 } 411 } 412 return ''; 413} 414 415function masonryGrid(p_xGrid) { 416 let l_nRowHeight = 20; 417 let l_nRowGap = parseInt($(p_xGrid).css('grid-row-gap')); 418 419 $(p_xGrid).css('grid-auto-rows', l_nRowHeight + 'px'); 420 $(p_xGrid).children().each(function() { 421 let l_xContent = $(this).children()[0]; 422 let l_nHeight = $(l_xContent).height(); 423 let l_nRowSpan = Math.ceil((l_nHeight + l_nRowGap) / (l_nRowHeight + l_nRowGap)); 424 425 $(this).css('grid-row-end', 'span ' + l_nRowSpan); 426 }); 427} 428 429function resizeAllGridItems() { 430 $(".mv_product_list").each(function() { 431 masonryGrid(this); 432 }); 433} 434 435async function copyToClipboard(textToCopy) { 436 // Navigator clipboard api needs a secure context (https) 437 if (navigator.clipboard && window.isSecureContext) { 438 await navigator.clipboard.writeText(textToCopy); 439 } else { 440 // Use the 'out of viewport hidden text area' trick 441 const textArea = document.createElement("textarea"); 442 textArea.value = textToCopy; 443 444 // Move textarea out of the viewport so it's not visible 445 textArea.style.position = "absolute"; 446 textArea.style.left = "-999999px"; 447 448 document.body.prepend(textArea); 449 textArea.select(); 450 451 try { 452 document.execCommand('copy'); 453 } catch (error) { 454 console.error(error); 455 } finally { 456 textArea.remove(); 457 } 458 } 459} 460 461 462/**************** On Load ******************/ 463 464 465function resizeCleanUp() { 466 if (g_bAnnouncementStatus) { 467 $('#mv_welcome_area_padding').height($('header').height()); 468 } 469 470 $(".mv_search_box").on('focus', function() { 471 //$( '.mv_search_box' ).removeClass('opacity-50').addClass('opacity-100'); 472 $('.mv_search_button').show(); 473 $('.js_product_category').hide(); 474 }); 475 476 if (!g_bProductUniform) { 477 resizeAllGridItems(); 478 setTimeout(function() { resizeAllGridItems(); }, 1000); 479 setTimeout(function() { resizeAllGridItems(); }, 2000); 480 } 481 482} 483 484$(window).on("load", function() { 485 $(".js_clean_email").change(function() { 486 $(this).val(cleanEmail($(this).val())); 487 }); 488 489 490 $(".js_product_category").change(function() { 491 window.location = '/products/switch/category/' + $(this).val(); 492 }); 493 494 $(".js_module_dropdown").change(function() { 495 var val = $(this).val(); 496 497 if (val.indexOf("c-") === 0) { // or use val.startsWith("c-") if supported 498 window.location = '/products/community/view/' + val.substring(2); 499 } else { 500 window.location = '/products/units/view/' + val; 501 } 502 }); 503 504 resizeCleanUp(); 505}); 506 507$(window).resize(function() { 508 resizeCleanUp(); 509}); 510 511function errorAlert(message, title = 'Error') { 512 Swal.fire({ 513 titleText: title, 514 icon: 'error', 515 html: message 516 }); 517} 518 519function toggleProfileMenu() { 520 $('#mv_profile_menu').slideToggle(); 521 522 $.ajax({ 523 method: "POST", 524 url: "/admin/notifications/clear_notifications" 525 }) 526 .done(function(msg) { 527 $('#mv_notifications_new').hide(); 528 }); 529} 530 531
532/**************** Community VueJS ******************/ 533 534Vue.directive('click-outside', { 535 bind: function(el, binding, vnode) { 536 el.clickOutsideEvent = function(event) { 537 // here I check that click was outside the el and his children 538 if (!(el == event.target || el.contains(event.target))) { 539 // and if it did, call method provided in attribute value 540 vnode.context[binding.expression](event); 541 } 542 }; 543 document.body.addEventListener('click', el.clickOutsideEvent) 544 }, 545 unbind: function(el) { 546 document.body.removeEventListener('click', el.clickOutsideEvent) 547 }, 548});
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.