Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No icon on the demo website #1

Open
Outpox opened this issue Oct 12, 2016 · 8 comments
Open

No icon on the demo website #1

Outpox opened this issue Oct 12, 2016 · 8 comments

Comments

@Outpox
Copy link

Outpox commented Oct 12, 2016

image

Running on Linux Mint 18 with Google Chrome (53.0.2785.143)

@mikeerickson
Copy link

@Outpox This is also the case on OSX 10.12

@mikeerickson
Copy link

@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
    }
})();

@mikeerickson
Copy link

@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

@hkirat
Copy link
Owner

hkirat commented Oct 12, 2016

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

@mikeerickson
Copy link

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

@hkirat
Copy link
Owner

hkirat commented Oct 13, 2016

Any progress @mikeerickson ?
Shouldn't be that difficult

@mikeerickson
Copy link

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

@hkirat
Copy link
Owner

hkirat commented Oct 14, 2016

I've added a logo on the website for now.
Whenever you get the time please make the changes. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants