Skip to content
Aaron Franco - Clickslide CTO edited this page Jul 31, 2014 · 1 revision

Global

setHomePageId(id)

Set the homePageId parameter.

Parameters

id: String, id of the homepage

Returns: null

setHomePageId()

Get the homePageId parameter.

Returns: null

setBaseUrl(url, protocol, host)

Set the BaseUrl parameter.

Parameters

url: string, the url as developer/app based on your Datadipity API.

protocol: string, http or https, always https for Datadipity.com

host: string, datadipity.com

Returns: null

getBaseUrl()

Get the BaseUrl.

Returns: string, BaseUrl - The base url variable

setSession()

Set the session ID in local storage.

Returns: string, BaseUrl - The base url variable

getSession()

get the session ID from local storage.

Returns: string, BaseUrl - The base url variable

Register(userName, userEmail, userPassword1, userPassword2, callback)

Registration and Login use similar functionality. New users and possibly returning users will have to authorize API services. Once logged in or registered, if authorization is required, Clickslide will return a "registerApis=true" in its JSON response. The manageAuthRedirect Method in the example handles this behavior. It is altered slightly in Cordova Phonegap.

Parameters

userName: string, Name of user to register

userEmail: string, Email address of the user ro register

userPassword1: string, Email address of the user to register

userPassword2: string, Verify the user password

callback: asyncCallback, a custom function to override the onRegister method. This method will take a data object as an argument.

Returns: null

onRegister(data, nml)

Default callback for the Register method.. This function does nothing at the moment except log the data returned. You should override this in your app by sending a function to the Register function.

Parameters

data: object, This is the JSON object coming from the server.

nml: object, This is the NML object used to maintain scope.

Returns: null

Logout(sessid, callback)

Logout an App user or developer to their Clickslide account.

Parameters

sessid: string, Session ID

callback: asyncCallback, a custom function to override the onLogin method. This method will take a data object as an argument.

Returns: null

Login(userEmail, userPassword, callback)

Login an App user or developer to their Clickslide account.

Parameters

userEmail: string, Email address of the user to login

userPassword: string, To be used once to connect for a session DO NOT STORE THIS

callback: asyncCallback, a custom function to override the onLogin method. This method will take a data object as an argument.

Returns: null

onLogin(data)

Default callback for the Login method.. This function sets the user session for this NML object. You can override this but we suggest calling NML.onLogin(data) in the first line of your custom callback to make sure the NML object maintains its session data properly.

Parameters

data: object, This is the JSON object coming from the server.

Returns: null

add(action, pageType, callback)

POST data to Datadipity.com to create a new resource or trigger the "add" event for API communication. TODO: Add the ability to upload files.

Parameters

action: string, This is an NML String representing the resource to add. This resource will be parsed and will trigger the API events on the server side. ...

pageType: string, A NML page type in lowercase and plural: basicpages, listpages, etc. It depends on the type of page you are posting to the ListPage and which type of page it accepts.

callback: asyncCallback, A custom callback function to override the default. This takes an NML object as an argument.

Returns: null

update(action, pageType, callback)

Update an NML resource on the Datadipity server

Parameters

action: string, This is an NML String representing the resource to add. This resource will be parsed and will trigger the API events on the server side. ...

pageType: string, A NML page type in lowercase and plural: basicpages, listpages, etc. It depends on the type of page you are posting to the ListPage and which type of page it accepts.

callback: asyncCallback, A custom callback function to override the default. This takes an NML object as an argument.

Returns: null

remove(pageType, pageId)

Remove a resource from the Datadipity server using basic pages as an example it would look similar to https://datadipity.com/developerurl/apiurl/pageType/pageId.xml?_method=delete

Parameters

pageType: string, the type of page eg: basicpages, listpages, linkpages, etc.

pageId: string, Required to execute a delete on a resource

Returns: null

get(callback, withUpdate, postparams, pageType, pageId, pageUrl)

A simple method to get a single NML object or a collection of objects. Urls for requests are formed as NML.AppUrl/pageUrl.json or NML.AppUrl/pageTypespageId.json. This uses JSON by default. This has an XML endpoint but is not implemented in JavaScript.

Parameters

callback: asyncCallback, A function to override the default event listener.

withUpdate: boolean, Adds ?update to force the API data provider to refresh

postparams: array, Adds ?postparam[key]=val from [{name:key, value:val}] for every Object in the array

pageType: string, basicpages, listpages, linkpages, etc.

pageId: string, The ID parameter from the @attributes.id element

pageUrl: string, This will override using pageType/pageId

Returns: null

failedRequest(xhr, status, err)

Logs any Ajax failures to the console

Parameters

xhr: object, The full Ajax request object

status: string, The Error message

err: object, The full Error object

Returns: null

processPageData(data)

This sets the search boolean and the homepage ID

Parameters

data: object, This sets the search boolean and the homepage ID

Returns: null

loadDialogs(null)

Loads the login-register-auth template and the loading-progress templates into the appropriate DIVs. You may override this method by not calling it in your app. Login form uses nml.handleLoginFormSubmit for its callback and Register uses _nml.handleRegisterFormSubmit for its callback. Be sure to register a data handling fuction with nml.onGetData before calling this method.

Parameters

null: Loads the login-register-auth template and the loading-progress templates into the appropriate DIVs. You may override this method by not calling it in your app. Login form uses nml.handleLoginFormSubmit for its callback and Register uses _nml.handleRegisterFormSubmit for its callback. Be sure to register a data handling fuction with nml.onGetData before calling this method.

Returns: null

onLoginOrRegister(data, _nml)

This is a generic handler for both login and register. If a Session isn't returned then the user is registered but if it is and APIs require authorization the user is redirected to the Authorize APIs screen which opens in a new Window. The reason for opening in a new window is to enable oAuth 1 and oAuth 2 server handshakes. If APIs don't need auth then it will trigger the first download of data from the server.

Parameters

data: object, This is coming from the server

_nml: object, This is the NML() object

Returns: null

manageAuthRedirect(_nml)

Verify APIs and redirect for Auth if necessary. This method ends by calling _nml.get(_nml.onGetData, true). Be sure to register a callback with onGetData before this gets called otherwise it will lose its scope.

Parameters

_nml: object, This is the NML() object

Returns: null

getParentPage(pageid)

Parameters

pageid: string, the current page id

Returns: Object - the parent page