Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 177 lines (145 sloc) 5.154 kb
8dc6daf5 »
2011-07-11 Initial commit
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;
4f7314d6 » ebryn
2011-07-23 Display arrays in a more structured way, rather than just outputting …
26 margin: 0 0 10px 20px;
8dc6daf5 »
2011-07-11 Initial commit
27 padding-left: 0;
28 }
29
4f7314d6 » ebryn
2011-07-23 Display arrays in a more structured way, rather than just outputting …
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 }
8dc6daf5 »
2011-07-11 Initial commit
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
cee20406 » ebryn
2011-07-23 Move prop functions
106 function simpleProp(klassProp) {
107 var buffer = "<li><span class='prop-name'>" + klassProp.name + "</span>: ";
108 buffer += "<span class='prop-value'>" + klassProp.value + "</span></li>";
109 return buffer;
110 }
111
112 function arrayProp(klassProp) {
113 var propArray, buffer = "";
114
115 if (klassProp.value === "[]") { return simpleProp(klassProp); }
116
117 propArray = klassProp.value.replace(/^\[|\]$/g, '').split(',');
118 buffer += "<li class='array'><span class='prop-name'>" + klassProp.name + "</span>: ";
119 buffer += "[<ol class='array'>";
120 for (var i = 0; i < propArray.length; i++) {
121 buffer += "<li><span class='prop-value'>" + propArray[i] + "</span></li>";
122 }
123 buffer += "</ol><div style='clear: left;'></div>]</li>";
124 return buffer;
125 }
126
8dc6daf5 »
2011-07-11 Initial commit
127 webInspector.panels.elements.onSelectionChanged.addListener(function() {
128 webInspector.inspectedWindow.eval("SproutQueryExtension.properties(SC.View.views[$0.id])", function(result) {
129 result = JSON.parse(result);
ea877719 » ebryn
2011-07-23 Refactor
130 var buffer = "", resultProp, klassProp, prop, klass, anyProps, isArrayProp;
8dc6daf5 »
2011-07-11 Initial commit
131
132 var classProperties = true;
133
134 for (resultProp in result) {
135 klass = result[resultProp];
136 anyProps = false;
137
138 for (prop in klass.properties) { anyProps = true; }
139
140 if (classProperties) {
141 buffer = buffer + "<h1";
142 if (!anyProps) { buffer = buffer + " class='no-props'"; }
143 buffer = buffer + "><span>inherited properties";
144 if (!anyProps) { buffer = buffer + " (none)"; }
145 buffer = buffer + "</span>" + klass.name + "</h1>";
146 } else {
147 buffer = buffer + "<h1";
148 if (!anyProps) { buffer = buffer + " class='no-props'"; }
149 buffer = buffer + "><span>inherited properties";
150 if (!anyProps) { buffer = buffer + " (none)"; }
151 buffer = buffer + "</span>" + klass.name + "</h1>";
152 }
153
154 classProperties = false;
155
156 buffer = buffer + "<ul class='monospace'>";
157
158 for (prop in klass.properties) {
159 klassProp = klass.properties[prop];
ea877719 » ebryn
2011-07-23 Refactor
160 isArrayProp = klassProp.value.charAt(0) === '[' && klassProp.value.substring(0, 7) !== '[object';
161
162 if (isArrayProp) { buffer += arrayProp(klassProp); }
163 else { buffer += simpleProp(klassProp); }
8dc6daf5 »
2011-07-11 Initial commit
164 }
165
166 buffer = buffer + "</ul>";
167 }
168
169 $("body").html(buffer);
170 });
171 });
172 </script>
173 </head>
174 <body>
175 HI
176 </body>
177 </html>
Something went wrong with that request. Please try again.