Tilde Friends
Loading...
Searching...
No Matches
Tilde Friends Client JS

Classes

class  TfNavigationElement
 
class  TfFilesElement
 
class  TfFilesPaneElement
 

Functions

function ensureLoaded (nodes, callback)
 
function editing ()
 
function is_edit_only ()
 
function async edit ()
 
function loadFile (name, id)
 
function async load (path)
 
function closeEditor ()
 
function async update_html ()
 
function save (save_to)
 
function async save_open_direct ()
 
function save_locally ()
 
function save_as ()
 
function changeIcon ()
 
function deleteApp ()
 
function url ()
 
function hash ()
 
function api_setDocument (content)
 
function api_postMessage (message)
 
function api_error (error)
 
function api_localStorageSet (key, value)
 
function api_localStorageGet (key)
 
function api_requestPermission (permission, description)
 
function api_print ()
 
function api_getHash (hash)
 
function api_setHash (hash)
 
function set_hidden (id, hide)
 
function update_credentials (credentials)
 
function _receive_websocket_message (message)
 
function setStatusMessage (message, color)
 
function send (value)
 
function hashChange ()
 
function focus ()
 
function blur ()
 
function visibilitychange ()
 
function message (event)
 
function reconnect (path)
 
function connectSocket (path)
 
function modeFromName (name)
 
function openFile (name)
 
function updateFiles ()
 
function makeNewFile (name)
 
function newFile ()
 
function removeFile ()
 
function async appExport ()
 
function async save_file_to_blob_id (name, file)
 
function async appImport ()
 
function async sourcePretty ()
 
function toggleVisibleWhitespace ()
 

Variables

const k_api
 

Detailed Description

Tilde Friends client-side browser JavaScript.

Function Documentation

◆ _receive_websocket_message()

function _receive_websocket_message (   message)

Process an incoming WebSocket message.

Parameters
messageThe message.

◆ api_error()

function api_error (   error)

Show an error.

Parameters
errorThe error.

◆ api_getHash()

function api_getHash (   hash)

Get the window's location hash.

Returns
hash The hash.

◆ api_localStorageGet()

function api_localStorageGet (   key)

Get a value from local storage.

Parameters
keyThe key.
Returns
The value.

◆ api_localStorageSet()

function api_localStorageSet (   key,
  value 
)

et a value in local storage.

Parameters
keyThe key.
valueThe value.

◆ api_postMessage()

function api_postMessage (   message)

Send a message to the sandboxed iframe.

Parameters
messageThe message.

◆ api_print()

function api_print ( )

Log from the app to the console.

◆ api_requestPermission()

function api_requestPermission (   permission,
  description 
)

Request a permission

Parameters
permissionThe permission to request.
descriptionAn optional human-readable description of the action for which the permission is being requested.
Returns
A promise fulfilled if the permission was granted.

◆ api_setDocument()

function api_setDocument (   content)

Set the iframe document contents.

Parameters
contentThe contents.

◆ api_setHash()

function api_setHash (   hash)

Set the window's location hash.

Parameters
hashThe new hash.

◆ appExport()

function async appExport ( )

Export the app to a zip file, which is downloaded by the browser.

◆ appImport()

function async appImport ( )

Prompt to import an app from a zip file.

◆ blur()

function blur ( )

Notify the app of lost focus.

◆ changeIcon()

function changeIcon ( )

Prompt to set the app icon.

◆ closeEditor()

function closeEditor ( )

Hide the editor.

◆ connectSocket()

function connectSocket (   path)

Connect the WebSocket.

Parameters
pathThe path to which to connect.

◆ deleteApp()

function deleteApp ( )

Prompt to delete the current app.

◆ edit()

function async edit ( )

Show the editor.

◆ editing()

function editing ( )

Check whether the editior is currently visible.

Returns
true if the editor is visible.

◆ ensureLoaded()

function ensureLoaded (   nodes,
  callback 
)

Make sure a set of dependencies are loaded

Parameters
nodesAn array of descriptions of dependencies to load.
callbackCalled when all dependencies are loaded.

◆ focus()

function focus ( )

Make sure the app is connected on window focus, and notify the app.

◆ hash()

function hash ( )

Get the window hash without the lone '#' if it is empty.

