Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

local storage vs Web SQL

I am working on a project, that is a mobile web app. I am using JQuery mobile.

I have a page with a jquery listview, when a user clicks on each item on the list view all data associated with that item is passed to a dialog page. I used local storage to pass the values between pages. However what I am trying to do is record a user's action and display them as an activity feed. Storing what item they clicked on, how long they spent on the opened dialog page and to be able to display all this info on a new page. example

You clicked on item a

You spent 15seconds on item b

etc.

So would local storage be good for this or or WEB SQL?

I also noticed that the WeB SQL is not actively maintained anymore? http://www.w3.org/TR/webdatabase/ does this mean it's going to be deprecated?

Local Storage example:

each item is a json object, I need to pass entire object to view it in a new page so I have:

function addPostToLocalStorage(YTfeeditems){
    $(".item").on('click', function () {
        
        var i = $('.item').index(this);
        console.log(i);
        
        var Viditem = YTfeeditems[i];
        console.log(Viditem);

        localStorage['youtubeclickedPost'] = JSON.stringify(Viditem);
        storedItem = localStorage['youtubeclickedPost'];
        retrievPostFromLocalStorage();
    }
});

function retrievPostFromLocalStorage(){
    var retrievedStringItem = localStorage.getItem(['youtubeclickedPost']);
    var convertedPost = JSON.parse(retrievedStringItem);
    showDetailedPost(convertedPost);
}

when item is clicked I would want to store the the id of the video, record the time it was clicked, record how long the ytfullviewpage was open for and also within that page record if the "thumbs up" image was clicked or if "thumbs down" was clicked, add these details to local ftorage and retrieve them in a new page to show them. I can seem to understand the approach to take with local storage in doing this. I have Pasted my javascript for this here

which might give you a better idea.

like image 953
Dot Avatar asked Mar 24 '23 03:03

Dot


1 Answers

WEB SQL is deprecated however still available on some platforms http://caniuse.com/#feat=sql-storage localstorage we probable be fine for you solution. If you feel you need more storage use http://pouchdb.com/ as it has cross adapters for different browser storages and some nice features like syncing.

like image 162
timmak Avatar answered Mar 25 '23 18:03

timmak