kopia lustrzana https://github.com/backface/turtlestitch
deprecated storing projects in localStorage
rodzic
6f529f0276
commit
3ad75ed84d
|
@ -29,6 +29,7 @@
|
||||||
* adjust bottom of STOP block to reflect the menu selection (show / hide bottom notch)
|
* adjust bottom of STOP block to reflect the menu selection (show / hide bottom notch)
|
||||||
* enable dropping commands into all rings
|
* enable dropping commands into all rings
|
||||||
* colors in the vector editor are now named "Edge color" and "Fill color", thanks, Brian!
|
* colors in the vector editor are now named "Edge color" and "Fill color", thanks, Brian!
|
||||||
|
* deprecated storing projects in the browser's localStorage
|
||||||
* Notable Fixes:
|
* Notable Fixes:
|
||||||
* "relabel" blocks with translated drop-down choices
|
* "relabel" blocks with translated drop-down choices
|
||||||
* transforming arrayed to linked lists without loosing the last element
|
* transforming arrayed to linked lists without loosing the last element
|
||||||
|
@ -42,6 +43,9 @@
|
||||||
* Catalan, thanks, Joan!
|
* Catalan, thanks, Joan!
|
||||||
* German
|
* German
|
||||||
|
|
||||||
|
### 2019-03-04
|
||||||
|
* GUI: deprecated storing projects in localStorage
|
||||||
|
|
||||||
### 2019-02-26
|
### 2019-02-26
|
||||||
* Symbols: new "globe" symbol
|
* Symbols: new "globe" symbol
|
||||||
* GUI: replaced "storage" icon in project dialog with "globe" symbol
|
* GUI: replaced "storage" icon in project dialog with "globe" symbol
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<script type="text/javascript" src="src/blocks.js?version=2019-02-21"></script>
|
<script type="text/javascript" src="src/blocks.js?version=2019-02-21"></script>
|
||||||
<script type="text/javascript" src="src/threads.js?version=2019-02-19"></script>
|
<script type="text/javascript" src="src/threads.js?version=2019-02-19"></script>
|
||||||
<script type="text/javascript" src="src/objects.js?version=2019-02-26"></script>
|
<script type="text/javascript" src="src/objects.js?version=2019-02-26"></script>
|
||||||
<script type="text/javascript" src="src/gui.js?version=2019-02-27"></script>
|
<script type="text/javascript" src="src/gui.js?version=2019-03-04"></script>
|
||||||
<script type="text/javascript" src="src/paint.js?version=2019-02-22"></script>
|
<script type="text/javascript" src="src/paint.js?version=2019-02-22"></script>
|
||||||
<script type="text/javascript" src="src/lists.js?version=2019-02-07"></script>
|
<script type="text/javascript" src="src/lists.js?version=2019-02-07"></script>
|
||||||
<script type="text/javascript" src="src/byob.js?version=2019-02-15"></script>
|
<script type="text/javascript" src="src/byob.js?version=2019-02-15"></script>
|
||||||
|
|
110
src/gui.js
110
src/gui.js
|
@ -75,7 +75,7 @@ isRetinaSupported, SliderMorph, Animation, BoxMorph, MediaRecorder*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.gui = '2019-February-27';
|
modules.gui = '2019-March-04';
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ IDE_Morph.prototype.init = function (isAutoFill) {
|
||||||
// additional properties:
|
// additional properties:
|
||||||
this.cloud = new Cloud();
|
this.cloud = new Cloud();
|
||||||
this.cloudMsg = null;
|
this.cloudMsg = null;
|
||||||
this.source = 'local';
|
this.source = null;
|
||||||
this.serializer = new SnapSerializer();
|
this.serializer = new SnapSerializer();
|
||||||
|
|
||||||
this.globalVariables = new VariableFrame();
|
this.globalVariables = new VariableFrame();
|
||||||
|
@ -3809,7 +3809,7 @@ IDE_Morph.prototype.editProjectNotes = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.newProject = function () {
|
IDE_Morph.prototype.newProject = function () {
|
||||||
this.source = this.cloud.username ? 'cloud' : 'local';
|
this.source = this.cloud.username ? 'cloud' : null;
|
||||||
if (this.stage) {
|
if (this.stage) {
|
||||||
this.stage.destroy();
|
this.stage.destroy();
|
||||||
}
|
}
|
||||||
|
@ -3853,56 +3853,23 @@ IDE_Morph.prototype.save = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.source === 'examples') {
|
if (this.source === 'examples' || this.source === 'local') {
|
||||||
this.source = 'local'; // cannot save to examples
|
// cannot save to examples, deprecated localStorage
|
||||||
|
this.source = null;
|
||||||
}
|
}
|
||||||
if (this.projectName) {
|
if (this.projectName) {
|
||||||
if (this.source === 'local') { // as well as 'examples'
|
if (this.source === 'disk') {
|
||||||
this.saveProject(this.projectName);
|
this.exportProject(this.projectName);
|
||||||
} else { // 'cloud'
|
} else if (this.source === 'cloud') {
|
||||||
this.saveProjectToCloud(this.projectName);
|
this.saveProjectToCloud(this.projectName);
|
||||||
|
} else {
|
||||||
|
this.saveProjectsBrowser();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.saveProjectsBrowser();
|
this.saveProjectsBrowser();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.saveProject = function (name) {
|
|
||||||
var myself = this;
|
|
||||||
this.nextSteps([
|
|
||||||
function () {
|
|
||||||
myself.showMessage('Saving...');
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
myself.rawSaveProject(name);
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Serialize a project and save to the browser.
|
|
||||||
IDE_Morph.prototype.rawSaveProject = function (name) {
|
|
||||||
var str;
|
|
||||||
if (name) {
|
|
||||||
this.setProjectName(name);
|
|
||||||
if (Process.prototype.isCatchingErrors) {
|
|
||||||
try {
|
|
||||||
localStorage['-snap-project-' + name]
|
|
||||||
= str = this.serializer.serialize(this.stage);
|
|
||||||
this.setURL('#open:' + str);
|
|
||||||
this.showMessage('Saved!', 1);
|
|
||||||
} catch (err) {
|
|
||||||
this.showMessage('Save failed: ' + err);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
localStorage['-snap-project-' + name]
|
|
||||||
= str = this.serializer.serialize(this.stage);
|
|
||||||
this.setURL('#open:' + str);
|
|
||||||
this.showMessage('Saved!', 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
IDE_Morph.prototype.exportProject = function (name, plain) {
|
IDE_Morph.prototype.exportProject = function (name, plain) {
|
||||||
// Export project XML, saving a file to disk
|
// Export project XML, saving a file to disk
|
||||||
// newWindow requests displaying the project in a new tab.
|
// newWindow requests displaying the project in a new tab.
|
||||||
|
@ -5136,7 +5103,7 @@ IDE_Morph.prototype.saveProjectsBrowser = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.source === 'examples') {
|
if (this.source === 'examples') {
|
||||||
this.source = 'local'; // cannot save to examples
|
this.source = null; // cannot save to examples
|
||||||
}
|
}
|
||||||
new ProjectDialogMorph(this, 'save').popUp();
|
new ProjectDialogMorph(this, 'save').popUp();
|
||||||
};
|
};
|
||||||
|
@ -6000,7 +5967,7 @@ ProjectDialogMorph.prototype.init = function (ide, task) {
|
||||||
// additional properties:
|
// additional properties:
|
||||||
this.ide = ide;
|
this.ide = ide;
|
||||||
this.task = task || 'open'; // String describing what do do (open, save)
|
this.task = task || 'open'; // String describing what do do (open, save)
|
||||||
this.source = ide.source || 'local'; // or 'cloud' or 'examples'
|
this.source = ide.source;
|
||||||
this.projectList = []; // [{name: , thumb: , notes:}]
|
this.projectList = []; // [{name: , thumb: , notes:}]
|
||||||
|
|
||||||
this.handle = null;
|
this.handle = null;
|
||||||
|
@ -6063,11 +6030,16 @@ ProjectDialogMorph.prototype.buildContents = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addSourceButton('cloud', localize('Cloud'), 'cloud');
|
this.addSourceButton('cloud', localize('Cloud'), 'cloud');
|
||||||
this.addSourceButton('local', localize('Browser'), 'globe');
|
|
||||||
if (this.task === 'open') {
|
if (this.task === 'open') {
|
||||||
this.buildFilterField();
|
this.buildFilterField();
|
||||||
this.addSourceButton('examples', localize('Examples'), 'poster');
|
this.addSourceButton('examples', localize('Examples'), 'poster');
|
||||||
|
if (this.ide.world().currentKey === 16) { // shiftClicked
|
||||||
|
this.addSourceButton('local', localize('Browser'), 'globe');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this.addSourceButton('disk', localize('Computer'), 'storage');
|
||||||
|
|
||||||
this.srcBar.fixLayout();
|
this.srcBar.fixLayout();
|
||||||
this.body.add(this.srcBar);
|
this.body.add(this.srcBar);
|
||||||
|
|
||||||
|
@ -6341,17 +6313,18 @@ ProjectDialogMorph.prototype.setSource = function (source) {
|
||||||
var myself = this,
|
var myself = this,
|
||||||
msg;
|
msg;
|
||||||
|
|
||||||
this.source = source; //this.task === 'save' ? 'local' : source;
|
this.source = source;
|
||||||
this.srcBar.children.forEach(function (button) {
|
this.srcBar.children.forEach(function (button) {
|
||||||
button.refresh();
|
button.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (this.source) {
|
switch (this.source) {
|
||||||
case 'cloud':
|
case 'cloud':
|
||||||
msg = myself.ide.showMessage('Updating\nproject list...');
|
msg = myself.ide.showMessage('Updating\nproject list...');
|
||||||
this.projectList = [];
|
this.projectList = [];
|
||||||
myself.ide.cloud.getProjectList(
|
myself.ide.cloud.getProjectList(
|
||||||
function (response) {
|
function (response) {
|
||||||
// Don't show cloud projects if user has since switch panes.
|
// Don't show cloud projects if user has since switched panes.
|
||||||
if (myself.source === 'cloud') {
|
if (myself.source === 'cloud') {
|
||||||
myself.installCloudProjectList(response.projects);
|
myself.installCloudProjectList(response.projects);
|
||||||
}
|
}
|
||||||
|
@ -6367,8 +6340,18 @@ ProjectDialogMorph.prototype.setSource = function (source) {
|
||||||
this.projectList = this.getExamplesProjectList();
|
this.projectList = this.getExamplesProjectList();
|
||||||
break;
|
break;
|
||||||
case 'local':
|
case 'local':
|
||||||
|
// deprecated, only for reading
|
||||||
this.projectList = this.getLocalProjectList();
|
this.projectList = this.getLocalProjectList();
|
||||||
break;
|
break;
|
||||||
|
case 'disk':
|
||||||
|
if (this.task === 'save') {
|
||||||
|
this.projectList = [];
|
||||||
|
} else {
|
||||||
|
this.destroy();
|
||||||
|
this.ide.importLocalFile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listField.destroy();
|
this.listField.destroy();
|
||||||
|
@ -6381,6 +6364,9 @@ ProjectDialogMorph.prototype.setSource = function (source) {
|
||||||
null,
|
null,
|
||||||
function () {myself.ok(); }
|
function () {myself.ok(); }
|
||||||
);
|
);
|
||||||
|
if (this.source === 'disk') {
|
||||||
|
this.listField.hide();
|
||||||
|
}
|
||||||
|
|
||||||
this.fixListFieldItemColors();
|
this.fixListFieldItemColors();
|
||||||
this.listField.fixLayout = nop;
|
this.listField.fixLayout = nop;
|
||||||
|
@ -6625,6 +6611,7 @@ ProjectDialogMorph.prototype.openProject = function () {
|
||||||
this.ide.openProjectString(src);
|
this.ide.openProjectString(src);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
} else { // 'local'
|
} else { // 'local'
|
||||||
|
this.ide.source = null;
|
||||||
this.ide.openProject(proj.name);
|
this.ide.openProject(proj.name);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
|
@ -6693,31 +6680,12 @@ ProjectDialogMorph.prototype.saveProject = function () {
|
||||||
this.ide.setProjectName(name);
|
this.ide.setProjectName(name);
|
||||||
myself.saveCloudProject();
|
myself.saveCloudProject();
|
||||||
}
|
}
|
||||||
} else { // 'local'
|
} else if (this.source === 'disk') {
|
||||||
if (detect(
|
this.ide.exportProject(name, false);
|
||||||
this.projectList,
|
this.ide.source = 'disk';
|
||||||
function (item) {return item.name === name; }
|
|
||||||
)) {
|
|
||||||
this.ide.confirm(
|
|
||||||
localize(
|
|
||||||
'Are you sure you want to replace'
|
|
||||||
) + '\n"' + name + '"?',
|
|
||||||
'Replace Project',
|
|
||||||
function () {
|
|
||||||
myself.ide.setProjectName(name);
|
|
||||||
myself.ide.source = 'local';
|
|
||||||
myself.ide.saveProject(name);
|
|
||||||
myself.destroy();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.ide.setProjectName(name);
|
|
||||||
myself.ide.source = 'local';
|
|
||||||
this.ide.saveProject(name);
|
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectDialogMorph.prototype.saveCloudProject = function () {
|
ProjectDialogMorph.prototype.saveCloudProject = function () {
|
||||||
|
|
Ładowanie…
Reference in New Issue