-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfunction.htm
129 lines (117 loc) · 4.92 KB
/
function.htm
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>erldocs.com - Function lookup</title>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<link type="text/css" href="typeahead-examples.css" rel="stylesheet"/>
<link type="text/css" href="repo.css" rel="stylesheet"/>
<link href="/search.xml" rel="search" type="application/opensearchdescription+xml" title="erldocs_other"/>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js']);
_gaq.push(['_setAccount', 'UA-44246018-1']);
_gaq.push(['_setDomainName', 'erldocs.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
$.fn.enterKey = function (fnc, mod) {
return this.each(function () {
$(this).keypress(function (ev) {
var keycode = (ev.keyCode ? ev.keyCode : ev.which);
if ((keycode == '13' || keycode == '10') && (!mod || ev[mod + 'Key']))
fnc.call(this, ev);
});
});
};
$(document).ready(function () {
INDEX = [];
COUNT = 0;
$.get("/api/v1.json", function (data) {
RELEASES = data["otp_releases_built"];
RELEASES_COUNT = RELEASES.length;
$.ajaxSetup({"cache": true});
var update = function () {
$("#msg").html("Searching "+ COUNT +" / "+ RELEASES_COUNT +" releases");
if (COUNT === RELEASES_COUNT)
setup();
};
var cacheReleaseIndex = function (Release) {
if (Release === undefined) return;
$.getScript("/"+Release+"/erldocs_index.js").done(function (src, status) {
var pos = $.inArray(Release, RELEASES);
$.each(index, function (i, o) {
if (o[0] !== "fun") return;
INDEX.push({"mfa": o[2], "otp": pos});
});
COUNT += 1;
index = null;
update();
});
};
for (var i = 0; i < RELEASES_COUNT; i++)
cacheReleaseIndex(RELEASES[i]);
function setup () {
var getData = function () {
DATA = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("mfa")
, queryTokenizer: Bloodhound.tokenizers.whitespace
, local: INDEX
, limit: RELEASES_COUNT
});
DATA.initialize();
return DATA.ttAdapter();
};
<!-- var substringMatcher = function(strs) { -->
<!-- return function findMatches(q, cb) { -->
<!-- var matches = []; -->
<!-- var substrRegex = new RegExp(q); -->
<!-- $.each(strs, function(i, str) { -->
<!-- if (substrRegex.test(str["mfa"])) -->
<!-- matches.push(str); -->
<!-- }); -->
<!-- cb(matches); -->
<!-- }; -->
<!-- }; -->
var ppSuggestion = function (o) {
return "<p>"+ o["mfa"] +" ~ "+ RELEASES[o["otp"]] +"</p>";
};
var ppEmpty = '<p style="text-align:center;">No Erlang/OTP release provides this function</p>'
$("#bar").typeahead({ hint: true
, highlight: true
, limit: RELEASES_COUNT
, minLength: 3 }, { name: "funs"
, displayKey: "mfa"
, source: getData()
<!-- , source: substringMatcher(INDEX) -->
<!-- , source: function (q, cb) { -->
<!-- return cb($.grep(INDEX, function (o, i) { return o["mfa"] === q; })); -->
<!-- } -->
, templates: { suggestion: ppSuggestion
, empty: ppEmpty }
})
.focus()
.enterKey(function () {
$(".typeahead").open();
});
};
});
});
</script>
</head>
<body>
<div id="front_page">
<h1>function lookup</h1>
Find the OTP releases providing this function<br/><br/>
<span id="msg" style="color:#666;">loading indexes…</span>
<br/>
<input type="text" id="bar" class="typeahead" name="q" placeholder="Module:Function/Arity" size="50" autofocus/>
<br/>
<p><a href="/">home</a></p>
</div>
<script type="text/javascript" src="typeahead.bundle-0.10.5.js"></script>
</body>
</html>