mirror of
https://github.com/thedevs-network/kutt-extension.git
synced 2026-02-03 13:53:23 +00:00
QRCode addition
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
<h3 id="text">Shortening...</h3>
|
||||
<button id="button__copy">Copy</button>
|
||||
<button id="button__details">Details</button>
|
||||
<button id="button">options</button>
|
||||
<button id="button__qrcode">QR Code</button>
|
||||
<img id="qr_code" src="#" alt="QRCode" style="display: none;"/>
|
||||
|
||||
<script src="js/popup.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
let longUrl, shortUrl;
|
||||
let longUrl, shortUrl, qrSrc = 'https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=';
|
||||
|
||||
// 1. Pass the message and receive response
|
||||
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, (tabs) => {
|
||||
@@ -10,6 +10,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
console.log(response.shortUrl);
|
||||
shortUrl = response.shortUrl;
|
||||
document.getElementById('text').textContent = shortUrl;
|
||||
// fetch qrcode from http://goqr.me
|
||||
document.getElementById('qr_code').src = `${qrSrc}${shortUrl}`;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,5 +38,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
win.focus();
|
||||
});
|
||||
|
||||
// 4. QR Code
|
||||
document.getElementById('button__qrcode').addEventListener('click', () => {
|
||||
document.getElementById('button__qrcode').style = "display: none;";
|
||||
document.getElementById('qr_code').style = '';
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user