Privileged methods/Helper Functions
multiReplace(str, hash)
Replace multiple value in a single string. Return the new string at the end. You can pass regExe also.
var str = "http://localhost.com/mywebsite/?name=NAME&age=AGE&company=COMPANY";
JSB.helper.multiReplace(str, {
"NAME" : "Sam",
"AGE" : "26yrs",
"COMPANY" : "Sapient"
});
Final Output :
http://localhost.com/mywebsite/?name=Sam&age=26yrs&company=Sapient
setCSS(el, styles)
Apply css to any element. Pass the name of element and the CSS in JSON format.
JSB.helper.setCSS("main", {
"width" : "300px",
"background" : "red",
"padding" : "10px"
});
hasClass(el, name)
Check if the given element has given class assign or not.
JSB.helper.hasClass("main", "my_element");
addClass(el, name)
Add class to the given element.
JSB.helper.addClass("main", "my_element2");
removeClass(el, name)
Remove class from the given element.
JSB.helper.removeClass("main", "my_element2");
getDomain()
Return the URI of site. Return protocol, hostname and port if found.
getQueryString(name, default_)
This method will return the query string from the URL of the website.
Copy "?name=RSR&age=26" and paste this at the address bar of the website and press enter.
JSB.helper.getQueryString("name", "Not Found.");
isBlank(string)
This method will check for blank value in the provided string. This will return true if provided string contain blank value and false if not.
var test = " ";
JSB.helper.isBlank(test);
setInfo(name, value)
Store information to client machine using HTML5 localStorate method.
JSB.helper.setInfo("name", "RSR");
getInfo(name, checkCookie)
Get information from client machine. Get information for HTML5 localstorage if available else get information from cookie.
JSB.helper.getInfo("name");
removeInfo(name, checkCookie)
Remove information from client machine.
JSB.helper.removeInfo("name");