提交 890a9624 authored 作者: Thomas Mueller's avatar Thomas Mueller

H2 Console: HTML and XML documents can now be edited in an updatable result set.…

H2 Console: HTML and XML documents can now be edited in an updatable result set. There is (limited) support for editing multi-line documents.
上级 33550415
...@@ -30,7 +30,8 @@ Change Log ...@@ -30,7 +30,8 @@ Change Log
</li><li>When opening a remote session, don't open a temporary file if the trace level is set to zero </li><li>When opening a remote session, don't open a temporary file if the trace level is set to zero
</li><li>Use HMAC for authenticating remote LOB id's, removing the need for maintaining a cache, and removing the limit </li><li>Use HMAC for authenticating remote LOB id's, removing the need for maintaining a cache, and removing the limit
on the number of LOBs per result set. on the number of LOBs per result set.
</li><li>Fix editing of XML documents in web console </li><li>H2 Console: HTML and XML documents can now be edited in an updatable result set.
There is (limited) support for editing multi-line documents.
</li></ul> </li></ul>
<h2>Version 1.3.167 (2012-05-23)</h2> <h2>Version 1.3.167 (2012-05-23)</h2>
......
...@@ -59,17 +59,26 @@ function editRow(row, session, write, undo) { ...@@ -59,17 +59,26 @@ function editRow(row, session, write, undo) {
for(i=1; i<cells.length; i++) { for(i=1; i<cells.length; i++) {
var cell = cells[i]; var cell = cells[i];
var text = getInnerText(cell); var text = getInnerText(cell);
// escape stuff so we can edit data that contains HTML special characters // escape so we can edit data that contains HTML special characters
text = text.replace(/&/g, '&amp;') /* This MUST be the 1st replacement. */ // '&' needs to be replaced first
.replace(/'/g, '&apos;') /* The 4 other predefined entities, required. */ text = text.replace(/&/g, '&amp;').
.replace(/"/g, '&quot;') replace(/'/g, '&apos;').
.replace(/</g, '&lt;') replace(/"/g, '&quot;').
.replace(/>/g, '&gt;'); replace(/</g, '&lt;').
var newHTML = '<input type="text" name="$rowName" value="$t" size="$size" onkeydown="return editKeyDown($row, this, event)" />'; replace(/>/g, '&gt;');
var size;
var newHTML;
if (text.indexOf('\n') >= 0) {
size = 40;
newHTML = '<textarea name="$rowName" cols="$size" onkeydown="return editKeyDown($row, this, event)">$t</textarea/>';
} else {
size = text.length+5;
newHTML = '<input type="text" name="$rowName" value="$t" size="$size" onkeydown="return editKeyDown($row, this, event)" />';
}
newHTML = newHTML.replace('$rowName', 'r' + row + 'c' + i); newHTML = newHTML.replace('$rowName', 'r' + row + 'c' + i);
newHTML = newHTML.replace('$row', row); newHTML = newHTML.replace('$row', row);
newHTML = newHTML.replace('$t', text); newHTML = newHTML.replace('$t', text);
newHTML = newHTML.replace('$size', text.length+5); newHTML = newHTML.replace('$size', size);
cell.innerHTML = newHTML; cell.innerHTML = newHTML;
} }
} }
...@@ -95,8 +104,10 @@ function editKeyDown(row, object, event) { ...@@ -95,8 +104,10 @@ function editKeyDown(row, object, event) {
object.value = 'null'; object.value = 'null';
return false; return false;
} else if(key == 13) { } else if(key == 13) {
editOk(row); if (!event.ctrlKey && !event.shiftKey && !event.altKey) {
return false; editOk(row);
return false;
}
} else if(key == 27) { } else if(key == 27) {
editCancel(row); editCancel(row);
return false; return false;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论