From 99815dd54734d88c0314c3ea10b62f5d74b245cf Mon Sep 17 00:00:00 2001 From: Bernat Romagosa Date: Mon, 17 Dec 2018 12:41:10 +0100 Subject: [PATCH] added remix functionality --- src/cloud.js | 22 ++-------------------- src/gui.js | 6 ++++-- src/store.js | 7 ++++--- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/cloud.js b/src/cloud.js index 6d242ddf..4135c21e 100755 --- a/src/cloud.js +++ b/src/cloud.js @@ -413,7 +413,8 @@ Cloud.prototype.saveProject = function (ide, onSuccess, onError) { xml: xml, media: ide.hasChangedMedia ? ide.serializer.mediaXML(ide.projectName) : null, - thumbnail: thumbnail + thumbnail: thumbnail, + remixID: ide.stage.remixID }; ide.serializer.isCollectingMedia = false; ide.serializer.flushMedia(); @@ -711,25 +712,6 @@ Cloud.prototype.unpublishProject = function ( ); }; -Cloud.prototype.remixProject = function ( - projectName, - username, - onSuccess, - onError -) { - this.withCredentialsRequest( - 'POST', - '/projects/' + - encodeURIComponent(username) + - '/' + - encodeURIComponent(projectName) + - '/remix', - onSuccess, - onError, - 'Could not remix project' - ); -}; - Cloud.prototype.updateNotes = function ( projectName, notes, diff --git a/src/gui.js b/src/gui.js index 3915aa39..a0708d3b 100644 --- a/src/gui.js +++ b/src/gui.js @@ -4361,7 +4361,8 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) { this.serializer.openProject( this.serializer.loadProjectModel( model.childNamed('project'), - this + this, + model.attributes.remixID ), this ); @@ -4374,7 +4375,8 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) { this.serializer.openProject( this.serializer.loadProjectModel( model.childNamed('project'), - this + this, + model.attributes.remixID ), this ); diff --git a/src/store.js b/src/store.js index 4193f67c..de73d673 100644 --- a/src/store.js +++ b/src/store.js @@ -316,7 +316,7 @@ SnapSerializer.prototype.load = function (xmlString, ide) { return this.loadProjectModel(this.parse(xmlString), ide); }; -SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide) { +SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide, remixID) { // public - answer a new Project represented by the given XML top node // show a warning if the origin apps differ @@ -331,10 +331,10 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide) { '\n\nand may be incompatible or fail to load here.' ); } - return this.rawLoadProjectModel(xmlNode); + return this.rawLoadProjectModel(xmlNode, remixID); }; -SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { +SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) { // private var myself = this, project = {sprites: {}}, @@ -376,6 +376,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { model.stage = model.project.require('stage'); StageMorph.prototype.frameRate = 0; project.stage = new StageMorph(project.globalVariables); + project.stage.remixID = remixID; if (Object.prototype.hasOwnProperty.call( model.stage.attributes, 'id'