1 2console.log("%cWeb on Demand - 2023", "color:#80c745; font-size:40px;"); 3 4console.log("%cAjax1.js", "color:#FF8F1C; font-size:20px;"); 5 6 7 8function ResizeFrame(id) { 9 10 console.log("ResizeFrame"); 11 12 var Frame = document.getElementById(id); 13 var H = Frame.contentWindow.document.body.scrollHeight; 14 console.log('ResizeFrame: ' + H); 15 if (H > 0 ) { 16 //H = H + 100; 17 Frame.style.height = H + 'px'; 18 }; 19 20} 21 22function SpaceItems() { 23 24 //console.log("SpaceItems") 25 26 var viewportWidth = window.innerWidth; 27 //alert(viewportWidth); //320px 28 29 $(".ItemSpacer").each(function() { 30 31 var NumberofItems = $(this).attr("data-itemcount") || 5; 32 if (NumberofItems == 0) { 33 NumberofItems = 5; 34 } 35 var GapSize = $(this).attr("data-gap") || 10; 36 var Justify = $(this).attr("data-justify") || "start"; 37 38 var NumberofSpaces = NumberofItems - 1; 39 var GapWidth = (NumberofSpaces * GapSize) / NumberofItems; 40 41 // Build base CSS props 42 var cssProps = { 43 "display": "flex", 44 "flex-wrap": "wrap", 45 "justify-content": Justify, 46 "gap": GapSize + "px" 47 }; 48 49 // If it also has WOD_FormRowV2, set margin-bottom 50 if ($(this).hasClass("WOD_FormRowV2")) { 51 cssProps["margin-bottom"] = GapSize + "px"; 52 } 53 54 // Apply styles to the spacer 55 $(this).css(cssProps); 56 57 // Style each child item 58 $(this).find(".SpacedItem").each(function() { 59 60 //var viewportWidth = window.innerWidth; 61 var Grow = $(this).attr("data-grow") || 0; 62 var ItemWidth = $(this).attr("data-itemwidth") || 100 / NumberofItems; 63 64 //console.log("ItemWidth: " + ItemWidth);
65 66 if (viewportWidth > 575.98) { 67 //alert(ItemWidth); 68 $(this).css({ 69 "flex": Grow + " 1 calc( (" + ItemWidth + "% - " + GapWidth + "px) )" 70 }); 71 } else { 72 $(this).css({ 73 "flex": "0 1 100%" 74 }); 75 } 76 77 }); 78 }); 79} 80 81function SpaceItemsV1() { 82 83 //console.log("SpaceItemsV1") 84 85 $(".ItemSpacer").each(function() { 86 87 var NumberofItems = $(this).attr("data-itemcount") || 5; 88 if (NumberofItems==0) {NumberofItems=5} 89 var GapSize = $(this).attr("data-gap") || 10; 90 var Justify = $(this).attr("data-justify") || "start"; 91 92 var NumberofSpaces = NumberofItems-1; 93 var GapWidth = NumberofSpaces * GapSize; 94 95 $(this).css({ 96 "display": "flex", 97 "flex-wrap": "wrap", 98 "justify-content": Justify, 99 "gap": GapSize+"px" 100 }); 101 102 $(this).find(".SpacedItem").each(function() { 103 // Do something with each 'yyy' child element, like changing text 104 //$(this).text("Updated Child"); 105 106 let viewportWidth = window.innerWidth; 107 var Grow = $(this).attr("data-grow") || 0; 108 109 if (viewportWidth > 575.98) { 110 111 $(this).css({ 112 "flex": ""+Grow+" 1 calc((100% - "+GapWidth+"px) / "+NumberofItems+")" 113 }); 114 115 } else { 116 117 $(this).css({ 118 "flex": "0 1 100%" 119 }); 120 121 } 122 123 }); 124 125 }); 126 127 128} 129 130 131window.addEventListener("resize", function() { 132 133 SpaceItems(); 134 135}); 136 137 138document.addEventListener("DOMContentLoaded", function() { 139 140 //console.log("ItemSpacer"); 141 142 143 SpaceItems(); 144 145 146 try{ 147 148 document.querySelector(".SysModal_Terms_Open").addEventListener("click", () => { document.querySelector("#SysModal_Terms").showModal()}); 149 document.querySelector(".SysModal_Terms_Close").addEventListener("click", () => { document.querySelector("#SysModal_Terms").close()}); 150 151 document.querySelector(".SysModal_Privacy_Open").addEventListener("click", () => { document.querySelector("#SysModal_Privacy").showModal()}); 152 document.querySelector(".SysModal_Privacy_Close").addEventListener("click", () => { document.querySelector("#SysModal_Privacy").close()}); 153 154 } catch(err) {}; 155 156}); 157 158function OpenEditIframeB(SMD, file) 159{ 160 161 var AdminDialog = document.getElementById("AdminDialog") 162 163 if(AdminDialog==null) { 164 165 AdminDialog = document.createElement("dialog"); 166 AdminDialog.id = "AdminDialog"; 167 AdminDialog.style.height = "100%"; 168 AdminDialog.style.width = "100%"; 169 AdminDialog.style.maxWidth = "1080px"; 170 AdminDialog.style.overflow = "hidden"; 171 AdminDialog.style.padding = "0"; 172 document.body.appendChild(AdminDialog); 173 174 } 175 176 AdminDialog.innerHTML = "<iframe width='100%' height='100%' id='DialogBoxiframe' allowtransparency='true' src='"+file+"?"+SMD+"'></iframe>"; 177 AdminDialog.showModal(); 178 179} 180 181const audioElement = new Audio(); 182let currentIndex = 0; 183let isPlaying = false 184let isPause = false; 185 186function playAudioSequence(audioFiles) { 187 188 if (isPause) { 189 console.log('Audio is Pause.'); 190 isPause = false; 191 resumeAudio(); 192 return; 193 } 194 195 if (isPlaying) { 196 console.log('Audio is already playing.'); 197 return; 198 } 199 200 isPlaying = true; 201 202 audioElement.src = audioFiles[currentIndex]; 203 audioElement.play().catch(error => { 204 console.error('Audio playback error:', error); 205 isPlaying = false; 206 }); 207 208 audioElement.addEventListener('ended', playNextAudio); 209} 210 211function playNextAudio() { 212 currentIndex++; 213 if (currentIndex < audioFiles.length) { 214 audioElement.src = audioFiles[currentIndex]; 215 audioElement.play().catch(error => { 216 console.error('Audio playback error:', error); 217 isPlaying = false; 218 }); 219 isPlaying = true; 220 } else { 221 currentIndex = 0; 222 isPlaying = false; 223 } 224} 225 226function pauseAudio() { 227 if (isPlaying) { 228 audioElement.pause(); 229 isPlaying = false; 230 isPause = true; 231 } 232} 233 234function stopAudio() { 235 if (isPlaying) { 236 audioElement.pause(); 237 audioElement.currentTime = 0; 238 isPlaying = false; 239 } 240} 241 242function resumeAudio() { 243 if (!isPlaying) { 244 audioElement.play().catch(error => { 245 console.error('Audio playback error:', error); 246 isPlaying = false; 247 });
248 isPlaying = true; 249 } 250} 251 252//function playAudioSequence(audioFiles) { 253// let CurrentAudioIndex = 0; 254// const audioElement = new Audio(); 255// 256// audioElement.addEventListener('error', (event) => { 257// console.error(`Error loading ${audioFiles[CurrentAudioIndex]}`); 258// CurrentAudioIndex++; 259// if (CurrentAudioIndex < audioFiles.length) { 260// audioElement.src = audioFiles[CurrentAudioIndex]; 261// audioElement.play().catch(error => { 262// console.error('Audio playback error:', error); 263// }); 264// } else { 265// CurrentAudioIndex = 0; // Reset to the beginning if all files are played 266// } 267// }); 268// 269// audioElement.addEventListener('ended', () => { 270// CurrentAudioIndex++; 271// if (CurrentAudioIndex < audioFiles.length) { 272// audioElement.src = audioFiles[CurrentAudioIndex]; 273// audioElement.play().catch(error => { 274// console.error('Audio playback error:', error); 275// }); 276// } else { 277// CurrentAudioIndex = 0; // Reset to the beginning if all files are played 278// } 279// }); 280// 281// audioElement.src = audioFiles[CurrentAudioIndex]; 282// audioElement.play().catch(error => { 283// console.error('Audio playback error:', error); 284// }); 285//} 286 287 288 289//var GoogleFAQSchema = []; 290
291//Add to reference if Ajax1 not used 292function docReady(fn) { 293 // see if DOM is already available 294 if (document.readyState === "complete" || document.readyState === "interactive") { 295 // call on next available tick 296 setTimeout(fn, 1); 297 } else { 298 document.addEventListener("DOMContentLoaded", fn); 299 } 300} 301 302var Page3 = decodeURI(window.location.href) + ''; 303var EventVer3 = 'Sys<br>'; 304 305var EventInfo3 = EventVer3 + '<a href="' + Page3 + '" target="_blank">' + Page3 + '</a><br>' ; 306 307//window.addEventListener("error", function (myevnt) { 308// 309// 310// var Vars = checkOS2(navigator); //navigator.userAgentData; //navigator.appVersion 311// 312// var t = ""; 313// 314// try{ 315// t = myevnt.error.stack 316// } catch(err) { 317// t = myevnt.message 318// } 319// 320// var EventInfo2 = EventInfo3 + Vars + '<br><br>' + 'Event: `'+myevnt.type+'`<br>'+t+'<br>'; //myevnt.target.className 321// 322// //console.log(EventInfo); 323// Poll('/Tools/LogErrors.aspx', 'MyEvent=' + EventInfo2, '', '', '', 0); 324// return false; 325// 326//}) 327 328function checkOS2(n) { 329 330 if (n.userAgentData) { 331 return n.userAgentData.platform + " - " + n.userAgentData.brands[0].brand + " " + n.userAgentData.brands[0].version; 332 } else { 333 return n.userAgent; //"navigator.userAgentData is not supported!"; 334 } 335} 336 337 338 339 340// const formatter = new Intl.NumberFormat('en-US', { 341// style: 'currency', 342// currency: Currency, 343// minimumFractionDigits: 2 344// }) 345 const formatter2 = new Intl.NumberFormat('en-US', { 346 minimumFractionDigits: 0 347 }) 348 349 350var contacts; 351var cont; 352 353function UpdateItemsPriceRange(){ 354 355 356 357 var f = cont.first() 358 359 var min = parseInt(f.data('price')); 360 var max = parseInt(f.data('price')); 361 362 cont.each(function() { 363 var p = parseInt( $(this).data('price')); 364 if(p < min) {min = p}; 365 if(p > max) {max = p}; 366 }); 367 368 $( "#slider-range" ).slider("option", "min", min); 369 $( "#slider-range" ).slider("option", "max", max); 370 $( "#slider-range" ).slider("values", min, max); 371 372 373} 374 375 376var SortTogel = false; 377 378function SortItemSet(id){ 379 380 SortTogel = !SortTogel; 381 382 //var contacts = $('div.clist'), cont = contacts.children($('div.clist').data('elm')); 383 384 cont.detach().sort(function(a, b) { 385 386 var astts; 387 var bstts; 388 389 var r = parseInt($(a).data(id)); 390 391 if(r > 0){ 392 astts = parseInt($(a).data(id)); 393 bstts = parseInt($(b).data(id)); 394 } else { 395 astts = $(a).data(id); 396 bstts = $(b).data(id); 397 }; 398 399 if (SortTogel) { 400 return (astts > bstts) ? (astts > bstts) ? 1 : 0 : -1; 401 } else { 402 return (astts < bstts) ? (astts < bstts) ? 1 : 0 : -1; 403 } 404 }); 405 406 contacts.append(cont); 407} 408 409 410//(function() { 411//$( document ). ready(function() { 412docReady(function() { 413 414 AfterLoad(); 415 416// for (var i = 0; i < GoogleFAQSchema.length; i++){ 417// 418// // 419// 420// } 421 422 //var GFAQ = {"@context": "https://schema.org","@type": "FAQPage","mainEntity": [GoogleFAQSchema]} 423 //console.log(GFAQ); 424 425 try{ 426 427 contacts = $('div.clist') 428 cont = contacts.children($('div.clist').data('elm')) 429 430 $( "#slider-range" ).slider({ 431 range: true, 432 min: 1, 433 max: 10000000, 434 values: [ 1, 10000000 ], 435 436 change: function( event, ui ) { 437 438 // $( "#minPrice" ).val(ui.values[0]); 439 // $( "#maxPrice" ).val(ui.values[1]); 440 $( "#amount" ).val( "" + CurrencySign + formatter2.format($( "#slider-range" ).slider( "values", 0 )) + " - " + CurrencySign + formatter2.format($( "#slider-range" ).slider( "values", 1 )) ); 441 442 443 }, 444 445 slide: function( event, ui ) { 446 $( "#amount" ).val( "" + CurrencySign + formatter2.format(ui.values[ 0 ]) + " - " + CurrencySign + formatter2.format(ui.values[ 1 ]) ); 447 448 cont.each(function() { 449 $(this).hide() 450 var p = parseInt( $(this).data('price')); 451 if(p >= ui.values[ 0 ] && p <= ui.values[ 1 ]) {$(this).show()}; 452 }); 453 454 } 455 456 457 }); 458 // $( "#minPrice" ).val( $( "#slider-range" ).slider( "values", 0 ) ); 459 // $( "#maxPrice" ).val( $( "#slider-range" ).slider( "values", 1 ) ); 460 // $( "#amount" ).val( "$" + formatter2.format($( "#slider-range" ).slider( "values", 0 )) + " - $" + formatter2.format($( "#slider-range" ).slider( "values", 1 )) ); 461 462 463 464 465 UpdateItemsPriceRange() 466 467 468 469 $(".Sort").click(function(){ 470 SortItemSet($(this).data('id')); 471 }) 472 473 } catch(err) {}; 474 475 }); 476 477//}); 478 479 480 481//$( document ). ready(function() { 482// 483// console.log("RenderItems"); 484// RenderItems ("ItemSet_10003") 485// 486//}); 487
488function RenderItems (d) { 489 490 console.log("RenderItems "+d); 491 492 var output = ""; 493 494 for (var i = 0; i < eval("JsonItemSet_"+d).length; i++){ 495 496 var obj = eval("JsonItemSet_"+d)[i]; 497 var t = eval("ItemLayout_"+d); 498 499 var ItemCollection = obj.B //ItemCollection 500 var CurrentItem = obj.C //CurrentItem 501 var UniqueIdentifier = ItemCollection + "_" + CurrentItem 502 503 //console.log(UniqueIdentifier); 504 505 t = MyReplace(t, "`", "'") 506 t = MyReplace(t, "##Admin##", "") 507 t = MyReplace(t, "##SI_On_CurrentPage##", obj.A) //SI_On_CurrentPage 508 t = MyReplace(t, "##ShowOptions##", "") //ShowOptions 509 t = MyReplace(t, "##UniqueIdentifier##", UniqueIdentifier) 510 t = MyReplace(t, "##Discount##", "") 511 t = MyReplace(t, "Editable_", "") 512 513 for (var key in obj){ 514 515 var value = obj[key]; 516 517 t = MyReplace(t, "##" + key + "##", value) 518 t = MyReplace(t, "{{" + key + "}}", value) 519 520 //document.write("<br> - " + "##" + key + "##" + ": " + value); 521 } 522 523 //document.write(t); 524 525 output = output + t 526 527 } 528 529 document.getElementById("ItemSet_"+d).parentElement.innerHTML = output 530 531} 532 533 534function MyReplace (v, a, b) { 535 536 var searchMask = a; 537 var regEx = new RegExp(searchMask, "ig"); 538 var replaceMask = b; 539 540 var result = v.replace(regEx, replaceMask); 541 return result 542 543} 544 545 546function isOnScreen(elem) { 547 // if the element doesn't exist, abort 548 if( elem.length == 0 ) { 549 return; 550 } 551 var $window = jQuery(window) 552 var viewport_top = $window.scrollTop() 553 var viewport_height = $window.height() 554 var viewport_bottom = viewport_top + viewport_height 555 var $elem = jQuery(elem) 556 var top = $elem.offset().top 557 var height = $elem.height() 558 var bottom = top + height 559 560 return (top >= viewport_top && top < viewport_bottom) || 561 (bottom > viewport_top && bottom <= viewport_bottom) || 562 (height > viewport_height && top <= viewport_top && bottom >= viewport_bottom) 563} 564 565//jQuery( document ). ready( function() { 566// window.addEventListener('scroll', function(e) { 567// 568// $('img').not(".ItemControlPanel").each(function(){ 569// 570// if( isOnScreen($(this))) { /* Pass element id/class you want to check */ 571// ImageisVisable($(this)) 572// } 573// 574// }); 575// }); 576//}); 577 578//$('img.lazy').on('appear',function(){ 579// console.log(this)//fires this function when it appears 580// ImageisVisable($(this)) 581//}); 582 583function ImageisVisable(elem) { 584 585 var imgsrcXXX = elem.attr("src") 586 var imgsrcorg = elem.attr("data-wodsrc") //src 587 588 console.log( elem ); 589 590 if (imgsrcorg && imgsrcorg.toLowerCase().indexOf("tm-")==-1 && imgsrcorg.toLowerCase().indexOf("http")==-1 && imgsrcorg.toLowerCase().indexOf(".svg")==-1 && imgsrcorg.indexOf("/Sites/")>-1){ 591 592 //console.log(""); 593 imgsrc = imgsrcorg 594 595 var width = elem.width(); 596 var height = elem.height(); 597 598 var attrwidth = elem["0"].width //elem.attr('width'); 599 var attrheight = elem["0"].height //elem.attr('height'); 600 601 var naturalWidth = elem["0"].naturalWidth; 602 var naturalHeight = elem["0"].naturalHeight; 603 604 //console.log("width: " + width); 605 //console.log("height: " + height); 606 607 if (width > 0 || height > 0) { 608 //Keep 609 //console.log("By width/height"); 610 } else { 611 console.log("By Original"); 612 elem.attr("src",imgsrcorg); 613 return; 614 } 615 616 if (width > 1600){width = 1920} else if (width > 1200) {width = 1600} else if (width > 800) {width = 1200} else if (width > 400) {width = 800} else if (width > 2) {width = 400} else {width = 1} 617 if (height > 1600){height = 1920} else if (height > 1200) {height = 1600} else if (height > 800) {height = 1200} else if (height > 400) {height = 800} else if (height > 2) {height = 400} else {height = 1} 618 619 var a = imgsrc.split("/"); 620 var Name = a[a.length-1]; 621 var Path = ""; 622 623 a.forEach( 624 function(element, index) { 625 if (index < a.length -1 && element != ""){Path = Path + "/" + element}; 626 } 627 ); 628
629 Path = Path.replace("/https:", "https:/") 630 Path = Path.replace("/http:", "http:/") 631 Path = Path.replace("/dwp5n41rsfk7g.cloudfront.net", "//dwp5n41rsfk7g.cloudfront.net") 632 var src = Path+"/"+"tm-"+width+"X"+height+"_"+Name 633 elem.attr("src",src); 634 635 } 636 637}; 638 639 640 641 642 643function sb(Form) { 644 645 console.log(Form); 646 647 Poll('', '', '/SendSystemMail_IC.aspx', 'Phantom_FormID=ww###and###Phantom_SiteID=1###and###Phantom_Thanks=Debug###and###Phantom_FormName=###and###Phantom_DB=0###and###Phantom_Subject=Debug###and###Phantom_IC=10004', "", false); 648 649 /////////////////////////////Poll('', '', '/SendSystemMail_IC.aspx', 'Phantom_FormID=2###and###Phantom_SiteID=2050###and###Phantom_Thanks=Thank you! We will be in touch shortly.###and###Phantom_FormName=CTA Form###and###Phantom_DB=0###and###Phantom_Subject=CTA Form###and###Phantom_IC=10004' + GetFormValues(Form), document.getElementById('res'), false); 650 //Poll('', '', '/robots.txt', '', document.getElementById('res'), true); 651 652} 653 654document.addEventListener("keyup", LogIn); 655 656function LogIn(event){ 657 658 event.preventDefault(); 659 660 if (event.which == 76 && event.altKey) { 661 location='/login.aspx'; return false; 662 } 663 664} 665 666 667function GetSearchRes(SearchPhrase, Phantom_smd, SearchBoxFile, SearchBoxDiv){ 668 669 //$('#WOD_SearchModal').modal('show'); 670 $('#WOD_ModalSearchResults').dialog({ autoOpen: true, maximized:false, minimized:true }); 671 $.ajax({method:"POST", data: { SearchPhrase: SearchPhrase, Phantom_smd: Phantom_smd }, url: SearchBoxFile, success: function(result){$("#"+SearchBoxDiv).html(result)}}) 672 673} 674 675 676 677 678 679 680 function PaginatedPageChanged(){ 681 if (CanRefreshCart) { 682 console.log("PaginatedPageChanged, IniCart()"); 683 try{IniCart()} catch(err) {}; 684 } 685 } 686 687 688 689 function UpdateCartItemCount(){ 690 var x = 0; 691 for (var i = 0; i < localStorage.length; i++){ 692 var Key = localStorage.key(i); 693 if (Key.indexOf("CartItem_")>-1 && Key.indexOf("_Count")==-1 && Key.indexOf("_Name")==-1 && Key.indexOf("_Img")==-1 && Key.indexOf("_Discount")==-1 && Key.indexOf("_Quantity")==-1 && Key.indexOf("_Weight")==-1 && Key.indexOf("_ShippedFrom")==-1 ) { 694 x = x + 1; 695 }; 696 $("#CartItemCount").html(x); 697 } 698 } 699 function UpdateWishListItemCount(){ 700 var x = 0; 701 for (var i = 0; i < localStorage.length; i++){ 702 var Key = localStorage.key(i); 703 if (Key.indexOf("WishListItem_")>-1 && Key.indexOf("_Count")==-1 && Key.indexOf("_Name")==-1 && Key.indexOf("_Img")==-1 && Key.indexOf("_Discount")==-1 && Key.indexOf("_Quantity")==-1 && Key.indexOf("_Weight")==-1 && Key.indexOf("_ShippedFrom")==-1 ) { 704 x = x + 1; 705 }; 706 $("#WishListItemCount").html(x); 707 } 708 } 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725//$(document).on('ready', function () { 726 727//(function() { 728//$( document ). ready(function() { 729 730 //Not Working 731 732function AfterLoad() 733{ 734 735 736 737 738// UpdateCartItemCount(); 739// UpdateWishListItemCount() 740 741// if (localStorage.getItem("Cookie")!="Set") { 742// console.log("Cookie Not Set.") 743// $("#SetCookieDiv").css( "display", "block" ); 744// } else { 745// console.log("Cookie Set.") 746// $("#SetCookieDiv").css( "display", "none" ); 747// }; 748// 749// $("#SetCookie").click(function() { 750// 751// localStorage.setItem("Cookie" , "Set"); 752// $("#SetCookieDiv").css( "display", "none" ); 753// console.log("Cookie Set.") 754// 755// }); 756 757// $(".adthumbnail").click(function() { 758// 759// $("#AdFrames").attr('src', "/AdGenerator/AdFrames2.aspx?Style=" + $(this).attr("id")) 760// $("#AdName").html("" + $(this).attr("name")) 761// $("#adgeneratorad").attr('style', "width:180px;height:460px;border:none;display:block;") 762// 763// }); 764 765 766// $.HSCore.components.HSDropdown.init($('[data-dropdown-target]'), { 767// afterOpen: function(){ 768// $(this).find('input[type="search"]').focus(); 769// }}); 770 771 772 773 function showPosition(position) { 774 console.log("Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude); 775 } 776 777 778// $( "#WOD_SearchPhrase + input" ).click(function() { 779// $('#WOD_SearchModal').modal('show') 780// }); 781 782} 783 784//}); 785 786 787function WOD_Search(MyCode, SearchPhrase, xTempSpan) 788{ 789 790} 791 792 793function MyTrim(Str, Deli) { 794 795 while (Str.substr(Str.length-1, 1) == Deli){Str=Str.substr(0, Str.length-1)}; 796 while (Str.substr(0, 1) == Deli){Str=Str.substr(1, Str.length-1)}; 797 798 return Str 799} 800 801var ActualSiteFolder = ""; 802 803function GetDropzonePublic(Field, Mode) { 804 805 //var MainDZ1 = 'MainDZ_'+Field; 806 var MainDZ1 = Field; 807 808 console.log("GetDropzonePublic"); 809 //console.log($(MainDZ1).dropzone); 810 811 try { 812 813 console.log("New Dropzone FUMode:" + Mode); 814 815 var myDropzonePublic = new Dropzone("input#" + MainDZ1, { 816 url: "/SWFUpload/upload.aspx?FUMode=" + Mode, 817 init: function() { 818 819 this.on("complete", function(file) { 820 821 console.log("GetDropzonePublic: "+file.name); 822 823 if (Mode == "UserPic") { 824 document.getElementById(Field).value = file.name; 825 } else if (Mode == "PageLayout") { 826 827 console.log("PageLayout complete: " + file.name) 828 829 $.ajax({method:"GET", url: "/Sites/" + ActualSiteFolder + "/Root/Web/Images/PageLayout/" + file.name, success: function(result){ 830 831 //console.log("PageLayout complete: " + result ) 832 document.getElementById('Layout').value = result; 833 FixPaths(`Layout`,`JS`); 834 835 }}
835); 836 837 } else if (Mode == "CallBack") { 838 839 let CallBack = Field; 840 841 if (typeof window[CallBack] === 'function') { 842 // Run the function programmatically using the variable 843 //////window[CallBack]("/Sites/" + ActualSiteFolder + "/Root/Web/Images/CallBack/" + file.name); 844 window[CallBack]("/CallBack/" + file.name); 845 } else { 846 //console.log(`Function ${CallBack} not found.`); 847 } 848 849 } else { 850 document.getElementById(Field).value = document.getElementById(Field).value + "," + file.name; 851 } 852 }); 853 this.on("queuecomplete", function(file) { 854 document.getElementById(Field).value = MyTrim(document.getElementById(Field).value, ","); 855 }); 856 }, 857 clickable: true, 858 resizeWidth: 800, 859 acceptedFiles: ".css,.doc,.docx,.eml,.eot,.gif,.html,.jfif,.jpeg,.jpf,.jpg,.js,.jsf,.less,.mov,.mp3,.mp4,.m4a,.mpeg,.otf,.pdf,.png,.pptx,.psd,.rar,.svg,.text,.tiff,.ttf,.txt,.url,.wav,.webm,.webp,.wma,.wmv,.woff,.xls,.zip" 860 }); 861 862 } catch(err) { 863 var na=1; 864 } 865 866 //console.log($(MainDZ1)); 867 868 //console.log(Field); 869// if (1==2) { 870// console.log("Dropzone already attached."); 871// 872// } else { 873// 874// //document.location.reload(); 875// console.log("New Dropzone."); 876// var myDropzonePublic = new Dropzone("div#"+MainDZ1, { url: "/SWFUpload/upload.aspx", init: function() {this.on("queuecomplete", function(file) { document.getElementById(Field).value = this.files["0"].name; console.log(this.files["0"].name); });},clickable: true}); 877// console.log(myDropzonePublic); 878// } 879}; 880 881 882function getRandomColor() { 883 var letters = '0123456789ABCDEF'; 884 var color = '#'; 885 for (var i = 0; i < 6; i++) { 886 color += letters[Math.floor(Math.random() * 16)]; 887 } 888 return color; 889} 890 891 892 893 894 895function OpenMsgBox(Title,Msg,w,h) { 896 897 $('#MsgBox').dialog({ autoOpen: true, minHeight: h, minWidth: w, height: h, width: w, maximized:false, minimized:true }); 898 document.getElementById('ui-id-1').innerHTML=Title; 899 document.getElementById("MsgBox").innerHTML="<div class='ErrorMsgBox'>"+Msg+"</div>"; 900 901}; 902//$(document).on('ready', function () { 903//OpenMsgBox("Title","Test",500,150); 904//}); 905 906//Disabled, Implamanet with JS only, No Jquery 907//$(document).scroll(function() { 908// if(InfiniteScrollIIds.length > 0){ 909// if($(window).scrollTop() + $(window).height() == $(document).height()) { 910// //alert("bottom!"); 911// GetNextInfiniteScrollIItem(); 912// } 913// } 914//}); 915 916function GetNextInfiniteScrollIItem() { 917 918 var a = InfiniteScrollIIds[0]; 919 920 console.log(a); 921 922 $("#"+a).css('display', 'block'); 923 924 InfiniteScrollIIds.shift(); 925} 926 927var InfiniteScrollIIds = []; 928var InfiniteScrollTimer; 929var InfiniteScrollid; 930 931function sys_poll_OnResponse(ResaultsPage, ResponseText) { 932 933 if(ResaultsPage=="/GetItemSet.aspx"){ 934 InfiniteScrollid = ResaultsPage 935 InfiniteScrollTimer = setTimeout(GetInfiniteScroll, 100); 936 } else if (ResaultsPage=="/Edit/CreateNewSection.aspx"){ 937 parent.location.reload(); 938 } else if (ResaultsPage=="/GetHistory.aspx"){ 939 Get_Diff(); 940 } else if (ResaultsPage=="/SendSystemMail_IC.aspx"){ 941 if(ResponseText.indexOf("location:")>-1){ 942 ResponseText = ResponseText.split("location:")[1] 943 ResponseText = ResponseText.replace("</div>", "") 944 location = ResponseText; 945 //window.open(ResponseText); 946 } 947 } 948} 949 950function GetInfiniteScroll() { 951 952 clearTimeout(InfiniteScrollTimer); 953 954 var IDs = "" 955 956 $(".InfiniteScroll").each(function() { 957 IDs = IDs + "," + this.id; 958 }); 959 960 IDs = MyTrim(IDs, ","); 961 InfiniteScrollIIds = IDs.split(",") 962 963 964 965 //console.log(x); 966 967 while (InfiniteScrollIIds.length > 0 && $(window).height() - $(document).height() == 0){GetNextInfiniteScrollIItem()}; 968 969 970} 971 972 973var eee = false; //true; 974var DoRenderImages = false; 975 976document.onreadystatechange = function () { 977 978 //console.log("onreadystatechange=" + "0"); 979 980 if (!DoRenderImages) {return;}; 981 982 if (!eee) {eee = true; return;}; 983 984 //console.log("RenderImages"); 985 RenderImages(0) 986 987} //); 988 989 990
991function RenderImages(Mode) { 992 993 994 995 996 997 998 console.log("****** Processing Images"); 999 //console.log("readyState: "+document.readyState) 1000 1001 1002 var images = document.querySelectorAll("img"); 1003 1004 for (var i = 0; i < images.length; i++) { 1005 if (images[i].dataset.wodsrc){ 1006 //console.log(images[i].dataset.wodsrc); 1007 //console.log(images[i].width); 1008 } 1009 } 1010 1011 1012 try { 1013 1014 $('img').each(function(){ 1015 1016 var imgsrcXXX = $(this).attr("src") 1017 var imgsrcorg = $(this).attr("data-wodsrc"); //src 1018 var DataWidth = $(this).attr("data-width"); 1019 var DataHeight = $(this).attr("data-height"); 1020 var DataRatio = $(this).attr("data-ratio"); //For Random 1021 var AspectRatio = $(this).css("aspectRatio"); 1022 1023 if (AspectRatio != "auto") { 1024 while (AspectRatio.indexOf(" ")>-1){AspectRatio=AspectRatio.replace(" ", "")}; 1025 var r = AspectRatio.split("/") 1026 AspectRatio = r[0] / r[1]; 1027 DataRatio = AspectRatio 1028 }; 1029 1030 if ( Mode==1 || (imgsrcorg && imgsrcorg.toLowerCase().indexOf("tm-")==-1 && imgsrcorg.toLowerCase().indexOf("http")==-1 && imgsrcorg.toLowerCase().indexOf(".svg")==-1 && imgsrcorg.indexOf("/Sites/")>-1) ){ 1031 1032 //console.log(""); 1033 1034 //console.log(imgsrcorg); 1035 1036 imgsrc = imgsrcorg; 1037 if (Mode==1) {imgsrc = imgsrcXXX}; 1038 1039 var width = $(this).width(); 1040 var height = $(this).height(); 1041 1042 if (DataWidth > 0){ 1043 width = DataWidth; 1044 height=1; 1045 //console.log("DataWidth:" + DataWidth); 1046 }else if (DataHeight > 0) { 1047 height = DataHeight; 1048 width=1; 1049 }; 1050 1051 var attrwidth = $(this)["0"].width //$(this).attr('width'); 1052 var attrheight = $(this)["0"].height //$(this).attr('height'); 1053 1054 var naturalWidth = $(this)["0"].naturalWidth; 1055 var naturalHeight = $(this)["0"].naturalHeight; 1056 1057 var a = imgsrc.split("/"); 1058 var Name = a[a.length-1]; 1059 var Path = ""; 1060 1061 //console.log("width: " + width); 1062 //console.log("height: " + height); 1063 1064 //if (width > 0 || height > 0) { 1065 if ((Name.indexOf("Random")>-1) || width < 3200 || height < 3200) { 1066 //Keep 1067 //console.log("By width/height"); 1068 } else { 1069 //console.log("By Original"); 1070 $(this).attr("src",imgsrcorg); 1071 return; 1072 } 1073 1074 if (DataWidth == 0 || DataWidth == undefined){ 1075 1076 //if (width > 1600){width = 1920} else if (width > 1200) {width = 1600} else if (width > 800) {width = 1200} else if (width > 400) {width = 800} else if (width > 2) {width = 400} else {width = 1} 1077 //if (height > 1600){height = 1920} else if (height > 1200) {height = 1600} else if (height > 800) {height = 1200} else if (height > 400) {height = 800} else if (height > 2) {height = 400} else {height = 1} 1078 1079 if (width > 800){width = 1920} else if (width > 400) {width = 800} else if (width > 2) {width = 400} else {width = 1} 1080 if (height > 800){height = 1920} else if (height > 400) {height = 800} else if (height > 2) {height = 400} else {height = 1} 1081 1082 }; 1083 1084 1085 1086 //console.log(Name); 1087 1088 a.forEach( 1089 function(element, index) { 1090 if (index < a.length -1 && element != ""){Path = Path + "/" + element}; 1091 } 1092 ); 1093 1094 Path = Path.replace("/https:", "https:/") 1095 Path = Path.replace("/http:", "http:/") 1096 Path = Path.replace("/dwp5n41rsfk7g.cloudfront.net", "//dwp5n41rsfk7g.cloudfront.net") 1097 1098 var src; 1099 1100 var x = Math.floor(Math.random() * (999 - 0)) + 0; 1101 1102 if (Name.indexOf("Random")>-1) { 1103 1104 width = Math.trunc(width); 1105 height = Math.trunc(height); 1106 1107 if(DataRatio) {height = Math.trunc(width/DataRatio)}; 1108 1109 if (Name == "Random.jpg") { 1110 1111 src = "https://picsum.photos/seed/"+x+"/"+width+"/"+height+"/"; 1112 1113 } else { 1114 1115 //src = "https://random.imagecdn.app/"+width+"/"+height+"" 1116 1117 Name = Name.replace("Random", "") 1118 Name = Name.replace("-", "") 1119 Name = Name.replace(".jpg", "") 1120 Name = Name.toLowerCase(); 1121 1122 src = "https://api.lorem.space/image/"+Name+"?w="+width+"&h="+height+"&p="+Math.floor(Math.random() * 10000) 1123 1124 } 1125 1126 } else { 1127 src = Path+"/"+"tm-"+width+"X"+height+"_"+Name 1128 } 1129 1130 $(this).attr("src",src); 1131 1132 } 1133 1134 }); 1135 1136 try{AfterWindowLoad()} catch(err) {}; 1137 1138 } catch(err) { 1139 var na=1; 1140 console.log(err); 1141 } 1142 1143 1144} 1145 1146 1147 1148 1149 1150 1151 1152 1153function GetGooleMap(title, address, zoomm, div) { 1154
1155// while (title.indexOf("(")>0){title=title.replace("(", " ")}; 1156// while (title.indexOf(")")>0){title=title.replace(")", " ")}; 1157// 1158// while (address.indexOf("(")>0){address=address.replace("(", " ")}; 1159// while (address.indexOf(")")>0){address=address.replace(")", " ")}; 1160 1161 var geocoder; 1162 var map; 1163 var mapOptions; 1164 var marker; 1165 1166 mapOptions = { 1167 zoom: zoomm, 1168 mapTypeId: google.maps.MapTypeId.ROADMAP 1169 } 1170 1171 geocoder = new google.maps.Geocoder(); 1172 map = new google.maps.Map(document.getElementById(div), mapOptions); 1173 //codeAddress(title, address); 1174 1175 geocoder.geocode( { 'address': address}, function(results, status) { 1176 if (status == google.maps.GeocoderStatus.OK) { 1177 map.setCenter(results[0].geometry.location); 1178 if(marker) 1179 marker.setMap(null); 1180 marker = new google.maps.Marker({ 1181 map: map, 1182 position: results[0].geometry.location, 1183 draggable: true 1184 }); 1185 1186 var infowindow = new google.maps.InfoWindow({ 1187 content: '<div id="content"><strong>'+title+'</strong></br>'+address+'</div>' 1188 }); 1189 infowindow.open(map, marker); 1190 } else { 1191 //alert('Geocode was not successful for the following reason: ' + status); 1192 } 1193 }); 1194 1195 1196} 1197 1198function AdjustIframeHeightOnLoad() { document.getElementById(id).style.height = document.getElementById(id).contentWindow.document.body.scrollHeight + "px"; } 1199function AdjustIframeHeight(i) { document.getElementById(id).style.height = parseInt(i) + "px"; } 1200 1201function ResizeParentIframeHeight(pid, id){ 1202 var newheight; 1203 newheight=document.getElementById(id).offsetHeight; 1204 1205 //console.log(id); 1206 //console.log(newheight); 1207 1208 //parent.document.body.style.backgroundColor = "red"; 1209 parent.document.getElementById(pid).height= (newheight) + "px"; 1210 //alert(newheight); 1211 1212} 1213 1214function ResizeParentIframeWidth(pid, id){ 1215 var newwidth; 1216 newwidth=document.getElementById(id).offsetWidth; 1217 //parent.document.body.style.backgroundColor = "red"; 1218 parent.document.getElementById(pid).width= (newwidth) + "px"; 1219 //alert(newwidth + ' - ' + id); 1220 1221} 1222 1223function WOD_SubmitForm(Form) { 1224 var FormX = document.getElementById(Form); 1225 FormX.submit(); 1226} 1227 1228function autoResize(pid,id){ 1229 var newheight; 1230 //var newwidth; 1231 1232 if(document.getElementById){ 1233 newheight=document.getElementById(pid).contentWindow.document.body.scrollHeight; 1234 //newwidth=document.getElementById(id).contentWindow.document.body.scrollWidth; 1235 1236 newheight=document.getElementById(pid).contentWindow.document.getElementById(id).offsetHeight; 1237 //newwidth=document.getElementById(id).contentWindow.document.getElementById("ResumeTable").offsetWidth; 1238 } 1239 1240 document.getElementById(pid).height= (newheight) + "px"; 1241 //document.getElementById(id).width= (newwidth) + "px"; 1242} 1243 1244 var Color = 1; 1245 var Style = 1; 1246 1247function SetCSS(value) { 1248 1249 AllowKeyUp = true; 1250 1251 1252 1253 if (AllowKeyUp) { 1254 1255 AllowKeyUp = false; 1256 1257 1258 switch(value) { 1259 case 37: // left 1260 Color = Color + 1; 1261 if (Color > 10) {Color = 1}; 1262 break; 1263 1264 case 38: // up 1265 Style = Style + 1; 1266 if (Style > 8) {Style = 1}; 1267 break; 1268 1269 case 39: // right 1270 Color = Color - 1; 1271 if (Color < 1) {Color = 10}; 1272 break; 1273 1274 case 40: // down 1275 Style = Style - 1; 1276 if (Style < 1) {Style = 8}; 1277 break; 1278 1279 default: return; // exit this handler for other keys 1280 } 1281 1282 1283// if (value == "up") { 1284// 1285// } else if (value == "down") { 1286// 1287// } else if (value == "left") { 1288// 1289// } else if (value == "right") { 1290// 1291// }; 1292 1293 createCookie('LimaStyle',Style,999); 1294 createCookie('LimaColor',Color,999); 1295 1296 var f = '/images/Templates/'+Style+'/style_'+Color+'.css' 1297 console.log(f); 1298 1299 replacejscssfile(f); 1300 1301 } 1302 1303} 1304 1305function createCookie(name,value,days) { 1306 if (days) { 1307 var date = new Date(); 1308 date.setTime(date.getTime()+(days*24*60*60*1000)); 1309 var expires = "; expires="+date.toGMTString(); 1310 } 1311 else var expires = ""; 1312 document.cookie = name+"="+value+expires+"; path=/"; 1313 //alert(name+"="+value+expires+"; path=/"); 1314} 1315 1316function readCookie(name) { 1317 var nameEQ = name + "="; 1318 var ca = document.cookie.split(';'); 1319 for(var i=0;i < ca.length;i++) { 1320 var c = ca[i];
1321 while (c.charAt(0)==' ') c = c.substring(1,c.length); 1322 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 1323 } 1324 return null; 1325} 1326 1327function eraseCookie(name) { 1328 createCookie(name,"",-1); 1329} 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340function ErrorMode(Obj) { 1341 1342 var Ob = document.getElementById(Obj); 1343 var compStyles = window.getComputedStyle(Ob).border; 1344 console.log(compStyles); 1345 Ob.setAttribute('data-border', compStyles); 1346 Ob.style.setProperty("border", "red solid 1px", "important"); 1347} 1348 1349function ClearErrors(Obj) { 1350 Obj.style.border = Obj.getAttribute('data-border') 1351} 1352 1353function MM_findObj(n, d) { //v4.01 1354 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 1355 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 1356 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 1357 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 1358 if(!x && d.getElementById) x=d.getElementById(n); return x; 1359} 1360 1361function MM_validateForm2New() { 1362 //v4.0 1363 var i, p, q, nm, test, num, min, max, errors = '', args = MM_validateForm2New.arguments; 1364 1365 MM_findObj(args[0]).innerHTML = ""; 1366 1367 for (i=3; i<(args.length-2); i += 3) { 1368 test = args[i+2]; 1369 val = MM_findObj(args[i]); 1370 if (val) { 1371 nm = val.name; 1372 1373 //console.log(nm); 1374 1375 while (nm.indexOf("IsFile_")>-1){ 1376 nm = nm.replace("IsFile_", ""); 1377 } 1378 1379 //console.log(nm); 1380 1381 if (nm.indexOf("_IC")>-1){ 1382 nm = nm.split("_IC")[0]; 1383 } 1384 1385 while (nm.indexOf("_")>-1){ 1386 nm = nm.replace("_", ""); 1387 } 1388 1389 //console.log(nm); 1390 1391 if (val.value != "" || val.checked) { 1392 1393 if (test.indexOf('isEmail') != -1) { 1394 1395 p = val.value.indexOf('@'); 1396 1397 if (p<1) { 1398 1399 errors += ''+nm+' Must contain an @ sign.<br>'; 1400 //MM_findObj(args[i]).placeholder = '* ' + MM_findObj(args[i]).placeholder; 1401 ErrorMode(args[i]) 1402 1403 } else if (p == (val.value.length-1)) { 1404 1405 errors += ''+nm+' Must contain a domain.<br>'; 1406 ErrorMode(args[i]) 1407 1408 } else if ((val.value.match(/[@]/g) || []).length > 1) { 1409 1410 errors += ''+nm+' Must contain only one @ sign.<br>'; 1411 ErrorMode(args[i]) 1412 1413 } else { 1414 1415 var RightSideStr = val.value.split("@")[1] 1416 console.log(RightSideStr); 1417 1418 var d = RightSideStr.indexOf('.'); 1419 if (d<1 || d == (RightSideStr.length-1)) { 1420 1421 errors += ''+nm+' Must contain a valid extension.<br>'; 1422 ErrorMode(args[i]) 1423 } 1424 1425 1426 1427 } 1428 1429 } else if (test != 'R') { 1430 1431 num = parseFloat(val.value); 1432 if (isNaN(val.value)) { 1433 errors += ''+nm+' Must contain numbers only.<br>'; 1434 ErrorMode(args[i]) 1435 } 1436 if (test.indexOf('inRange') != -1) { 1437 p = test.indexOf(':'); 1438 min = test.substring(8, p); 1439 max = test.substring(p+1); 1440 if (num<min || max<num) { 1441 errors += ''+nm+' Must contain a number between '+min+' and '+max+'.<br>'; 1442 ErrorMode(args[i]) 1443 } 1444 } 1445 } 1446 } else if (test.charAt(0) == 'R') { 1447 errors += ''+nm+' is required.<br>'; 1448 ErrorMode(args[i]) 1449 } 1450 } 1451 } 1452 if (errors) { 1453 //alert('×ש××××ת ××××ת ×רע×:\n'+errors); 1454 //document.getElementById('ErrorMsg').innerHTML = '<b>×ש××××ת ××××ת ×רע×:</b><br><br>'+errors+'<br>' 1455 ////MM_findObj(args[0]).innerHTML = '<b>The following error(s) occurred:</b><br>'+errors+'<br><br>' 1456 } 1457 document.MM_returnValue2 = (errors == ''); 1458 return document.MM_returnValue2; 1459} 1460 1461function GetFormValues(Form) 1462{ 1463 //alert(Form); 1464 //Needs Form ID Value 1465 var k = ""; 1466 for(i=0; i<Form.elements.length; i++){ 1467 if (!Form.elements[i].name=="") { 1468 var v = Form.elements[i].value; 1469 k = k + '#&#' + Form.elements[i].name + '='+Form.elements[i].value 1470 }; 1471 } 1472 return k 1473} 1474 1475var LoadingPic = "clock.svg"; 1476//"IndicatorBig.gif"; 1477//////////////////alert("1"+LoadingPic); 1478 1479
1480function ResEffect(Res) 1481{ 1482 console.log("ResEffect"); 1483 1484 var t = $("#ResSpan", window.parent.parent.document); 1485 1486 t.fadeTo(1,1); 1487 //Res == "Saved" 1488if (Res.indexOf(":OK") > 0) { 1489 t.addClass("SavedOK").removeClass('SavedFailed'); 1490 try { 1491 t.effect("bounce", 300); 1492 } catch (e) { 1493 console.log(e) 1494 }; 1495} else { 1496 t.addClass("SavedFailed").removeClass('SavedOK'); 1497 try { 1498 t.effect("shake", 300); 1499 } catch (e) { 1500 console.log(e) 1501 }; 1502} 1503 1504 t.delay(1000).fadeTo(2000,0, function() {$('#ResSpan', window.parent.parent.document).css({display:'none'});}); 1505 //t.removeClass("SavedFailed").removeClass('SavedOK'); 1506 1507 //parent.parent.document.getElementById('ResSpan').innerHTML = ""; 1508} 1509 1510function PollL(aa,bb,cc,dd,ee,ff){if(dd){dd=dd+"###and###Phantom_sid="+Math.random()};ee.innerHTML = "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0'><tr><td align='center' valign='middle'><img src='/images/Icons/Loading/"+LoadingPic+"'></td></tr></table>";while (bb.indexOf("+")>0){bb=bb.replace("+", "##plus##")};while (bb.indexOf("&")>0){bb = bb.replace("&", "##and##")};while (dd.indexOf("&")>0){dd = dd.replace("&", "##and##")};while (bb.indexOf("###and###")>0){bb = bb.replace("###and###", "&")};while (dd.indexOf("###and###")>0){dd = dd.replace("###and###", "&")};if(window.XMLHttpRequest){var oXMLHTTP=new XMLHttpRequest()} else if (window.ActiveXObject) {var oXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP")};if(ff) {cc=aa;dd=bb;aa="";alert("Step 1: "+dd)};if(aa){if(ff){alert("Save")};oXMLHTTP.open("POST", aa, false );oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");oXMLHTTP.send(bb)};if(ff) {alert("Read: "+dd)};oXMLHTTP.open("POST", cc, true );oXMLHTTP.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");oXMLHTTP.onreadystatechange=function(){if (oXMLHTTP.readyState==4) {ee.innerHTML=oXMLHTTP.responseText; if(ee.innerHTML==''){ee.style.display='none'}}};oXMLHTTP.send(dd);} 1511 1512function PollB(aa,bb,cc,dd,ee,ff){if(dd){dd=dd+"###and###Phantom_sid="+Math.random()};while (bb.indexOf("+")>0){bb=bb.replace("+", "##plus##")};while (bb.indexOf("&")>0){bb = bb.replace("&", "##and##")};while (dd.indexOf("&")>0){dd = dd.replace("&", "##and##")};while (bb.indexOf("###and###")>0){bb = bb.replace("###and###", "&")};while (dd.indexOf("###and###")>0){dd = dd.replace("###and###", "&")};if(window.XMLHttpRequest){var oXMLHTTP=new XMLHttpRequest()} else if (window.ActiveXObject) {var oXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP")};if(ff) {cc=aa;dd=bb;aa="";alert("Step 1: "+dd)};if(aa){if(ff){alert("Save")};oXMLHTTP.open("POST", aa, false );oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");oXMLHTTP.send(bb)};if(ff) {alert("Read: "+dd)};oXMLHTTP.open("POST", cc, true );oXMLHTTP.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");oXMLHTTP.onreadystatechange=function(){if (oXMLHTTP.readyState==4) {ee.innerHTML=oXMLHTTP.responseText}};oXMLHTTP.send(dd);} 1513 1514function Poll(CommandPage,CommandStr,ResaultsPage,ResaultsStr,ResaultsSpan,DeBug,CallBack) 1515{ 1516 1517 /////////////////////console.log("ResaultsSpan"+ResaultsSpan); 1518 1519 //alert("2"+LoadingPic); 1520 1521 //window.setTimeout("alert(document.activeElement.tagName+ ':'+document.activeElement.getAttribute('id'))", 2000) 1522 //ResaultsSpan.innerHTML = "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0'><tr><td align='center' valign='middle'><img src='images/IndicatorBig.gif'></td></tr></table>" 1523 //ResaultsSpan.innerHTML = "<img src='images/IndicatorBig.gif' height='16'>" 1524 if (ResaultsSpan != null && ResaultsSpan != "") { 1525 //ResaultsSpan.innerHTML = "<img src='/images/Icons/Loading/Arrows.gif' height='16'>" 1526 //ResaultsSpan.innerHTML = "<img src='/images/Icons/Loading/"+LoadingPic+"' >" 1527 //ResaultsSpan.innerHTML = "<img src='/images/245.gif' >" 1528 1529 ResaultsSpan.innerHTML = "<div id='loadingProgressG'><div id='loadingProgressG_1' class='loadingProgressG'></div></div>"; 1530 1531 }; 1532 //alert(document.getElementById(ResaultsSpan).innerHTML); 1533 1534 //////////////////return; 1535 1536 while (CommandStr.indexOf("%")>0){CommandStr=CommandStr.replace("%", "##Percent##")}; 1537 1538 while (CommandStr.indexOf("&")>0){CommandStr=CommandStr.replace("&", "##and##")}; 1539 while (ResaultsStr.indexOf("&")>0){ResaultsStr=ResaultsStr.replace("&", "##and##")}; 1540 while (CommandStr.indexOf("###and###")>0){CommandStr=CommandStr.replace("###and###", "&")}; 1541 while (ResaultsStr.indexOf("###and###")>0){ResaultsStr=ResaultsStr.replace("###and###", "&")}; 1542 while (ResaultsStr.indexOf("##plus##")>0){ResaultsStr=ResaultsStr.replace("##plus##", "+")}; 1543 1544 while (CommandStr.indexOf("<")>0){CommandStr=CommandStr.replace("<", "##OpenTag##")}; 1545 while (CommandStr.indexOf(">")>0){CommandStr=CommandStr.replace(">", "##CloseTag##")}; 1546 1547 if (window.ActiveXObject) { // Mozilla, Safari, ... 1548 var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP"); 1549 var oXMLHTTP2 = new ActiveXObject("Microsoft.XMLHTTP"); 1550 if (DeBug) {alert("Browser IE")}; 1551 } else if (window.XMLHttpRequest) { // IE 1552 var oXMLHTTP = new XMLHttpRequest(); 1553 var oXMLHTTP2 = new XMLHttpRequest(); 1554 if (DeBug) {alert("Browser Mozilla")}; 1555 } 1556 1557 //DeBug = true; 1558 1559 1560// console.log("CommandPage"+CommandPage); 1561// console.log("CommandStr"+CommandStr); 1562// console.log("ResaultsPage"+ResaultsPage); 1563// console.log("ResaultsSpan"+ResaultsSpan); 1564 1565 1566 if (DeBug) { 1567 1568 1569 1570 1571 //ResaultsPage = CommandPage; 1572 //ResaultsStr = CommandStr; 1573 //CommandPage = ""; 1574 1575 if (CommandPage) { 1576 ResaultsPage = CommandPage; 1577 ResaultsStr = CommandStr; 1578 CommandPage = ""; 1579 } 1580
1581 console.log("ResaultsStr: "+ResaultsStr); 1582 console.log("ResaultsPage: "+ResaultsPage); 1583 } 1584 1585 if (CommandPage) { 1586 1587 1588 try {document.getElementById('ResSpan').innerHTML="<span class='ResSaved' >Saving...</span>";} catch(err) {var na=1;} 1589 1590 ////////////////////console.log("CommandPage Called: "+CommandPage); 1591 if (DeBug) {alert("CommandPage Called: "+CommandPage)}; 1592 oXMLHTTP2.open("POST", CommandPage, false ); 1593 oXMLHTTP2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 1594 1595 oXMLHTTP2.onreadystatechange=function() { 1596 if (oXMLHTTP2.readyState==4) { 1597 1598 if (oXMLHTTP2.status == 200) { 1599 ////////////////////////console.log(CommandPage); 1600 1601 ///////////////////////console.log(oXMLHTTP2.responseText); 1602 if (DeBug) {alert(oXMLHTTP2.responseText)}; 1603 1604 //alert("R"); 1605 1606 try { 1607 1608 var R = oXMLHTTP2.responseText; 1609 R = R.split("~")[1]; 1610 var rr = R.replace(":OK", ""); 1611 parent.parent.document.getElementById('ResSpan').innerHTML = rr; 1612 parent.parent.ResEffect(R); 1613 1614 //parent.parent.Notify("Saved", rr); 1615 parent.parent.alertify.success("a:"+rr); 1616 console.log("Saved"); 1617 1618 } catch(err) {var na=1;} 1619 1620 } else { 1621 ////////////////////alert('There was a problem saving.'); 1622 if (DeBug) {alert(oXMLHTTP2.status)}; 1623 if (DeBug) {alert(oXMLHTTP2.responseText)}; 1624 } 1625 1626 } else { 1627 if (DeBug) {alert("Not Ready "+oXMLHTTP2.readyState)}; 1628 } 1629 } 1630 1631 oXMLHTTP2.send(CommandStr); 1632 } 1633 1634 1635 if (ResaultsPage) { 1636 1637 ////////////////////////console.log("ResaultsPage Called: "+ResaultsPage); 1638 1639 if (DeBug) {alert("Read")}; 1640 oXMLHTTP.open("POST", ResaultsPage, true ); 1641 1642 oXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 1643 1644 oXMLHTTP.onreadystatechange=function() { 1645 if (oXMLHTTP.readyState==4) { 1646 1647 1648 if (oXMLHTTP.status == 200) { 1649 1650 if (DeBug) {alert(oXMLHTTP.responseText)}; 1651 ResaultsSpan.innerHTML=oXMLHTTP.responseText; 1652 1653 1654 //Need to Add 'CallID' 1655 try {poll_OnResponse(ResaultsPage);} catch(err) {var na=1;} 1656 try {sys_poll_OnResponse(ResaultsPage, oXMLHTTP.responseText);} catch(err) {var na=1;} 1657 1658 if (typeof window[CallBack] === 'function') { 1659 // Run the function programmatically using the variable 1660 window[CallBack](); 1661 } else { 1662 //console.log(`Function ${CallBack} not found.`); 1663 } 1664 1665 //oUtil.initializeEditor('innovaeditor',{ width:"100%", height:"450px",cmdAssetManager:"modalDialogShow('/Editor51/assetmanager/assetmanager.aspx',640,465)" }); 1666 1667 if (ResaultsPage=="Fix.aspx") { 1668 //alert("ResaultsPage"); 1669 compactMenu('treeversion',false,''); 1670 }; 1671 1672 } else { 1673 ///////////////alert('There was a problem with the request.'); 1674 if (DeBug) {alert(oXMLHTTP.status)}; 1675 if (DeBug) {alert(oXMLHTTP.responseText)}; 1676 } 1677 1678 1679 } else { 1680 if (DeBug) {alert("Not Ready "+oXMLHTTP.readyState)}; 1681 } 1682 } 1683 1684 ResaultsStr = ResaultsStr+"&Phantom_sid="+Math.random()+" " 1685 if (DeBug) {alert("ResaultsStr: "+ResaultsStr)}; 1686 oXMLHTTP.send(ResaultsStr); 1687 1688 } 1689 1690} 1691 1692function Notify(Title, Msg) { 1693 1694 console.log("Notify: "+Msg); 1695 1696 $.notify({ 1697 // options 1698 title: '<strong>'+Title+'</strong>', 1699 message: Msg, 1700 icon: 'glyphicon glyphicon-ok', 1701 url: 'https://github.com/mouse0270/bootstrap-notify', 1702 target: '_blank' 1703 }, { 1704 // settings 1705 element: 'body', 1706 //position: null, 1707 type: "success", 1708 //allow_dismiss: true, 1709 newest_on_top: false, 1710 showProgressbar: false, 1711 placement: {from: "top", align: "right" 1712 }, 1713 offset: 20, spacing: 10, z_index: 1031, delay: 3300, timer: 1000, url_target: '_blank', mouse_over: null, 1714 animate: {enter: 'animated fadeInDown', exit: 'animated fadeOutRight' 1715 }, onShow: null, onShown: null, onClose: null, onClosed: null, 1716 icon_type: 'class', 1717 });
1718} 1719 1720function createjscssfile(filename){ 1721 var fileref=document.createElement("link") 1722 fileref.setAttribute("rel", "stylesheet") 1723 fileref.setAttribute("type", "text/css") 1724 fileref.setAttribute("href", filename) 1725 return fileref 1726} 1727 1728var LoadedCSSFile = "/images/Templates/1/style_1.css"; 1729function replacejscssfile(newfilename){ 1730 1731 //alert(newfilename); 1732 1733 var allsuspects=document.getElementsByTagName("link") 1734 for (var i=allsuspects.length; i>=0; i--){ 1735 if (allsuspects[i] && allsuspects[i].getAttribute("href")!=null && allsuspects[i].getAttribute("href").indexOf(LoadedCSSFile)!=-1){ 1736 var newelement=createjscssfile(newfilename) 1737 allsuspects[i].parentNode.replaceChild(newelement, allsuspects[i]) 1738 LoadedCSSFile = newfilename 1739 } 1740 } 1741} 1742 1743function setHomePageSub(id, url) { 1744 id.style.behavior='url(#default#homepage)'; 1745 id.setHomePage('http://www.'+url); 1746} 1747 1748 1749function ShowHideDivNew(Element){ 1750 $( "#" + Element ).slideToggle(); 1751} 1752 1753function ShowHideDivV3(Element, Display){ 1754 1755 if ($(Element).css('display') != 'none'){ 1756 $(Element).css('display', 'none'); 1757 } else { 1758 $(Element).css('display', Display); 1759 } 1760 1761} 1762 1763 1764 1765var head="display:''" 1766function ShowHideDiv(header){ 1767 //alert(header.style.display); 1768 1769 $( "#" + header.id ).slideToggle(); 1770 1771// var head=header.style 1772// if (head.display=="none") 1773// head.display="block" 1774// else 1775// head.display="none" 1776} 1777 1778function ShowHideDivInLine(header){ 1779 //alert(header.style.display); 1780 var head=header.style 1781 if (head.display=="none") 1782 head.display="inline-block" 1783 else 1784 head.display="none" 1785} 1786 1787 1788function HideDiv(header){ 1789var head=header.style 1790head.display="none" 1791} 1792 1793 1794function ShowDiv(header){ 1795var head=header.style 1796head.display="block" 1797} 1798 1799 1800 1801 1802 document.addEventListener('DOMContentLoaded', function() { 1803 1804 console.log("DoAllMultiStepForm"); 1805 DoAllMultiStepForm(); 1806 1807 }); 1808 1809 1810 1811 function DoAllMultiStepForm() { 1812 1813 document.querySelectorAll('.WOD_MultiStepForm').forEach(function (form) { 1814 console.log(form.id); 1815 1816 // Configuration 1817 const config = { 1818 formId: form.id, 1819 validationMessages: { 1820 required: 'This field is required', 1821 email: 'Please enter a valid email address', 1822 number: 'Please enter a valid number' 1823 } 1824 }; 1825 1826 convertFormToTypeForm(config.formId, config.validationMessages); 1827 1828 }); 1829 1830 }; 1831 1832 1833 1834 1835 1836 function convertFormToTypeForm(formId, validationMessages) { 1837 const form = document.getElementById(formId); 1838 if (!form) return; 1839 1840 // Add TypeForm class
1841 ////////////////////////////////////////form.classList.add('typeform-form'); 1842 1843 ////////////////////form.classList.add('no-animation'); 1844 1845 1846 // Store original submit button if it exists 1847 const originalSubmit = form.querySelector('button[type="submit"], input[type="submit"]'); 1848 if (originalSubmit) originalSubmit.style.display = 'none'; 1849 1850 // Get all input, textarea, select elements (excluding hidden and submit buttons) 1851 const formFields = Array.from(form.elements).filter(el => 1852 ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName) && 1853 el.type !== 'hidden' && 1854 el.type !== 'submit' 1855 ); 1856 1857 // Clear form content 1858 form.innerHTML = ''; 1859 1860 // Add progress bar 1861 const progressBar = document.createElement('div'); 1862 progressBar.className = 'typeform-progress'; 1863 progressBar.innerHTML = '<div class="typeform-progress-bar"></div>'; 1864 form.appendChild(progressBar); 1865 1866 1867 // Create steps (one per field) 1868 formFields.forEach((field, index) => { 1869 const step = document.createElement('div'); 1870 step.className = 'typeform-step'; 1871 if (index === 0) step.classList.add('active'); 1872 step.dataset.step = index + 1; 1873 1874 // Add question (using placeholder, label, or field name) 1875 const question = document.createElement('div'); 1876 question.className = 'typeform-question'; 1877 1878 // Determine question text (priority: placeholder > aria-label > name > id) 1879 let questionText = field.placeholder || 1880 field.getAttribute('aria-label') || 1881 field.name.replace(/_/g, ' ') || 1882 field.id.replace(/_/g, ' '); 1883 1884 // Clean up question text (remove "IC10015" if present) 1885 questionText = questionText.replace(/IC10015/g, '').trim(); 1886 question.textContent = questionText || `Question ${index + 1}`; 1887 step.appendChild(question); 1888 1889 // Create field wrapper 1890 const wrapper = document.createElement('div'); 1891 wrapper.className = 'typeform-field-wrapper'; 1892 1893 // Clone the field to preserve original attributes 1894 const clonedField = field.cloneNode(true); 1895 clonedField.classList.add('typeform-input'); 1896 1897 // Special handling for different field types 1898 if (clonedField.tagName === 'TEXTAREA') { 1899 clonedField.classList.remove('typeform-input'); 1900 clonedField.classList.add('typeform-textarea'); 1901 } else if (clonedField.type === 'checkbox' || clonedField.type === 'radio') { 1902 // Handle checkboxes and radios differently 1903 wrapper.innerHTML = ''; // Clear wrapper 1904 1905 // Create container for radio/checkbox options 1906 const optionsContainer = document.createElement('div'); 1907 optionsContainer.className = 'typeform-options'; 1908 1909 // If it's a radio group, get all options with the same name 1910 if (clonedField.type === 'radio') { 1911 const radioGroup = form.querySelectorAll(`input[type="radio"][name="${clonedField.name}"]`); 1912 radioGroup.forEach(radio => { 1913 const optionWrapper = createOptionElement(radio.cloneNode(true), questionText); 1914 optionsContainer.appendChild(optionWrapper); 1915 }); 1916 } else { 1917 // Single checkbox 1918 const optionWrapper = createOptionElement(clonedField, questionText); 1919 optionsContainer.appendChild(optionWrapper); 1920 } 1921 1922 wrapper.appendChild(optionsContainer); 1923 1924 } else if (clonedField.tagName === 'SELECT') { 1925 // Style select dropdown 1926 clonedField.classList.add('typeform-select'); 1927 } 1928 1929 if (clonedField.type !== 'checkbox' && clonedField.type !== 'radio') { 1930 wrapper.appendChild(clonedField); 1931 } 1932 1933 step.appendChild(wrapper); 1934 1935 // Add navigation buttons 1936 const buttons = document.createElement('div'); 1937 buttons.className = 'typeform-buttons'; 1938 1939 // Previous button (not on first step) 1940 if (index > 0) { 1941 const prevButton = document.createElement('button'); 1942 prevButton.className = 'typeform-button prev'; 1943 prevButton.textContent = 'Back'; 1944 prevButton.addEventListener('click', (e) => { 1945 e.preventDefault(); 1946 navigateSteps(index, 'prev'); 1947 }); 1948 buttons.appendChild(prevButton); 1949 } else { 1950 // Empty div to maintain flex spacing 1951 buttons.appendChild(document.createElement('div')); 1952 } 1953 1954 // Next/Submit button 1955 if (index < formFields.length - 1) { 1956 const nextButton = document.createElement('button'); 1957 nextButton.className = 'typeform-button next'; 1958 nextButton.textContent = 'Continue'; 1959 nextButton.addEventListener('click', (e) => { 1960 e.preventDefault(); 1961 navigateSteps(index, 'next'); 1962 }); 1963 buttons.appendChild(nextButton); 1964 } else { 1965 // On last step, show original submit button or create one 1966 if (originalSubmit) { 1967 const submitBtn = originalSubmit.cloneNode(true); 1968 submitBtn.style.display = 'block'; 1969 submitBtn.className = 'RepcaptchaDiv typeform-button submit'; 1970 buttons.appendChild(submitBtn); 1971 } else { 1972 const submitBtn = document.createElement('button'); 1973 submitBtn.className = 'typeform-button submit'; 1974 submitBtn.textContent = 'Submit'; 1975 submitBtn.type = 'submit'; 1976 buttons.appendChild(submitBtn); 1977 } 1978 } 1979 1980 step.appendChild(buttons); 1981 form.appendChild(step); 1982 1983 // Auto-focus on first field 1984 if (index === 0) { 1985 setTimeout(() => { 1986 const input = step.querySelector('input, textarea, select'); 1987 if (input) input.focus(); 1988 }, 400); 1989 } 1990 }); 1991 1992 // Helper function to create radio/checkbox options 1993 function createOptionElement(input, questionText) { 1994 const optionWrapper = document.createElement('label'); 1995 optionWrapper.className = 'typeform-option'; 1996 1997 // Create the input element 1998 const inputClone = input.cloneNode(true); 1999 inputClone.classList.add('typeform-option-input'); 2000 2001 // Create the custom styled "checkbox" 2002 const customInput = document.createElement('span'); 2003 customInput.className = 'typeform-custom-input'; 2004 2005 // Create the label text 2006 const labelText = document.createElement('span'); 2007 labelText.className = 'typeform-option-label'; 2008 labelText.textContent = input.value || questionText; 2009 2010 optionWrapper.appendChild(inputClone); 2011 optionWrapper.appendChild(customInput); 2012 optionWrapper.appendChild(labelText); 2013 2014 return optionWrapper; 2015 } 2016 2017 // Validation function 2018 function validateField(field) { 2019 const validationType = field.getAttribute('data-validate'); 2020 const value = field.value.trim(); 2021 let isValid = true; 2022 let errorMessage = ''; 2023 2024 if (!validationType) return { isValid: true, errorMessage: '' }; 2025 2026 // Check validation types 2027 if (validationType === '1' || validationType === '3' || validationType === '5') { 2028 // Required validation 2029 if (!value) { 2030 isValid = false; 2031 errorMessage = validationMessages.required; 2032 } 2033 } 2034 2035 if ((validationType === '2' || validationType === '3') && value) { 2036 // Email validation 2037 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 2038 if (!emailRegex.test(value)) { 2039 isValid = false; 2040 errorMessage = validationMessages.email; 2041 } 2042 } 2043 2044 if ((validationType === '4' || validationType === '5') && value) { 2045 // Number validation 2046 if (isNaN(Number(value))) { 2047 isValid = false; 2048 errorMessage = validationMessages.number; 2049 } 2050 } 2051 2052 return { isValid, errorMessage }; 2053 } 2054 2055 // Navigation function with validation 2056 function navigateSteps(currentIndex, direction) { 2057 const currentStep = form.querySelector(`.typeform-step[data-step="${currentIndex + 1}"]`); 2058 const nextStepIndex = direction === 'next' ? currentIndex + 1 : currentIndex - 1; 2059 const nextStep = form.querySelector(`.typeform-step[data-step="${nextStepIndex + 1}"]`); 2060 2061 // Validate current step before proceeding to next 2062 if (direction === 'next') { 2063 let allValid = true; 2064 2065 // Validate regular inputs 2066 const inputs = currentStep.querySelectorAll('input:not([type="radio"]):not([type="checkbox"]), textarea, select');
2067 inputs.forEach(input => { 2068 const { isValid, errorMessage } = validateField(input); 2069 if (!isValid) { 2070 showError(input, errorMessage); 2071 allValid = false; 2072 } 2073 }); 2074 2075 // Validate radio groups 2076 const radios = currentStep.querySelectorAll('input[type="radio"]'); 2077 if (radios.length > 0 && radios[0].getAttribute('data-validate') === '1') { 2078 const radioGroupName = radios[0].name; 2079 const isRadioSelected = form.querySelector(`input[type="radio"][name="${radioGroupName}"]:checked`); 2080 if (!isRadioSelected) { 2081 allValid = false; 2082 radios.forEach(radio => { 2083 showError(radio, validationMessages.required); 2084 }); 2085 } 2086 } 2087 2088 // Validate checkboxes 2089 const checkboxes = currentStep.querySelectorAll('input[type="checkbox"]'); 2090 if (checkboxes.length > 0 && checkboxes[0].getAttribute('data-validate') === '1') { 2091 const isCheckboxChecked = Array.from(checkboxes).some(cb => cb.checked); 2092 if (!isCheckboxChecked) { 2093 allValid = false; 2094 checkboxes.forEach(cb => { 2095 showError(cb, validationMessages.required); 2096 }); 2097 } 2098 } 2099 2100 if (!allValid) { 2101 currentStep.style.animation = 'shake 0.5s'; 2102 setTimeout(() => currentStep.style.animation = '', 500); 2103 return; 2104 } 2105 } 2106 2107 // Switch steps 2108 currentStep.classList.remove('active'); 2109 nextStep.classList.add('active'); 2110 2111 // Update progress bar if enabled 2112 const progressPercentage = (nextStepIndex / (formFields.length - 1)) * 100; 2113 form.querySelector('.typeform-progress-bar').style.width = `${progressPercentage}%`; 2114 2115 // Auto-focus on next field 2116 setTimeout(() => { 2117 const input = nextStep.querySelector('input, textarea, select'); 2118 if (input) input.focus(); 2119 }, 400); 2120 2121 2122 // Scroll to top of form for better mobile experience 2123 window.scrollTo({ 2124 top: form.getBoundingClientRect().top + window.pageYOffset - 20, 2125 behavior: 'smooth' 2126 }); 2127 } 2128 2129 // Function to show validation error 2130 function showError(field, message) { 2131 // For regular inputs 2132 if (field.style) { 2133 field.style.borderBottomColor = 'red'; 2134 2135 // Add or update error message 2136 let errorElement = field.nextElementSibling; 2137 if (!errorElement || !errorElement.classList.contains('typeform-error')) { 2138 errorElement = document.createElement('div'); 2139 errorElement.className = 'typeform-error'; 2140 field.parentNode.insertBefore(errorElement, field.nextSibling); 2141 } 2142 errorElement.textContent = message; 2143 errorElement.style.display = 'block'; 2144 } 2145 2146 // For radio/checkbox options 2147 if (field.parentElement && field.parentElement.querySelector('.typeform-custom-input')) { 2148 field.parentElement.querySelector('.typeform-custom-input').style.borderColor = 'red'; 2149 2150 // Add error message to the group 2151 const groupContainer = field.closest('.typeform-options'); 2152 if (groupContainer) { 2153 let groupError = groupContainer.querySelector('.typeform-group-error'); 2154 if (!groupError) { 2155 groupError = document.createElement('div'); 2156 groupError.className = 'typeform-group-error'; 2157 groupContainer.appendChild(groupError); 2158 } 2159 groupError.textContent = message; 2160 } 2161 } 2162 } 2163 2164 // Function to clear errors 2165 function clearErrors(field) { 2166 // For regular inputs 2167 if (field.style) { 2168 field.style.borderBottomColor = '#e0e0e0'; 2169 2170 // Hide error message 2171 const errorElement = field.nextElementSibling; 2172 if (errorElement && errorElement.classList.contains('typeform-error')) { 2173 errorElement.style.display = 'none'; 2174 } 2175 } 2176 2177 // For radio/checkbox options 2178 if (field.parentElement && field.parentElement.querySelector('.typeform-custom-input')) { 2179 field.parentElement.querySelector('.typeform-custom-input').style.borderColor = ''; 2180 2181 // Clear group error 2182 const groupContainer = field.closest('.typeform-options'); 2183 if (groupContainer) { 2184 const groupError = groupContainer.querySelector('.typeform-group-error'); 2185 if (groupError) groupError.remove(); 2186 } 2187 } 2188 } 2189 2190 // Attach clear errors function to all inputs 2191 const allInputs = form.querySelectorAll('input, textarea, select');
2192 allInputs.forEach(input => { 2193 input.addEventListener('focus', function() { 2194 clearErrors(this); 2195 }); 2196 2197 // Handle Enter key to go to next step 2198 if (input.tagName !== 'TEXTAREA') { 2199 input.addEventListener('keydown', function(e) { 2200 if (e.key === 'Enter') { 2201 e.preventDefault(); 2202 const currentStep = this.closest('.typeform-step'); 2203 const currentIndex = parseInt(currentStep.dataset.step) - 1; 2204 if (currentIndex < formFields.length - 1) { 2205 navigateSteps(currentIndex, 'next'); 2206 } 2207 } 2208 }); 2209 } 2210 }); 2211 } 2212 2213 2214 2215 2216 2217 2218 2219 2220
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.