Skip to content

Commit

Permalink
v1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alundiak committed Oct 21, 2024
1 parent 1956a9f commit 1aaf730
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,18 @@ function createFlagButtons(flagsData) {
}

function copyToClipboard(codeObject) {
navigator.clipboard.writeText(codeObject.flag).then(() => {
// vA
// const flagEmoji = codeObject.flag;
// const countryName = codeObject.name;

// vB
const keys = Object.keys(codeObject);
const flagEmoji = keys[0];
const countryName = codeObject[flagEmoji];

navigator.clipboard.writeText(flagEmoji).then(() => {
// console.log(`Copied: ${flagEmoji}`);
showToast(`Copied: ${codeObject.flag} ${codeObject.name}`);
showToast(`Copied: ${flagEmoji} ${countryName}`);
}).catch(err => {
console.error('Failed to copy: ', err);
});
Expand All @@ -74,6 +83,7 @@ function showToast(message) {
}

getCountryFlags().then(flagsFromApi => {
console.log(flagsFromApi);
// console.log(JSON.stringify(flagsFromApi));
createFlagButtons(flagsFromApi);
});

0 comments on commit 1aaf730

Please sign in to comment.