diff options
| author | jmoenig <jens@moenig.org> | 2013-04-02 14:01:42 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-04-02 14:01:42 +0200 |
| commit | 84fd877fa483d986a9651b7d5555455cce978cae (patch) | |
| tree | bb36ebf2d24033add6d7da83b012cb3f9fcd1f6e | |
| parent | f05104ee6765ba25b503323a172c5a6365c32466 (diff) | |
| download | snap-yow-84fd877fa483d986a9651b7d5555455cce978cae.tar.gz snap-yow-84fd877fa483d986a9651b7d5555455cce978cae.zip | |
Project Sharing / Unsharing Support (frontend)
Support for publishing and un-publishing projects in the cloud (not yet
live in the current production version of the cloud backend)
| -rw-r--r-- | cloud.js | 28 | ||||
| -rw-r--r-- | gui.js | 106 | ||||
| -rwxr-xr-x | history.txt | 10 | ||||
| -rw-r--r-- | locale.js | bin | 13844 -> 13844 bytes |
4 files changed, 134 insertions, 10 deletions
@@ -29,7 +29,7 @@ /*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/ -modules.cloud = '2013-March-22'; +modules.cloud = '2013-April-02'; // Global stuff @@ -82,6 +82,10 @@ Cloud.prototype.signup = function ( + email, true ); + request.setRequestHeader( + "Content-Type", + "application/x-www-form-urlencoded" + ); request.withCredentials = true; request.onreadystatechange = function () { if (request.readyState === 4) { @@ -127,6 +131,10 @@ Cloud.prototype.connect = function ( (this.hasProtocol() ? '' : 'http://') + this.url, true ); + request.setRequestHeader( + "Content-Type", + "application/x-www-form-urlencoded" + ); request.withCredentials = true; request.onreadystatechange = function () { if (request.readyState === 4) { @@ -318,7 +326,10 @@ Cloud.prototype.callURL = function (url, callBack, errorCall) { try { request.open('GET', url, true); request.withCredentials = true; - request.setRequestHeader('Content-Type', 'text/plain'); + request.setRequestHeader( + "Content-Type", + "application/x-www-form-urlencoded" + ); request.setRequestHeader('MioCracker', this.session); request.onreadystatechange = function () { if (request.readyState === 4) { @@ -355,11 +366,15 @@ Cloud.prototype.callService = function ( postDict; if (!this.session) { - errorCall.call('You are not connected', 'Cloud'); + errorCall.call(null, 'You are not connected', 'Cloud'); return; } if (!service) { - errorCall.call('service ' + serviceName + ' is not available', 'API'); + errorCall.call( + null, + 'service ' + serviceName + ' is not available', + 'API' + ); return; } if (args && args.length > 0) { @@ -371,7 +386,10 @@ Cloud.prototype.callService = function ( try { request.open(service.method, service.url, true); request.withCredentials = true; - request.setRequestHeader('Content-Type', 'text/plain'); + request.setRequestHeader( + "Content-Type", + "application/x-www-form-urlencoded" + ); request.setRequestHeader('MioCracker', this.session); request.onreadystatechange = function () { if (request.readyState === 4) { @@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2013-March-22'; +modules.gui = '2013-April-02'; // Declarations @@ -3325,6 +3325,9 @@ ProjectDialogMorph.prototype.init = function (ide, task) { this.preview = null; this.notesText = null; this.notesField = null; + this.deleteButton = null; + this.shareButton = null; + this.unshareButton = null; // initialize inherited properties: ProjectDialogMorph.uber.init.call( @@ -3458,7 +3461,13 @@ ProjectDialogMorph.prototype.buildContents = function () { if (this.task === 'open') { this.addButton('openProject', 'Open'); - this.addButton('deleteProject', 'Delete'); + + this.shareButton = this.addButton('shareProject', 'Share'); + this.unshareButton = this.addButton('unshareProject', 'Unshare'); + this.shareButton.hide(); + this.unshareButton.hide(); + + this.deleteButton = this.addButton('deleteProject', 'Delete'); this.action = 'openProject'; } else { // 'save' this.addButton('saveProject', 'Save'); @@ -3684,6 +3693,24 @@ ProjectDialogMorph.prototype.setSource = function (source) { }; } this.body.add(this.listField); + + if (this.task === 'open') { + if (this.source === 'cloud') { + this.shareButton.show(); + this.unshareButton.hide(); + this.deleteButton.show(); + } else { + this.shareButton.hide(); + this.unshareButton.hide(); + if (this.source === 'local') { + this.deleteButton.show(); + } else { // examples + this.deleteButton.hide(); + } + } + } + this.buttons.fixLayout(); + this.fixLayout(); if (this.task === 'open') { this.clearDetails(); @@ -3747,6 +3774,15 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { myself.preview.texture = item.Thumbnail || null; myself.preview.cachedTexture = null; myself.preview.drawNew(); + if (item.Public === 'true') { + myself.shareButton.hide(); + myself.unshareButton.show(); + } else { + myself.unshareButton.hide(); + myself.shareButton.show(); + } + myself.buttons.fixLayout(); + myself.fixLayout(); } myself.edit(); }; @@ -3908,7 +3944,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ); // refresh list }, myself.ide.cloudError(), - [myself.listField.selected.ProjectName] + [proj.ProjectName] ); }, myself.ide.cloudError() @@ -3933,6 +3969,70 @@ ProjectDialogMorph.prototype.deleteProject = function () { } }; +ProjectDialogMorph.prototype.shareProject = function () { + var myself = this, + proj = this.listField.selected; + + if (proj) { + this.ide.confirm( + localize( + 'Are you sure you want to publish' + ) + '\n"' + proj.ProjectName + '"?', + 'Share Project', + function () { + SnapCloud.reconnect( + function () { + SnapCloud.callService( + 'publishProject', + function () { + SnapCloud.disconnect(); + proj.Public = 'true'; + myself.listField.select(proj); + myself.ide.showMessage('shared.', 2); + }, + myself.ide.cloudError(), + [proj.ProjectName] + ); + }, + myself.ide.cloudError() + ); + } + ); + } +}; + +ProjectDialogMorph.prototype.unshareProject = function () { + var myself = this, + proj = this.listField.selected; + + if (proj) { + this.ide.confirm( + localize( + 'Are you sure you want to unpublish' + ) + '\n"' + proj.ProjectName + '"?', + 'Unshare Project', + function () { + SnapCloud.reconnect( + function () { + SnapCloud.callService( + 'unpublishProject', + function () { + SnapCloud.disconnect(); + proj.Public = 'false'; + myself.listField.select(proj); + myself.ide.showMessage('unshared.', 2); + }, + myself.ide.cloudError(), + [proj.ProjectName] + ); + }, + myself.ide.cloudError() + ); + } + ); + } +}; + ProjectDialogMorph.prototype.edit = function () { if (this.nameField) { this.nameField.edit(); diff --git a/history.txt b/history.txt index eab382e..b7f4b25 100755 --- a/history.txt +++ b/history.txt @@ -1360,7 +1360,7 @@ ______ * Blocks: Drawn symbols for TURN RIGHT / LEFT * continuations tweaks * revert of "returning 'undefined' to parent frame fix" (121204), breaks call/cc -* ScriptPane cleanUp teak for attached comments +* ScriptPane cleanUp tweak for attached comments 130111 ------ @@ -1564,4 +1564,10 @@ ______ ------ * Spanish translation! Yay, thanks, Victor Muratalla!! * Objects: Boolean value block representations are now translated, thanks, Victor, for the report -* Simplified Chinese translation update, thanks 邓江华 !!
\ No newline at end of file +* Simplified Chinese translation update, thanks 邓江华 !! + +130402 +------ +* Japanese translations update, thanks, Kazuhiro Abe! +* Content-type support for Cloud backend +* sharing / unsharing projects support and GUI
\ No newline at end of file Binary files differ |
