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."
pull/3/merge
Michael Ball 2014-10-25 02:03:12 -07:00
rodzic 5f3279990b
commit 9e5fb9a4cb
1 zmienionych plików z 15 dodań i 0 usunięć

15
gui.js
Wyświetl plik

@ -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()
);