The
function first tests the property
changeCase()
document.forms[0].elements[0].checked
property refers to the first element in the first form of the current document object, which is
the UI for the extension. The
(or enabled) and
false
button, which is the Uppercase button. Because one of the radio buttons is always checked
when the user clicks OK, the code assumes that if the choice is not uppercase, it must be
lowercase. The function sets the variable
The remaining code in the function retrieves the selected text, converts it to the specified case,
and copies it back in place in the document.
To retrieve the selected text for the user's document, the function gets the DOM. It then gets
the root element of the document, which is the
document into the
theWholeDoc
Next,
changeCase()
text. It also retrieves any child nodes (
that contains text, such as
If there are child nodes (
through the children looking for a text node. If one is found, the text
(
theChildren[i].data
.
theSel
If there are no child nodes, the command calls
ending offsets of the selection in
and stores it in
selText
The function then checks the
If so, the function writes the HTML code back to the document in sections: first, the
beginning of the document to the beginning of the selection; then the selected text,
converting it to uppercase (
the end of the document.
If the user selects lowercase, the function performs the same operation, but calls
selText.toLowerCase()
Finally,
changeCase()
property has the value
checked
if it is not. In the interface,
uorl
variable.
calls
getSelectedNode()
theSelNode.childNodes)
.
<b>text</b>
hasChildNodes()
) is stored in
selText
. It then extracts the string between those two offsets
theSel
.
variable to determine whether the user selected uppercase.
uorl
selText.toUppercase()
to convert the selected text to lowercase.
resets the selection and calls
. The
document.forms[0].elements[0]
true
elements[0]
to "u" or "l" to store the user's response.
tag. Finally, it extracts the whole
html
to retrieve the node that contains the selected
returns the value
true
, and the offsets of the text node are stored in
and stores the beginning and
getSelection()
); and last, the end of the selected text to
window.close()
A simple command example
if the element is checked
refers to the first radio
in case the selection is a tag
), the command loops
to close the UI.
175
Need help?
Do you have a question about the DREAMWEAVER 8-EXTENDING DREAMWEAVER and is the answer not in the manual?
Questions and answers