[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    JavaScript: Reading/Writing to TextArea with "innerText"
From:       Stefan Eilers <stefan.eilers () basyskom ! de>
Date:       2007-06-06 8:52:57
Message-ID: FBA500D2-06E7-4BA3-AB56-DFD5B4F11B09 () basyskom ! de
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi!

At the moment I have some fun with extending konqueror to support a  
special web service. Among other problems which still needs to be  
fixed (like a proper support of iFrames), I had to add a feature  
which seems to be supported by IE (see example "eingabefeld.html"  
below). The example changes the attribute "innerText" within a  
textarea. This patch adds reading and writing to a textarea which was  
not available in the implementation in KDELibs 3.5.x. The  
modification is quite simple, therefore I would like to ask whether  
this modification is ok or not. In the latter case: It would be nice  
to know what needs to be added to implement it the right way.

Every comment is welcome! Thanks in advance! :)

Mfg., Dr. Stefan Eilers
--  

Dr.-Ing. Stefan Eilers
Projekt Manager

basysKom GmbH
Robert-Bosch-Str. 7 | 64293 Darmstadt | Germany
Tel: +49 6151 3968753 | Fax: -736 | Mobile: +49 170 4213459
stefan.eilers@basyskom.de | www.basyskom.de

Handelsregister: Darmstadt HRB 9352
Geschaeftsfuehrung: Eva Brucherseifer


["eingabefeld.html" (eingabefeld.html)]

<html>
	<head>
<script type="text/javascript"> <!-- Script-Bereich einleiten -->
function Start(){
	// The following just works on Firefox and IE
	// document.getElementById('txtSection0').contentWindow.document.designMode = "on";
	document.getElementById('txtArea0').innerText = "This text should be visible";
	document.getElementById('txtArea0').oncontextmenu="ContextMenu"
	document.body.style.cursor = "normal";
}


function GetText(){
	var strStr = document.getElementById('txtArea0').innerText;
	alert( "Entered:" + strStr ); 
	DisplayLoading();
	alert( "test" );
	
}	

function ShowSection(iNumber)
{
	alert( "ShowSection()" );
	return true;
}

function ContextMenu(e)
{
	alert( "ContextMenu" );
	return true;
}

</script>


		<title>TextArea Test</title>
		<link id='page_style_sheet' rel="stylesheet" type="text/css" href="Styles.css">
	</head>
	<body onLoad="Start()">
			<TABLE id="tblSection0" openSection='0' style="background:red; FONT-WEIGHT: bold; \
LEFT: 0px;  WIDTH: 821px; COLOR: white; BORDER-STYLE: none; POSITION: absolute; TOP: \
150px; HEIGHT: 165px;" cellSpacing="1" cols="1" cellPadding="1" border="0">  <TR \
id="trTitleSection0">  <TD id="tdSection0" background="images_PNG/bar_fade.png" \
style="BORDER: 1px darkblue solid; CURSOR:pointer; CURSOR: hand; HEIGHT: 22px; \
BACKGROUND-COLOR: royalblue" onclick="return ShowSection(0);" align="left" \
colSpan="2" height="22" title="Click here to 'Open' this section of your essay.">  <p \
id="pSection0">Section 0</p>  </TD>
				</TR>
				<TR id="trSection0" >
					<TD onblur="return SectionOnBlur()" style="background:#c2d8e6;">
						<iframe src='frame_src_2.html' id="txtSection0" onblur="return SectionOnBlur()" \
style= "display: none; Z-INDEX:0; background-color:white; LEFT: 0px; MARGIN: 2px; \
WIDTH: 730px; POSITION: relative; TOP: 0px; HEIGHT: 127px" tabindex="1">  </iframe>
						<textarea id="txtArea0" onblur="return SectionOnBlur()" \
style="font-family:veranda; font-size:12pt; DISPLAY: block; LEFT: 0px; MARGIN: 10px; \
WIDTH: 730px; POSITION: relative; TOP: 0px; HEIGHT: 127px" tabindex="1">This text   \
should never be visible!  </textarea>
					</TD>
					<td style="background:#c2d8e6;" valign=middle>
						<TABLE id="instructional_table_0" style="background:#c2d8e6; font-size:10pt; \
font-weight:bold; WIDTH: 108px; HEIGHT: 51px; border-width:0px;" cellSpacing="2" \
cellPadding="0" width="78" border="0">  <TR>
								<TD unselectable='on' title="Want a hint?" \
style="cursor:pointer;cursor:hand;" id="colHint0" onmouseup="return \
imgHint_onclick()" onmouseover='this.style.color="blue";' \
                onmouseout='this.style.color="black";' >
									<IMG id="imgHint0" height="21" src="images_PNG/help.png" style="LEFT: -1px; \
POSITION: relative; TOP: 3px">  Hint
								</TD>
							</TR>
							<TR>
								<TD unselectable='on' title="Want feedback on your essay?" \
style="cursor:pointer;cursor:hand;" id="colTutor0" onmouseup="return \
imgTutor_onclick(0)" onmouseover='this.style.color="blue";' \
                onmouseout='this.style.color="black";' >
									<IMG id="imgTutor0" height="21" src="images_PNG/check.png" style="POSITION: \
relative; TOP: 2px">  Tutor
								</TD>
							</TR>
							<TR>
								<TD unselectable='on' title="Want to see synonyms for a word? Highlight the \
word and click thesaurus." style="cursor:pointer;cursor:hand;" \
onmouseover='this.style.color="blue";' onmouseout='this.style.color="black";' \
                id="colThesaurus0" onmouseup="return \
                imgThesaurus_onclick('colThesaurus0')">
									<IMG id="imgThesaurus0" style="POSITION: relative; LEFT: -1px; TOP: 3px" \
height="21" src="images_PNG/thes8.png">  Thesaurus
								</TD>
							</TR>
							<TR>
								<TD unselectable='on' title="Want to view the sentence tree?" \
style="cursor:pointer;cursor:hand;" id="colTree0" onmouseup="return \
imgTree_onclick()" onmouseover='this.style.color="blue";' \
                onmouseout='this.style.color="black";' unselectable=true>
									<IMG id="imgTree0" height="21" src="images_PNG/tree.png" style="LEFT: -1px; \
POSITION: relative; TOP: 3px">  Tree
								</TD>
							</TR>
						</TABLE>
					</td>
		<div name="fFeedback" id="fFeedback" style="DISPLAY: none; border:1px solid \
darkblue; overflow:auto; z-index: 110; POSITION: absolute;"></div>

				</TR>
			</TABLE>
		<button onClick="return GetText();" class="input_off" id="cmdLogin"  \
style='font-size: 13px;height:25px; color:black; width:80px;' \
onmouseout="this.className='input_off'" type="button" value="Kick Me!" \
name="fldType">Kick Me</button>

	</body>
</html>


["js_innertext_for_textarea.patch" (js_innertext_for_textarea.patch)]

Index: ecma/kjs_html.cpp
===================================================================
--- ecma/kjs_html.cpp	(Revision 668224)
+++ ecma/kjs_html.cpp	(Arbeitskopie)
@@ -1389,6 +1389,7 @@
     case TextAreaSelectionStart:  return Number(textarea.selectionStart());
     case TextAreaSelectionEnd:    return Number(textarea.selectionEnd());
     case TextAreaTextLength:      return Number(textarea.textLength());
+    case ElementInnerText:        return String(textarea.value());
     }
   }
   break;
@@ -2632,6 +2633,7 @@
       case TextAreaValue:           { textarea.setValue(str); return; }
       case TextAreaSelectionStart:  { textarea.setSelectionStart(value.toInteger(exec)); return; }
       case TextAreaSelectionEnd:    { textarea.setSelectionEnd  (value.toInteger(exec)); return; }
+      case ElementInnerText:        { textarea.setValue(str); return; }
       }
     }
     break;



["PGP.sig" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic