(function () {
  'use strict';

  angular
    .module('PLMApp')
    .factory('BuggleWorld', BuggleWorld);

  function BuggleWorld() {

    var BuggleWorld = function (world) {
      this.type = world.type;
      this.operations = [];
      this.currentState = -1;
      this.steps = [];

      this.width = world.width;
      this.height = world.height;
    };

    BuggleWorld.prototype.clone = function () {
      return new BuggleWorld(this);
    };

      BuggleWorld.prototype.addOperations = function (operations) {
          var i, step, length, operation, generatedOperation;

          step = [];
          length = operations.length;
          for (i = 0; i < length; i += 1) {
              operation = operations[i];
              step.push(operation);
              // generatedOperation = this.generateOperation(operation);
              // step.push(generatedOperation);
          }
          this.operations.push(step);
      };

      BuggleWorld.prototype.setState = function (state) {
          var i, j, length, step;
          if (state < this.operations.length && state >= -1) {

              if (this.currentState < state) {
                  for (i = this.currentState + 1; i <= state; i += 1) {
                      // step = this.operations[i];
                      step= this.operations;
                      length = step.length;
                      // for (j = 0; j < length; j += 1) {
                      // step[j].apply(this);
                      this.drawSVG(step[i][0]);
                      // }
                  }
              } else {
                  for (i = this.currentState; i > state; i -= 1) {
                      // step = this.operations[i];
                      step= this.operations;
                      length = step.length;
                      // for (j = 0; j < length; j += 1) {
                      // step[j].reverse(this);
                      this.drawSVG(step[i][0]);
                      // }
                  }
              }
              this.currentState = state;
          }
      };

    BuggleWorld.prototype.drawSVG = function (svg) {
          (function () {

              document.getElementById('drawingArea').innerHTML = svg.operation;
              var svgbis = document.getElementsByTagName('svg');
              svgbis[0].setAttribute("width", "400px");
              svgbis[0].setAttribute("height", "400px");


          })();

      };

    return BuggleWorld;
  }
}());

@@ -762,129 +762,8 @@
 n);%0A
-              // generatedOperation = this.generateOperation(operation);%0A              // step.push(generatedOperation);%0A
     
@@ -762,32 +762,32 @@
 n);%0A          %7D%0A
+
           this.o
@@ -1097,60 +1097,8 @@
 ) %7B%0A
-                      // step = this.operations%5Bi%5D;%0A
     
@@ -1186,113 +1186,8 @@
 th;%0A
-                      // for (j = 0; j %3C length; j += 1) %7B%0A                      // step%5Bj%5D.apply(this);%0A
     
@@ -1234,35 +1234,8 @@
 %5D);%0A
-                      // %7D%0A
     
@@ -1344,60 +1344,8 @@
 ) %7B%0A
-                      // step = this.operations%5Bi%5D;%0A
     
@@ -1433,115 +1433,8 @@
 th;%0A
-                      // for (j = 0; j %3C length; j += 1) %7B%0A                      // step%5Bj%5D.reverse(this);%0A
     
@@ -1481,35 +1481,8 @@
 %5D);%0A
-                      // %7D%0A
     
@@ -1914,17 +1914,16 @@
 0px%22);%0A%0A
-%0A
         
@@ -1930,17 +1930,16 @@
   %7D)();%0A
-%0A
       %7D;

kill dead code