diff --git a/src/extension.js b/src/extension.js index 337f23e..34914f0 100644 --- a/src/extension.js +++ b/src/extension.js @@ -65,22 +65,22 @@ function _getTimerStartValue() { // update timer value if slider has changed function _onSliderChanged() { settings.set_int('slider-value', (slider.value * 100)); - const [houers, minutes] = timer.calculateTimeStamp(_getTimerStartValue()) - switcher.label.text = houers + ' ' +_("h : ") + minutes + ' min'; + const [hours, minutes] = timer.convertTime(_getTimerStartValue()) + switcher.label.text = hours + ' ' +_("h : ") + minutes + ' min'; if (settings.get_boolean('root-mode-value')) { - switcher.label.text = houers + ' ' +_("h : ") + minutes + ' min (root)'; + switcher.label.text = hours + ' ' +_("h : ") + minutes + ' min (root)'; } } function _onSettingsChanged() { let sliderValue = settings.get_int('slider-value') / 100.0; slider.value = sliderValue; - const [houers, minutes] = timer.calculateTimeStamp(_getTimerStartValue()) - switcher.label.text = houers + ' ' +_("h : ") + minutes + ' ' +_("min"); + const [hours, minutes] = timer.convertTime(_getTimerStartValue()) + switcher.label.text = hours + ' ' +_("h : ") + minutes + ' ' +_("min"); if (settings.get_boolean('root-mode-value')) { - switcher.label.text = houers + ' ' +_("h : ") + minutes + ' ' +_("min (root)"); + switcher.label.text = hours + ' ' +_("h : ") + minutes + ' ' +_("min (root)"); } } @@ -94,9 +94,9 @@ function _onShowSettingsButtonChanged() { function _onToggle() { if(switcher.state) { timer.startTimer(); - const [houers, minutes] = timer.calculateTimeStamp(_getTimerStartValue()) + const [hours, minutes] = timer.convertTime(_getTimerStartValue()) _showTextbox( _("System will shutdown in")+ ' ' - + houers + ' ' +_("h : ") + minutes + ' '+_("minutes")); + + hours + ' ' +_("h : ") + minutes + ' '+_("minutes")); } else { timer.stopTimer(); _showTextbox(_("Shutdown Timer stopped")); @@ -107,10 +107,10 @@ function _onToggle() { // menu items switcher and slider function _createSwitcherItem() { let switchMenuItem = new PopupMenu.PopupSwitchMenuItem('', false); - const [houers, minutes] = timer.calculateTimeStamp(_getTimerStartValue()) - switchMenuItem.label.text = houers + ' ' +_("h : ") + minutes + ' ' +_("min"); + const [hours, minutes] = timer.convertTime(_getTimerStartValue()) + switchMenuItem.label.text = hours + ' ' +_("h : ") + minutes + ' ' +_("min"); if(settings.get_boolean('root-mode-value')) { - switchMenuItem.label.text = houers + ' ' +_("h : ") + minutes + ' ' +_("min (root)"); + switchMenuItem.label.text = hours + ' ' +_("h : ") + minutes + ' ' +_("min (root)"); } switchMenuItem.connect('toggled', _onToggle); diff --git a/src/timer.js b/src/timer.js index d1611aa..ee26edf 100755 --- a/src/timer.js +++ b/src/timer.js @@ -36,8 +36,8 @@ const Timer = GObject.registerClass({}, class Timer extends GObject.Object { if(this._settings.get_boolean('use-suspend-value') || !this._settings.get_boolean('root-mode-value')) { this._startTime = GLib.get_monotonic_time(); this._timerId = Mainloop.timeout_add_seconds(1, () => this._timerCallback()); - const [houers, minutes] = this.calculateTimeStamp(this._timerValue) - this._menuLabel.text = houers + ' ' + _("h : ") + minutes + ' ' + _("min till shutdown"); + const [hours, minutes] = this.convertTime(this._timerValue) + this._menuLabel.text = hours + ' ' + _("h : ") + minutes + ' ' + _("min till shutdown"); } else { let pkexec_path = GLib.find_program_in_path('pkexec'); let shutdown_path = GLib.find_program_in_path('shutdown'); @@ -57,8 +57,8 @@ const Timer = GObject.registerClass({}, class Timer extends GObject.Object { let secondsLeft = (this._timerValue*60) - secondsElapsed; if (this._menuLabel && (secondsLeft % 60 == 0)) { - const [houers, minutes] = this.calculateTimeStamp(Math.floor(secondsLeft / 60)) - this._menuLabel.text = houers + ' ' +_("h : ") + minutes +' ' +_("min till shutdown"); + const [hours, minutes] = this.convertTime(Math.floor(secondsLeft / 60)) + this._menuLabel.text = hours + ' ' +_("h : ") + minutes +' ' +_("min till shutdown"); } if (secondsLeft > 0) { return true; @@ -69,11 +69,11 @@ const Timer = GObject.registerClass({}, class Timer extends GObject.Object { } /** - * Calculates houers and minutes from a time in minutes + * Calculates hours and minutes from a time in minutes * @param {number} timeInMinutes - * @returns {number[]} houers at i = 0, minutes at i = 1 + * @returns {Array} hours at index 0, minutes at index 1 */ - calculateTimeStamp(timeInMinutes) { + convertTime(timeInMinutes) { const hours = Math.floor(timeInMinutes / 60) const minutes = timeInMinutes - hours * 60 return [hours, minutes]