chatterbot 2.0.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +19 -0
- data/Gemfile +9 -17
- data/README.markdown +10 -23
- data/Rakefile +2 -18
- data/chatterbot.gemspec +17 -12
- data/docs/Gemfile +3 -0
- data/docs/README.md +3 -0
- data/docs/_config.yml +37 -0
- data/docs/_includes/footer.html +3 -0
- data/docs/_includes/header.html +4 -0
- data/docs/_includes/navigation.html +23 -0
- data/docs/_layouts/default.html +98 -0
- data/docs/_layouts/page.html +11 -0
- data/docs/_posts/.gitkeep +0 -0
- data/docs/_site/Gemfile +3 -0
- data/docs/_site/advanced.html +465 -0
- data/docs/_site/configuration.html +436 -0
- data/docs/_site/contributing.html +414 -0
- data/docs/_site/css/main.css +58 -0
- data/docs/_site/css/syntax.css +61 -0
- data/docs/_site/deploying.html +451 -0
- data/docs/_site/examples.html +559 -0
- data/docs/_site/features.html +496 -0
- data/docs/_site/images/01-create-application.png +0 -0
- data/docs/_site/images/02-application-permissions.png +0 -0
- data/docs/_site/images/03-mobile-number.png +0 -0
- data/docs/_site/images/04-access-token.png +0 -0
- data/docs/_site/index.html +461 -0
- data/docs/_site/javascripts/main.js +1 -0
- data/docs/_site/other-tools.html +419 -0
- data/docs/_site/params.json +1 -0
- data/docs/_site/rdoc.html +409 -0
- data/docs/_site/setup.html +491 -0
- data/docs/_site/stylesheets/pygment_trac.css +68 -0
- data/docs/_site/stylesheets/stylesheet.css +247 -0
- data/docs/_site/tut.html +402 -0
- data/docs/_site/twitter-docs.html +409 -0
- data/docs/_site/walkthrough.html +447 -0
- data/docs/advanced.md +62 -0
- data/docs/basics.md +12 -0
- data/docs/bin/jekyll-page +109 -0
- data/docs/configuration.md +32 -0
- data/docs/contributing.md +14 -0
- data/docs/css/main.css +58 -0
- data/docs/css/syntax.css +61 -0
- data/docs/deploying.md +47 -0
- data/docs/examples.md +120 -0
- data/docs/features.md +88 -0
- data/docs/images/01-create-application.png +0 -0
- data/docs/images/02-application-permissions.png +0 -0
- data/docs/images/03-mobile-number.png +0 -0
- data/docs/images/04-access-token.png +0 -0
- data/docs/index.md +69 -0
- data/docs/javascripts/main.js +1 -0
- data/docs/other-tools.md +17 -0
- data/docs/params.json +1 -0
- data/docs/rdoc.md +6 -0
- data/docs/setup.md +84 -0
- data/docs/stylesheets/pygment_trac.css +68 -0
- data/docs/stylesheets/stylesheet.css +247 -0
- data/docs/tips.md +22 -0
- data/docs/tut.md +6 -0
- data/docs/twitter-docs.md +6 -0
- data/docs/walkthrough.md +46 -0
- data/lib/chatterbot.rb +0 -1
- data/lib/chatterbot/bot.rb +7 -67
- data/lib/chatterbot/client.rb +2 -9
- data/lib/chatterbot/config.rb +1 -2
- data/lib/chatterbot/dsl.rb +20 -47
- data/lib/chatterbot/home_timeline.rb +1 -1
- data/lib/chatterbot/search.rb +26 -3
- data/lib/chatterbot/skeleton.rb +0 -2
- data/lib/chatterbot/tweet.rb +13 -3
- data/lib/chatterbot/ui.rb +0 -1
- data/lib/chatterbot/version.rb +1 -1
- data/spec/bot_spec.rb +1 -76
- data/spec/client_spec.rb +0 -3
- data/spec/config_manager_spec.rb +6 -5
- data/spec/config_spec.rb +4 -1
- data/spec/dsl_spec.rb +10 -35
- data/spec/fixtures/update_with_media.png +0 -0
- data/spec/search_spec.rb +40 -1
- data/spec/spec_helper.rb +1 -4
- data/spec/tweet_spec.rb +74 -34
- data/templates/skeleton.txt +0 -47
- metadata +81 -135
- data/.document +0 -5
- data/.travis.yml +0 -11
- data/examples/streaming_bot.rb +0 -48
- data/examples/tweet_logger.rb +0 -68
- data/lib/chatterbot/streaming.rb +0 -62
- data/spec/streaming_spec.rb +0 -172
@@ -0,0 +1,58 @@
|
|
1
|
+
body {
|
2
|
+
font-weight: 400;
|
3
|
+
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
|
4
|
+
}
|
5
|
+
|
6
|
+
pre, code {
|
7
|
+
border: none;
|
8
|
+
border-radius: 0;
|
9
|
+
background-color: #f9f9f9;
|
10
|
+
font-size: 0.85em;
|
11
|
+
}
|
12
|
+
|
13
|
+
pre {
|
14
|
+
font-size: 1em;
|
15
|
+
}
|
16
|
+
|
17
|
+
code {
|
18
|
+
color: inherit;
|
19
|
+
}
|
20
|
+
|
21
|
+
#header {
|
22
|
+
border-bottom: 1px solid #eee;
|
23
|
+
margin-bottom: 20px;
|
24
|
+
}
|
25
|
+
|
26
|
+
#header a:hover {
|
27
|
+
text-decoration: none;
|
28
|
+
}
|
29
|
+
|
30
|
+
#footer {
|
31
|
+
margin: 20px 0;
|
32
|
+
font-size: 0.85em;
|
33
|
+
color: #999;
|
34
|
+
text-align: center;
|
35
|
+
}
|
36
|
+
|
37
|
+
#content > .page-header:first-child {
|
38
|
+
margin-top: 0;
|
39
|
+
}
|
40
|
+
|
41
|
+
#content > .page-header:first-child h2 {
|
42
|
+
margin-top: 0;
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
#navigation {
|
47
|
+
font-size: 0.9em;
|
48
|
+
}
|
49
|
+
|
50
|
+
#navigation li a {
|
51
|
+
padding-left: 10px;
|
52
|
+
padding-right: 10px;
|
53
|
+
}
|
54
|
+
|
55
|
+
#navigation .nav-header {
|
56
|
+
padding-left: 0;
|
57
|
+
padding-right: 0;
|
58
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
.highlight .hll { background-color: #ffffcc }
|
2
|
+
.highlight { background: #ffffff; }
|
3
|
+
.highlight .c { color: #888888 } /* Comment */
|
4
|
+
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
|
5
|
+
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
|
6
|
+
.highlight .cm { color: #888888 } /* Comment.Multiline */
|
7
|
+
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
|
8
|
+
.highlight .c1 { color: #888888 } /* Comment.Single */
|
9
|
+
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
|
10
|
+
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
|
11
|
+
.highlight .ge { font-style: italic } /* Generic.Emph */
|
12
|
+
.highlight .gr { color: #aa0000 } /* Generic.Error */
|
13
|
+
.highlight .gh { color: #333333 } /* Generic.Heading */
|
14
|
+
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
|
15
|
+
.highlight .go { color: #888888 } /* Generic.Output */
|
16
|
+
.highlight .gp { color: #555555 } /* Generic.Prompt */
|
17
|
+
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
18
|
+
.highlight .gu { color: #666666 } /* Generic.Subheading */
|
19
|
+
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
|
20
|
+
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
|
21
|
+
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
|
22
|
+
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
|
23
|
+
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
|
24
|
+
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
|
25
|
+
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
|
26
|
+
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
|
27
|
+
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
|
28
|
+
.highlight .na { color: #336699 } /* Name.Attribute */
|
29
|
+
.highlight .nb { color: #003388 } /* Name.Builtin */
|
30
|
+
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
|
31
|
+
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
|
32
|
+
.highlight .nd { color: #555555 } /* Name.Decorator */
|
33
|
+
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
|
34
|
+
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
|
35
|
+
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
|
36
|
+
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
|
37
|
+
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
|
38
|
+
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
|
39
|
+
.highlight .nv { color: #336699 } /* Name.Variable */
|
40
|
+
.highlight .ow { color: #008800 } /* Operator.Word */
|
41
|
+
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
42
|
+
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
|
43
|
+
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
|
44
|
+
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
|
45
|
+
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
|
46
|
+
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
|
47
|
+
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
|
48
|
+
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
|
49
|
+
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
|
50
|
+
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
|
51
|
+
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
|
52
|
+
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
|
53
|
+
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
|
54
|
+
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
|
55
|
+
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
|
56
|
+
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
|
57
|
+
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
|
58
|
+
.highlight .vc { color: #336699 } /* Name.Variable.Class */
|
59
|
+
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
|
60
|
+
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
|
61
|
+
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
|
@@ -0,0 +1,451 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
6
|
+
<meta name="viewport" content="width=device-width">
|
7
|
+
|
8
|
+
<title>chatterbot : Running your Bot</title>
|
9
|
+
<meta name="description" content="twitter bots in ruby">
|
10
|
+
|
11
|
+
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
|
12
|
+
<link rel="stylesheet" href="/chatterbot/css/syntax.css">
|
13
|
+
<link rel="stylesheet" href="/chatterbot/css/main.css">
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
|
17
|
+
<div class="container">
|
18
|
+
<div class=row-fluid>
|
19
|
+
<div id=header class=span12>
|
20
|
+
<h4><a class=brand href="/chatterbot/">chatterbot</a>
|
21
|
+
<small>twitter bots in ruby</small>
|
22
|
+
</h4>
|
23
|
+
|
24
|
+
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class=row-fluid>
|
29
|
+
|
30
|
+
|
31
|
+
<div id=navigation class=span2>
|
32
|
+
<ul class="nav nav-list">
|
33
|
+
<li><a href="/chatterbot/">Home</a></li>
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
<li class=nav-header>Getting Started</li>
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<li data-order="">
|
58
|
+
|
59
|
+
<a href="/chatterbot/examples.html">Examples</a>
|
60
|
+
|
61
|
+
</li>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<li data-order="">
|
84
|
+
|
85
|
+
<a href="/chatterbot/setup.html">Authorizing Your Bot</a>
|
86
|
+
|
87
|
+
</li>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<li data-order="">
|
102
|
+
|
103
|
+
<a href="/chatterbot/walkthrough.html">Walkthrough</a>
|
104
|
+
|
105
|
+
</li>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
<li class=nav-header>Documentation</li>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
<li data-order="">
|
117
|
+
|
118
|
+
<a href="/chatterbot/advanced.html">Advanced Features</a>
|
119
|
+
|
120
|
+
</li>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
<li data-order="">
|
127
|
+
|
128
|
+
<a href="/chatterbot/configuration.html">Configuration</a>
|
129
|
+
|
130
|
+
</li>
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
<li data-order="">
|
141
|
+
|
142
|
+
<a href="/chatterbot/deploying.html">Running your Bot</a>
|
143
|
+
|
144
|
+
</li>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<li data-order="">
|
155
|
+
|
156
|
+
<a href="/chatterbot/features.html">Basic Features</a>
|
157
|
+
|
158
|
+
</li>
|
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
|
+
<li class=nav-header>Developers</li>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<li data-order="">
|
206
|
+
|
207
|
+
<a href="/chatterbot/contributing.html">Contributing</a>
|
208
|
+
|
209
|
+
</li>
|
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
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
<li class=nav-header>Resources</li>
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
<li data-order="">
|
289
|
+
|
290
|
+
<a href="/chatterbot/other-tools.html">Other Tools</a>
|
291
|
+
|
292
|
+
</li>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
<li data-order="">
|
299
|
+
|
300
|
+
<a href="http://rubydoc.info/gems/chatterbot">rdoc</a>
|
301
|
+
|
302
|
+
</li>
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
<li data-order="">
|
317
|
+
|
318
|
+
<a href="https://dev.twitter.com/rest/public">Twitter API docs</a>
|
319
|
+
|
320
|
+
</li>
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
<!-- List additional links. It is recommended to add a divider
|
330
|
+
e.g. <li class=divider></li> first to break up the content. -->
|
331
|
+
</ul>
|
332
|
+
|
333
|
+
</div>
|
334
|
+
|
335
|
+
<div id=content class=span10>
|
336
|
+
<div class=page-header>
|
337
|
+
<h2>Running your Bot
|
338
|
+
|
339
|
+
</h2>
|
340
|
+
</div>
|
341
|
+
|
342
|
+
<p>There’s a couple ways of running your bot:</p>
|
343
|
+
|
344
|
+
<h2 id="manually">Manually</h2>
|
345
|
+
|
346
|
+
<p>Run it on the command-line whenever you like. Whee!</p>
|
347
|
+
|
348
|
+
<h2 id="cron">Cron</h2>
|
349
|
+
<p>Run it via cron. Here’s an example of running a bot every two minutes</p>
|
350
|
+
|
351
|
+
<pre><code>*/2 * * * * . ~/.bash_profile; cd /path/to/bot/; ./bot.rb
|
352
|
+
</code></pre>
|
353
|
+
|
354
|
+
<h2 id="looping">Looping</h2>
|
355
|
+
<p>Run it as a background process. Just put the guts of your bot in a loop like this:</p>
|
356
|
+
|
357
|
+
<p>```rb
|
358
|
+
loop do
|
359
|
+
search “twitter” do |tweet|
|
360
|
+
# here you could do something with a tweet
|
361
|
+
# if you want to retweet
|
362
|
+
retweet(tweet[:id])
|
363
|
+
end</p>
|
364
|
+
|
365
|
+
<p>replies do |tweet|
|
366
|
+
# do stuff
|
367
|
+
end</p>
|
368
|
+
|
369
|
+
<p># explicitly update our config
|
370
|
+
update_config</p>
|
371
|
+
|
372
|
+
<p>sleep 60
|
373
|
+
end
|
374
|
+
```</p>
|
375
|
+
|
376
|
+
<p><strong>NOTE:</strong> You need to call <code>update_config</code> to update the last tweet your script
|
377
|
+
has processed – if you don’t have this call, you will get duplicate
|
378
|
+
tweets.</p>
|
379
|
+
|
380
|
+
<h2 id="streaming">Streaming</h2>
|
381
|
+
|
382
|
+
<p>Chatterbot has rough support for the Streaming API. If your bot can
|
383
|
+
use it, it’s a great option, because you get your data immediately.
|
384
|
+
You can read more about setting up a bot to use <a href="streaming.html">streaming</a>.</p>
|
385
|
+
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
</div>
|
390
|
+
|
391
|
+
<div class=row-fluid>
|
392
|
+
<div id=footer class=span12>
|
393
|
+
<!--
|
394
|
+
Documentation for <a href="https://github.com/muffinista/chatterbot">chatterbot</a>
|
395
|
+
-->
|
396
|
+
|
397
|
+
</div>
|
398
|
+
</div>
|
399
|
+
</div>
|
400
|
+
|
401
|
+
<script>
|
402
|
+
function orderNav() {
|
403
|
+
var list,
|
404
|
+
section,
|
405
|
+
header,
|
406
|
+
sections = [],
|
407
|
+
lists = {},
|
408
|
+
headers = {};
|
409
|
+
|
410
|
+
var navUl = document.querySelectorAll('#navigation ul')[0],
|
411
|
+
navLis = document.querySelectorAll('#navigation ul li');
|
412
|
+
|
413
|
+
if (!navUl) return;
|
414
|
+
|
415
|
+
for (var i = 0; i < navLis.length; i++) {
|
416
|
+
var order, li = navLis[i];
|
417
|
+
|
418
|
+
if (li.classList.contains('nav-header')) {
|
419
|
+
section = li.textContent || li.innerText;
|
420
|
+
sections.push(section);
|
421
|
+
headers[section] = li;
|
422
|
+
continue;
|
423
|
+
}
|
424
|
+
|
425
|
+
if (!lists[section]) {
|
426
|
+
lists[section] = [];
|
427
|
+
}
|
428
|
+
|
429
|
+
order = parseFloat(li.getAttribute('data-order'))
|
430
|
+
lists[section].push([order, li]);
|
431
|
+
}
|
432
|
+
|
433
|
+
for (var i = 0; i < sections.length; i++) {
|
434
|
+
section = sections[i];
|
435
|
+
list = lists[section].sort(function(a, b) {
|
436
|
+
return a[0] - b[0];
|
437
|
+
});
|
438
|
+
|
439
|
+
if (header = headers[section]) {
|
440
|
+
navUl.appendChild(header);
|
441
|
+
}
|
442
|
+
for (var j = 0; j < list.length; j++) {
|
443
|
+
navUl.appendChild(list[j][1]);
|
444
|
+
}
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
if (document.querySelectorAll) orderNav();
|
449
|
+
</script>
|
450
|
+
</body>
|
451
|
+
</html>
|