1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-06-05 21:49:31 +02:00

Improved: Popup

This commit is contained in:
nobody
2021-04-02 07:21:33 +02:00
parent bcf0bc1631
commit bdd1e89719

View File

@@ -26,14 +26,6 @@
var popup = {}; var popup = {};
const PopupLinks = {
'statistics': Links.STATISTICS,
'translation': Links.WEBLATE,
'logging': Links.LOGGING,
'faq-html-filter': Links.FAQ_HTML_FILTER,
'donate': Links.DONATE,
};
/** /**
* Private Methods * Private Methods
*/ */
@@ -78,17 +70,17 @@ popup._renderNonContextualContents = function () {
testingUtilityLinkElement.addEventListener('mouseup', popup._onTestingUtilityLinkClicked); testingUtilityLinkElement.addEventListener('mouseup', popup._onTestingUtilityLinkClicked);
optionsButtonElement.addEventListener('mouseup', popup._onOptionsButtonClicked); optionsButtonElement.addEventListener('mouseup', popup._onOptionsButtonClicked);
donationButtonElement.addEventListener('mouseup', popup._onButtonClicked); donationButtonElement.addEventListener('mouseup', popup._onDonationButtonClicked);
infoButtonLabel.addEventListener('mouseup', popup._onButtonClicked); infoButtonLabel.addEventListener('mouseup', popup._onInfoButtonClicked);
if (popup._statisticsStatus) { if (popup._statisticsStatus) {
document.getElementById('statistics-button').style.display = 'block'; document.getElementById('statistics-button').style.display = 'block';
document.getElementById('statistics-button').addEventListener('mouseup', popup._onButtonClicked); document.getElementById('statistics-button').addEventListener('mouseup', popup._onStatisticsButtonClicked);
} }
if (popup._loggingStatus) { if (popup._loggingStatus) {
document.getElementById('logging-button').style.display = 'block'; document.getElementById('logging-button').style.display = 'block';
document.getElementById('logging-button').addEventListener('mouseup', popup._onButtonClicked); document.getElementById('logging-button').addEventListener('mouseup', popup._onLoggingButtonClicked);
} }
if (!popup.hideDonationButton) { if (!popup.hideDonationButton) {
@@ -419,7 +411,7 @@ popup._renderLocaleNotice = function () {
localeNoticeElement = document.getElementById('popup-incomplete-translation'); localeNoticeElement = document.getElementById('popup-incomplete-translation');
localeNoticeElement.setAttribute('class', 'notice notice-default'); localeNoticeElement.setAttribute('class', 'notice notice-default');
localeNoticeElement.addEventListener('mouseup', popup._onButtonClicked); localeNoticeElement.addEventListener('mouseup', popup._onIncompleteTranslation);
nameTextNode = document.createTextNode('Translation is incomplete. You want to help on Weblate?'); nameTextNode = document.createTextNode('Translation is incomplete. You want to help on Weblate?');
@@ -459,6 +451,57 @@ popup._onTestingUtilityLinkClicked = function (event) {
} }
}; };
popup._onDonationButtonClicked = function () {
if (event.button === 0 || event.button === 1) {
chrome.tabs.create({
'url': Links.DONATE,
'active': event.button === 0,
});
}
if (event.button === 0) {
window.close();
}
};
popup._onInfoButtonClicked = function () {
if (event.button === 0 || event.button === 1) {
chrome.tabs.create({
'url': Links.FAQ_HTML_FILTER,
'active': event.button === 0,
});
}
if (event.button === 0) {
window.close();
}
};
popup._onIncompleteTranslation = function () {
if (event.button === 0 || event.button === 1) {
chrome.tabs.create({
'url': Links.WEBLATE,
'active': event.button === 0,
});
}
if (event.button === 0) {
window.close();
}
};
popup._onStatisticsButtonClicked = function () {
if (event.button === 0 || event.button === 1) {
chrome.tabs.create({
'url': Links.STATISTICS,
'active': event.button === 0,
});
}
if (event.button === 0) {
window.close();
}
};
popup._injectDomain = function (tabId) { popup._injectDomain = function (tabId) {
let message = { let message = {
'topic': 'tab:inject', 'topic': 'tab:inject',
@@ -499,11 +542,10 @@ popup._close = function () {
}); });
}; };
popup._onButtonClicked = function ({target}) { popup._onLoggingButtonClicked = function () {
let data = target.getAttribute('data-link');
if (event.button === 0 || event.button === 1) { if (event.button === 0 || event.button === 1) {
chrome.tabs.create({ chrome.tabs.create({
'url': PopupLinks[data], 'url': Links.LOGGING,
'active': event.button === 0, 'active': event.button === 0,
}); });
} }