mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
cleanup plugin code
This commit is contained in:
parent
922196c541
commit
cfe0951c9f
1 changed files with 0 additions and 57 deletions
|
|
@ -8,60 +8,3 @@ PluginAPI.registerShortcut({
|
|||
PluginAPI.showIndexHtmlAsView();
|
||||
},
|
||||
});
|
||||
|
||||
// Helper function to get yesterday's date range
|
||||
function getYesterdayRange() {
|
||||
const now = new Date();
|
||||
const yesterday = new Date(now);
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
|
||||
// Set to start of yesterday (00:00:00)
|
||||
const startOfYesterday = new Date(yesterday);
|
||||
startOfYesterday.setHours(0, 0, 0, 0);
|
||||
|
||||
// Set to end of yesterday (23:59:59)
|
||||
const endOfYesterday = new Date(yesterday);
|
||||
endOfYesterday.setHours(23, 59, 59, 999);
|
||||
|
||||
return {
|
||||
start: startOfYesterday.getTime(),
|
||||
end: endOfYesterday.getTime(),
|
||||
};
|
||||
}
|
||||
|
||||
// Function to calculate total time spent
|
||||
function calculateTimeSpent(timeSpentOnDay) {
|
||||
if (!timeSpentOnDay) return 0;
|
||||
|
||||
let total = 0;
|
||||
for (const date in timeSpentOnDay) {
|
||||
const entries = timeSpentOnDay[date];
|
||||
if (Array.isArray(entries)) {
|
||||
for (const entry of entries) {
|
||||
if (entry && typeof entry === 'object') {
|
||||
total += entry.e - entry.s || 0;
|
||||
}
|
||||
}
|
||||
} else if (typeof entries === 'number') {
|
||||
total += entries;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// Function to format duration
|
||||
function formatDuration(ms) {
|
||||
if (!ms || ms === 0) return '0m';
|
||||
|
||||
const hours = Math.floor(ms / (1000 * 60 * 60));
|
||||
const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60));
|
||||
|
||||
if (hours > 0) {
|
||||
return hours + 'h ' + minutes + 'm';
|
||||
}
|
||||
return minutes + 'm';
|
||||
}
|
||||
|
||||
// Note: The plugin.js runs in a sandboxed environment separate from the iframe.
|
||||
// The iframe has access to PluginAPI for communication with the host app,
|
||||
// but not to variables defined in plugin.js.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue