Built-in JS functions

utils - utility functions

utils.openUrl()

Open a URL.

// Syntax
utils.openUrl( url: string, options?: { newTab:  boolean = true } )
Parameter
Description

url

Required. A String value that specifies the URL to open. It must start with http:// or https://.

newTab

Optional. Boolean value that, when True, specifies the url is to open in a new tab. The default value is True.

// Example: Open google.com in a new tab.
utils.openUrl("https://www.google.com", { newTab: true })

utils.openApp()

Open an OpenFlower app.

// Syntax
utils.openApp( applicationId: string, options?: { queryParams?: {"key":"value"}, hashParams?: {"key":"value"}, newTab: true } )
Parameter
Description

appId

Required. A String value that specifies the ID of the app to open.

queryParams: {'key1':'value1',key2:'value2',...}

Optional. An Object that specifies query parameters to pass into the app. The query parameters are added to the app URL in the form of ?key1=value1&key2=value2&...

hashParams:{'key1':'value1',key2:'value2',...}

Optional. An Object that specifies hash parameters to pass into the app. The hash parameters are added to the app URL in the form of #key1=value1&key2=value2&...

newTab

Optional. A Boolean value that, when True, specifies the url is to open in a new tab. The default value is True.

utils.downloadFile()

Download a file containing the specified data.

Parameter
Description

data

Required. A String or Object that specifies the data to download from queries, components, transformers, etc.

fileName

Required. A String value that specifies the name of the file to download.

fileType

Optional. A String value that specifies the type of the file to download. All MIME types are supported.

dataType

Optional. A String value that specifies the type of the data: "url" or "base64".

utils.copyToClipboard()

Copy a string to clipboard.

Parameter
Description

text

Required. A String value that specifies the content to copy.

message - global notification

Use message methods to send a global alert notification, which displays at the top of the screen and lasts for 3 seconds by default. Each of the following four methods supports a unique display style.

localStorage

Use localStorage methods to store and manage key-value pair data locally, which is not reset when the app refreshes, and can be accessed in any app within the workspace using localStorage.values.

Method
Description

setItem(key: string, value: any)

Store a key-value pair.

removeItem(key: string)

Delete a key-value pair.

clear()

Clear all data in localStorage.

localStorage.values

You can access any key-value pair in local storage using localStorage.values. in JavaScript queries.

Inspect the data in localStorage in Globals in the data browser.

localStorage.setItem()

Store a key-value pair.

localStorage.removeItem()

Delete a key-value pair.

localStorage.clear()

Clear all data in localStorage.

Responsiveness / Screen information

To enable responsive Layouts, you need to know which device type your app is currently viewed. This helper gives you information about the screen sizes. The values automatically update on Screen size changes.

screenInfo.deviceType

You can use deviceType to get the Type of the Device based on the current screen width of the Lowoder app (or the website where it is embedded). This value automatically updates on Screen size changes.

screenInfo.height

screenInfo.width

screenInfo.isDesktop

screenInfo.isTablet

screenInfo.isMobile

Last updated