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