JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" value="Force reload" onclick="javascript:pictureValidate()" />
<span>Current song:</span>
<br>
<iframe id="stitle" src=""></iframe>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>
<img class="d" id="1"></img>
</td>
<td>
<img class="t" id="2"></img>
</td>
<td>
<img class="d" id="3"></img>
</td>
</tr>
</table>
<p class="c" id="debug"></p>
<p class="c" id="txt"></p>
CSS
img.d {
width:120px;
height:120px;
}
img.t {
width:120px;
}
table, th, td {
border: 4px solid black;
}
tr {
text-align:center;
}
iframe {
height:40px;
width:402px;
border-style:1;
}
JavaScript
var count = -1;
function pictureValidate() {
console.log("started-------------------------------------------------I");
var clear = false;
var txt = document.getElementById("txt");
var img1 = document.getElementById("1");
var img2 = document.getElementById("2");
var img3 = document.getElementById("3");
var debug = document.getElementById("debug");
var stitle = document.getElementById("stitle");
var test = document.createElement("img");
var art = 'http://rndmradio.net:8000/playingart?sid=1';
var pic = 'http://rndmradio.net:8000/streamart?sid=1';
var csong = 'http://rndmradio.net:8000/currentsong?sid=1';
var isong = '<!--#include virtual="http://rndmradio.net:8000/currentsong?sid=1"-->';
img2.src = art;
img2.onerror = function(){
alert('see');
}
img3.src = pic;
try { // This if statement is the determining factor here, and it refuses to work with me.
console.log("testing...");
if (img2.height > 0) {
console.log("cleared [true]");
clear = true;
} else {
console.log("cleared [false]");
clear = false;
}
} catch (err) {}
if (clear) {
console.log("cover art used");
img1.src = art;
} else {
console.log("default art used");
img1.src = pic;
}
console.log("posting results...");
count = count + 1;
txt.innerHTML = "reloaded [" + count + "] times";
debug.innerHTML = "[img: " + img1.src + "] <br>" + "[art: " + art + "] <br>" + "[pic: " + pic + "] <br>";
stitle.src = csong;
console.log("function finished---------------------------------------" + count);
}