Merge branch 'master' of https://github.com/Microsoft/TouchDevelop
|
@ -5985,6 +5985,10 @@ module TDev
|
|||
case "landing":
|
||||
hs = ["hub", "install-run", hs[1]]
|
||||
break;
|
||||
case "signin":
|
||||
case "login":
|
||||
hs = ["hub", "signin"]
|
||||
break;
|
||||
case "signout":
|
||||
case "logout":
|
||||
hs = ["hub", "signout"]
|
||||
|
|
|
@ -732,7 +732,7 @@ module TDev.Browser {
|
|||
EditorSettings.setTheme(themes[m[2]]);
|
||||
else if (Cloud.isRestricted()) {
|
||||
var theme = Cloud.hasPermission('full-editor') ? 'restrictededitor' :
|
||||
Cloud.hasPermission('post-art') ? 'restrictedteacher' : 'restricted';
|
||||
Cloud.hasPermission('teacher-editor') ? 'restrictedteacher' : 'restricted';
|
||||
EditorSettings.setTheme(themes[theme]);
|
||||
}
|
||||
else if (Browser.isRaspberryPiDebian) EditorSettings.setTheme(themes['rpi']);
|
||||
|
@ -1161,6 +1161,11 @@ module TDev.Browser {
|
|||
return
|
||||
}
|
||||
|
||||
if (h[1] == "signin") {
|
||||
Login.show("list:installed-scripts")
|
||||
return
|
||||
}
|
||||
|
||||
if (h[1] == 'new') {
|
||||
HistoryMgr.instance.setHash(this.screenId() + ":" + h[1] + ":" + h[2], null)
|
||||
this.newScriptHash(h[2], h[3]);
|
||||
|
|
|
@ -2576,7 +2576,11 @@
|
|||
});
|
||||
},
|
||||
(err:any) => {
|
||||
reqs.forEach((entry) => this.handleError(err, entry))
|
||||
try {
|
||||
Cloud.handlePostingError(err, lf("reading server data"))
|
||||
} catch (err) {
|
||||
reqs.forEach((entry) => this.handleError(err, entry))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -7896,7 +7900,7 @@
|
|||
cc.push(div("", lf("You have credit to sign-up up to {0} kid{0:s}.", s.credit)));
|
||||
|
||||
settingsDiv.setChildren(cc)
|
||||
})
|
||||
}, e => Cloud.handlePostingError(e, lf("getting settings")))
|
||||
|
||||
if (this.isMe())
|
||||
refreshSettings()
|
||||
|
|
После Ширина: | Высота: | Размер: 9.0 KiB |
После Ширина: | Высота: | Размер: 14 KiB |
После Ширина: | Высота: | Размер: 6.1 KiB |
После Ширина: | Высота: | Размер: 13 KiB |
После Ширина: | Высота: | Размер: 12 KiB |
После Ширина: | Высота: | Размер: 11 KiB |
После Ширина: | Высота: | Размер: 17 KiB |
После Ширина: | Высота: | Размер: 7.2 KiB |
После Ширина: | Высота: | Размер: 14 KiB |
|
@ -1941,7 +1941,7 @@ function getScriptAsync(id:string)
|
|||
console.log("fetching script " + id)
|
||||
|
||||
var p = liteStorage ?
|
||||
TDev.Util.httpGetJsonAsync(liteStorage + "/scripttext/" + id).then(resp => resp ? resp.text : null, err => null)
|
||||
TDev.Util.httpGetTextAsync(apiEndpoint + id + "/text" + accessToken + "&original=true")
|
||||
: TDev.Util.httpGetTextAsync("https://www.touchdevelop.com/api/" + encodeURIComponent(id) + "/text?original=true&ids=true")
|
||||
|
||||
return p.then(text => {
|
||||
|
|
23
rt/cloud.ts
|
@ -327,7 +327,7 @@ module TDev.Cloud {
|
|||
|
||||
var m = new ModalDialog();
|
||||
m.addHTML(
|
||||
Util.fmt("<h3>{0:q} requires sign in</h3>", activity) +
|
||||
lf("<h3>{0:q} requires sign in</h3>", activity) +
|
||||
(!(<any>TDev).TheEditor ? "" :
|
||||
"<p class='agree'>" +
|
||||
lf("After you sign in we will back up and sync scripts between your devices.") +
|
||||
|
@ -847,7 +847,26 @@ module TDev.Cloud {
|
|||
}
|
||||
else if (e.status == 403) {
|
||||
Cloud.accessTokenExpired();
|
||||
ModalDialog.info(lf("access denied"), lf("Your access token might have expired. Please return to the main hub and then try again."));
|
||||
if (Cloud.lite) {
|
||||
// in lite, 403 always means missing or expired access token
|
||||
if (localStorage['everLoggedIn'])
|
||||
Cloud.isOnlineWithPingAsync()
|
||||
.then(isOnline => {
|
||||
if (isOnline) {
|
||||
var login = (<any>TDev).Login;
|
||||
if (login && login.show) {
|
||||
login.show()
|
||||
return
|
||||
}
|
||||
}
|
||||
ModalDialog.info(lf("sign-in required"), lf("Sign-in is required, but you appear to be offline."))
|
||||
})
|
||||
.done()
|
||||
else
|
||||
authenticateAsync(action).done()
|
||||
} else {
|
||||
ModalDialog.info(lf("access denied"), lf("Your access token might have expired. Please return to the main hub and then try again."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (e.status == 419 || e.status == 402) {
|
||||
|
|
|
@ -936,6 +936,8 @@ module TDev{
|
|||
|
||||
export function svgGravatar(id : string) : string
|
||||
{
|
||||
if (!id) id = "none";
|
||||
|
||||
var advance = (hash:number, v:number) => ((hash << 16) + (hash << 6) + v - hash) << 0;
|
||||
var hash = 0;
|
||||
for (var i = 0; i < id.length; ++i) {
|
||||
|
@ -948,10 +950,10 @@ module TDev{
|
|||
var d = "";
|
||||
var numPixels = 0
|
||||
|
||||
while (numPixels < 5) {
|
||||
while (numPixels < 6) {
|
||||
for (var x = 0; x < 3; ++x) {
|
||||
for (var y = 0; y < 5; ++y) {
|
||||
hash = advance(hash, 0)
|
||||
hash = advance(hash, id.charCodeAt(i++ % id.length))
|
||||
n = hash & 0xffff;
|
||||
if (n > 30000) {
|
||||
// svg += Util.fmt("<rect fill='white' stroke-width='5' stroke='{0}' width='20.5' height='20.5' x='{1}' y='{2}' rx='3' ry='3'/>", c, 50 * x, 50 * y)
|
||||
|
@ -966,6 +968,7 @@ module TDev{
|
|||
}
|
||||
}
|
||||
}
|
||||
numPixels++
|
||||
}
|
||||
|
||||
var svg = Util.fmt("<path fill='{0}' d='{1}' />", c, d);
|
||||
|
|
|
@ -268,9 +268,10 @@ module TDev {
|
|||
|
||||
function publishInstalledAsync(indexTable: Storage.Table, scriptsTable: Storage.Table, header: Cloud.Header) : Promise {
|
||||
log(header.guid + "/" + header.scriptId + ": " + header.name + " is to be published");
|
||||
var hidden = header.publishAsHidden
|
||||
return indexTable.getValueAsync(header.guid)
|
||||
.then(resp => { header = JSON.parse(resp) })
|
||||
.then(() => Cloud.postUserInstalledPublishAsync(header.guid, header.publishAsHidden, JSON.stringify(header.scriptVersion), header.meta))
|
||||
.then(() => Cloud.postUserInstalledPublishAsync(header.guid, hidden, JSON.stringify(header.scriptVersion), header.meta))
|
||||
.then(function (installedBodies: Cloud.InstalledBodies) {
|
||||
var body = <Cloud.Body>undefined;
|
||||
installedBodies.bodies.forEach(function (b) { if (b.guid == header.guid) body = b; });
|
||||
|
|