OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This file is the controller for generating extension | 6 * @fileoverview This file is the controller for generating extension |
7 * doc pages. | 7 * doc pages. |
8 * | 8 * |
9 * It expects to have available via XHR (relative path): | 9 * It expects to have available via XHR (relative path): |
10 * 1) API_TEMPLATE which is the main template for the api pages. | 10 * 1) API_TEMPLATE which is the main template for the api pages. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 // Assigns all keys & values of |obj2| to |obj1|. | 130 // Assigns all keys & values of |obj2| to |obj1|. |
131 function extend(obj, obj2) { | 131 function extend(obj, obj2) { |
132 for (var k in obj2) { | 132 for (var k in obj2) { |
133 obj[k] = obj2[k]; | 133 obj[k] = obj2[k]; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 /* | 137 /* |
138 * Main entry point for composing the page. It will fetch it's template, | 138 * Main entry point for composing the page. It will fetch its template, |
139 * the extension api, and attempt to fetch the matching static content. | 139 * the extension api, and attempt to fetch the matching static content. |
140 * It will insert the static content, if any, prepare it's pageData then | 140 * It will insert the static content, if any, prepare its pageData then |
141 * render the template from |pageData|. | 141 * render the template from |pageData|. |
142 */ | 142 */ |
143 function renderPage() { | 143 function renderPage() { |
144 // The page name minus the '.html' extension. | 144 // The page name minus the '.html' extension. |
145 pageBase = document.location.href.match(/\/([^\/]*)\.html/)[1]; | 145 pageBase = document.location.href.match(/\/([^\/]*)\.html/)[1]; |
146 if (!pageBase) { | 146 if (!pageBase) { |
147 alert('Empty page name for: ' + document.location.href); | 147 alert('Empty page name for: ' + document.location.href); |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 var data = JSON.parse(JSON.minify(sampleManifest)); | 210 var data = JSON.parse(JSON.minify(sampleManifest)); |
211 samples = data.samples; | 211 samples = data.samples; |
212 apiMapping = data.api; | 212 apiMapping = data.api; |
213 renderTemplate(); | 213 renderTemplate(); |
214 }, function(error) { | 214 }, function(error) { |
215 renderTemplate(); | 215 renderTemplate(); |
216 }); | 216 }); |
217 } | 217 } |
218 | 218 |
219 /** | 219 /** |
220 * Fetches |url| and returns it's text contents from the xhr.responseText in | 220 * Fetches |url| and returns its text contents from the xhr.responseText in |
221 * onSuccess(content) | 221 * onSuccess(content) |
222 */ | 222 */ |
223 function fetchContent(url, onSuccess, onError) { | 223 function fetchContent(url, onSuccess, onError) { |
224 var localUrl = url; | 224 var localUrl = url; |
225 var xhr = new XMLHttpRequest(); | 225 var xhr = new XMLHttpRequest(); |
226 var abortTimerId = window.setTimeout(function() { | 226 var abortTimerId = window.setTimeout(function() { |
227 xhr.abort(); | 227 xhr.abort(); |
228 console.log('XHR Timed out'); | 228 console.log('XHR Timed out'); |
229 }, REQUEST_TIMEOUT); | 229 }, REQUEST_TIMEOUT); |
230 | 230 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 679 } |
680 if (a.name > b.name) { | 680 if (a.name > b.name) { |
681 return 1; | 681 return 1; |
682 } | 682 } |
683 return 0; | 683 return 0; |
684 } | 684 } |
685 | 685 |
686 function disableDocs(obj) { | 686 function disableDocs(obj) { |
687 return !!obj.nodoc || !!obj.internal; | 687 return !!obj.nodoc || !!obj.internal; |
688 } | 688 } |
OLD | NEW |