summaryrefslogtreecommitdiff
path: root/cloud.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-04-04 17:47:26 +0200
committerjmoenig <jens@moenig.org>2013-04-04 17:47:26 +0200
commit8f249e63bb07f978322fc1fa68b44ca70062dda5 (patch)
tree9f6e151d3ce3dfa060ee65f2214a42841edec2f0 /cloud.js
parent18821f7bc1807b6ae199e2c207a865439ee6167f (diff)
downloadsnap-yow-8f249e63bb07f978322fc1fa68b44ca70062dda5.tar.gz
snap-yow-8f249e63bb07f978322fc1fa68b44ca70062dda5.zip
Loading shared cloud projects in presentation mode
and exporting URLs for shared projects
Diffstat (limited to 'cloud.js')
-rw-r--r--cloud.js58
1 files changed, 57 insertions, 1 deletions
diff --git a/cloud.js b/cloud.js
index 86964b6..56ac6fe 100644
--- a/cloud.js
+++ b/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