Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make notifications optional #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Consider this add-on done (except for bugfixes). I may or may not add new featur

- **Access browser tabs** : required to list the tabs ;
- **Input data to the clipboard** : required to copy the list to the clipboard ;
- **Display notifications** : not required stricto sensu (as the extension could work without it) but it is used to improve the user experience by providing visual feedback about what is going on ;
- **Display notifications** : not required stricto sensu (as the extension could work without it) but it is used to improve the user experience by providing visual feedback about what is going on (if the "Enable Notifications" option is selected) ;
- **Storage** : required to store settings.

## Screenshots
Expand Down
3 changes: 3 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"popupFilterTabsPlaceholder": {
"message": "Filter Tabs"
},
"optionsNotifications": {
"message": "Benachrichtigungen aktivieren"
},
"optionsCustomHeader": {
"message": "Benutzerdefinierter Header"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"popupFilterTabsPlaceholder": {
"message": "Filter tabs"
},
"optionsNotifications": {
"message": "Enable Notifications"
},
"optionsCustomHeader": {
"message": "Custom header"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"popupFilterTabsPlaceholder": {
"message": "Filtrer les onglets"
},
"optionsNotifications": {
"message": "Activer les notifications"
},
"optionsCustomHeader": {
"message": "Entête personnalisée"
},
Expand Down
7 changes: 7 additions & 0 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ <h1>Options</h1>
<div data-i18n="optionsFilterTabsDescription"></div>
</div>

<div class="option">
<p>
<input type="checkbox" id="options-notifications" />
<label for="options-notifications" data-i18n="optionsNotifications"></label>
</p>
</div>

<div class="option">
<p>
<label for="options-format-custom" data-i18n="optionsFormatCustom"></label>:
Expand Down
7 changes: 7 additions & 0 deletions options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ w.addEventListener('load', function () {
optionsFormatCustom = d.getElementById('options-format-custom')
optionsButtonResetFormat = d.getElementById('options-button-reset-format')
optionsFilterTabs = d.getElementById('options-filter-tabs')
optionsNotifications = d.getElementById('options-notifications')
optionsCustomHeader = d.getElementById('options-custom-header')
optionsButtonResetHeader = d.getElementById('options-button-reset-header')

Expand All @@ -32,6 +33,10 @@ w.addEventListener('load', function () {
saveOptions()
})

optionsNotifications.addEventListener('change', function () {
saveOptions()
})

optionsButtonResetHeader.addEventListener('click', function () {
optionsCustomHeader.value = ''
saveOptions()
Expand Down Expand Up @@ -71,6 +76,7 @@ function restoreOptions () {
optionsIgnorePinned.checked = items.options.ignorePinned
optionsFormatCustom.value = items.options.formatCustom
optionsFilterTabs.checked = items.options.filterTabs
optionsNotifications.checked = items.options.enableNotifications
optionsCustomHeader.value = items.options.customHeader

setOptionsButtonResetFormatVisibility()
Expand All @@ -85,6 +91,7 @@ function saveOptions () {
ignorePinned: optionsIgnorePinned.checked,
formatCustom: optionsFormatCustom.value,
filterTabs: optionsFilterTabs.checked,
notifications: optionsNotifications.checked,
customHeader: optionsCustomHeader.value
}
})
Expand Down
22 changes: 14 additions & 8 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var
popupButtonCopy, popupButtonExport,
popupFormat, popupLabelFormatTitles, popupLabelFormatCustom, popupLimitWindow,
currentWindowId, os,
optionsIgnoreNonHTTP, optionsIgnorePinned, optionsFormatCustom, optionsFilterTabs, optionsCustomHeader
optionsIgnoreNonHTTP, optionsIgnorePinned, optionsFormatCustom, optionsFilterTabs, optionsCustomHeader,
optionsNotifications

var defaultPopupStates = {
'states': {
Expand Down Expand Up @@ -168,17 +169,21 @@ function copyToClipboard () {

var message = d.execCommand('copy') ? 'copiedToClipboard' : 'notCopiedToClipboard'

browser.notifications.create('ExportTabsURLs', {
'type': 'basic',
'title': browser.i18n.getMessage('appName'),
'iconUrl': '../img/icon.svg',
'message': browser.i18n.getMessage(message)
})
if (optionsNotifications) {
browser.notifications.create('ExportTabsURLs', {
'type': 'basic',
'title': browser.i18n.getMessage('appName'),
'iconUrl': '../img/icon.svg',
'message': browser.i18n.getMessage(message)
})
}

popupButtonCopy.classList.add('disabled')

setTimeout(function () {
browser.notifications.clear('ExportTabsURLs')
if (optionsNotifications) {
browser.notifications.clear('ExportTabsURLs')
}
popupButtonCopy.classList.remove('disabled')
}, 3000)
}
Expand Down Expand Up @@ -228,5 +233,6 @@ function getOptions () {
optionsFormatCustom = items.options.formatCustom
optionsFilterTabs = items.options.filterTabs
optionsCustomHeader = items.options.customHeader
optionsNotifications = items.options.notifications
})
}