Skip to content

Commit

Permalink
Correct spelling mistake and rename timer.calculateTimeStamp
Browse files Browse the repository at this point in the history
  • Loading branch information
your-local-developer committed Jul 21, 2022
1 parent 0205860 commit 7fd0960
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
}
}

Expand All @@ -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"));
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand All @@ -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<number>} 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]
Expand Down

0 comments on commit 7fd0960

Please sign in to comment.