Example of usingthe LMS API courtesy of Paul Edwards using jquery:
In Index.html
<script src="
https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js
"></script>
<script type="text/javascript">
function Lmsjs(url) {
this.league_base_url = url;
}
Lmsjs.prototype = {
contructor: Lmsjs,
leagueRequest: function (lms, url, org, eventName, selector) {
// Send an AJAX request to the server
$.ajax({
url: url,
type: "POST",
crossDomain: true,
dataType: "json",
data: JSON.stringify({ org: org, name: eventName }),
contentType: "application/json",
error: function (xhr, ajaxOptions, thrownError) {
alert("ajax error status:" + xhr.status);
alert("ajax error:" + thrownError);
},
success: function (data) {
// Create the event
var event = new CustomEvent("results", {
detail: data[0],
});
// Dispatch/Trigger/Fire the event
document.dispatchEvent(event);
},
});
},
leagueResults: function (org, eventName, selector) {
url = this.league_base_url + "match";
this.leagueRequest(this, url, org, eventName, selector);
},
leagueTable: function (org, eventName, selector) {
url = this.league_base_url + "table";
this.leagueRequest(this, url, org, eventName, selector);
},
leagueClub: function (org, eventName, selector) {
url = this.league_base_url + "club";
this.leagueRequest(this, url, org, eventName, selector);
},
leagueEvent: function (org, eventName, selector) {
url = this.league_base_url + "event";
this.leagueRequest(this, url, org, eventName, selector);
},
};
</script>
Using Angular for the website url: string = '';
lmsjs: any;
dataListLeagueOne: any[] = [];
dataListLeagueTwo: any[] = [];
dataListFixtures: any[] = [];
public _reload = true;
ngOnInit() {
this.url = '
https://lms.englishchess.org.uk/lms/lmsrest/league/
';
this.lmsjs = new Lmsjs(this.url);
// get the results table.
this.lmsjs.leagueTable(752, 'Division 1', '#league1');
// get a clubs fixtures
this.lmsjs.leagueClub(752, '8060', '#fixtures'); //752 is the Sussex league code ; 8060 is ECF Club Code, not sure where you get this from tbh
//this.lmsjs.leagueResults(752, "Division 1", "#matches"); <= this will work gets all matches
//this.lmsjs.leagueEvent(36614, "Plummer Knight", "#rounds");<= I couldn't get this going
document.addEventListener('results', (e: any) => {
switch (e.detail.title) {
case 'Division 1':
for (var i = 0; i < e.detail.data.length; i++) {
this.dataListLeagueOne.push({
Team: this.replaceLms(e.detail.data[i][0]),
Play: e.detail.data[i][1],
Won: e.detail.data[i][2],
Draw: e.detail.data[i][3],
Lost: e.detail.data[i][4],
Points: e.detail.data[i][7],
});
}
break;
case 'Division 2':
for (var i = 0; i < e.detail.data.length; i++) {
this.dataListLeagueTwo.push({
Team: this.replaceLms(e.detail.data[i][0]),
Play: e.detail.data[i][1],
Won: e.detail.data[i][2],
Draw: e.detail.data[i][3],
Lost: e.detail.data[i][4],
Points: e.detail.data[i][7],
});
}
break;
case 'Brighton & Hove Fixtures ':
for (var i = 0; i < e.detail.data.length; i++) {
this.dataListFixtures.push({
HomeTeam: e.detail.data[i][0],
Result: e.detail.data[i][1],
AwayTeam: e.detail.data[i][2],
Date: e.detail.data[i][3],
});
}
}
this.reload();
});
}
private reload() {
setTimeout(() => (this._reload = false));
setTimeout(() => (this._reload = true));
}