optimizations master
optimizations

--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "node-red-contrib-web-watch",
-    "version": "0.0.5",
+    "version": "0.0.6",
     "description": "A Node-RED node that watches for changes on webpages",
     "repository": {
         "type": "git",
@@ -9,7 +9,7 @@
     "dependencies": {
         "request": "^2.79.0"
     },
-    "inputs" : 0,
+    "inputs": 0,
     "keywords": [
         "node-red",
         "node-red-contrib",

--- a/web-watch/web-watch.html
+++ b/web-watch/web-watch.html
@@ -49,10 +49,6 @@
         <label for="node-input-interval"><i class="fa fa-clock-o"></i> Interval (S)</label>
         <input type="text" id="node-input-interval" placeholder="Interval">
     </div>
-    <div class="form-row">
-        <label for="node-input-headers"><i class="fa fa-user"></i> Custom headers</label>
-        <input type="text" id="node-input-headers" placeholder="Custom headers">
-    </div>
     <p>HTTP Authentication</p>
     <div class="form-row">
         <label for="node-input-username"><i class="fa fa-user"></i> Username</label>
@@ -90,7 +86,7 @@
 <script type="text/javascript">
     RED.nodes.registerType("Web watch", {
         category: "advanced-input",
-        color: "#3c8dbc",
+        color: "#91d2f7",
         defaults: {
             name: {value: ""},
             url: {value: "", required: true},
@@ -133,6 +129,20 @@
                     url: "web-watch/"+this.id+"/"+(this.active?"enable":"disable"),
                     type: "POST",
                     success: function(resp, textStatus, xhr) {
+                        var historyEvent = {
+                            t:'edit',
+                            node:node,
+                            changes:{
+                                active: !node.active
+                            },
+                            dirty:node.dirty,
+                            changed:node.changed
+                        };
+                        node.changed = true;
+                        node.dirty = true;
+                        RED.nodes.dirty(true);
+                        RED.history.push(historyEvent);
+                        RED.view.redraw();
                         if (xhr.status == 200) {
                             RED.notify(label + " succesfully activated", "success");
                         } else if (xhr.status == 201) {
@@ -141,11 +151,11 @@
                     },
                     error: function(jqXHR,textStatus,errorThrown) {
                         if (jqXHR.status == 404) {
-                            RED.notify(node._("common.notification.error", {message: node._("common.notification.errors.not-deployed")}),"error");
+                            RED.notify(label + " not deployed", "error");
                         } else if (jqXHR.status == 0) {
-                            RED.notify(node._("common.notification.error", {message: node._("common.notification.errors.no-response")}),"error");
+                            RED.notify(label + " no response", "error");
                         } else {
-                            RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.unexpected",{status:err.status,message:err.response})}),"error");
+                            RED.notify(label + " unexpected error", "error");
                         }
                     }
                 });
@@ -169,7 +179,7 @@
     });
     RED.nodes.registerType("Web watch in", {
         category: "advanced-input",
-        color: "#3c8dbc",
+        color: "#91d2f7",
         defaults: {
             name: {value: ""},
             url: {value: "", required: true},
@@ -190,7 +200,7 @@
             username: {value: ""},
             password: {value: ""},
             body: {value: "html", required: true},
-            active: {value:true}
+            active: {value: true}
         },
         inputs: 1,
         outputs: 1,
@@ -212,6 +222,20 @@
                     url: "web-watch/"+this.id+"/"+(this.active?"enable":"disable"),
                     type: "POST",
                     success: function(resp, textStatus, xhr) {
+                        var historyEvent = {
+                            t:'edit',
+                            node:node,
+                            changes:{
+                                active: !node.active
+                            },
+                            dirty:node.dirty,
+                            changed:node.changed
+                        };
+                        node.changed = true;
+                        node.dirty = true;
+                        RED.nodes.dirty(true);
+                        RED.history.push(historyEvent);
+                        RED.view.redraw();
                         if (xhr.status == 200) {
                             RED.notify(label + " succesfully activated", "success");
                         } else if (xhr.status == 201) {
@@ -220,11 +244,11 @@
                     },
                     error: function(jqXHR,textStatus,errorThrown) {
                         if (jqXHR.status == 404) {
-                            RED.notify(node._("common.notification.error", {message: node._("common.notification.errors.not-deployed")}),"error");
+                            RED.notify(label + " not deployed", "error");
                         } else if (jqXHR.status == 0) {
-                            RED.notify(node._("common.notification.error", {message: node._("common.notification.errors.no-response")}),"error");
+                            RED.notify(label + " no response", "error");
                         } else {
-                            RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.unexpected",{status:err.status,message:err.response})}),"error");
+                            RED.notify(label + " unexpected error", "error");
                         }
                     }
                 });

comments