mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-02-05 03:24:17 +00:00
added requesting of permission, fixed behaviour when it denied, fixed alerts lines
This commit is contained in:
parent
581d6c0a8d
commit
3ae61f3f97
@ -96,8 +96,8 @@ if(preferredLanguage == "en"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "Not available", // username is not available
|
"Not available": "Not available", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Number of blocks in block chain: ",
|
"Number of blocks in block chain:": "Number of blocks in block chain: ",
|
||||||
@ -334,8 +334,8 @@ if(preferredLanguage == "es"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "Nadie", // used to promote a post without attaching the user
|
"nobody": "Nadie", // used to promote a post without attaching the user
|
||||||
"Not available": "No disponible", // username is not available
|
"Not available": "No disponible", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Número de bloques en la cadena de bloques: ",
|
"Number of blocks in block chain:": "Número de bloques en la cadena de bloques: ",
|
||||||
@ -570,8 +570,8 @@ if(preferredLanguage == "uk"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "Не доступне", // username is not available
|
"Not available": "Не доступне", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Кількість блоків у ланцюгу: ",
|
"Number of blocks in block chain:": "Кількість блоків у ланцюгу: ",
|
||||||
@ -804,8 +804,8 @@ if(preferredLanguage == "zh"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "用户名不可用", // username is not available
|
"Not available": "用户名不可用", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "块链中的块数:",
|
"Number of blocks in block chain:": "块链中的块数:",
|
||||||
@ -1038,8 +1038,8 @@ if(preferredLanguage == "nl"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "Niet beschikbaar", // username is not available
|
"Not available": "Niet beschikbaar", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Aantal blocks in block chain: ",
|
"Number of blocks in block chain:": "Aantal blocks in block chain: ",
|
||||||
@ -1273,8 +1273,8 @@ if(preferredLanguage == "it"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nessuno", // used to promote a post without attaching the user
|
"nobody": "nessuno", // used to promote a post without attaching the user
|
||||||
"Not available": "Non disponibile", // username is not available
|
"Not available": "Non disponibile", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Numero di blocchi nella catena: ",
|
"Number of blocks in block chain:": "Numero di blocchi nella catena: ",
|
||||||
@ -1506,8 +1506,8 @@ if(preferredLanguage == "fr"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "Non disponible", // username is not available
|
"Not available": "Non disponible", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Nombre de blocs dans la chaîne de blocs: ",
|
"Number of blocks in block chain:": "Nombre de blocs dans la chaîne de blocs: ",
|
||||||
@ -1745,8 +1745,8 @@ if(preferredLanguage == "ru"){
|
|||||||
"new_direct_messages": "%{smart_count} новое личное сообщение |||| %{smart_count} новых личных сообщений",
|
"new_direct_messages": "%{smart_count} новое личное сообщение |||| %{smart_count} новых личных сообщений",
|
||||||
"nobody": "Анонимно", // used to promote a post without attaching the user
|
"nobody": "Анонимно", // used to promote a post without attaching the user
|
||||||
"Not available": "Недоступно",
|
"Not available": "Недоступно",
|
||||||
"notify_desktop_error": "Твистер не может выполнить уведомление: произошла неизвестная ошибка. Попробуйте изменить предпочтения браузера для уведомлений рабочего стола.",
|
"notify_desktop_error": "Твистер не может выполнить уведомление: произошла неизвестная ошибка.",
|
||||||
"notify_desktop_perm_denied": "Твистер не может выполниь уведомление: разрешение не получено. Убедитесь, что в браузере разрешены уведомления для этого домена.",
|
"notify_desktop_perm_denied": "Твистер не может выполниь уведомление: разрешение не получено.\n\nЧтобы получать уведомления, разрешите их для этого домена в настройках вашего браузера.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Количество блоков в цепочке: ",
|
"Number of blocks in block chain:": "Количество блоков в цепочке: ",
|
||||||
@ -1985,8 +1985,8 @@ if(preferredLanguage == "de"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "Nicht verfügbar", // username is not available
|
"Not available": "Nicht verfügbar", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Anzahl der Blöcke in der Block-Chain: ",
|
"Number of blocks in block chain:": "Anzahl der Blöcke in der Block-Chain: ",
|
||||||
@ -2221,8 +2221,8 @@ if(preferredLanguage == "ja"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "ナナシ", // used to promote a post without attaching the user
|
"nobody": "ナナシ", // used to promote a post without attaching the user
|
||||||
"Not available": "使用中", // username is not available
|
"Not available": "使用中", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "全ブロック数: ",
|
"Number of blocks in block chain:": "全ブロック数: ",
|
||||||
@ -2454,8 +2454,8 @@ if(preferredLanguage == "pt-BR"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nobody", // used to promote a post without attaching the user
|
"nobody": "nobody", // used to promote a post without attaching the user
|
||||||
"Not available": "Indisponível", // username is not available
|
"Not available": "Indisponível", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Número de blocos: ",
|
"Number of blocks in block chain:": "Número de blocos: ",
|
||||||
@ -2691,8 +2691,8 @@ if(preferredLanguage == "tr"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "hiçkimse", // used to promote a post without attaching the user
|
"nobody": "hiçkimse", // used to promote a post without attaching the user
|
||||||
"Not available": "Kullanılamaz", // username is not available
|
"Not available": "Kullanılamaz", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Blok zincirindeki blok sayısı: ",
|
"Number of blocks in block chain:": "Blok zincirindeki blok sayısı: ",
|
||||||
@ -2925,8 +2925,8 @@ if(preferredLanguage == "cs"){
|
|||||||
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
"new_direct_messages": "%{smart_count} new direct message |||| %{smart_count} new direct messages",
|
||||||
"nobody": "nikdo", // used to promote a post without attaching the user
|
"nobody": "nikdo", // used to promote a post without attaching the user
|
||||||
"Not available": "Tuto přezdívku již někdo používá", // username is not available
|
"Not available": "Tuto přezdívku již někdo používá", // username is not available
|
||||||
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured. Try to change browser permissions for this domain.",
|
"notify_desktop_error": "Twister cannot perform desktop notification: unknown error occured.",
|
||||||
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied. Check out browser's policy for this domain.",
|
"notify_desktop_perm_denied": "Twister cannot perform desktop notification: permission denied.\n\nIf you want to get notifications, allow them for this domain in settings of your browser.",
|
||||||
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
"notify_desktop_test": "All the twisters gonna twist. Now you are welcome too.",
|
||||||
"notify_desktop_title": "Watch out, it's twister over here!",
|
"notify_desktop_title": "Watch out, it's twister over here!",
|
||||||
"Number of blocks in block chain:": "Počet bloků v blockchainu: ",
|
"Number of blocks in block chain:": "Počet bloků v blockchainu: ",
|
||||||
|
18
js/notify.js
18
js/notify.js
@ -80,6 +80,16 @@
|
|||||||
if (isFunction(this.options.notifyError)) {
|
if (isFunction(this.options.notifyError)) {
|
||||||
this.onErrorCallback = this.options.notifyError;
|
this.onErrorCallback = this.options.notifyError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//callback when permission granted after request
|
||||||
|
if (isFunction(this.options.permissionGranted)) {
|
||||||
|
this.onPermissionGrantedCallback = this.options.permissionGranted;
|
||||||
|
}
|
||||||
|
|
||||||
|
//callback when permission denied after request
|
||||||
|
if (isFunction(this.options.permissionDenied)) {
|
||||||
|
this.onPermissionDeniedCallback = this.options.permissionDenied;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +131,14 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Notify.permissionLevel === 'default' ) {
|
||||||
|
Notify.requestPermission(this.onPermissionGrantedCallback, this.onPermissionDeniedCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Notify.needsPermission) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.myNotify = new Notification(this.title, {
|
this.myNotify = new Notification(this.title, {
|
||||||
'body': this.options.body,
|
'body': this.options.body,
|
||||||
'tag' : this.options.tag,
|
'tag' : this.options.tag,
|
||||||
|
@ -2,7 +2,7 @@ $(function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var _desktopNotificationTimeout = 4; // it should be an option
|
var _desktopNotificationTimeout = 40; // it should be an option
|
||||||
|
|
||||||
var TwisterOptions = function()
|
var TwisterOptions = function()
|
||||||
{
|
{
|
||||||
@ -97,10 +97,13 @@ var TwisterOptions = function()
|
|||||||
icon: '../img/twister_mini.png',
|
icon: '../img/twister_mini.png',
|
||||||
tag: 'twister_notification_test',
|
tag: 'twister_notification_test',
|
||||||
timeout: _desktopNotificationTimeout,
|
timeout: _desktopNotificationTimeout,
|
||||||
notifyError: function() { alert(polyglot.t('notify_desktop_error')); },
|
notifyError: function() { alert(polyglot.t('notify_desktop_error')); }
|
||||||
permissionDenied: function() { alert(polyglot.t('notify_desktop_perm_denied')); }
|
|
||||||
});
|
});
|
||||||
|
if (Notify.permissionLevel === 'denied') {
|
||||||
|
alert(polyglot.t('notify_desktop_perm_denied'));
|
||||||
|
} else {
|
||||||
desktopNotification.show();
|
desktopNotification.show();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user