/
index.html
84 lines (83 loc) · 2.19 KB
/
index.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>giles</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#host').val(document.domain.length ? document.domain : 'localhost');
$('#execute').click(function(){
var host = $('#host').val(),
port = $('#port').val(),
queryText = $('#query').val(),
queryRecord = {SQL:queryText},
queryJSON = JSON.stringify(queryRecord),
escapedQueryJSON = escape(queryJSON.replace(/ /g,"+")),
url = 'http://'+host+':'+port+'/db?'+escapedQueryJSON;
$.ajax({
url: url,
dataType: 'text',
success: function(data, successCode, xhr) {
$('#error').empty();
$('#result').text(data);
},
error: function (xhr, msg, exception){
console.log('ajax.error ', xhr, msg, exception);
$('#error').text('ERROR: '+msg);
}
});
});
$(document).ajaxStart(function(){
$('#spinner').show();
});
$(document).ajaxStop(function(){
$('#spinner').hide();
});
});
</script>
<style type="text/css">
body {
font-family: sans-serif;
}
div {
margin-bottom: 1em;
}
input[type="text"], #query, #result {
font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
}
#error {
color: red;
}
#result {
font-size: 11px;
background-color: #eee;
}
#spinner {
display: none;
}
</style>
</head>
<body>
<form action="#">
<div>
Giles — a simple ajax frontend to <a href="http://code.nytimes.com/projects/dbslayer">DBSlayer</a>
</div>
<div style="font-size:smaller">
Host: <input type="text" id="host">
Port: <input type="text" id="port" value="9090" size="4">
</div>
<div>
Query:<br>
<textarea id="query" rows="10" cols="80">use mysql;select name from help_topic;</textarea><br>
<input type="button" id="execute" value="Execute">
<img src="spinner.gif" alt="" id="spinner"><br>
</div>
<div id="error"></div>
<div>
Result:<br>
<div id="result"></div>
</div>
</form>
</body>
</html>