kopia lustrzana https://github.com/backface/turtlestitch
added getProjectXML() method to API
rodzic
c0cdd202c9
commit
81f7461f80
21
API.md
21
API.md
|
@ -1,6 +1,6 @@
|
|||
# The Snap! API
|
||||
|
||||
Jens Mönig, July 07, 2020
|
||||
Jens Mönig, October 20, 2020
|
||||
|
||||
This document describes how Snap! can be accessed from an outside program to start scripts, send and retrieve information. The model use case is embedding interactive Snap! projects in other websites such as MOOCs or other adaptive learning platforms.
|
||||
|
||||
|
@ -28,6 +28,10 @@ Currently the API consists of the following methods:
|
|||
|
||||
* IDE_Morph.prototype.newList()
|
||||
|
||||
#### Access the Serialized Project
|
||||
|
||||
* IDE_Morph.prototype.getProjectXML()
|
||||
|
||||
## Referencing the IDE
|
||||
|
||||
Getting hold of an ide can usually be achieved by
|
||||
|
@ -113,7 +117,7 @@ The getMessage() method returns a new Array that contains all the message string
|
|||
ide.getMessages();
|
||||
|
||||
#### return value
|
||||
an Array of strings, or an empty Array
|
||||
an Array of Strings, or an empty Array
|
||||
|
||||
|
||||
### IDE_Morph.prototype.getVarNames()
|
||||
|
@ -123,7 +127,7 @@ The getVarNames() method returns a new Array that contains all the global variab
|
|||
ide.getVarNames();
|
||||
|
||||
### return value
|
||||
an Array of strings, or an empty Array
|
||||
an Array of Strings, or an empty Array
|
||||
|
||||
|
||||
### IDE_Morph.prototype.getVar()
|
||||
|
@ -145,6 +149,7 @@ The setVar() methods assigns a value to the a global variable specified by name.
|
|||
#### return value
|
||||
undefined
|
||||
|
||||
|
||||
### IDE_Morph.prototype.newList()
|
||||
The newList() methods returns a new Snap! list. Optionally a source array containing the list elements can be specified.
|
||||
|
||||
|
@ -154,6 +159,16 @@ The newList() methods returns a new Snap! list. Optionally a source array contai
|
|||
#### return value
|
||||
a new Snap! List
|
||||
|
||||
|
||||
### IDE_Morph.prototype.getProjectXML()
|
||||
the getProjectXML() method returns a string in XML format representing the serialized project currently loaded into the IDE.
|
||||
|
||||
#### syntax
|
||||
ide.getProjectXML();
|
||||
|
||||
#### return value
|
||||
an XML String
|
||||
|
||||
## Manipulating Lists
|
||||
|
||||
Snap! lists can be accessed and manipulated through a set of methods described in the file `lists.js`
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* morphic: enabled zero values for menu selection entries
|
||||
* blocks: fixed translation bug for zero-value menu selection entries
|
||||
* Russian translation update, thanks, Pavel!
|
||||
* api: added getProjectXML() method
|
||||
|
||||
### 2020-10-15
|
||||
* new dev version
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<script src="src/store.js?version=2020-07-08"></script>
|
||||
<script src="src/locale.js?version=2020-10-20"></script>
|
||||
<script src="src/cloud.js?version=2020-05-17"></script>
|
||||
<script src="src/api.js?version=2020-07-06"></script>
|
||||
<script src="src/api.js?version=2020-10-20"></script>
|
||||
<script src="src/sha512.js?version=2019-06-27"></script>
|
||||
<script src="src/FileSaver.min.js?version=2019-06-27"></script>
|
||||
<script>
|
||||
|
|
10
src/api.js
10
src/api.js
|
@ -58,6 +58,10 @@
|
|||
|
||||
- IDE_Morph.prototype.newList()
|
||||
|
||||
Access the Serialized Project
|
||||
|
||||
- IDE_Morph.prototype.getProjectXML()
|
||||
|
||||
Getting hold of an ide can usually be achieved by
|
||||
evaluating:
|
||||
|
||||
|
@ -200,7 +204,7 @@
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.api = '2020-July-06';
|
||||
modules.api = '2020-October-20';
|
||||
|
||||
// IDE_Morph external communication API - experimental
|
||||
/*
|
||||
|
@ -313,3 +317,7 @@ IDE_Morph.prototype.newList = function (array) {
|
|||
// nested array will not be automatically converted to nested lists
|
||||
return new List(array);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.getProjectXML = function () {
|
||||
return this.serializer.serialize(this.stage);
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue