-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
249 lines (211 loc) · 8.2 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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<html>
<head>
<title>Interactive Linked List</title>
<!-- Fonts -->
<link href='https://fonts.googleapis.com/css?family=Roboto:400,900,500,700,100,300|Roboto+Mono:400,100,300,500,700' rel='stylesheet' type='text/css'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css' rel='stylesheet' type='text/css'>
<!-- CSS -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/prism.custom.css">
<link rel="stylesheet" href="app.css">
<!-- JS -->
<script src="js/vendor/modernizr.js"></script>
<script src="js/vendor/fastclick.js"></script>
<script src="js/vendor/jquery-2.1.4.min.js"></script>
<script src="js/vendor/underscore-min.js"></script>
<script src="js/vendor/jquery.noty.packaged.js"></script>
<script src="js/vendor/prism.custom.js"></script>
<script src="js/vendor/snap.svg.js"></script>
<script src="js/vendor/foundation.min.js"></script>
<script src="js/vendor/jquery.cookie.js"></script>
</head>
<body>
<div class="wrapper">
<div id="header">
<img src="img/logo.svg" id="logo">
<ul id="menu">
<li>
<label for="notification-switch">Notifications</label>
<div class="switch radius small">
<input id="notification-switch" type="checkbox" checked>
<label for="notification-switch"></label>
</div>
</li>
<li>
<label>Speed</label>
<div id="speed-slider" class="range-slider radius" data-slider data-options="start: 1; end: 3; step: 1;">
<span class="range-slider-handle" role="slider" tabindex="0"></span>
<span class="range-slider-active-segment"></span>
<input id="speed-value" type="hidden">
</div>
</li>
</ul>
</div>
<!-- Options -->
<div class="header-spacer">
<div id="options" class="animated slideInLeft">
<div class="box alt">
<h3 class="heading goal-heading animated">Goals <span class="right"><span class="goal-count">0</span>/<span class="goal-max">5</span></span></h3>
<h1>Linked Lists</h1>
<h2 class="goal-title animated"></h2>
<p class="goal-text"></p>
<a href="#" class="right help" data-joyride-restart>Help</a>
</div>
<h4 class="separator">Functions</h4>
<div class="box">
<h5>Insert</h5>
<form id="insert" class="row collapse" data-abide="ajax">
<div class="small-6 columns">
<input type="text" id="insert-text" value="30" required maxlength="3" pattern="integer">
</div>
<div class="small-6 columns">
<button type="submit"><i class="ion-ios-plus"></i></button>
</div>
</form>
<h5>Search</h5>
<form id="search" class="row collapse" data-abide="ajax">
<label class="small-6 columns">
<input type="text" id="search-text" value="72" required maxlength="3" pattern="integer">
</label>
<div class="small-6 columns">
<button type="submit"><i class="ion-ios-search-strong"></i></button>
</div>
</form>
<h5>Remove <small>by index</small></h5>
<form id="remove" class="row collapse" data-abide="ajax">
<div class="small-6 columns">
<input type="text" id="remove-text" value="4" required maxlength="3" pattern="integer">
</div>
<div class="small-6 columns">
<button type="submit"><i class="ion-ios-close"></i></button>
</div>
</form>
</div>
</div>
</div>
<!-- Editor -->
<svg id="editor" version="1.1" xmlns="http://www.w3.org/2000/svg">
<!-- Markers & Filters -->
<defs>
<marker id="triangle" viewBox="0 0 10 10" refX="10" refY="5" markerUnits="strokeWidth" fill="#fff" markerWidth="10" markerHeight="10" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
<filter id="dragging" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceAlpha" stdDeviation="2" />
<feOffset dx="0" dy="6" result="offsetblur" />
<feFlood flood-color="rgba(0,0,0,0.2)" />
<feComposite in2="offsetblur" operator="in" />
<feMerge>
<feMergeNode />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
<filter id="highlight" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceAlpha" stdDeviation="3" />
<feOffset dx="0" dy="0" result="offsetblur" />
<feFlood flood-color="#fff" />
<feComposite in2="offsetblur" operator="in" />
<feMerge>
<feMergeNode />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
<!-- Dynamic stuff happens around here -->
</svg>
<!-- Code -->
<div class="header-spacer right">
<pre id="code" class="language-python animated slideInRight"><code>class Node(object):
def __init__(self, data=None, next=None):
self.data = data
self.next = next
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def insert(self, value):
new_node = Node(value)
new_node.next(self.head)
self.head = new_node
def search(self, value):
current = self.head
previous = None
index = 0
found = False
# Search by value
while current and found is False:
if current.value == value:
found = True
else:
previous = current
current = current.next
index += 1
if current is not None:
return {
'current': current,
'previous': previous,
'index': index
}
else:
print("Value not found in list")
def delete(self, index):
current = self.head
previous = None
index = 0
found = False
# Search by index
while current and found is False:
if current.index == index:
found = True
else:
previous = current
current = current.next
index += 1
if found:
previous.next = current.next
else:
print("Index not found in list")
</code></pre>
</div>
<div class="joyride-tips">
<div id="jr1"></div>
<div id="jr2"></div>
<div id="jr3"></div>
</div>
<ol class="joyride-list" data-joyride>
<li data-button="Next" data-options="prev_button:false;">
<h4>Welcome!</h4>
<p>This is an interactive linked list that you can play around with, to understand the data structure better.</p>
<p>A short introduction will take you through the features.</p>
</li>
<li data-id="jr1" data-prev-text="‹" data-text="Next" data-options="tip_location:right; nub_position:left;">
<h4>The Editor</h4>
<img src="img/tip2.gif">
<p>The editor contains the head and the nodes, it represents the current state of the linked list.</p>
<p>You can drag on the first half of a node to move it, or on the right half of a node to move the pointer.</p>
</li>
<li data-id="jr2" data-prev-text="‹" data-text="Next" data-options="tip_location:right; nub_position:left;">
<h4>Goals & Functions</h4>
<img src="img/tip3.gif">
<p>There are goals that you can complete to familiarize yourself with the concepts.</p>
<p>Below the goals, there are functions you can execute on the list. As they are being executed, they will be highlighted on the editor. Use them to complete the goals.</p>
</li>
<li data-id="jr3" data-prev-text="‹" data-text="Finish" data-options="tip_location:left; nub_position:right;">
<h4>Code & Notifications</h4>
<img src="img/tip4.gif">
<p>While functions are being executed, they will be reflected in the code by highlighting the line being executed.</p>
<p>Along with this, there will be notifications popping up at the bottom of the screen that explain each step.</p>
<p class="show-for-large-down"><strong>Your screen is currently too small to view the code. Please use the fullscreen option on Alexandria to be able to view the code highlighter on the right.</strong>
</li>
</ol>
<!-- Fullscreen alert -->
<div class="fullscreen-alert animated fadeInDown">Please switch this interactive to fullscreen to view the code editor.</div>
</div>
<script src="js/base.js"></script>
<script src="js/helpers.js"></script>
<script src="js/init.noty.js"></script>
<script src="js/node.js"></script>
<script src="js/goals.js"></script>
<script src="js/app.js"></script>
</body>
</html>