Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TadLibrary

TadLibrary (Library)

This is a class that holds information about this library and allows interactions such as reading and updating the information.

Hierarchy

  • TadLibrary

Index

Constructors

constructor

  • Creates new instance of TadLibarary class. The construction specifies default settings values, and merges in the values form the settings file. It will also automatically load test libraries if the loading setting for test libraries is enabled.

    Returns TadLibrary

Properties

actions

actions: JSON

A set of key value pairs which describe a name for an action (key) and the name of the Drafts action to be run (value). This is used by actions that, for example, allow the user to select from a subset of actions via a prompt, and then run the action.

authors

authors: string[]

An array of the library authors. Any value held in the settings file is overridden by the internal library processing, and is set to TAD_AUTHORS.

backlink_de

backlink_de: any

Delimiter for cross-links in a back links section of a draft.

backlink_prefix

backlink_prefix: string

Prefix for a cross-link in a back links section of a draft.

backlink_sectionend

backlink_sectionend: string

Used to denote the end of a back links section in a draft.

backlink_sectionstart

backlink_sectionstart: string

Used to denote the start of a back links section in a draft.

backlink_suffix

backlink_suffix: string

Suffix for a cross-link in a back links section of a draft.

buttonLabelTruncation

buttonLabelTruncation: string

Used to specify the maximum number of characters shown in the list of drafts in the draft.TA_getRecentDraftData() listing.

commands

commands: JSON

A set of key value pairs which describe the string of characters for a slash command (key), and the details of the command (value). These are used by the library's slash command functionality.

consoleDebugMarker

consoleDebugMarker: string

When debug messages are enabled, any debug messages written to the console log using one of the library's debug functions will prefix the console item with this string.

consoleErrorMarker

consoleErrorMarker: string

When error messages are written to the console log using one of the library's error logging functions, the message will prefix the console item with this string.

consoleInformationMarker

consoleInformationMarker: string

When information messages are written to the console log using one of the library's information logging functions, the message will prefix the console item with this string.

consoleSuccessMarker

consoleSuccessMarker: string

When success messages are written to the console log using one of the library's success logging functions, the message will prefix the console item with this string.

consoleWarningMarker

consoleWarningMarker: string

When warning messages are written to the console log using one of the library's warning logging functions, the message will prefix the console item with this string.

copyright

copyright: string

The copyright information for the library. This includes the copyright period, author list, and a reference to the main web site, ThoughtAsylum. Any value held in the settings file is overridden by the internal library processing, and is set to "Copyright " + this.copyrightPeriod + ": " + this.authors.join(", ") + " (ThoughtAsylum).".

copyrightPeriod

copyrightPeriod: string

The period for which the license copyright is applied. Development of the library began in 2018, and copyright is taken to extend from that year to the current. Any value held in the settings file is overridden by the internal library processing, and is set to "2018 - " + dtNow.getFullYear().

dataPath

dataPath: string

The path to the library persistent data file.

debugEnabled

debugEnabled: string

Enables a debug mode state The natural default for this is off. You can set it on and off at the start of a script, for the duration of that script by using this line: tadLib.debugEnabled = true;

draft_discourse

draft_discourse: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing Discourse posts. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file.

draft_github_markdown

