$(function () { $.getJSON("https://search-api.nfhsnetwork.com/views/events/upcoming?size=4", function (data) { var str = ''; $.each(data.items, function (i, item) { var date = formatDate(new Date(item.start_time)); str += '
'; str += '' + item.headline.replace(/ /g, ' ') + ''; str += '' + item.activity.replace(/ /g, ' ') + ''; str += '' + date.replace(/ /g, ' ') + ' | ' + item.city.replace(/ /g, ' ') + ',' + item.state.replace(/ /g, ' ') + ''; str += '
'; }); if(str == '') { str = 'There are no upcoming events scheduled.'; str = str.replace(/ /g, ' ') str = '

' + str + '

'; } $('#networkUpcoming').html(str); }); // Get NFHS Network Highlights $.getJSON("https://search-api.nfhsnetwork.com/views/highlights?size=4", function (data) { var str = ''; $.each(data.items, function (i, item) { var date = formatDate(new Date(item.created_at)); str += '
'; str += '' + item.activity.replace(/ /g, ' ') + ''; str += '
' + item.headline.replace(/ /g, ' ') + ''; str += '' + date.replace(/ /g, ' ') + ' | ' + item.city.replace(/ /g, ' ') + ',' + item.state.replace(/ /g, ' ') + ''; str += '
'; }); if(str == '') { str = 'There are no live highlights available.'; str = str.replace(/ /g, ' ') str = '

' + str + '

'; } $('#networkHighlights').html(str); }); // Get NFHS Network Live $.getJSON("https://search-api.nfhsnetwork.com/views/events/live?size=3", function (data) { var str = ''; $.each(data.items, function (i, item) { var date = formatDate(new Date(item.start_time)); str += '
'; str += '' + item.header.replace(/ /g, ' ') + ''; str += '
' + item.headline.replace(/ /g, ' ') + ''; str += '' + item.subheadline.replace(/ /g, ' ') + ''; str += '' + item.activity.replace(/ /g, ' ') + ''; str += '' + date.replace(/ /g, ' ') + ' | ' + item.city.replace(/ /g, ' ') + ',' + item.state.replace(/ /g, ' ') + ''; str += '
'; }); if(str == '') { str = 'There are no live events at this time.'; str = str.replace(/ /g, ' ') str = '

' + str + '

'; } $('#networkLive').html(str); }); //$('.networkTabs').cycle(); //$('.videoTabsWrapper').cycle(); }); function formatDate(val) { var date = new Date(val); var options = { //weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZoneName: 'short' } return date.toLocaleTimeString(navigator.language, options); }