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