Welcome to GM Poke.com
Watch Video
What is this
What is this
What is this
ENTER DRAWING
//-------//SETUP VARIABLES //------------------------------ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $(document).ready(function(e) { timer=null;moving=true; carItems = $('.carousel-item').length; $(document) .on('click','.carousel-control-prev',function(){carouselMove(-1);}) .on('click','.carousel-control-next',function(){carouselMove(1);}) .on('click','.btnGiveAways',function(){ $('#modalGiveaway').modal('show'); }) .on("change",'#giveawayId',function(){ $g=$('#giveawayId option:selected'); $t=$('.giveaway.template').clone().removeClass('template').attr({videoCode:$g.attr("videoCode"),videoLink:$g.attr("videoLink"),videoId:$g.attr("value")}); $('.videoTitle',$t).html($g.attr("videoTitle")); $('.btnVideoLink',$t).attr('href',$g.attr("videoLink")); $('#entry').html($t); const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]'); const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl)); }) .on('click','.btnSubmit',function(){ $g=$(this).closest('.giveaway'); videocode=$('.videocode',$g).val(); emailaddress=$('.emailaddress',$g).val(); youtubeusername=$('.youtubeusername',$g).val(); if(youtubeusername.length<3){alert('You must enter the YouTube username you are entering drawing under');fnLoadingModal(false);return;} if(emailaddress==''||!isEmail(emailaddress)){alert('You must enter a valid email address we can contact you at if you win');fnLoadingModal(false);return;} if(videocode==''||videocode!=$g.attr('videocode')){alert('You must enter the valid code to be entered to win this giveaway');fnLoadingModal(false);return;} $('#modalGiveaway').modal('hide'); fnLoadingModal(true); $.post('api/addGiveAwayEntry/auth=3kljlk234324lGiveaway',{videoCode:videocode,emailAddress:emailaddress,youtubeUsername:youtubeusername,videoId:$g.attr('videoId')},function(res){ if(res.status='success'){alert('Congratulations, We have you entered in the '+$('.videoTitle',$g).html()+' giveaway.');}else{alert("Sorry, we are having some difficulty. Please try again later.");} refreshGiveaways(); }); fnLoadingModal(false); $('#modalGiveaway').modal('show'); }); ; carouselMove(0); refreshGiveaways(); }); function carouselMove(direction){ clearInterval(timer); carItems = $('.carousel-item').length; i = $('.carousel-item').index($('.carousel-item.active')); $('.carousel-item.active').removeClass('active'); i=i+direction; switch(true){ case i<0: i=carItems-1; break; case i>carItems-1: i=0; } $('.carousel-item').eq(i).addClass('active'); if(moving){timer = setTimeout(function(){carouselMove(1);},5000);} } function refreshGiveaways(){ $.getJSON('api/getVideos/auth=l1j23jjakljGiveaways',function(res){ if (res.records==undefined||res.records==null){return;} $('#giveawayId option:not(#title)').remove(); $.each(res.records,function(i,v){ $('#giveawayId').append(''); }); }); } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); }