mirror of
https://github.com/oleid/gnome-shell-teatime.git
synced 2022-04-29 18:53:50 +00:00
workaround for leading zeros causing failure in string to int conversion in older gnome-shell versions
This commit is contained in:
parent
60a8f34563
commit
241a3dc475
@ -253,17 +253,17 @@ 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]);
|
|
||||||
}
|
}
|
||||||
this._initCountdown(seconds);
|
if (seconds > 0) {
|
||||||
this.menu.close();
|
this._initCountdown(seconds);
|
||||||
}
|
this.menu.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
this._customEntry.set_text("");
|
this._customEntry.set_text("");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user