Giter VIP home page Giter VIP logo

Comments (8)

mikeerickson avatar mikeerickson commented on July 4, 2024

@Outpox This is also the case on OSX 10.12

from notification-logger.

mikeerickson avatar mikeerickson commented on July 4, 2024

@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.

mikeerickson avatar mikeerickson commented on July 4, 2024

@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.

hkirat avatar hkirat commented on July 4, 2024

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.

mikeerickson avatar mikeerickson commented on July 4, 2024

@hkirat OK, sounds good. I will implement it the way you want.

from notification-logger.

hkirat avatar hkirat commented on July 4, 2024

Any progress @mikeerickson ?
Shouldn't be that difficult

from notification-logger.

mikeerickson avatar mikeerickson commented on July 4, 2024

@hkirat Not a difficulty issue, more of a time issue. Have some deadlines for work that need to take priority :-)

from notification-logger.

hkirat avatar hkirat commented on July 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.