From ffc2f74a95470a5cc264abc0458f445157668bc9 Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Sun, 25 Sep 2011 00:56:39 +0100 Subject: [PATCH] Seconds -> Minutes & seconds conversion for onReconnecting() --- js/front.events.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/front.events.js b/js/front.events.js index a03b022..4966721 100644 --- a/js/front.events.js +++ b/js/front.events.js @@ -175,7 +175,7 @@ kiwi.front.events = { kiwi.plugs.run('disconnect', {success: false}); }, onReconnecting: function (e, data) { - var err_box, f, msg; + var err_box, f, msg, mins, secs; err_box = $('.messages .msg.error.disconnect .text'); if (!err_box) { @@ -196,7 +196,15 @@ kiwi.front.events = { }; // TODO: convert seconds to mins:secs - msg = f(data.attempts) + ' attempt at reconnecting in ' + (data.delay / 1000).toString() + ' seconds..'; + secs = Math.floor(data.delay / 1000); + mins = Math.floor(secs / 60); + secs = secs % 60; + if (mins > 0) { + msg = f(data.attempts) + ' attempt at reconnecting in ' + mins + ' minute' + ((mins > 1) ? 's' : '') + ' , ' + secs + 'second' + (((secs > 1) || (secs === 0)) ? 's' : '') + '...'; + } else { + msg = f(data.attempts) + ' attempt at reconnecting in ' + secs + ' second' + (((secs > 1) || (secs === 0)) ? 's' : '') + '...'; + } + err_box.text(msg); }, onOptions: function (e, data) { -- 2.25.1