diff --git a/all-websites/index.html b/all-websites/index.html
new file mode 100644
index 0000000..c6d7101
--- /dev/null
+++ b/all-websites/index.html
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
All spent time
+
+
+
+
+
+
+
+
+
+
+
+
+ Paste here the JSON (or text) file content you exported previously, then click the Import now
+ button. The page will be automatically reloaded if data are successfully imported.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create a new JSON (or text) file and paste the code below without modifying
+ it (you can click the Copy now button to copy the code).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/css/style.css b/css/style.css
index 8f30cf3..49b2d88 100644
--- a/css/style.css
+++ b/css/style.css
@@ -18,6 +18,13 @@
box-sizing: border-box;
font-family: open-sans;
font-size: 16px;
+ transition: 0.5s;
+ position: relative;
+ z-index: 1;
+ scrollbar-color: #0080ff transparent;
+ scrollbar-width: thin;
+ outline: 0px solid transparent;
+ border-radius: 5px;
}
body {
@@ -44,24 +51,32 @@ body {
background-color: #0080ff;
}
-#website-section, #buy-me-a-coffee-section {
+.section-popup {
position: relative;
width: 350px;
height: auto;
padding: 5px;
margin: 0px;
- background-color: #0080ff;
font-size: 16px;
- color: #ffffff;
text-align: center;
border: 0px solid transparent;
+ border-radius: 0px;
+}
+
+.background-primary {
+ background-color: #0080ff;
+ color: #ffffff;
+}
+
+.section-boder-bottom {
+ border-bottom: 1px solid #eeeeee;
}
#buy-me-a-coffee-section {
font-size: 12px;
cursor: pointer;
- border: 0px solid transparent;
margin: 0px;
+ padding: 5px;
}
#text-toggle-section {
@@ -74,6 +89,7 @@ body {
text-align: right;
padding: 0px;
position: relative;
+ overflow: visible;
}
#toggle-section {
@@ -95,6 +111,7 @@ body {
background-size: 20px auto;
background-repeat: no-repeat;
background-position: 5px center;
+ border-radius: 0px;
}
#toggle-container {
@@ -103,6 +120,7 @@ body {
position: relative;
border-radius: 10px;
cursor: pointer;
+ overflow: visible;
}
#toggle-background {
@@ -121,7 +139,7 @@ body {
#toggle-thumb {
width: 20px;
height: 20px;
- border-radius: 10px;
+ border-radius: 50%;
background-color: #0080ff;
border: 0px solid transparent;
position: absolute;
@@ -140,6 +158,20 @@ body {
background-image: url("../img/yes.png");
}
+#toggle-thumb:hover {
+ box-shadow: 0px 0px 0px 2px #0080ff55;
+ z-index: 2;
+}
+
+#toggle-thumb:active {
+ box-shadow: 0px 0px 0px 5px #0080ff66;
+ z-index: 2;
+}
+
+#details-section {
+ padding: 0px;
+}
+
#details-container {
position: relative;
width: 350px;
@@ -157,10 +189,12 @@ body {
'text1 text1 value1'
'text2 text2 value2';
grid-gap: 5px;
+ border-radius: 0px;
}
.grid-item {
padding: 0px 10px;
+ border-radius: 0px;
}
.grid-item-time-spent {
@@ -188,10 +222,6 @@ body {
grid-area: value2;
}
-.bold {
- font-family: open-sans-bold;
-}
-
.grey {
color: #dddddd;
}
@@ -200,10 +230,298 @@ body {
font-family: niconne;
}
+.button {
+ border-radius: 5px;
+ border: 0px solid transparent;
+ cursor: pointer;
+ font-size: 14px;
+ margin: 0px;
+ padding: 5px;
+ background-color: #0080ff;
+ color: #ffffff;
+ width: auto;
+ box-sizing: border-box;
+ display: inline-block;
+}
+
+.section-link {
+ width: auto;
+ background-color: #0080ff;
+ color: #ffffff;
+ cursor: pointer;
+}
+
+.button:hover, .section-link:hover {
+ background-color: #2c96ff;
+}
+
+.button:active, .button:focus, textarea:focus, textarea:active {
+ box-shadow: 0px 0px 0px 2px #0080ff, 0px 0px 0px 5px #84c0ff;
+ border-radius: 5px;
+ z-index: 2;
+}
+
+textarea {
+ width: 100%;
+ height: 300px;
+ border: 0px;
+ border-radius: 5px;
+ background-color: #ffffff;
+ color: #000000;
+ resize: none;
+ margin: 0px;
+ padding: 5px;
+ font-size: 14px;
+ overflow: auto;
+}
+
+#all-websites-dedication-section {
+ background-color: #eeeeee;
+ padding: 5px;
+ width: 70%;
+ height: 100%;
+ margin-left: auto;
+ margin-right: auto;
+ overflow: auto;
+}
+
+.section, .sub-section, .section-empty {
+ background-color: #ffffff;
+ padding: 5px;
+ margin: 5px;
+ border-radius: 5px;
+}
+
+.section-empty {
+ padding: 50px;
+ text-align: center;
+ color: #2c96ff;
+}
+
+.sticky-section {
+ position: -webkit-sticky;
+ position: sticky;
+ top: 0px;
+ z-index: 4;
+}
+
+table {
+ border-collapse: collapse;
+ padding: 5px;
+ width: 100%;
+}
+
+.sub-section {
+ background-color: #eeeeee;
+ padding: 10px;
+}
+
+tr {
+ background-color: #eeeeee;
+ padding: 10px;
+}
+
+tr:nth-child(even) {
+ background-color: #ffffff;
+}
+
+tr:hover {
+ background-color: #0090ff33;
+}
+
+.status-enabled {
+ background-color: #196c1944;
+ color: #007e00;
+ border-radius: 0px;
+}
+
+.status-disabled {
+ background-color: #8a111144;
+ color: #b70101;
+ border-radius: 0px;
+}
+
+.since-install-time {
+ background-color: #2c96ff44;
+ border-radius: 0px;
+}
+
+.yellow {
+ background-color: #ffd40044;
+ border-radius: 0px;
+}
+
+.orange {
+ background-color: #FF7C0044;
+ border-radius: 0px;
+}
+
+.red {
+ background-color: #ff000044;
+ border-radius: 0px;
+}
+
+#background-opacity {
+ background-color: rgba(0, 0, 0, 0.6);
+ position: fixed;
+ top: 0px;
+ bottom: 0px;
+ left: 0px;
+ right: 0px;
+ transition: 0.5s;
+ display: none;
+ z-index: 100;
+ border-radius: 0px;
+}
+
+#import-section, #export-section {
+ display: none;
+ background-color: transparent;
+ position: fixed;
+ top: 0px;
+ bottom: 0px;
+ left: 0px;
+ right: 0px;
+ z-index: 101;
+ padding: 10px;
+ padding-left: 20%;
+ padding-right: 20%;
+ overflow: auto;
+}
+
+.background-transparent {
+ background-color: transparent;
+}
+
+.background-light-red {
+ background-color: #ffbcbc;
+}
+
+.button-code {
+ background-color: #0080ff55;
+ border-radius: 5px;
+ padding: 5px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ font-size: 13px;
+}
+
+.small-button {
+ font-size: 12px;
+ height: 27px;
+}
+
+.very-small-button {
+ font-size: 10px;
+ height: 25px;
+}
+
+h1, h2, h3 {
+ color: #2c96ff;
+ font-size: 30px;
+ font-family: open-sans-bold;
+ padding: 0px;
+ padding-left: 20px;
+ margin: 0px;
+ display: inline-block;
+}
+
+h2, th {
+ color: #0080ff;
+ font-size: 18px;
+ padding: 5px;
+ padding-left: 10px;
+ font-family: open-sans;
+ height: 35px;
+}
+
+th {
+ min-width: 70px;
+ font-size: 14px;
+ background-color: #0080ff;
+ color: #ffffff;
+ border-radius: 0px;
+}
+
+td {
+ font-size: 14px;
+ text-align: center;
+ border: 1px solid transparent;
+}
+
+td:first-child {
+ text-align: left;
+}
+
+h3 {
+ color: #0080ff;
+ font-size: 14px;
+ padding: 3px;
+ font-family: open-sans;
+ height: 25px;
+}
+
+.go-to-external {
+ transition: 0s;
+ padding-right: 20px;
+}
+
+.go-to-external:hover::after {
+ content: url('../img/open-external.svg');
+ top: 12px;
+ margin-left: 5px;
+ position: absolute;
+}
+
+.section-selected {
+ background-color: #bee0ff;
+}
+
+.link {
+ cursor: pointer;
+ text-decoration: underline;
+}
+
+.bold, strong {
+ font-family: open-sans-bold;
+}
+
.font-size-20px {
font-size: 20px;
}
.font-size-24px {
font-size: 24px;
+}
+
+.text-align-right {
+ text-align: right;
+}
+
+.text-align-center {
+ text-align: center;
+}
+
+.text-align-left {
+ text-align: left;
+}
+
+.float-right {
+ float: right;
+}
+
+.margin-right-5-px {
+ margin-right: 5px;
+}
+
+.margin-top-5-px {
+ margin-top: 5px;
+}
+
+.overflow-auto {
+ overflow: auto;
+}
+
+.no-padding {
+ padding: 0px;
}
\ No newline at end of file
diff --git a/img/open-external.svg b/img/open-external.svg
new file mode 100644
index 0000000..cfbce74
--- /dev/null
+++ b/img/open-external.svg
@@ -0,0 +1,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/js/all-websites.js b/js/all-websites.js
new file mode 100644
index 0000000..a6c2b10
--- /dev/null
+++ b/js/all-websites.js
@@ -0,0 +1,298 @@
+let websites_json = {};
+let websites_json_by_domain = [];
+let smallest_date = "";
+let all_dates = [];
+
+function loaded() {
+ document.getElementById("refresh-data-button").onclick = function () {
+ //location.reload();
+ loadDataFromBrowser(true);
+ }
+ document.getElementById("delete-all-data-button").onclick = function () {
+ deleteAllData();
+ }
+ document.getElementById("import-data-button").onclick = function () {
+ importData();
+ }
+ document.getElementById("export-data-button").onclick = function () {
+ exportData();
+ }
+
+ loadDataFromBrowser(true);
+
+ document.getElementById("all-websites-dedication-section").onscroll = function () {
+ if (document.getElementById("all-websites-dedication-section").scrollTop > 30) {
+ document.getElementById("actions").classList.add("section-selected");
+ } else {
+ if (document.getElementById("actions").classList.contains("section-selected")) {
+ document.getElementById("actions").classList.remove("section-selected");
+ }
+ }
+ }
+}
+
+function loadDataFromBrowser(generate_section = true) {
+ browser.storage.local.get("websites", function (value) {
+ websites_json = {};
+ if (value["websites"] != undefined) {
+ websites_json = value["websites"];
+ }
+ if (generate_section) {
+ document.getElementById("all-websites-sections").textContent = "";
+ websites_json_by_domain = [];
+ loadAllWebsites();
+ }
+ //console.log(JSON.stringify(websites_json));
+ });
+}
+
+function deleteAllData() {
+ let confirmationClearAllNotes = confirm("Are you sure you want to clear all notes?\nYou can cancel this process once started.");
+ if (confirmationClearAllNotes) {
+ let clearStorage = browser.storage.local.clear();
+ clearStorage.then(onCleared, onError);
+ }
+}
+
+function deleteAWebsite(url) {
+ let confirmation = confirm("Are you sure you want to clear the selected notes?\nYou can cancel this process once started.");
+ if (confirmation) {
+ //delete the selected page
+ delete websites_json[url];
+
+ browser.storage.local.set({"websites": websites_json}, function () {
+ loadDataFromBrowser(true);
+ });
+ }
+}
+
+function onCleared() {
+ //all notes clear || successful
+ loadDataFromBrowser(true);
+}
+
+function onError(e) {
+}
+
+function importData() {
+ showBackgroundOpacity();
+ document.getElementById("import-section").style.display = "block";
+ let jsonImportElement = document.getElementById("json-import")
+ jsonImportElement.value = "";
+ jsonImportElement.focus();
+
+ document.getElementById("cancel-import-data-button").onclick = function () {
+ hideBackgroundOpacity();
+ document.getElementById("import-section").style.display = "none";
+ }
+ document.getElementById("import-now-data-button").onclick = function () {
+ let value = jsonImportElement.value;
+ if (value.replaceAll(" ", "") != "") {
+ try {
+ websites_json = JSON.parse(value);
+ document.getElementById("import-section").style.display = "none";
+ browser.storage.local.set({"websites": websites_json}, function () {
+ loadDataFromBrowser(true);
+ hideBackgroundOpacity()
+ });
+ } catch (e) {
+ //console.log("Error: " + e.toString());
+ let errorSubSection = document.createElement("div");
+ errorSubSection.classList.add("sub-section", "background-light-red");
+ errorSubSection.textContent = "Error: " + e.toString();
+
+ let mainSection = document.getElementById("import-sub-sections");
+ mainSection.insertBefore(errorSubSection, mainSection.childNodes[0]);
+ }
+ }
+ }
+}
+
+function exportData() {
+ showBackgroundOpacity();
+ browser.storage.local.get("websites", function (value) {
+ websites_json = {};
+ if (value["websites"] != undefined) {
+ websites_json = value["websites"];
+ }
+ document.getElementById("export-section").style.display = "block";
+ document.getElementById("json-export").value = JSON.stringify(websites_json);
+
+ document.getElementById("cancel-export-data-button").onclick = function () {
+ hideBackgroundOpacity();
+ document.getElementById("export-section").style.display = "none";
+ }
+ document.getElementById("copy-now-data-button").onclick = function () {
+ document.getElementById("cancel-export-data-button").value = "Close";
+
+ document.getElementById("json-export").value = JSON.stringify(websites_json);
+ document.getElementById("json-export").select();
+ document.execCommand("copy");
+ }
+ loadDataFromBrowser(true);
+ });
+}
+
+function showBackgroundOpacity() {
+ document.getElementById("background-opacity").style.display = "block";
+}
+
+function hideBackgroundOpacity() {
+ document.getElementById("background-opacity").style.display = "none";
+}
+
+function loadAllWebsites() {
+ if (!isEmpty(websites_json)) {
+ //there are websites saved
+
+ for (let url in websites_json) {
+ websites_json_by_domain.push(url);
+ }
+ //console.log(JSON.stringify(websites_json_by_domain));
+
+ websites_json_by_domain.sort();
+
+ smallest_date = getToday();
+
+ for (let index in websites_json_by_domain) {
+ for (let date in websites_json[websites_json_by_domain[index]]) {
+ if (date != "enabled") {
+ if (date < smallest_date) {
+ smallest_date = date;
+ }
+ }
+ }
+ }
+
+ all_dates = getAllDates(smallest_date, getToday());
+
+ let section = document.createElement("div");
+ section.classList.add("section", "overflow-auto", "no-padding");
+
+ let tableElement = document.createElement("table");
+
+ let tableRowElement = document.createElement("tr");
+
+ let tableHeaderElement = document.createElement("th");
+ tableHeaderElement.textContent = "Website";
+ tableRowElement.append(tableHeaderElement);
+
+ tableHeaderElement = document.createElement("th");
+ tableHeaderElement.textContent = "Status";
+ tableRowElement.append(tableHeaderElement);
+
+ tableHeaderElement = document.createElement("th");
+ tableHeaderElement.textContent = "Since install";
+ tableRowElement.append(tableHeaderElement);
+
+ for (let date in all_dates) {
+ let date_to_show = all_dates[date];
+ tableHeaderElement = document.createElement("th");
+ tableHeaderElement.textContent = date_to_show;
+ tableRowElement.append(tableHeaderElement);
+ }
+
+ tableElement.append(tableRowElement);
+
+ for (let index in websites_json_by_domain) {
+ tableRowElement = document.createElement("tr");
+
+ let current_website = websites_json_by_domain[index];
+
+ let currentWebsiteElement = document.createElement("h2");
+ currentWebsiteElement.textContent = "https://" + current_website;
+ currentWebsiteElement.classList.add("link", "go-to-external");
+ currentWebsiteElement.onclick = function () {
+ browser.tabs.create({url: "https://" + current_website});
+ }
+
+ let tableDataElement = document.createElement("td");
+ tableDataElement.append(currentWebsiteElement);
+ tableRowElement.append(tableDataElement);
+
+ let status_to_show = true;
+ if (websites_json[current_website]["enabled"] != undefined) {
+ status_to_show = websites_json[current_website]["enabled"];
+ }
+ tableDataElement = document.createElement("td");
+ if (status_to_show) {
+ tableDataElement.textContent = "enabled";
+ tableDataElement.classList.add("status-enabled");
+ } else {
+ tableDataElement.textContent = "disabled";
+ tableDataElement.classList.add("status-disabled");
+ }
+ tableRowElement.append(tableDataElement);
+
+ let sum_since_install = 0;
+ for (let date in all_dates) {
+ let date_to_show = all_dates[date];
+ if (websites_json[current_website][date_to_show] != undefined) {
+ sum_since_install += parseInt(websites_json[current_website][date_to_show].toString());
+ }
+ }
+ let since_install = getTimeConverted(sum_since_install);
+ tableDataElement = document.createElement("td");
+ tableDataElement.textContent = since_install;
+ tableDataElement.classList.add("since-install-time");
+ if (sum_since_install >= 60 * 30 && sum_since_install < 60 * 60) {
+ tableDataElement.classList.add("yellow");
+ } else if (sum_since_install >= 60 * 60 && sum_since_install < 60 * 60 * 3) {
+ tableDataElement.classList.add("orange");
+ } else if (sum_since_install >= 60 * 60 * 3) {
+ tableDataElement.classList.add("red");
+ }
+ tableRowElement.append(tableDataElement);
+
+ for (let date in all_dates) {
+ let date_to_show = all_dates[date];
+ let time_to_show = getTimeConverted(0);
+ let time = 0;
+ if (websites_json[current_website][date_to_show] != undefined) {
+ time = websites_json[current_website][date_to_show];
+ time_to_show = getTimeConverted(time);
+ }
+ if (time_to_show == "") time_to_show = getTimeConverted(0);
+ tableDataElement = document.createElement("td");
+ tableDataElement.textContent = time_to_show;
+ if (time >= 60 * 30 && time < 60 * 60) {
+ tableDataElement.classList.add("yellow");
+ } else if (time >= 60 * 60 && time < 60 * 60 * 3) {
+ tableDataElement.classList.add("orange");
+ } else if (time >= 60 * 60 * 3) {
+ tableDataElement.classList.add("red");
+ }
+ tableRowElement.append(tableDataElement);
+ }
+
+ tableElement.append(tableRowElement);
+ }
+
+ section.append(tableElement);
+ document.getElementById("all-websites-sections").append(section);
+
+ } else {
+ //no websites
+ let section = document.createElement("div");
+ section.classList.add("section-empty");
+ section.textContent = "No websites found";
+
+ document.getElementById("all-websites-sections").append(section);
+ }
+}
+
+function isEmpty(obj) {
+ return Object.keys(obj).length === 0
+}
+
+function getAllDates(startDate, stopDate) {
+ let dateArray = [];
+ let currentDate = new Date(startDate);
+ while (currentDate <= new Date(stopDate)) {
+ dateArray.push(getFormattedDate(new Date(currentDate)));
+ currentDate.setDate(currentDate.getDate() + 1);
+ }
+ return dateArray;
+}
+
+loaded();
\ No newline at end of file
diff --git a/js/background.js b/js/background.js
index 5177558..0aca87b 100644
--- a/js/background.js
+++ b/js/background.js
@@ -145,11 +145,17 @@ function getTheProtocol(url) {
function saveUrlToData(enabled, time = 0) {
let urlToUse = currentUrl;
+ //console.log(JSON.stringify(websites_json));
+
let valueToUse = {};
browser.storage.local.get("websites", function (value) {
+ websites_json = {};
if (value["websites"] != undefined) {
websites_json = value["websites"];
+ } else {
+ enabledOrNot = true;
}
+ //console.log(JSON.stringify(websites_json));
changedTab = false;
timeSpentToday = 0;
//timeSpentAlways = 0;
@@ -161,6 +167,8 @@ function saveUrlToData(enabled, time = 0) {
/*if (websites_json[urlToUse]["always"] != undefined) {
timeSpentAlways = websites_json[urlToUse]["always"];
}*/
+ } else {
+ websites_json[urlToUse] = {};
}
timeSpentToday += time;
diff --git a/js/definitions.js b/js/definitions.js
new file mode 100644
index 0000000..95c697f
--- /dev/null
+++ b/js/definitions.js
@@ -0,0 +1,88 @@
+function getTimeConverted(time) {
+ let timeToUse = time;
+ let timeToReturn = "";
+ if (timeToUse >= 60) {
+ //check minutes
+ if (timeToUse / 60 >= 60) {
+ //check hours
+ if (timeToUse / (60 * 60) >= 24) {
+ //check days
+ if (timeToUse / (60 * 60 * 24) >= 365) {
+ //check year(s)
+ if (getDayOrDays((timeToUse % (60 * 60 * 24 * 365))) != "") {
+ timeToReturn = getYearOrYears(timeToUse) + " and " + getDayOrDays((timeToUse % (60 * 60 * 24 * 365)));
+ } else {
+ timeToReturn = getYearOrYears(timeToUse);
+ }
+ } else {
+ //check day(s)
+ timeToReturn = getDayOrDays(timeToUse);
+ }
+ } else {
+ //hours
+ timeToReturn = getHourOrHours(timeToUse);
+ }
+ } else {
+ //minutes
+ timeToReturn = getMinuteOrMinutes(timeToUse);
+ }
+ } else {
+ //seconds
+ timeToReturn = getSecondOrSeconds(timeToUse);
+ }
+ return timeToReturn;
+}
+
+function getSecondOrSeconds(timeToUse) {
+ let timeToReturn = "";
+ if (timeToUse === 1) timeToReturn = timeToUse + " second";
+ else if (timeToUse === 0 || timeToUse > 1) timeToReturn = timeToUse + " seconds";
+ return timeToReturn;
+}
+
+function getMinuteOrMinutes(timeToUse) {
+ let timeToReturn = "";
+ if (timeToUse >= 60 && timeToUse < 60 * 2) timeToReturn = ((timeToUse - (timeToUse % 60)) / 60) + " minute";
+ else if (timeToUse >= 60 * 2) timeToReturn = ((timeToUse - (timeToUse % 60)) / 60) + " minutes";
+ return timeToReturn;
+}
+
+function getHourOrHours(timeToUse) {
+ let timeToReturn = "";
+ if (timeToUse / (60) >= 60 && timeToUse / (60) < 60 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60))) / (60 * 60)) + " hour";
+ else if (timeToUse / (60) >= 60 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60))) / (60 * 60)) + " hours";
+ return timeToReturn;
+}
+
+function getDayOrDays(timeToUse) {
+ let timeToReturn = "";
+ if (timeToUse / (60 * 60) >= 24 && timeToUse / (60 * 60) < 24 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24))) / (60 * 60 * 24)) + " day";
+ else if (timeToUse / (60 * 60) >= 24 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24))) / (60 * 60 * 24)) + " days";
+ return timeToReturn;
+}
+
+function getYearOrYears(timeToUse) {
+ let timeToReturn = "";
+ if (timeToUse / (60 * 60 * 24) >= 365 && timeToUse / (60 * 60 * 24) < 365 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24 * 365))) / (60 * 60 * 24 * 365)) + " year";
+ else timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24 * 365))) / (60 * 60 * 24 * 365)) + " years";
+ return timeToReturn;
+}
+
+function getToday() {
+ let todayDate = new Date();
+ return getFormattedDate(todayDate);
+}
+
+function getFormattedDate(date) {
+ let dateToUse = new Date(date);
+ let dateToReturn = "";
+ dateToReturn = dateToUse.getFullYear() + "-";
+ let month = dateToUse.getMonth() + 1;
+ if (month < 10) dateToReturn = dateToReturn + "0" + month + "-";
+ else dateToReturn = dateToReturn + "" + month + "-";
+ let day = dateToUse.getDate();
+ if (day < 10) dateToReturn = dateToReturn + "0" + day;
+ else dateToReturn = dateToReturn + "" + day;
+
+ return dateToReturn;
+}
\ No newline at end of file
diff --git a/js/script.js b/js/script.js
index 53d565d..a29fb37 100644
--- a/js/script.js
+++ b/js/script.js
@@ -48,6 +48,10 @@ function loaded() {
browser.tabs.create({url: linkDonate[0]});
window.close();
}
+ document.getElementById("open-all-websites").onclick = function () {
+ browser.tabs.create({url: "../all-websites/index.html"});
+ window.close();
+ }
}
function loadUI() {
@@ -274,90 +278,6 @@ function isUrlSupported(url) {
return valueToReturn;
}
-function getToday() {
- let todayDate = new Date();
- let today = "";
- today = todayDate.getFullYear() + "-";
- let month = todayDate.getMonth() + 1;
- if (month < 10) today = today + "0" + month + "-";
- else today = today + "" + month + "-";
- let day = todayDate.getDate();
- if (day < 10) today = today + "0" + day;
- else today = today + "" + day;
-
- return today;
-}
-
-function getTimeConverted(time) {
- let timeToUse = time;
- let timeToReturn = "";
- if (timeToUse >= 60) {
- //check minutes
- if (timeToUse / 60 >= 60) {
- //check hours
- if (timeToUse / (60 * 60) >= 24) {
- //check days
- if (timeToUse / (60 * 60 * 24) >= 365) {
- //check year(s)
- if (getDayOrDays((timeToUse % (60 * 60 * 24 * 365))) != "") {
- timeToReturn = getYearOrYears(timeToUse) + " and " + getDayOrDays((timeToUse % (60 * 60 * 24 * 365)));
- } else {
- timeToReturn = getYearOrYears(timeToUse);
- }
- } else {
- //check day(s)
- timeToReturn = getDayOrDays(timeToUse);
- }
- } else {
- //hours
- timeToReturn = getHourOrHours(timeToUse);
- }
- } else {
- //minutes
- timeToReturn = getMinuteOrMinutes(timeToUse);
- }
- } else {
- //seconds
- timeToReturn = getSecondOrSeconds(timeToUse);
- }
- return timeToReturn;
-}
-
-function getSecondOrSeconds(timeToUse) {
- let timeToReturn = "";
- if (timeToUse == 1) timeToReturn = timeToUse + " second";
- else if (timeToUse == 0 || timeToUse > 1) timeToReturn = timeToUse + " seconds";
- return timeToReturn;
-}
-
-function getMinuteOrMinutes(timeToUse) {
- let timeToReturn = "";
- if (timeToUse / 60 && timeToUse < 60 * 2) timeToReturn = ((timeToUse - (timeToUse % 60)) / 60) + " minute";
- else if (timeToUse > 60 * 2) timeToReturn = ((timeToUse - (timeToUse % 60)) / 60) + " minutes";
- return timeToReturn;
-}
-
-function getHourOrHours(timeToUse) {
- let timeToReturn = "";
- if (timeToUse / (60) >= 60 && timeToUse / (60) < 60 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60))) / (60 * 60)) + " hour";
- else if (timeToUse / (60) > 60 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60))) / (60 * 60)) + " hours";
- return timeToReturn;
-}
-
-function getDayOrDays(timeToUse) {
- let timeToReturn = "";
- if (timeToUse / (60 * 60) >= 24 && timeToUse / (60 * 60) < 24 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24))) / (60 * 60 * 24)) + " day";
- else if (timeToUse / (60 * 60) > 24 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24))) / (60 * 60 * 24)) + " days";
- return timeToReturn;
-}
-
-function getYearOrYears(timeToUse) {
- let timeToReturn = "";
- if (timeToUse / (60 * 60 * 24) >= 365 && timeToUse / (60 * 60 * 24) < 365 * 2) timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24 * 365))) / (60 * 60 * 24 * 365)) + " year";
- else timeToReturn = ((timeToUse - (timeToUse % (60 * 60 * 24 * 365))) / (60 * 60 * 24 * 365)) + " years";
- return timeToReturn;
-}
-
function isInteger(value) {
if (Number.isNaN(value) == false) {
if (Number.isInteger(value)) {
diff --git a/manifest.json b/manifest.json
index d1a1968..dd8d9b0 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Limite",
- "version": "1.1.1",
+ "version": "1.2",
"description": "Check how much time you spend on each website every day.\nOptimise your productivity, your time and your life as well.\nDon't lose precious time!",
"icons": {
"16": "./img/icon-16.png",
diff --git a/popup.html b/popup.html
index d870b52..aa542a6 100644
--- a/popup.html
+++ b/popup.html
@@ -10,8 +10,8 @@
-