Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TadHTMLPrompt

TadHTMLPrompt (Library)

This is a class that his used for running Drafts commands. These commands are based on the slash command approach of other systems.

Hierarchy

  • TadHTMLPrompt

Index

Constructors

constructor

  • Creates new instance of TadHTMLPrompt class.

    Returns TadHTMLPrompt

Properties

buttonCancel

buttonCancel: string

The HTML that constructs the cancel button on the form. This HTML is defaulted in the constructor() function, but can be overridden. You could customise what the button does, its name, or set it to a null string to simply not include a cancel button.

buttonSubmit

buttonSubmit: string

The HTML that constructs the submit button on the form. This HTML is defaulted in the constructor() function, but can be overridden. You could customise what the button does, its name, or set it to a null string to simply not include a submit button.

content

content: string

The body content to include in the tad-fd form in the body of the HTML of the preview.

css

css: string

The main CSS to be used in the preview window.

hideInterface

hideInterface: Boolean

Determines if the preview window should have the interface bar shown. Deafulted to true by the constructor() function, which will cause the interface to be hidden.

html

html: string

The base HTML of the preview window. Note that it includes template placeholders for five regions:

  • tadpreview_content - the main content.
  • tadpreview_css - the main CSS.
  • tadpreview_title - the window title.
  • tadpreview_submit - the submit button.
  • tadpreview_cancel - the cancel button. These entries are populated from the corresponding class properties.

title

title: string

The title of the preview window.

Methods

TA_dropDown

  • TA_dropDown(p_strLabel: string, p_astrList: string[]): string
  • Display an HTML prompt containing a drop down list. The function returns the value of the drop down field, or undefined if cancelled.

    Parameters

    • p_strLabel: string

      the label to be associated with the drop down list.

    • p_astrList: string[]

      the array of strings with which to populate the drop down list.

      // Example
      let obj1 = new TadHTMLPrompt;
      alert(obj1.TA_dropDown("Select an option", ["alpha","bravo","charlie"]));

    Returns string

TA_filterField

  • TA_filterField(p_strLabel: string, p_astrList: string[]): string
  • Display an HTML prompt containing a filter list. This is displayed as a test field, but as the user enters text, it filters a list that displays beneath it of 'known' values. Any value can be entered, but generally the idea is to use the list to populate the field with a known value. This is particularly useful for long lists. The user can match using a tap, mouse click, or cursor key navigation, and selecting enter while the focus is on the text field will automatically submit. The function returns the value of the text field, or undefined of cancelled. One limitation is that the array of entries cannot (currently) include a backtick.

    Parameters

    • p_strLabel: string

      the label to be associated with the text field.

    • p_astrList: string[]

      the array of strings with which to populate the drop down list that shows beneath the text field.

      // Example
      let obj1 = new TadHTMLPrompt;
      alert(obj1.TA_filterField("Select an option", ["Alan","Albert","Alfred"]));

    Returns string

TA_show

  • TA_show(): string
  • Display the HTML prompt and return the form contents as an object. The function returns an object whose properties relate to the form field IDs and can be accessed using the same name. If cancelled, the function returns undefined.

    // Example
    let obj1 = new TadHTMLPrompt;
    obj1.content = `<label for="fname">First Name:</label><input type="text" id="fnamefield" name="fname"><br>
         <label for="lname">Last Name:</label><input type="text" id="lnamefield" name="lname">`
    let objData = obj1.TA_show();
    if (objData != undefined)
    {
        alert(objData.fnamefield);
        alert(objData.lnamefield);
    }

    Returns string

TA_textFields

  • TA_textFields(p_astrField: string[]): object
  • Display an HTML prompt containing multiple text entry fields. This function accepts an array of arrays. The inner arrays consist of two strings, the field label text, and the field ID. The function takes each pair of data from the outer array and builds a text field for it. The data object containing the values for each of those IDs is then returned.

    Parameters

    • p_astrField: string[]

      tan array containing 2-element arrays for the field label text and the field ID.

      // Example
      let obj1 = new TadHTMLPrompt;
      let objData = obj1.TA_textFields([["First Name", "firstName"], ["Middle Name", "middleName"], ["Surname", "lastName"]]);
      alert(`My name is ${objData.firstName} ${objData.middleName} ${objData.lastName}`);

    Returns object