-
Notifications
You must be signed in to change notification settings - Fork 5
/
api.html
159 lines (154 loc) · 4.41 KB
/
api.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
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
---
layout: default
---
{% include header.html %}
<section class="container">
<h1>Algorithm API</h1>
<p class="lead">
You can add/edit your own javascript algorithm by clicking the "Add Algorithm"
button at the bottom-left side of the <a href="index.html">main page</a>.
</p>
<p class="lead">
When writing your algorithm, you have access to the <strong>AS</strong> (Audio Sort)
global object. The methods on that object are described in the table below. The
<strong>AS</strong> object gives you access to the current array, allows you to set
visualization markers, and lets you "play" certain array elements.
</p>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style="width:200px">Method</th>
<th>Description</th>
<th>Marker Color</th>
<th>Marker Level</th>
</tr>
</thead>
<tbody>
<tr>
<th>AS.length()</th>
<td>Gets the length of the array.</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>AS.size()</th>
<td>Gets the length of the array.</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>AS.get(index)</th>
<td>
Gets the sortItem object with the given array index. This sortItem
can be passed to other AS method calls.
</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>AS.play(item1, ..., itemN)</th>
<td>
Will play the given items. Items can be indexes or array items returned
via AS.get() calls.
</td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<th>AS.mark(item1, ..., itemN)</th>
<td>
Will mark the given items. Items can be indexes or array items returned
via AS.get() calls.
</td>
<td><div class="api-marker mark"> </div></td>
<td>1</td>
</tr>
<tr>
<th>AS.lt(itemOne, itemTwo)</th>
<td>
Returns true if itemOne is less than itemTwo. Item can be an array
index, or an array item (returned via an AS.get() call).
</td>
<td><div class="api-marker compare"> </div></td>
<td>2</td>
</tr>
<tr>
<th>AS.lte(itemOne, itemTwo)</th>
<td>
Returns true if itemOne is less than or equal to itemTwo. Item
can be an array index, or an array item (returned via an AS.get() call).
</td>
<td><div class="api-marker compare"> </div></td>
<td>2</td>
</tr>
<tr>
<th>AS.gt(itemOne, itemTwo)</th>
<td>
Returns true if itemOne is greater than itemTwo. Item can be an
array index, or an array item (returned via an AS.get() call).
</td>
<td><div class="api-marker compare"> </div></td>
<td>2</td>
</tr>
<tr>
<th>AS.gte(itemOne, itemTwo)</th>
<td>
Returns true if itemOne is greater than or equal to itemTwo. Item
can be an array index, or an array item (returned via an AS.get() call).
</td>
<td><div class="api-marker compare"> </div></td>
<td>2</td>
</tr>
<tr>
<th>AS.eq(itemOne, itemTwo)</th>
<td>
Returns true if itemOne is equal to itemTwo. Item can be an array
index, or an array item (returned via an AS.get() call).
</td>
<td><div class="api-marker compare"> </div></td>
<td>2</td>
</tr>
<tr>
<th>AS.neq(itemOne, itemTwo)</th>
<td>
Returns true if itemOne is not equal to itemTwo. Item can be an array
index, or an array item (returned via an AS.get() call).
</td>
<td><div class="api-marker compare"> </div></td>
<td>2</td>
</tr>
<tr>
<th>AS.swap(itemOne, itemTwo)</th>
<td>Will swap the positions of the two items.</td>
<td><div class="api-marker swap"> </div></td>
<td>3</td>
</tr>
<tr>
<th>N/A</th>
<td>
Items that were swapped in the last iteration, will show up below the "swapped"
items. They appear as green circles, while items that are getting ready to be
swapped show up as yellow circles.
</td>
<td><div class="api-marker justSwapped"> </div></td>
<td>4</td>
</tr>
<tr>
<th>AS.highlight(item1, ..., itemN)</th>
<td>
Will highlight the given items. Highlighted items stay highlighted until
the next AS.highlight() call, or until AS.clearHighlight() is called.
</td>
<td><div class="api-marker highlight"> </div></td>
<td>5</td>
</tr>
<tr>
<th>AS.clearHighlight()</th>
<td>Clears the currently highlighted items.</td>
<td>N/A</td>
<td>N/A</td>
</tr>
</tbody>
</table>
</section>
{% include footer.html %}