Fixed "show more" button
This commit is contained in:
parent
f0ee94a9fd
commit
5c1a8da2d8
|
@ -19,6 +19,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let counterFrameworks = 0;
|
let counterFrameworks = 0;
|
||||||
|
let counterCDNs = 0;
|
||||||
|
let oversized = false;
|
||||||
var popup = {};
|
var popup = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +67,8 @@ popup._renderContextualContents = function () {
|
||||||
popup._renderDomainWhitelistPanel();
|
popup._renderDomainWhitelistPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(popup._resourceInjections).length > 0) {
|
counterCDNs = Object.keys(popup._resourceInjections).length;
|
||||||
|
if (counterCDNs > 0) {
|
||||||
popup._renderInjectionPanel(popup._resourceInjections);
|
popup._renderInjectionPanel(popup._resourceInjections);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -291,9 +294,14 @@ popup._createInjectionOverviewElement = function (groupedInjections) {
|
||||||
|
|
||||||
injectionOverviewElement.appendChild(injectionGroupHeaderElement);
|
injectionOverviewElement.appendChild(injectionGroupHeaderElement);
|
||||||
injectionOverviewElement.appendChild(injectionGroupElement);
|
injectionOverviewElement.appendChild(injectionGroupElement);
|
||||||
|
} else {
|
||||||
|
oversized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oversized) {
|
||||||
|
injectionOverviewElement.append(popup._appendMoreButton());
|
||||||
|
}
|
||||||
return injectionOverviewElement;
|
return injectionOverviewElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -320,7 +328,7 @@ popup._createInjectionGroupHeaderElement = function (source, cdn) {
|
||||||
|
|
||||||
popup._createInjectionGroupElement = function (source, cdn) {
|
popup._createInjectionGroupElement = function (source, cdn) {
|
||||||
|
|
||||||
let injectionGroupElement, count, oversized;
|
let injectionGroupElement;
|
||||||
|
|
||||||
// Filter duplicates
|
// Filter duplicates
|
||||||
let bundle = [];
|
let bundle = [];
|
||||||
|
@ -332,7 +340,6 @@ popup._createInjectionGroupElement = function (source, cdn) {
|
||||||
injectionGroupElement = document.createElement('ul');
|
injectionGroupElement = document.createElement('ul');
|
||||||
injectionGroupElement.setAttribute('class', 'sublist');
|
injectionGroupElement.setAttribute('class', 'sublist');
|
||||||
|
|
||||||
oversized = false;
|
|
||||||
for (let injection of filtered) {
|
for (let injection of filtered) {
|
||||||
|
|
||||||
if(counterFrameworks < 3){
|
if(counterFrameworks < 3){
|
||||||
|
@ -343,11 +350,7 @@ popup._createInjectionGroupElement = function (source, cdn) {
|
||||||
}
|
}
|
||||||
counterFrameworks++;
|
counterFrameworks++;
|
||||||
}
|
}
|
||||||
if (oversized) {
|
|
||||||
let injectionElement = popup._createInjectionElement(filtered, true);
|
|
||||||
let moreInjectionsSection = document.getElementById('more-injections-section');
|
|
||||||
moreInjectionsSection.appendChild(injectionElement);
|
|
||||||
}
|
|
||||||
return injectionGroupElement;
|
return injectionGroupElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -355,23 +358,8 @@ popup._createInjectionElement = function (injection, oversized = false) {
|
||||||
|
|
||||||
let injectionElement, filename, name, nameTextNode, noteElement, noteTextNode;
|
let injectionElement, filename, name, nameTextNode, noteElement, noteTextNode;
|
||||||
|
|
||||||
|
|
||||||
if(oversized) {
|
if(oversized) {
|
||||||
|
return popup._appendMoreButton();
|
||||||
let lastElement = document.createElement('p');
|
|
||||||
let moreInjections = document.createElement('span');
|
|
||||||
|
|
||||||
nameTextNode = document.createTextNode(`... and more`);
|
|
||||||
moreInjections.setAttribute('id', 'get-more-injections-btn');
|
|
||||||
|
|
||||||
moreInjections.addEventListener('mouseup', function() {
|
|
||||||
popup._onMoreInjectionsButton();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
moreInjections.appendChild(nameTextNode);
|
|
||||||
lastElement.appendChild(moreInjections);
|
|
||||||
|
|
||||||
return lastElement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
injectionElement = document.createElement('li');
|
injectionElement = document.createElement('li');
|
||||||
|
@ -401,6 +389,23 @@ popup._createInjectionElement = function (injection, oversized = false) {
|
||||||
return injectionElement;
|
return injectionElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
popup._appendMoreButton = function() {
|
||||||
|
|
||||||
|
let lastElement = document.createElement('p');
|
||||||
|
let moreInjections = document.createElement('span');
|
||||||
|
let nameTextNode = document.createTextNode(`... and more`);
|
||||||
|
|
||||||
|
moreInjections.setAttribute('id', 'get-more-injections-btn');
|
||||||
|
|
||||||
|
moreInjections.addEventListener('mouseup', function() {
|
||||||
|
popup._onMoreInjectionsButton();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
moreInjections.appendChild(nameTextNode);
|
||||||
|
lastElement.appendChild(moreInjections);
|
||||||
|
return lastElement;
|
||||||
|
}
|
||||||
|
|
||||||
popup._filterDuplicates = function(array, key) {
|
popup._filterDuplicates = function(array, key) {
|
||||||
/**
|
/**
|
||||||
* Function to remove duplicates from an array, depending on 'key'.
|
* Function to remove duplicates from an array, depending on 'key'.
|
||||||
|
|
Loading…
Reference in New Issue