var $ = require("jquery");
var utils = require("../utils");

module.exports = function(dataSources){

  var contentFactory = {
    load : function(rerender){
      var value = [];
      var suppressRerender = false;
      var feedbackTrans = dataSources.get("translations").get("feedback");

      return {
        render : function(){
          var sourceField = $("<input type='text'></input>");

          var initField = $("<textarea></textarea>");
          var numberField = $("<input type='checkbox'></input>")
          var renameField = $("<input type='text'></input>")

          var createButton = $("<input type='button' value='Create'></input>")
            .click(function(){
              var source = sourceField.val();
              var init = initField.val();
              var name = renameField.val();

              var checked = numberField.is(":checked")
              if(checked){
                init = parseFloat(init) || 0;
              }

              if(source){
                  feedbackTrans(source, init, dataSources, name);
                  rerender();
              }
            });

          return $("<span></span>")
            .append($("<h3>Feedback Translation: </h3>"))
            .append($("<p>The source must be a tap data source or else infinite subscriptions will be generated by the feedback loop</p>"))
            .append($("<div></div>").append($("<span>Source: </span>")).append(sourceField))
            .append($("<div></div>").append($("<span>Number: </span>")).append(numberField))
            .append($("<div></div>").append($("<span>Init: </span>")).append(initField))
            .append($("<div></div>").append($("<span>Name: </span>")).append(renameField))
            .append(createButton);

        }, unload: function(){
          suppressRerender = true;
        }
      };
    }
  };

  dataSources.get("contentTypes").set("feedback-translation", contentFactory);
}

@@ -450,73 +450,8 @@
 %22);%0A
-          var numberField = $(%22%3Cinput type='checkbox'%3E%3C/input%3E%22)%0A
     
@@ -689,16 +689,27 @@
  init = 
+JSON.parse(
 initFiel
@@ -707,32 +707,41 @@
 (initField.val()
+) %7C%7C null
 ;%0A              
@@ -775,153 +775,8 @@
 );%0A%0A
-              var checked = numberField.is(%22:checked%22)%0A              if(checked)%7B%0A                init = parseFloat(init) %7C%7C 0;%0A              %7D%0A%0A
     
@@ -1257,101 +1257,8 @@
 d))%0A
-            .append($(%22%3Cdiv%3E%3C/div%3E%22).append($(%22%3Cspan%3ENumber: %3C/span%3E%22)).append(numberField))%0A
     

fix feedback