Show upgrades of frameworks in popup (#68)

This commit is contained in:
nobody 2020-07-30 07:56:48 +02:00
parent cc16cefc36
commit 1830616afe
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
3 changed files with 22 additions and 9 deletions

View File

@ -137,14 +137,16 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
if (resourcePattern.startsWith(resourceMold)) {
let targetPath, hostShorthands, version;
let targetPath, hostShorthands, versionDelivered, versionRequested;
targetPath = resourceMappings[resourceMold].path;
targetPath = targetPath.replace(Resource.VERSION_PLACEHOLDER, versionNumber);
// Replace the requested version with the latest depending on major version
version = helpers.setLastVersion(targetPath, versionNumber).toString();
targetPath = targetPath.replace(versionNumber, version);
versionDelivered = helpers.setLastVersion(targetPath, versionNumber).toString();
targetPath = targetPath.replace(versionNumber, versionDelivered);
versionRequested = versionNumber === null ? false : versionNumber[0];
hostShorthands = shorthands[channelHost];
@ -153,10 +155,10 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
let shorthand = hostShorthands[targetPath];
targetPath = shorthand.path;
version = shorthand.version;
versionDelivered = shorthand.version;
} else {
version = versionNumber && versionNumber[0] || targetPath.match(Resource.VERSION_EXPRESSION);
} else if (versionNumber === null) {
versionDelivered = targetPath.match(Resource.VERSION_EXPRESSION).toString();
}
// Get bundle name
@ -172,7 +174,8 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
// Prepare and return a local target.
return {
'source': channelHost,
'version': version,
'versionRequested': versionRequested,
'versionDelivered': versionDelivered,
'path': targetPath,
'bundle': bundle
};

View File

@ -381,10 +381,19 @@ popup._createInjectionElement = function (injection) {
nameTextNode = document.createTextNode(`- ${name}`);
injectionElement.appendChild(nameTextNode);
if (injection.version !== null) {
if (injection.versionRequested !== null) {
noteElement = document.createElement('span');
noteElement.setAttribute('class', 'side-note');
let versionNode = (injection.version === 'beta') ? ` ${injection.version}` : ` v${injection.version}`;
let versionNode = '';
console.log(injection);
if (injection.versionRequested === injection.versionDelivered) {
versionNode = ` v${injection.versionRequested}`;
} else if (injection.versionRequested === 'beta') {
versionNode = ` ${injection.versionRequested}`;
} else if (injection.versionRequested !== false){
versionNode = ` (v${injection.versionRequested} 🡢 v${injection.versionDelivered})`;
}
noteTextNode = document.createTextNode(versionNode);
noteElement.appendChild(noteTextNode);
injectionElement.appendChild(noteElement);

View File

@ -29,6 +29,7 @@
<li>Removed: Unused jQuery v3.4.1</li>
<li>Updated: Welcome page</li>
<li>Improved: Detection of Google Fonts</li>
<li>Implemented: Show upgrades of frameworks in popup (<a href="https://codeberg.org/nobody/LocalCDN/issues/68">#68</a>)</li>
</ul>
<div id="generator-section">
<div class="topic-label">