-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdbQuery.html
More file actions
255 lines (214 loc) · 6.52 KB
/
dbQuery.html
File metadata and controls
255 lines (214 loc) · 6.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>dbQuery</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
<link href="../bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
/* Sticky footer styles
-------------------------------------------------- */
html,body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Set the fixed height of the footer here */
#push,#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
/* Lastly, apply responsive CSS fixes as necessary */
@media ( max-width : 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
#wrap>.container {
padding-top: 60px;
}
.container .credit {
margin: 20px 0;
}
code {
font-size: 80%;
}
</style>
<link href="../bootstrap/assets/css/bootstrap-responsive.css"
rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144"
href="../bootstrap/assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114"
href="../bootstrap/assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72"
href="../bootstrap/assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed"
href="../bootstrap/assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="../bootstrap/assets/ico/favicon.png">
</head>
<body>
<!-- Part 1: Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="brand" href="#">DB Query</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<div class="input-prepend input-append">
<span class="add-on">数据库连接</span> <input class="span7"
id="conn_txt" type="text" value="DSN=mysqldb;SERVER=127.0.0.1;User ID=root;Password=root;Database=esap;Port=3306"><a id="lock_btn" tg='true'
class="btn btn-info"><i class="icon-lock"></i></a></span>
</div>
<hr>
<div class="input-prepend input-append">
<span class="add-on">查询SQL</span><input class="span4"
id="search_txt" type="text"><a id="search_btn"
class="btn btn-info"><i class="icon-search"></i></a>
</div>
<div class="input-prepend input-append" style="float: right">
<span class="add-on">执行SQL</span><input class="span4" id="exec_txt"
type="text"><a id="update_btn" class="btn btn-info"><i
class="icon-tags"></i></a>
</div>
</div>
<!-- data -->
<div id="data_div" ></div>
</div>
<div id="push"></div>
</div>
<div id="footer">
<div class="container">
<p class="muted credit">
肥添 <a href="###">dbQuery by odbc</a>
使用odbc操作数据库小工具
</p>
</div>
</div>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../bootstrap/assets/js/jquery.js"></script>
<script src="../bootstrap/assets/css/mustache.js"></script>
<script src="./dbQuery.js"></script>
<script type="text/mustache" id="tableTemplate">
<table class="table table-hover" width="100%">
<thead>
<tr>
{{#heads}}
<th>{{h_name}}</th>
{{/heads}}
</tr>
</thead>
<tbody>
{{#datas}}
{{#records}}
<tr>
{{#field}}
<td>{{d_value}}</td>
{{/field}}
</tr>
{{/records}}
{{/datas}}
</tbody>
</table>
</script>
<script type="text/javascript">
$(function() {
//lock_btn conn_txt
//search_btn search_txt
//update_btn exec_txt
//data_div
//tableTemplate
//连接开关
lockBtn();
//查询按钮开关
bindExecute();
//更新按钮开关
bindUpdate();
});
function lockBtn(){
$("#lock_btn").click(function() {
var tg=$(this).attr("tg");
if(tg=='false'){
$("#lock_btn").removeClass("disabled");
//$("#lock_btn").addClass("btn btn-info");
$("#lock_btn").attr("tg","true");
$("#conn_txt").removeClass("uneditable-input");
$("#conn_txt").removeAttr("disabled");
dbQuery.release_conn.call(dbQuery,null);
}else{
//$("#lock_btn").removeClass("btn btn-info");
$("#lock_btn").addClass("disabled");
$("#lock_btn").attr("tg","false");
$("#conn_txt").addClass("uneditable-input");
$("#conn_txt").attr("disabled","disabled");
dbQuery.reset_conn.call(dbQuery,($("#conn_txt").val()));
}
});
};
function bindExecute(){
$("#search_btn").click(function(){
var sql=$("#search_txt").val();
var result=dbQuery.executeQuery.call(dbQuery,sql);
refreshView(result);
})
}
function bindUpdate(){
$("#update_btn").click(function(){
var sql=$("#exec_txt").val();
if(sql){
var result=dbQuery.executeUpdate.call(dbQuery,sql);
alert("finish update~!");
}
})
}
//更新结果集合
function refreshView(result){
var template=$("#tableTemplate").html();
var renderTemplate=Mustache.render(template,result);
$("#data_div").empty();
$("#data_div").html(renderTemplate);
}
</script>
</body>
</html>