This commit is contained in:
Peli de Halleux 2015-11-11 15:24:07 -08:00
Родитель aa5c816911 12b8c1f1bd
Коммит 4dbc49c41c
4 изменённых файлов: 41 добавлений и 2 удалений

Просмотреть файл

@ -3277,6 +3277,7 @@ module TDev
return final();
}).then(() => {
Ticker.setCurrentEditorId("touchdevelop");
if (!shouldRun) return Browser.EditorSettings.initEditorModeAsync().then(() => this.setMode(true))
else return Promise.as();
}).then(() => {

Просмотреть файл

@ -304,6 +304,7 @@ module TDev {
switch ((<Message> event.data).type) {
case MessageType.Save: {
tick(Ticks.externalSave);
var message = <Message_Save> event.data;
World.getInstalledHeaderAsync(this.guid).then((header: Cloud.Header) => {
var scriptText = message.script.scriptText;
@ -538,6 +539,7 @@ module TDev {
break;
case MessageType.Load:
tick(Ticks.externalLoad);
var message4 = <Message_Load> event.data;
ArtUtil.handleImportFilesAsync([message4.file]).done();
break;
@ -586,6 +588,8 @@ module TDev {
baseSnapshot: null,
};
Ticker.setCurrentEditorId(editor.id);
// Clear leftover iframes and simulators.
document.getElementById("externalEditorSide").setChildren([]);
var iframeDiv = document.getElementById("externalEditorFrame");

Просмотреть файл

@ -1973,8 +1973,10 @@
if (s instanceof TopicInfo)
this.reloadHelpTopic = setHash;
else
else {
Ticker.setCurrentEditorId("shell");
this.reloadHelpTopic = null;
}
Host.tryUpdate();
this.syncTabVisibility();

Просмотреть файл

@ -242,6 +242,8 @@ module TDev {
editorTutorialNext,
editorTutorialPrevious,
externalSave,
externalLoad,
externalCompile,
externalRun,
@ -605,7 +607,7 @@ module TDev {
var disabled = false;
var delay = 10; // initial, 10s
var chunkId = 1;
var maxDelay = 1200; // 1200s
var maxDelay = 300; // 300s
var initialized = false;
export var mainJsName = "unknown";
@ -665,6 +667,8 @@ module TDev {
}
}
usageTick();
initialized = true;
}
@ -977,6 +981,9 @@ module TDev {
logIdx = 0;
}
if (t != Ticks.dbgEvent)
poke();
// this one we only wanted logged, not counted
if (t != Ticks.dbgEvent && shouldStoreTick(tn)) {
if (sessionEvents[tn])
@ -1007,6 +1014,31 @@ module TDev {
else
return logMsgs.slice(0);
}
function usageTick()
{
var id = getCurrentEditorId();
if (id && !document.hidden && lastPoke) {
if (Browser.isCellphone)
id += "_mobile"
rawTick("editor_" + id)
lastPoke = 0;
}
// avarage out to once per 10s, but get more even probabilistic distribution
Util.setTimeout(RT.Math_.random_range(3000,17000), usageTick)
}
var currentEditorId:string;
var lastPoke:number;
export function poke()
{
lastPoke = Util.now();
}
export function setCurrentEditorId(id:string) {
Util.log("set editor: " + id)
currentEditorId = id;
}
export function getCurrentEditorId() { return currentEditorId; }
}
export function tick(t: Ticks, arg?: string) { Ticker.tick(t, arg) }