var app = {
    initialize: function() {
      this.bindEvents();
    },

    bindEvents: function() {
      document.getElementById('panicbtn').addEventListener('click', this.panic, false);
    },

    setFailureText: function (e) { document.getElementById('panicmsg').innerHTML = 'Panic Failed:' + e; },

    sendSms: function(position) {
      var number = "+441982421043";
      var message = "{'event': 'panic','long': '" + position.coords.longitude + "', 'lat': '" + position.coords.latitude + "'}";
      var options = {
        replaceLineBreaks: false, // true to replace \n by a new line, false by default
        android: {
          intent: '' // send SMS without open any other app
        }
      };
      var success = function () { document.getElementById('panicmsg').innerHTML = 'Panic sent successfully'; };
      sms.send(number, message, options, success, setFailureText);
    },

    panic: function() {
      navigator.geolocation.getCurrentPosition(sendSms, setFailureText);
      document.getElementById('panicmsg').setAttribute('style', 'display');
    }
};

app.initialize();

@@ -62,25 +62,24 @@
 s();%0A    %7D,%0A
-%0A
     bindEven
@@ -186,25 +186,24 @@
 se);%0A    %7D,%0A
-%0A
     setFailu
@@ -301,20 +301,50 @@
  %7D,%0A
-%0A
    
+ panic: function() %7B%0A%0A      var
  sendSms
 : fu
@@ -339,17 +339,18 @@
  sendSms
-:
+ =
  functio
@@ -365,24 +365,26 @@
 on) %7B%0A      
+  
 var number =
@@ -401,16 +401,18 @@
 21043%22;%0A
+  
       va
@@ -534,24 +534,26 @@
 %22'%7D%22;%0A      
+  
 var options 
@@ -552,24 +552,26 @@
 options = %7B%0A
+  
         repl
@@ -654,16 +654,18 @@
         
+  
 android:
@@ -667,16 +667,18 @@
 roid: %7B%0A
+  
         
@@ -737,18 +737,22 @@
         
-%7D%0A
+  %7D%0A  
       %7D;
@@ -754,24 +754,26 @@
    %7D;%0A      
+  
 var success 
@@ -872,16 +872,18 @@
 ;%0A      
+  
 sms.send
@@ -943,36 +943,14 @@
     
-%7D,
+  %7D;
 %0A%0A
-    panic: function() %7B%0A
     
@@ -1000,16 +1000,63 @@
 sendSms,
+%0A                                              
  setFail
@@ -1061,24 +1061,25 @@
 ilureText);%0A
+%0A
       docume

Revert "AJ: refactored"