Commits

Alexander Nordlund committed e34fb24

Cleaner javascript.

Comments (0)

Files changed (2)

     <body>
         <p id="mytitle" style="display:none;">[filepath]</p>
         <p onclick="setTitle()">Hello</p>
-        <img id="Play" src="imgs/PlayNormal.png">
-        <img id="Eject" src="imgs/EjectNormal.png">
+	<div id="zeplayer">
+		<img id="Play" class="button" src="imgs/PlayNormal.png">
+		<img id="Eject" class="button" src="imgs/EjectNormal.png">
+	</div>
     </body>
 </html>
    return xmlHttp.responseText;
 }
 
+function changeImage(id,state)
+{
+	document.getElementById(id).src="imgs/"+id+state+".png";
+}
+
 var prepare = function()
 {
-	document.onclick = function(e) {
+	document.getElementById("zeplayer").onclick = function(e) {
 		e = e || window.event; 
 		var t = e.target || e.srcElement; 
 		
 		//console.log(t.nodeName + ": this or parent id #" + (t.nodeName == "A" ? t.parentNode.parentNode.id : t.id || t.parentNode.id));
-                if (t.id == "Play") { sendCommand(887) }
-                else if (t.id == "Pause") { sendCommand(888); }
-                else if (t.id == "PlayPause") { sendCommand(889); }
+
+		if (t.className == "button") { changeImage(t.id, "Pressed") }
+                if (t.id == "Play") { //sendCommand(887)
+			console.log("887")
+		}
+                
+		else if (t.id == "Pause") { sendCommand(888);
+		}
+                
+		else if (t.id == "PlayPause") { //sendCommand(889);
+		}
 
 		return false;
 	}
 	
+	document.onmouseover = function(e) {
+		e = e || window.event; 
+		var t = e.target || e.srcElement;
+		
+		if (t.className == "button") { changeImage(t.id, "Hot") }
+	}
+
+	document.onmouseout = function(e) {
+		e = e || window.event; 
+		var t = e.target || e.srcElement;
+		
+		if (t.className == "button") { changeImage(t.id, "Normal") }
+	}
 };
 
 window.onload = prepare;