Skip to content

Commit

Permalink
Add isOnToolbar to checkInstall
Browse files Browse the repository at this point in the history
  • Loading branch information
smashedr committed Oct 25, 2024
1 parent ec1c925 commit 958ccd2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest-firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "112.0",
"strict_min_version": "116.0",
"update_url": "https://raw.githubusercontent.com/cssnr/aviation-tools/master/update.json"
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1 class="">Aviation Tools</h1>
<div class="d-flex flex-row align-items-center justify-content-center my-2">
<hr class="w-100 my-0 me-2">
<span class="text-nowrap">Keyboard Shortcuts</span>
<div class="ms-2" style="width: 30px;">
<div class="ms-2" style="min-width: 30px;">
<a class="text-decoration-none text-center small" role="button" data-section="keyboard-section">hide</a>
</div>
<hr class="w-100 my-0 ms-2">
Expand Down Expand Up @@ -66,7 +66,7 @@ <h1 class="">Aviation Tools</h1>
<div class="d-flex flex-row align-items-center justify-content-center my-2">
<hr class="w-100 my-0 me-2">
<span class="text-nowrap">Search Defaults</span>
<div class="ms-2" style="width: 30px;">
<div class="ms-2" style="min-width: 30px;">
<a class="text-decoration-none text-center small" role="button" data-section="search-section">hide</a>
</div>
<hr class="w-100 my-0 ms-2">
Expand Down Expand Up @@ -148,7 +148,7 @@ <h5>Airport Defaults</h5>
<div class="d-flex flex-row align-items-center justify-content-center my-2">
<hr class="w-100 my-0 me-2">
<span class="text-nowrap">Tools</span>
<div class="ms-2" style="width: 30px;">
<div class="ms-2" style="min-width: 30px;">
<a class="text-decoration-none text-center small" role="button" data-section="tools-section">hide</a>
</div>
<hr class="w-100 my-0 ms-2">
Expand Down Expand Up @@ -200,7 +200,7 @@ <h5>Tools</h5>
<div class="d-flex flex-row align-items-center justify-content-center my-2">
<hr class="w-100 my-0 me-2">
<span class="text-nowrap">Bookmarks</span>
<div class="ms-2" style="width: 30px;">
<div class="ms-2" style="min-width: 30px;">
<a class="text-decoration-none text-center small" role="button" data-section="bookmarks-section">hide</a>
</div>
<hr class="w-100 my-0 ms-2">
Expand Down Expand Up @@ -246,7 +246,7 @@ <h5>Tools</h5>
<div class="d-flex flex-row align-items-center justify-content-center my-2">
<hr class="w-100 my-0 me-2">
<span class="text-nowrap">Extension Options</span>
<div class="ms-2" style="width: 30px;">
<div class="ms-2" style="min-width: 30px;">
<a class="text-decoration-none text-center small" role="button" data-section="extension-section">hide</a>
</div>
<hr class="w-100 my-0 ms-2">
Expand Down
4 changes: 2 additions & 2 deletions src/js/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ export function updateOptions(options) {
continue
}
if (key.startsWith('radio')) {
key = value
value = true
key = value // NOSONAR
value = true // NOSONAR
}
console.debug(`${key}:`, value)
const el = document.getElementById(key)
Expand Down
25 changes: 24 additions & 1 deletion src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ async function checkInstall() {
// if (install) {
if (window.location.search.includes('?install=new')) {
history.pushState(null, '', location.href.split('?')[0])
const userSettings = await chrome.action.getUserSettings()
if (userSettings.isOnToolbar) {
return console.log('%cToolbar Icon Already Pinned!', 'color: Aqua')
}
const pin = document.getElementById('pin-notice')
pin.addEventListener('click', pinClick)
setTimeout(pinClick, 10000)
Expand Down Expand Up @@ -416,8 +420,9 @@ function onChanged(changes, namespace) {
* Set Keyboard Shortcuts
* @function setShortcuts
* @param {String} selector
* @param {Boolean} action
*/
async function setShortcuts(selector = '#keyboard-shortcuts') {
async function setShortcuts(selector = '#keyboard-shortcuts', action = true) {
const table = document.querySelector(selector)
const tbody = table.querySelector('tbody')
const source = table.querySelector('tfoot > tr').cloneNode(true)
Expand All @@ -434,6 +439,22 @@ async function setShortcuts(selector = '#keyboard-shortcuts') {
row.querySelector('kbd').textContent = command.shortcut || 'Not Set'
tbody.appendChild(row)
}

if (action) {
try {
const userSettings = await chrome.action.getUserSettings()
const row = source.cloneNode(true)
row.querySelector('i').className = 'fa-solid fa-puzzle-piece me-1'
row.querySelector('.description').textContent =
'Toolbar Icon Pinned'
row.querySelector('kbd').textContent = userSettings.isOnToolbar
? 'Yes'
: 'No'
tbody.appendChild(row)
} catch (e) {
console.log('Error adding pinned setting:', e)
}
}
}

/**
Expand Down Expand Up @@ -473,10 +494,12 @@ async function copySupport(event) {
event.preventDefault()
const manifest = chrome.runtime.getManifest()
const { options } = await chrome.storage.sync.get(['options'])
const userSettings = await chrome.action.getUserSettings()
const result = [
`${manifest.name} - ${manifest.version}`,
navigator.userAgent,
`options: ${JSON.stringify(options)}`,
`pinned: ${userSettings.isOnToolbar ? 'yes' : 'no'}`,
]
await navigator.clipboard.writeText(result.join('\n'))
showToast('Support Information Copied.')
Expand Down

0 comments on commit 958ccd2

Please sign in to comment.