Skip to content
Javascript configuration library to handle an application's configuration. Stores config to localstorage.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
jasmine
LICENSE
README.md
component.json
configurator.js
index.html
tests.js

README.md

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.

You can’t perform that action at this time.