Categories
- No categories
Archives
No archives to show.
wordpress-seo
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/sportsgambleusa/wp-includes/functions.php on line 6114Call: 0123-456789
Email: email@domain.com
Upcoming and live Events Calendar
var metaRequest = new XMLHttpRequest(); var page = 1; var sport="Basketball";
var sportSelectorDiv = document.getElementById("sportSelector"); sportSelectorDiv.innerHTML = ""; sportSelectorDiv.classList.add("table");
var sportDivBasketBall = document.createElement("div"); sportDivBasketBall.classList.add("cell"); var sportIconBasketBall = document.createElement("i"); sportIconBasketBall.classList.add("fa-3x"); sportIconBasketBall.classList.add("fas"); sportIconBasketBall.classList.add("fa-basketball-ball"); sportDivBasketBall.appendChild(sportIconBasketBall); sportDivBasketBall.onclick = function() { page = 1; sport = "Basketball"; loadWidget(); }
var sportDivFootball = document.createElement("div"); sportDivFootball.classList.add("cell"); var sportIconFootball = document.createElement("i"); sportIconFootball.classList.add("fa-3x"); sportIconFootball.classList.add("fas"); sportIconFootball.classList.add("fa-football-ball"); sportDivFootball.appendChild(sportIconFootball); sportDivFootball.onclick = function() { page = 1; sport = "football"; loadWidget(); }
var sportDivBaseball = document.createElement("div"); sportDivBaseball.classList.add("cell"); var sportIconBaseball = document.createElement("i"); sportIconBaseball.classList.add("fa-3x"); sportIconBaseball.classList.add("fas"); sportIconBaseball.classList.add("fa-baseball"); sportDivBaseball.appendChild(sportIconBaseball); sportDivBaseball.onclick = function() { page = 1; sport = "baseball"; loadWidget(); }
sportSelectorDiv.appendChild(sportDivBasketBall); sportSelectorDiv.appendChild(sportDivFootball); sportSelectorDiv.appendChild(sportDivBaseball);
function loadWidget() {
var metaURL = "https://sportsgambleusa.com/api/fixtures.php?sport="+sport+"&country=United%2BStates&page="+page; metaRequest.open("GET", metaURL, true);
function addPagingControls(calendar,calendarMetaDiv) {
var div = document.createElement("div"); div.classList.add("row");
var backDiv = document.createElement("div"); backDiv.classList.add("cell"); backDiv.innerHTML = "<<<"; div.appendChild(backDiv); var indexDiv = document.createElement("div"); indexDiv.classList.add("cell"); indexDiv.innerHTML = "Page " + page + " of " + calendar.pages; div.appendChild(indexDiv); var forwardDiv = document.createElement("div"); forwardDiv.classList.add("cell"); forwardDiv.innerHTML = ">>>"; div.appendChild(forwardDiv);
backDiv.onclick = function() { page = page -1; if (page < 1) { page = 1; } loadWidget(); } forwardDiv.onclick = function() { page = page +1; if (page >= calendar.pages) { page = calendar.pages; } loadWidget(); }
calendarMetaDiv.appendChild(div); }
function addRow(event,calendarMetaDiv) { console.log(event);
var div = document.createElement("div"); div.classList.add("row");
var sportDiv = document.createElement("div"); sportDiv.classList.add("cell"); var sportIcon = document.createElement("i"); sportIcon.classList.add("fas"); sportIcon.classList.add("fas"); sportIcon.classList.add("fa-"+event.sport.name+"-ball"); var sportName = document.createElement("div"); sportName.classList.add("row"); sportName.innerHTML = event.sport.name; sportDiv.appendChild(sportIcon); sportDiv.appendChild(sportName);
var gameMetaDiv = document.createElement("div"); gameMetaDiv.classList.add("cell"); var gameTitleDiv = document.createElement("div"); gameTitleDiv.classList.add("row"); gameTitleDiv.innerHTML = event.cachedFrontEndName; var gameLocationDiv = document.createElement("div"); gameLocationDiv.classList.add("row"); gameLocationDiv.innerHTML = event.location.place.name + " - " + event.location.city.name; gameMetaDiv.appendChild(gameTitleDiv); gameMetaDiv.appendChild(gameLocationDiv);
var dateMetaDiv = document.createElement("div"); dateMetaDiv.classList.add("cell"); var gameDateDiv = document.createElement("div"); gameDateDiv.classList.add("row"); gameDateDiv.innerHTML = new Date(event.startTime).toDateString() + "" + new Date(event.startTime).toTimeString().slice(0, 8); dateMetaDiv.appendChild(gameDateDiv);
div.appendChild(sportDiv); div.appendChild(gameMetaDiv); div.appendChild(dateMetaDiv);
calendarMetaDiv.appendChild(div); }
metaRequest.onreadystatechange = function () { if (metaRequest.readyState == 4 && metaRequest.status == 200) {
var doc = metaRequest.response; var calendarMetaDiv = document.getElementById("calendarMeta"); calendarMetaDiv.innerHTML = ""; calendarMetaDiv.classList.add("table"); const calendar = JSON.parse(doc);
calendar.events.map(event => ( addRow(event,calendarMetaDiv) ));
addPagingControls(calendar,calendarMetaDiv);
} }; metaRequest.send(null);
}
loadWidget();