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

View File

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