kopia lustrzana https://github.com/backface/turtlestitch
refactored IDE cloud operations
rodzic
f64de5fb20
commit
1278f60c0b
134
src/gui.js
134
src/gui.js
|
@ -5516,12 +5516,10 @@ IDE_Morph.prototype.setStageExtent = function (aPoint) {
|
||||||
IDE_Morph.prototype.userSetDragThreshold = function () {
|
IDE_Morph.prototype.userSetDragThreshold = function () {
|
||||||
new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
this,
|
this,
|
||||||
function (num) {
|
num => MorphicPreferences.grabThreshold = Math.min(
|
||||||
MorphicPreferences.grabThreshold = Math.min(
|
|
||||||
Math.max(+num, 0),
|
Math.max(+num, 0),
|
||||||
200
|
200
|
||||||
);
|
),
|
||||||
},
|
|
||||||
this
|
this
|
||||||
).prompt(
|
).prompt(
|
||||||
"Dragging threshold",
|
"Dragging threshold",
|
||||||
|
@ -5537,18 +5535,16 @@ IDE_Morph.prototype.userSetDragThreshold = function () {
|
||||||
// IDE_Morph cloud interface
|
// IDE_Morph cloud interface
|
||||||
|
|
||||||
IDE_Morph.prototype.initializeCloud = function () {
|
IDE_Morph.prototype.initializeCloud = function () {
|
||||||
var myself = this,
|
var world = this.world();
|
||||||
world = this.world();
|
|
||||||
new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (user) {
|
user => this.cloud.login(
|
||||||
myself.cloud.login(
|
|
||||||
user.username.toLowerCase(),
|
user.username.toLowerCase(),
|
||||||
user.password,
|
user.password,
|
||||||
user.choice,
|
user.choice,
|
||||||
function (username, role, response) {
|
(username, role, response) => {
|
||||||
sessionStorage.username = username;
|
sessionStorage.username = username;
|
||||||
myself.source = 'cloud';
|
this.source = 'cloud';
|
||||||
if (!isNil(response.days_left)) {
|
if (!isNil(response.days_left)) {
|
||||||
new DialogBoxMorph().inform(
|
new DialogBoxMorph().inform(
|
||||||
'Unverified account: ' +
|
'Unverified account: ' +
|
||||||
|
@ -5566,15 +5562,14 @@ IDE_Morph.prototype.initializeCloud = function () {
|
||||||
'menu.\n\n' +
|
'menu.\n\n' +
|
||||||
'You have ' + response.days_left + ' days left.',
|
'You have ' + response.days_left + ' days left.',
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(null, new Color(0, 180, 0))
|
this.cloudIcon(null, new Color(0, 180, 0))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
myself.showMessage(response.message, 2);
|
this.showMessage(response.message, 2);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
myself.cloudError()
|
this.cloudError()
|
||||||
);
|
)
|
||||||
}
|
|
||||||
).withKey('cloudlogin').promptCredentials(
|
).withKey('cloudlogin').promptCredentials(
|
||||||
'Sign in',
|
'Sign in',
|
||||||
'login',
|
'login',
|
||||||
|
@ -5584,35 +5579,29 @@ IDE_Morph.prototype.initializeCloud = function () {
|
||||||
null,
|
null,
|
||||||
'stay signed in on this computer\nuntil logging out',
|
'stay signed in on this computer\nuntil logging out',
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(),
|
this.cloudIcon(),
|
||||||
myself.cloudMsg
|
this.cloudMsg
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.createCloudAccount = function () {
|
IDE_Morph.prototype.createCloudAccount = function () {
|
||||||
var myself = this,
|
var world = this.world();
|
||||||
world = this.world();
|
|
||||||
|
|
||||||
new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (user) {
|
user => this.cloud.signup(
|
||||||
myself.cloud.signup(
|
|
||||||
user.username,
|
user.username,
|
||||||
user.password,
|
user.password,
|
||||||
user.passwordRepeat,
|
user.passwordRepeat,
|
||||||
user.email,
|
user.email,
|
||||||
function (txt, title) {
|
(txt, title) => new DialogBoxMorph().inform(
|
||||||
new DialogBoxMorph().inform(
|
|
||||||
title,
|
title,
|
||||||
txt +
|
txt + '.\n\nYou can now log in.',
|
||||||
'.\n\nYou can now log in.',
|
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(null, new Color(0, 180, 0))
|
this.cloudIcon(null, new Color(0, 180, 0))
|
||||||
);
|
),
|
||||||
},
|
this.cloudError()
|
||||||
myself.cloudError()
|
)
|
||||||
);
|
|
||||||
}
|
|
||||||
).withKey('cloudsignup').promptCredentials(
|
).withKey('cloudsignup').promptCredentials(
|
||||||
'Sign up',
|
'Sign up',
|
||||||
'signup',
|
'signup',
|
||||||
|
@ -5622,34 +5611,29 @@ IDE_Morph.prototype.createCloudAccount = function () {
|
||||||
'Privacy...',
|
'Privacy...',
|
||||||
'I have read and agree\nto the Terms of Service',
|
'I have read and agree\nto the Terms of Service',
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(),
|
this.cloudIcon(),
|
||||||
myself.cloudMsg
|
this.cloudMsg
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.resetCloudPassword = function () {
|
IDE_Morph.prototype.resetCloudPassword = function () {
|
||||||
var myself = this,
|
var world = this.world();
|
||||||
world = this.world();
|
|
||||||
|
|
||||||
new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (user) {
|
user => this.cloud.resetPassword(
|
||||||
myself.cloud.resetPassword(
|
|
||||||
user.username,
|
user.username,
|
||||||
function (txt, title) {
|
(txt, title) => new DialogBoxMorph().inform(
|
||||||
new DialogBoxMorph().inform(
|
|
||||||
title,
|
title,
|
||||||
txt +
|
txt +
|
||||||
'\n\nAn e-mail with a link to\n' +
|
'\n\nAn e-mail with a link to\n' +
|
||||||
'reset your password\n' +
|
'reset your password\n' +
|
||||||
'has been sent to the address provided',
|
'has been sent to the address provided',
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(null, new Color(0, 180, 0))
|
this.cloudIcon(null, new Color(0, 180, 0))
|
||||||
);
|
),
|
||||||
},
|
this.cloudError()
|
||||||
myself.cloudError()
|
)
|
||||||
);
|
|
||||||
}
|
|
||||||
).withKey('cloudresetpassword').promptCredentials(
|
).withKey('cloudresetpassword').promptCredentials(
|
||||||
'Reset password',
|
'Reset password',
|
||||||
'resetPassword',
|
'resetPassword',
|
||||||
|
@ -5659,31 +5643,26 @@ IDE_Morph.prototype.resetCloudPassword = function () {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(),
|
this.cloudIcon(),
|
||||||
myself.cloudMsg
|
this.cloudMsg
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.resendVerification = function () {
|
IDE_Morph.prototype.resendVerification = function () {
|
||||||
var myself = this,
|
var world = this.world();
|
||||||
world = this.world();
|
|
||||||
|
|
||||||
new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (user) {
|
user => this.cloud.resendVerification(
|
||||||
myself.cloud.resendVerification(
|
|
||||||
user.username,
|
user.username,
|
||||||
function (txt, title) {
|
(txt, title) => new DialogBoxMorph().inform(
|
||||||
new DialogBoxMorph().inform(
|
|
||||||
title,
|
title,
|
||||||
txt,
|
txt,
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(null, new Color(0, 180, 0))
|
this.cloudIcon(null, new Color(0, 180, 0))
|
||||||
);
|
),
|
||||||
},
|
this.cloudError()
|
||||||
myself.cloudError()
|
)
|
||||||
);
|
|
||||||
}
|
|
||||||
).withKey('cloudresendverification').promptCredentials(
|
).withKey('cloudresendverification').promptCredentials(
|
||||||
'Resend verification email',
|
'Resend verification email',
|
||||||
'resendVerification',
|
'resendVerification',
|
||||||
|
@ -5693,27 +5672,23 @@ IDE_Morph.prototype.resendVerification = function () {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(),
|
this.cloudIcon(),
|
||||||
myself.cloudMsg
|
this.cloudMsg
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.changeCloudPassword = function () {
|
IDE_Morph.prototype.changeCloudPassword = function () {
|
||||||
var myself = this,
|
var world = this.world();
|
||||||
world = this.world();
|
|
||||||
new DialogBoxMorph(
|
new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (user) {
|
user => this.cloud.changePassword(
|
||||||
myself.cloud.changePassword(
|
|
||||||
user.oldpassword,
|
user.oldpassword,
|
||||||
user.password,
|
user.password,
|
||||||
user.passwordRepeat,
|
user.passwordRepeat,
|
||||||
function () {
|
() => this.showMessage('password has been changed.', 2),
|
||||||
myself.showMessage('password has been changed.', 2);
|
this.cloudError()
|
||||||
},
|
)
|
||||||
myself.cloudError()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
).withKey('cloudpassword').promptCredentials(
|
).withKey('cloudpassword').promptCredentials(
|
||||||
'Change Password',
|
'Change Password',
|
||||||
'changePassword',
|
'changePassword',
|
||||||
|
@ -5723,21 +5698,20 @@ IDE_Morph.prototype.changeCloudPassword = function () {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
world,
|
world,
|
||||||
myself.cloudIcon(),
|
this.cloudIcon(),
|
||||||
myself.cloudMsg
|
this.cloudMsg
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.logout = function () {
|
IDE_Morph.prototype.logout = function () {
|
||||||
var myself = this;
|
|
||||||
this.cloud.logout(
|
this.cloud.logout(
|
||||||
function () {
|
() => {
|
||||||
delete(sessionStorage.username);
|
delete(sessionStorage.username);
|
||||||
myself.showMessage('disconnected.', 2);
|
this.showMessage('disconnected.', 2);
|
||||||
},
|
},
|
||||||
function () {
|
() => {
|
||||||
delete(sessionStorage.username);
|
delete(sessionStorage.username);
|
||||||
myself.showMessage('disconnected.', 2);
|
this.showMessage('disconnected.', 2);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -5802,7 +5776,7 @@ IDE_Morph.prototype.verifyProject = function (body) {
|
||||||
};
|
};
|
||||||
|
|
||||||
IDE_Morph.prototype.saveProjectToCloud = function (name) {
|
IDE_Morph.prototype.saveProjectToCloud = function (name) {
|
||||||
var myself = this, projectBody, projectSize;
|
var projectBody, projectSize;
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
this.setProjectName(name);
|
this.setProjectName(name);
|
||||||
|
@ -5818,7 +5792,7 @@ IDE_Morph.prototype.saveProjectToCloud = function (name) {
|
||||||
this.cloud.saveProject(
|
this.cloud.saveProject(
|
||||||
this.projectName,
|
this.projectName,
|
||||||
projectBody,
|
projectBody,
|
||||||
function () {myself.showMessage('saved.', 2); },
|
() => this.showMessage('saved.', 2),
|
||||||
this.cloudError()
|
this.cloudError()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue