ID:139367
 
Code:
#define LP(str) list2params(list(str))

src << output(LP("[ATK]"),"StatOutput:replaceATK")
///
<head>
<script type="text/javascript">
function replaceATK(x){
document.getElementById('ATK').innerHTML = x;}
</head>
///
<span id="ATK">[ATK]</span>


Problem description:

The above code uses JavaScript to replace text strings in an Output window. It works fine for MOST people, however some users complained that it doesn't work for them, and it only updates when the whole output is rewritten (not just replaced by JavaScript, but completely refreshes).
Any possible causes?

Thanks!
Emasym wrote:
> runtime error: bad text or out of bounds
> proc name: RecoverIconState (/mob/proc/RecoverIconState)
>
> if(findtext(charging," Fired")) icon_state="[copytext(charging," Fired")] Release"


That's not how copytext() works. If I recall correctly, copytext() has a signature of copytext(text, integer, integer), where the second integer is optional. You have to give it the number of the position in the text string to copy from, which in your case could be the value returned by findtext().

So something more like
copytext(charging, findtext(charging, " Fired"))

Check out the reference entry for copytext() for the particulars. It will explain the exact usage.
In response to Loduwijk
Oh wow, can't believe I missed that. I know perfectly well how copytext works, seems like I forgot the findtext in there to return the integer to start copying, heh. Thanks Loduwijk. That's 1 down.
In response to Emasym
I routinely forget to put the actual text string in as the first argument to copytext(), so you're not alone on that score.

Lummox JR
In response to Lummox JR
Happens when you take for granted you know what you're typing. Lesson well learned, hah.

Lummox, no idea on the Javascript issue? I've got about 2 users for whom it simply does not work. I've had them reinstall BYOND, delete their BYOND map in Documents, and set Firefox as standard browser, nothing changed.
In response to Emasym
Emasym wrote:
Lummox, no idea on the Javascript issue? I've got about 2 users for whom it simply does not work. I've had them reinstall BYOND, delete their BYOND map in Documents, and set Firefox as standard browser, nothing changed.

Well when you mention this is for the output window, I assume you mean a browser control and not an output control, since the output control doesn't support JS at all. I would recommend calling your function with (), and putting in a check for a null value of x, but otherwise I don't see anything really wrong there. (I do know IE has some issues with innerHTML for some elements, but I doubt that's the case here.)

Changing the default browser to Firefox definitely won't work though because the embedded browser is, by necessity, always IE. It would probably help to know which version of IE they're using as opposed to everyone else, because maybe they're on the IE9 beta and it broke this like it also broke line spacing and a bunch of other stuff.

Lummox JR
In response to Lummox JR
Yes it's a browser of course.

So BYOND's browser is always IE? Well one of them was using Chrome and the other FF, chances are their IE is either uninstalled or severely outdated, I'll ask.

Thanks.