/* Prediction Page:
Plugin: plugins/predictions-page/
Template file: single-predictions-page.php
Sample URL: http://www.goldderby.com/awardshows/expert-predictions/oscars-2015-nominations/best-picture/ */
function get_prediction_page_league() {
var prediction_page_league = jQuery( '#prediction_page_league' ).val();
var prediction_page_user = jQuery( '#prediction_page_user' ).val();
var sort_by = jQuery( '#prediction_page_sort' ).val();
if ( ! prediction_page_league ) {
return false;
}
var URL = '/awardshows/' + prediction_page_user + '-predictions/' + prediction_page_league + '/';
if (sort_by) {
URL += 'sort/' + sort_by + '/';
}
jQuery( '#prediction_page_league' ).prop( "disabled", true );
jQuery( '#prediction_page_category' ).prop( "disabled", true );
jQuery( '#prediction_page_user' ).prop( "disabled", true );
jQuery( '#prediction_page_sort' ).prop( "disabled", true );
window.location = URL;
}
function get_prediction_page_sort() {
var prediction_page_league = jQuery( '#prediction_page_league' ).val();
var prediction_page_category = jQuery( '#prediction_page_category' ).val();
var prediction_page_user = jQuery( '#prediction_page_user' ).val();
var sort_by = jQuery( '#prediction_page_sort' ).val();
if ( ! prediction_page_league ) {
return false;
}
var URL = '/awardshows/' + prediction_page_user + '-predictions/' + prediction_page_league + '/';
if (prediction_page_category ) {
URL += prediction_page_category + '/';
}
if (sort_by) {
URL += 'sort/' + sort_by + '/';
}
jQuery( '#prediction_page_league' ).prop( "disabled", true );
jQuery( '#prediction_page_category' ).prop( "disabled", true );
jQuery( '#prediction_page_user' ).prop( "disabled", true );
jQuery( '#prediction_page_sort' ).prop( "disabled", true );
window.location = URL;
}
function get_prediction_page_category() {
var prediction_page_league = jQuery( '#prediction_page_league' ).val();
var prediction_page_category = jQuery( '#prediction_page_category' ).val();
var prediction_page_user = jQuery( '#prediction_page_user' ).val();
var sort_by = jQuery( '#prediction_page_sort' ).val();
if ( ! prediction_page_league ) {
return false;
}
var URL = '/awardshows/' + prediction_page_user + '-predictions/' + prediction_page_league + '/';
if (prediction_page_category ) {
URL += prediction_page_category + '/';
}
if (sort_by) {
URL += 'sort/' + sort_by + '/';
}
jQuery( '#prediction_page_league' ).prop( "disabled", true );
jQuery( '#prediction_page_category' ).prop( "disabled", true );
jQuery( '#prediction_page_user' ).prop( "disabled", true );
jQuery( '#prediction_page_sort' ).prop( "disabled", true );
window.location = URL;
}
(function($) {
function get_season_long_leaderboard_page() {
if ( $( '#season_long_tvshow' ).val() && '' === $( '#season_long_tvshow_league' ).val() ) {
var URL = '/season-long-leaderboard/' + $( '#season_long_tvshow' ).val() + '/';
}
if ( $( '#season_long_tvshow' ).val() && $( '#season_long_tvshow_league' ).val() ) {
var URL = '/season-long-leaderboard/' + $( '#season_long_tvshow' ).val() + '/' + $( '#season_long_tvshow_league' ).val() + '/';
}
window.location = URL;
}
})(jQuery);
;
(function($) {
// If not predictions page, bail.
if ( ! $( document.body ).hasClass( 'predictions-page' ) ) {
return;
}
$(
function () {
//Initialize the carousel
$( '.carousel' ).slick().fadeIn();
//check if the slides are less than slidesToShow
var count = $( '.carousel .slick-slide' ).length;
var slick_options = $( '.carousel' ).slick( 'slickGetOption' );
if ( slick_options.slidesToShow > count ) {
$( '.carousel .slick-slide' ).each(
function(){
$( this ).on(
'click', function(){
after_change_callback();
$( '.carousel' ).slick( 'slickNext' );
}
);
}
);
}
$( '.carousel .week-box' ).on(
'click', function () {
var currnet_id = this.id;
var week = currnet_id.substr( currnet_id.indexOf( "_" ) + 1 );
var days_row_id = '#' + week;
//$('#week-slider-navigation').hide();
$( '#week-slider-navigation' ).removeClass( 'display-block' );
$( '#week-slider-navigation' ).addClass( 'display-none' );
$( '.days' ).show();
$( days_row_id ).show();
}
);
$( '.day-navigation .back-icon' ).on(
'click', function () {
$( '.day_box_div' ).hide();
$( '.days' ).hide();
//$('#week-slider-navigation').show();
$( '#week-slider-navigation' ).removeClass( 'display-none' );
$( '#week-slider-navigation' ).addClass( 'display-block' );
}
);
$( '.day-box:not(.disabled)' ).on(
'click', function () {
$( '.day-box:not(.disabled)' ).removeClass( 'active' );
$( '.day:not(.disabled), .date-range:not(.disabled), .no-change:not(.disabled)' ).removeClass( 'active' ).addClass( 'normal' );
$( this ).removeClass( 'normal' ).addClass( 'active' );
$( this ).find( '.day, .date-range, .no-change' ).removeClass( 'normal' ).addClass( 'active' );
//Get clicked date, currnet game_slag, category_id, user_type etc.
var prediction_date = this.id;
var featured_league = $( '#prediction_page_league' ).val();
var nonce = $( '#hp-gd-past-prediction-nonce' ).val();
add_overlay();
$( '#loading-image' ).show();
if ( $( "#prediction-week-slider-wrapper" ).hasClass( "predictions-page" ) ) {
var category_slug = $( '#prediction_page_category' ).val();
var user_type = $( '#prediction_page_user' ).val();
var page_sort = $( '#prediction_page_sort' ).val();
$.ajax(
{
method : "GET",
url: GOLDDERBY.root + 'gameplay/v1/prediction-page/past_predictions',
dataType: 'html',
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-Nonce', GOLDDERBY.nonce );
},
data: {
featured_league: featured_league,
category_slug: category_slug,
user_type: user_type,
page_sort: page_sort,
prediction_date: prediction_date,
security: nonce
},
success: function(data) {
$( '.prediction_changed' ).removeClass( 'prediction_changed' );
$( '#odds-page' ) . html( data );
$( '#loading-image' ).hide();
remove_overlay();
}
}
);
} else if ( $( "#prediction-week-slider-wrapper" ).hasClass( "view-predictions-page" ) ) {
var user_id = $( '#view_past_prediction_user_id' ).val();
var nonce = $( '#hp-gd-past-prediction-nonce' ).val();
$.ajax(
{
method : "GET",
url: GOLDDERBY.root + 'gameplay/v1/prediction-page/user_past_predictions',
dataType: 'html',
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-Nonce', GOLDDERBY.nonce );
},
data: {
featured_league: featured_league,
user_id: user_id,
prediction_date: prediction_date,
security: nonce
},
success: function(data) {
$( '.prediction_changed' ).removeClass( 'prediction_changed' );
$( data ).find( '.predictions-wrapper' ).each(
function() {
var ajax_prediction_id = $( this ).attr( 'id' );
var page_prediction_id = '#' + ajax_prediction_id;
$( '#odds-page' ) . find( page_prediction_id ).html( $( this ).html() );
}
);
$( '#loading-image' ).hide();
remove_overlay();
var top_of_last_predix_changed_div = $( ".prediction_changed:last" ).offset().top;
if ( ( parseInt( $( window ).scrollTop(), 10 ) + parseInt( $( window ).height(), 10 ) ) < parseInt( top_of_last_predix_changed_div, 10 ) ) {
$( "#see-more-indicator" ).show();
$( "#see-more-indicator" ).css( 'top', parseInt( $( window ).scrollTop(), 10 ) + parseInt( $( window ).height(), 10 ) - 150 + 'px' );
} else {
$( "#see-more-indicator" ).hide();
}
$( window ).scroll(
function() {
$( "#see-more-indicator" ).css( 'top', parseInt( $( window ).scrollTop(), 10 ) + parseInt( $( window ).height(), 10 ) - 150 + 'px' );
if ( ( parseInt( $( window ).scrollTop(), 10 ) + parseInt( $( window ).height(), 10 ) ) < parseInt( top_of_last_predix_changed_div, 10 ) ) {
$( "#see-more-indicator" ).show();
} else {
$( "#see-more-indicator" ).hide();
}
}
);
}
}
);
} else if ( $( "#prediction-week-slider-wrapper" ).hasClass( "view-odds-page" ) ) {
var featured_league = $( '#odds_page_league' ).val();
var featured_league_url_parts = featured_league.split( '/' );
featured_league = featured_league_url_parts[ parseInt( featured_league_url_parts.length ) - 2 ];
var user_type = $( '#odds_page_user_type' ).val();
var user_type_parts = user_type.split( '/' );
user_type = user_type_parts[2].replace( '-odds', '' );
$.ajax(
{
method : "GET",
url: GOLDDERBY.root + 'gameplay/v1/odds-page/past_odds',
dataType: 'html',
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-Nonce', GOLDDERBY.nonce );
},
data: {
featured_league: featured_league,
prediction_date: prediction_date,
user_type: user_type
},
success: function(data) {
$( data ).find( '.predictions-wrapper' ).each(
function() {
var ajax_prediction_id = $( this ).attr( 'id' );
var page_prediction_id = '#' + ajax_prediction_id;
$( '#odds-page' ) . find( page_prediction_id ).html( $( this ).html() );
}
);
$( '#loading-image' ).hide();
remove_overlay();
}
}
);
}
}
);
}
);
// Add transparent overlay div to disable category links on carousel.
function add_overlay() {
var $overlay = $( '
' );
$overlay.attr( "id", "carousel-overlay" );
$( ".carousel" ).prepend( $overlay );
}
// Remove the transparent overlay, so user can click on categories now.
function remove_overlay() {
$( "#carousel-overlay" ).remove();
}
})(jQuery);
;
/*
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2012 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
*
* Version: 1.8.3
*
*/
(function(a,b,c,d){var e=a(b);a.fn.lazyload=function(c){function i(){var b=0;f.each(function(){var c=a(this);if(h.skip_invisible&&!c.is(":visible"))return;if(!a.abovethetop(this,h)&&!a.leftofbegin(this,h))if(!a.belowthefold(this,h)&&!a.rightoffold(this,h))c.trigger("appear"),b=0;else if(++b>h.failure_limit)return!1})}var f=this,g,h={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null};return c&&(d!==c.failurelimit&&(c.failure_limit=c.failurelimit,delete c.failurelimit),d!==c.effectspeed&&(c.effect_speed=c.effectspeed,delete c.effectspeed),a.extend(h,c)),g=h.container===d||h.container===b?e:a(h.container),0===h.event.indexOf("scroll")&&g.bind(h.event,function(a){return i()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,c.one("appear",function(){if(!this.loaded){if(h.appear){var d=f.length;h.appear.call(b,d,h)}a("
").bind("load",function(){c.hide().attr("src",c.data(h.data_attribute))[h.effect](h.effect_speed),b.loaded=!0;var d=a.grep(f,function(a){return!a.loaded});f=a(d);if(h.load){var e=f.length;h.load.call(b,e,h)}}).attr("src",c.data(h.data_attribute))}}),0!==h.event.indexOf("scroll")&&c.bind(h.event,function(a){b.loaded||c.trigger("appear")})}),e.bind("resize",function(a){i()}),/iphone|ipod|ipad.*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent.persisted&&f.each(function(){a(this).trigger("appear")})}),a(b).load(function(){i()}),this},a.belowthefold=function(c,f){var g;return f.container===d||f.container===b?g=e.height()+e.scrollTop():g=a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return f.container===d||f.container===b?g=e.width()+e.scrollLeft():g=a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return f.container===d||f.container===b?g=e.scrollTop():g=a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return f.container===d||f.container===b?g=e.scrollLeft():g=a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!a.rightoffold(b,c)&&!a.leftofbegin(b,c)&&!a.belowthefold(b,c)&&!a.abovethetop(b,c)},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})})(jQuery,window,document)
;
(function($) {
$( 'body' ).on(
'click', '.second-nav-item', function() {
var current_score_type_id = $(this).attr('id');
if ( current_score_type_id === 'season_scores' ) {
$( '#season_scores' ).addClass( 'active' );
$( '#week_scores' ).removeClass( 'active' );
} else {
$( '#season_scores' ).removeClass( 'active' );
$( '#week_scores' ).addClass( 'active' );
}
}
);
$( document ).ready(
function () {
$( 'body' ).on(
'click', '.best-predix-scores-widget .top-nav-item', function() {
var current_game_type_id = $(this).attr('id');
var no_of_events = $( '#best-predix-no_of_events' ).val();
var url = '';
$( '.best-predix-scores-widget #best-predix-loading-image' ).css("display", 'block');
game_type = current_game_type_id;
url = '/wp-json/gameplay-api/v1/app/best-prediction-scores/' + game_type + '/' + 'league-data' + '/' + no_of_events;
if ( current_game_type_id === 'tvshow' ) {
$( '.best-predix-scores-widget #awards' ).removeClass( 'active-desktop-main-top active' );
$( '.best-predix-scores-widget #awards' ).addClass( 'inactive-desktop-main-top inactive' );
$( '.best-predix-scores-widget #tvshow' ).removeClass( 'inactive-desktop-main-top inactive' );
$( '.best-predix-scores-widget #tvshow' ).addClass( 'active-desktop-main-top active' );
} else {
$( '.best-predix-scores-widget #tvshow' ).removeClass( 'active-desktop-main-top active' );
$( '.best-predix-scores-widget #tvshow' ).addClass( 'inactive-desktop-main-top inactive' );
$( '.best-predix-scores-widget #awards' ).removeClass( 'inactive-desktop-main-top inactive' );
$( '.best-predix-scores-widget #awards' ).addClass( 'active-desktop-main-top active' );
}
$.ajax(
{
method: "GET",
url: url,
success: function (response) {
success_callback( response.response, game_type, 'league-data' );
},
fail: function (response) {
}
}
);
},
);
$( 'body' ).on(
'click', '.best-predix-scores-widget .second-nav-item', function() {
var current_score_type_id = $(this).attr('id');
var no_of_events = $( '#best-predix-no_of_events' ).val();
$( '.best-predix-scores-widget #best-predix-loading-image2' ).css("display", 'block');
if ( current_score_type_id === 'season_scores' ) {
$( '.best-predix-scores-widget #season_scores' ).addClass( 'active' );
$( '.best-predix-scores-widget #week_scores' ).removeClass( 'active' );
url = '/wp-json/gameplay-api/v1/app/best-prediction-scores/tvshow/' + 'season-data' + '/' + no_of_events;
data_type = 'season-data';
} else {
$( '.best-predix-scores-widget #season_scores' ).removeClass( 'active' );
$( '.best-predix-scores-widget #week_scores' ).addClass( 'active' );
url = '/wp-json/gameplay-api/v1/app/best-prediction-scores/tvshow/' + 'league-data';
data_type = 'league-data';
}
$.ajax(
{
method: "GET",
url: url,
success: function (response) {
success_callback( response.response, 'tvshow', data_type );
},
fail: function (response) {
}
}
);
}
);
}
);
function success_callback( response, game_type, data_type ){
$( '.best-predix-scores-widget #best-predix-loading-image' ).css("display", 'none');
$( '.best-predix-scores-widget #best-predix-loading-image2' ).css("display", 'none');
$( '.best-predix-scores-widget .second-nav-container' ).empty();
$( '.best-predix-scores-widget #week_score_data' ).empty();
$( '.best-predix-scores-widget .links-container' ).remove();
$( '.best-predix-scores-widget #best-predix-data-container-main' ).empty();
var $data_outer_div_class = 'best-predix-container best-predix-container-awards';
if( game_type == 'tvshow' ) {
$data_outer_div_class = 'best-predix-container best-predix-container-tv';
}
var $wrapper = $( '' ).attr( 'class', 'data-container' );
$wrapper.attr( 'id', 'best-predix-data-container' );
var $loading_img_div = $( '' ).attr( 'id', 'best-predix-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 );
var $second_nav_container = $( '' ).attr( 'class', 'second-nav-container' );
var $loading_img_div2 = $( '' ).attr( 'id', 'best-predix-loading-image2' );
$loading_img_div2.css( 'display', 'none' );
$loadin_img2 = $( '
' ).attr( 'src', '/wp-content/themes/vip/pmc-goldderby/assets/images/loading.gif' );
$loadin_img2.attr( 'alt', 'Loading...' );
$loading_img_div2.append( $loadin_img2 );
if( game_type == 'tvshow' ) {
season_score_nav_class = 'second-nav-item';
week_score_nav_class = 'second-nav-item active';
if ( 'season-data' == data_type ) {
season_score_nav_class = 'second-nav-item active';
week_score_nav_class = 'second-nav-item';
}
var $second_nav = $( '' ).attr( 'class', 'second-nav' );
var $second_nav_item_1 = $( '' ).attr( 'class', season_score_nav_class );
$second_nav_item_1.attr( 'id', 'season_scores' );
$second_nav_item_1.text( 'Season Scores' );
$second_nav.append( $second_nav_item_1 );
var $second_nav_item_2 = $( '' ).attr( 'class', week_score_nav_class );
$second_nav_item_2.attr( 'id', 'week_scores' );
$second_nav_item_2.text( 'Recent Week Scores' );
$second_nav.append( $second_nav_item_2 );
$second_nav_container.append( $second_nav );
$wrapper.append( $second_nav_container );
$wrapper.append( $loading_img_div2 );
if ( 'season-data' == data_type ) {
var $season_score_data = $( '' ).attr( 'id', 'season_score_data' );
var $best_predix_container = $( '' ).attr( 'class', $data_outer_div_class );
$.each(
response.season_data, function (i, events) {
if (events.game_event_name) {
$league_name = $( '' ).attr( 'class', 'league-name' );
$league_name.text( events.game_event_name );
$best_predix_container.append( $league_name );
$data_header_container = $( '' ).attr( 'class', 'data-header-container' );
$head1 = $( '' ).attr( 'class', 'head1' );
$head1.text( 'Username' );
$data_header_container.append( $head1 );
$head2 = $( '' ).attr( 'class', 'head2' );
$head2.text( 'Accuracy %' );
$data_header_container.append( $head2 );
$head3 = $( '' ).attr( 'class', 'head2' );
$head3.text( 'Points Won' );
$data_header_container.append( $head3 );
$best_predix_container.append( $data_header_container );
$.each(
events.scores, function (j, score) {
$user_data_container = $( '' ).attr( 'class', 'user-data-container' );
$data1 = $( '' ).attr( 'class', 'data1' );
$data1.text( parseInt(j) + 1 + '.' );
$user_data_container.append( $data1 );
$data2 = $( '' ).attr( 'class', 'data2' );
$img = $( '
' ).attr( 'src', response.user_info[score.user_id]['image'] );
$data2.append( $img );
$user_data_container.append( $data2 );
$data3 = $( '' ).attr( 'class', 'data3' );
$data3.text( response.user_info[score.user_id]['display_name'] );
$user_data_container.append( $data3 );
$data4 = $( '' ).attr( 'class', 'data4' );
$data4.text( score.average_accuracy );
$user_data_container.append( $data4 );
$data5 = $( '' ).attr( 'class', 'data4' );
$data5.text( score.total_points_won );
$user_data_container.append( $data5 );
$best_predix_container.append( $user_data_container );
}
);
$see_more_container = $( '' ).attr( 'class', 'see-more-container' );
$see_more = $( '' ).attr( 'class', 'see-more' );
$link_url = '/all-leaderboards/tvshows/recent/';
$see_more_link = $( '' ).attr( 'href', $link_url );
$see_more_link.text( 'See more' );
$see_more.append( $see_more_link );
$see_more_container.append( $see_more );
$see_more_arrow_container = $( '' ).attr( 'class', 'right-arrow-container' );
$see_more_arrow = $( '' ).attr( 'class', 'right-arrow' );
$see_more_arrow_container.append( $see_more_arrow );
$see_more_container.append( $see_more_arrow_container );
$best_predix_container.append( $see_more_container );
}
}
);
$season_score_data.append( $best_predix_container );
$wrapper.append( $season_score_data );
}
}
if ( 'league-data' == data_type ) {
$wrapper.append( $loading_img_div2 );
var $week_score_data = $( '' ).attr( 'id', 'week_score_data' );
var $best_predix_container = $( '' ).attr( 'class', $data_outer_div_class );
$.each(
response.league_data, function (i, events) {
if (events.game_event_name) {
$event_name = events.game_event_name;
$week_name = '';
if( game_type == 'tvshow' ) {
$event_week_name = $event_name.split( ': ' );
$event_name = $event_week_name[0];
$week_name = $event_week_name[1];
}
$league_name = $( '' ).attr( 'class', 'league-name' );
$league_name.text( $event_name );
$best_predix_container.append( $league_name );
$episode_name = $( '' ).attr( 'class', 'episode-name' );
$episode_name.text( $week_name );
$best_predix_container.append( $episode_name );
$data_header_container = $( '' ).attr( 'class', 'data-header-container' );
$head1 = $( '' ).attr( 'class', 'head1' );
$head1.text( 'Username' );
$data_header_container.append( $head1 );
$head2 = $( '' ).attr( 'class', 'head2' );
$head2.text( 'Accuracy %' );
$data_header_container.append( $head2 );
$head3 = $( '' ).attr( 'class', 'head2' );
$head3.text( 'Points Won' );
$data_header_container.append( $head3 );
$best_predix_container.append( $data_header_container );
$.each(
events.scores, function (j, score) {
$user_data_container = $( '' ).attr( 'class', 'user-data-container' );
$data1 = $( '' ).attr( 'class', 'data1' );
$data1.text( parseInt(j) + 1 + '.' );
$user_data_container.append( $data1 );
$data2 = $( '' ).attr( 'class', 'data2' );
$img = $( '
' ).attr( 'src', response.user_info[score.user_id]['image'] );
$data2.append( $img );
$user_data_container.append( $data2 );
$data3 = $( '' ).attr( 'class', 'data3' );
$data3.text( response.user_info[score.user_id]['display_name'] );
$user_data_container.append( $data3 );
$data4 = $( '' ).attr( 'class', 'data4' );
$data4.text( score.game_summary_accuracy );
$user_data_container.append( $data4 );
$data5 = $( '' ).attr( 'class', 'data4' );
$data5.text( score.game_summary_total_points_won );
$user_data_container.append( $data5 );
$best_predix_container.append( $user_data_container );
}
);
$see_more_container = $( '' ).attr( 'class', 'see-more-container' );
$see_more = $( '' ).attr( 'class', 'see-more' );
$link_url = '/leaderboard/' + events.league_slug;
$see_more_link = $( '' ).attr( 'href', $link_url );
$see_more_link.text( 'See more' );
$see_more.append( $see_more_link );
$see_more_container.append( $see_more );
$see_more_arrow_container = $( '' ).attr( 'class', 'right-arrow-container' );
$see_more_arrow = $( '' ).attr( 'class', 'right-arrow' );
$see_more_arrow_container.append( $see_more_arrow );
$see_more_container.append( $see_more_arrow_container );
$best_predix_container.append( $see_more_container );
}
}
);
$week_score_data.append( $best_predix_container );
$wrapper.append( $week_score_data );
}
/*****See all leaderboard link code start here******/
var $links_container = $( '' ).attr( 'class', 'links-container' );
var $see_all_leaderboards_link_container = $( '' ).attr( 'id', 'see-all-leaderboards-link-container' );
var $see_all_leaderboard_link = $( '' ).attr( 'class', 'see-all-leaderboard-link' );
if( game_type == 'tvshow' ) {
var $link = $( '' ).attr( 'href', '/all-leaderboards/tvshows/recent/' );
$link.text( 'See All TV Shows Leaderboards' );
} else {
var $link = $( '' ).attr( 'href', '/all-leaderboards/awardshows/recent/' );
$link.text( 'See All Awardshow Leaderboards' );
}
$see_all_leaderboard_link.append( $link );
var $right_arrow_container = $( '' ).attr( 'class', 'right-arrow-container' );
var $right_arrow = $( '' ).attr( 'class', 'right-arrow' );
$right_arrow_container.append( $right_arrow );
$see_all_leaderboards_link_container.append( $see_all_leaderboard_link );
$see_all_leaderboards_link_container.append( $right_arrow_container );
$links_container.append( $see_all_leaderboards_link_container );
$wrapper.append( $links_container );
/*****See all leaderboard link code ends here******/
var $predix_button_container_main = $( '' ).attr( 'class', 'predix-button-container-main' );
var $predix_button_container = $( '' ).attr( 'class', 'predix-button-container' );
var $link = $( '' ).attr( 'href', '/leagues' );
var $predix_button = $( '' ).attr( 'class', 'predix-button' );
$predix_button.text( 'Make My Predictions' );
$link.append( $predix_button );
$predix_button_container.append( $link );
$predix_button_container_main.append( $predix_button_container );
$wrapper.append( $predix_button_container_main );
$( '.best-predix-scores-widget #best-predix-data-container-main' ).append( $wrapper );
return;
}
})(jQuery);
;
/*
* Script for custom comments functionality.
*/
(function($) {
$( document ).ready(
function() {
if ( 0 == $( '.custom-comments' ).length ) {
// return if we are not on correct page.
return;
}
/**
* Read More, Comment and Reply Buttons click events
*/
$( '.custom-comments .read-more, .custom-comments .comments, .custom-comments .reply, .custom-comments .add-a-comment' ).on(
'click', function (e) {
var form_id = $(this).parents('.custom-comments').attr('id');
$( '#comments-area-' + form_id ).toggle().css('display', 'flex');
$( '#read-more-area-' + form_id ).toggle();
// Expand reasons text on /awardshows/expert-predictions/* pages.
$( '#' + form_id ).parent().children('.reasons-area').css('display', 'block').hide().show(500);
}
);
/**
* Hide button click event
*/
$( '.comments-area .hide-button' ).on(
'click', function (e) {
var form_id = $(this).parents('.custom-comments').attr('id');
$( '#comments-area-' + form_id ).slideToggle();
$( '#read-more-area-' + form_id ).slideToggle();
// Collapse reasons text on /awardshows/expert-predictions/* pages.
$( '#' + form_id ).parent().children('.reasons-area').css('display', '-webkit-box');
}
);
/**
* Submit button OnClick event
*/
$( '.comments-area .add-reply-button' ).on(
'click', function (e) {
var form_id = $(this).parents('.custom-comments').attr('id');
var nonce = $( '#nonce-' + form_id ).val();
var identifier = $( '#identifier-' + form_id ).val();
var textarea = $( '#reply-text-' + form_id );
var reply_text = textarea.val();
var submit_buttton = $(this);
if ( '' === form_id || '' === nonce || '' === textarea.val() ) {
return;
}
// Update submit button.
submit_buttton.html('Saving, please wait..');
submit_buttton.css('color', '#aaa');
// Disable input text area
textarea.val('');
textarea.attr('placeholder', 'Saving..');
textarea.attr('disabled', 'true');
$.ajax(
{
method: "POST",
url: '/wp-json/gameplay/v1/add-comment/',
data: { identifier: identifier, reply_text: reply_text },
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-Nonce', nonce );
},
success: function (response) {
if ( 'success' == response.message ) {
// Display Comment
var HTML = build_comments_html( response );
$(HTML).insertAfter( '#' + form_id + ' .header' );
// Enable input text area
textarea.removeAttr('disabled');
textarea.attr('placeholder', 'Add your comment here..');
// Enable submit button
submit_buttton.html(' Submit');
submit_buttton.css('color', '#0088cc');
// Animate BG color for the new comment.
$('#' + response.id).hide().fadeIn();
// Add remove events again.
add_remove_event();
} else {
// Error
}
},
fail: function (response) {
// Error
}
}
);
}
);
function build_comments_html( data ) {
// if user can remove the comment.
var trashHTML = '';
if ( true === data.remove ) {
trashHTML = ' Remove
';
}
var HTML = '';
return HTML;
}
add_remove_event();
function add_remove_event() {
/**
* Remove a comment
*/
$( '.comments-area .trash' ).on(
'click', function (e) {
var form_id = $(this).parents('.custom-comments').attr('id');
var comment_id = $(this).parents('.comments-row').attr('id');
var nonce = $( '#nonce-' + form_id ).val();
var form_user = $( '#form-user-' + form_id ).val();
$('#' + comment_id).fadeOut('slow');
$.ajax(
{
method: "POST",
url: '/wp-json/gameplay/v1/delete-reply/',
data: { id: comment_id, form_user: form_user},
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-Nonce', nonce );
},
success: function (response) {
if ( 'success' == response.message ) {
$('#' + comment_id).remove();
} else {
// Error
}
},
fail: function (response) {
// Error
}
}
);
}
);
}
/**
* Show more comments
*/
$( '.show-more-comments' ).on(
'click', function (e) {
var form_id = $(this).parents('.custom-comments').attr('id');
var form_user = $( '#form-user-' + form_id ).val();
var nonce = $( '#nonce-' + form_id ).val();
$('#show-more-link-' + form_id ).hide();
$('#loading-' + form_id ).show();
// Find last comment id ( comments are loaded in DESC form)
var last_comment_id = $( '#' + form_id + ' .comments-row').last().attr('id');
if ( '' === last_comment_id ) {
return;
}
$.ajax(
{
method: "POST",
url: '/wp-json/gameplay/v1/more-comments/',
data: { id: last_comment_id, form_user: form_user },
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-Nonce', nonce );
},
success: function (response) {
if ( 'success' == response.message ) {
var array_length = response.comments.length;
for ( var i = 0; i < array_length; i++ ) {
var HTML = build_comments_html( response.comments[i] );
$('#more-comments-' + form_id ).append( HTML );
$('#loading-' + form_id ).hide();
}
if ( response.total_replies === array_length ) {
$('#show-more-link-' + form_id ).hide();
} else {
$('#show-more-link-' + form_id ).show();
}
add_remove_event();
} else {
// Error
$('#loading-' + form_id ).hide();
$('#show-more-link-' + form_id ).hide();
}
},
fail: function (response) {
// Error
}
}
);
}
);
// To Do:
}
);
})(jQuery);
;
(function($) {
$('body #top-ten-gallery-container').on(
'click', '.ui-sortable li .ttg-arrow-cont .fa-chevron-up', function (index) {
var $curr = $( this );
var $first_element = $curr.closest( 'li' );
var $first_element_content = $first_element.html();
var $first_element_pos = $first_element.attr( 'data-pos' );
var $first_element_item_id = $first_element.attr( 'data-gallery_item_id' );
var $second_element = '';
var $previous_element = $first_element.prev();
if ( $previous_element.is( "li" ) ) {
$second_element = $first_element.prev( 'li' );
} else {
$second_element = $first_element.prev().prev( 'li' );
}
var $second_element_content = $second_element.html();
var $second_element_pos = $second_element.attr( 'data-pos' );
var $second_element_item_id = $second_element.attr( 'data-gallery_item_id' );
if ( $first_element_content != 'undefined' && $second_element_content != 'undefined' ) {
$first_element.html( $second_element_content );
$sno_element = $first_element.find('.ttg-rec-sno');
$sno_element.html($first_element_pos + '.');
$first_element.attr( 'data-gallery_item_id', $second_element_item_id );
$second_element.html($first_element_content);
$sno_element = $second_element.find('.ttg-rec-sno');
$sno_element.html($second_element_pos + '.');
$second_element.attr( 'data-gallery_item_id', $first_element_item_id );
}
}
);
$('body #top-ten-gallery-container').on(
'click', '.ui-sortable li .ttg-arrow-cont .fa-chevron-down', function (index) {
var $curr = $( this );
var $first_element = $curr.closest( 'li' );
var $first_element_content = $first_element.html();
var $first_element_pos = $first_element.attr( 'data-pos' );
var $first_element_item_id = $first_element.attr( 'data-gallery_item_id' );
var $second_element = '';
var $previous_element = $first_element.next();
if ( $previous_element.is( "li" ) ) {
$second_element = $first_element.next( 'li' );
} else {
$second_element = $first_element.next().next( 'li' );
}
var $second_element_content = $second_element.html();
var $second_element_pos = $second_element.attr('data-pos');
var $second_element_item_id = $second_element.attr( 'data-gallery_item_id' );
if ( $first_element_content != 'undefined' && $second_element_content != 'undefined' ) {
$first_element.html($second_element_content);
$sno_element = $first_element.find('.ttg-rec-sno');
$sno_element.html($first_element_pos + '.');
$first_element.attr( 'data-gallery_item_id', $second_element_item_id );
$second_element.html($first_element_content);
$sno_element = $second_element.find('.ttg-rec-sno');
$sno_element.html($second_element_pos + '.');
$second_element.attr( 'data-gallery_item_id', $first_element_item_id );
}
}
);
$('body').on(
'click', '.ttg-btn-container .ttg-btn.ttg-btn-enabled', function () {
var $u_id = $('#u_id').val();
var $total_items = $('#total_items').val();
var $gallery_id = $('#gallery_id').val();
var $nonce = $('#top_ten_widget_nonce').val();
var $choices = [];
/***** Loading image starts here ******/
$loadin_img = $( '
' ).attr( 'src', '/wp-content/themes/vip/pmc-goldderby/assets/images/loading.gif' );
$loadin_img.attr( 'alt', 'Loading...' );
$('.msg-container').html( $loadin_img );
/***** Loading image ends here ******/
// Disable Save button
$('.btn-cont button').removeClass('ttg-btn-enabled');
$('.btn-cont button').addClass('ttg-btn-disabled');
if (parseInt($total_items) > 0) {
var $first_li_element = $('#top-ten-gallery-container').find('li');
var $next_li_element = $first_li_element;
var $item_id = $($first_li_element).attr('data-gallery_item_id');
$choices[0] = $item_id;
for (var i = 1; i < parseInt($total_items); i++) {
$next_li_element = $next_li_element.next('li');
$item_id = $($next_li_element).attr('data-gallery_item_id');
$choices[i] = $item_id;
}
}
$.ajax(
{
method: "POST",
url: '/wp-json/top-ten/v1/top-ten-save-choices/',
data: {
user_id: $u_id,
gallery_id: $gallery_id,
choices: $choices
},
beforeSend: function (xhr) {
xhr.setRequestHeader('X-WP-Nonce', $nonce);
},
success: function (response) {
if ( 'success' === response.message ) {
// Success
$('.ttg-btn-container').css('display', 'none');
$sec_txt_div = $('').attr('class', 'sec-txt-cont');
$sec_txt_sub_div = $('').attr('class', 'sec-txt-sub-cont');
$sec_txt_sub_div.html('If your list is final, click last save below. or go back to change.');
$sec_txt_div.append($sec_txt_sub_div);
$sec_btns_div = $('').attr('class', 'sec-btns-cont');
$sec_btn1_div = $('').attr('class', 'sec-btn1-cont');
$sec_btn1 = $('