Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.history
Binary file added src/img/logo-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/js/_date-filter-directive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
Copyright 2016 - 2022 Therp (http://therp.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/

Expand Down
2 changes: 1 addition & 1 deletion src/js/_localstorage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
Copyright 2016 - 2022 Therp (http://therp.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/

Expand Down
2 changes: 1 addition & 1 deletion src/js/_main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
Copyright 2016 - 2022 Therp (http://therp.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/

Expand Down
2 changes: 1 addition & 1 deletion src/js/_sfit-readmore-directive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
Copyright 2016 - 2022 Therp (http://sunflowerweb.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/

Expand Down
2 changes: 1 addition & 1 deletion src/js/_utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
Copyright 2016 - 2022 Therp (http://therp.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/

Expand Down
62 changes: 33 additions & 29 deletions src/js/background.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/
// ---- one API alias for Chrome/Firefox ----
const api = (typeof chrome !== 'undefined' && chrome.runtime)
? chrome // Chrome (and Chromium)
: (typeof browser !== 'undefined' ? browser : null); // Firefox

var online = "it is online";
console.log(online);
var TogglButton = {
setBrowserAction: function (timer) {
console.log("TIMER CHECK:" + timer);
if (timer === true) {
var imagePath = {'19': 'img/icon_19.png', '38': 'img/icon_38.png'};
}
else if (timer === 'pause') {
var imagePath = {'19': 'img/icon-pause.png', '38': 'img/icon-pause.png'};
}
else {
var imagePath = {'19': 'img/inactive_19.png', '38': 'img/inactive_19.png'};
}
browser.action.setIcon({
path: imagePath,
});
console.log("works");
},
};
browser.runtime.onMessage.addListener(async (msg, sender) => {
console.log("BG page received message", msg, "from", sender);
console.log("Stored data", await browser.storage.local.get());
TogglButton.setBrowserAction(msg.TimerActive);
});
if (!api) throw new Error('No extension API found');

// helpers
const R = api.runtime;
const A = api.action || api.browserAction; // MV3 uses action
const S = api.storage;
const url = (p) => R.getURL(p); // build extension-absolute URLs

const TogglButton = {
setBrowserAction(timer) {
console.log('TIMER CHECK:', timer);
let path;
if (timer === true || String(timer).toLowerCase() === 'true') {
path = { 19: url('img/icon_19.png'), 38: url('img/icon_38.png') };
} else if (String(timer).toLowerCase() === 'pause') {
path = { 19: url('img/icon-pause.png'), 38: url('img/icon-pause.png') };
} else {
path = { 19: url('img/inactive_19.png'), 38: url('img/inactive_38.png') };
}
const p = A.setIcon({ path });
if (p?.catch) p.catch(err => console.error('setIcon failed:', err));
},
};

// Message listener (works in both)
api.runtime.onMessage.addListener(async (msg, sender) => {
console.log('BG got message', msg, 'from', sender);
const data = await S?.local?.get?.(['TimerActive']);
console.log('Stored data', data);
TogglButton.setBrowserAction(msg?.TimerActive);
});
2 changes: 1 addition & 1 deletion src/js/options_main_page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016 - 2022 Sunflower IT (http://sunflowerweb.nl)
Copyright 2016 - 2022 Therp (http://therp.nl)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/

Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"default_title": "Therp Timer",
"default_popup": "popup.html"
},
"devtools_page": "/devtools/devtools-page.html",
"background": {
"scripts": [
"/js/lib/browser-polyfill.js",
"/js/lib/jquery-3.6.0.min.js",
"/js/background.js"
]
],
"service_worker": "/js/background.js"
},
"options_ui": {
"page": "options_main_page.html"
Expand Down
4 changes: 2 additions & 2 deletions src/options_main_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h1>
<div class="about-app">
<h4 class="title-app text-center">Description</h4>
<hr/>
This is a cross-platform Sunflower IT Timer App that works in
This is a cross-platform Therp Timer App that works in
Firefox, Opera and Chrome browsers with the aim of registering working
hours of individual's issues/tasks based on Odoo timesheets.
<hr/>
Expand Down Expand Up @@ -94,7 +94,7 @@ <h4 class="remote-title text-info">Add Remote</h4>
type="text"
ng-model="data.remote_host" type="text"
class="form-control" id="remote-host"
placeholder="https://wwww.sunflowerweb.nl">
placeholder="https://wwww.therp.nl">
</div>
<div class="form-group">
<label for="remote-database">Display Name</label>
Expand Down