Skip to content
Merged
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
26 changes: 16 additions & 10 deletions src/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,9 @@ class UI {

if (typeOfList !== undefined && typeOfList === TypeListEnum.ToDay) {
if (restrictionList !== undefined && restrictionList.length > 0) {
var item = restrictionList.find(x => x.url.isMatch(tab.url));
if (item !== undefined) {
var divLimit = this.createElement('div', ['tooltip', 'inline-block']);
var limitIcon = this.createElement('img', ['margin-left-5', 'tooltip']);
limitIcon.height = 15;
limitIcon.src = '/icons/limit.png';
var tooltip = this.createElement('span', ['tooltiptext'], "Daily limit is " + convertShortSummaryTimeToLongString(item.time));
divLimit = this.appendChild(divLimit, [limitIcon, tooltip]);
spanUrl.appendChild(divLimit);
}
this.addRestrictionIcon(tab, restrictionList, spanUrl);
} else {
getLimitsListFromStorage(() => this.addRestrictionIcon(tab, restrictionList, spanUrl));
}
}

Expand All @@ -242,6 +235,19 @@ class UI {
this.getTableOfSite().appendChild(div);
}

addRestrictionIcon(tab, restrictions, spanUrl) {
var item = restrictions.find(x => x.url.isMatch(tab.url));
if (item !== undefined) {
var divLimit = this.createElement('div', ['tooltip', 'inline-block']);
var limitIcon = this.createElement('img', ['margin-left-5', 'tooltip']);
limitIcon.height = 15;
limitIcon.src = '/icons/limit.png';
var tooltip = this.createElement('span', ['tooltiptext'], "Daily limit is " + convertShortSummaryTimeToLongString(item.time));
divLimit = this.appendChild(divLimit, [limitIcon, tooltip]);
spanUrl.appendChild(divLimit);
}
}

createElementsForTotalTime(summaryTime, typeOfList, parentElement) {
var arr = getArrayTime(summaryTime);
var isNextPartActiv = false;
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Url {
}

isPathMatch(path) {
var result = path === this.path || path.indexOf(this.path) === 0;
var result = this.path === '' || path === this.path || path.indexOf(this.path) === 0;

return result;
}
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/webact.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,16 @@ window.addEventListener('click', function (e) {
}
});

function getLimitsListFromStorage() {
storage.loadTabs(STORAGE_RESTRICTION_LIST, getLimitsListFromStorageCallback);
function getLimitsListFromStorage(callback) {
callback = callback || (() => {});
if (!restrictionList) {
storage.loadTabs(STORAGE_RESTRICTION_LIST, items => {
getLimitsListFromStorageCallback(items);
callback();
});
} else {
callback();
}
}

function getDataFromStorage() {
Expand Down