Javascript Functions for Designs in TVTools SYSTEM - TVTools.getDeviceType() returns the device type: "ANDROID" or "WINDOWS". - TVTools.quitApplication() quits TVSlide. - TVTools.getHorizontalResolution() returns the horizontal resolution in pixels of the device. - TVTools.getVerticalResolution() returns the vertical resolution in pixels of the device. - TVTools.setLedColor(String type, String sColor1, String sColor2, String sBlinkTime). Enables LED color changing for the devices which are equipped with such a feature. "type" is the type of device. For now, only "PHILIPS" is supported. "color1" is the desired color, in hexadecimal AARRGGBB format. If AA is 00, the leds are turned off. "color2" is the second color when blinking is desired. "blink rate" is the rate in milliseconds at which the two colors blink. If "0", blinking is disabled. - TVTools.executeShellCommand(String cmd) Executes a shell command on the device. - TVTools.sendKeysToZone(String keys, int zone) Sends a series of key presses to the currently played element, or if its a multizone, to the currently played element in a specific zone. GENERAL - TVTools.setLanguage(String language) Permits to change the language of the device. Language uses the standard notation for countries ("en", "fr", etc... or "enUS", "frFR", etc...). - TVTools.initVar(String variable, String value) Gives a value to a variable. This function does NOT trigger the "variableChanged" callback of the design. Variables can have any alphanumeric names, but VAR0 to VAR9 are the 10 TVTools user variables which are saved to storage and therefore kept between sessions. - TVTools.setVar(String variable, String value) Same as initVar, but this function additionally triggers the "variableChanged" callback of the design. - String TVTools.getVar(String variable) Gets the value of a variable. Returns a String containing the value, or "null" if there's no such variable. - TVTools.startApplication(String name) Starts an Android application. Name is the package name, e.g. "com.wildcopper.tvslide4droid". - TVTools.nextPage(int page) Plays the next page of the design. Page isn't used yet. - TVTools.setInteractiveMode(String mode) Sets the interactive mode of the device. Values can be: "remote" for remote control or keyboard "touch" for touch screen - TVTools.log(String message) Permits to put a message in the "logcat" from a script. - TVTools.sendCommand1(String nb, String cmd) Sends the "sendCommand1" web service command number nb to the server. Returns the boolean value true on success. DESIGN OBJECTS - TVTools.redrawContent(int objectID) Redraws the object with the specified ID, if that object has a content updater. - TVTools.updateObject(int objectID) Updates the object with the specified ID, if it has a content updater or if it is a container. - TVTools.selectContainerElement(int objectID, String selector) In an interactive container, selects the first container element for which the selector is true. E.g. TVTools.selectContainerElement(10, "name=tvtools") will select the first container element whose database field "name" equals "tvtools". - TVTools.playContainerPage(int objectID, int pageNum) Play a specific page of a container. - TVTools.setObjectVisibility(int objectID, boolean visible) Make the object with the specified ID visible (true) or not (false). - TVTools.setObjectBlink(int objectID, int rate, int number) Makes an object blink at a specified rate for specific number of times. - TVTools.setObjectBackgroundColor(int objectID, int color) Sets the specified object's background color (format AARRGGBB). - TVTools.getObjectFileName(int page, int objectID) Returns the local file name of the object with the specified ID on the page . DESIGN PAGES - TVTools.setPageVisibility(int page, boolean visibility) Makes the specified design page visible or not. If invisible, the page will be skipped during playback. - TVTools.getActualPage() Returns the currently played page number. - TVTools.getTotalPages() Returns the total number of pages in the design. OTHER DESIGN FUNCTIONS - TVTools.setInactivityTimer(int duration) Sets the inactivity timer of the design, in seconds. If there is no user input during that period, the page script function "onInactivity" will be called. - TVTools.setTimer(int duration) Sets a timer for the design, in milliseconds. The page script function "onTimer" will be called repeteadly after the duration. - TVTools.parseString(String input, int index) Parses the string 's hashtags. should be the current recordset entry index if there is one. DESIGN MODAL PLAYLIST DIALOGS - TVTools.modalPlayList(String playlistName) Will open a modal dialog playing the content of the playlist which should have been previously loaded with the "Android/LoadPlaylist" command. The dialog will be of the size of the playlist content, centered on the screen. - TVTools.customModalPlayList(String playlistName, int x, int y, int w, int h, int opacity) Will open a modal dialog playing the content of the playlist which should have been previously loaded with the "Android/LoadPlaylist" command. The dialog will be at position (x, y) and of size (w, h), and the background will be grayed out at . - TVTools.closeTopMostDialog() Will close the topmost modal dialog on the screen. DESIGN RECORDSETS - TVTools.getBDDField(String recordsetName, int recordNumber, String fieldName) Returns the content of field of the record number of the recordset . Returns an empty String in case of failure. - TVTools.getBDDFieldFromValue(String recordsetName, String selector, String fieldName) Returns the content of the field of the first record of the recordset for which the selector is true. E.g. TVTools.getBDDFieldFromValue("MyRecordset", "name=tvtools", "email") will return the content of the field "email" for the first record of "MyRecordset" for which the field "name" equals "tvtools". Returns an empty String in case of failure. - TVTools.getBDDIndexFromValue(String recordsetName, String selector) Returns the index of the first record of the recordset for which the selector is true. Returns -1 on failure. - TVTools.changeBDDFilterValue(String recordsetName, int index, String value) Changes the filter value of the recordset . - TVTools.filterBDD(String recordsetName) Forced the re-filtering of the recordset . if is "*", it will re-filter all recordsets of the design. - TVTools.updateBDD(String recordsetName, boolean force) Updates the recordset . If equals true, it will force the downloading from the source even if the cache delay is not expired yet. - TVTools.getBDDSize(String recordsetName) Returns the size of the recordset . - TVTools.forceBDDUpdate(String recordsetName) The recordset will be updated next time it is accessed even if the cache delay is not expired. ROOM BOOKING - TVTools.roomBookingInitInfo("room recordset", "event recordset", int confirmationDelay, int precision, int mode) Initializes the room booking system, parameters are two strings with the numbers of the room and event recordsets, and an integer giving the confirmation delay in minutes. If the delay is 0, there's no confirmation required. The mode is 0 for the old room booking, 1 for V2 with WebSocket and 2 for V2 with WebService. - String TVTools.roomBookingAddEvent("start", "end", "details") Adds a room booking reservation to the actual room between start and end dates (format: "dd/MM/yyyy HH:mm") providing details of the event. Returns "true" if succeeded and "false" if failed. - String TVTools.roomBookingRoomAddEvent("start", "end", "roomname", "details") Adds a room booking reservation to the specified room between start and end dates (format: "dd/MM/yyyy HH:mm") providing details of the event. Returns "true" if succeeded and "false" if failed. - String TVTools.roomBookingAddTime("time") Adds a specific amount of time to the actual event. The format for time is "HH:mm" (24 hour mode hours:minutes). The function can return: "NO_EVENT": there's no actual event to extend. "RB_NOT_INIT": room booking hasn't been initialized. "ROOM_OCCUPIED": the room isn't free during the requested period. "true": everything is ok. - String TVTools.roomBookingSelectNearbyFreeRoom("title", "start", "end", "variable", "okText", "cancelText") Will search among the nearby rooms those which are free in the start to end timeframe and then permit the user to select one and book it. Can return "ERROR:NO ROOM" if there's no free nearby room. - String TVTools.roomBookingEndEvent() Ends the current event of the current room. Returns "true" if succeeded and "false" if failed. - TVTools.roomBookingConfirmEvent() Confirms the current event, or the next one if its in the pre-confirmation limit. - TVTools.roomBookingIsConfirmed() Returns "true" if the actual event is confirmed. - TVTools.roomBookingIsNextConfirmed() Returns "true" if the next event (in the range of the confirmation delay) is confirmed. - TVTools.roomBookingSetConfirmationLimit(int limit) Events longer than minutes will no longer require a confirmation. - TVTools.roomBookingGetCurrentEventIndex(String roomName) Returns the current even index (in the recordset) for the room . Returns -1 if there's no event. - TVTools.roomBookingGetNextStatusChange(String roomName, String format) Returns the time of the next status change of room in the specified format . A status change is when the room goes from occupied to free or vice versa. Returns an empty String on failure. - TVTools.roomBookingGetCurrentEventLengthMS() Returns the duration of the current event in milliseconds, or -1 if there's no event. - TVTools.roomBookingGetNextFreeNiche(String roomName, String startTime, String duration) Returns the next free time period after startTime in which an event of size duration would fit. The date format is standard booking "dd/MM/yyyy HH:mm". For the duration, the format is "HH:mm". USER INPUT - TVTools.alert(String title, String message) Displays a modal alert dialog with title and message. - TVTools.blockingAlert(String title, String message, String seconds) Displays a modal alert dialog with title and message and without buttons for a specific amount of seconds. It blocks all user input. - TVTools.question(String title, String message, final String variable, String okText, String cancelText) Asks a question in a modal dialog, putting "OK" or "CANCEL" in the specified variable depending on the choice. The dialog will automatically close after 30 seconds. This function triggers the "variableChanged" callback of the design. - TVTools.inputText(String label, String message, final String variable) Permits to enter a text that will be put in the specified variable. The dialog will automatically close after 30 seconds. This function triggers the "variableChanged" callback of the design. - TVTools.inputList(String label, String message, final String variable) Permits to select an option in a list. Options are separated by a | (e.g.: "One|Two|Three|Four"). The result will be put in the specified variable. This function triggers the "variableChanged" callback of the design. - TVTools.inputTime(String format, String mode, String variable) Permits to select a time or duration. If mode is "24", works in 24 hours mode, otherwise it's 12 hours with am/pm. The selection will be put in the specified variable. This function triggers the "variableChanged" callback of the design. - TVTools.inputDate(format, variable) Permits to select a date. The selection will be put in the specified variable. This function triggers the "variableChanged" callback of the design. POLLS/SURVEYS - TVTools.sendStats(String guid, int question, int answer) Sends the selected answer of question of the survey with id "guid". DATE UTILITIES (for date formats, see https://developer.android.com/reference/java/text/SimpleDateFormat.html) - String TVTools.getCurrentDate(String format) Returns the current date and time using the specified format. - String TVTools.getDateDiff(String date1, String date2, String format, String mode) Returns the difference between two dates in the specified format. Mode can be "seconds", "minutes" or "hours". - String TVTools.incrementDateMinutes(String date, String format, String minutes, String precision) Returns the date in the specified format to which are added the specified minutes. Can be positive or negative. Precision is the minutes step of the value returned, for instance if precision = 5, at 11:43 it will return 11:45. - String TVTools.compareDates(String date1, String format1, String date2, String format2) Compares two dates which can have a different format. Returns "before", "after" or "equal". MESSAGES - TVTools.displayLastMessage() Displays the first unread message, or if there's none, the first message.