1 | dojo.provide("dojox.help.console"); |
---|
2 | dojo.require("dojox.help._base"); |
---|
3 | |
---|
4 | dojo.mixin(dojox.help, { |
---|
5 | _plainText: function(str){ |
---|
6 | return str.replace(/(<[^>]*>|&[^;]{2,6};)/g, ''); |
---|
7 | }, |
---|
8 | _displayLocated: function(located){ |
---|
9 | var obj = {}; |
---|
10 | dojo.forEach(located, function(item){ obj[item[0]] = dojo.isMoz ? { toString: function(){ return "Click to view"; }, item: item[1] } : item[1]; }); |
---|
11 | console.dir(obj); |
---|
12 | }, |
---|
13 | _displayHelp: function(loading, obj){ |
---|
14 | if(loading){ |
---|
15 | var message = "Help for: " + obj.name; |
---|
16 | console.log(message); |
---|
17 | var underline = ""; |
---|
18 | for(var i = 0; i < message.length; i++){ |
---|
19 | underline += "="; |
---|
20 | } |
---|
21 | console.log(underline); |
---|
22 | }else if(!obj){ |
---|
23 | console.log("No documentation for this object"); |
---|
24 | }else{ |
---|
25 | var anything = false; |
---|
26 | for(var attribute in obj){ |
---|
27 | var value = obj[attribute]; |
---|
28 | if(attribute == "returns" && obj.type != "Function" && obj.type != "Constructor"){ |
---|
29 | continue; |
---|
30 | } |
---|
31 | if(value && (!dojo.isArray(value) || value.length)){ |
---|
32 | anything = true; |
---|
33 | console.info(attribute.toUpperCase()); |
---|
34 | value = dojo.isString(value) ? dojox.help._plainText(value) : value; |
---|
35 | if(attribute == "returns"){ |
---|
36 | var returns = dojo.map(value.types || [], "return item.title;").join("|"); |
---|
37 | if(value.summary){ |
---|
38 | if(returns){ |
---|
39 | returns += ": "; |
---|
40 | } |
---|
41 | returns += dojox.help._plainText(value.summary); |
---|
42 | } |
---|
43 | console.log(returns || "Uknown"); |
---|
44 | }else if(attribute == "parameters"){ |
---|
45 | for(var j = 0, parameter; parameter = value[j]; j++){ |
---|
46 | var type = dojo.map(parameter.types, "return item.title").join("|"); |
---|
47 | console.log((type) ? (parameter.name + ": " + type) : parameter.name); |
---|
48 | var summary = ""; |
---|
49 | if(parameter.optional){ |
---|
50 | summary += "Optional. "; |
---|
51 | } |
---|
52 | if(parameter.repating){ |
---|
53 | summary += "Repeating. "; |
---|
54 | } |
---|
55 | summary += dojox.help._plainText(parameter.summary); |
---|
56 | if(summary){ |
---|
57 | summary = " - " + summary; |
---|
58 | for(var k = 0; k < parameter.name.length; k++){ |
---|
59 | summary = " " + summary; |
---|
60 | } |
---|
61 | console.log(summary); |
---|
62 | } |
---|
63 | } |
---|
64 | }else{ |
---|
65 | console.log(value); |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | if(!anything){ |
---|
70 | console.log("No documentation for this object"); |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | }); |
---|
75 | |
---|
76 | dojox.help.init(); |
---|