diff --git a/.env b/.env index 1c3f088..90033cb 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -APP_VERSION=8.2.46 +APP_VERSION=8.2.47 PAYPAL_URL=https://www.paypal.me/ArtemSolovev OPENCOLLECTIVE_URL=https://opencollective.com/artem-solovev diff --git a/README.md b/README.md index ce5fdda..d635fbe 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ___ ## History ### Version: -- current: 8.2.46 ( 2021, 15 february ) +- current: 8.2.47 ( 2021, 16 february ) - initial: 2.0.1 ( 2017, 12 february ) I made this program in the Russian Army while I was on duty. I was coding as fast as i could ))) diff --git a/manifest.json b/manifest.json index 1e30db8..9ab5f1f 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "short_name": "__MSG_shortName__", "author": "__MSG_author__", "description": "__MSG_description__", - "version": "8.2.46", + "version": "8.2.47", "browser_action": { "default_icon": "img/icon128.png", "default_popup": "index.html", diff --git a/package-lock.json b/package-lock.json index 7e96892..53a33be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gloc", - "version": "8.2.46", + "version": "8.2.47", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 183e3bc..67679c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gloc", - "version": "8.2.46", + "version": "8.2.47", "description": "Extension counts the number of lines of code in GitHub pages.", "author": "Artem Solovev", "license": "GPL-2.0", diff --git a/src/utils/renderLocs.ts b/src/utils/renderLocs.ts index 452deb0..c3a6028 100644 --- a/src/utils/renderLocs.ts +++ b/src/utils/renderLocs.ts @@ -12,13 +12,12 @@ export const renderLocs = (linksData: InitialData, token: string) => { const placeToInsert = linksData.linksToInsert[index] || anchor; if (repoName) { - const renderLoc = makeRenderFunc(placeToInsert); + const renderLoaderFunc = makeRenderLoaderFunc(placeToInsert); - renderLoc(LOADING_OUTPUT); - + renderLoaderFunc(LOADING_OUTPUT); requestLoc(repoName, TRIES_DEFAULT, token) - .then(loc => renderLoc(formatOutput(loc))) + .then(loc => renderLoc(placeToInsert, repoName, formatOutput(loc))) .catch(err => console.error(`Error by setting LOC for ${repoName}`, err)); } }); @@ -29,9 +28,14 @@ export const renderLocs = (linksData: InitialData, token: string) => { * The initial inner HTML of the anchor element is saved and reset upon updating the badge. * @param anchor HTML Element to add LOC badges to */ -const makeRenderFunc = (anchor: HTMLAnchorElement) => { +const makeRenderLoaderFunc = (anchor: HTMLAnchorElement) => { const startInnerHTML = anchor.innerHTML; + return (loc: string) => { anchor.innerHTML = startInnerHTML + renderBadge(loc); }; }; + +const renderLoc = (anchor: HTMLAnchorElement, reponame: string, loc: string) => { + anchor.innerHTML = reponame.split('/').slice(-1)[0] + renderBadge(loc); +};