kopia lustrzana https://github.com/backface/turtlestitch
rodzic
f22338b3a9
commit
b5ddbfbc75
60
cloud.js
60
cloud.js
|
@ -29,7 +29,7 @@
|
|||
|
||||
/*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/
|
||||
|
||||
modules.cloud = '2013-April-19';
|
||||
modules.cloud = '2013-May-06';
|
||||
|
||||
// Global stuff
|
||||
|
||||
|
@ -37,7 +37,7 @@ var Cloud;
|
|||
|
||||
var SnapCloud = new Cloud(
|
||||
'https://snapcloud.miosoft.com/miocon/app/login?_app=SnapCloud'
|
||||
//'192.168.2.108:8087/miocon/app/login?_app=SnapCloud'
|
||||
//'192.168.2.110:8087/miocon/app/login?_app=SnapCloud'
|
||||
//'192.168.186.167:8087/miocon/app/login?_app=SnapCloud'
|
||||
// 'localhost/miocon/app/login?_app=SnapCloud'
|
||||
);
|
||||
|
@ -178,6 +178,62 @@ Cloud.prototype.getPublicProject = function (
|
|||
}
|
||||
};
|
||||
|
||||
Cloud.prototype.resetPassword = function (
|
||||
username,
|
||||
email,
|
||||
callBack,
|
||||
errorCall
|
||||
) {
|
||||
// both callBack and errorCall are two-argument functions
|
||||
var request = new XMLHttpRequest(),
|
||||
myself = this;
|
||||
try {
|
||||
request.open(
|
||||
"GET",
|
||||
(this.hasProtocol() ? '' : 'http://')
|
||||
+ this.url + 'ResetPW'
|
||||
+ '&Username='
|
||||
+ encodeURIComponent(username)
|
||||
+ '&Email='
|
||||
+ email,
|
||||
true
|
||||
);
|
||||
request.setRequestHeader(
|
||||
"Content-Type",
|
||||
"application/x-www-form-urlencoded"
|
||||
);
|
||||
request.withCredentials = true;
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4) {
|
||||
if (request.responseText) {
|
||||
if (request.responseText.indexOf('ERROR') === 0) {
|
||||
errorCall.call(
|
||||
this,
|
||||
request.responseText,
|
||||
'Reset Password'
|
||||
);
|
||||
} else {
|
||||
callBack.call(
|
||||
null,
|
||||
request.responseText,
|
||||
'Reset Password'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
errorCall.call(
|
||||
null,
|
||||
myself.url + 'ResetPW',
|
||||
'could not connect to:'
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(null);
|
||||
} catch (err) {
|
||||
errorCall.call(this, err.toString(), 'Snap!Cloud');
|
||||
}
|
||||
};
|
||||
|
||||
Cloud.prototype.connect = function (
|
||||
callBack,
|
||||
errorCall
|
||||
|
|
105
gui.js
105
gui.js
|
@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2013-April-30';
|
||||
modules.gui = '2013-May-06';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -153,7 +153,7 @@ IDE_Morph.prototype.init = function (isAutoFill) {
|
|||
};
|
||||
|
||||
IDE_Morph.prototype.openIn = function (world) {
|
||||
var hash, usr, motd, myself = this;
|
||||
var hash, usr, myself = this;
|
||||
|
||||
this.buildPanes();
|
||||
world.add(this);
|
||||
|
@ -215,10 +215,10 @@ IDE_Morph.prototype.openIn = function (world) {
|
|||
/*
|
||||
this.cloudMsg = getURL('http://snap.berkeley.edu/cloudmsg.txt');
|
||||
motd = getURL('http://snap.berkeley.edu/motd.txt');
|
||||
*/
|
||||
if (motd) {
|
||||
this.inform('Snap!', motd);
|
||||
}
|
||||
*/
|
||||
|
||||
if (location.hash.substr(0, 6) === '#open:') {
|
||||
hash = location.hash.substr(6);
|
||||
|
@ -411,7 +411,8 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
// button.hint = 'stage size\nsmall & normal';
|
||||
button.fixLayout();
|
||||
button.refresh();
|
||||
this.controlBar.add(stageSizeButton = button);
|
||||
stageSizeButton = button;
|
||||
this.controlBar.add(stageSizeButton);
|
||||
this.controlBar.stageSizeButton = button; // for refreshing
|
||||
|
||||
//appModeButton
|
||||
|
@ -442,8 +443,9 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
// button.hint = 'app & edit\nmodes';
|
||||
button.fixLayout();
|
||||
button.refresh();
|
||||
this.controlBar.add(appModeButton = button);
|
||||
this.controlBar.appModeButton = button; // for refreshing
|
||||
appModeButton = button;
|
||||
this.controlBar.add(appModeButton);
|
||||
this.controlBar.appModeButton = appModeButton; // for refreshing
|
||||
|
||||
// stopButton
|
||||
button = new PushButtonMorph(
|
||||
|
@ -464,7 +466,8 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
button.drawNew();
|
||||
// button.hint = 'stop\nevery-\nthing';
|
||||
button.fixLayout();
|
||||
this.controlBar.add(stopButton = button);
|
||||
stopButton = button;
|
||||
this.controlBar.add(stopButton);
|
||||
|
||||
//pauseButton
|
||||
button = new ToggleButtonMorph(
|
||||
|
@ -494,8 +497,9 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
// button.hint = 'pause/resume\nall scripts';
|
||||
button.fixLayout();
|
||||
button.refresh();
|
||||
this.controlBar.add(pauseButton = button);
|
||||
this.controlBar.pauseButton = button; // for refreshing
|
||||
pauseButton = button;
|
||||
this.controlBar.add(pauseButton);
|
||||
this.controlBar.pauseButton = pauseButton; // for refreshing
|
||||
|
||||
// startButton
|
||||
button = new PushButtonMorph(
|
||||
|
@ -516,7 +520,8 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
button.drawNew();
|
||||
// button.hint = 'start green\nflag scripts';
|
||||
button.fixLayout();
|
||||
this.controlBar.add(startButton = button);
|
||||
startButton = button;
|
||||
this.controlBar.add(startButton);
|
||||
this.controlBar.startButton = startButton;
|
||||
|
||||
// projectButton
|
||||
|
@ -539,7 +544,8 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
button.drawNew();
|
||||
// button.hint = 'open, save, & annotate project';
|
||||
button.fixLayout();
|
||||
this.controlBar.add(projectButton = button);
|
||||
projectButton = button;
|
||||
this.controlBar.add(projectButton);
|
||||
this.controlBar.projectButton = projectButton; // for menu positioning
|
||||
|
||||
// settingsButton
|
||||
|
@ -562,7 +568,8 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
button.drawNew();
|
||||
// button.hint = 'edit settings';
|
||||
button.fixLayout();
|
||||
this.controlBar.add(settingsButton = button);
|
||||
settingsButton = button;
|
||||
this.controlBar.add(settingsButton);
|
||||
this.controlBar.settingsButton = settingsButton; // for menu positioning
|
||||
|
||||
// cloudButton
|
||||
|
@ -584,7 +591,8 @@ IDE_Morph.prototype.createControlBar = function () {
|
|||
button.drawNew();
|
||||
// button.hint = 'cloud operations';
|
||||
button.fixLayout();
|
||||
this.controlBar.add(cloudButton = button);
|
||||
cloudButton = button;
|
||||
this.controlBar.add(cloudButton);
|
||||
this.controlBar.cloudButton = cloudButton; // for menu positioning
|
||||
|
||||
this.controlBar.fixLayout = function () {
|
||||
|
@ -1018,8 +1026,8 @@ IDE_Morph.prototype.createSpriteBar = function () {
|
|||
tabBar.children.forEach(function (each) {
|
||||
each.refresh();
|
||||
});
|
||||
|
||||
this.spriteBar.add(this.spriteBar.tabBar = tabBar);
|
||||
this.spriteBar.tabBar = tabBar;
|
||||
this.spriteBar.add(this.spriteBar.tabBar);
|
||||
|
||||
this.spriteBar.fixLayout = function () {
|
||||
this.tabBar.setLeft(this.left());
|
||||
|
@ -1169,9 +1177,8 @@ IDE_Morph.prototype.createCorral = function () {
|
|||
frame.alpha = 0;
|
||||
|
||||
this.sprites.asArray().forEach(function (morph) {
|
||||
frame.contents.add(
|
||||
template = new SpriteIconMorph(morph, template)
|
||||
);
|
||||
template = new SpriteIconMorph(morph, template);
|
||||
frame.contents.add(template);
|
||||
});
|
||||
|
||||
this.corral.frame = frame;
|
||||
|
@ -1659,6 +1666,10 @@ IDE_Morph.prototype.cloudMenu = function () {
|
|||
'Signup...',
|
||||
'createCloudAccount'
|
||||
);
|
||||
menu.addItem(
|
||||
'Reset Password...',
|
||||
'resetCloudPassword'
|
||||
);
|
||||
} else {
|
||||
menu.addItem(
|
||||
'Logout',
|
||||
|
@ -2533,9 +2544,8 @@ IDE_Morph.prototype.openProject = function (name) {
|
|||
if (name) {
|
||||
this.showMessage('opening project\n' + name);
|
||||
this.setProjectName(name);
|
||||
this.openProjectString(
|
||||
str = localStorage['-snap-project-' + name]
|
||||
);
|
||||
str = localStorage['-snap-project-' + name];
|
||||
this.openProjectString(str);
|
||||
location.hash = '#open:' + str;
|
||||
}
|
||||
};
|
||||
|
@ -3063,6 +3073,47 @@ IDE_Morph.prototype.createCloudAccount = function () {
|
|||
);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.resetCloudPassword = function () {
|
||||
var myself = this,
|
||||
world = this.world();
|
||||
/*
|
||||
// force-logout, commented out for now:
|
||||
delete localStorage['-snap-user'];
|
||||
SnapCloud.clear();
|
||||
*/
|
||||
new DialogBoxMorph(
|
||||
null,
|
||||
function (user) {
|
||||
SnapCloud.resetPassword(
|
||||
user.username,
|
||||
user.email,
|
||||
function (txt, title) {
|
||||
new DialogBoxMorph().inform(
|
||||
title,
|
||||
txt +
|
||||
'.\n\nAn e-mail with your password\n' +
|
||||
'has been sent to the address provided',
|
||||
world,
|
||||
myself.cloudIcon(null, new Color(0, 180, 0))
|
||||
);
|
||||
},
|
||||
myself.cloudError()
|
||||
);
|
||||
}
|
||||
).withKey('cloudresetpassword').promptCredentials(
|
||||
'Reset password',
|
||||
'resetPassword',
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
world,
|
||||
myself.cloudIcon(),
|
||||
myself.cloudMsg
|
||||
);
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.changeCloudPassword = function () {
|
||||
var myself = this,
|
||||
world = this.world();
|
||||
|
@ -3122,14 +3173,14 @@ IDE_Morph.prototype.saveProjectToCloud = function (name) {
|
|||
};
|
||||
|
||||
IDE_Morph.prototype.exportProjectMedia = function (name) {
|
||||
var menu, str, media;
|
||||
var menu, media;
|
||||
this.serializer.isCollectingMedia = true;
|
||||
if (name) {
|
||||
this.setProjectName(name);
|
||||
if (Process.prototype.isCatchingErrors) {
|
||||
try {
|
||||
menu = this.showMessage('Exporting');
|
||||
str = encodeURIComponent(
|
||||
encodeURIComponent(
|
||||
this.serializer.serialize(this.stage)
|
||||
);
|
||||
media = encodeURIComponent(
|
||||
|
@ -3144,7 +3195,7 @@ IDE_Morph.prototype.exportProjectMedia = function (name) {
|
|||
}
|
||||
} else {
|
||||
menu = this.showMessage('Exporting');
|
||||
str = encodeURIComponent(
|
||||
encodeURIComponent(
|
||||
this.serializer.serialize(this.stage)
|
||||
);
|
||||
media = encodeURIComponent(
|
||||
|
@ -3346,7 +3397,7 @@ IDE_Morph.prototype.setCloudURL = function () {
|
|||
'https://snapcloud.miosoft.com/miocon/app/' +
|
||||
'login?_app=SnapCloud',
|
||||
'local network lab' :
|
||||
'192.168.2.108:8087/miocon/app/login?_app=SnapCloud',
|
||||
'192.168.2.110:8087/miocon/app/login?_app=SnapCloud',
|
||||
'local network office' :
|
||||
'192.168.186.167:8087/miocon/app/login?_app=SnapCloud',
|
||||
'localhost dev' :
|
||||
|
@ -5131,7 +5182,7 @@ SoundIconMorph.prototype.init = function (aSound, aTemplate) {
|
|||
};
|
||||
|
||||
SoundIconMorph.prototype.createThumbnail = function () {
|
||||
var label, btnColor, btnLabelColor;
|
||||
var label;
|
||||
if (this.thumbnail) {
|
||||
this.thumbnail.destroy();
|
||||
}
|
||||
|
@ -5157,8 +5208,6 @@ SoundIconMorph.prototype.createThumbnail = function () {
|
|||
'toggleAudioPlaying',
|
||||
(this.object.previewAudio ? 'Stop' : 'Play')
|
||||
);
|
||||
btnLabelColor = new Color(110, 100, 110);
|
||||
btnColor = new Color(220, 220, 220);
|
||||
this.button.drawNew();
|
||||
this.button.hint = 'Play sound';
|
||||
this.button.fixLayout();
|
||||
|
|
|
@ -1692,3 +1692,7 @@ ______
|
|||
* GUI: select dragged costume
|
||||
* Blocks: eraser symbol for paint editor
|
||||
* Morphic: ScrollFrame scrollY() fix (fixes #24)
|
||||
|
||||
130506
|
||||
------
|
||||
* Reset Password feature (frontend only)
|
10
morphic.js
10
morphic.js
|
@ -1035,7 +1035,7 @@
|
|||
/*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio,
|
||||
FileList, getBlurredShadowSupport*/
|
||||
|
||||
var morphicVersion = '2013-April-30';
|
||||
var morphicVersion = '2013-May-06';
|
||||
var modules = {}; // keep track of additional loaded modules
|
||||
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ function getDocumentPositionOf(aDOMelement) {
|
|||
function clone(target) {
|
||||
// answer a new instance of target's type
|
||||
if (typeof target === 'object') {
|
||||
var Clone = function () {};
|
||||
var Clone = function () {nop(); };
|
||||
Clone.prototype = target;
|
||||
return new Clone();
|
||||
}
|
||||
|
@ -8230,8 +8230,10 @@ MenuItemMorph.prototype.createLabel = function () {
|
|||
// assume its pattern is: [icon, string]
|
||||
this.label = new Morph();
|
||||
this.label.alpha = 0; // transparent
|
||||
this.label.add(icon = this.createIcon(this.labelString[0]));
|
||||
this.label.add(lbl = this.createLabelString(this.labelString[1]));
|
||||
icon = this.createIcon(this.labelString[0]);
|
||||
this.label.add(icon);
|
||||
lbl = this.createLabelString(this.labelString[1]);
|
||||
this.label.add(lbl);
|
||||
lbl.setCenter(icon.center());
|
||||
lbl.setLeft(icon.right() + 4);
|
||||
this.label.bounds = (icon.bounds.merge(lbl.bounds));
|
||||
|
|
24
widgets.js
24
widgets.js
|
@ -73,7 +73,7 @@ newCanvas, StringMorph, Morph, TextMorph, nop, detect, StringFieldMorph,
|
|||
HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
||||
ArrowMorph, MenuMorph, isString, isNil, SliderMorph*/
|
||||
|
||||
modules.widgets = '2013-April-24';
|
||||
modules.widgets = '2013-May-06';
|
||||
|
||||
var PushButtonMorph;
|
||||
var ToggleButtonMorph;
|
||||
|
@ -1805,7 +1805,8 @@ DialogBoxMorph.prototype.promptCredentials = function (
|
|||
dof.add(mCol);
|
||||
dof.add(yCol);
|
||||
inp.add(dof);
|
||||
inp.add(emlLabel = labelText('foo'));
|
||||
emlLabel = labelText('foo');
|
||||
inp.add(emlLabel);
|
||||
inp.add(eml);
|
||||
}
|
||||
|
||||
|
@ -1823,6 +1824,14 @@ DialogBoxMorph.prototype.promptCredentials = function (
|
|||
inp.add(pw2);
|
||||
}
|
||||
|
||||
if (purpose === 'resetPassword') {
|
||||
inp.add(labelText('User name:'));
|
||||
inp.add(usr);
|
||||
emlLabel = labelText('E-mail address:');
|
||||
inp.add(emlLabel);
|
||||
inp.add(eml);
|
||||
}
|
||||
|
||||
if (msg) {
|
||||
bdy.add(labelText(msg));
|
||||
}
|
||||
|
@ -1912,6 +1921,8 @@ DialogBoxMorph.prototype.promptCredentials = function (
|
|||
checklist = [usr, bmn, byr, eml];
|
||||
} else if (purpose === 'changePassword') {
|
||||
checklist = [opw, pw1, pw2];
|
||||
} else if (purpose === 'resetPassword') {
|
||||
checklist = [usr, eml];
|
||||
}
|
||||
|
||||
empty = detect(
|
||||
|
@ -1945,6 +1956,13 @@ DialogBoxMorph.prototype.promptCredentials = function (
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (purpose === 'resetPassword') {
|
||||
if (em.indexOf(' ') > -1 || em.indexOf('@') === -1
|
||||
|| em.indexOf('.') === -1) {
|
||||
indicate(eml, 'please provide a valid\nemail address');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (purpose === 'signup') {
|
||||
if (!agree) {
|
||||
indicate(chk, 'please agree to\nthe TOS');
|
||||
|
@ -1963,7 +1981,7 @@ DialogBoxMorph.prototype.promptCredentials = function (
|
|||
this.edit = function () {
|
||||
if (purpose === 'changePassword') {
|
||||
opw.edit();
|
||||
} else { // 'signup', 'login'
|
||||
} else { // 'signup', 'login', 'resetPassword'
|
||||
usr.edit();
|
||||
}
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue