From ff5d568259c9451ffafb016b41eac134a6a3e098 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 22 Jul 2015 22:09:52 -0600 Subject: [PATCH] * A few MCI codes * Fix timer/flicker bug @ connect ANSI term size detection --- core/connect.js | 18 ++++++++++++------ core/mci_view_factory.js | 7 +++++++ mods/apply.js | 1 + mods/art/userstats.ans | Bin 904 -> 1063 bytes 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/connect.js b/core/connect.js index ac6e124e..f89301ec 100644 --- a/core/connect.js +++ b/core/connect.js @@ -21,12 +21,18 @@ function ansiQueryTermSizeIfNeeded(client, cb) { return; } + var done = function(res) { + client.removeListener('cursor position report', cprListener); + clearTimeout(giveUpTimer); + cb(res); + }; + var cprListener = function(pos) { // // If we've already found out, disregard // if(client.term.termHeight > 0 || client.term.termWidth > 0) { - cb(true); + done(true); return; } @@ -42,7 +48,7 @@ function ansiQueryTermSizeIfNeeded(client, cb) { client.log.warn( { height : h, width : w }, 'Ignoring ANSI CPR screen size query response due to very small values'); - cb(false); + done(false); return; } @@ -58,17 +64,17 @@ function ansiQueryTermSizeIfNeeded(client, cb) { 'Window size updated' ); - cb(true); + done(true); }; client.once('cursor position report', cprListener); // give up after 2s - setTimeout(function onTimeout() { - client.removeListener('cursor position report', cprListener); - cb(false); + var giveUpTimer = setTimeout(function onTimeout() { + done(false); }, 2000); + // This causes client.term.write(ansi.queryScreenSize()); } diff --git a/core/mci_view_factory.js b/core/mci_view_factory.js index d6dfe8bf..802a4a85 100644 --- a/core/mci_view_factory.js +++ b/core/mci_view_factory.js @@ -46,9 +46,16 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) { UW : this.client.user.properties.web_address, UF : this.client.user.properties.affiliation, UT : this.client.user.properties.theme_id, + MS : moment(this.client.user.properties.timestamp).format(this.client.currentTheme.helpers.getDateFormat()), + + + SH : this.client.term.termHeight.toString(), + SW : this.client.term.termWidth.toString(), ND : this.client.runtime.id.toString(), + DT : moment().format(this.client.currentTheme.helpers.getDateFormat()), + OS : { linux : 'Linux', darwin : 'Mac OS X', diff --git a/mods/apply.js b/mods/apply.js index 8aa0615e..11ef0d82 100644 --- a/mods/apply.js +++ b/mods/apply.js @@ -92,6 +92,7 @@ function submitApplication(callingMenu, formData, extraArgs) { affiliation : formData.value.affils, email_address : formData.value.email, web_address : formData.value.web, + timestamp : new Date().toISOString(), // :TODO: This is set in User.create() -- proabbly don't need it here: //account_status : Config.users.requireActivation ? user.User.AccountStatus.inactive : user.User.AccountStatus.active, diff --git a/mods/art/userstats.ans b/mods/art/userstats.ans index 5b35b80c3472b49945672cb0f581817aa8871b6d..2e38ebcc8ef4443452883e3b4f72ab687dde21bc 100644 GIT binary patch delta 196 zcmeBRU(PW>*Fix+I@%ytI@-|O8A#*;dBz60A*n^V3c;CGsUSH$C;&;T277=NQ~*iy zTm{wO@QJ$W)*w|NbAZ}mrkNs{=8{-~Vi4FouxTzK8$;L`)uf}141wx_7Q1B@6_+SD iC+6fJ*$h_d8@xH1v6^x6btbjR|Cmx3mrYJ)Rs{f%H#9i_ delta 32 ocmZ3^(ZN1JcVe#k#`ElqoBuFYGfpmJR-ZhFIhB!pG82m`0KxbQWdHyG