From ab8f1b0fc16c1a806a6246e30ae695b13ff46330 Mon Sep 17 00:00:00 2001 From: Ahmet Bora Date: Tue, 21 May 2019 13:46:14 +0300 Subject: [PATCH] Version 1.0.3 --- css/style.css | 4 ++++ js/tasks.js | 50 ++++++++++++++++++++++++++++++++++++++++---------- manifest.json | 2 +- package.json | 2 +- popup.html | 3 ++- readme.md | 3 +++ 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/css/style.css b/css/style.css index dcffe63..92c220a 100644 --- a/css/style.css +++ b/css/style.css @@ -252,4 +252,8 @@ p.remove-confirm strong { #footer a:hover { color: #333; +} + +#footer span#total-time { + float: right; } \ No newline at end of file diff --git a/js/tasks.js b/js/tasks.js index be90a1f..c36f703 100644 --- a/js/tasks.js +++ b/js/tasks.js @@ -45,10 +45,11 @@ var tasks = { insert: function (id, project_name, name) { db.transaction(function (tx) { tx.executeSql("INSERT INTO tasks (id, project_name, name, time, start, running) VALUES (?, ?, ?, ?, ?, ?)", [id, project_name, name, 0, new Date(), false], - function (tx, result) { - taskInterface.index(); - }, - onError); + function (tx, result) { + taskInterface.index(); + taskInterface.count(); + }, + onError); }); }, @@ -59,11 +60,12 @@ var tasks = { remove: function (id) { db.transaction(function (tx) { tx.executeSql("DELETE FROM tasks WHERE id=?", [id], - function (tx, result) { - window.clearInterval(taskInterface.intervals[id]); - taskInterface.index(); - }, - onError); + function (tx, result) { + window.clearInterval(taskInterface.intervals[id]); + taskInterface.index(); + taskInterface.count(); + }, + onError); }); }, @@ -76,6 +78,7 @@ var tasks = { } taskInterface.index(); + taskInterface.count(); }, onError); }); }, @@ -84,6 +87,7 @@ var tasks = { db.transaction(function (tx) { tx.executeSql("UPDATE tasks SET time = ?", [0], function (tx, results) { taskInterface.index(); + taskInterface.count(); }, onError); }); } @@ -255,6 +259,7 @@ var taskInterface = { db.transaction(function (tx) { tx.executeSql("UPDATE tasks SET project_name = ?, name = ?, time = ? WHERE id = ?", [project_name, name, taskInterface.sec(time), id], function (tx, results) { taskInterface.index(); + taskInterface.count(); }, onError); }); }); @@ -271,6 +276,7 @@ var taskInterface = { db.transaction(function (tx) { tx.executeSql("UPDATE tasks SET time = ? WHERE id = ?", [0 , id], function (tx, results) { taskInterface.index(); + taskInterface.count(); }, onError); }); @@ -326,10 +332,34 @@ var taskInterface = { }, null); }); }, + + count: function () { + var totalTime = 0; + + db.transaction(function (tx) { + tx.executeSql('SELECT * FROM tasks ORDER BY id DESC', [], function (tx, results) { + + var len = results.rows.length, i; + + if (len > 0) + { + for (i = 0; i < len; i++) + { + var task = results.rows.item(i); + totalTime += task.time; + } + } + + $("#total-time-counter").html(taskInterface.hms(totalTime)); + + }, null); + }); + }, init: function () { this.bind(); this.index(); + this.count(); this.toggleRunText(); }, @@ -348,8 +378,8 @@ var taskInterface = { taskInterface.startTask(task); } + taskInterface.count(); taskInterface.toggleRunText(); - } else { alert("Task " + id + " not found sorry!"); } diff --git a/manifest.json b/manifest.json index ec32e4c..a692b31 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "update_url":"http://clients2.google.com/service/update2/crx", "name": "Simple Time Tracker", "description": "Simple Time Tracker - How much time spend on tasks?", - "version": "1.0.2", + "version": "1.0.3", "manifest_version": 2, "content_security_policy": "script-src 'self'; object-src 'self'", "icons": diff --git a/package.json b/package.json index 6a3c80a..3eb80c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SimpleTimeTracker", - "version": "1.0.2", + "version": "1.0.3", "description": "Simple time tracker extensions for Google Chrome", "keywords": [ "chrome", diff --git a/popup.html b/popup.html index 9b38d1b..8552d27 100644 --- a/popup.html +++ b/popup.html @@ -4,7 +4,7 @@ Simple Time Tracker Aplication for Chrome Extension - +
@@ -76,6 +76,7 @@
diff --git a/readme.md b/readme.md index 37202f4..b5bc9e7 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,9 @@ https://chrome.google.com/webstore/detail/simple-time-tracker/ifdmgpcchapjlldljf # CHANGELOG +1.0.3 +- Added total time counter + 1.0.2 - Fixed delete confirmations