Browse code

Add a configuration option to reset transfer and resend everything

Natasha Kerensikova authored on15/04/2016 22:37:41
Showing2 changed files
... ...
@@ -46,6 +46,10 @@
46 46
        options.bundleMax = "1";
47 47
     }
48 48
 
49
+    if (document.getElementById("resendEverything").checked) {
50
+       options.resend = true;
51
+    }
52
+
49 53
     console.log("returning " + JSON.stringify(options));
50 54
     document.location = return_to + encodeURIComponent(JSON.stringify(options));
51 55
   }
... ...
@@ -68,6 +72,10 @@
68 72
       <label class="item">
69 73
         <input type="text" class="item-input" name="url" id="url" placeholder="http://example.com/post/path">
70 74
       </label>
75
+      <label class="item">
76
+        Restart sending everthing
77
+        <input type="checkbox" class="item-toggle" name="resendEverything" id="resendEverything">
78
+      </label>
71 79
     </div>
72 80
   </div>
73 81
 
... ...
@@ -146,11 +146,21 @@ Pebble.addEventListener("webviewclosed", function(e) {
146 146
       if (!(cfg_bundle_max >= 1)) cfg_bundle_max = 1;
147 147
       localStorage.setItem("cfgBundleMax", cfg_bundle_max);
148 148
    }
149
+
149 150
    if (configData.bundleSeparator) {
150 151
       cfg_bundle_separator = decodeURIComponent(configData.bundleSeparator);
151 152
       localStorage.setItem("cfgBundleSeparator", cfg_bundle_separator);
152 153
    }
153 154
 
155
+   if (configData.resend) {
156
+      senders[0].abort();
157
+      senders[1].abort();
158
+      localStorage.setItem("toSend", "");
159
+      localStorage.setItem("lastSent", "0");
160
+      to_send = [];
161
+      wasConfigured = false;
162
+   }
163
+
154 164
    if (!wasConfigured && cfg_endpoint && cfg_data_field) {
155 165
       Pebble.sendAppMessage({ "lastSent": 0 });
156 166
    }