Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cee20406c3
Fetching contributors…

Cannot retrieve contributors at this time

178 lines (145 sloc) 5.154 kb
<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>
Jump to Line
Something went wrong with that request. Please try again.