Skip to content
Browse files

Refactor

  • Loading branch information...
1 parent 4f7314d commit ea87771936dbdaa19e9cc044ccbad66b5021b536 @ebryn ebryn committed Jul 23, 2011
Showing with 20 additions and 16 deletions.
  1. +20 −16 wot.html
View
36 wot.html
@@ -106,7 +106,7 @@ <h1 {{^ifProps}}class='no-props'{{/ifProps}}><span>{{type}}{{^ifProps}} (none){{
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;
@@ -140,23 +140,27 @@ <h1 {{^ifProps}}class='no-props'{{/ifProps}}><span>{{type}}{{^ifProps}} (none){{
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;
+ }
+
for (prop in klass.properties) {
klassProp = klass.properties[prop];
- if (klassProp.value.charAt(0) == '[' && klassProp.value.substring(0, 7) != '[object') {
- var propArray = klassProp.value.replace(/^\[|\]$/g, '').split(',');
- if (propArray.length > 0 && propArray.toString() != "") {
- 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>";
- } else {
- buffer += simpleProp(klassProp);
- }
- } else {
- buffer += simpleProp(klassProp);
- }
+ isArrayProp = klassProp.value.charAt(0) === '[' && klassProp.value.substring(0, 7) !== '[object';
+
+ if (isArrayProp) { buffer += arrayProp(klassProp); }
+ else { buffer += simpleProp(klassProp); }
}
buffer = buffer + "</ul>";

0 comments on commit ea87771

Please sign in to comment.
Something went wrong with that request. Please try again.