Browse Source

basic save and reset

pg 4 years ago
parent
commit
0fa68f85bb
4 changed files with 35 additions and 5 deletions
  1. 2
    1
      .gitignore
  2. 30
    3
      assets/clientApp.js
  3. BIN
      views/.index.jade.swp
  4. 3
    1
      views/index.jade

+ 2
- 1
.gitignore View File

@@ -1,5 +1,6 @@
1 1
 node_modules/
2 2
 *.swp
3
-*.swo
3
+.*.swp
4
+.*.swo
4 5
 *~
5 6
 

+ 30
- 3
assets/clientApp.js View File

@@ -28,13 +28,22 @@ $(document).ready(function(){
28 28
 //localStorage.removeItem("url_ressources")
29 29
 
30 30
 var row = function(data){
31
-  var htmlobj = "<div>"+data.title+" |"+ data.url+
31
+  var htmlobj = "<div> <a href='"+data.url+"'>[ "+data.title+" ]</a>"+
32 32
     //" </div>"+ "<div class='presLink'><button value='"+ data.url+"'> launch </button></div>"
33 33
      "<button  class='presLink' value='"+data.url+"' > launch </button></div>"
34 34
   //return "<div><div>"+data.title+"</div> <div>| "+ data.url+" </div>"+ "<button class='.presLink'value='bla'> launch </button></div>"
35 35
    return htmlobj
36 36
 
37 37
   }
38
+var export_json = function(){
39
+  
40
+  var csvData = 'data:application/json;charset=utf-8,' + localStorage.getItem(name);
41
+
42
+  $(this).attr({
43
+  'href': csvData,
44
+  'target': '_blank'
45
+  });
46
+}
38 47
 
39 48
   var browser_ressource = loadObject("url_ressources")
40 49
   console.log()
@@ -61,12 +70,30 @@ var row = function(data){
61 70
         addObject("url_ressources", data)
62 71
         $("#ressources_list").append(row(data))
63 72
         $(".presLink").click(function(){
64
-        $.post('/set', {url:this.value}, function(data) {console.log("hop")})
65
-      })
73
+          $.post('/set', {url:this.value}, function(data) {console.log("hop")})
74
+        })
66 75
       }
67 76
     })
77
+  })
68 78
 
79
+  $("#deleteButton").click(function(){
80
+    console.log("delete")
81
+    localStorage.removeItem("url_ressources")
82
+    $("#ressources_list").html("")
69 83
 
70 84
   })
85
+
86
+  $("#saveButton").click(function(event){
87
+    console.log("save")
88
+   var csvData = 'data:application/json;charset=utf-8,' + localStorage.getItem("url_ressources");
89
+
90
+  $(this).attr({
91
+  'href': csvData,
92
+  'target': '_blank'
93
+  });
94
+
95
+  })
96
+
97
+
71 98
   })
72 99
 

BIN
views/.index.jade.swp View File


+ 3
- 1
views/index.jade View File

@@ -16,6 +16,8 @@ html
16 16
             span.label url
17 17
             input(type="text", name="url",id="urlText")
18 18
             input(type="submit", value="add", id="addUrl")
19
-  
19
+            input(type="submit", value="delete", id="deleteButton")
20
+            a(id="saveButton", href="#") [SAVE]
21
+        p
20 22
     #ressources_list
21 23
       

Loading…
Cancel
Save