java.lang.Object | |
↳ | net.pierrox.lightning_launcher.script.api.Script |
This object is used to access script properties such as text, tag and menu attributes. Warning: this API is currently experimental.
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
|
Retrieve the script's unique identifier.
Retrieve the script's name.
Retrieve the path of the script. Default is "/".
Retrieve the data associated to the currently executing script.
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.
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:
And then use it this way:
function doSomething() {
alert("hello");
...
}
eval(LL.getScript("some_script"));
doSomething();
Check for the presence of a given flag
flag | one of FLAG_* |
---|
Run this script
screen | screen in which to execute the script |
---|---|
data | optional data to send to the script. Use JSON to pass more than a string. |
Set a flag
flag | one of FLAG_* |
---|---|
on | whether to set or clear the flag |
Change the script's name
name | new name |
---|
Set the path of this script. This is useful to group scripts by owner and/or category.
path | use "/" as separator |
---|
Set a custom and persistent data for this container.
Using a null id is the same as using setTag(String)
without the id argument.
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.
tag | data to store. Use JSON to pass more than a string. |
---|
Have fun with this, but not too much !!!