(function($) { $( document ).ready( function () { $( 'body' ).on( 'click', '.latest-odds-widget .top-nav-item', function() { var current_game_type_id = $(this).attr('id'); var url = ''; $( '.latest-odds-widget #latest-odds-loading-image' ).css("display", 'block'); if ( 'latest_odds_widget_tvshow' == current_game_type_id ) { game_type = 'tvshows'; $( '.latest-odds-widget #latest_odds_widget_tvshow' ).addClass( 'active-desktop-main-top' ); $( '.latest-odds-widget #latest_odds_widget_tvshow' ).removeClass( 'inactive-desktop-main-top' ); $( '.latest-odds-widget #latest_odds_widget_awards' ).removeClass( 'active-desktop-main-top' ); $( '.latest-odds-widget #latest_odds_widget_awards' ).addClass( 'inactive-desktop-main-top' ); } else { game_type = 'awardshows'; $( '.latest-odds-widget #latest_odds_widget_tvshow' ).removeClass( 'active-desktop-main-top' ); $( '.latest-odds-widget #latest_odds_widget_tvshow' ).addClass( 'inactive-desktop-main-top' ); $( '.latest-odds-widget #latest_odds_widget_awards' ).addClass( 'active-desktop-main-top' ); $( '.latest-odds-widget #latest_odds_widget_awards' ).removeClass( 'inactive-desktop-main-top' ); } url = '/wp-json/gameplay/v1/odds-hub/' + game_type + '/', $.ajax( { method: "GET", url: url, success: function (response) { success_callback( response, game_type, 'first' ); }, fail: function (response) { } } ); }, ); $( 'body' ).on( 'click', '.latest-odds-widget .top-navigation .item', function() { var current_event_id = $(this).attr('id'); if ( $(this).hasClass( 'active' ) ) { return; } var url = ''; $( '.latest-odds-widget #latest-odds-loading-image2' ).css("display", 'block'); $( '.latest-odds-widget .item' ).removeClass( 'active' ); $(this).addClass("active"); game_type = $( '.latest-odds-widget #odds_widget_current_game_type' ).text(); odds_widget_current_category_id = $( '.latest-odds-widget #odds_widget_current_category_id' ).text(); odds_widget_current_user_type = $( '.latest-odds-widget #odds_widget_current_user_type' ).text(); url = '/wp-json/gameplay/v1/odds-hub/' + game_type + '/' + odds_widget_current_user_type + '/' + current_event_id, $.ajax( { method: "GET", url: url, success: function (response) { success_callback( response, game_type, 'second' ); }, fail: function (response) { } } ); }, ); $( 'body' ).on( 'change', '.latest-odds-widget #category_dropdown', function() { var category_id = $(this).val(); var url = ''; $( '.latest-odds-widget #latest-odds-loading-image3' ).css("display", 'block'); game_type = $( '.latest-odds-widget #odds_widget_current_game_type' ).text(); odds_widget_current_event = $( '.latest-odds-widget #odds_widget_current_event' ).text(); odds_widget_current_user_type = $( '.latest-odds-widget #odds_widget_current_user_type' ).text(); url = '/wp-json/gameplay/v1/odds-hub/' + game_type + '/' + odds_widget_current_user_type + '/' + odds_widget_current_event + '/' + category_id, $.ajax( { method: "GET", url: url, success: function (response) { success_callback( response, game_type, 'third' ); }, fail: function (response) { } } ); }, ); $( 'body' ).on( 'change', '.latest-odds-widget #user_type_dropdown', function() { var user_type = $(this).val(); usr_type = 'combined'; if ( 'expert' == user_type ) { usr_type = 'expert'; } else if ( 'editor' == user_type ) { usr_type = 'editor'; } else if ( 'top24' == user_type ) { usr_type = 'top24'; } else if ( 'users' == user_type ) { usr_type = 'user'; } var url = ''; $( '.latest-odds-widget #latest-odds-loading-image3' ).css("display", 'block'); game_type = $( '.latest-odds-widget #odds_widget_current_game_type' ).text(); odds_widget_current_event = $( '.latest-odds-widget #odds_widget_current_event' ).text(); odds_widget_current_category_id = $( '.latest-odds-widget #odds_widget_current_category_id' ).text(); url = '/wp-json/gameplay/v1/odds-hub/' + game_type + '/' + usr_type + '/' + odds_widget_current_event + '/' + odds_widget_current_category_id, $.ajax( { method: "GET", url: url, success: function (response) { success_callback( response, game_type, 'third' ); }, fail: function (response) { } } ); }, ); } ); function success_callback( response, game_type, resp_type ){ $( '.latest-odds-widget #latest-odds-loading-image' ).css("display", 'none'); $( '.latest-odds-widget #latest-odds-loading-image2' ).css("display", 'none'); $( '.latest-odds-widget #latest-odds-loading-image3' ).css("display", 'none'); if ( 'first' == resp_type ) { $( '.latest-odds-widget #latest-odds-data-container-main' ).empty(); var $wrapper = $( '
' ).attr( 'id', 'latest-odds-widget-container' ); /***** Loading image starts here ******/ var $loading_img_div = $( '
' ).attr( 'id', 'latest-odds-loading-image' ); $loading_img_div.css( 'display', 'none' ); $loadin_img = $( '' ).attr( 'src', '/wp-content/themes/vip/pmc-goldderby/assets/images/loading.gif' ); $loadin_img.attr( 'alt', 'Loading...' ); $loading_img_div.append( $loadin_img ); $wrapper.append( $loading_img_div ); /***** Loading image ends here ******/ var $latest_odds_dynamic_area = $( '
' ).attr( 'id', 'latest-odds-dynamic-area' ); /***** Game names (top navigation) starts here ******/ var $top_navitation = $( '
' ).attr( 'class', 'top-navigation' ); $.each( response.top_navigation, function (i, nav_item) { cl = 'item'; if ( nav_item.league_id == response.selected_league_id ) { cl = 'item active'; } $item = $( '
' ).attr( 'class', cl ); $item.attr( 'id', nav_item.league_id ); $item.text( nav_item.title ); $top_navitation.append( $item ); } ); $latest_odds_dynamic_area.append( $top_navitation ); /***** Game names (top navigation) ends here ******/ } else if ( 'second' == resp_type ){ $( '.latest-odds-widget #second_sec' ).empty(); } else { $( '.latest-odds-widget .latest-odds-user-data-container' ).empty(); } if ( 'third' !== resp_type ) { $second_sec = $( '
' ).attr( 'id', 'second_sec' ); /***** Loading image in second_sec starts here ******/ var $loading_img_div = $( '
' ).attr( 'id', 'latest-odds-loading-image2' ); $loading_img_div.css( 'display', 'none' ); $loadin_img = $( '' ).attr( 'src', '/wp-content/themes/vip/pmc-goldderby/assets/images/loading.gif' ); $loadin_img.attr( 'alt', 'Loading...' ); $loading_img_div.append( $loadin_img ); $second_sec.append( $loading_img_div ); /***** Loading image in second_sec ends here ******/ /***** Current League Title starts here ******/ $league_title = $( '
' ).attr( 'class', 'league_title' ); $league_title.text( response.selected_league_title ); $second_sec.append( $league_title ); /***** Current League Title ends here ******/ $cat_usertype_dropdown_div = $( '
' ).attr( 'class', 'cat-usertype-dropdown-div' ); /***** Category dropdown starts here ******/ $custom_dropdown = $( '' ).attr( 'class', 'custom-dropdown cat-dropdown' ); $select = $( '' ).attr( 'id', 'category_dropdown' ); $.each( response.categories, function (i, cat) { $option = $( '' ).attr( 'value', cat.category_id ); $option.text( cat.category_title ); $select.append( $option ); } ); $custom_dropdown.append( $select ); $cat_usertype_dropdown_div.append( $custom_dropdown ); /***** Category dropdown ends here ******/ /***** user type dropdown starts here ******/ var sortData = [ { value: "combined" }, { value: "editor" }, { value: "top24" }, { value: "users" }, ]; if ( 'awardshows' == game_type ) { sortData = [ { value: "combined" }, { value: "expert" }, { value: "editor" }, { value: "top24" }, { value: "users" }, ]; } $custom_dropdown = $( '' ).attr( 'class', 'custom-dropdown flr' ); $select = $( '' ).attr( 'id', 'user_type_dropdown' ); $.each( sortData, function (i, usertype) { $option = $( '' ).attr( 'value', usertype.value ); $option.text( usertype.value ); $select.append( $option ); } ); $custom_dropdown.append( $select ); $cat_usertype_dropdown_div.append( $custom_dropdown ); /***** user type dropdown ends here ******/ $second_sec.append( $cat_usertype_dropdown_div ); /******** Data heading starts here ********/ $data_heading = $( '
' ).attr( 'class', 'data-heading' ); $f_column = $( '
' ).attr( 'class', 'f_column' ); $f_column.text( 'Nominees' ); $data_heading.append( $f_column ); $s_column = $( '
' ).attr( 'class', 's_column' ); $s_column.text( 'Top Choice' ); $data_heading.append( $s_column ); $t_column = $( '
' ).attr( 'class', 't_column' ); $t_column.text( 'Odds' ); $data_heading.append( $t_column ); $second_sec.append( $data_heading ); /******** Data heading ends here ********/ } /******** Main data container starts here ********/ if ( $( '.latest-odds-widget .latest-odds-user-data-container' ).length && $( ".latest-odds-widget .latest-odds-user-data-container" ).text() == '' ) { $user_data_container = $( '
' ).attr( 'class', 'latest-odds-user-data-container2' ); } else { $user_data_container = $( '
' ).attr( 'class', 'latest-odds-user-data-container' ); } /***** Loading image in second_sec starts here ******/ var $loading_img_div = $( '
' ).attr( 'id', 'latest-odds-loading-image3' ); $loading_img_div.css( 'display', 'none' ); $loadin_img = $( '' ).attr( 'src', '/wp-content/themes/vip/pmc-goldderby/assets/images/loading.gif' ); $loadin_img.attr( 'alt', 'Loading...' ); $loading_img_div.append( $loadin_img ); $user_data_container.append( $loading_img_div ); /***** Loading image in second_sec ends here ******/ $.each( response.odds, function (i, odd) { $user_data = $( '
' ).attr( 'class', 'user-data' ); $data1 = $( '
' ).attr( 'class', 'data1' ); $data1.text( parseInt(i) + 1 + '.' ); $user_data.append( $data1 ); $data2 = $( '
' ).attr( 'class', 'data2' ); $img = $( '' ).attr( 'src', odd.nominee_image ); $data2.append( $img ); $user_data.append( $data2 ); $data3 = $( '
' ).attr( 'class', 'data3' ); $data3.text( odd.candidate_title ); $user_data.append( $data3 ); $data4 = $( '
' ).attr( 'class', 'data4' ); $data4.text( odd.top_choice ); $user_data.append( $data4 ); $data5 = $( '
' ).attr( 'class', 'data5' ); $data5.text( odd.fractional_odds ); $user_data.append( $data5 ); $user_data_container.append( $user_data ); } ); /********* Add hiddend data starts here ************/ $hidden1 = $( '
' ).attr( 'id', 'odds_widget_current_event' ); $hidden1.css( 'display', 'none' ); $hidden1.text( response.selected_league_id ); $user_data_container.append( $hidden1 ); $hidden1 = $( '
' ).attr( 'id', 'odds_widget_current_category_id' ); $hidden1.css( 'display', 'none' ); $hidden1.text( response.selected_category_id ); $user_data_container.append( $hidden1 ); $hidden1 = $( '
' ).attr( 'id', 'odds_widget_current_user_type' ); $hidden1.css( 'display', 'none' ); $hidden1.text( response.selected_user_type ); $user_data_container.append( $hidden1 ); $hidden1 = $( '
' ).attr( 'id', 'odds_widget_current_game_type' ); $hidden1.css( 'display', 'none' ); $hidden1.text( game_type ); $user_data_container.append( $hidden1 ); /********* Add hiddend data ends here ************/ if ( 'third' !== resp_type ) { $second_sec.append( $user_data_container ); } /******** Main data container ends here ********/ if ( 'first' == resp_type ) { $latest_odds_dynamic_area.append( $second_sec ); $wrapper.append( $latest_odds_dynamic_area ); } if ( 'first' == resp_type ) { $( '.latest-odds-widget #latest-odds-data-container-main' ).append( $wrapper ); } else if ( 'second' == resp_type ) { $( '.latest-odds-widget #second_sec' ).append( $second_sec ); } else { $( '.latest-odds-widget .latest-odds-user-data-container' ).append( $user_data_container ); } $( '.lateset-odds-widget-more-link-text a' ).attr( 'href', '/odds/' + response.selected_user_type + '-odds/' + response.selected_league_slug + '/' ); return; } })(jQuery); ; /*! This file is auto-generated */ window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,r="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){d(),e&&new e(o).observe(E.body,{childList:!0,subtree:!0})}function d(e){if(r&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("touchstart",l),I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode&&"a"!==E.activeElement.tagName.toLowerCase())return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n,d=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,i=d.length;o 1 ) { keypress.push( keydowns[ e.key ][1] ); } keypresses.push( keypress ); } } delete keydowns[ e.key ]; lastKeyup = keyupTime; }, supportsPassive ? { passive: true } : false ); form.addEventListener( "focusin", function ( e ) { lastKeydown = null; lastKeyup = null; keydowns = {}; }, supportsPassive ? { passive: true } : false ); form.addEventListener( "focusout", function ( e ) { lastKeydown = null; lastKeyup = null; keydowns = {}; }, supportsPassive ? { passive: true } : false ); } document.addEventListener( 'mousedown', function ( e ) { lastMousedown = ( new Date() ).getTime(); }, supportsPassive ? { passive: true } : false ); document.addEventListener( 'mouseup', function ( e ) { if ( ! lastMousedown ) { // If the mousedown happened before this script was loaded, but the mouseup happened after... return; } var now = ( new Date() ).getTime(); var mouseclick = []; mouseclick.push( now - lastMousedown ); if ( lastMouseup ) { mouseclick.push( lastMousedown - lastMouseup ); } mouseclicks.push( mouseclick ); lastMouseup = now; // If the mouse has been clicked, don't record this time as an interval between keypresses. lastKeydown = null; lastKeyup = null; keydowns = {}; }, supportsPassive ? { passive: true } : false ); document.addEventListener( 'mousemove', function ( e ) { if ( mousemoveTimer ) { clearTimeout( mousemoveTimer ); mousemoveTimer = null; } else { mousemoveStart = ( new Date() ).getTime(); lastMousemoveX = e.offsetX; lastMousemoveY = e.offsetY; } mousemoveTimer = setTimeout( function ( theEvent, originalMousemoveStart ) { var now = ( new Date() ).getTime() - 500; // To account for the timer delay. var mousemove = []; mousemove.push( now - originalMousemoveStart ); mousemove.push( Math.round( Math.sqrt( Math.pow( theEvent.offsetX - lastMousemoveX, 2 ) + Math.pow( theEvent.offsetY - lastMousemoveY, 2 ) ) ) ); if ( mousemove[1] > 0 ) { // If there was no measurable distance, then it wasn't really a move. mousemoves.push( mousemove ); } mousemoveStart = null; mousemoveTimer = null; }, 500, e, mousemoveStart ); }, supportsPassive ? { passive: true } : false ); document.addEventListener( 'touchmove', function ( e ) { if ( touchmoveCountTimer ) { clearTimeout( touchmoveCountTimer ); } touchmoveCountTimer = setTimeout( function () { touchmoveCount++; }, 500 ); }, supportsPassive ? { passive: true } : false ); document.addEventListener( 'touchstart', function ( e ) { lastTouchStart = ( new Date() ).getTime(); }, supportsPassive ? { passive: true } : false ); document.addEventListener( 'touchend', function ( e ) { if ( ! lastTouchStart ) { // If the touchstart happened before this script was loaded, but the touchend happened after... return; } var now = ( new Date() ).getTime(); var touchEvent = []; touchEvent.push( now - lastTouchStart ); if ( lastTouchEnd ) { touchEvent.push( lastTouchStart - lastTouchEnd ); } touchEvents.push( touchEvent ); lastTouchEnd = now; // Don't record this time as an interval between keypresses. lastKeydown = null; lastKeyup = null; keydowns = {}; }, supportsPassive ? { passive: true } : false ); document.addEventListener( 'scroll', function ( e ) { if ( scrollCountTimer ) { clearTimeout( scrollCountTimer ); } scrollCountTimer = setTimeout( function () { scrollCount++; }, 500 ); }, supportsPassive ? { passive: true } : false ); } /** * For the timestamp data that is collected, don't send more than `limit` data points in the request. * Choose a random slice and send those. */ function prepare_timestamp_array_for_request( a, limit ) { if ( ! limit ) { limit = 100; } var rv = ''; if ( a.length > 0 ) { var random_starting_point = Math.max( 0, Math.floor( Math.random() * a.length - limit ) ); for ( var i = 0; i < limit && i < a.length; i++ ) { rv += a[ random_starting_point + i ][0]; if ( a[ random_starting_point + i ].length >= 2 ) { rv += "," + a[ random_starting_point + i ][1]; } rv += ";"; } } return rv; } if ( document.readyState !== 'loading' ) { init(); } else { document.addEventListener( 'DOMContentLoaded', init ); } })();;