mirror of
https://github.com/brunofontes/shareit.git
synced 2025-12-08 00:30:48 -03:00
feat: favicon with number of used items
This commit is contained in:
25
resources/js/app.js
vendored
25
resources/js/app.js
vendored
@@ -20,3 +20,28 @@ import './bootstrap';
|
||||
// const app = new Vue({
|
||||
// el: '#app'
|
||||
// });
|
||||
|
||||
|
||||
function setFaviconNumber(number) {
|
||||
var canvas = document.createElement('canvas'),
|
||||
ctx,
|
||||
img = document.createElement('img'),
|
||||
link = document.getElementById('favicon').cloneNode(true);
|
||||
|
||||
if (canvas.getContext) {
|
||||
canvas.height = canvas.width = 48; // set the size
|
||||
ctx = canvas.getContext('2d');
|
||||
img.onload = function () { // once the image has loaded
|
||||
ctx.drawImage(this, 0, 0);
|
||||
ctx.font = 'bold 35px "helvetica", sans-serif';
|
||||
ctx.fillStyle = '#ffff66';
|
||||
ctx.fillText(number, 3, 25);
|
||||
link.href = canvas.toDataURL('image/png');
|
||||
document.body.appendChild(link);
|
||||
};
|
||||
img.src = 'favicon.png';
|
||||
}
|
||||
};
|
||||
|
||||
usedItems = document.getElementById("usedItems").innerText;
|
||||
setFaviconNumber(usedItems);
|
||||
|
||||
Reference in New Issue
Block a user