From e45562fc530f74fff38baa7ba8c4f39ab8e4e08f Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 6 Feb 2015 11:29:46 +0100 Subject: Added url switch #cloud: to open a shared project in edit mode --- gui.js | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'gui.js') diff --git a/gui.js b/gui.js index 73fffe9..b30b6de 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-January-21'; +modules.gui = '2015-February-06'; // Declarations @@ -390,6 +390,46 @@ IDE_Morph.prototype.openIn = function (world) { }, this.cloudError() ); + } else if (location.hash.substr(0, 7) === '#cloud:') { + this.shield = new Morph(); + this.shield.alpha = 0; + this.shield.setExtent(this.parent.extent()); + this.parent.add(this.shield); + myself.showMessage('Fetching project\nfrom the cloud...'); + + // make sure to lowercase the username + dict = SnapCloud.parseDict(location.hash.substr(7)); + dict.Username = dict.Username.toLowerCase(); + + SnapCloud.getPublicProject( + SnapCloud.encodeDict(dict), + function (projectData) { + var msg; + myself.nextSteps([ + function () { + msg = myself.showMessage('Opening project...'); + }, + function () {nop(); }, // yield (bug in Chrome) + function () { + if (projectData.indexOf(' Date: Fri, 20 Feb 2015 12:49:18 +0100 Subject: Un-hide “Save to disk” feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (currently supported by both Chrome and Firefox, but not by Safari) --- gui.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'gui.js') diff --git a/gui.js b/gui.js index b30b6de..5f7f3ab 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-February-06'; +modules.gui = '2015-February-20'; // Declarations @@ -2349,14 +2349,11 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem('New', 'createNewProject'); menu.addItem('Open...', 'openProjectsBrowser'); menu.addItem('Save', "save"); - if (shiftClicked) { - menu.addItem( - 'Save to disk', - 'saveProjectToDisk', - 'experimental - store this project\nin your downloads folder', - new Color(100, 0, 0) - ); - } + menu.addItem( + 'Save to disk', + 'saveProjectToDisk', + 'store this project\nin your downloads folder\n(not supported by all browsers)' + ); menu.addItem('Save As...', 'saveProjectsBrowser'); menu.addLine(); menu.addItem( -- cgit v1.3.1 From 662a743f4ed564f2c296e2370c555ca44e12116d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 20 Feb 2015 15:01:43 +0100 Subject: Make “project data in URLs” a hidden dev option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (prevent long urls per default) --- gui.js | 43 +++++++++++++++++++++++++++++++++++++------ history.txt | 1 + 2 files changed, 38 insertions(+), 6 deletions(-) (limited to 'gui.js') diff --git a/gui.js b/gui.js index 5f7f3ab..c3104c5 100644 --- a/gui.js +++ b/gui.js @@ -202,6 +202,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { // restore saved user preferences this.userLanguage = null; // user language preference for startup + this.projectsInURLs = false; this.applySavedSettings(); // additional properties: @@ -1779,6 +1780,7 @@ IDE_Morph.prototype.applySavedSettings = function () { language = this.getSetting('language'), click = this.getSetting('click'), longform = this.getSetting('longform'), + longurls = this.getSetting('longurls'), plainprototype = this.getSetting('plainprototype'); // design @@ -1812,6 +1814,13 @@ IDE_Morph.prototype.applySavedSettings = function () { InputSlotDialogMorph.prototype.isLaunchingExpanded = true; } + // project data in URLs + if (longurls) { + this.projectsInURLs = true; + } else { + this.projectsInURLs = false; + } + // plain prototype labels if (plainprototype) { BlockLabelPlaceHolderMorph.prototype.plainLabel = true; @@ -2281,6 +2290,21 @@ IDE_Morph.prototype.settingsMenu = function () { 'check for alternative\nGUI design', false ); + addPreference( + 'Project URLs', + function () { + myself.projectsInURLs = !myself.projectsInURLs; + if (myself.projectsInURLs) { + myself.saveSetting('longurls', true); + } else { + myself.removeSetting('longurls'); + } + }, + myself.projectsInURLs, + 'uncheck to disable\nproject data in URLs', + 'check to enable\nproject data in URLs', + true + ); addPreference( 'Sprite Nesting', function () { @@ -2352,7 +2376,8 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem( 'Save to disk', 'saveProjectToDisk', - 'store this project\nin your downloads folder\n(not supported by all browsers)' + 'store this project\nin your downloads folder\n' + + '(not supported by all browsers)' ); menu.addItem('Save As...', 'saveProjectsBrowser'); menu.addLine(); @@ -2825,7 +2850,7 @@ IDE_Morph.prototype.rawSaveProject = function (name) { try { localStorage['-snap-project-' + name] = str = this.serializer.serialize(this.stage); - location.hash = '#open:' + str; + this.setURL('#open:' + str); this.showMessage('Saved!', 1); } catch (err) { this.showMessage('Save failed: ' + err); @@ -2833,7 +2858,7 @@ IDE_Morph.prototype.rawSaveProject = function (name) { } else { localStorage['-snap-project-' + name] = str = this.serializer.serialize(this.stage); - location.hash = '#open:' + str; + this.setURL('#open:' + str); this.showMessage('Saved!', 1); } } @@ -2874,7 +2899,7 @@ IDE_Morph.prototype.exportProject = function (name, plain) { str = encodeURIComponent( this.serializer.serialize(this.stage) ); - location.hash = '#open:' + str; + this.setURL('#open:' + str); window.open('data:text/' + (plain ? 'plain,' + str : 'xml,' + str)); menu.destroy(); @@ -2887,7 +2912,7 @@ IDE_Morph.prototype.exportProject = function (name, plain) { str = encodeURIComponent( this.serializer.serialize(this.stage) ); - location.hash = '#open:' + str; + this.setURL('#open:' + str); window.open('data:text/' + (plain ? 'plain,' + str : 'xml,' + str)); menu.destroy(); @@ -3161,7 +3186,13 @@ IDE_Morph.prototype.openProject = function (name) { this.setProjectName(name); str = localStorage['-snap-project-' + name]; this.openProjectString(str); - location.hash = '#open:' + str; + this.setURL('#open:' + str); + } +}; + +IDE_Morph.prototype.setURL = function (str) { + if (this.projectsInURLs) { + location.hash = str; } }; diff --git a/history.txt b/history.txt index 1a69cfb..e125b70 100755 --- a/history.txt +++ b/history.txt @@ -2440,3 +2440,4 @@ ______ * Malayam, Tamil and Telagu translations, thanks, Vinay Kumar!! * Un-hide “Save to disk” feature (currently supported by both Chrome and Firefox, but not by Safari) * Update German translation +* GUI: Make “project data in URLs” a hidden dev option (prevent long urls per default) -- cgit v1.3.1