DEV Community

Cover image for Vs Code Extension
Ganesh Raja
Ganesh Raja

Posted on β€’ Edited on

Vs Code Extension

Today I spent time updating the code from JS file to Class Format. The update is partially done. I will be continuing this tomorrow. You can check full code in Repo as well.

const vscode = require("vscode");

const pomodo = class Pomodoro {
  constructor(context) {
    this.vsCodeStatusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment["Right"], 10);
    this.context = context;
  }
  startPomodoTimer() {
    this.vsCodeStatusBar.text = "Pomodo Started";
    this.vsCodeStatusBar.show();
    this.startWorkTimer();
  }
  appendZero() {
    this.num <= 9 ? "0" + this.num : this.num;
  }

  updateStatusBar(min, sec, icon) {}

  timer(countDownTime, callEverySecond = null, counterisDone = null, icon = null) {
    let countDownTimer = countDownTime;
    let that = this;
    let timerId = setInterval(function () {
      countDownTimer -= 1000;
      let min = Math.floor(countDownTimer / (60 * 1000));
      let sec = Math.floor((countDownTimer - min * 60 * 1000) / 1000);

      if (countDownTimer <= 0) {
        clearInterval(timerId);
        if (counterisDone) counterisDone();
      } else {
        that.vsCodeStatusBar.text = icon + " " + this.appendZero(min) + " : " + this.appendZero(sec);
      }
    }, 1000);
  }

  startWorkTimer() {
    const pomodoCountDown = 5 * 60 * 1000;
    const tomatodIcon = "πŸ…";
    this.timer(pomodoCountDown, this.updateStatusBar, this.startRestTimer, tomatodIcon);
  }

  pomodoDone() {
    this.vsCodeStatusBar.text = "Pomodo Done!!!";
  }

  startRestTimer() {
    const restCountDown = 1 * 60 * 100;
    const restIcon = "🌴";
    this.timer(restCountDown, this.updateStatusBar, this.pomodoDone, restIcon);
  }
};
exports.pomodo = pomodo;

Enter fullscreen mode Exit fullscreen mode

Image of Timescale

πŸ“Š Benchmarking Databases for Real-Time Analytics Applications

Benchmarking Timescale, Clickhouse, Postgres, MySQL, MongoDB, and DuckDB for real-time analytics. Introducing RTABench πŸš€

Read full post β†’

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay