Show the daily chess puzzle on your website
You can show the daily chess puzzle on your website or blog with the following code:
<div>
<p>
<span id="puzzlePlayers"></span><br />
<span id="puzzleSite"></span>
</p>
<a id="puzzleLink" href="https://chesspuzzle.net/Daily">
<img id="puzzleImage" alt="Daily Chess Puzzle" />
</a><br />
<h3><span id="puzzleText" /></h3>
</div>
<script type="text/javascript">
var request = new XMLHttpRequest();
request.open('GET', 'https://chesspuzzle.net/Daily/Api', true);
request.onload = function () {
if (request.status >= 200 && request.status < 400) {
var result = JSON.parse(request.responseText);
document.getElementById("puzzleText").textContent = result.Text;
document.getElementById("puzzleLink").href = result.Link;
document.getElementById("puzzleImage").src = result.Image;
document.getElementById("puzzlePlayers").textContent = result.Players;
document.getElementById("puzzleSite").innerHTML = result.Site;
}
};
request.send();
</script>