Fix new project creation ()

* Fix new project creation

* Fix new project creation

* const -> var
This commit is contained in:
dekrain 2016-10-12 19:56:31 +02:00 committed by Tim Mickel
parent a7522c7734
commit 49d6bd3b67
2 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,12 @@
var NEW_PROJECT_HASH = 'createEmptyProject';
var loadProject = function () {
var id = location.hash.substring(1);
if (id.length < 1) {
if (id === NEW_PROJECT_HASH) {
window.vm.createEmptyProject();
return;
}
if (id.length < 1 || !isFinite(id)) {
id = '119615668';
}
var url = 'https://projects.scratch.mit.edu/internalapi/project/' +
@ -32,7 +38,7 @@ window.onload = function() {
};
document.getElementById('createEmptyProject').addEventListener('click',
function() {
document.location = '#' + 'createEmptyProject';
document.location = '#' + NEW_PROJECT_HASH;
location.reload();
});
loadProject();

View file

@ -132,7 +132,7 @@ VirtualMachine.prototype.loadProject = function (json) {
VirtualMachine.prototype.createEmptyProject = function () {
// Stage.
var blocks2 = new Blocks();
var stage = new Sprite(blocks2);
var stage = new Sprite(blocks2, this.runtime);
stage.name = 'Stage';
stage.costumes.push({
skin: '/assets/stage.png',
@ -151,7 +151,7 @@ VirtualMachine.prototype.createEmptyProject = function () {
target2.isStage = true;
// Sprite1 (cat).
var blocks1 = new Blocks();
var sprite = new Sprite(blocks1);
var sprite = new Sprite(blocks1, this.runtime);
sprite.name = 'Sprite1';
sprite.costumes.push({
skin: '/assets/scratch_cat.svg',