Skip to content

Commit

Permalink
bugfix/#112 Fixed error with badge multiplying
Browse files Browse the repository at this point in the history
  • Loading branch information
kas-elvirov committed Feb 16, 2021
1 parent 2175f8c commit 6a3593e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 )))
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 9 additions & 5 deletions src/utils/renderLocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
});
Expand All @@ -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);
};

0 comments on commit 6a3593e

Please sign in to comment.