| @@ -42,8 +42,23 @@ | ||
| 42 | 42 | window.location.href = currentUrl.toString(); |
| 43 | 43 | }); |
| 44 | 44 | /* */ |
| 45 | 45 | |
| 46 | + // Replace image to YouTube embed video | |
| 47 | + $(document).on('click', '.ays-chart-youtube-placeholder', function() { | |
| 48 | + var videoId = $(this).data('video-id'); | |
| 49 | + var iframe = $('<iframe>', { | |
| 50 | + src: 'https://www.youtube.com/embed/' + videoId + '?autoplay=1', | |
| 51 | + class: '', | |
| 52 | + width: 560, | |
| 53 | + height: 315, | |
| 54 | + frameborder: 0, | |
| 55 | + allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture', | |
| 56 | + allowfullscreen: true, | |
| 57 | + }); | |
| 58 | + $(this).replaceWith(iframe); | |
| 59 | + }); | |
| 60 | + | |
| 46 | 61 | $(document).find('#ays-title').on('input', function () { |
| 47 | 62 | $(document).find('.ays_chart_title_in_top').text($(this).val()); |
| 48 | 63 | }); |
| 49 | 64 | |
| @@ -513,9 +528,12 @@ | ||
| 513 | 528 | var closeButton = mainParent.find("button.notice-dismiss"); |
| 514 | 529 | |
| 515 | 530 | var attr_plugin = $this.attr('data-plugin'); |
| 516 | 531 | var wp_nonce = thisParent.find('#chart-builder-sale-banner').val(); |
| 517 | - | |
| 532 | + if(typeof wp_nonce == 'undefined'){ | |
| 533 | + wp_nonce = $(document).find('#chart-builder-sale-banner').val(); | |
| 534 | + } | |
| 535 | + | |
| 518 | 536 | var data = { |
| 519 | 537 | action: 'ays_chart_dismiss_button', |
| 520 | 538 | _ajax_nonce: wp_nonce, |
| 521 | 539 | }; |
| @@ -571,9 +589,9 @@ | ||
| 571 | 589 | imgBox.attr("data-img-src", newString); |
| 572 | 590 | }); |
| 573 | 591 | // Pro features end |
| 574 | 592 | |
| 575 | - var checkCountdownIsExists = $(document).find('#ays-chart-countdown-main-container'); | |
| 593 | + var checkCountdownIsExists = $(document).find('#ays-chart-new-silver-bundle-dicount-month-main'); | |
| 576 | 594 | |
| 577 | 595 | if ( checkCountdownIsExists.length > 0 ) { |
| 578 | 596 | var second = 1000, |
| 579 | 597 | minute = second * 60, |
| @@ -579,10 +597,10 @@ | ||
| 579 | 597 | minute = second * 60, |
| 580 | 598 | hour = minute * 60, |
| 581 | 599 | day = hour * 24; |
| 582 | 600 | |
| 583 | - // var chartCountdownEndTime = aysChartBuilderAdmin.chartBannerDate; | |
| 584 | - var chartCountdownEndTime = "JAN 15, 2025 23:59:59"; | |
| 601 | + var chartCountdownEndTime = aysChartBuilderAdmin.chartBannerDate; | |
| 602 | + // var chartCountdownEndTime = "NOV 28, 2025 23:59:59"; | |
| 585 | 603 | var countDown_new = new Date(chartCountdownEndTime).getTime(); |
| 586 | 604 | |
| 587 | 605 | if ( isNaN(countDown_new) || isFinite(countDown_new) == false ) { |
| 588 | 606 | var AYS_QUIZ_MILLISECONDS = 3 * day; |
| @@ -694,26 +712,35 @@ | ||
| 694 | 712 | |
| 695 | 713 | var createdNewChart = getCookie('ays_chart_created_new'); |
| 696 | 714 | if (createdNewChart && createdNewChart > 1) { |
| 697 | 715 | var url = new URL(window.location.href); |
| 716 | + var getCustomPostId = getCookie('ays_chart_created_new_'+createdNewChart+'_post_id'); | |
| 717 | + var link = "#"; | |
| 718 | + if(getCustomPostId){ | |
| 719 | + link = getCustomPostId; | |
| 720 | + } | |
| 698 | 721 | |
| 699 | 722 | var parameterValue = url.searchParams.get("action"); |
| 700 | 723 | var htmlDefaultText = '<p style="margin-top:1rem;">For more detailed configuration visit <a href="admin.php?page=chart-builder&action=edit&id=' + createdNewChart + '">edit chart page</a>.</p>'; |
| 701 | 724 | |
| 702 | 725 | var htmlContent = parameterValue && parameterValue == 'edit' ? '' : htmlDefaultText; |
| 703 | - | |
| 726 | + var previewButtonSvgIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.9999 7.21325C11.8231 7.21325 11.6535 7.28349 11.5285 7.40851C11.4035 7.53354 11.3333 7.70311 11.3333 7.87992V12.6666C11.3333 12.8434 11.263 13.013 11.138 13.138C11.013 13.263 10.8434 13.3333 10.6666 13.3333H3.33325C3.15644 13.3333 2.98687 13.263 2.86185 13.138C2.73682 13.013 2.66659 12.8434 2.66659 12.6666V5.33325C2.66659 5.15644 2.73682 4.98687 2.86185 4.86185C2.98687 4.73682 3.15644 4.66658 3.33325 4.66658H8.11992C8.29673 4.66658 8.4663 4.59635 8.59132 4.47132C8.71635 4.3463 8.78658 4.17673 8.78658 3.99992C8.78658 3.82311 8.71635 3.65354 8.59132 3.52851C8.4663 3.40349 8.29673 3.33325 8.11992 3.33325H3.33325C2.80282 3.33325 2.29411 3.54397 1.91904 3.91904C1.54397 4.29411 1.33325 4.80282 1.33325 5.33325V12.6666C1.33325 13.197 1.54397 13.7057 1.91904 14.0808C2.29411 14.4559 2.80282 14.6666 3.33325 14.6666H10.6666C11.197 14.6666 11.7057 14.4559 12.0808 14.0808C12.4559 13.7057 12.6666 13.197 12.6666 12.6666V7.87992C12.6666 7.70311 12.5963 7.53354 12.4713 7.40851C12.3463 7.28349 12.1767 7.21325 11.9999 7.21325ZM14.6133 1.74659C14.5456 1.58369 14.4162 1.45424 14.2533 1.38659C14.1731 1.35242 14.087 1.33431 13.9999 1.33325H9.99992C9.82311 1.33325 9.65354 1.40349 9.52851 1.52851C9.40349 1.65354 9.33325 1.82311 9.33325 1.99992C9.33325 2.17673 9.40349 2.3463 9.52851 2.47132C9.65354 2.59635 9.82311 2.66659 9.99992 2.66659H12.3933L5.52659 9.52658C5.4641 9.58856 5.4145 9.66229 5.38066 9.74353C5.34681 9.82477 5.32939 9.91191 5.32939 9.99992C5.32939 10.0879 5.34681 10.1751 5.38066 10.2563C5.4145 10.3375 5.4641 10.4113 5.52659 10.4733C5.58856 10.5357 5.66229 10.5853 5.74353 10.6192C5.82477 10.653 5.91191 10.6705 5.99992 10.6705C6.08793 10.6705 6.17506 10.653 6.2563 10.6192C6.33754 10.5853 6.41128 10.5357 6.47325 10.4733L13.3333 3.60659V5.99992C13.3333 6.17673 13.4035 6.3463 13.5285 6.47132C13.6535 6.59635 13.8231 6.66658 13.9999 6.66658C14.1767 6.66658 14.3463 6.59635 14.4713 6.47132C14.5963 6.3463 14.6666 6.17673 14.6666 5.99992V1.99992C14.6655 1.9128 14.6474 1.82673 14.6133 1.74659Z" fill="#007DCB"/></svg>'; | |
| 727 | + | |
| 704 | 728 | swal({ |
| 705 | 729 | title: '<strong>Great job</strong>', |
| 706 | 730 | type: 'success', |
| 707 | 731 | html: '<p>Your chart is Created!<br>Copy the generated shortcode and paste it into any post or page to display the chart.</p><input type="text" id="ays-chart-create-new" onClick="this.setSelectionRange(0, this.value.length)" readonly value="[ays_chart id=\'' + createdNewChart + '\']" />' + htmlContent, |
| 708 | - showCloseButton: true, | |
| 732 | + confirmButtonText: '<a href="'+ link +'" target="_blank">'+ 'Preview Chart' + ' ' + previewButtonSvgIcon +'</a>', | |
| 733 | + confirmButtonAriaLabel: 'Preview this chart', | |
| 734 | + showCloseButton: true, | |
| 709 | 735 | focusConfirm: false, |
| 710 | - confirmButtonText: '<i class="ays_fa ays_fa_thumbs_up"></i> Done', | |
| 711 | - confirmButtonAriaLabel: 'Thumbs up, done!', | |
| 712 | - }); | |
| 736 | + cancelButtonText: '<i class="ays_fa ays_fa_thumbs_up"></i> Done', | |
| 737 | + cancelButtonAriaLabel: 'Thumbs up, done!', | |
| 738 | + }); | |
| 713 | 739 | deleteCookie('ays_chart_created_new'); |
| 740 | + deleteCookie('ays_chart_created_new'+createdNewChart+'_post_id'); | |
| 714 | 741 | } |
| 715 | - | |
| 742 | + | |
| 716 | 743 | function getCookie (cname) { |
| 717 | 744 | let name = cname + "="; |
| 718 | 745 | let decodedCookie = decodeURIComponent(document.cookie); |
| 719 | 746 | let ca = decodedCookie.split(';'); |
| @@ -734,5 +761,108 @@ | ||
| 734 | 761 | } |
| 735 | 762 | |
| 736 | 763 | }); |
| 737 | 764 | |
| 738 | -})(jQuery); | |
| 765 | +})(jQuery); | |
| 766 | + | |
| 767 | +function selectAndCopyElementContents(el) { | |
| 768 | + if (window.getSelection && document.createRange) { | |
| 769 | + var _this = jQuery(document).find('.ays-chart-copy-element-box'); | |
| 770 | + | |
| 771 | + var text = el.textContent; | |
| 772 | + var textField = document.createElement('textarea'); | |
| 773 | + | |
| 774 | + textField.innerText = text; | |
| 775 | + document.body.appendChild(textField); | |
| 776 | + textField.select(); | |
| 777 | + document.execCommand('copy'); | |
| 778 | + textField.remove(); | |
| 779 | + | |
| 780 | + var selection = window.getSelection(); | |
| 781 | + selection.setBaseAndExtent(el,0,el,1); | |
| 782 | + | |
| 783 | + _this.attr( "data-original-title", 'Copied!' ); | |
| 784 | + _this.attr( "title", 'Copied!' ); | |
| 785 | + | |
| 786 | + _this.tooltip("show"); | |
| 787 | + | |
| 788 | + } else if (document.selection && document.body.createTextRange) { | |
| 789 | + var textRange = document.body.createTextRange(); | |
| 790 | + textRange.moveToElementText(el); | |
| 791 | + textRange.select(); | |
| 792 | + } | |
| 793 | +} | |
| 794 | + | |
| 795 | +document.addEventListener("DOMContentLoaded", function() { | |
| 796 | + var startDate = new Date("2025-09-24"); | |
| 797 | + var endDate = new Date("2025-10-25"); | |
| 798 | + var totalLicenses = 50; | |
| 799 | + var progressionPattern = new Array(3, 2, 1, 4, 2, 3, 1, 2, 4, 3, 2, 1, 3, 2, 4, 1, 3, 2, 2, 3, 1, 2); | |
| 800 | + function getCurrentProgress() { | |
| 801 | + var today = new Date(); | |
| 802 | + var daysPassed = Math.floor((today - startDate) / (1000 * 60 * 60 * 24)); | |
| 803 | + var usedLicenses = 0; | |
| 804 | + for (var i = 0; i < Math.min(daysPassed, progressionPattern.length); i++) { | |
| 805 | + usedLicenses += progressionPattern[i]; | |
| 806 | + } | |
| 807 | + return Math.min(usedLicenses, totalLicenses); | |
| 808 | + } | |
| 809 | + function updateProgress() { | |
| 810 | + var usedLicenses = getCurrentProgress(); | |
| 811 | + var remainingLicenses = totalLicenses - usedLicenses; | |
| 812 | + var progressPercentage = (usedLicenses / totalLicenses) * 100; | |
| 813 | + var remainingElement = document.getElementById("remaining-licenses"); | |
| 814 | + var progressElement = document.getElementById("progress-fill"); | |
| 815 | + if (remainingElement) remainingElement.textContent = remainingLicenses; | |
| 816 | + if (progressElement) progressElement.style.width = progressPercentage + "%"; | |
| 817 | + } | |
| 818 | + updateProgress(); | |
| 819 | +}); | |
| 820 | + | |
| 821 | +// Copy to clipboard function | |
| 822 | +function chartCopyToClipboard(text) { | |
| 823 | + if (navigator.clipboard && window.isSecureContext) { | |
| 824 | + navigator.clipboard.writeText(text).then(function() { | |
| 825 | + chartShowCopyNotification(aysChartBuilderAdmin.successCopyCoupon); | |
| 826 | + }).catch(function() { | |
| 827 | + fallbackCopyTextToClipboard(text); | |
| 828 | + }); | |
| 829 | + } else { | |
| 830 | + fallbackCopyTextToClipboard(text); | |
| 831 | + } | |
| 832 | +} | |
| 833 | + | |
| 834 | +function fallbackCopyTextToClipboard(text) { | |
| 835 | + var textArea = document.createElement("textarea"); | |
| 836 | + textArea.value = text; | |
| 837 | + textArea.style.position = "fixed"; | |
| 838 | + textArea.style.top = "-9999px"; | |
| 839 | + textArea.style.left = "-9999px"; | |
| 840 | + document.body.appendChild(textArea); | |
| 841 | + textArea.focus(); | |
| 842 | + textArea.select(); | |
| 843 | + try { | |
| 844 | + var successful = document.execCommand("copy"); | |
| 845 | + if (successful) { | |
| 846 | + chartShowCopyNotification(aysChartBuilderAdmin.successCopyCoupon); | |
| 847 | + } else { | |
| 848 | + chartShowCopyNotification(aysChartBuilderAdmin.failedCopyCoupon); | |
| 849 | + } | |
| 850 | + } catch (err) { | |
| 851 | + chartShowCopyNotification(aysChartBuilderAdmin.failedCopyCoupon); | |
| 852 | + } | |
| 853 | + document.body.removeChild(textArea); | |
| 854 | +} | |
| 855 | + | |
| 856 | +function chartShowCopyNotification(message) { | |
| 857 | + var notification = document.createElement("div"); | |
| 858 | + notification.className = "ays-chart-copy-notification show"; | |
| 859 | + console.log(notification); | |
| 860 | + notification.textContent = message; | |
| 861 | + document.body.appendChild(notification); | |
| 862 | + setTimeout(function() { | |
| 863 | + notification.classList.remove("show"); | |
| 864 | + setTimeout(function() { | |
| 865 | + document.body.removeChild(notification); | |
| 866 | + }, 300); | |
| 867 | + }, 2000); | |
| 868 | +} | |