ShowTable of Contents
An object with various useful tools. YN Is always there, you don't need to create the object.
Properties YN.logfilename
The name of the current logfile if ynSession.setDebug(level, true) was called.
YN.isIPhone
Returns true if the device is an iPhone. Also available as a function in YNUI.isIPhone().
YN.isIPad
Returns true if the device is an iPad. Also available as a function in YNUI.isIPad().
YN.isAndroid
Returns true if the device is an Android. Also available as a function in YNUI.isAndroid().
Methods YN.log(msg, debuglevel)
Writes a message to the console and - optionally - to the logfile.
With:
msg: the message to write debuglevel: optional, if used, writes the message only if an equal or higher debug level is set using ynSession.setDebug().
Example:
YN.log("message to the console");
YN.log("message only if debug level 1 or higher is set.", 1);
YN.log("message only if debug level 3 or higher is set.", 3);
YN.logSendAsMail(recipients, subject, body)
If debug mode with writing to logfile is enabled (see ynSession.setDebug() ), use this method to compose a mail with the current logfile attached. This is useful to provide a user with a simple button to send the current logfile to the developer. With:
recipients: one or more mail addresses as string or as array of strings.
subject: optional, a custom subject for the mail.
body: optional, a custom body for the mail. Some vital informations about the device are included automatically.
YN.exception(msg, e)
Useful in exception handlers to write the exception message along with a custom message to the console or the log.
Example:
try {
... some code ..
} catch (e) {
YN.exception("name of current method", e);
}
YN.createUNID()
Returns a unique ID as a string consisting of the current time and a random number.
YN.getRandom(x,y)
Returns a random number between x and y.
Example:
var myNumber = YN.getRandom(1,10);
|