Tilde Friends
Tilde Friends Client JS

Classes

class  TfNavigationElement
 
class  TfFilesElement
 
class  TfFilesPaneElement
 

Functions

customElements define ('tf-navigation', TfNavigationElement)
 
window addEventListener ('keydown', function(event) { if(event.keyCode==83 &&(event.altKey||event.ctrlKey)) { if(editing()) { save();event.preventDefault();} } else if(event.keyCode==66 &&event.altKey) { if(editing()) { closeEditor();event.preventDefault();} } })
 
function ensureLoaded (nodes, callback)
 
function editing ()
 
function is_edit_only ()
 
function async edit ()
 
function trace ()
 
function loadFile (name, id)
 
function async load (path)
 
function closeEditor ()
 
function save (save_to)
 
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, id)
 
function api_print ()
 
function api_setHash (hash)
 
function _receive_websocket_message (message)
 
function setStatusMessage (message, color)
 
function send (value)
 
function hashChange ()
 
function focus ()
 
function blur ()
 
function message (event)
 
function reconnect (path)
 
function connectSocket (path)
 
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.

◆ addEventListener()

ssb addEventListener ( 'keydown'  ,
function(event) { if(event.keyCode==83 &&(event.altKey||event.ctrlKey)) { if(editing()) { save();event.preventDefault();} } else if(event.keyCode==66 &&event.altKey) { if(editing()) { closeEditor();event.preventDefault();} } }   
)

A keyboard key is pressed down.

Register event handlers and connect the WebSocket on load.

◆ api_error()

function api_error (   error)

Show an error.

Parameters
errorThe error.

◆ 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,
  id 
)

Request a permission

Parameters
permissionThe permission to request.
idThe id requeesting the permission.
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.

◆ 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_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.

◆ send()

function send (   value)

Send a message to the app.

Parameters
valueThe message.

◆ 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.

◆ trace()

function trace ( )

Open a performance trace.

◆ updateFiles()

function updateFiles ( )

Refresh the files list.

◆ url()

function url ( )

Get the current app URL.

Returns
The app URL.

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'], func: api_requestPermission},
print: {args: ['...'], func: api_print},
setHash: {args: ['hash'], func: api_setHash},
}
function api_requestPermission(permission, id)
Definition: client.js:1222
function api_localStorageGet(key)
Definition: client.js:1212
function api_error(error)
Definition: client.js:1187
function api_setHash(hash)
Definition: client.js:1299
function api_postMessage(message)
Definition: client.js:1178
function api_setDocument(content)
Definition: client.js:1169
function api_print()
Definition: client.js:1291
function api_localStorageSet(key, value)
Definition: client.js:1203

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