Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 174 lines (145 sloc) 5.185 kb
8dc6daf @wycats Initial commit
authored
1 <html>
2 <head>
3 <style>
4 body {
5 font-family: Helvetica Neue, Helvetica, sans-serif;
6 font-size: 11px;
7 }
8
9 header {
10 margin: 10px 0 20px 0;
11 font-size: 14px;
12 font-weight: bold;
13 }
14
15 h1 span {
16 font-weight: normal;
17 margin-left: 30px;
18 font-size: 11px;
19 float: right;
20 color: #ccc;
21 }
22
23 ul.monospace {
24 font-family: Menlo, Monaco, monospace;
25 list-style-type: none;
4f7314d @ebryn Display arrays in a more structured way, rather than just outputting …
ebryn authored
26 margin: 0 0 10px 20px;
8dc6daf @wycats Initial commit
authored
27 padding-left: 0;
28 }
29
4f7314d @ebryn Display arrays in a more structured way, rather than just outputting …
ebryn authored
30 ol.array {
31 list-style: none;
32 padding-left: 10px;
33 }
34
35 li.array {
36 margin-left: -10px;
37 padding-left: 10px;
38 background: url(tree-down.png) no-repeat 0 4px;
39 }
40
41 ol.array li {
42 float: left;
43 margin-right: 5px;
44 }
45 ol.array li:not(:last-child):after {
46 content: ', ';
47 }
8dc6daf @wycats Initial commit
authored
48 .prop-name {
49 color: #881391;
50 }
51
52 h1 {
53 font-size: 11px;
54 font-family: Menlo, Monaco, monospace;
55 padding-left: 10px;
56 background: url(tree-down.png) no-repeat left;
57 margin: 10px 0 0 0;
58 }
59
60 h1.no-props {
61 background: none;
62 }
63 </style>
64 <script src="jquery.js"></script>
65 <script src="handlebars.js"></script>
66
67 <script type="text/x-template">
68 {{#forIn result}}
69 <h1 {{^ifProps}}class='no-props'{{/ifProps}}><span>{{type}}{{^ifProps}} (none){{/ifProps}}</span></h1>
70
71 <ul class='monospace'>
72 {{#forIn properties}}
73 <li><span class='prop-name'>{{name}}</span>: <span class='prop-value'>{{value}}</span></li>
74 {{/forIn}}
75 </ul>
76 {{/forIn}}
77 </script>
78
79 <script>
80 Handlebars.registerHelper('forIn', function(context, options) {
81 var childContext, exposedChildContext, buffer = "";
82
83 for (var prop in context) {
84 if (!context.hasOwnProperty(prop)) { continue; }
85
86 childContext = context[prop];
87
88 exposedChildContext = Object.create(childContext);
89 exposedChildContext._key = prop;
90
91 buffer = buffer + options.fn(exposedChildContext);
92 }
93 });
94
95 Handlebars.registerHelper('ifProps', function(context, options) {
96 hasProps = false;
97 for (var prop in context) { hasProps = true; }
98
99 if (hasProps) {
100 return options.fn(context);
101 } else {
102 return options.inverse(context);
103 }
104 });
105
106 webInspector.panels.elements.onSelectionChanged.addListener(function() {
107 webInspector.inspectedWindow.eval("SproutQueryExtension.properties(SC.View.views[$0.id])", function(result) {
108 result = JSON.parse(result);
109 var buffer = "", resultProp, klassProp, prop, klass, anyProps;
110
111 var classProperties = true;
112
113 for (resultProp in result) {
114 klass = result[resultProp];
115 anyProps = false;
116
117 for (prop in klass.properties) { anyProps = true; }
118
119 if (classProperties) {
120 buffer = buffer + "<h1";
121 if (!anyProps) { buffer = buffer + " class='no-props'"; }
122 buffer = buffer + "><span>inherited properties";
123 if (!anyProps) { buffer = buffer + " (none)"; }
124 buffer = buffer + "</span>" + klass.name + "</h1>";
125 } else {
126 buffer = buffer + "<h1";
127 if (!anyProps) { buffer = buffer + " class='no-props'"; }
128 buffer = buffer + "><span>inherited properties";
129 if (!anyProps) { buffer = buffer + " (none)"; }
130 buffer = buffer + "</span>" + klass.name + "</h1>";
131 }
132
133 classProperties = false;
134
135 buffer = buffer + "<ul class='monospace'>";
136
4f7314d @ebryn Display arrays in a more structured way, rather than just outputting …
ebryn authored
137 function simpleProp(klassProp) {
138 var buffer = "<li><span class='prop-name'>" + klassProp.name + "</span>: ";
139 buffer += "<span class='prop-value'>" + klassProp.value + "</span></li>";
140 return buffer;
141 }
142
8dc6daf @wycats Initial commit
authored
143 for (prop in klass.properties) {
144 klassProp = klass.properties[prop];
4f7314d @ebryn Display arrays in a more structured way, rather than just outputting …
ebryn authored
145 if (klassProp.value.charAt(0) == '[' && klassProp.value.substring(0, 7) != '[object') {
146 var propArray = klassProp.value.replace(/^\[|\]$/g, '').split(',');
147 if (propArray.length > 0 && propArray.toString() != "") {
148 buffer += "<li class='array'><span class='prop-name'>" + klassProp.name + "</span>: ";
149 buffer += "[<ol class='array'>";
150 for (var i = 0; i < propArray.length; i++) {
151 buffer += "<li><span class='prop-value'>" + propArray[i] + "</span></li>";
152 }
153 buffer += "</ol><div style='clear: left;'></div>]</li>";
154 } else {
155 buffer += simpleProp(klassProp);
156 }
157 } else {
158 buffer += simpleProp(klassProp);
159 }
8dc6daf @wycats Initial commit
authored
160 }
161
162 buffer = buffer + "</ul>";
163 }
164
165 $("body").html(buffer);
166 });
167 });
168 </script>
169 </head>
170 <body>
171 HI
172 </body>
173 </html>
Something went wrong with that request. Please try again.