Back

FocusThingy

A small JavaScript application using IndexedDB.


This JavaScript application allows the user to enter a specific task he or she wants to work on. The entered task is persisted across multiple browser sessions, using IndexedDB.

The project was my excuse to practice some Javascript as well as applying the principles of OfflineFirst. I decided to use IndexedDB, because it seems to be the simplest solution for persistent offline storage. There is also localStorage which has limits on the maximum size of data. Other frameworks, such as hood.ie or PouchDB also allow syncing with a server.

Things left to improve

  • Remove task if it’s older than 24 hours so that the user would no longer have to remove yesterday’s task by hand.

Code snippets

focusApp.indexedDB.updateTask = function(taskText) {
  var db = focusApp.indexedDB.db;

  var trans = db.transaction(["task"], "readwrite");
  var store = trans.objectStore("task");
  var request = store.put({
    "text": taskText,
    "timeStamp": new Date().getTime()
  }, 1);

  request.onerror = function(e) {
    console.log(e.value);
  };
};

This function is responsible for saving a modified task text.

Download

No download available.

FocusThingy on GitHub/GitLab

Download the latest source or clone/fork the project from source control.