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.
8 WebInspector.DocumentationURLProvider = function()
14 * @type {!Array.<{source: !Object, url: string, name: string}>}
16 WebInspector.DocumentationURLProvider._sources = [
17 { source: window, url: "javascript/", name: "Global" },
18 { source: window.Node.prototype, url: "dom/Node/", name: "Node.prototype" },
19 { source: window.Node, url: "dom/Node/", name: "Node" },
20 { source: window.Object.prototype, url: "javascript/Object/", name: "Object.prototype" },
21 { source: window.Object, url: "javascript/Object/", name: "Object" },
22 { source: window.Math, url: "javascript/Math/", name: "Math" },
23 { source: window.Array.prototype, url: "javascript/Array/", name: "Array.prototype" },
24 { source: window.Array, url: "javascript/Array/", name: "Array" },
25 { source: window.String.prototype, url: "javascript/String/", name: "String.prototype" },
26 { source: window.String, url: "javascript/String/", name: "String" },
27 { source: window.Date.prototype, url: "javascript/Date/", name: "Date.prototype" },
28 { source: window.Date, url: "javascript/Date/", name: "Date" },
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.prototype"},
33 { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp.prototype"}
39 WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&format=json"
42 * @typedef {{url: string, name: string, searchItem: string}}
44 WebInspector.DocumentationURLProvider.ItemDescriptor;
46 WebInspector.DocumentationURLProvider.prototype = {
48 * @param {string} searchTerm
49 * @return {!Array.<!WebInspector.DocumentationURLProvider.ItemDescriptor>}
51 itemDescriptors: function(searchTerm)
54 for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.length; ++i) {
55 var sourceRef = WebInspector.DocumentationURLProvider._sources[i];
56 if (!sourceRef.source.hasOwnProperty(searchTerm))
58 descriptors.push(createDescriptor(searchTerm.toUpperCase() === searchTerm ? "constants" : searchTerm));
63 * @param {string} searchTerm
64 * @return {!WebInspector.DocumentationURLProvider.ItemDescriptor}
66 function createDescriptor(searchTerm)
69 url: String.sprintf(WebInspector.DocumentationURLProvider._urlFormat, sourceRef.url, searchTerm),
71 searchItem: searchTerm