Skip to content

Commit 94c8b96

Browse files
committed
Add auto complete symbol feature
1 parent ed4c7ea commit 94c8b96

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ ENV/
8888

8989
# Rope project settings
9090
.ropeproject
91+
92+
app/search/static/names.js

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ COPY cron.conf /etc/supervisor/conf.d/cron.conf
2020
COPY app /app
2121
COPY libc-database /libc-database
2222

23+
# Generate autocomplete symbols list
24+
COPY gen_names.sh /gen_names.sh
25+
RUN cd / && /gen_names.sh
26+
2327
# nginx.conf of the base image aliases /static to /app/static.
2428
RUN ln -s /app/search/static /app/static
2529
# Enable download link

app/search/static/main.js

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ function show_offset_diffs($radio) {
7272
});
7373
}
7474

75+
function set_autocomplete(names) {
76+
$('.query-name').autocomplete({
77+
source: names
78+
});
79+
}
80+
7581
$('.symbol-radio').change(function() {
7682
show_offset_diffs($(this));
7783
});

app/search/templates/index.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
<title>libc database search</title>
77
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
88
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
9+
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/start/jquery-ui.css">
910
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
1011
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
12+
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
1113
<script type="text/javascript" src="{{ url_for('static', filename='URI.min.js') }}"></script>
1214
</head>
1315
<body>
@@ -95,10 +97,14 @@ <h1 class="panel-title panel-title-inline">{{ lib }}</h1>
9597
</div>
9698
</div>
9799
<script type="text/javascript" src="{{ url_for('static', filename='main.js') }}"></script>
98-
<script>
100+
<script type="text/javascript">
99101
{% for name, addr in query.items() %}
100102
add_query("{{ name }}", "{{ addr }}");
101103
{% endfor %}
102104
</script>
105+
<script type="text/javascript" src="{{ url_for('static', filename='names.js') }}"></script>
106+
<script type="text/javascript">
107+
set_autocomplete(names);
108+
</script>
103109
</body>
104110
</html>

gen_names.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dbdir=libc-database/db
2+
outfile=app/search/static/names.js
3+
4+
cat $dbdir/*.symbols \
5+
| cut -d ' ' -f 1 \
6+
| sort \
7+
| uniq \
8+
| awk ' \
9+
BEGIN { print "var names = [" }
10+
{ printf "\"%s\",\n", $1 }
11+
END { print "];" }' \
12+
> $outfile
13+
wc -l $outfile

0 commit comments

Comments
 (0)