Wallogit.com
2017 © Pedro Peláez
Core Javascript Library for URI CURD.
Core Javascript Library for Powerful URL level Operations ADD|UPDATE|DELETE and much more..., (*1)
One library to perform most of the URI operations. Such as,, (*3)
| Action | Method | Description |
|---|---|---|
| Add | URI.addNew(key, val) | To add new param to URL. |
| Bulk Add | URI.add([{key1 : val1},{key2: val2}]) | To add multiple params to URL. |
| Append | URI.append(key, val) | To add new item to the existing value. |
| Update Value | URI.add([{key: val}]) | To perform update with add function. |
| Delete | URI.remove(key) | To remove param from URL. |
| Bulk Delete | URI.remove([key1, key2]) | To remove multiple param from URL. |
| Delete All | URI.removeAll() | To remove all param in the URL. |
| Clear | URI.clear() | TO clear the URL history. |
| Update | URI.update() | To update URI status. |
| Get | URI.get(key) | To get value of a param. |
Include the URI library to project by using,, (*4)
<script src="uri_helper.min.js"></script>
For ES6:, (*5)
<script src="uri_helper_es6.min.js"></script> <script> let URI = new _URI(); </script>
### getAll(), (*6)
To get list of URI params as Object., (*7)
URI.getAll(); // URL : http://domain.com/?type=my-ticket&page=1&limit=5 // Output : ["type=myTicket", "page=1", "limit=5"]
To get value of the param from URI., (*8)
URI.get('type'); // URI : http://domain.com/?type=myTicket&page=2&limit=5 // OUT : 'myTicket' ``` ### addNew() To add single param to the URI. If item already exists, then value get updated. ```javascript URI.add('page', 1); // Before URL : http://domain.com/?type=my-ticket // After URL : http://domain.com/?type=my-ticket&page=1
To add list of params to the URI. If item already exists, then value get updated., (*9)
URI.add([{'page': 1}, {'limit': 5}]); // Before URL : http://domain.com/?type=my-ticket // After URL : http://domain.com/?type=my-ticket&page=1&limit=5
To append value to the param in the URI., (*10)
URI.append(name, bala); // Before URL : http://domain.com/?name=shankar // After URL : http://domain.com/?name=shankar,bala
To remove list of param from the URI., (*11)
URI.remove(['page','limit']); // For Bulk. URI.remove('type'); // For Single. URI.remove('id','55') // For Single Value. // Before URL : http://domain.com/?type=my-ticket&page=1&limit=5 // After URL : http://domain.com/? // For Single Value: // Before URL : http://domain.com/?id=45,23,55,34 // After URL : http://domain.com/?id=45,23,34
To remove all param in the URI., (*12)
URI.removeAll(); // Before URI : http://domain.com/?type=my-ticket&page=2&limit=5 // After URI : http://domain.com/?
To go back to previous page by update the URI., (*13)
URI.prevPage(); // Before URL : http://domain.com/?type=my-ticket&page=2&limit=5 // After URL : http://domain.com/?type=my-ticket&page=1&limit=5
To move to next page by update the URI., (*14)
URI.nextPage(); // Before URL : http://domain.com/?type=my-ticket&page=1&limit=5 // After URL : http://domain.com/?type=my-ticket&page=2&limit=5
To check the param is exist in URI or Not., (*15)
URI.isParamExists('page'); URI.isParamExists('newPage'); // URL : http://domain.com/?type=my-ticket&page=2&limit=5 // OUT 1 : true // OUT 2 : false
MIT License, (*16)