Uncaught TypeError: moment.tz is not a function
-
Hi All,
I have problem with Raffle Ticket Generator Gold – Woocommerce.
When is plugin enable, I got an error in the console, and my navigation not working properly.
Uncaught TypeError: moment.tz is not a function at HTMLDocument.<anonymous> (script.js?ver=5.4.2:5) at i (jquery.js?ver=1.12.4-wp:2) at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2) at Function.ready (jquery.js?ver=1.12.4-wp:2) at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)
This is full code of my script.js file
jQuery(function() { var nextYear_winner = moment.tz(jQuery('#time-remaining-winner').val(), jQuery('#timezone-winner').val()); jQuery('#time-winner').countdown(nextYear_winner.toDate(), function(event) { var $this = jQuery(this).html(event.strftime('' + '<span>%-w</span> week%!w ' + '<span>%-d</span> day%!d ' + '<span>%H</span> hr ' + '<span>%M</span> min ' + '<span>%S</span> sec')); if(event.elapsed) { jQuery("#start").html('<p style="color:red; font-weight:bold">'+jQuery("#textstart").val()+'</p>'); jQuery('#winner').css({'opacity' : '1' }); jQuery(".newsticker-jcarousellite").jCarouselLite({ vertical: true, hoverPause:false, visible: 5, auto:500, speed:-300, btnNext: ".next", btnPrev: ".prev" }); jQuery( ".prev" ).trigger( "click" ); jQuery('#time-winner').hide(); jQuery('#time-winner-selection').countdown(nextYear_winner.add(jQuery("#time").val()/2,jQuery("#formate").val()).toDate(), function(event) { var $this = jQuery(this).html(event.strftime('' + '<span>%-w</span> week%!w ' + '<span>%-d</span> day%!d ' + '<span>%H</span> hr ' + '<span>%M</span> min ' + '<span>%S</span> sec')); if(event.elapsed) { jQuery(this).html('<p style="color:red; font-weight:bold">'+jQuery("#textend").val()+'</p>'); jQuery("#start").hide(); jQuery( ".next" ).trigger( "click" ); jQuery(".newsticker-jcarousellite").hide(); var winnertype = ''; for (i = 1; i <= jQuery("#numberofwinners").val(); i++) { winnertype += ','+jQuery("#winnertype"+i).val(); } jQuery.post(wpAjax.wpurl+"/wp-content/plugins/raffle-ticket-generator-gold/includes/ajax/ajax.php", { time: jQuery("#time-remaining-winner").val(), cattid: jQuery("#catid").val(), timezone:jQuery("#timezone-winner").val(), winnertypes:winnertype }) .done(function( data ) { jQuery(".winner-selected").html(data); }); jQuery(".winner-selected").show(); jQuery(this).unbind(); } }); } else { jQuery(".winners").hide(); jQuery(".winner-selected").hide(); } }); jQuery('.quantity input[name=quantity]').change(function() { inputboxes = ''; ticket_numbers = jQuery('#no_of_tickets').val(); for (i = 1; i<=jQuery(this).val()*ticket_numbers; i++) { inputboxes += '<label>Ticket Number '+i+' :</label><input type="text" value="" id ="manual_ticket_number_'+i+'" name="manual_ticket_number_'+i+'" onblur=check_manual_ticket_number("manual_ticket_number_'+i+'")><span></span><br />'; } if (jQuery(this).val()*ticket_numbers > 3) { inputboxes += '<br><input type="button" class="button alt" value="Fill all remaining tickets" style="float:right" onclick=fill_remaining("'+jQuery(this).val()*ticket_numbers+'")>'; } jQuery('#manual').html(inputboxes); }); var nextYear_start = moment.tz(jQuery('#time-start-input').val(), jQuery('#timezone-start').val()); var nextYear_remaining = moment.tz(jQuery('#time-remaining-input').val(), jQuery('#timezone-remaining').val()); jQuery('#time-remaining-start').countdown(nextYear_start.toDate(), function(event) { var $this = jQuery(this).html(event.strftime('' + '<span>%-w</span> week%!w ' + '<span>%-d</span> day%!d ' + '<span>%H</span> hr ' + '<span>%M</span> min ' + '<span>%S</span> sec')); if (event.elapsed){ jQuery(this).html(''); jQuery(".single_add_to_cart_button").show(); jQuery(".quantity").show(); jQuery("#start").hide(); jQuery("#time-remaining-start").hide(); jQuery("#end").show(); jQuery("#time-remaining").show(); } else { jQuery(".single_add_to_cart_button").hide(); jQuery(".quantity").hide(); jQuery("#end").hide(); jQuery("#time-remaining").hide(); } }); jQuery('#time-remaining').countdown(nextYear_remaining.toDate(), function(event) { var $this = jQuery(this).html(event.strftime('' + '<span>%-w</span> week%!w ' + '<span>%-d</span> day%!d ' + '<span>%H</span> hr ' + '<span>%M</span> min ' + '<span>%S</span> sec')); if (event.elapsed){ jQuery(this).html('<p style="color:red; font-weight:bold">This Raffle has ended.</p>'); jQuery(".single_add_to_cart_button").hide(); jQuery(".quantity").hide(); jQuery("#end").hide(); jQuery("#start").hide(); jQuery("#time-remaining-start").hide(); } }); jQuery( "#start" ).click(function() { jQuery('#newsticker-demo').css({'opacity' : '1' }); jQuery('.winner-top').hide('slow'); }); jQuery( "#stop" ).click(function() { jQuery('#newsticker-demo').hide('slow'); jQuery('#winner-name').show('slow'); }); jQuery(".newsticker-jcarousellite").jCarouselLite({ vertical: true, hoverPause:true, visible: 3, auto:500, speed:-400, btnNext: ".next", btnPrev: ".prev" }); }); function manual_ticket_selection(id) { if (id == "ticket_selection_automatically") { jQuery('#manual input').removeAttr('required'); jQuery('#ticket_type').val('automatic'); jQuery('.quantity').show('slow'); jQuery('.single_add_to_cart_button').show('slow'); jQuery('#manual').hide('slow'); } if (id == "ticket_selection_manual") { jQuery('#manual input').attr('required', 'required'); jQuery('#ticket_type').val('manual'); jQuery('.quantity').hide('slow'); jQuery('.single_add_to_cart_button').hide('slow'); jQuery('#manual').show('slow'); } } function check_manual_ticket_number(id) { if (jQuery('#'+id).val() != '') { var duplicate = CheckDuplicates(); if (duplicate == true) { jQuery('#'+id).val(''); alert(" Duplicates Not allowed"); } jQuery.post(wpAjax.wpurl+"/wp-content/plugins/raffle-ticket-generator-gold/includes/ajax/manual_tickets_ajax.php", { cat_id: jQuery("#cat_id").val(), tickets_designation: jQuery("#tickets_designation").val(), ticket_prefix: jQuery("#ticket_prefix").val(), ticket_number: jQuery('#'+id).val(), manual_ticket_number_id:id }) .done(function( data ) { if (data == 'Not Available') { alert(data+" Try adding some other number"); jQuery('#'+id).val(''); jQuery('#'+id).css('border','1px solid #ff0000'); jQuery('.quantity').hide('slow'); jQuery('.single_add_to_cart_button').hide('slow'); } else { jQuery('#'+id).css('border','1px solid green'); jQuery('.quantity').show('slow'); jQuery('.single_add_to_cart_button').show('slow'); } }); } } function fill_remaining(number_of_tickets) { j = 0; empty_ids = ''; for(i=0;i<=number_of_tickets;i++) { if (jQuery('#manual_ticket_number_'+i).val() == '') { j++; empty_ids += i+','; } } jQuery.post(wpAjax.wpurl+"/wp-content/plugins/raffle-ticket-generator-gold/includes/ajax/put_tickets_ajax.php", { cat_id: jQuery("#cat_id").val(), tickets_designation: jQuery("#tickets_designation").val(), ticket_prefix: jQuery("#ticket_prefix").val(), number_of_tickets_to_generate: j, emptyids : empty_ids }) .done(function( data ) { var ticketnumber = data.split(","); var emptyids = empty_ids.split(","); for (k=0;k<=emptyids.length;k++) { jQuery('#manual_ticket_number_'+emptyids[k]).val(ticketnumber[k]) ; } jQuery('.quantity').show('slow'); jQuery('.single_add_to_cart_button').show('slow'); }); } function CheckDuplicates() { var values = []; //Create array where we'll store values jQuery(".duplicate").removeClass("duplicate"); //Clear all duplicates var $inputs = jQuery('input[class="manual_inputs"]'); //Store all inputs $inputs.each(function() { //Loop through the inputs var v = this.value; if (!v) return true; //If no value, skip this input //If this value is a duplicate, get all inputs from our list that //have this value, and mark them ALL as duplicates if (values.includes(v)) $inputs.filter(function() { return this.value == v }).addClass("duplicate"); values.push(v); //Add the value to our array }); return jQuery(".duplicate").length > 0; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Uncaught TypeError: moment.tz is not a function’ is closed to new replies.