OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 */ |
| 8 WebInspector.DocumentationURLProvider = function() {} |
| 9 |
| 10 /** |
| 11 * @const |
| 12 * @type {!Array.<!Object, string>} |
| 13 */ |
| 14 WebInspector.DocumentationURLProvider._Sources = [ |
| 15 { source: window, url: "javascript/" }, |
| 16 { source: window.Node.prototype, url: "dom/Node/" }, |
| 17 { source: window.Object, url: "javascript/Object/" }, |
| 18 { source: window.Math, url: "javascript/Math/" }, |
| 19 { source: window.Array, url: "javascript/Array/" }, |
| 20 { source: window.String, url: "javascript/String/" }, |
| 21 { source: window.Date, url: "javascript/Date/" }, |
| 22 { source: window.JSON, url: "javascript/JSON/" } |
| 23 ] |
| 24 |
| 25 /** |
| 26 * @const |
| 27 */ |
| 28 WebInspector.DocumentationURLProvider._URLFormat = "http://docs.webplatform.org/
w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma
t=json" |
| 29 |
| 30 WebInspector.DocumentationURLProvider.prototype = { |
| 31 /** |
| 32 * @param {string} searchTerm |
| 33 * @return {?string} |
| 34 */ |
| 35 itemPath: function(searchTerm) |
| 36 { |
| 37 for (var i = 0; i < WebInspector.DocumentationURLProvider._Sources.lengt
h; ++i) { |
| 38 var sourceRef = WebInspector.DocumentationURLProvider._Sources[i]; |
| 39 if (sourceRef.source[searchTerm] instanceof Function) |
| 40 return String.sprintf(WebInspector.DocumentationURLProvider._URL
Format, sourceRef.url, searchTerm); |
| 41 } |
| 42 return null; |
| 43 } |
| 44 } |
OLD | NEW |