PDA

View Full Version : Template:Stats is broken!!!!!!


coppro
06-05-2005, 04:19 PM
Look! Bulba (http://bulbapedia.bulbagarden.net/wiki/Bulbasaur_%28Pokémon%29)

Archaic
06-05-2005, 05:49 PM
Hmmm....I assume Meowth's fiddling yesterday broke it a little. Whoops. ^^;

How to fix it though...

Zhen Lin
06-05-2005, 08:03 PM
Ah, I knew it. I said something would probably break in the last security fix.

coppro
06-06-2005, 02:48 PM
It seems to be something weird between when the template is called and when its processed. The source of the page has no width specification at all. Scripting could possibly fix it, but that would be drastic...

Misty
06-06-2005, 03:22 PM
Hmmm....I assume Meowth's fiddling yesterday broke it a little. Whoops. ^^;

How to fix it though...
So Meowth's still working on the pedia?

Zhen Lin
06-06-2005, 05:42 PM
The root cause is that there is a security fix that disallows HTML parameter expansion in templates. So the {{{HP}}} in the style parameter isn't being replaced.

It has been fixed in CVS, I'm waiting for MediaWiki to release a new version.

coppro
06-06-2005, 08:12 PM
I could try fixing it with some scripting to set the style to work with the template.

The script would be roughly as follows (If someone could explain to me all the funny stuff that would be great" :

<script language="javascript">
<!--

function style(div,valuename){

if(valuename="atk"){
var value={{{Attack}}}
}

if(valuename="def"){
var value={{{Defense}}}
}

if(valuename="spd"){
var value={{{Speed}}}
}

if(valuename="hp"){
var value={{{HP}}}
}

if(valuename="spatk"){
var value={{{SpAtk}}}
}

if(valuename="atk"){
var value={{{SpDef}}}
}

div.style="background-color: rgb(240,128,48); width: "+value+"px; height: 10px; border: 1px solid black; overflow: hidden";

}


//-->

</script>

{|
|-
|style="text-align:right;"|HP:
!style="text-align:left;"|{{{HP}}}
|<div class="statbar" style="" onload="style(this,"hp")>&nbsp;</div>
|-
|style="text-align:right;"|Attack:
!style="text-align:left;"|{{{Attack}}}
|<div class="statbar" style="" onload="style(this,"atk")>&nbsp;</div>
|-
|style="text-align:right;"|Defense:
!style="text-align:left;"|{{{Defense}}}
|<div class="statbar" style="" onload="style(this,"def")>&nbsp;</div>
|-
|style="text-align:right;"|SpAtk:
!style="text-align:left;"|{{{SpAtk}}}
|<div class="statbar" style="" onload="style(this,"spatk")>&nbsp;</div>
|-
|style="text-align:right;"|SpDef:
!style="text-align:left;"|{{{SpDef}}}
|<div class="statbar" style="" onload="style(this,"spdef")>&nbsp;</div>
|-
|style="text-align:right;"|Speed:
!style="text-align:left;"|{{{Speed}}}
|<div class="statbar" style="" onload="style(this,"spd")>&nbsp;</div>
|}

This should bypass the security because the system would decide that the templating was not inside an element.

Zhen Lin
06-07-2005, 01:08 AM
Hmm. Funny, that you've used Javascript. Accidental Javascript inclusion was exactly what they were trying to prevent. (I assume you can't use custom Javascript anyway.)

Zhen Lin
06-08-2005, 08:35 PM
I have patched the parser with the relevant fixes. I think this should fix the {{tt}} and {{Stats}} problems.