Returns
The hash.

◆ hashChange()

function hashChange ( )

Notify the app of the window hash changing.

◆ is_edit_only()

function is_edit_only ( )

Check whether only the editor is visible and the app is hidden.

Returns
true if the editor is visible and the app is not.

◆ load()

function async load (   path)

Load files for the app.

Parameters
pathThe app path to load.
Returns
A promise resolved when the app is laoded.

◆ loadFile()

function loadFile (   name,
  id 
)

Load a single file.

Parameters
nameThe name by which the file is known.
idThe file's ID.
Returns
A promise resolved with the file's contents.

◆ makeNewFile()

function makeNewFile (   name)

Create a new file with the given name.

Parameters
nameThe file's name.

◆ message()

function message (   event)

Handle a message.

Parameters
eventThe message.

◆ modeFromName()

function modeFromName (   name)

Determine a CodeMirror language mode from filename.

Parameters
nameFilename.
Returns
The mode name.

◆ newFile()

function newFile ( )

Prompt to create a new file.

◆ openFile()

function openFile (   name)

Open a file by name.

Parameters
nameThe file to open.

◆ reconnect()

function reconnect (   path)

Reconnect the WebSocket.

Parameters
pathThe path to which the WebSocket should be connected.

◆ removeFile()

function removeFile ( )

Prompt to remove a file.

◆ save()

function save (   save_to)

Save the app.

Parameters
save_toAn optional path to which to save the app.
Returns
A promise resoled when the app is saved.

◆ save_as()

function save_as ( )

Prompt the user for a path to save the application to, and save there.

◆ save_file_to_blob_id()

function async save_file_to_blob_id (   name,
  file 
)

Save a file.

Parameters
nameThe file to svae.
fileThe file contents.
Returns
A promise resolved with the blob ID of the saved file.

◆ save_locally()

function save_locally ( )

Save the current application under a standard path for the current user

◆ save_open_direct()

function async save_open_direct ( )

Save the app in-place and then open it by blob ID.

◆ send()

function send (   value)

Send a message to the app.

Parameters
valueThe message.

◆ set_hidden()

function set_hidden (   id,
  hide 
)

Hide or unhide a DOM element with the given id.

Parameters
idThe element ID.
hidetrue to hide the element or false to show it.

◆ setStatusMessage()

function setStatusMessage (   message,
  color 
)

Set the status message.

Parameters
messageThe message.
colorThe message's color.

◆ sourcePretty()

function async sourcePretty ( )

Prettify the current source file.

◆ toggleVisibleWhitespace()

function toggleVisibleWhitespace ( )

Toggle visible whitespace.

◆ update_credentials()

function update_credentials (   credentials)

React to user credentials changing.

Parameters
credentialsCredentials object.

◆ update_html()

function async update_html ( )

Reload any static HTML content in the iframe.

◆ updateFiles()

function updateFiles ( )

Refresh the files list.

◆ url()

function url ( )

Get the current app URL.

Returns
The app URL.

◆ visibilitychange()

function visibilitychange ( )

Notify the app of visibility change. Seems to work when changing apps/tabs where focus/blur doesn't on mobile.

Variable Documentation

◆ k_api

const k_api
Initial value:
= {
setDocument: {args: ['content'], func: api_setDocument},
postMessage: {args: ['message'], func: api_postMessage},
error: {args: ['error'], func: api_error},
localStorageSet: {args: ['key', 'value'], func: api_localStorageSet},
localStorageGet: {args: ['key'], func: api_localStorageGet},
requestPermission: {
args: ['permission', 'id', 'description'],
},
print: {args: ['...'], func: api_print},
setHash: {args: ['hash'], func: api_setHash},
getHash: {args: [], func: api_getHash},
}
function api_localStorageGet(key)
Definition client.js:1333
function api_error(error)
Definition client.js:1305
function api_setHash(hash)
Definition client.js:1440
function api_postMessage(message)
Definition client.js:1296
function api_setDocument(content)
Definition client.js:1287
function api_print()
Definition client.js:1424
function api_getHash(hash)
Definition client.js:1432
function api_localStorageSet(key, value)
Definition client.js:1324
function api_requestPermission(permission, description)
Definition client.js:1343

Functions that server-side app code can call through the app object.