Code Monkey home page Code Monkey logo

datasaver's Introduction

DataSaver

ABOUT

The jQuery plugin allows you to save data from form fields in the web storage.

This saves users from a situation when they lost all data entered into the form. This can happen due to a crash browser, disconnection, reload the page, etc.

Browser Support

Plugin is supported in Internet Explorer 8+, Firefox 3.5+, Opera 10.5+, Chrome 4.0+, and Safari 4.0+.

USAGE

DataSaver plugin uses the jQuery JavaScript library, only. So, include just these two javascript files in your header.

<script src="js/jquery.js"></script>
<script src="js/jquery.DataSaver.js"></script>

Select elements whose data you want to save.

<textarea class="saveme"> </textarea>

After it, call the jQuery DataSaver plugin.

$('.saveme').DataSaver();

Options:

You can pass an options object in plugin init method.

  • timeout : Automatic save interval data (in milliseconds). If zero, it is not used (Default: 0);
  • events : List of events that cause data save. If undefined or '', it is not used (Default: change).
$('.saveme').DataSaver({timeout: 1000, events: "change keyup"});

Methods:

You can call some methods. Just pass their name.

  • save : Save the data in web storage;
  • load : Load the data from web storage;
  • remove : Remove the data from web storage;
  • stop : Stop the DataSaver.
$('.saveme').DataSaver('remove');

Events:

You can listen DataSaver events.

  • DataSaver_start
  • DataSaver_stop
  • DataSaver_save
  • DataSaver_load
  • DataSaver_remove

You can also get localStorage key (DataSaver_key) and value:

$(document).on("DataSaver_save DataSaver_load DataSaver_remove", function(e) {
    console.log(e.type);
    console.log(e.target.DataSaver_key + " : " + localStorage[e.target.DataSaver_key]);
    console.log("");
});

EXAMPLE

View example

datasaver's People

Contributors

absentik avatar

Watchers

Mizno Kruge avatar

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.