GithubHelp home page GithubHelp logo

jeremydurham / persist-js Goto Github PK

View Code? Open in Web Editor NEW
397.0 397.0 70.0 155 KB

PersistJS is a JavaScript client-side persistent storage library

Home Page: http://pablotron.org/software/persist-js/

License: MIT License

Shell 0.47% JavaScript 92.69% AngelScript 1.63% HTML 5.20%

persist-js's People

Contributors

gabehamilton avatar jeremydurham avatar johanneswuerbach avatar mashpie avatar mayanks avatar mjpizz avatar philzen avatar rlittlefield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

persist-js's Issues

remove item raises: Object [object Object] has no method 'getItem'

Please patch the remove call in localStorage:

      // get value
      val = this.store.getItem(key);

local storage remove should read

    remove: function(key, fn, scope) {
      var val;

      // expand key
      key = this.key(key);

      // get value
      val = this.store.getItem(key);

      // delete value
      this.store.removeItem(key);

      if (fn){
          fn.call(scope || this, (val !== null), val);
      }
    } 

instead of

    remove: function(key, fn, scope) {
      var val;

      // expand key
      key = this.key(key);

      // get value
      val = this.getItem(key);

      // delete value
      this.store.removeItem(key);

      if (fn){
          fn.call(scope || this, (val !== null), val);
      }
    } 

Register a Bower package

The title says it all. I would like to pull this into a project I am working on but didn't want to fork and register a Bower package on my fork.

Urgent

Hi,

I am thinking of implementing offline feature based on user. For example. if user 1 is logged in when internet connection is on and logged off when the internet connection is off. Meanwhile, want to store the data accessed by the user 1. Like that, i want to do the same for User 2.

I want to maintain the data for al teast a day. But, it should work based on the user.

I am planning the user id and password in local when the user logged in.

I am not sure, whether persistant.js will support this kind of feature.

Kindly let me know your thoughts on this.

Thanks
Rajesh khanna

firefox prevented the outdated plugin adobe flash from using in your website

i am using persist.min.all js in my website for local storage although there is no flash content on my website but Firefox is giving error "Firefox has prevented the outdated plugin from running in your website " its because persist min all check for the shock-wave version .
Does this have impact on my website JavaScript if someone has explicitly blocked the flash content from their browser .as still the code runs the flash check in persist min all

Accessing the data store

Hi,

Is there any way to retrieve the key:value pairs from the store in a batch format? JSON perhaps? I was hoping for a way to loop through and build a query string based on what's been saved.

Thanks.

User for...in instead of for loop in iterate function

I think it would be common to use store.remove inside store.iterate. If a for..in loop was used we could iterate and remove/delete keys.

Edit:
The issue is that currently a for loop is used, and as the number of keys changes (ie during a remove) so does the referenced length value, which means we won't be iterating through the entire collection. A for...in loop will iterate over all items in the collection even after a delete since it doesn't depend on the length of the collection.

Order by which back ends are used?

What is the order in which PersistJS tries to save the data? Is it:

flash: Flash 8 persistent storage.
gears: Google Gears-based persistent storage.
localstorage: HTML5 draft storage.
whatwg_db: HTML5 draft database storage.
globalstorage: HTML5 draft storage (old spec).
ie: Internet Explorer userdata behaviors.
cookie: Cookie-based persistent storage.

Can we somehow influence this order?

remove function faulty

The line at around 798 in the Remove function with the code "val = this.store[key];" should read "val = this.store.getItem[key];"

How can I use persist-js on react

Hello I'm trying to use persist-js on my React preject but I'm getting this error:
Line 6: 'Persist' is not defined no-undef
Search for the keywords to learn more about each error.

The problem is that I don't know how to import the lib correctly
I have tried this:
import 'persist-js' and
import Persist from 'persist-js'
With no luck.

Some workaround?

IE6 flash raises 'object not supported' error

I was trying the examples and when i try to run test_flash, it does not work in IE6. I have flash version 10. The type is shown as flash but when i try to save, it gives me the object is not supported error.
I cant use the userData behaviour as i have pages in multiple directories.

remove of an item returns this.getitem is not a function

I want to update the value of an item, I am not finding it possible to do this so I decided to remove it and write it again, in looking at that I got the following error

