diff --git a/.gitignore b/.gitignore
index a6ec74b..41a6858 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
node_modules/
*.swp
+*.swo
+*~
+
diff --git a/assets/clientApp.js b/assets/clientApp.js
index c83bad3..7a147e9 100644
--- a/assets/clientApp.js
+++ b/assets/clientApp.js
@@ -1,8 +1,33 @@
//var bla = function
-$(document).ready(function(){
- var row = function(data){
+function storeObject(name,obj){
+ console.log("storeObject: ",obj)
+ localStorage.setItem(name,JSON.stringify(obj))
+
+}
+function loadObject(name){
+ return JSON.parse(localStorage.getItem(name))
+}
+
+function addObject(name, obj){
+ var entry = loadObject(name)
+ console.log('add object '+entry)
+ if (entry == null ){
+ entry = new Array()
+ //storeObject(name,)
+ }
+ entry.push(obj)
+ storeObject(name,entry)
+}
+
+$(document).ready(function(){
+
+
+// DELETE STORAGE
+//localStorage.removeItem("url_ressources")
+
+var row = function(data){
var htmlobj = "
"+data.title+" |"+ data.url+
//"
"+ ""
""
@@ -11,6 +36,20 @@ $(document).ready(function(){
}
+ var browser_ressource = loadObject("url_ressources")
+ console.log()
+ if (browser_ressource != null && browser_ressource.forEach != null){
+ browser_ressource.forEach(function (o,i,l){
+ if (o.url){
+ $("#ressources_list").append(row(o))
+ $(".presLink").click(function(){
+ $.post('/set', {url:this.value}, function(data) {console.log("hop")})
+ })
+ }
+
+ })
+ }
+
$("#addUrl").click(function(){
console.log("Hey")
@@ -19,9 +58,10 @@ $(document).ready(function(){
console.log(data)
if (data.url){
//$("#ressources_list").append("")
+ addObject("url_ressources", data)
$("#ressources_list").append(row(data))
$(".presLink").click(function(){
- console.log(this.value)
+ $.post('/set', {url:this.value}, function(data) {console.log("hop")})
})
}
})
diff --git a/main.js b/main.js
index 1f11f0e..730843e 100644
--- a/main.js
+++ b/main.js
@@ -47,6 +47,14 @@ webapp.use(bodyParser.urlencoded({ // to support URL-encoded bodies
webapp.get('/', function (req, res) {
res.render('index', {ressources:[]});
});
+webapp.post('/set', function (req, res) {
+ var candidate = req.body.url
+ if( validUrl.isUri(candidate) )
+ refresh.emit('event',candidate)
+ res.send({ressources:[]});
+});
+
+
webapp.post("/", function(req,res){
console.log("/new")