-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel.js
More file actions
50 lines (43 loc) · 1.3 KB
/
level.js
File metadata and controls
50 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// � by Caspar Goeke and Holger Finger
/**
* a level of a factor.
*
* @param {string} name - the name of the level
* @constructor
*/
var Level = function (globalVar) {
this.type = "Level";
this.name = ko.observable("");
// not serialized
this.editName = ko.observable(false);
this.globalVar = globalVar;
};
/**
* This function initializes all internal state variables to point to other instances in the same experiment. Usually
* this is called after ALL experiment instances were deserialized using fromJS(). In this function use
* 'entitiesArr.byId[id]' to retrieve an instance from the global list given some unique id.
*
* @param {ko.observableArray} entitiesArr - this is the knockout array that holds all instances.
*/
Level.prototype.setPointers = function (entitiesArr) {
};
/**
* load from a json object to deserialize the states.
* @param {object} data - the json description of the states.
* @returns {Level}
*/
Level.prototype.fromJS = function (data) {
this.name(data.name);
this.type = data.type;
return this;
};
/**
* serialize the state of this instance into a json object, which can later be restored using the method fromJS.
* @returns {object}
*/
Level.prototype.toJS = function () {
return {
name: this.name(),
type: this.type
};
};