mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 10:28:32 +00:00
chore: add precommit hook for testing code style (#1448)
* chore: add precommit hook for testing code style * chore: use prettier + eslint for js code
This commit is contained in:
@@ -1,42 +1,46 @@
|
||||
var Notifications = {};
|
||||
const Notifications = {};
|
||||
|
||||
$(document).ready(function () {
|
||||
if (!window.webkitNotifications) {
|
||||
return;
|
||||
};
|
||||
if (!window.webkitNotifications) {
|
||||
return;
|
||||
}
|
||||
|
||||
var notificationsEnabled = (window.webkitNotifications.checkPermission() === 0)
|
||||
var toggle = $('#toggle_notifications');
|
||||
let notificationsEnabled = window.webkitNotifications.checkPermission() === 0;
|
||||
const toggle = $('#toggle_notifications');
|
||||
|
||||
toggle.show();
|
||||
updateMenuTitle();
|
||||
$(transmission).bind('downloadComplete seedingComplete', function (event, torrent) {
|
||||
if (notificationsEnabled) {
|
||||
var title = (event.type == 'downloadComplete' ? 'Download' : 'Seeding') + ' complete',
|
||||
content = torrent.getName(),
|
||||
notification;
|
||||
toggle.show();
|
||||
updateMenuTitle();
|
||||
$(transmission).bind('downloadComplete seedingComplete', function (event, torrent) {
|
||||
if (notificationsEnabled) {
|
||||
let title = (event.type == 'downloadComplete' ? 'Download' : 'Seeding') + ' complete',
|
||||
content = torrent.getName(),
|
||||
notification;
|
||||
|
||||
notification = window.webkitNotifications.createNotification('style/transmission/images/logo.png', title, content);
|
||||
notification.show();
|
||||
setTimeout(function () {
|
||||
notification.cancel();
|
||||
}, 5000);
|
||||
};
|
||||
});
|
||||
notification = window.webkitNotifications.createNotification(
|
||||
'style/transmission/images/logo.png',
|
||||
title,
|
||||
content
|
||||
);
|
||||
notification.show();
|
||||
setTimeout(function () {
|
||||
notification.cancel();
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
function updateMenuTitle() {
|
||||
toggle.html((notificationsEnabled ? 'Disable' : 'Enable') + ' Notifications');
|
||||
};
|
||||
function updateMenuTitle() {
|
||||
toggle.html((notificationsEnabled ? 'Disable' : 'Enable') + ' Notifications');
|
||||
}
|
||||
|
||||
Notifications.toggle = function () {
|
||||
if (window.webkitNotifications.checkPermission() !== 0) {
|
||||
window.webkitNotifications.requestPermission(function () {
|
||||
notificationsEnabled = (window.webkitNotifications.checkPermission() === 0);
|
||||
updateMenuTitle();
|
||||
});
|
||||
} else {
|
||||
notificationsEnabled = !notificationsEnabled;
|
||||
updateMenuTitle();
|
||||
};
|
||||
};
|
||||
Notifications.toggle = function () {
|
||||
if (window.webkitNotifications.checkPermission() !== 0) {
|
||||
window.webkitNotifications.requestPermission(function () {
|
||||
notificationsEnabled = window.webkitNotifications.checkPermission() === 0;
|
||||
updateMenuTitle();
|
||||
});
|
||||
} else {
|
||||
notificationsEnabled = !notificationsEnabled;
|
||||
updateMenuTitle();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user