var view = require('../../lib/view');
var clone = require('clone');

module.exports = view.extend({
    id: 'profile',
    template: require('./index.html'),
    data: {
        title: 'My Profile'
    },
    methods: {
      clean: function (e) {
        var sh = this.model._fs.Shell();
        var fs = this.model._fs;
        var sync = fs.sync;
          fs.stat('/', function(e, stat) {
          if (!stat.isDirectory()) {
            fs.unlink('/', function(e) {
              sync.request();
            });
          } else {
            sh.rm('/', {
              recursive: true
            }, function(e) {
              console.log(e);
              sync.request();
            });
          }
        });
      }
    },
    created: function () {
        var user = clone(this.model.user);
        this.$data = this.model.user;

        // Default to editing mode if the user have not filled out their profile
        // if (this.$data.name || this.$data.location) {
        //     this.$data.editing = false;
        // } else {
        //     this.$data.editing = true;
        // }

        this.$data.myApps = clone(this.model.apps);

        // this.$data.cancel = function () {
        //     this.$data.name = user.name;
        //     this.$data.location = user.location;
        //     this.$data.editing = false;
        // };

        // this.$data.save = function () {
        //     this.$data.editing = false;
        //     this.model.user.name = this.$data.name;
        //     this.model.user.location = this.$data.location;
        //     this.model.user.avatar = this.$data.avatar;
        //     this.model.save();
        //     this.$data.myApps = clone(this.model.apps);
        // };
    },
    detached: function () {
        // this.model.user.name = this.$data.name;
        // this.model.user.location = this.$data.location;
        // this.model.user.avatar = this.$data.avatar;
    }
});

@@ -190,16 +190,37 @@
 Profile'
+,%0A        back: false
 %0A    %7D,%0A
@@ -230,24 +230,26 @@
  methods: %7B%0A
+  
       clean:
@@ -260,24 +260,28 @@
 ction (e) %7B%0A
+    
         var 
@@ -313,24 +313,28 @@
 ();%0A        
+    
 var fs = thi
@@ -350,24 +350,28 @@
 fs;%0A        
+    
 var sync = f
@@ -388,16 +388,18 @@
         
+ 
+ 
 fs.stat(
@@ -433,16 +433,22 @@
         
+      
 if (!sta
@@ -478,16 +478,24 @@
         
+  
+      
 fs.unlin
@@ -521,32 +521,42 @@
 %7B%0A              
+   
+       
 sync.request();%0A
@@ -559,32 +559,40 @@
 ();%0A            
+        
 %7D);%0A          %7D 
@@ -589,16 +589,22 @@
         
+  
+    
 %7D else %7B
@@ -616,16 +616,24 @@
         
+     
+   
 sh.rm('/
@@ -651,16 +651,26 @@
         
+      
+    
 recursiv
@@ -689,16 +689,24 @@
         
+     
+   
 %7D, funct
@@ -728,16 +728,26 @@
         
+     
+     
 console.
@@ -760,32 +760,42 @@
 ;%0A              
+    
+      
 sync.request();%0A
@@ -798,36 +798,48 @@
 ();%0A            
+   
-%7D);%0A
+     %7D);%0A    
           %7D%0A    
@@ -828,26 +828,32 @@
             
-%7D%0A
+  %7D%0A    
         %7D);%0A
@@ -848,24 +848,26 @@
         %7D);%0A
+  
       %7D%0A    

Remove back button from profile view