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

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more