hkirat / notification-logger Goto Github PK
View Code? Open in Web Editor NEWDesktop notification for your console Logs
Home Page: http://hkirat.github.io/notification-logger
Desktop notification for your console Logs
Home Page: http://hkirat.github.io/notification-logger
Using the following javascript one may include and init the notification logger at any page without having to put dev-only dependencies or script tags into the code:
if (typeof window.logger === 'undefined') {
var script = document.createElement('script');
script.src = 'http://singhharkirat.com/notification-logger/notification-logger.js';
document.body.appendChild(script);
}
window.logger.init();
Putting that as a bookmarklet link and you've got a quick way to activate notification-logger on any page:
<a href="javascript:if(typeof window.logger=='undefined'){var script=document.createElement('script');script.src='http://singhharkirat.com/notification-logger/notification-logger.js';document.body.appendChild(script);}window.logger.init();">Bookmarklet</a>
Maybe you want to add that to the description page.
The notification permission request pop up does not appear on chrome.
Console contains
"title" notification-logger.js:23 2
"title" example.html:32 2
The notification-logger demo works fine.
This is based on https://github.com/chinchang/screenlog.js
& website design is copied from https://kushagragour.in/lab/hint/
Hey,
Great idea on the script! As far as unwrapping objects would you just use JSON.stringify?
The notification web API supports multiple options - https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification
These options could be used to customise the notifications.
I’ve tested your demo in browsers on Android; it works in Firefox, but not in Chrome. Could you confirm?
You talk about it only being ~100 lines of code, but you duplicated the code for one of the main functions, which just increases the number of lines quite a bit...
You can probably remove all that by re-using the same function... talking about this one (and what is in genericLogger())...
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});
} else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
new Notification(title ,{body: body});
}
});
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.