varaible name changed to more meaningful

Co-authored-by: timvisee <tim@visee.me>
This commit is contained in:
Ashesh Vidyut 2019-03-21 01:08:11 +05:30 committed by timvisee
parent 0acdf3a720
commit acf82a4e3e
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
1 changed files with 8 additions and 7 deletions

View File

@ -3,20 +3,21 @@ const assets = require('../../common/assets');
module.exports.updateFavicon = function(percentageString) {
if (platform() === 'web') {
const percentage = parseInt(percentageString.replace('%', ''));
if (percentage === 0 || percentage === 100) {
let progress = parseInt(percentageString.replace('%', ''));
if (progress === 0 || progress === 100) {
const link = document.querySelector("link[rel*='icon']");
link.type = 'image/png';
link.href = assets.get('favicon-32x32.png');
document.getElementsByTagName('head')[0].appendChild(link);
return;
}
progress = progress * 0.01;
const link = document.querySelector("link[rel*='icon']");
const canvas = document.createElement('canvas');
const size = 32;
const lineWidth = 5;
const color = '#0090ed';
const loaderWidth = 5;
const loaderColor = '#0090ed';
const span = document.createElement('span');
span.textContent = percentageString;
@ -25,7 +26,7 @@ module.exports.updateFavicon = function(percentageString) {
context.translate(size / 2, size / 2);
const radius = (size - lineWidth) / 2;
const radius = (size - loaderWidth) / 2;
const drawCircle = function(color, lineWidth, percent) {
context.beginPath();
@ -37,8 +38,8 @@ module.exports.updateFavicon = function(percentageString) {
};
const drawNewFavicon = function() {
drawCircle('#efefef', lineWidth, 1);
drawCircle(color, lineWidth, percentage / 100);
drawCircle('#efefef', loaderWidth, 1);
drawCircle(loaderColor, loaderWidth, progress);
};
drawNewFavicon(link);