How to deploy Favorites in localStorage?

1

I'm implementing a notification tracking project. On the page where you list notifications, there's a star on each notification to add it to bookmarks, which is stored in localStorage . However, I'm not able to program jQuery to receive class status and store. Follow the code below.

index.html

<script type="text/javascript">

                 contador = localStorage.getItem("contador");

                 for(j=0;j<contador;j++)  
                 {    
                     d = localStorage.getItem("ntime-"+j);
                     data = $.datepicker.formatDate('dd/mm/yy', new Date(d));

                     document.write('<div class="list-group-item unread">'
                      +'<div class="list-left">'
                        +'<label class="ckbox">'
                        +  '<input type="checkbox" id="checkbox"><span></span>'
                        +  '<input type="hidden" class="nid" value="'+localStorage.getItem("nid-"+j)+'">'
                        +'</label>'
                        +'<span class="markstar"><i class="glyphicon glyphicon-star"></i></span>'                
                      +'</div>'
                      +'<div class="media">'                                    
                        +'<div class="media-body">'
                          +'<span class="pull-right">'+data+'</span>'
                          +'<h5 class="media-heading">Portal NetSorte</h5>'
                          +'<h5>'+localStorage.getItem("ntitulo-"+j)+'</h5>'
                        +'</div>'
                        +'<p>'+localStorage.getItem("nmensagem-"+j)+'</p>'
                      +'</div>'
                    +'</div>');

app.js

$('.markstar').on('click', function()
    {         
        var elem = $('span').hasClass('starred');

        if(elem)
        {
            alert("Possui starred");
        }
        else
        {
            alert("Não");
        }
 });
    
asked by anonymous 07.01.2016 / 22:50

0 answers