Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface HTTP

HTTP (Drafts)

The ThoughtAsylum library includes a set of extensions to the HTTP object

Hierarchy

  • HTTP

Index

Methods

TA_getContent

  • TA_getContent(p_strURL: string): string
  • Fetches content from a URL. Returns the content retrieved from the URL, and an empty string if nothing was retrieved.

    Parameters

    • p_strURL: string

      The URL from which to fetch the content.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_getContent("https://www.w3.org/TR/PNG/iso_8859-1.txt"));

    Returns string

TA_getContentToLocalFile

  • TA_getContentToLocalFile(p_strURL: string, p_strFilePath: string): Boolean
  • Save the content of a URL to a local file. It will overwrite existing files and returns a Boolean for the file writing process.

    Parameters

    • p_strURL: string

      the URL of the web page to retrieve the content from.

    • p_strFilePath: string

      the file path to save the content to.

      // Example
      let objHTTP = HTTP.create();
      objHTTP.TA_getContentToLocalFile("https://tools.ietf.org/rfc/rfc2606.txt", "/Info/rfc2606.txt");

    Returns Boolean

TA_getContentToiCloudFile

  • TA_getContentToiCloudFile(p_strURL: string, p_strFilePath: string): Boolean
  • Save the content of a URL to an iCloud file. It will overwrite existing files and returns a Boolean for the file writing process.

    Parameters

    • p_strURL: string

      the URL of the web page to retrieve the content from.

    • p_strFilePath: string

      the file path to save the content to.

      // Example
      let objHTTP = HTTP.create();
      objHTTP.TA_getContentToiCloudFile("https://tools.ietf.org/rfc/rfc2606.txt", "/Info/rfc2606.txt");

    Returns Boolean

TA_getExternalIP

  • TA_getExternalIP(): string
  • Get the external IP address of the device. Utilises ipify.org's API.

    // Example
    let objHTTP = HTTP.create();
    alert(objHTTP.TA_getExternalIP());

    Returns string

TA_getSyntaxTest

  • TA_getSyntaxTest(p_strSyntx: string): string
  • Fetches example syntax content from @sylumer's GitHub repo of syntax examples for Drafts. The syntax type must be specified, and must match (case sensitive), one of the syntax types in the repo. Standard Drafts examples are included.

    Parameters

    • p_strSyntx: string

      The name of the syntax type.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_getSyntaxTest("Simple List"));

    Returns string

TA_getTitleFromURL

  • TA_getTitleFromURL(p_strURL: string): string
  • Returns a web page title for a specified URL. Also trims any whitespace from the start and end.

    Parameters

    • p_strURL: string

      the URL of the web page to retrieve the title for.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_getTitleFromURL("https://getdrafts.com/"));

    Returns string

TA_getURLContentClipboard

  • TA_getURLContentClipboard(p_strURL: string): string
  • Fetches content from a URL on the clipboard. If the validity check fails on the clipboard's URL validity, an entry will be written to the console noting this. Returns the content retrieved from the URL, and void if nothing was retrieved or the URL was invalid.

    Parameters

    • p_strURL: string

      the string to validate as a URL.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_getURLContentClipboard());

    Returns string

TA_isValidURL

  • TA_isValidURL(p_strURL: string): Boolean
  • Checks a string is a valid URL. If the validity check fails, an entry will be written to the console noting this. Returns true if the string meets a pattern matching-based URL validity check, and false if it is not.

    Parameters

    • p_strURL: string

      the string to validate as a URL.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_isValidURL("https://www.w3.org/TR/PNG/iso_8859-1.txt"));

    Returns Boolean

TA_mdTitleLinkFromURL

  • TA_mdTitleLinkFromURL(p_strURL: string): string
  • Returns a markdown link for a page, utilising it's title as the link text, for a specified URL.

    Parameters

    • p_strURL: string

      the URL of the web page to generate the link for.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_mdTitleLinkFromURL("https://getdrafts.com/"));

    Returns string

TA_quoteSimpsons

  • TA_quoteSimpsons(): number
  • Fetch a random The Simpson's quote from the thesimpsonsquoteapi.glitch.me. The function returns the quotation followed by the name of the character it is attributed to, in square brackets.

    // Example
    let objHTTP = HTTP.create();
    alert(objHTTP.TA_quoteSimpsons());

    Returns number

TA_randomInteger

  • TA_randomInteger(p_intMin: number, p_intMax: number): number
  • Get a random integer from an online service. Utilises csnrg.net's API.

    Parameters

    • p_intMin: number

      the minimum value of the random number.

    • p_intMax: number

      the maximum value of the random number.

      // Example
      let objHTTP = HTTP.create();
      alert(objHTTP.TA_randomInteger(1, 500));

    Returns number

TA_updateBeautifierLibrary

  • TA_updateBeautifierLibrary(): Boolean
  • Save a copy of the minified beautifier.io library file to the Drafts library scripts folder. The URL and filename are taken from the beautifierURL and beautifierLibName settings in the library properties. It will overwrite the file and returns a Boolean for the file writing process.

    // Example
    let objHTTP = HTTP.create();
    objHTTP.TA_updateBeautifierLibrary();

    Returns Boolean