Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Display arrays in a more structured way #2

Merged
merged 3 commits into from

2 participants

@ebryn

Display arrays in a more structured way, rather than just outputting them as strings.

@wycats wycats merged commit fa5f228 into wycats:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 24, 2011
  1. @ebryn
  2. @ebryn

    Refactor

    ebryn authored
  3. @ebryn

    Move prop functions

    ebryn authored
This page is out of date. Refresh to see the latest.
Showing with 45 additions and 3 deletions.
  1. +45 −3 wot.html
View
48 wot.html
@@ -23,10 +23,28 @@
ul.monospace {
font-family: Menlo, Monaco, monospace;
list-style-type: none;
- margin: 0 0 10px 10px;
+ 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;
}
@@ -85,10 +103,31 @@ <h1 {{^ifProps}}class='no-props'{{/ifProps}}><span>{{type}}{{^ifProps}} (none){{
}
});
+ 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;
+ var buffer = "", resultProp, klassProp, prop, klass, anyProps, isArrayProp;
var classProperties = true;
@@ -118,7 +157,10 @@ <h1 {{^ifProps}}class='no-props'{{/ifProps}}><span>{{type}}{{^ifProps}} (none){{
for (prop in klass.properties) {
klassProp = klass.properties[prop];
- buffer = buffer + "<li><span class='prop-name'>" + klassProp.name + "</span>: <span class='prop-value'>" + klassProp.value + "</span></li>";
+ isArrayProp = klassProp.value.charAt(0) === '[' && klassProp.value.substring(0, 7) !== '[object';
+
+ if (isArrayProp) { buffer += arrayProp(klassProp); }
+ else { buffer += simpleProp(klassProp); }
}
buffer = buffer + "</ul>";
Something went wrong with that request. Please try again.