OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 * @constructor | 6 * @constructor |
7 */ | 7 */ |
8 WebInspector.DocumentationURLProvider = function() | 8 WebInspector.DocumentationURLProvider = function() |
9 { | 9 { |
10 } | 10 } |
(...skipping 20 matching lines...) Expand all Loading... |
31 { source: window.Number.prototype, url: "javascript/Number/", name: "Number.
prototype"}, | 31 { source: window.Number.prototype, url: "javascript/Number/", name: "Number.
prototype"}, |
32 { source: window.Error.prototype, url: "javascript/Error/", name: "Error.pro
totype"}, | 32 { source: window.Error.prototype, url: "javascript/Error/", name: "Error.pro
totype"}, |
33 { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp.
prototype"} | 33 { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp.
prototype"} |
34 ]; | 34 ]; |
35 | 35 |
36 /** | 36 /** |
37 * @const | 37 * @const |
38 */ | 38 */ |
39 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/
w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma
t=json" | 39 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/
w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&forma
t=json" |
40 | 40 |
| 41 /** |
| 42 * @typedef {{url: string, name: string, searchItem: string}} |
| 43 */ |
| 44 WebInspector.DocumentationURLProvider.ItemDescriptor; |
| 45 |
41 WebInspector.DocumentationURLProvider.prototype = { | 46 WebInspector.DocumentationURLProvider.prototype = { |
42 /** | 47 /** |
43 * @param {string} searchTerm | 48 * @param {string} searchTerm |
44 * @return {!Array.<{url: string, name: string}>} | 49 * @return {!Array.<!WebInspector.DocumentationURLProvider.ItemDescriptor>} |
45 */ | 50 */ |
46 itemDescriptors: function(searchTerm) | 51 itemDescriptors: function(searchTerm) |
47 { | 52 { |
48 var descriptors = []; | 53 var descriptors = []; |
49 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt
h; ++i) { | 54 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt
h; ++i) { |
50 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; | 55 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; |
51 if (!sourceRef.source.hasOwnProperty(searchTerm)) | 56 if (!sourceRef.source.hasOwnProperty(searchTerm)) |
52 continue; | 57 continue; |
53 descriptors.push(createDescriptor(searchTerm.toUpperCase() === searc
hTerm ? "constants" : searchTerm)); | 58 descriptors.push(createDescriptor(searchTerm.toUpperCase() === searc
hTerm ? "constants" : searchTerm)); |
54 } | 59 } |
55 return descriptors; | 60 return descriptors; |
56 | 61 |
57 /** | 62 /** |
58 * @param {string} searchTerm | 63 * @param {string} searchTerm |
59 * @return {{url: string, name: string}} | 64 * @return {!WebInspector.DocumentationURLProvider.ItemDescriptor} |
60 */ | 65 */ |
61 function createDescriptor(searchTerm) | 66 function createDescriptor(searchTerm) |
62 { | 67 { |
63 return { | 68 return { |
64 url: String.sprintf(WebInspector.DocumentationURLProvider._urlFo
rmat, sourceRef.url, searchTerm), | 69 url: String.sprintf(WebInspector.DocumentationURLProvider._urlFo
rmat, sourceRef.url, searchTerm), |
65 name: sourceRef.name | 70 name: sourceRef.name, |
| 71 searchItem: searchTerm |
66 }; | 72 }; |
67 } | 73 } |
68 } | 74 } |
69 } | 75 } |
OLD | NEW |