GithubHelp home page GithubHelp logo

captn3m0 / configurator Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 2.0 26 KB

Javascript configuration library to handle an application's configuration. Stores config to localstorage.

Home Page: https://github.com/captn3m0/configurator#setup

License: MIT License

JavaScript 92.46% HTML 1.16% CSS 6.39%

configurator's Introduction

Configurator is a config manager library for Javascript. It uses localStorage to store persistent configurations in the browser.

Setup

Include configurator.js in your html

<script src="configurator.js"></script>

Now, create a config object. The function takes two parameters :

  1. default: Object holding default configuration values
  2. persistent: Array of key strings for persistent configuration.
var config= Configurator({sound:true,autoPlay:false,volume:60},['volume']);

//volume property will persist even after refreshes using localstorage.

//Set additional configuration options

config.set("shuffle",true,true);

.set takes three parameters:

  1. Key Name
  2. Value
  3. Persistent (true/false)
var shuffleState = config.get('shuffle');
//Will get the value of the config option.

Localstorage clearing

Since configurator stores the persistent config information in localstorage, you cannot clear localstorage using localStorage.clear any more. Instead use config.clearLS() function to clear the localStorage. It will clear localstorage, and write the persistent config keys back into localStorage.

License

Licensed under the MIT License. See LICENSE file for details.

Configurator is extracted from SDSLabs Muzi, a music player application for the IIT-Roorkee Campus.

configurator's People

Contributors

captn3m0 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

configurator's Issues

Add tests

Need to write unit tests for configurator.

  • Unit tests
  • Provide fallback for localStorage
  • Write documentation for nested config options

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.