Fix initial state issues.
authorDavid I. Lehn <dlehn@digitalbazaar.com>
Fri, 15 Jul 2011 16:38:35 -0400
changeset 71 c786d195a93a
parent 70 b210c41dddac
child 72 4b0e9ddd3d6e
Fix initial state issues.

- Add a default frame properly.
- Only process data if new data present.
playground/playground.js
--- a/playground/playground.js	Fri Jul 15 16:26:36 2011 -0400
+++ b/playground/playground.js	Fri Jul 15 16:38:35 2011 -0400
@@ -309,28 +309,38 @@
     */
    playground.populateWithJSON = function(data)
    {
+      var hasData = false;
+
       if('markup' in data && data.markup !== null)
       {
+         hasData = true;
          // fill the markup box with the example
          $("#markup").val(js_beautify(
             data.markup,
             { "indent_size": 3, "brace_style": "expand" }));
-         $("#frame").val("{}");
       }
 
       if('frame' in data && data.frame !== null)
       {
+         hasData = true;
          // fill the frame input box with the example frame
          $("#frame").val(js_beautify(
             data.frame,
             { "indent_size": 3, "brace_style": "expand" }));
       }
+      else
+      {
+         $("#frame").val("{}");
+      }
 
-      // perform processing on the data provided in the input boxes
-      playground.process();
+      if(hasData)
+      {
+         // perform processing on the data provided in the input boxes
+         playground.process();
 
-      // apply the syntax colorization
-      prettyPrint();
+         // apply the syntax colorization
+         prettyPrint();
+      }
    };
 
    /**