Tilde Friends client-side browser JavaScript.
◆ _receive_websocket_message()
function _receive_websocket_message |
( |
|
message | ) |
|
Process an incoming WebSocket message.
- Parameters
-
◆ 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
-
◆ api_localStorageGet()
function api_localStorageGet |
( |
|
key | ) |
|
Get a value from local storage.
- Parameters
-
- Returns
- The value.
◆ api_localStorageSet()
function api_localStorageSet |
( |
|
key, |
|
|
|
value |
|
) |
| |
et a value in local storage.
- Parameters
-
key | The key. |
value | The value. |
◆ api_postMessage()
function api_postMessage |
( |
|
message | ) |
|
Send a message to the sandboxed iframe.
- Parameters
-
◆ api_print()
Log from the app to the console.
◆ api_requestPermission()
function api_requestPermission |
( |
|
permission, |
|
|
|
id |
|
) |
| |
Request a permission
- Parameters
-
permission | The permission to request. |
id | The 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
-
◆ api_setHash()
function api_setHash |
( |
|
hash | ) |
|
Set the window's location hash.
- Parameters
-
◆ 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()
Notify the app of lost focus.
◆ changeIcon()
Prompt to set the app icon.
◆ closeEditor()
◆ connectSocket()
function connectSocket |
( |
|
path | ) |
|
Connect the WebSocket.
- Parameters
-
path | The path to which to connect. |
◆ deleteApp()
Prompt to delete the current app.
◆ edit()
◆ 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
-
nodes | An array of descriptions of dependencies to load. |
callback | Called when all dependencies are loaded. |
◆ focus()
Make sure the app is connected on window focus, and notify the app.
◆ hash()
Get the window hash without the lone '#' if it is empty.
- Returns
- The hash.
◆ 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
-
path | The app path to load. |
- Returns
- A promise resolved when the app is laoded.
◆ loadFile()
function loadFile |
( |
|
name, |
|
|
|
id |
|
) |
| |
Load a single file.
- Parameters
-
name | The name by which the file is known. |
id | The 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
-
◆ message()
function message |
( |
|
event | ) |
|
Handle a message.
- Parameters
-
◆ newFile()
Prompt to create a new file.
◆ openFile()
function openFile |
( |
|
name | ) |
|
Open a file by name.
- Parameters
-
◆ reconnect()
function reconnect |
( |
|
path | ) |
|
Reconnect the WebSocket.
- Parameters
-
path | The path to which the WebSocket should be connected. |
◆ removeFile()
◆ save()
Save the app.
- Parameters
-
save_to | An 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
-
name | The file to svae. |
file | The file contents. |
- Returns
- A promise resolved with the blob ID of the saved file.
◆ send()
Send a message to the app.
- Parameters
-
◆ setStatusMessage()
function setStatusMessage |
( |
|
message, |
|
|
|
color |
|
) |
| |
Set the status message.
- Parameters
-
message | The message. |
color | The message's color. |
◆ sourcePretty()
function async sourcePretty |
( |
| ) |
|
Prettify the current source file.
◆ toggleVisibleWhitespace()
function toggleVisibleWhitespace |
( |
| ) |
|
Toggle visible whitespace.
◆ trace()
Open a performance trace.
◆ updateFiles()
◆ url()
Get the current app URL.
- Returns
- The app URL.
◆ k_api
Initial value:= {
}
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.