This project contains helper functions needed for common operations in Javascript. Two main functions are supported currently: parsing the query parameters of a URL and parsing the cookie values of the document.
If a user browses to your website with query parameters in the URL, e.g. https://www.google.com/?q=test.
To get the value for query parameter 'q', one would do the following:
> var value = jsutilities.getParameter('q');
> value
"test"
To provide a simple API for functionality that should be built into Javascript.
Either include the jsutilties.js file in a script tag. Or embed the source directly into your page.
-
jsutilities.getCookie(String)
:String
This will return the value for the cookie stored under the cookie name passed.
var cookieValue = jsutilities.getCookie('cookieName');
-
jsutilities.getParameter(String)
:String
This will return the value for the query parameter stored under the query parameter name passed.
var queryParameterValue = jsutilities.getParameter('queryParameterName');
-
jsutilities.getStringHashCode(String)
:Int32
This will return the java-style hashCode for the string passed.
var stringData = 'data'; var hashCode = jsutilities.getStringHashCode(stringData);
-
String.prototype.hashCode()
:Int32
This will return the java-style hashCode for the string passed using the getStringHashCode function above. If the function is defined, it does not overwrite.
var stringData = 'data'; var hashCode = stringData.hashCode();
MIT License