public class zUtl
extends java.lang.Object
For more utilities, refer to Utl
.
Modifier and Type | Field and Description |
---|---|
static String |
cellps0
A shortcut of
' cellpadding="0" cellspacing="0" border="0"' . |
static String |
i0
A shortcut of
'<i style="height:0;width:0"/>' . |
static String |
img0
A shortcut of
'<img style="height:0;width:0"/>' . |
Modifier and Type | Method and Description |
---|---|
static void |
appendAttr(String nm,
java.lang.Object val)
Appends an attribute.
|
static void |
appendAttr(String nm,
java.lang.Object val,
boolean force)
Appends an attribute.
|
static void |
convertDataURLtoBlob()
Converts the dataURL to Blob object.
|
static Function |
debounce(Function func,
int wait,
boolean immediate)
Creates and returns a new debounced version of the passed function
which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked.
|
static String |
decodeXML(String txt)
Decodes the XML string into a normal string.
|
static void |
destroyProgressbox(String id)
Removes the message box created by
progressbox(_global_.String, _global_.String, boolean, _global_.String) . |
static String |
encodeXML(String txt,
Map opts)
Encodes the string to a valid XML string.
|
static String |
encodeXMLAttribute(String txt)
Encodes the string to a valid XML attribute string.
|
static void |
fireShown(Widget wgt,
int bfsz)
Fires beforeSize, onShow, onFitSize, onSize and afterSize
|
static void |
fireSized(Widget wgt,
int bfsz)
Fires beforeSize, onFitSize, onSize and afterSize
|
static Array |
frames(Window w)
Returns all descendant frames of the given window.
|
static double |
getDevicePixelRatio()
Returns the ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device.
|
static Promise |
getUserMedia(String constraints)
Returns the Promise whose fulfillment handler receives a MediaStream object when the requested media has successfully been obtained.
|
static void |
getWeekOfYear()
Get week numbers of year for a specific date
|
static void |
go(String url,
Map opts)
Navigates to the specified URL.
|
static String |
intsToString(int[] ary)
Converts an integer array to a string (separated by comma).
|
static boolean |
isAncestor(java.lang.Object p,
java.lang.Object c)
Returns if one is ancestor of the other.
|
static boolean |
isChar(char cc,
Map opts)
Returns whether the character is according to its opts.
|
static void |
isImageLoading()
Checks whether all the loading images are finish.
|
static void |
loadImage(String url)
Loads an image before ZK client engine to calculate the widget's layout.
|
static String |
mapToString(Map map,
String assign,
String separator)
Converts a map to a string
|
static long |
now()
Deprecated.
As of release 5.0.6, replaced with jq.now().
|
static Map |
parseMap(String text,
String separator,
String quote)
Parses the specifie text into a map.
|
static void |
progressbox(String id,
String msg,
boolean mask,
String icon)
Creates a message box to indicate something is being processed
|
static int[] |
stringToInts(String text,
int defaultValue)
Converts a string separated by comma to an array of integers.
|
static Function |
throttle(Function func,
int wait)
Creates and returns a new, throttled version of the passed function, that,
when invoked repeatedly, will only actually call the original function at most once per every wait milliseconds.
|
static Date |
today(boolean full)
Returns today.
|
static Date |
today(String fmt)
Returns today.
|
public static String cellps0
' cellpadding="0" cellspacing="0" border="0"'
.public static String img0
'<img style="height:0;width:0"/>'
.public static String i0
'<i style="height:0;width:0"/>'
.public static boolean isChar(char cc, Map opts)
cc
- the characteropts
- the options.
Name | Allowed Values | Description |
---|---|---|
digit | true, false | Specifies the character is digit only. |
upper | true, false | Specifies the character is upper case only. |
lower | true, false | Specifies the character is lower case only. |
whitespace | true, false | Specifies the character is whitespace only. |
opts[cc] | true, false | Specifies the character is allowed only. |
public static Map parseMap(String text, String separator, String quote)
zUtl.parseMap("a=b,c=d");
zUtl.parseMap("a='b c',c=de", ',', "'\"");
text
- the text to parseseparator
- the separator. If omitted, ','
is assumedquote
- the quote to handle. Ignored if omitted.public static String decodeXML(String txt)
txt
- the text to decodepublic static Date today(String fmt)
fmt
- the time format, such as HH:mm:ss.SSS
If a time element such as seconds not specified in the format, it will
be considered as 0. For example, if the format is "HH:mm", then
the returned object will be today, this hour and this minute, but
the second and milliseconds will be zero.public static Date today(boolean full)
full
- if true, returns the full time,
else only returns year, month, and day.
If omitted, false is assumedpublic static boolean isAncestor(java.lang.Object p, java.lang.Object c)
getParent
or a field called parent
.
A typical example is used to test the widgets (Widget
).
Notice that, if you want to test DOM elements, please use
jq.isAncestor(_global_.DOMElement, _global_.DOMElement)
instead.
p
- the parent. This method return true if p is null
or p is the same as cc
- the childjq.isAncestor(_global_.DOMElement, _global_.DOMElement)
public static void progressbox(String id, String msg, boolean mask, String icon)
id
- the ID of the DOM element being createdmsg
- the message to shownmask
- whether to show sem-transparent mask to prevent
the user from accessing it.icon
- the CSS class used to shown an icon in the box.
Ignored if not specified.destroyProgressbox(_global_.String)
public static void destroyProgressbox(String id)
progressbox(_global_.String, _global_.String, boolean, _global_.String)
.id
- the ID of the DOM element of the message boxpublic static void go(String url, Map opts)
url
- the URL to go toopts
- [optional] the options. Allowed values:
public static Array frames(Window w)
To retrieve all, invoke zUtl.frames(top)
.
Notice: w is included in the returned array.
If you want to exclude it, invoke zUtl.frames(w).$remove(w)
.
w
- the browser windowpublic static String intsToString(int[] ary)
ary
- the integer array to convert.
If null, an empty string is returned.stringToInts(_global_.String, int)
public static int[] stringToInts(String text, int defaultValue)
text
- the string to convert.
If null, null is returned.defaultValue
- the default value used if the value
is not specified. For example, zUtl.stringToInts("1,,3", 2) returns [1, 2, 3].intsToString(int[])
public static String mapToString(Map map, String assign, String separator)
map
- the map to convertassign
- the symbol for assignment. If omitted, '=' is assumed.separator
- the symbol for separator. If omitted, ',' is assumed.intsToString(int[])
public static void appendAttr(String nm, java.lang.Object val, boolean force)
nm
- the name of the attributeval
- the value of the attributeforce
- whether to append attribute no matter what value it is.
If false (or omitted), it is the same as appendAttr(String, Object)
.public static void appendAttr(String nm, java.lang.Object val)
val ? ' ' + nm + '="' + val + '"': ""
.
If you want to generate the attribute no matter what val is, use
appendAttr(String, Object, boolean)
.
nm
- the name of the attributeval
- the value of the attributepublic static void fireSized(Widget wgt, int bfsz)
wgt
- the widget which the zWatch event will be fired against.bfsz
- the beforeSize mode:
public static void fireShown(Widget wgt, int bfsz)
wgt
- the widget which the zWatch event will be fired against.bfsz
- the beforeSize mode:
public static void loadImage(String url)
url
- the loading image's localationpublic static void isImageLoading()
loadImage(_global_.String)
public static void getWeekOfYear()
public static void convertDataURLtoBlob()
public static double getDevicePixelRatio()
public static Promise getUserMedia(String constraints)
constraints
- a constraints object specifying the types of media to requestpublic static Function throttle(Function func, int wait)
func
- the passed functionwait
- wait millisecondspublic static Function debounce(Function func, int wait, boolean immediate)
func
- the passed functionwait
- wait millisecondsimmediate
- trigger the function on the leading instead of the trailing edge of the wait intervalpublic static String encodeXMLAttribute(String txt)
Utl
for more XML utilities.txt
- the text to encodepublic static String encodeXML(String txt, Map opts)
Utl
for more XML utilities.txt
- the text to encodeopts
- [optional] the options. Allowd value:
public static long now()
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.