Topic: mascot selection js

Posted under General

I have mascot_bg=5 atm, that atelope-like thingy I think (at least that's what I had for bg last time I was here) which is apparently not available anymore.
This makes bgchanger.js throw up js error instead of falling back to whatever backgrounds it still has.
Plusungood.
Patch attached.

--- http://e621.net/javascripts/bgchanger.js	2013-04-20 11:07:20.253129112 +0300
+++ http://e621.net/javascripts/bgchanger.js	2013-04-20 11:09:37.506459308 +0300
@@ -56,7 +56,8 @@
 function onloadfunction()
 {
 	cur = parseInt(getCookie("mascot_bg"));
-	if (isNaN(cur)) cur = Math.floor(Math.random()*mascots.length);
+	if (isNaN(cur) || cur < 0 || cur >= mascots.length)
+		cur = Math.floor(Math.random()*mascots.length);
 	
 	if (getparam("mascot") && !isNaN(getparam("mascot"))) // override from ?mascot=x param
 	{		

Updated by TonyCoon

Huh, it looks like two of the mascots were removed from the config for some reason. Must be a bug, and I've added them back in, so they should be back soon. I added your revision to the script anyway though, thanks.

Edit: I did not write "They all seem to work just fine for me.". Please do not edit my forum posts.

Updated by anonymous

  • 1