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

View File

@ -381,10 +381,19 @@ popup._createInjectionElement = function (injection) {
nameTextNode = document.createTextNode(`- ${name}`); nameTextNode = document.createTextNode(`- ${name}`);
injectionElement.appendChild(nameTextNode); injectionElement.appendChild(nameTextNode);
if (injection.version !== null) { if (injection.versionRequested !== null) {
noteElement = document.createElement('span'); noteElement = document.createElement('span');
noteElement.setAttribute('class', 'side-note'); 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); noteTextNode = document.createTextNode(versionNode);
noteElement.appendChild(noteTextNode); noteElement.appendChild(noteTextNode);
injectionElement.appendChild(noteElement); injectionElement.appendChild(noteElement);

View File

@ -29,6 +29,7 @@
<li>Removed: Unused jQuery v3.4.1</li> <li>Removed: Unused jQuery v3.4.1</li>
<li>Updated: Welcome page</li> <li>Updated: Welcome page</li>
<li>Improved: Detection of Google Fonts</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> </ul>
<div id="generator-section"> <div id="generator-section">
<div class="topic-label"> <div class="topic-label">