” + d + ” +
‘
‘; } $.each(s, function (i, v) { $(‘.schedule-tabs’).append(template(_this.days[new Date(i).getDay()], runonce)); runonce = true; }); }, populate: function (s) { var _this = this, runonce = false, count=0; function template(o, j) { var cl = (j % 2) ? ” : ‘striped’; cl += (j >= _this.limit) ? ‘ hide’ : ”; return ” + ‘
‘ + moment(o.datetime).format(‘LT’) + ‘
‘ + ‘
‘ + o.title + ‘
‘ + ‘
‘ + o.subtitle + ‘
‘ + ‘
‘ + o.description + ‘
‘ + ”; } function loadMoreTemplate() { return ‘
‘ +
‘‘+
‘
‘; } function showLessTemplate() { return ‘
‘ +
‘‘+
‘
‘;
}
$.each(s, function (i, v) {
var d = _this.days[new Date(i).getDay()].toLowerCase();
$.each(v, function (j, o) {
var nmSubtitle = “”;
if (o.Episode == o.Program) {
nmSubtitle = “”;
} else {
nmSubtitle = o.Episode;
}
var program = { datetime: o.ShowDateTime, title: o.Program, description: o.Description, subtitle: nmSubtitle };
$(‘#sched-‘ + d).append(template(program, j));
(_this.limit == j+1) ? $(‘#sched-‘ + d).append(loadMoreTemplate) : [];
(v.length-1 == j && j>_this.limit) ? $(‘#sched-‘ + d).append(showLessTemplate) : [];
if (!runonce) {
$(‘#sched-‘ + d).addClass(‘in active’);
$(document).trigger(‘programEvent’, program);
}
runonce = true;
});
});
},
scrollUp: function () {
var target = $(‘#schedule-section’);
$(‘html, body’).animate({
scrollTop: target.offset().top – 100
}, 1000);
},
init: function (ms) {
var _this = this;
var hash = (ms) ? “?h=” + ms : “”;
$.getJSON(_this.endpoint + hash, function (data) {
$.each(data, function (i, v) { _this.parse(v); });
_this.createSchedule();
_this.createTabs(_this.data);
_this.populate(_this.data);
});
}
};
// Initialize
schedule.init();
// Intervals
var everyInterval = 1860000; // 31 Minutes
var nextInterval = Math.abs(moment().endOf(‘hour’).toDate() – moment().toDate());
window.setTimeout(function() {
schedule.init(Date.now());
window.setInterval(function() {
schedule.init(Date.now());
}, everyInterval);
}, nextInterval);
$(d).ready(function () {
function showmore(btn) {
$(btn).addClass(‘hide’);
$(btn).parent().siblings().removeClass(‘hide’);
$(btn).parent().siblings().find(‘.sched-less’).removeClass(‘hide’);
}
function showless(btn) {
$(btn).addClass(‘hide’);
schedule.scrollUp();
$(btn).parent().siblings().find(‘.sched-more’).removeClass(‘hide’);
$(btn).parent().siblings().find(‘.sched-more’).parent().nextAll().addClass(‘hide’);
}
$(‘body’).on(‘click’, ‘.sched-more’, function (e) {
showmore(e.target);
});
$(‘body’).on(‘click’, ‘.sched-less’, function (e) {
showless(e.target);
});
});
})(window.jQuery, this);
“, ““] }); })(window.jQuery); ]]>
Get Newsmax on your cable, call us at: 844-500-6397
Get free Newsmax TV alerts for breaking news, latest shows, and guests
Privacy: We never share your email.
Be the first to comment