From 9e5fb9a4cba980c977d4e11e5c9a4e7f9c8596db Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Sat, 25 Oct 2014 02:03:12 -0700 Subject: Set location.hash to cloud URLs on project shares This will make it much easier to get the URL for a shared project. It also removes the # from the URL when the open project is unshared." --- gui.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gui.js b/gui.js index 04481cc..6052953 100644 --- a/gui.js +++ b/gui.js @@ -4864,6 +4864,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, + ide = this.siblings()[0], proj = this.listField.selected, entry = this.listField.active; @@ -4894,6 +4895,15 @@ ProjectDialogMorph.prototype.shareProject = function () { myself.ide.cloudError(), [proj.ProjectName] ); + // Set the Shared URL if the project is currently open + if (proj.ProjectName === ide.projectName) { + var usr = SnapCloud.username, + projectId = 'Username=' + + encodeURIComponent(usr.toLowerCase()) + + '&ProjectName=' + + encodeURIComponent(ide.projectName); + location.hash = projectId; + } }, myself.ide.cloudError() ); @@ -4904,6 +4914,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, + ide = this.siblings()[0], proj = this.listField.selected, entry = this.listField.active; @@ -4935,6 +4946,10 @@ ProjectDialogMorph.prototype.unshareProject = function () { myself.ide.cloudError(), [proj.ProjectName] ); + // Remove the shared URL if the project is open. + if (proj.ProjectName === ide.projectName) { + location.hash = ''; + } }, myself.ide.cloudError() ); -- cgit v1.3.1 From e892ea80cb627961a0f84ebe61b7610528f67090 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 24 Nov 2014 15:23:40 -0800 Subject: Shared URLs: remove call to .siblings() Project dialog morphs reference `ide` directly instead of using a function call --- gui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index f53d597..d80e61a 100644 --- a/gui.js +++ b/gui.js @@ -4865,7 +4865,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, - ide = this.siblings()[0], + ide = this.ide, proj = this.listField.selected, entry = this.listField.active; @@ -4902,7 +4902,7 @@ ProjectDialogMorph.prototype.shareProject = function () { projectId = 'Username=' + encodeURIComponent(usr.toLowerCase()) + '&ProjectName=' + - encodeURIComponent(ide.projectName); + encodeURIComponent(proj.projectName); location.hash = projectId; } }, @@ -4915,7 +4915,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, - ide = this.siblings()[0], + ide = this.ide, proj = this.listField.selected, entry = this.listField.active; -- cgit v1.3.1