Creates new instance of TadHTMLPrompt class.
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.
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.
The body content to include in the tad-fd
form in the body of the HTML of the preview.
The main CSS to be used in the preview window.
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.
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.The title of the preview window.
Display an HTML prompt for draft creation/editing. This function displays a simple pop-up drafts editor. The editor includes a field for capturing draft content, a word count, a checkbox to mark the flagged status of the draft, and an expandable section showing existing tag association and a field to add new tags (comma separated list). The function can be used to not only create a new draft, but also to edit an existing one. It is a very simple editor and is in no way intended to replace the main draft editor. Rather it is a way to quickly add or update a draft without leaving the current draft - useful on devices that do not suport multi-windowing, or within the context of an executing action. The function returns undefined if the editor was cancelled, and the edited (and updated) draft object if submitted.
the draft object to load into the pop-up editor, defaults to null
, which is what should be used to specify creation of a new draft.
the label to use for the large text field, defaults to "Content".
an optional limit to the number of characters that can be entered.
an optional specification of after how many characters a countdown will be displayed in red.
// Example
let obj1 = new TadHTMLPrompt;
//Create a new draft
obj1.TA_draft();
//Edit the current draft, set the label and set some editing constraints
obj1.TA_draft(draft, "Current Draft Content to be Edited", 5000, 4750);
Display an HTML prompt containing a drop down list. The function returns the value of the drop down field, or undefined if cancelled.
the label to be associated with the drop down list.
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"]));
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.
the label to be associated with the text field.
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"]));
Simple function to show some HTML and an OK button for informational purposes. The function uses TADpoLe's standard HTML Prompt set-up, but strips out the standard submit button and renames cancel to OK. This allows the prompt to still be closed by ESC, but we also don't expect to process any return. This is intended to just by a quick way to produce a pop-up information window with a lot more styling and layout control than you get with a simple JavaScript alert.
the HTML content to be used in the prompt.
// Example
let obj1 = new TadHTMLPrompt;
obj1.TA_message("<h1>Hello World</h1>");
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);
}
Display an HTML prompt with a single large text entry field.
This function must receive a label for the text field to be displayed. It may optionally also accept a maximum
size for the field. If no maximum size is set, the field will use a character counter. If a maximum size is
specified, the character counter will count down, and change to red once a specified number of characters is reached
(the default if unspecified is 10% of the maximum number of characters that can be entered).
The function may also include some initial text to be edited.
The function returns the content of the field if submitted, and undefined
if cancelled.
the label to use for the large text field.
an optional limit to the number of characters that can be entered.
an optional specification of after how many characters a countdown will be displayed in red.
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.
an 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}`);
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.