draft_github_markdown: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing GitHub Markdown content. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file. /**

draft_javascript

draft_javascript: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing JavaScript. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file.

draft_markdown

draft_markdown: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing Markdown content. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file. /**

draft_multimarkdown

draft_multimarkdown: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing MultiMarkdown content. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file. /**

draft_plain_text

draft_plain_text: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing plain text content. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file. /**

draft_simple_list

draft_simple_list: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing simple list content. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file. /**

draft_taskpaper

draft_taskpaper: string

A set of JSON that describes a particular type of special draft. In this case the draft is one used for writing a Taskpaper list. The are drafts is described by a set of properties that can be used by library functions as a point of reference when working with this type of draft.

The properties for such a draft are:

  • tags : an array of tag names for tags that would be associated with the draft.
  • syntax : the draft syntax that would be used for this type of draft.
  • extension : the file extension that would be used if this type of draft were to be exported to a file.

duplicateLinesDefault

duplicateLinesDefault: number

Used by the editor function TA_repeatDuplicateCurrentLineAsk. It specified the default number of line duplications to offer to the user when prompted to duplicate lines a number of times.

encodeMap

encodeMap: JSON

A set of URL encoding mappings used by the String function TA_encodeURI() to encode additional characters beyond those converted by encodeURIComponent().

ilmiter

ilmiter: string

libName

libName: string

The file name of the library.

libSourceURL

libSourceURL: string

The URL where the latest version of the library can be downloaded.

metaPath

metaPath: string

The path to the library meta data file.

msgTitleDebug

msgTitleDebug: string

The string displayed as the title on a debug message box - see app.TA_msgDebug().

msgTitleError

msgTitleError: string

The string displayed as the title on an error message box - see app.TA_msgError().

msgTitleInfo

msgTitleInfo: string

The string displayed as the title on an information message box - see app.TA_msgInfo().

msgTitleWarn

msgTitleWarn: string

The string displayed as the title on an warning message box - see app.TA_msgWarn().

runArea

runArea: string

The folder which will be used for the search of a draft with a matching tag for running. See runTag.

runSyntax

runSyntax: string

The syntax to be applied to a draft for content execution.

runTag

runTag: string

The name of a tag used for identifying current in-situ code testing.

runTagScript

runTagScript: string

The name of a tag used to identify scripts. The intent is that while you only have one draft assigned therunTag at any time, this tag would be assigned to all that have been runnable to help you identify them after switching the runTag to another draft.

separatorDateStamp

separatorDateStamp: string

The string used to separate elements in a date stamp.

separatorDateTimeStamp

separatorDateTimeStamp: string

The string used to separate a date stamp and a time stamp in a full timestamp.

separatorTimeStamp

separatorTimeStamp: string

The string used to separate elements in a time stamp.

settingsPath

settingsPath: string

The path to the library settings file.

source

source: string

The url of the web site for the library. Any value held in the settings file is overridden by the internal library processing, and is set to TAD_SOURCE.

taskBasicComplete

taskBasicComplete: string

The string that deontes a completed basic task. e.g. X

taskBasicEnd

taskBasicEnd: string

The suffix for a basic task marker. e.g. ]

taskBasicIncomplete

taskBasicIncomplete: string

The string that deontes a basic task has not been completed. e.g.

taskBasicStart

taskBasicStart: string

The prefix for a basic task marker. e.g. - [

taskBasicSyntax

taskBasicSyntax: string

The draft syntax to use when utilising basic tasks

templateFilter

templateFilter: string

The string used to define the query for drafts based templates. This could be for example "inbox", "archive", or "all".

templateTags

templateTags: string[]

Specifies an array of tag names used to define the query for drafts based templates. This could be for example be "[template"].

testLibsAlert

testLibsAlert: Boolean

Used to specify whether when additional library files are loaded for testing, if an audio/visual notification should be triggered. The default is true, and will trigger the information message and sound to be activated.

testLibsEnable

testLibsEnable: Boolean

Used to specify whether additional library files should be loaded for testing. Typically this should be kept as false, unless you were developing further extensions to the library. But, it is available should anyone wish to add and manage the requirement of their own libraries in this way. The list of libraries to be loaded is specified by the path stored in the testLibsListPath property.

testLibsListPath

testLibsListPath: Boolean

Used to specify a list of additional library files that may be loaded for testing. The path should be to a plain text file where the file name for each library file to be loaded should be stored on separate lines. They should be the only things on those lines. No comments, indents, etc. Typically this should be left as is and is for use by the library developer(s). However, it is available should anyone wish to add and manage the requirement of their own libraries in this way. The loading of the libraries occurs at initialisation of the global libarary object and only when the testLibsEnable property is set to true; which given when the libraries are loaded and it being false by default, it must be specified in the settings file prior to triggering the script/action.

version

version: string

The version of the library. This is useful when checking if you have the latest version, or for identifying a version where there may have been a bug, new feature added/deprecated, etc. Any value held in the settings file is overridden by the internal library processing, and set to TAD_VERSION.

Methods

Private TA_buildLibraryAction

  • TA_buildLibraryAction(): void
  • Used to quickly replace the TAD-Libray action contents from the tad.js library file.

    // Example
    tadLib.TA_buildLibraryAction();

    Returns void

TA_copySettings

  • TA_copySettings(): string
  • Copy a set of options for displaying a set of settings to the clipboard. The user has the option to copy the loaded library settings as text, as stringified text (JSON), or the saved settings from file as stringified text (JSON). The function returns the copied text.

    // Example
    tadLib.TA_copySettings();

    Returns string

TA_copySettingsLoaded

  • TA_copySettingsLoaded(): string
  • Copy the current settings for the library object to the clipboard. The settings are returned with a property and its description separated by an equality character (=) between them, and with each key-value pair on a separate line. The results are also sorted alphabetically. Any settings that are themselves objects are simply returned as an object. The function returns the copied text.

    // Example
    tadLib.TA_copySettingsLoaded();

    Returns string

TA_copySettingsLoadedJSON

  • TA_copySettingsLoadedJSON(): string
  • Copy the current settings for the library object as a text representation of JSON to the clipboard. The text copied is a 'stringified' version of the library object. The function returns the copied text.

    // Example
    tadLib.TA_copySettingsLoadedJSON();

    Returns string

TA_copySettingsSavedJSON

  • TA_copySettingsSavedJSON(): string
  • Copy the persistent library settings that are saved to file, as a text representation of JSON to the clipboard. The settings are read from the JSON file specified by the settingsPath property. These settings can be different from the currently loaded settings in that there may be default settings in the locaded settings that overide those in the settings file, are defaults from the file that have not yet been saved, or settings that have been updated by the flow of a script since loading the settings from file. The function returns the copied text.

    // Example
    tadLib.TA_copySettingsSavedJSON();

    Returns string

TA_displaySettings

  • TA_displaySettings(): string
  • Display a set of options for displaying a set of settings and show the selected settings. The user has the option to display the loaded library settings as text, as stringified text (JSON), or the saved settings from file as stringified text (JSON). The function returns the displayed text.

    // Example
    tadLib.TA_displaySettings();

    Returns string

TA_displaySettingsLoaded

  • TA_displaySettingsLoaded(): string
  • Display the current settings for the library object in a pop up. The settings are returned with a property and its description separated by an equality character (=) between them, and with each key-value pair on a separate line. The results are also sorted alphabetically. Any settings that are themselves objects are simply returned as an object. The function returns the displayed text.

    // Example
    tadLib.TA_displaySettingsLoaded();

    Returns string

TA_displaySettingsLoadedJSON

  • TA_displaySettingsLoadedJSON(): string
  • Display the current settings for the library object as a text representation of JSON in a pop up. The text displayed is a 'stringified' version of the library object. The function returns the displayed text.

    // Example
    tadLib.TA_displaySettingsLoadedJSON();

    Returns string

TA_displaySettingsSavedJSON

  • TA_displaySettingsSavedJSON(): string
  • Display the persistent library settings fthat are saved to file, as a text representation of JSON in a pop up. The settings are read from the JSON file specified by the settingsPath property. These settings can be different from the currently loaded settings in that there may be default settings in the locaded settings that overide those in the settings file, are defaults from the file that have not yet been saved, or settings that have been updated by the flow of a script since loading the settings from file. The function returns the displayed text.

    // Example
    tadLib.TA_displaySettingsSavedJSON();

    Returns string

TA_getSettingsLoaded

  • TA_getSettingsLoaded(): string
  • Get the library settings of the library object as a string of text. The settings are returned with a property and its description separated by an equality character (=) between them, and with each key-value pair on a separate line. The results are also sorted alphabetically. Any settings that are themselves objects are simply returned as an object. If you want to view all details at all levels, a better way to do this is to stringify() the library object. for convenience.

    // Example
    tadLib.TA_getSettingsLoaded();

    Returns string

TA_getSettingsSavedJSON

  • TA_getSettingsSavedJSON(): string
  • Get the persistent library settings that are saved to file as a JSON formatted string of text. The settings are read from the JSON file specified by the settingsPath property. These settings can be different from the currently loaded settings in that there may be default settings in the locaded settings that overide those in the settings file, are defaults from the file that have not yet been saved, or settings that have been updated by the flow of a script since loading the settings from file.

    // Example
    tadLib.TA_getSettingsSavedJSON();

    Returns string

Private TA_libraryInitialise

  • TA_libraryInitialise(): void
  • Initialises the library settings. Settings are stored in the file specified by the settingsPath property. This is called at the point of creating a new library object, and should never need to be called outside of that. The location of the library settings file is set as /Library/Scripts/tad.json by deafult, within the Drafts standard folder structure.

    Returns void

Private TA_libraryTestLibLoad

  • TA_libraryTestLibLoad(): Boolean
  • Load additional library files for testing. Libraries to load are stored one per line in the file specified by the testLibsListPath property. Returns true if libraries are loaded.

    Returns Boolean

TA_save

  • TA_save(): boolean
  • Saves the latest library settings to file. Settings are stored in the file specified by the settingsPath property.

    // Example
    tadLib.TA_save();

    Returns boolean