kopia lustrzana https://github.com/backface/turtlestitch
removed incomplete api documentation from the source code
rodzic
b60127ccf6
commit
88f648a6c3
|
@ -62,6 +62,7 @@
|
|||
|
||||
### 2021-11-16
|
||||
* store, gui: updated serializer app tag to v7
|
||||
* api: removed incomplete api documentation from the source code
|
||||
|
||||
### 2021-11-15
|
||||
* German translation update
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<script src="src/store.js?version=2021-11-16"></script>
|
||||
<script src="src/locale.js?version=2021-11-15"></script>
|
||||
<script src="src/cloud.js?version=2021-02-04"></script>
|
||||
<script src="src/api.js?version=2021-07-05"></script>
|
||||
<script src="src/api.js?version=2021-11-16"></script>
|
||||
<script src="src/sha512.js?version=2019-06-27"></script>
|
||||
<script src="src/FileSaver.min.js?version=2019-06-27"></script>
|
||||
<script>
|
||||
|
|
173
src/api.js
173
src/api.js
|
@ -32,173 +32,10 @@
|
|||
|
||||
documentation
|
||||
-------------
|
||||
the experimental Snap! API is a set of methods for an IDE_Morph containing
|
||||
a Snap! project. These methods are maintained to work with future versions
|
||||
of Snap! They can be used to trigger scripts, get feedback from running
|
||||
scripts, and access the project's global variables. Currently the API
|
||||
consists of the following methods:
|
||||
|
||||
Broadcast Messages (and optionally wait)
|
||||
|
||||
- IDE_Morph.prototype.broadcast()
|
||||
|
||||
Listen to Messages
|
||||
|
||||
- IDE_Morph.prototype.addMessageListenerForAll()
|
||||
- IDE_Morph.prototype.addMessageListener()
|
||||
- IDE_Morph.prototype.getMessages()
|
||||
|
||||
Access Global Variables
|
||||
|
||||
- IDE_Morph.prototype.getVarNames()
|
||||
- IDE_Morph.prototype.getVar()
|
||||
- IDE_Morph.prototype.setVar()
|
||||
|
||||
Create and Modify Lists
|
||||
|
||||
- IDE_Morph.prototype.newList()
|
||||
|
||||
Access the Serialized Project
|
||||
|
||||
- IDE_Morph.prototype.getProjectXML()
|
||||
- IDE_Morph.prototype.loadProjectXML(projectXML)
|
||||
- IDE_Morph.prototype.unsavedChanges()
|
||||
|
||||
Getting hold of an ide can usually be achieved by
|
||||
evaluating:
|
||||
|
||||
var ide = world.children[0];
|
||||
|
||||
|
||||
IDE_Morph.prototype.broadcast()
|
||||
===============================
|
||||
The broadcast() method triggers all scripts whose hat block listens to
|
||||
the specified message. An optional callback can be added to be run
|
||||
after all triggered scripts have terminated.
|
||||
|
||||
syntax:
|
||||
-------
|
||||
ide.broadcast(message [, callback]);
|
||||
|
||||
parameters:
|
||||
-----------
|
||||
message
|
||||
string, the message to be sent to all listeners
|
||||
callback | optional
|
||||
function to execute after all scripts terminate, no arguments
|
||||
|
||||
return value:
|
||||
-------------
|
||||
undefined
|
||||
|
||||
|
||||
IDE_Morph.prototype.addMessageListenerForAll()
|
||||
==============================================
|
||||
The addMessageListenerForAll() method sets up a function that will be
|
||||
called whenever a message is broadcast. The function takes one argument,
|
||||
the message being broadcast, and can be used to react to any message.
|
||||
Multiple message listeners can be set up, they all the executed in the
|
||||
order in which they were added.
|
||||
|
||||
syntax:
|
||||
-------
|
||||
ide.addMessageListenerForAll(callback);
|
||||
|
||||
parameters:
|
||||
-----------
|
||||
callback
|
||||
function to execute whenever a message is sent,
|
||||
takes one argument: The message string
|
||||
|
||||
return value:
|
||||
-------------
|
||||
undefined
|
||||
|
||||
|
||||
IDE_Morph.prototype.addMessageListener()
|
||||
========================================
|
||||
The addMessageListener() method sets up a function that will be called
|
||||
whenever the specified message is broadcast. Multiple message listeners
|
||||
can be set up per message, they all get executed in the order in which
|
||||
they were added.
|
||||
|
||||
syntax:
|
||||
-------
|
||||
ide.addMessageListener(message, callback);
|
||||
|
||||
parameters:
|
||||
-----------
|
||||
message
|
||||
string, the message to which the listener will react.
|
||||
If the message is an empty string the callback will
|
||||
be executed at any broadcast, passing the message as
|
||||
argument
|
||||
callback
|
||||
function to execute whenever the specified message is sent,
|
||||
takes no argument, except when the message to listen to is
|
||||
the empty string, then it takes the message as argument
|
||||
|
||||
return value:
|
||||
-------------
|
||||
undefined
|
||||
|
||||
|
||||
IDE_Morph.prototype.getMessages()
|
||||
=================================
|
||||
The getMessage() method returns a new Array that contains all the message
|
||||
strings that occur in the project, both in hat blocks and in broadcast
|
||||
blocks.
|
||||
|
||||
syntax:
|
||||
-------
|
||||
ide.getMessages();
|
||||
|
||||
return value:
|
||||
-------------
|
||||
an Array of strings, or an empty Array
|
||||
|
||||
|
||||
IDE_Morph.prototype.getVarNames()
|
||||
=================================
|
||||
The getVarNames() method returns a new Array that contains all the global
|
||||
variable names in the project.
|
||||
|
||||
syntax:
|
||||
-------
|
||||
ide.getVarNames();
|
||||
|
||||
return value:
|
||||
-------------
|
||||
an Array of strings, or an empty Array
|
||||
|
||||
|
||||
IDE_Morph.prototype.getVar()
|
||||
=============================
|
||||
The getVar() method returns the value of the global variable indicated by
|
||||
the specified name.
|
||||
|
||||
syntax:
|
||||
-------
|
||||
ide.getVar(name);
|
||||
|
||||
return value:
|
||||
-------------
|
||||
whatever value the variable holds.
|
||||
|
||||
|
||||
IDE_Morph.prototype.setVar()
|
||||
============================
|
||||
The setVar() methods assigns a value to the a global variable specified
|
||||
by name.
|
||||
|
||||
syntax:
|
||||
=======
|
||||
ide.setVar(name, value);
|
||||
|
||||
return value:
|
||||
=============
|
||||
undefined
|
||||
|
||||
along with this file you should have received a copy of the Snap! API
|
||||
documentation. If not, see
|
||||
https://github.com/jmoenig/Snap/blob/master/API.md
|
||||
or https://snap.berkeley.edu/snap/API.md
|
||||
|
||||
*/
|
||||
|
||||
|
@ -208,7 +45,7 @@
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.api = '2021-July-05';
|
||||
modules.api = '2021-November-16';
|
||||
|
||||
// IDE_Morph external communication API - experimental
|
||||
/*
|
||||
|
|
Ładowanie…
Reference in New Issue