Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
70380398
提交
70380398
authored
2月 17, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto-complete on Tab. Formatting.
上级
7cf52f0b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
53 行删除
+53
-53
query.jsp
h2/src/main/org/h2/server/web/res/query.jsp
+53
-53
没有找到文件。
h2/src/main/org/h2/server/web/res/query.jsp
浏览文件 @
70380398
...
...
@@ -46,8 +46,8 @@ function buildTableAliases(input) {
var
last
=
""
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
var
word
=
list
[
i
].
toUpperCase
();
if
(
word
!=
"AS"
)
{
if
(
columnsByTable
[
last
])
{
if
(
word
!=
"AS"
)
{
if
(
columnsByTable
[
last
])
{
tableAliases
[
word
]
=
last
;
}
last
=
word
;
...
...
@@ -61,11 +61,11 @@ function splitSQL(s) {
var
e
=
s
.
length
;
for
(
var
i
=
0
;
i
<
e
;
i
++
)
{
var
ch
=
s
.
charAt
(
i
);
if
(
ch
==
'_'
||
(
ch
>=
'A'
&&
ch
<=
'Z'
))
{
if
(
ch
==
'_'
||
(
ch
>=
'A'
&&
ch
<=
'Z'
))
{
var
start
=
i
;
do
{
ch
=
s
.
charAt
(
++
i
);
}
while
(
ch
==
'_'
||
(
ch
>=
'0'
&&
ch
<=
'9'
)
||
(
ch
>=
'A'
&&
ch
<=
'Z'
));
}
while
(
ch
==
'_'
||
(
ch
>=
'0'
&&
ch
<=
'9'
)
||
(
ch
>=
'A'
&&
ch
<=
'Z'
));
list
[
list
.
length
]
=
s
.
substring
(
start
,
i
);
}
}
...
...
@@ -76,22 +76,22 @@ function help() {
var
input
=
document
.
h2query
.
sql
;
setSelection
(
input
);
var
pos
=
input
.
selectionStart
;
if
(
pos
>
0
)
{
if
(
pos
>
0
)
{
var
s
=
input
.
value
.
substring
(
0
,
pos
).
toUpperCase
();
var
e
=
pos
-
1
;
for
(;
e
>=
0
;
e
-=
1
)
{
var
ch
=
s
.
charAt
(
e
);
if
(
ch
!=
'_'
&&
(
ch
<
'0'
||
ch
>
'9'
)
&&
(
ch
<
'A'
||
ch
>
'Z'
))
{
if
(
ch
!=
'_'
&&
(
ch
<
'0'
||
ch
>
'9'
)
&&
(
ch
<
'A'
||
ch
>
'Z'
))
{
break
;
}
}
s
=
s
.
substring
(
e
+
1
,
s
.
length
);
buildTableAliases
(
input
.
value
);
if
(
!
columnsByTable
[
s
])
{
if
(
!
columnsByTable
[
s
])
{
s
=
tableAliases
[
s
];
}
if
(
columnsByTable
[
s
])
{
if
(
top
.
h2menu
.
goToTable
(
s
))
{
if
(
columnsByTable
[
s
])
{
if
(
top
.
h2menu
.
goToTable
(
s
))
{
top
.
h2menu
.
document
.
location
=
'tables.do?jsessionid=${sessionId}#'
+
s
;
// top.h2menu.window.blur();
document
.
h2query
.
sql
.
focus
();
...
...
@@ -101,7 +101,7 @@ function help() {
}
function
setSelection
(
element
)
{
if
(
document
.
all
&&
!
is_opera
)
{
if
(
document
.
all
&&
!
is_opera
)
{
try
{
var
range
=
document
.
selection
.
createRange
();
var
copy
=
range
.
duplicate
();
...
...
@@ -122,20 +122,20 @@ function set(field, combo) {
}
function
trim
(
s
)
{
while
(
s
.
charAt
(
0
)
==
' '
&&
s
.
length
>
0
)
{
while
(
s
.
charAt
(
0
)
==
' '
&&
s
.
length
>
0
)
{
s
=
s
.
substring
(
1
);
}
while
(
s
.
charAt
(
s
.
length
-
1
)
==
' '
&&
s
.
length
>
0
)
{
while
(
s
.
charAt
(
s
.
length
-
1
)
==
' '
&&
s
.
length
>
0
)
{
s
=
s
.
substring
(
0
,
s
.
length
-
1
);
}
return
s
;
}
function
trimCommas
(
s
)
{
while
(
s
.
charAt
(
0
)
==
','
&&
s
.
length
>
0
)
{
while
(
s
.
charAt
(
0
)
==
','
&&
s
.
length
>
0
)
{
s
=
s
.
substring
(
1
);
}
while
(
s
.
charAt
(
s
.
length
-
1
)
==
','
&&
s
.
length
>
0
)
{
while
(
s
.
charAt
(
s
.
length
-
1
)
==
','
&&
s
.
length
>
0
)
{
s
=
s
.
substring
(
0
,
s
.
length
-
1
);
}
return
s
;
...
...
@@ -150,10 +150,10 @@ function insertText(s, isTable) {
s
=
decodeURIComponent
(
s
);
var
field
=
document
.
h2query
.
sql
;
var
last
=
s
.
substring
(
s
.
length
-
1
);
if
(
last
!=
'.'
&&
last
!=
'
\'
'
&&
last
!=
'"'
&&
last
>
' '
)
{
if
(
last
!=
'.'
&&
last
!=
'
\'
'
&&
last
!=
'"'
&&
last
>
' '
)
{
s
+=
' '
;
}
if
(
isTable
&&
trim
(
field
.
value
)
==
''
)
{
if
(
isTable
&&
trim
(
field
.
value
)
==
''
)
{
field
.
value
=
'SELECT * FROM '
+
s
;
}
else
{
if
(
document
.
selection
)
{
...
...
@@ -177,7 +177,7 @@ function insertText(s, isTable) {
}
function
showAutoComplete
()
{
if
(
showAutoCompleteWait
==
0
)
{
if
(
showAutoCompleteWait
==
0
)
{
showAutoCompleteWait
=
5
;
setTimeout
(
'showAutoCompleteNow()'
,
100
);
}
else
{
...
...
@@ -190,7 +190,7 @@ function showAutoCompleteNow() {
setSelection
(
input
);
var
pos
=
input
.
selectionStart
;
var
s
=
input
.
value
.
substring
(
0
,
pos
);
if
(
s
!=
lastQuery
)
{
if
(
s
!=
lastQuery
)
{
lastQuery
=
s
;
retrieveList
(
s
);
}
...
...
@@ -199,60 +199,60 @@ function showAutoCompleteNow() {
function
keyDown
(
event
)
{
var
key
=
event
.
keyCode
?
event
.
keyCode
:
event
.
charCode
;
if
(
key
==
null
)
{
if
(
key
==
null
)
{
return
false
;
}
if
(
key
==
13
&&
(
event
.
ctrlKey
||
event
.
metaKey
))
{
// ctrl + return, cmd + return
submitAll
();
return
false
;
}
else
if
(
key
==
13
&&
event
.
shiftKey
)
{
}
else
if
(
key
==
13
&&
event
.
shiftKey
)
{
// shift + return
submitSelected
();
return
false
;
}
else
if
(
key
==
32
&&
(
event
.
ctrlKey
||
event
.
altKey
))
{
}
else
if
(
key
==
32
&&
(
event
.
ctrlKey
||
event
.
altKey
))
{
// ctrl + space
autoCompleteManual
=
true
;
lastQuery
=
null
;
lastList
=
''
;
showAutoCompleteNow
();
return
false
;
}
else
if
(
key
==
190
&&
autoComplete
==
0
)
{
}
else
if
(
key
==
190
&&
autoComplete
==
0
)
{
// dot
help
();
return
true
;
}
var
table
=
getAutoCompleteTable
();
if
(
table
.
rows
.
length
>
0
)
{
if
(
key
==
27
)
{
if
(
table
.
rows
.
length
>
0
)
{
if
(
key
==
27
)
{
// escape
while
(
table
.
rows
.
length
>
0
)
{
while
(
table
.
rows
.
length
>
0
)
{
table
.
deleteRow
(
0
);
}
showOutput
(
''
);
return
false
;
}
else
if
((
key
==
13
&&
!
event
.
shiftKey
)
||
(
key
==
9
&&
!
event
.
shiftKey
)
)
{
//
enter or
tab
if
(
table
.
rows
.
length
>
selectedRow
)
{
}
else
if
(
key
==
9
&&
!
event
.
shiftKey
)
{
// tab
if
(
table
.
rows
.
length
>
selectedRow
)
{
var
row
=
table
.
rows
[
selectedRow
];
if
(
row
.
cells
.
length
>
1
)
{
if
(
row
.
cells
.
length
>
1
)
{
insertText
(
row
.
cells
[
1
].
innerHTML
);
}
if
(
autoComplete
==
0
)
{
if
(
autoComplete
==
0
)
{
setAutoComplete
(
0
);
}
return
false
;
}
}
else
if
(
key
==
38
&&
!
event
.
shiftKey
)
{
}
else
if
(
key
==
38
&&
!
event
.
shiftKey
)
{
// up
if
(
table
.
rows
.
length
>
selectedRow
)
{
if
(
table
.
rows
.
length
>
selectedRow
)
{
selectedRow
=
selectedRow
<=
0
?
table
.
rows
.
length
-
1
:
selectedRow
-
1
;
highlightRow
(
selectedRow
);
}
return
false
;
}
else
if
(
key
==
40
&&
!
event
.
shiftKey
)
{
}
else
if
(
key
==
40
&&
!
event
.
shiftKey
)
{
// down
if
(
table
.
rows
.
length
>
selectedRow
)
{
if
(
table
.
rows
.
length
>
selectedRow
)
{
selectedRow
=
selectedRow
>=
table
.
rows
.
length
-
1
?
0
:
selectedRow
+
1
;
highlightRow
(
selectedRow
);
}
...
...
@@ -270,13 +270,13 @@ function keyDown(event) {
function
keyUp
(
event
)
{
var
key
=
event
==
null
?
0
:
(
event
.
keyCode
?
event
.
keyCode
:
event
.
charCode
);
if
(
autoComplete
!=
0
)
{
if
(
key
!=
37
&&
key
!=
38
&&
key
!=
39
&&
key
!=
40
)
{
if
(
autoComplete
!=
0
)
{
if
(
key
!=
37
&&
key
!=
38
&&
key
!=
39
&&
key
!=
40
)
{
// left, right, up, down: don't show autocomplete
showAutoComplete
();
}
}
if
(
key
==
13
&&
event
.
shiftKey
)
{
if
(
key
==
13
&&
event
.
shiftKey
)
{
// shift + return
return
false
;
}
...
...
@@ -285,13 +285,13 @@ function keyUp(event) {
function
setAutoComplete
(
value
)
{
autoComplete
=
value
;
if
(
value
!=
1
)
{
if
(
value
!=
1
)
{
var
s
=
lastList
;
lastList
=
''
;
showList
(
s
);
}
else
{
var
table
=
getAutoCompleteTable
();
while
(
table
.
rows
.
length
>
0
)
{
while
(
table
.
rows
.
length
>
0
)
{
table
.
deleteRow
(
0
);
}
showOutput
(
''
);
...
...
@@ -299,7 +299,7 @@ function setAutoComplete(value) {
}
function
highlightRow
(
row
)
{
if
(
row
!=
null
)
{
if
(
row
!=
null
)
{
selectedRow
=
row
;
}
var
table
=
getAutoCompleteTable
();
...
...
@@ -312,7 +312,7 @@ function highlightThisRow(row) {
var
r
=
table
.
rows
[
i
];
var
col
=
(
r
==
row
)
?
'#95beff'
:
''
;
var
cells
=
r
.
cells
;
if
(
cells
.
length
>
0
)
{
if
(
cells
.
length
>
0
)
{
cells
[
0
].
style
.
backgroundColor
=
col
;
}
}
...
...
@@ -330,19 +330,19 @@ function showOutput(x) {
}
function
showList
(
s
)
{
if
(
lastList
==
s
)
{
if
(
lastList
==
s
)
{
return
;
}
lastList
=
s
;
var
list
=
s
.
length
==
0
?
null
:
s
.
split
(
'|'
);
var
table
=
getAutoCompleteTable
();
if
(
table
==
null
)
{
if
(
table
==
null
)
{
return
;
}
while
(
table
.
rows
.
length
>
0
)
{
while
(
table
.
rows
.
length
>
0
)
{
table
.
deleteRow
(
0
);
}
if
(
autoComplete
==
0
)
{
if
(
autoComplete
==
0
)
{
return
;
}
selectedRow
=
0
;
...
...
@@ -352,7 +352,7 @@ function showList(s) {
for
(
var
i
=
0
;
list
!=
null
&&
i
<
list
.
length
;
i
++
)
{
var
kv
=
list
[
i
].
split
(
'#'
);
var
type
=
kv
[
0
];
if
(
type
>
0
&&
autoComplete
!=
2
&&
!
autoCompleteManual
)
{
if
(
type
>
0
&&
autoComplete
!=
2
&&
!
autoCompleteManual
)
{
continue
;
}
var
row
=
doc
.
createElement
(
"tr"
);
...
...
@@ -360,14 +360,14 @@ function showList(s) {
var
cell
=
doc
.
createElement
(
"td"
);
var
key
=
kv
[
1
];
var
value
=
kv
[
2
];
if
(
!
key
||
!
value
)
{
if
(
!
key
||
!
value
)
{
break
;
}
count
++
;
cell
.
className
=
'autoComp'
+
type
;
key
=
decodeURIComponent
(
key
);
row
.
onmouseover
=
function
(){
highlightThisRow
(
this
)};
if
(
!
document
.
all
||
is_opera
)
{
if
(
!
document
.
all
||
is_opera
)
{
row
.
onclick
=
function
(){
insertText
(
this
.
cells
[
1
].
innerHTML
);
keyUp
()};
}
// addEvent(row, "click", function(e){var row=e?e.target:window.event.srcElement;alert(row);insertText(row.cells[1].innerHTML)});
...
...
@@ -384,7 +384,7 @@ function showList(s) {
cell
.
appendChild
(
text
);
row
.
appendChild
(
cell
);
}
if
(
count
>
0
)
{
if
(
count
>
0
)
{
highlightRow
();
showOutput
(
'none'
);
}
else
{
...
...
@@ -404,7 +404,7 @@ function retrieveList(s) {
function
addEvent
(
element
,
eventType
,
fn
)
{
// cross-browser event handling for IE5+, NS6 and Mozilla by Scott Andrew
if
(
fn
==
null
)
{
if
(
fn
==
null
)
{
return
;
}
if
(
element
.
addEventListener
)
{
...
...
@@ -419,13 +419,13 @@ function addEvent(element, eventType, fn) {
function
sendAsyncRequest
(
url
)
{
req
=
false
;
if
(
window
.
XMLHttpRequest
)
{
if
(
window
.
XMLHttpRequest
)
{
try
{
req
=
new
XMLHttpRequest
();
}
catch
(
e
)
{
req
=
false
;
}
}
else
if
(
window
.
ActiveXObject
)
{
}
else
if
(
window
.
ActiveXObject
)
{
try
{
req
=
new
ActiveXObject
(
"Msxml2.XMLHTTP"
);
}
catch
(
e
)
{
...
...
@@ -436,7 +436,7 @@ function sendAsyncRequest(url) {
}
}
}
if
(
req
)
{
if
(
req
)
{
req
.
onreadystatechange
=
processAsyncResponse
;
req
.
open
(
"GET"
,
url
,
true
);
req
.
send
(
""
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论