Public/Private Variables and Methods

  • Private variables are declared with the 'var' keyword inside the object, and can only be accessed by private functions and privileged methods.
  • Private functions are declared inline inside the object's constructor (or alternatively may be defined via var functionName=function(){...}) and may only be called by privileged methods (including the object's constructor).
  • Privileged methods are declared with this.methodName=function(){...} and may invoked by code external to the object.
  • Public properties are declared with this.variableName and may be read/written from outside the object.
  • Public methods are defined by Classname.prototype.methodName = function(){...} and may be called from outside the object.
  • Prototype properties are defined by Classname.prototype.propertyName = someValue
  • Static properties are defined by Classname.propertyName = someValue

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.

JSB.helper.getDomain();

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");

Private methods

id(el)

This method return the element using javaScript getElementById() method.

setCookie(name,value,days)

Store informaiton in a cookie on user machine.

getCookie(name)

Get value of cookie by using its name from user machine.

removeCookie(name)

Remove or delete cookie from user machine by its name.