Save a JavaScript library file to the Drafts library scripts folder. It will overwrite existing files and returns a Boolean for the file writing process. The output directory will be created if it does not exist.
the URL of the web content to retrieve the JavaScript from.
the base file name to save the JavaScript to in the Drafts script library (/Library/Scripts/
).
// Example
let objHTTP = HTTP.create();
objHTTP.TA_downloadLibrary("https://somedomain.com/somefile.js", "somelib");
Fetches content from a URL. Returns the content retrieved from the URL, and an empty string if nothing was retrieved.
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"));
Save the content of a URL to a local file. It will overwrite existing files and returns a Boolean for the file writing process.
the URL of the web page to retrieve the content from.
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");
Save the content of a URL to an iCloud file. It will overwrite existing files and returns a Boolean for the file writing process.
the URL of the web page to retrieve the content from.
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");
Get the external IP address of the device. Utilises ipify.org's API.
// Example
let objHTTP = HTTP.create();
alert(objHTTP.TA_getExternalIP());
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.
The name of the syntax type.
// Example
let objHTTP = HTTP.create();
alert(objHTTP.TA_getSyntaxTest("Simple List"));
Returns a web page title for a specified URL. Also trims any whitespace from the start and end.
the URL of the web page to retrieve the title for.
// Example
let objHTTP = HTTP.create();
alert(objHTTP.TA_getTitleFromURL("https://getdrafts.com/"));
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.
the string to validate as a URL.
// Example
let objHTTP = HTTP.create();
alert(objHTTP.TA_getURLContentClipboard());
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.
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 a markdown link for a page, utilising it's title as the link text, for a specified URL.
the URL of the web page to generate the link for.
// Example
let objHTTP = HTTP.create();
alert(objHTTP.TA_mdTitleLinkFromURL("https://getdrafts.com/"));
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());
Get a random integer from an online service. Utilises csnrg.net's API.
the minimum value of the random number.
the maximum value of the random number.
// Example
let objHTTP = HTTP.create();
alert(objHTTP.TA_randomInteger(1, 500));
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();
Save a copy of the TADpoLe library file to the Drafts library scripts folder.
The URL and filename are taken from the libSourceURL
and libName
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_updateTadpoleLibrary();
HTTP (Drafts)
The ThoughtAsylum library includes a set of extensions to the HTTP object