Server/Code/modifications to main.js

From kJams Wiki
Revision as of 21:33, 13 March 2011 by Deusexmachina (talk | contribs)
Jump to navigation Jump to search

Often times when using kJams server, the user will miss the "Song Added" alert at the bottom of the window. (Heck, even I just recently noticed it!) As a result, they will mistakenly hit the "Tonight" button over and over, thus adding the song multiple times. To combat this (but not be quite as intrusive as a pop up alert) I made this little code snippet that will make the text bright red and flash it several times to catch the users attention.

To use it, open the file "main.js" (it should be in "~/Libraries/Preferences/kJams/server") and find the "function m_setStatus(status, revert)" code block. Replace it with the text below and save.

function m_setStatus(status, revert) {
	statusObj = document.getElementById("status");
	statusObj.innerHTML = "<span style='color:#FF0000'>" + status + "</span>";
	var newInnerHTML='statusObj.innerHTML = "<span style="color:#FF0000">" + status + "</span>"';
	blink();
	setTimeout("statusObj.innerHTML = newInnerHTML",1250);
}

function blink(){ 
blinkFlag = 1 
blinkCount = 1 
blinkTimer(); 
}

function blinkTimer(){ 
if(blinkFlag==1){
blinkSpeed=250
blinkNumber=10 //If this value is even, the text flashes then remains visible. If it is odd, it flashes, then disappears
blinkFlag=0; 
blinkCount++; 
document.getElementById("status").style.visibility='visible'; 
}else { 
blinkFlag=1; 
blinkCount++; 
document.getElementById("status").style.visibility='hidden'; 
} 
if (blinkCount < blinkNumber) {setTimeout('blinkTimer()', blinkSpeed);} 
}