-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
292 lines (269 loc) · 29.4 KB
/
test.html
File metadata and controls
292 lines (269 loc) · 29.4 KB
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
250
251
252
253
254
255
256
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
289
290
291
292
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Polls</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"><style>@import url(http://fonts.googleapis.com/css?family=Roboto:400,700|Inconsolata|Raleway:200);.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}body{color:black;background:white;font-family:'Roboto',Helvetica,sans-serif;font-size:14px;line-height:1.42}header{border-bottom:1px solid #f2f2f2;margin-bottom:12px}h1,h2,h3,h4,h5{color:black;margin:12px 0}h1 .permalink,h2 .permalink,h3 .permalink,h4 .permalink,h5 .permalink{margin-left:6px;opacity:0;transition:opacity .25s ease}h1:hover .permalink,h2:hover .permalink,h3:hover .permalink,h4:hover .permalink,h5:hover .permalink{opacity:1}h1{font-family:'Raleway',Helvetica,sans-serif;font-size:36px;font-weight:500}h2{font-family:'Raleway',Helvetica,sans-serif;font-size:30px;font-weight:500}h3{font-size:100%;text-transform:uppercase}h5{font-size:100%;font-weight:normal}p{margin:0 0 10px}p.choices{line-height:1.6}a{color:#428bca;text-decoration:none}li p{margin:0}dl dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}dl dd{margin-left:180px}blockquote{color:rgba(0,0,0,0.5);font-size:15.5px;padding:10px 20px;margin:12px 0;border-left:5px solid #e8e8e8}blockquote p:last-child{margin-bottom:0}pre{background-color:#f5f5f5;padding:12px;border:1px solid #cfcfcf;border-radius:6px}pre code{background-color:transparent;padding:0;border:none}code{color:#444;background-color:#f5f5f5;font-family:'Inconsolata',monospace;padding:1px 4px;border:1px solid #cfcfcf;border-radius:3px}ul,ol{padding-left:2em}table{border-collapse:collapse;border-spacing:0;margin-bottom:12px}table tr:nth-child(2n){background-color:#fafafa}table th,table td{padding:6px 12px;border:1px solid #d9d9d9}nav{position:fixed;top:24px;bottom:0;overflow-y:auto}nav .resource-group{padding:0}nav .resource-group .heading{position:relative}nav .resource-group .heading .chevron{position:absolute;top:12px;right:12px;opacity:.5}nav .resource-group .heading a{display:block;color:black;opacity:.7;border-left:2px solid transparent;margin:0}nav .resource-group .heading a:hover{border-left:2px solid black}nav ul{list-style-type:none;padding-left:0}nav ul a{display:block;font-size:13px;color:rgba(0,0,0,0.7);padding:8px 12px;border-top:1px solid #d9d9d9;border-left:2px solid transparent;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nav ul a:hover{border-left:2px solid black}nav ul>li{margin:0}nav ul>li:first-child{margin-top:-12px}nav ul>li:last-child{margin-bottom:-12px}nav ul ul a{padding-left:24px}nav ul ul li{margin:0}nav ul ul li:first-child{margin-top:0}nav ul ul li:last-child{margin-bottom:0}nav>div>div>ul>li:first-child>a{border-top:none}.preload *{transition:none !important}.pull-left{float:left}.pull-right{float:right}.badge{display:inline-block;float:right;min-width:10px;min-height:14px;padding:3px 7px;font-size:12px;color:#000;background-color:#f2f2f2;border-radius:10px;margin-top:-2px;margin-bottom:-2px}.badge.get{color:#70bbe1;background-color:#d9edf7}.badge.head{color:#70bbe1;background-color:#d9edf7}.badge.options{color:#70bbe1;background-color:#d9edf7}.badge.put{color:#f0db70;background-color:#fcf8e3}.badge.patch{color:#f0db70;background-color:#fcf8e3}.badge.post{color:#93cd7c;background-color:#dff0d8}.badge.delete{color:#ce8383;background-color:#f2dede}.collapse-button{float:right}.collapse-button .close{display:none;color:#428bca;cursor:pointer}.collapse-button .open{color:#428bca;cursor:pointer}.collapse-button.show .close{display:inline}.collapse-button.show .open{display:none}.collapse-content{max-height:0;overflow:hidden;transition:max-height .3s ease-in-out}nav{width:220px}.container{max-width:940px;margin-left:auto;margin-right:auto}.container .row .content{margin-left:244px;width:696px}.container .row:after{content:'';display:block;clear:both}.container-fluid nav{width:22%}.container-fluid .row .content{margin-left:24%;width:76%}@media (max-width:1200px){nav{width:200px}.container{max-width:840px}.container .row .content{margin-left:224px;width:606px}}@media (max-width:992px){nav{width:170px}.container{max-width:720px}.container .row .content{margin-left:194px;width:526px}}@media (max-width:768px){nav{display:none}.container{width:95%;max-width:none}.container .row .content,.container-fluid .row .content{margin-left:auto;margin-right:auto;width:95%}}.back-to-top{position:fixed;z-index:1;bottom:0;right:24px;padding:4px 8px;color:rgba(0,0,0,0.5);background-color:#f2f2f2;text-decoration:none !important;border-top:1px solid #d9d9d9;border-left:1px solid #d9d9d9;border-right:1px solid #d9d9d9;border-top-left-radius:3px;border-top-right-radius:3px}.resource-group{padding:12px;margin-bottom:12px;background-color:white;border:1px solid #d9d9d9;border-radius:6px}.resource-group h2.group-heading,.resource-group .heading a{padding:12px;margin:-12px -12px 12px -12px;background-color:#f2f2f2;border-bottom:1px solid #d9d9d9;border-top-left-radius:6px;border-top-right-radius:6px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}nav .resource-group .heading a{margin-bottom:0}nav .resource-group .collapse-content{padding:0}.action{margin-bottom:12px;padding:12px 12px 0 12px;overflow:hidden;border:1px solid transparent;border-radius:6px}.action h4{padding:12px;margin:-12px -12px 12px -12px;border-bottom:1px solid transparent;border-top-left-radius:6px;border-top-right-radius:6px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.action h4 .name{float:right;font-weight:normal}.action h4 .method{padding:6px 12px;margin-right:12px;border-radius:3px}.action h4 .method.get{color:#fff;background-color:#337ab7}.action h4 .method.head{color:#fff;background-color:#337ab7}.action h4 .method.options{color:#fff;background-color:#337ab7}.action h4 .method.put{color:#000;background-color:#f0ad4e}.action h4 .method.patch{color:#000;background-color:#f0ad4e}.action h4 .method.post{color:#fff;background-color:#5cb85c}.action h4 .method.delete{color:#fff;background-color:#d9534f}.action h4 code{color:#444;background-color:#f5f5f5;border-color:#cfcfcf;font-weight:normal}.action dl.inner{padding-bottom:2px}.action .title{border-bottom:1px solid white;margin:0 -12px -1px -12px;padding:12px}.action.get{border-color:#bce8f1}.action.get h4{color:#337ab7;background:#d9edf7;border-bottom-color:#bce8f1}.action.head{border-color:#bce8f1}.action.head h4{color:#337ab7;background:#d9edf7;border-bottom-color:#bce8f1}.action.options{border-color:#bce8f1}.action.options h4{color:#337ab7;background:#d9edf7;border-bottom-color:#bce8f1}.action.post{border-color:#d6e9c6}.action.post h4{color:#5cb85c;background:#dff0d8;border-bottom-color:#d6e9c6}.action.put{border-color:#faebcc}.action.put h4{color:#f0ad4e;background:#fcf8e3;border-bottom-color:#faebcc}.action.patch{border-color:#faebcc}.action.patch h4{color:#f0ad4e;background:#fcf8e3;border-bottom-color:#faebcc}.action.delete{border-color:#ebccd1}.action.delete h4{color:#d9534f;background:#f2dede;border-bottom-color:#ebccd1}</style></head><body class="preload"><a href="#top" class="text-muted back-to-top"><i class="fa fa-toggle-up"></i> Back to top</a><div class="container"><div class="row"><nav><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#">Resource Group</a></div><div class="collapse-content"><ul><li><a href="#-polls-api-root-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>Retrieve the Entry Point</a></li></ul></div></div><div class="resource-group"><div class="heading"><div class="chevron"><i class="open fa fa-angle-down"></i></div><a href="#question">Question</a></div><div class="collapse-content"><ul><li><a href="#question-question-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>View a Questions Detail</a></li><li><a href="#question-choice-post"><span class="badge post"><i class="fa fa-plus"></i></span>Vote on a Choice</a></li><li><a href="#question-questions-collection">Questions Collection</a><ul><li><a href="#question-questions-collection-get"><span class="badge get"><i class="fa fa-arrow-down"></i></span>List All Questions</a></li><li><a href="#question-questions-collection-post"><span class="badge post"><i class="fa fa-plus"></i></span>Create a New Question</a></li></ul></li></ul></div></div><p style="text-align: center; word-wrap: break-word;"><a href="http://polls.apiblueprint.org/">http://polls.apiblueprint.org/</a></p></nav><div class="content"><header><h1 id="top">Polls</h1></header><p>Polls is a simple API allowing consumers to view polls and vote in them. You can view this documentation over at <a href="http://docs.pollsapi.apiary.io">Apiary</a>.</p>
<section id="" class="resource-group"><h2 class="group-heading">Resource Group<a href="#" class="permalink">¶</a></h2><div id="-polls-api-root" class="resource"><h3>Polls API Root<a href="#-polls-api-root" class="permalink">¶</a></h3><p>This resource does not have any attributes. Instead it offers the initial API affordances in the form of the links in the JSON body.</p>
<p>It is recommend to follow the “url” link values, <a href="https://tools.ietf.org/html/rfc5988">Link</a> or Location headers where applicable to retrieve resources. Instead of constructing your own URLs, to keep your client decoupled from implementation details.</p>
<div id="-polls-api-root-get" class="action get"><h4><div class="name">Retrieve the Entry Point</div><a href="#-polls-api-root-get" class="method get">GET</a><code class="uri">/</code></h4><div class="title"><strong>Response <code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">questions_url</span>": <span class="hljs-value"><span class="hljs-string">"/questions"</span>
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div></section><section id="question" class="resource-group"><h2 class="group-heading">Question<a href="#question" class="permalink">¶</a></h2><p>Resources related to questions in the API.</p>
<div id="question-question" class="resource"><h3>Question<a href="#question-question" class="permalink">¶</a></h3><p>A Question object has the following attributes:</p>
<ul>
<li>
<p>question</p>
</li>
<li>
<p>published_at - An ISO8601 date when the question was published.</p>
</li>
<li>
<p>url</p>
</li>
<li>
<p>choices - An array of Choice objects.</p>
</li>
</ul>
<div id="question-question-get" class="action get"><h4><div class="name">View a Questions Detail</div><a href="#question-question-get" class="method get">GET</a><code class="uri">/questions/{question_id}</code></h4><div class="title"><strong>Parameters</strong><div class="collapse-button show"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><dl class="inner"><dt>question_id</dt><dd><code>number</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>1</span></span><p>ID of the Question in form of an integer</p>
</dd></dl></div><div class="title"><strong>Response <code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">question</span>": <span class="hljs-value"><span class="hljs-string">"Favourite programming language?"</span></span>,
"<span class="hljs-attribute">published_at</span>": <span class="hljs-value"><span class="hljs-string">"2014-11-11T08:40:51.620Z"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1"</span></span>,
"<span class="hljs-attribute">choices</span>": <span class="hljs-value">[
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Swift"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/1"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">2048</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Python"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/2"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">1024</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Objective-C"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/3"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">512</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Ruby"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/4"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">256</span>
</span>}
]
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div><div id="question-choice" class="resource"><h3>Choice<a href="#question-choice" class="permalink">¶</a></h3><div id="question-choice-post" class="action post"><h4><div class="name">Vote on a Choice</div><a href="#question-choice-post" class="method post">POST</a><code class="uri">/questions/{question_id}/choices/{choice_id}</code></h4><p>This action allows you to vote on a question’s choice.</p>
<div class="title"><strong>Parameters</strong><div class="collapse-button show"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><dl class="inner"><dt>question_id</dt><dd><code>number</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>1</span></span><p>ID of the Question in form of an integer</p>
</dd><dt>choice_id</dt><dd><code>number</code> <span class="required">(required)</span> <span class="text-muted example"><strong>Example: </strong><span>1</span></span><p>ID of the Choice in form of an integer</p>
</dd></dl></div><div class="title"><strong>Response <code>201</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Location</span>: <span class="hljs-string">/questions/1</span></code></pre><div style="height: 1px;"></div></div></div></div></div><div id="question-questions-collection" class="resource"><h3>Questions Collection<a href="#question-questions-collection" class="permalink">¶</a></h3><div id="question-questions-collection-get" class="action get"><h4><div class="name">List All Questions</div><a href="#question-questions-collection-get" class="method get">GET</a><code class="uri">/questions{?page}</code></h4><div class="title"><strong>Parameters</strong><div class="collapse-button show"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><dl class="inner"><dt>page</dt><dd><code>number</code> <span>(optional)</span> <span class="text-muted example"><strong>Example: </strong><span>1</span></span><p>The page of questions to return</p>
</dd></dl></div><div class="title"><strong>Response <code>200</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span><br><span class="hljs-attribute">Link</span>: <span class="hljs-string"></questions?page=2>; rel="next"</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>[
{
"<span class="hljs-attribute">question</span>": <span class="hljs-value"><span class="hljs-string">"Favourite programming language?"</span></span>,
"<span class="hljs-attribute">published_at</span>": <span class="hljs-value"><span class="hljs-string">"2014-11-11T08:40:51.620Z"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1"</span></span>,
"<span class="hljs-attribute">choices</span>": <span class="hljs-value">[
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Swift"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/1"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">2048</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Python"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/2"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">1024</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Objective-C"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/3"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">512</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Ruby"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/1/choices/4"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">256</span>
</span>}
]
</span>}
]</code></pre><div style="height: 1px;"></div></div></div></div><div id="question-questions-collection-post" class="action post"><h4><div class="name">Create a New Question</div><a href="#question-questions-collection-post" class="method post">POST</a><code class="uri">/questions{?page}</code></h4><p>You may create your own question using this action. It takes a JSON object containing a question and a collection of answers in the form of choices.</p>
<ul>
<li>
<p>question (string) - The question</p>
</li>
<li>
<p>choices (array[string]) - A collection of choices.</p>
</li>
</ul>
<div class="title"><strong>Parameters</strong><div class="collapse-button show"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><dl class="inner"><dt>page</dt><dd><code>number</code> <span>(optional)</span> <span class="text-muted example"><strong>Example: </strong><span>1</span></span><p>The page of questions to return</p>
</dd></dl></div><div class="title"><strong>Request</strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">question</span>": <span class="hljs-value"><span class="hljs-string">"Favourite programming language?"</span></span>,
"<span class="hljs-attribute">choices</span>": <span class="hljs-value">[
<span class="hljs-string">"Swift"</span>,
<span class="hljs-string">"Python"</span>,
<span class="hljs-string">"Objective-C"</span>,
<span class="hljs-string">"Ruby"</span>
]
</span>}</code></pre><div style="height: 1px;"></div></div></div><div class="title"><strong>Response <code>201</code></strong><div class="collapse-button"><span class="close">Hide</span><span class="open">Show</span></div></div><div class="collapse-content"><div class="inner"><h5>Headers</h5><pre><code><span class="hljs-attribute">Content-Type</span>: <span class="hljs-string">application/json</span><br><span class="hljs-attribute">Location</span>: <span class="hljs-string">/questions/2</span></code></pre><div style="height: 1px;"></div><h5>Body</h5><pre><code>{
"<span class="hljs-attribute">question</span>": <span class="hljs-value"><span class="hljs-string">"Favourite programming language?"</span></span>,
"<span class="hljs-attribute">published_at</span>": <span class="hljs-value"><span class="hljs-string">"2014-11-11T08:40:51.620Z"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/2"</span></span>,
"<span class="hljs-attribute">choices</span>": <span class="hljs-value">[
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Swift"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/2/choices/1"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">0</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Python"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/2/choices/2"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">0</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Objective-C"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/2/choices/3"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">0</span>
</span>},
{
"<span class="hljs-attribute">choice</span>": <span class="hljs-value"><span class="hljs-string">"Ruby"</span></span>,
"<span class="hljs-attribute">url</span>": <span class="hljs-value"><span class="hljs-string">"/questions/2/choices/4"</span></span>,
"<span class="hljs-attribute">votes</span>": <span class="hljs-value"><span class="hljs-number">0</span>
</span>}
]
</span>}</code></pre><div style="height: 1px;"></div></div></div></div></div></section></div></div></div><p style="text-align: center;" class="text-muted">Generated by <a href="https://github.com/danielgtaylor/aglio" class="aglio">aglio</a> on 10 Aug 2015</p><script>/* eslint-env browser */
/* eslint quotes: [2, "single"] */
'use strict';
/*
Determine if a string ends with another string.
*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
/*
Get an array [width, height] of the window.
*/
function getWindowDimensions() {
var w = window,
d = document,
e = d.documentElement,
g = d.body,
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
return [x, y];
}
/*
Collapse or show a request/response example.
*/
function toggleCollapseButton(event) {
var button = event.target.parentNode;
var content = button.parentNode.nextSibling;
var inner = content.children[0];
if (button.className.indexOf('collapse-button') === -1) {
// Clicked without hitting the right element?
return;
}
if (content.style.maxHeight && content.style.maxHeight !== '0px') {
// Currently showing, so let's hide it
button.className = 'collapse-button';
content.style.maxHeight = '0px';
} else {
// Currently hidden, so let's show it
button.className = 'collapse-button show';
content.style.maxHeight = inner.offsetHeight + 12 + 'px';
}
}
/*
Collapse or show a navigation menu. It will not be hidden unless it
is currently selected or `force` has been passed.
*/
function toggleCollapseNav(event, force) {
var heading = event.target.parentNode;
var content = heading.nextSibling;
var inner = content.children[0];
if (heading.className.indexOf('heading') === -1) {
// Clicked without hitting the right element?
return;
}
if (content.style.maxHeight && content.style.maxHeight !== '0px') {
// Currently showing, so let's hide it, but only if this nav item
// is already selected. This prevents newly selected items from
// collapsing in an annoying fashion.
if (force || window.location.hash && endsWith(event.target.href, window.location.hash)) {
content.style.maxHeight = '0px';
}
} else {
// Currently hidden, so let's show it
content.style.maxHeight = inner.offsetHeight + 12 + 'px';
}
}
/*
Refresh the page after a live update from the server. This only
works in live preview mode (using the `--server` parameter).
*/
function refresh(body) {
document.querySelector('body').className = 'preload';
document.body.innerHTML = body;
// Re-initialize the page
init();
autoCollapse();
document.querySelector('body').className = '';
}
/*
Determine which navigation items should be auto-collapsed to show as many
as possible on the screen, based on the current window height. This also
collapses them.
*/
function autoCollapse() {
var windowHeight = getWindowDimensions()[1];
var itemsHeight = 64; /* Account for some padding */
var itemsArray = Array.prototype.slice.call(
document.querySelectorAll('nav .resource-group .heading'));
// Get the total height of the navigation items
itemsArray.forEach(function (item) {
itemsHeight += item.parentNode.offsetHeight;
});
// Should we auto-collapse any nav items? Try to find the smallest item
// that can be collapsed to show all items on the screen. If not possible,
// then collapse the largest item and do it again. First, sort the items
// by height from smallest to largest.
var sortedItems = itemsArray.sort(function (a, b) {
return a.parentNode.offsetHeight - b.parentNode.offsetHeight;
});
while (sortedItems.length && itemsHeight > windowHeight) {
for (var i = 0; i < sortedItems.length; i++) {
// Will collapsing this item help?
var itemHeight = sortedItems[i].nextSibling.offsetHeight;
if ((itemsHeight - itemHeight <= windowHeight) || i === sortedItems.length - 1) {
// It will, so let's collapse it, remove its content height from
// our total and then remove it from our list of candidates
// that can be collapsed.
itemsHeight -= itemHeight;
toggleCollapseNav({target: sortedItems[i].children[0]}, true);
sortedItems.splice(i, 1);
break;
}
}
}
}
/*
Initialize the interactive functionality of the page.
*/
function init() {
var i;
// Make collapse buttons clickable
var buttons = document.querySelectorAll('.collapse-button');
for (i = 0; i < buttons.length; i++) {
buttons[i].onclick = toggleCollapseButton;
// Show by default? Then toggle now.
if (buttons[i].className.indexOf('show') !== -1) {
toggleCollapseButton({target: buttons[i].children[0]});
}
}
// Make nav items clickable to collapse/expand their content.
var navItems = document.querySelectorAll('nav .resource-group .heading');
for (i = 0; i < navItems.length; i++) {
navItems[i].onclick = toggleCollapseNav;
// Show all by default
toggleCollapseNav({target: navItems[i].children[0]});
}
}
// Initial call to set up buttons
init();
window.onload = function () {
autoCollapse();
// Remove the `preload` class to enable animations
document.querySelector('body').className = '';
};
</script></body></html>