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 } |
11 | 11 |
12 /** | 12 /** |
13 * @const | 13 * @const |
14 * @type {!Array.<{source: !Object, url: string, name: string}>} | 14 * @type {!Array.<{source: !Object, url: string, name: string}>} |
15 */ | 15 */ |
16 WebInspector.DocumentationURLProvider._sources = [ | 16 WebInspector.DocumentationURLProvider._sources = [ |
17 { source: window, url: "javascript/", name: "Global" }, | 17 { source: window, url: "javascript/", name: "Global" }, |
18 { source: window.Node.prototype, url: "dom/Node/", name: "Node.prototype" }, | 18 { source: window.Node.prototype, url: "dom/Node/", name: "Node.prototype" }, |
19 { source: window.Node, url: "dom/Node/", name: "Node" }, | 19 { source: window.Node, url: "dom/Node/", name: "Node" }, |
20 { source: window.Object.prototype, url: "javascript/Object/", name: "Object. prototype" }, | 20 { source: window.Object.prototype, url: "javascript/Object/", name: "Object. prototype" }, |
21 { source: window.Object, url: "javascript/Object/", name: "Object" }, | 21 { source: window.Object, url: "javascript/Object/", name: "Object" }, |
22 { source: window.Math, url: "javascript/Math/", name: "Math" }, | 22 { source: window.Math, url: "javascript/Math/", name: "Math" }, |
23 { source: window.Array.prototype, url: "javascript/Array/", name: "Array.pro totype" }, | 23 { source: window.Array.prototype, url: "javascript/Array/", name: "Array.pro totype" }, |
24 { source: window.Array, url: "javascript/Array/", name: "Array" }, | 24 { source: window.Array, url: "javascript/Array/", name: "Array" }, |
25 { source: window.String.prototype, url: "javascript/String/", name: "String. prototype" }, | 25 { source: window.String.prototype, url: "javascript/String/", name: "String. prototype" }, |
26 { source: window.String, url: "javascript/String/", name: "String" }, | 26 { source: window.String, url: "javascript/String/", name: "String" }, |
27 { source: window.Date.prototype, url: "javascript/Date/", name: "Date.protot ype" }, | 27 { source: window.Date.prototype, url: "javascript/Date/", name: "Date.protot ype" }, |
28 { source: window.Date, url: "javascript/Date/", name: "Date" }, | 28 { source: window.Date, url: "javascript/Date/", name: "Date" }, |
29 { source: window.JSON, url: "javascript/JSON/", name: "JSON" } | 29 { source: window.JSON, url: "javascript/JSON/", name: "JSON" }, |
30 { source: window.Number, url: "javascript/Number/", name: "Number"}, | |
31 { source: window.Number.prototype, url: "javascript/Number/", name: "Number. prototype"}, | |
32 { source: window.Error.prototype, url: "javascript/Error/", name: "Error.pro totype"}, | |
33 { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp. prototype"} | |
30 ]; | 34 ]; |
31 | 35 |
32 /** | 36 /** |
33 * @const | 37 * @const |
34 */ | 38 */ |
35 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" |
36 | 40 |
41 /** | |
42 * @param {string} sourceUrl | |
43 * @param {string} objectName | |
44 * @param {string} searchTerm | |
45 * @return {{url: string, name: string}} | |
46 */ | |
47 WebInspector.DocumentationURLProvider._createProperty = function(sourceUrl, obje ctName, searchTerm) | |
apavlov
2014/08/13 13:35:35
Turn this into a nested function inside itemDescri
semeny
2014/08/13 14:10:17
Done.
| |
48 { | |
49 return { | |
50 url: String.sprintf(WebInspector.DocumentationURLProvider._urlFormat, so urceUrl, searchTerm), | |
51 name: objectName | |
52 } | |
apavlov
2014/08/13 13:35:35
Missing ';'
lushnikov
2014/08/13 13:42:15
semicolon
semeny
2014/08/13 14:10:18
Done.
| |
53 } | |
54 | |
37 WebInspector.DocumentationURLProvider.prototype = { | 55 WebInspector.DocumentationURLProvider.prototype = { |
38 /** | 56 /** |
39 * @param {string} searchTerm | 57 * @param {string} searchTerm |
40 * @return {!Array.<{url: string, name: string}>} | 58 * @return {!Array.<{url: string, name: string}>} |
41 */ | 59 */ |
42 itemDescriptors: function(searchTerm) | 60 itemDescriptors: function(searchTerm) |
43 { | 61 { |
44 var possibleProperties = []; | 62 var possibleProperties = []; |
apavlov
2014/08/13 13:35:34
var descriptors = [];
semeny
2014/08/13 14:10:18
Done.
| |
45 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt h; ++i) { | 63 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.lengt h; ++i) { |
46 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; | 64 var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; |
47 if (sourceRef.source[searchTerm] instanceof Function) { | 65 if (!(searchTerm in sourceRef.source)) |
lushnikov
2014/08/13 13:42:15
lets use hasOwnProperty instead of "in"
semeny
2014/08/13 14:10:18
Done.
| |
48 var property = { | 66 continue; |
49 url: String.sprintf(WebInspector.DocumentationURLProvider._u rlFormat, sourceRef.url, searchTerm), | 67 if (searchTerm.toUpperCase() === searchTerm) |
50 name: sourceRef.name | 68 var property = WebInspector.DocumentationURLProvider._createProp erty(sourceRef.url, sourceRef.name, "constants"); |
apavlov
2014/08/13 13:35:35
We discourage multiple var declarations in conditi
semeny
2014/08/13 14:10:17
Done.
| |
51 }; | 69 else |
52 possibleProperties.push(property); | 70 var property = WebInspector.DocumentationURLProvider._createProp erty(sourceRef.url, sourceRef.name, searchTerm); |
53 } | 71 possibleProperties.push(property); |
54 } | 72 } |
55 return possibleProperties; | 73 return possibleProperties; |
56 } | 74 } |
57 } | 75 } |
OLD | NEW |