public class

Script

extends Object
java.lang.Object
   ↳ net.pierrox.lightning_launcher.script.api.Script

Class Overview

This object is used to access script properties such as text, tag and menu attributes. Warning: this API is currently experimental.

Summary

Fields
public static final int FLAG_ALL
public static final int FLAG_APP_MENU
public static final int FLAG_CUSTOM_MENU
public static final int FLAG_DISABLED
public static final int FLAG_ITEM_MENU
Public Methods
int getId()
Retrieve the script's unique identifier.
String getName()
Retrieve the script's name.
String getPath()
Retrieve the path of the script.
String getTag()
Retrieve the data associated to the currently executing script.
String getTag(String id)
Returns the value associated with this container.
String getText()
Retrieve the script's text.
boolean hasFlag(int flag)
Check for the presence of a given flag
void run(Screen screen, String data)
Run this script
void setFlag(int flag, boolean on)
Set a flag
void setName(String name)
Change the script's name
void setPath(String path)
Set the path of this script.
void setTag(String id, String value)
Set a custom and persistent data for this container.
void setTag(String tag)
Set a persistent tag data for the currently executing script.
void setText(String text)
Have fun with this, but not too much !!!
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final int FLAG_ALL

public static final int FLAG_APP_MENU

public static final int FLAG_CUSTOM_MENU

public static final int FLAG_DISABLED

public static final int FLAG_ITEM_MENU

Public Methods

public int getId ()

Retrieve the script's unique identifier.

public String getName ()

Retrieve the script's name.

public String getPath ()

Retrieve the path of the script. Default is "/".

public String getTag ()

Retrieve the data associated to the currently executing script.

public String getTag (String id)

Returns the value associated with this container. Can be undefined if it has never been set. Using a null id is the same as using getTag() without argument.

See Also

public String getText ()

Retrieve the script's text. Experimental: it is possible to structure a script library using eval(some_script.getText()), at the expense of execution speed. Also the "evaled" script cannot include any direct suspension (alert or similar). Use a function to encapsulate code:

     function doSomething() {
         alert("hello");
         ...
     }
 
And then use it this way:
     eval(LL.getScript("some_script"));
     doSomething();
 

public boolean hasFlag (int flag)

Check for the presence of a given flag

Parameters
flag one of FLAG_*
Returns
  • true if the flag is set

public void run (Screen screen, String data)

Run this script

Parameters
screen screen in which to execute the script
data optional data to send to the script. Use JSON to pass more than a string.

public void setFlag (int flag, boolean on)

Set a flag

Parameters
flag one of FLAG_*
on whether to set or clear the flag

public void setName (String name)

Change the script's name

Parameters
name new name

public void setPath (String path)

Set the path of this script. This is useful to group scripts by owner and/or category.

Parameters
path use "/" as separator

public void setTag (String id, String value)

Set a custom and persistent data for this container. Using a null id is the same as using setTag(String) without the id argument.

public void setTag (String tag)

Set a persistent tag data for the currently executing script. This value will be saved and can be retrieved later using getTag(), including after an application restart.

Parameters
tag data to store. Use JSON to pass more than a string.

public void setText (String text)

Have fun with this, but not too much !!!