Implemented: "Week" as the default in statistics. Save last period. (#300)
This commit is contained in:
parent
08ac068170
commit
dda2762db0
|
@ -77,6 +77,7 @@ const Setting = {
|
|||
'SELECTED_ICON': 'selectedIcon',
|
||||
'INTERNAL_STATISTICS': 'internalStatistics',
|
||||
'INTERNAL_STATISTICS_DATA': 'internalStatisticsData',
|
||||
'DEFAULT_RANGE_STATISTIC': 'defaultRangeStatistic',
|
||||
'ALLOWED_DOMAINS_GOOGLE_FONTS': 'allowedDomainsGoogleFonts',
|
||||
'STORAGE_TYPE': 'storageType',
|
||||
'BADGE_COLOR': 'badgeColor',
|
||||
|
@ -96,6 +97,7 @@ const SettingDefaults = {
|
|||
[Setting.UPDATE_NOTIFICATION]: 0,
|
||||
[Setting.INTERNAL_STATISTICS]: false,
|
||||
[Setting.INTERNAL_STATISTICS_DATA]: {},
|
||||
[Setting.DEFAULT_RANGE_STATISTIC]: 'week',
|
||||
[Setting.LAST_MAPPING_UPDATE]: '2020-01-01',
|
||||
[Setting.NEGATE_HTML_FILTER_LIST]: false,
|
||||
[Setting.SELECTED_ICON]: 'Default',
|
||||
|
|
|
@ -30,12 +30,13 @@ statistics._onDocumentLoaded = function () {
|
|||
helpers.insertI18nContentIntoDocument(document);
|
||||
helpers.insertI18nTitlesIntoDocument(document);
|
||||
|
||||
// Default view is 'today'
|
||||
statistics._dateRange = [new Date().toISOString().slice(0, 10)];
|
||||
document.getElementById('date-range').value = statistics._dateUnit;
|
||||
|
||||
statistics._registerListener();
|
||||
statistics._getStatistics().then(statistics._renderContents);
|
||||
chrome.storage.local.get([Setting.DEFAULT_RANGE_STATISTIC], function (items) {
|
||||
document.getElementById('date-range').value = items.defaultRangeStatistic;
|
||||
statistics._dateUnit = items.defaultRangeStatistic;
|
||||
statistics._setDateRange(items.defaultRangeStatistic);
|
||||
statistics._registerListener();
|
||||
statistics._getStatistics().then(statistics._renderContents);
|
||||
});
|
||||
};
|
||||
|
||||
statistics._renderContents = function () {
|
||||
|
@ -229,6 +230,7 @@ statistics._handlerDateRange = function ({target}) {
|
|||
let type = target.value;
|
||||
if (type === 'day' || type === 'week' || type === 'month' || type === 'year') {
|
||||
statistics._dateUnit = type;
|
||||
statistics._saveDefaultRange(type);
|
||||
} else if (type === 'delete') {
|
||||
statistics._deleteStatistic();
|
||||
}
|
||||
|
@ -245,6 +247,12 @@ statistics._deleteStatistic = function () {
|
|||
}
|
||||
};
|
||||
|
||||
statistics._saveDefaultRange = function (value) {
|
||||
chrome.storage.local.set({
|
||||
[Setting.DEFAULT_RANGE_STATISTIC]: value
|
||||
});
|
||||
};
|
||||
|
||||
statistics._registerListener = function () {
|
||||
document.getElementById('date-range').addEventListener('change', statistics._handlerDateRange);
|
||||
document.getElementById('btn-delete').addEventListener('click', function () {
|
||||
|
@ -262,6 +270,6 @@ statistics._dataSortedCDNs = {};
|
|||
statistics._dataSortedFrameworks = {};
|
||||
statistics._dataOverview = [];
|
||||
statistics._dateRange = [];
|
||||
statistics._dateUnit = 'day';
|
||||
statistics._dateUnit = 'week';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', statistics._onDocumentLoaded);
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<li>Added: jQuery v3.6.0 (<a href="https://codeberg.org/nobody/LocalCDN/issues/297">#297</a>)</li>
|
||||
<li>Updated: angular-translate v2.7.2 -> v2.18.4 (<a href="https://codeberg.org/nobody/LocalCDN/issues/298">#298</a>)</li>
|
||||
<li>Added: Bulma v0.9.2 (<a href="https://codeberg.org/nobody/LocalCDN/issues/299">#299</a>)</li>
|
||||
<li>Implemented: "Week" as the default in statistics. Save last period. (<a href="https://codeberg.org/nobody/LocalCDN/issues/300">#300</a>)</li>
|
||||
</ul>
|
||||
<div id="generator-section">
|
||||
<div class="topic-label">
|
||||
|
|
Loading…
Reference in New Issue