workaround for leading zeros causing failure in string to int conversion in older gnome-shell versions

This commit is contained in:
Olaf Leidinger 2014-06-23 22:59:58 +02:00
parent 60a8f34563
commit 241a3dc475

View File

@ -253,16 +253,16 @@ const TeaTime = new Lang.Class({
let seconds = 0; let seconds = 0;
let match = customTime.match(/^(?:(\d+)(?::(\d{0,2}))?|:(\d+))$/) let match = customTime.match(/^(?:(\d+)(?::(\d{0,2}))?|:(\d+))$/)
if (match) { if (match) {
if (match[3]) let factor = 1;
seconds = parseInt(match[3]); for (var i = match.length-2; i > 0; i--) {
else { let s = match[i].replace(/^0/,''); // fix for elder GNOME <= 3.10 which don't like leading zeros
if (match[1]) seconds += factor * parseInt(s);
seconds += parseInt(match[1]) * 60; factor *= 60;
if (match[2]) }
seconds += parseInt(match[2]); if (seconds > 0) {
this._initCountdown(seconds);
this.menu.close();
} }
this._initCountdown(seconds);
this.menu.close();
} }
this._customEntry.set_text(""); this._customEntry.set_text("");
} }