Fixed: Unknown frameworks in statistics page (#151)

This commit is contained in:
nobody 2020-10-25 00:09:15 +02:00
parent c6e0a542fe
commit e4c5bc1db0
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
4 changed files with 20 additions and 2 deletions

View File

@ -215,6 +215,14 @@ const Links = {
'STATISTICS': chrome.extension.getURL('pages/statistics/statistics.html')
};
const FrameworkAndBundle = {
'resources/element-ui/2.13.2/': 'ElementUI',
'resources/bootstrap-datepicker/1.9.0/': 'Bootstrap DatePicker',
'resources/jquery.lazy/1.7.11/': 'jQuery Lazy',
'resources/waypoints/4.0.1/': 'Waypoints',
'resources/findify-bundle/6.9.15/': 'Findify'
};
// Supported charsets for TextDecoder()
// https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/TextDecoder
const EncodingTypes = {

View File

@ -21,12 +21,18 @@
var stats = {};
stats.setStats = function (injection) {
let data, today, cdn, framework, newEntry;
let data, today, cdn, framework, newEntry, pathSegments;
data = storageManager.statistics;
today = new Date().toISOString().slice(0, 10);
cdn = injection.source;
framework = injection.path;
if (injection.bundle !== '') {
pathSegments = injection.path.split('/');
framework = pathSegments[0] + '/' + pathSegments[1] + '/' + pathSegments[2] + '/';
} else {
framework = injection.path;
}
if (today in data) {
if (cdn in data[today]['cdns']) {

View File

@ -186,6 +186,9 @@ statistics._displayNameOfFramework = function (str, type) {
filename = helpers.extractFilenameFromPath(str);
filename = helpers.determineResourceName(filename);
if (filename === 'Unknown') {
filename = FrameworkAndBundle[str];
}
version = str.match(Resource.VERSION_EXPRESSION);
if (version !== null && version.length > 0) {
version = version === 'latest' ? version : 'v' + version;

View File

@ -37,6 +37,7 @@
<li>Added: OwlCarousel v2.3.4 (<a href="https://codeberg.org/nobody/LocalCDN/issues/148">#148</a>)</li>
<li>Added: OwlCarousel v2.0.0-beta.2.4 (<a href="https://codeberg.org/nobody/LocalCDN/issues/148">#148</a>)</li>
<li>Added: markdown-it v12.0.2 (<a href="https://codeberg.org/nobody/LocalCDN/issues/149">#149</a>)</li>
<li>Fixed: Unknown frameworks in statistics page (<a href="https://codeberg.org/nobody/LocalCDN/issues/150">#151</a>)</li>
</ul>
<div id="generator-section">
<div class="topic-label">