-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonlineextractor.html
More file actions
executable file
·204 lines (176 loc) · 6.13 KB
/
Copy pathonlineextractor.html
File metadata and controls
executable file
·204 lines (176 loc) · 6.13 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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8" />
<title>Snippet Parser</title>
</head>
<script src="jquery-1.9.1.min.js">
</script>
<script src="CodeMirror/lib/codemirror.js"></script>
<script src="CodeMirror/mode/clike/clike.js" type="text/javascript"></script>
<link href="CodeMirror/lib/codemirror.css" rel="stylesheet" type="text/css" />
<link href="CodeMirror/theme/default.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<style>
.CodeMirror {
border:1px solid #334;
width:550px;
height:400px;
}
</style>
<body>
<div class="style3"></div><div class="style_2"><span class="style3"><a href="" title="JavaBaker - Live API Documentation"><strong>JavaBaker - Live API Documentation</strong></a></span></div>
<div id="wrap">
<div id="topbar">
<h1 id="sitename"><a href="index.html">JavaBaker - Live API Documentation</a></h1>
<div id="menus">
<ul id="topmenu">
<li ><a href="index.html">Home</a>
</li>
<li class="active"><a href="#">Snippet Parser</a>
</li>
<li><a href="sodb.html">Snippet Search</a>
</li>
<li><a href="extract/fileupload.html">Oracle Generator</a>
</li>
<!--<li><a href="#">Others</a>
</li>-->
</ul>
</div>
</div>
<div id="header">
</div>
<br><br>
<div style="float:left">
<font color="red"><b>Paste your Java code snippet here:</b></font><br>
<!--<form action="getapitreefromcode.php" target="opcode" method="get">-->
<textarea rows="25" cols="50" id="pastedcode" name="pastedcode" placeholder="Paste your code here...">
</textarea><br><br>
<input type="button" value="Output as tree" id="getapi" name="getapi" style="width: 200px; height: 30px" onclick="SendData()">
<input type="button" value="Output as JSON" id="getapijson" name="getapijson" style="width: 200px; height: 30px" onclick="SendDataForJson()">
<br><br><br>
<!--</form>-->
<script>
$("#opframe").hide();
var editor = CodeMirror.fromTextArea(document.getElementById("pastedcode"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-java"
});
function syntaxHighlight(json) {
json = json.replace(/&/g, '&').replace(/\</g, '<').replace(/\>/g, '>');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
function SendData()
{
$("#opframe").hide();
$("#LoadingImage").show();
var code = editor.getValue();
//alert(code);
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var url="getapitreefromcode_graph.php";
var params="pastedcode="+encodeURIComponent(code);
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
$("#LoadingImage").hide();
$("#opframe").show();
//alert(xmlhttp.responseText);
var ifrm = document.getElementById('opcode');
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write(xmlhttp.responseText);
ifrm.document.close();
}
}
xmlhttp.send(params);
}
function SendDataForJson()
{
$("#opframe").hide();
$("#LoadingImage").show();
var code = editor.getValue();
//alert(code);
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var url="getapijsonfromcode.php";
var params="pastedcode="+encodeURIComponent(code);
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ //alert("in here");
$("#LoadingImage").hide();
$("#opframe").show();
//alert(xmlhttp.responseText);
//var ifrm = document.getElementById('opcode');
var ifrm = document.getElementById('opcode');
//var formatted_json = jsl.format.formatJson(xmlhttp.responseText);
//var op=JSON.stringify(xmlhttp.responseText, undefined, 2);
//document.getElementById("optarea").value=formatted_json;
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write(xmlhttp.responseText);
ifrm.document.close();
}
}
xmlhttp.send(params);
}
</script>
</div>
<div style="float:right">
<div id="LoadingImage" style="display: none;float:right;z-index:1">
<img src="images/loading.gif" />
</div>
<div id="opframe" style="display: none;float:right;z-index:0">
<font color="red"><b>API elements in entered code:</b></font><br>
<iframe id="opcode" name="opcode" height="400" width="550">
</iframe>
</div>
</div>
<div style="float:left">
<h4>
To access SnipParse as a web service and fetch JSON output, run the following command on the command line. Replace <i>filename</i> with the input file location.
</h4>
<br>
<code>
curl --data-urlencode "pastedcode@<i>filename</i>" http://gadget.cs.uwaterloo.ca:2145/snippet/getapijsonfromcode.php
</code>
</div>
</body>
</html>