Microjs
What is microjs?
Microjs (ujs) is a lightweight utility library written in JavaScript. The aim is to provide minimal but useful utility features. There are also a few extensions to extend existing features.
Features
- Trigger an event on a
DOMElement
- Add/Remove attributes
- Add/Remove styles
- Ajax method for
GET
andPOST
(IE9+) - Some aliases
- [Extension] ArrayList
- [Extension] Dictionary
Examples
Ajax
ujs;
Trigger events
OK
// Gets the buttonvar button = ujs; // Trigger a click eventujs;
ArrayList
class
[Extension] The // Creates a listvar list = ; // Adds an arraylist; // Adds an elementlist; // Removes the element at the fourth positionlist; // Inserts the element 42 at the fourth positionlist; // Starts a loop on all elements.list;
Dictionary
class
[Extension] The // Creates the dictionaryvar dictionary = ; // Adds an element.dictionary; // Creates an array of keys and values.var keys = "animaux" "humains" "reptiles";var values = name: "animal" age: 25 name: "humain" age: 48 name: "reptile" age: 18 ; // Adds them.dictionary; // Removes an element.dictionary; // Clones the collection.var dico2 = dictionary; // Edits the element with the key catdico2foo = "bar";dico2age = 42;dico2name = "Miaou";dico2bar = "foo"; // Merges a collection into another.dico2;
Build the library
Type the following commands to build the library and the documentation:
npm install
npm run build
Licence
MIT Licence, please read the LICENSE
file for more information.