kopia lustrzana https://github.com/backface/turtlestitch
Loading shared cloud projects in presentation mode
and exporting URLs for shared projectspull/3/merge
rodzic
18821f7bc1
commit
8f249e63bb
58
cloud.js
58
cloud.js
|
@ -29,7 +29,7 @@
|
|||
|
||||
/*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/
|
||||
|
||||
modules.cloud = '2013-April-02';
|
||||
modules.cloud = '2013-April-04';
|
||||
|
||||
// Global stuff
|
||||
|
||||
|
@ -37,6 +37,8 @@ var Cloud;
|
|||
|
||||
var SnapCloud = new Cloud(
|
||||
'https://snapcloud.miosoft.com/miocon/app/login?_app=SnapCloud'
|
||||
// '192.168.2.108:8087/miocon/app/login?_app=SnapCloud'
|
||||
// 'localhost/miocon/app/login?_app=SnapCloud'
|
||||
);
|
||||
|
||||
// Cloud /////////////////////////////////////////////////////////////
|
||||
|
@ -118,6 +120,60 @@ Cloud.prototype.signup = function (
|
|||
}
|
||||
};
|
||||
|
||||
Cloud.prototype.getPublicProject = function (
|
||||
id,
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
// id is Username=username&projectName=projectname,
|
||||
// where the values are url-component encoded
|
||||
// callBack is a single argument function, errorCall take two args
|
||||
var request = new XMLHttpRequest(),
|
||||
myself = this;
|
||||
try {
|
||||
request.open(
|
||||
"GET",
|
||||
(this.hasProtocol() ? '' : 'http://')
|
||||
+ this.url + 'Public'
|
||||
+ '&'
|
||||
+ id,
|
||||
true
|
||||
);
|
||||
request.setRequestHeader(
|
||||
"Content-Type",
|
||||
"application/x-www-form-urlencoded"
|
||||
);
|
||||
request.withCredentials = true;
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4) {
|
||||
if (request.responseText) {
|
||||
if (request.responseText.indexOf('ERROR') === 0) {
|
||||
errorCall.call(
|
||||
this,
|
||||
request.responseText
|
||||
);
|
||||
} else {
|
||||
callBack.call(
|
||||
null,
|
||||
request.responseText,
|
||||
'Published Project'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
myself.url + 'Public',
|
||||
'could not connect to:'
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
} catch (err) {
|
||||
errorCall.call(this, err.toString(), 'Snap!Cloud');
|
||||
}
|
||||
};
|
||||
|
||||
Cloud.prototype.connect = function (
|
||||
callBack,
|
||||
errorCall
|
||||
|
|
24
gui.js
24
gui.js
|
@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2013-April-02';
|
||||
modules.gui = '2013-April-04';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -150,7 +150,7 @@ IDE_Morph.prototype.init = function (isAutoFill) {
|
|||
};
|
||||
|
||||
IDE_Morph.prototype.openIn = function (world) {
|
||||
var hash, usr, motd;
|
||||
var hash, usr, motd, myself = this;
|
||||
|
||||
this.buildPanes();
|
||||
world.add(this);
|
||||
|
@ -245,6 +245,15 @@ IDE_Morph.prototype.openIn = function (world) {
|
|||
}
|
||||
this.toggleAppMode(true);
|
||||
this.runScripts();
|
||||
} else if (location.hash.substr(0, 9) === '#present:') {
|
||||
SnapCloud.getPublicProject(
|
||||
location.hash.substr(9),
|
||||
function (projectData) {
|
||||
myself.rawOpenProjectString(projectData);
|
||||
myself.toggleAppMode(true);
|
||||
},
|
||||
this.cloudError()
|
||||
);
|
||||
} else if (location.hash.substr(0, 6) === '#lang:') {
|
||||
this.setLanguage(location.hash.substr(6));
|
||||
this.newProject();
|
||||
|
@ -3831,7 +3840,8 @@ ProjectDialogMorph.prototype.openSelectedCloudProject = function () {
|
|||
};
|
||||
|
||||
ProjectDialogMorph.prototype.rawOpenSelectedCloudProject = function () {
|
||||
var myself = this;
|
||||
var myself = this,
|
||||
proj = this.listField.selected;
|
||||
SnapCloud.reconnect(
|
||||
function () {
|
||||
SnapCloud.callService(
|
||||
|
@ -3840,9 +3850,15 @@ ProjectDialogMorph.prototype.rawOpenSelectedCloudProject = function () {
|
|||
SnapCloud.disconnect();
|
||||
myself.ide.source = 'cloud';
|
||||
myself.ide.droppedText(response[0].SourceCode);
|
||||
if (proj.Public === 'true') {
|
||||
location.hash = '#present:Username=' +
|
||||
encodeURIComponent(SnapCloud.username) +
|
||||
'&ProjectName=' +
|
||||
encodeURIComponent(proj.ProjectName);
|
||||
}
|
||||
},
|
||||
myself.ide.cloudError(),
|
||||
[myself.listField.selected.ProjectName]
|
||||
[proj.ProjectName]
|
||||
);
|
||||
},
|
||||
myself.ide.cloudError()
|
||||
|
|
|
@ -1579,3 +1579,7 @@ ______
|
|||
------
|
||||
* YPR converter fix: No more text area in upper left corner of the Snap! IDE
|
||||
* Blocks, BYOB, Store: PrototypeHatBlocks in the BlockEditor accept anchored comments
|
||||
|
||||
130404
|
||||
------
|
||||
* loading shared projects in presentation mode, exporting URL for shared projects
|
||||
|
|
Ładowanie…
Reference in New Issue