From b68194a0dc3c62b0a6ea2376974e1d700689772a Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Wed, 30 Sep 2020 16:07:49 +0200 Subject: [PATCH 01/12] logic for global event --- Sequence.js | 22 ++++++++++++++++++++++ event.js | 8 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Sequence.js b/Sequence.js index 883d7c4..d7193d1 100644 --- a/Sequence.js +++ b/Sequence.js @@ -17,12 +17,33 @@ var Sequence = function (expData) { this.type = "Sequence"; this.name = ko.observable("Sequence"); this.workspaceVars = ko.observableArray([]).extend({ sortById: null }); + this.globalEvents = ko.observableArray([]); // sub-Structures (serialized below) this.elements = ko.observableArray().extend({ sortById: null }); }; +Sequence.prototype.getGlobalEvents = function () { + var events = []; + var elements = this.elements(); + for (var i = 0; i < elements.length; i++) { + var frame_events = elements[i].events(); + for (var j = 0; j < frame_events.length; j++) { + if (frame_events[j].isGlobal() == 'true') { + events.push(frame_events[j]); + } + } + } + console.log(this.currSelectedElement()); + for (var i = 0; i < elements.length; i++) { + for (var j = 0; j < events.length; j++) { + elements[i].events().push(events[j]); + } + } + this.elements(elements); + console.log(events); +} Sequence.prototype.dispose = function () { this.elements().forEach(function (elem) { elem.dispose(); @@ -198,6 +219,7 @@ Sequence.prototype.setPointers = function (entitiesArr) { return entitiesArr.byId[id]; })); + this.getGlobalEvents(); // converter to add all old existing factors to workspace only in editor //if(window.uc!==undefined){ // this.addAllRemainingFactorToWorkspace(); diff --git a/event.js b/event.js index 2537737..9738260 100644 --- a/event.js +++ b/event.js @@ -17,6 +17,7 @@ var ExpEvent = function (parent) { this.actions = ko.observableArray([]); this.name = ko.observable(null); this.description = ko.observable('event description'); + this.isGlobal = ko.observable(false); this.shortName = ko.computed(function () { if (self.name()) { @@ -226,7 +227,11 @@ ExpEvent.prototype.fromJS = function (data) { if (data.requirement) { this.requirementConverter(data); } + if (data.hasOwnProperty('isGlobal')) { + this.isGlobal(data.isGlobal); + } + console.log(data.isGlobal) @@ -264,7 +269,8 @@ ExpEvent.prototype.toJS = function () { type: this.type, trigger: this.trigger().toJS(), actions: actionData, - description: this.description() + description: this.description(), + isGlobal: this.isGlobal(), }; }; From 8ce5408aefbddd79d5841f444e2147f9be90de2a Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Thu, 1 Oct 2020 14:19:33 +0200 Subject: [PATCH 02/12] adding random id for isGlobal true --- Sequence.js | 13 +++++++++---- event.js | 11 +++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Sequence.js b/Sequence.js index d7193d1..3ac85ad 100644 --- a/Sequence.js +++ b/Sequence.js @@ -30,19 +30,24 @@ Sequence.prototype.getGlobalEvents = function () { for (var i = 0; i < elements.length; i++) { var frame_events = elements[i].events(); for (var j = 0; j < frame_events.length; j++) { - if (frame_events[j].isGlobal() == 'true') { + if (frame_events[j].isGlobal() !== false) { events.push(frame_events[j]); } } } - console.log(this.currSelectedElement()); for (var i = 0; i < elements.length; i++) { + var tmp_events = elements[i].events(); for (var j = 0; j < events.length; j++) { - elements[i].events().push(events[j]); + var checkInArray = tmp_events.findIndex(function (element) { + return element.isGlobal() === events[j].isGlobal(); + }) + if (checkInArray === -1) { + tmp_events.push(events[j]); + } } + elements[i].events(tmp_events); } this.elements(elements); - console.log(events); } Sequence.prototype.dispose = function () { this.elements().forEach(function (elem) { diff --git a/event.js b/event.js index 9738260..dffa9fe 100644 --- a/event.js +++ b/event.js @@ -31,6 +31,17 @@ var ExpEvent = function (parent) { }; +ExpEvent.prototype.switchGlobal = function (data, event) { + if (event.target.value == 'false') { + data.event.isGlobal(false); + } + else { + var id = Math.floor(Math.random() * 999999999999999999999); + data.event.isGlobal(id); + } + console.log(data.event.isGlobal()); +} + /** * delete the action at the specified index. * @param {number} index From ea7057e3b4e8ccb69a35d364e0e781c40a59e940 Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Fri, 2 Oct 2020 16:27:55 +0200 Subject: [PATCH 03/12] adding globalEvents --- Sequence.js | 40 +++++++++++++--------------------------- event.js | 6 +----- frameData.js | 7 ++++++- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/Sequence.js b/Sequence.js index 3ac85ad..043ee30 100644 --- a/Sequence.js +++ b/Sequence.js @@ -24,31 +24,6 @@ var Sequence = function (expData) { }; -Sequence.prototype.getGlobalEvents = function () { - var events = []; - var elements = this.elements(); - for (var i = 0; i < elements.length; i++) { - var frame_events = elements[i].events(); - for (var j = 0; j < frame_events.length; j++) { - if (frame_events[j].isGlobal() !== false) { - events.push(frame_events[j]); - } - } - } - for (var i = 0; i < elements.length; i++) { - var tmp_events = elements[i].events(); - for (var j = 0; j < events.length; j++) { - var checkInArray = tmp_events.findIndex(function (element) { - return element.isGlobal() === events[j].isGlobal(); - }) - if (checkInArray === -1) { - tmp_events.push(events[j]); - } - } - elements[i].events(tmp_events); - } - this.elements(elements); -} Sequence.prototype.dispose = function () { this.elements().forEach(function (elem) { elem.dispose(); @@ -224,7 +199,6 @@ Sequence.prototype.setPointers = function (entitiesArr) { return entitiesArr.byId[id]; })); - this.getGlobalEvents(); // converter to add all old existing factors to workspace only in editor //if(window.uc!==undefined){ // this.addAllRemainingFactorToWorkspace(); @@ -296,12 +270,18 @@ Sequence.prototype.reAddEntities = function (entitiesArr) { * @returns {Sequence} */ Sequence.prototype.fromJS = function (data) { + console.log(data); this.id(data.id); this.name(data.name); this.elements(data.elements); if (data.hasOwnProperty("workspaceVars")) { this.workspaceVars(data.workspaceVars); } + if (data.hasOwnProperty(this.globalEvents)) { + this.globalEvents(jQuery.map(data.globalEvents, function (eventData) { + return (new ExpEvent(self)).fromJS(eventData); + })); + } return this; }; @@ -310,11 +290,17 @@ Sequence.prototype.fromJS = function (data) { * @returns {object} */ Sequence.prototype.toJS = function () { + var tmp = jQuery.map(this.globalEvents(), function (event) { + return event.toJS(); + }); + console.log(tmp); return { id: this.id(), type: this.type, name: this.name(), elements: jQuery.map(this.elements(), function (elem) { return elem.id(); }), - workspaceVars: jQuery.map(this.workspaceVars(), function (variable) { return variable.id(); }) + workspaceVars: jQuery.map(this.workspaceVars(), function (variable) { return variable.id(); }), + globalEvents: tmp, + }; }; diff --git a/event.js b/event.js index dffa9fe..d44bd11 100644 --- a/event.js +++ b/event.js @@ -36,10 +36,8 @@ ExpEvent.prototype.switchGlobal = function (data, event) { data.event.isGlobal(false); } else { - var id = Math.floor(Math.random() * 999999999999999999999); - data.event.isGlobal(id); + data.event.isGlobal(true); } - console.log(data.event.isGlobal()); } /** @@ -242,8 +240,6 @@ ExpEvent.prototype.fromJS = function (data) { this.isGlobal(data.isGlobal); } - console.log(data.isGlobal) - return this; diff --git a/frameData.js b/frameData.js index 58ba433..4bff1a6 100644 --- a/frameData.js +++ b/frameData.js @@ -293,6 +293,11 @@ FrameData.prototype.fromJS = function (data) { * @returns {object} */ FrameData.prototype.toJS = function () { + + var events = this.events(); + events = events.filter(function (element) { + return !element.isGlobal(); + }); return { id: this.id(), type: this.type, @@ -308,7 +313,7 @@ FrameData.prototype.toJS = function () { syncFrame: this.syncFrame(), emotionFeedbackEnabled: this.emotionFeedbackEnabled(), emotionOffset: this.emotionOffset(), - events: jQuery.map(this.events(), function (event) { + events: jQuery.map(events, function (event) { return event.toJS(); }), elements: jQuery.map(this.elements(), function (elem) { return elem.id(); }), From 43a106888659195e8d11b4d5b5c4adc00859c6c8 Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Mon, 5 Oct 2020 18:05:11 +0200 Subject: [PATCH 04/12] adding set pointers and reAddEntites --- Sequence.js | 64 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/Sequence.js b/Sequence.js index 043ee30..e1a1c27 100644 --- a/Sequence.js +++ b/Sequence.js @@ -199,18 +199,33 @@ Sequence.prototype.setPointers = function (entitiesArr) { return entitiesArr.byId[id]; })); + jQuery.each(this.globalEvents(), function (idx, event) { + event.setPointers(entitiesArr); + }); + // converter to add all old existing factors to workspace only in editor //if(window.uc!==undefined){ // this.addAllRemainingFactorToWorkspace(); //} - - }; Sequence.prototype.onFinishedLoading = function () { this.addAllRemainingFactorToWorkspace(); }; +Sequence.prototype.reAddWorkspace = function () { + var self = this; + var tmpEntities = ko.observableArray([]).extend({ sortById: null }); + this.reAddEntities(tmpEntities); + jQuery.each(tmpEntities(), function (idx, entity) { + if (entity instanceof GlobalVar) { + if (!self.workspaceVars.byId.hasOwnProperty(entity.id())) { + self.workspaceVars.push(entity); + } + } + }); +}; + Sequence.prototype.addVariableToWorkspace = function (variable) { var isExisting = this.workspaceVars.byId[variable.id()]; if (!isExisting) { @@ -249,14 +264,28 @@ Sequence.prototype.reAddEntities = function (entitiesArr) { // add the direct child nodes: jQuery.each(this.elements(), function (index, elem) { entitiesArr.insertIfNotExist(elem); + if (!entitiesArr.byId.hasOwnProperty(elem.id())) { + entitiesArr.push(elem); + } // recursively make sure that all deep tree nodes are in the entities list: - if (elem.reAddEntities) + if (elem.reAddEntities) { elem.reAddEntities(entitiesArr); + } + }); + // add the direct child nodes: + jQuery.each(this.globalEvents(), function (index, evt) { + // recursively make sure that all deep tree nodes are in the entities list: + if (evt.reAddEntities) { + evt.reAddEntities(entitiesArr); + } }); - // add the direct child nodes: jQuery.each(this.workspaceVars(), function (index, elem) { + // check if they are not already in the list: + if (!entitiesArr.byId.hasOwnProperty(elem.id())) { + entitiesArr.push(elem); + } entitiesArr.insertIfNotExist(elem); }); @@ -270,19 +299,23 @@ Sequence.prototype.reAddEntities = function (entitiesArr) { * @returns {Sequence} */ Sequence.prototype.fromJS = function (data) { - console.log(data); + var self = this; this.id(data.id); this.name(data.name); this.elements(data.elements); if (data.hasOwnProperty("workspaceVars")) { this.workspaceVars(data.workspaceVars); } - if (data.hasOwnProperty(this.globalEvents)) { - this.globalEvents(jQuery.map(data.globalEvents, function (eventData) { - return (new ExpEvent(self)).fromJS(eventData); - })); - } + this.globalEvents(jQuery.map(data.globalEvents, function (eventData) { + return (new ExpEvent(self)).fromJS(eventData); + })); + // if (data.hasOwnProperty(this.globalEvents)) { + // this.globalEvents(jQuery.map(data.globalEvents, function (eventData) { + // return (new ExpEvent(self)).fromJS(eventData); + // })); + // } return this; + }; /** @@ -290,17 +323,20 @@ Sequence.prototype.fromJS = function (data) { * @returns {object} */ Sequence.prototype.toJS = function () { - var tmp = jQuery.map(this.globalEvents(), function (event) { - return event.toJS(); + var globalEvents = this.globalEvents(); + globalEvents = globalEvents.filter(function (element) { + return element.isGlobal(); }); - console.log(tmp); + return { id: this.id(), type: this.type, name: this.name(), elements: jQuery.map(this.elements(), function (elem) { return elem.id(); }), workspaceVars: jQuery.map(this.workspaceVars(), function (variable) { return variable.id(); }), - globalEvents: tmp, + globalEvents: jQuery.map(globalEvents, function (event) { + return event.toJS(); + }), }; }; From 568252354b7011176b3b9a3bd75c04ea9f6b3c1c Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Tue, 6 Oct 2020 16:15:39 +0200 Subject: [PATCH 05/12] small changes --- Sequence.js | 9 --------- frameData.js | 22 ++++++++++++++++++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Sequence.js b/Sequence.js index e1a1c27..1f4e386 100644 --- a/Sequence.js +++ b/Sequence.js @@ -309,11 +309,6 @@ Sequence.prototype.fromJS = function (data) { this.globalEvents(jQuery.map(data.globalEvents, function (eventData) { return (new ExpEvent(self)).fromJS(eventData); })); - // if (data.hasOwnProperty(this.globalEvents)) { - // this.globalEvents(jQuery.map(data.globalEvents, function (eventData) { - // return (new ExpEvent(self)).fromJS(eventData); - // })); - // } return this; }; @@ -324,10 +319,6 @@ Sequence.prototype.fromJS = function (data) { */ Sequence.prototype.toJS = function () { var globalEvents = this.globalEvents(); - globalEvents = globalEvents.filter(function (element) { - return element.isGlobal(); - }); - return { id: this.id(), type: this.type, diff --git a/frameData.js b/frameData.js index 4bff1a6..f4fdcd4 100644 --- a/frameData.js +++ b/frameData.js @@ -161,7 +161,8 @@ FrameData.prototype.getAllModifiers = function (modifiersArr) { */ FrameData.prototype.setPointers = function (entitiesArr) { var self = this; - + console.log("Elements SETPOINTERS -b") + console.log(this.events()); // convert ids to actual pointers: this.elements(jQuery.map(this.elements(), function (id) { var elem = entitiesArr.byId[id]; @@ -183,9 +184,21 @@ FrameData.prototype.setPointers = function (entitiesArr) { return localVar; })); + // for (var i = 0; i < this.parent.globalEvents(); i++) { + // console.log('cos'); + // } + // why after interation in array the parent is null? + console.log("CZY TU JEST NULL"); + console.log(this); + // jQuery.each(this.parent.globalEvents(), function (index, evt) { + // evt.parent = self; + // self.events().push(evt); + // }) + jQuery.each(this.events(), function (idx, event) { event.setPointers(entitiesArr); }); + }; /** @@ -235,6 +248,12 @@ FrameData.prototype.reAddEntities = function (entitiesArr) { } }); + var self = this; + jQuery.each(this.parent.globalEvents(), function (index, evt) { + evt.parent = self; + self.events().push(evt); + }) + console.log(this.events()); // add the direct child nodes: jQuery.each(this.localWorkspaceVars(), function (index, elem) { // check if they are not already in the list: @@ -293,7 +312,6 @@ FrameData.prototype.fromJS = function (data) { * @returns {object} */ FrameData.prototype.toJS = function () { - var events = this.events(); events = events.filter(function (element) { return !element.isGlobal(); From c0d499af635d9eb3634dc90751662a4a00f34a41 Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Tue, 6 Oct 2020 16:18:52 +0200 Subject: [PATCH 06/12] remove console logs --- frameData.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/frameData.js b/frameData.js index f4fdcd4..83011c6 100644 --- a/frameData.js +++ b/frameData.js @@ -161,8 +161,6 @@ FrameData.prototype.getAllModifiers = function (modifiersArr) { */ FrameData.prototype.setPointers = function (entitiesArr) { var self = this; - console.log("Elements SETPOINTERS -b") - console.log(this.events()); // convert ids to actual pointers: this.elements(jQuery.map(this.elements(), function (id) { var elem = entitiesArr.byId[id]; @@ -188,17 +186,13 @@ FrameData.prototype.setPointers = function (entitiesArr) { // console.log('cos'); // } // why after interation in array the parent is null? - console.log("CZY TU JEST NULL"); - console.log(this); // jQuery.each(this.parent.globalEvents(), function (index, evt) { // evt.parent = self; // self.events().push(evt); // }) - jQuery.each(this.events(), function (idx, event) { event.setPointers(entitiesArr); }); - }; /** @@ -253,7 +247,6 @@ FrameData.prototype.reAddEntities = function (entitiesArr) { evt.parent = self; self.events().push(evt); }) - console.log(this.events()); // add the direct child nodes: jQuery.each(this.localWorkspaceVars(), function (index, elem) { // check if they are not already in the list: From cac98c7944f442e65caf48cbbab0f661e57cf768 Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Wed, 7 Oct 2020 16:46:52 +0200 Subject: [PATCH 07/12] adding view global events --- event.js | 8 ++++++++ frameData.js | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/event.js b/event.js index d44bd11..bc20773 100644 --- a/event.js +++ b/event.js @@ -40,6 +40,14 @@ ExpEvent.prototype.switchGlobal = function (data, event) { } } +ExpEvent.prototype.getSequence = function () { + if (this.isGlobal()) { + console.log(this.parent); + return this.parent; + } + return this.parent.parent; +} + /** * delete the action at the specified index. * @param {number} index diff --git a/frameData.js b/frameData.js index 83011c6..af01821 100644 --- a/frameData.js +++ b/frameData.js @@ -242,11 +242,6 @@ FrameData.prototype.reAddEntities = function (entitiesArr) { } }); - var self = this; - jQuery.each(this.parent.globalEvents(), function (index, evt) { - evt.parent = self; - self.events().push(evt); - }) // add the direct child nodes: jQuery.each(this.localWorkspaceVars(), function (index, elem) { // check if they are not already in the list: From ef01ec4bda980eab5e72fa659eb5a95434dca68f Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Thu, 8 Oct 2020 18:34:04 +0200 Subject: [PATCH 08/12] delete option --- Sequence.js | 40 ++++++++++++++++++++++++---------------- event.js | 13 +++++++++---- eventTrigger.js | 1 + frameData.js | 8 -------- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Sequence.js b/Sequence.js index 1f4e386..431baba 100644 --- a/Sequence.js +++ b/Sequence.js @@ -25,11 +25,34 @@ var Sequence = function (expData) { }; Sequence.prototype.dispose = function () { + var self = this; this.elements().forEach(function (elem) { - elem.dispose(); + self.deleteChildEntity(elem) + }); + jQuery.each(this.workspaceVars(), function (index, entity) { + entity.removeBackRef(self); }); }; +Sequence.prototype.deleteChildEntity = function (entity) { + var self = this; + if (entity instanceof ExpEvent) { + this.globalEvents.remove(entity); + } + else { + this.elements.remove(entity); + if (typeof entity.dispose === 'function') { + entity.dispose(); + } + self.expData.entities.remove(entity); + } + + // if this element was selected, set selection to null + if (entity === this.currSelectedElement()) { + this.currSelectedElement(null); + } +}; + /** * Select a specific or multiple trial types. * @@ -213,18 +236,6 @@ Sequence.prototype.onFinishedLoading = function () { this.addAllRemainingFactorToWorkspace(); }; -Sequence.prototype.reAddWorkspace = function () { - var self = this; - var tmpEntities = ko.observableArray([]).extend({ sortById: null }); - this.reAddEntities(tmpEntities); - jQuery.each(tmpEntities(), function (idx, entity) { - if (entity instanceof GlobalVar) { - if (!self.workspaceVars.byId.hasOwnProperty(entity.id())) { - self.workspaceVars.push(entity); - } - } - }); -}; Sequence.prototype.addVariableToWorkspace = function (variable) { var isExisting = this.workspaceVars.byId[variable.id()]; @@ -264,9 +275,6 @@ Sequence.prototype.reAddEntities = function (entitiesArr) { // add the direct child nodes: jQuery.each(this.elements(), function (index, elem) { entitiesArr.insertIfNotExist(elem); - if (!entitiesArr.byId.hasOwnProperty(elem.id())) { - entitiesArr.push(elem); - } // recursively make sure that all deep tree nodes are in the entities list: if (elem.reAddEntities) { diff --git a/event.js b/event.js index bc20773..9d03e58 100644 --- a/event.js +++ b/event.js @@ -17,7 +17,7 @@ var ExpEvent = function (parent) { this.actions = ko.observableArray([]); this.name = ko.observable(null); this.description = ko.observable('event description'); - this.isGlobal = ko.observable(false); + this.isGlobal = ko.observable(); this.shortName = ko.computed(function () { if (self.name()) { @@ -33,16 +33,21 @@ var ExpEvent = function (parent) { ExpEvent.prototype.switchGlobal = function (data, event) { if (event.target.value == 'false') { - data.event.isGlobal(false); + var global = data.event.parent + if (global = data.event.parent) { + data.event.isGlobal(false); + } } else { - data.event.isGlobal(true); + var local = data.event.parent.parent; + if (local = data.event.parent.parent) { + data.event.isGlobal(true); + } } } ExpEvent.prototype.getSequence = function () { if (this.isGlobal()) { - console.log(this.parent); return this.parent; } return this.parent.parent; diff --git a/eventTrigger.js b/eventTrigger.js index 7bfa89c..c6fb4b1 100644 --- a/eventTrigger.js +++ b/eventTrigger.js @@ -975,6 +975,7 @@ var TriggerOnFrameStart = function (event) { TriggerOnFrameStart.prototype.type = "TriggerOnFrameStart"; TriggerOnFrameStart.prototype.label = "On Frame Start Trigger"; +TriggerOnFrameStart.prototype.iconPath = "/resources/icons/events/onChangeEvent.svg"; /** * returns true if all settings are valid (used in the editor). diff --git a/frameData.js b/frameData.js index af01821..8ed4fb8 100644 --- a/frameData.js +++ b/frameData.js @@ -182,14 +182,6 @@ FrameData.prototype.setPointers = function (entitiesArr) { return localVar; })); - // for (var i = 0; i < this.parent.globalEvents(); i++) { - // console.log('cos'); - // } - // why after interation in array the parent is null? - // jQuery.each(this.parent.globalEvents(), function (index, evt) { - // evt.parent = self; - // self.events().push(evt); - // }) jQuery.each(this.events(), function (idx, event) { event.setPointers(entitiesArr); }); From e5d6336ee1f4e40e7f08a9d649aaebfb2f2d2e39 Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Fri, 9 Oct 2020 16:02:59 +0200 Subject: [PATCH 09/12] local changes2 --- event.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/event.js b/event.js index 9d03e58..5077b7c 100644 --- a/event.js +++ b/event.js @@ -17,8 +17,6 @@ var ExpEvent = function (parent) { this.actions = ko.observableArray([]); this.name = ko.observable(null); this.description = ko.observable('event description'); - this.isGlobal = ko.observable(); - this.shortName = ko.computed(function () { if (self.name()) { return (self.name().length > 13 ? self.name().substring(0, 12) + '...' : self.name()); @@ -28,23 +26,9 @@ var ExpEvent = function (parent) { // not serialized: this.isPaused = false; - + this.isGlobal = ko.observable(this.parent.constructor.name === 'Sequence' ? true : false); }; -ExpEvent.prototype.switchGlobal = function (data, event) { - if (event.target.value == 'false') { - var global = data.event.parent - if (global = data.event.parent) { - data.event.isGlobal(false); - } - } - else { - var local = data.event.parent.parent; - if (local = data.event.parent.parent) { - data.event.isGlobal(true); - } - } -} ExpEvent.prototype.getSequence = function () { if (this.isGlobal()) { From 9f5f7baa897179db10ce659a368216b3a5fb35dd Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Mon, 12 Oct 2020 14:15:43 +0200 Subject: [PATCH 10/12] local changes --- Sequence.js | 11 +++-------- frameData.js | 1 + 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Sequence.js b/Sequence.js index 431baba..c66ce7a 100644 --- a/Sequence.js +++ b/Sequence.js @@ -26,7 +26,9 @@ var Sequence = function (expData) { Sequence.prototype.dispose = function () { var self = this; + // Delete event instead this.elements().forEach(function (elem) { + // self.deleteChildEntity(elem) }); jQuery.each(this.workspaceVars(), function (index, entity) { @@ -34,18 +36,11 @@ Sequence.prototype.dispose = function () { }); }; -Sequence.prototype.deleteChildEntity = function (entity) { +Sequence.prototype.childEvent = function (entity) { var self = this; if (entity instanceof ExpEvent) { this.globalEvents.remove(entity); } - else { - this.elements.remove(entity); - if (typeof entity.dispose === 'function') { - entity.dispose(); - } - self.expData.entities.remove(entity); - } // if this element was selected, set selection to null if (entity === this.currSelectedElement()) { diff --git a/frameData.js b/frameData.js index 8ed4fb8..1412393 100644 --- a/frameData.js +++ b/frameData.js @@ -161,6 +161,7 @@ FrameData.prototype.getAllModifiers = function (modifiersArr) { */ FrameData.prototype.setPointers = function (entitiesArr) { var self = this; + // convert ids to actual pointers: this.elements(jQuery.map(this.elements(), function (id) { var elem = entitiesArr.byId[id]; From b344dc8440ad11e4ed16e12e09130efbb7a08331 Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Thu, 15 Oct 2020 16:03:07 +0200 Subject: [PATCH 11/12] local changes --- Sequence.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Sequence.js b/Sequence.js index c66ce7a..61b7d4d 100644 --- a/Sequence.js +++ b/Sequence.js @@ -25,19 +25,12 @@ var Sequence = function (expData) { }; Sequence.prototype.dispose = function () { - var self = this; - // Delete event instead this.elements().forEach(function (elem) { - // - self.deleteChildEntity(elem) - }); - jQuery.each(this.workspaceVars(), function (index, entity) { - entity.removeBackRef(self); + elem.dispose(); }); }; -Sequence.prototype.childEvent = function (entity) { - var self = this; +Sequence.prototype.deleteChildEntity = function (entity) { if (entity instanceof ExpEvent) { this.globalEvents.remove(entity); } From dabe93dd5f27ff64e5abafe9ecd665ea29820d3d Mon Sep 17 00:00:00 2001 From: Tobiasz Date: Thu, 15 Oct 2020 17:31:06 +0200 Subject: [PATCH 12/12] observator for radio --- eventActions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eventActions.js b/eventActions.js index 5c56caf..8fec700 100644 --- a/eventActions.js +++ b/eventActions.js @@ -1655,6 +1655,7 @@ var ActionJumpTo = function (event) { this.blockToJumpId = ko.observable(null); this.conditionGroupIdx = ko.observable(null); this.checkRequired = ko.observable(null); + this.jumpTrailType = ko.observable('id'); this.alreadyTriggered = false; }; @@ -1838,6 +1839,9 @@ ActionJumpTo.prototype.fromJS = function (data) { this.checkRequired(data.checkRequired); } + if (data.hasOwnProperty('jumpTrailType')) { + this.jumpTrailType(data.jumpTrailType); + } return this; }; @@ -1864,7 +1868,8 @@ ActionJumpTo.prototype.toJS = function () { trialToJumpId: this.trialToJumpId(), conditionGroupIdx: this.conditionGroupIdx(), blockToJumpId: this.blockToJumpId(), - checkRequired: this.checkRequired() + checkRequired: this.checkRequired(), + jumpTrailType: this.jumpTrailType() }; };