which returns
TypeError: this.getItem is not a function
...key,fn,scope){var val;key=this.key(key);val=this.getItem(key);this.store.removeI...
I narrowed down and found I just couldn't remove the item.

It is the correct data store and item I referring to.

I can provoke this with something as simple as

var store = new Persist.Store('external_img_store');
store.remove("urls");

however If I do
store.get('urls', function (ok, val) {
var currenturl_list;
if (ok) {
currenturl_list = val.split(",");
console.log(currenturl_list);
}
});

I see all the urls I have stored in there.

Any ideas?

CDN

Can you add this to a cdn like cndjs?

#<HTMLObjectElement> has no method 'get'

var store = new Persist.Store('store', {
            swf_path: this.options.rootPath + 'assets/js/persist.swf'
        })
    store.save('h', 'heldadasdasdlo');
    console.log(store.get('h'));

Currently when I run the script I receive this error from the console.log output: (Chrome):
Uncaught TypeError: Object # has no method 'get'
(Firefox):
this.el.get is not a function
...key,val);return old_val;},remove:function(key){var val;key=esc(key);val=this.el....

Both are on line 138. I am using the latest version of persist and have tried everything on my end and still no go.

Thanks,
Daniel

Search order wrong - cookies used before IE's userdata

Firstly, great code bud, really got me out of a hole with too many cookies being set on the client:

Bug: The "search_order" methods place cookies before IE - meaning that cookies get implemented on IE rather than userdata. Just need to be swapped around.

Suggestion: Chopping up values to fit Persist.size

A suggestion is to handle the various size limitations in the library, by chopping up stored data into slices that fits into the current size limitation. This would effectively make the interface size-agnostic to use, with performance declining by large-sized values on small-sized storage methods.

I cannot currently contribute with this code myself, but I wanted to get it out there for this library. If you don't see it as a fit, I wanted to encourage someone writing a few code lines as a wrapper to this library which adds this functionality.

Add .md extension

Add .md extension to README and TODO to make GitHub render them with some style.

Library not working in Firefox and Chrome if COOKIE is disabled.

I'm using your persist.js (Version : 0.2.0) library as it handles the fall back mechanism in the background. It works fine if i have the cookies turned on, but not otherwise.

Do you have any thoughts on this issue ?

In firefox with the cookie turned OFF, I get Security error" code: "1000 , if i use http://localhost:xxxx and I dont see any error if i use 127.0.0.1 instead of localhost but still no data gets collected.

Thanks
Jay

Persist.type localStorage no longer persists across windows / tabs

I have an application where the user uses a bookmarklet to save images to their localStorage on our site - (user clicks save images - goes to our site with encoded url list of images to save) We save those images into a persist store, the type being used is localStorage.
(the site needs login to see it so I won't provide a link - right now anyway this is me doing stuff on localhost)

anyway if I have an url /images/external?list=encodedlistofurls
addtopersist = function(store_name){
try {
var store = new Persist.Store(store_name);
console.log("type = " + Persist.type);
//Persist.remove('cookie');
store.set('urls', currenturl_list);
store.save();
} catch (e) {
console.log(e);
}
}
addtopersist("external_img_store");

If I go to /images/external the Persist store is queried for the external_img_store, if I go to /images/external in the same tab I was just in where I loaded the image urls it works and I get all the urls back, if I open up a new window and go to /images/external if I go to my site and then navigate to /images/external I don't get the urls either.

It used to be that it worked that I could just paste in /images/external and see the images I had saved recently, or I could navigate there, but no longer (this if Firefox 46.0 right now but others have reported it in other browsers) , is anyone familiar with anything that could be changed with localStorage across that would cause this to not work anymore ?

Use of localStorage over sessionStorage

It seems like persist-js doesn't allow you to use sessionStorage. Is persist-js safe (at least as safe as js-accessible cookies) for a client-side session?

Persist.js breaking in Firefox local mode -> patch

Problem:
If FireFox is reading the website HTML, JS, etc. from file://, and you use persist.js to do your storage, It will be discarded upon browsing to a new site.

Solution and Explanation:
In more detail here: http://blog.ideaday.de/max/2011/10/persist-js-does-not-work-with-firefox-offline/

//detect FireFox. If it's the Fox, AND running locally remove localstorage
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent) && window.location.protocol == 'file:'){
    Persist.remove('localstorage');
}

Hope this gets patched in :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.