diff options
| author | Gubolin <gubolin@fantasymail.de> | 2015-02-24 10:18:10 +0100 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2015-02-24 10:18:10 +0100 |
| commit | 9ad7c87df968ce72cbd4a88c8948d78e38f5bdb6 (patch) | |
| tree | 96843abd0afaa2a327a109e5d8d1500da72f00f3 /gui.js | |
| parent | 6ff8e7e2d6c983bafe0658d17cbbb14118980e92 (diff) | |
| parent | 662a743f4ed564f2c296e2370c555ca44e12116d (diff) | |
| download | snap-9ad7c87df968ce72cbd4a88c8948d78e38f5bdb6.tar.gz snap-9ad7c87df968ce72cbd4a88c8948d78e38f5bdb6.zip | |
mergegithub_backend
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 100 |
1 files changed, 84 insertions, 16 deletions
@@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-January-21'; +modules.gui = '2015-February-20'; // Declarations @@ -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: @@ -432,7 +433,7 @@ IDE_Morph.prototype.openIn = function (world) { myself.parentCommitSha = pcSha; myself.lastCommit = code; myself.rawOpenCloudDataString(code); - myself.hasChangedMedia = true; + myself.hasChangedMedia = true; }, function () { myself.shield.destroy(); @@ -441,10 +442,50 @@ IDE_Morph.prototype.openIn = function (world) { myself.toggleAppMode(true); myself.runScripts(); } - ]); + ]); }, this.githubError() ); + } 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('<snapdata') === 0) { + myself.rawOpenCloudDataString(projectData); + } else if ( + projectData.indexOf('<project') === 0 + ) { + myself.rawOpenProjectString(projectData); + } + myself.hasChangedMedia = true; + }, + function () { + myself.shield.destroy(); + myself.shield = null; + msg.destroy(); + myself.toggleAppMode(false); + } + ]); + }, + this.cloudError() + ); } else if (location.hash.substr(0, 6) === '#lang:') { urlLanguage = location.hash.substr(6); this.setLanguage(urlLanguage); @@ -1794,6 +1835,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 @@ -1827,6 +1869,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; @@ -2309,6 +2358,21 @@ IDE_Morph.prototype.settingsMenu = function () { 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 () { SpriteMorph.prototype.enableNesting = @@ -2379,14 +2443,12 @@ IDE_Morph.prototype.projectMenu = function () { if (GitHub.username) { menu.addItem('Save with commit message', 'commitProjectToGitHub'); } - 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( @@ -2860,7 +2922,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); @@ -2868,7 +2930,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); } } @@ -2909,7 +2971,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(); @@ -2922,7 +2984,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(); @@ -3196,7 +3258,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; } }; |
