Comments (8)
@Outpox This is also the case on OSX 10.12
from notification-logger.
@Outpox Here is a quick and dirty fix (using a PD icon) You can change the icon
property to anything that is available publicly should you wish to change the icon.
(function() {
var isInitialized = false, _console = {};
var icon = 'https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/512/console.png'
Notification.requestPermission();
function log(body, title) {
title = title || "Notification";
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
} else if (Notification.permission === "granted") {
new Notification(title ,{body: body, icon: icon});
} else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
new Notification(title ,{body: body, icon: icon});
}
});
}
}
function genericLogger() {
return function (body, title) {
title = title || "Notification";
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
} else if (Notification.permission === "granted") {
new Notification(title ,{body: body, icon: icon});
} else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
new Notification(title ,{body: body, icon: icon});
}
});
}
}
}
function originalFnCallDecorator(fn, fnName) {
return function() {
fn.apply(this, arguments);
if (typeof _console[fnName] === 'function') {
_console[fnName].apply(console, arguments);
}
};
}
function destroy() {
isInitialized = false;
console.log = _console.log;
}
function init() {
if (isInitialized) { return; }
isInitialized = true;
_console.log = console.log;
console.log = originalFnCallDecorator(log, 'log');
}
window.logger = {
log: log,
init: init,
destroy:destroy
}
})();
from notification-logger.
@Outpox I will be extending the package to provide ability to set icon
@hkirat The option to set the icon can be done by adding an options
parameter (in addition to title
and message
parameters, or I can instead extend the entry point to accept an option 3rd parameter for icon
Possible signatures
function log(body[, title, icon])
or
function log(body[, title, options])
Where options would be a JS object
var options = {
icon: 'validUrl',
...
}
The second object allows the developer to extend call to include whatever they see fit (see Notification API) for list of all possible properties.
@hkirat which method do you prefer. Don't want to keep the API simple, add the icon
as parameter, make it more extensible, add options
from notification-logger.
I think logger should have an icon variable ( logger.icon). If the user wants to modify it, there should be a function logger.modifyIcon(icon_address).
Initially, the logger.icon should point to notifications.png that I have recently committed in the repo.
So the first option, adding icon as a parameter and providing a function to the user, logger.modifyIcon
from notification-logger.
@hkirat OK, sounds good. I will implement it the way you want.
from notification-logger.
Any progress @mikeerickson ?
Shouldn't be that difficult
from notification-logger.
@hkirat Not a difficulty issue, more of a time issue. Have some deadlines for work that need to take priority :-)
from notification-logger.
I've added a logo on the website for now.
Whenever you get the time please make the changes. Thanks
from notification-logger.
Related Issues (9)
- No npm package? HOT 10
- Remove duplication of code... HOT 1
- Support Chrome for Android HOT 6
- Unwrap Objects while Logging them as Desktop Notifications HOT 3
- example.html does not work on Ubuntu 16.04 Chrome version 53.0.2785.92 (64-bit) HOT 2
- Support Various notification options
- Bookmarklet HOT 2
- At least give due credit to the library you using in your readme & website HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notification-logger.