[Laszlo-dev] Documenting javascript in OL docs
John Sundman
jsundman at laszlosystems.com
Thu Jun 29 10:34:54 EDT 2006
I was looking at a nifty little program prosted by user "Pathogen" on
the forums:
http://www.laszlosystems.com/developers/community/forums/
showthread.php?s=&threadid=6704
In particular, I was noticing this line:
var buttonNumber = buttonText.substr(6)
I was trying to remember how substr() counted. So, I consulted the
LZX reference. But that was no help, since substr() is not an LZX
method but a plain-old javascript method and is thus not covered in our
documentation. I couldn't remember whether at <text> object was a pure
javascript string or what, so I quickly read the Developer's Guide, and
nowhere did I see any discussion of how a <text> object in LZX does or
does not correspond to a string object in javascript.
This reminded me of the age-old question of how much we need to say
about javascript itself in the OpenLaszlo docs.
This subject comes up from time to time when people expect to find
certain javascript libraries (regexp being the most common) and
discover they're not there, or conversely, as in my case, forget
entirely that there sometimes there are javascript methods that work on
OL objects but which are not in the OL docs.
Anybody care to comment on the best way to handle this general problem
(from a documentation point of view, that is).
Thanks,
jrs
P.S.: What is the relationship between our text objects and javascript
string objects?
P.P.S: By the way, here is the "cute" program I was referring to ( I
modified it slightly by changing his "button" to "ourbutton" to prevent
confusion with the built-in button).
<canvas debug="true">
<class name="myButton" extends="button">
<handler name="onclick">
var buttonText = this.getAttribute('text');
var buttonNumber = buttonText.substr(6);
Debug.write('Button ' + buttonNumber + ' has been
clicked!');
</handler>
</class>
<hbox name="buttonPanel" x="20" y="40" spacing="4"/>
<method name="createButtons" event="oninit">
<![CDATA[
for(var i = 0; i < 10; i++){
var ourbutton = new myButton(canvas.buttonPanel);
ourbutton.setAttribute('text', 'Button #' + i);
}
]]>
</method>
</canvas>
More information about the Laszlo-dev
mailing list