
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Simple and straigtforward notifications for the browser.
Alerts stack up. You dismiss them with a click (and also get them dismissed by themselves after some time by setting the timeout
option).
Source is only 2 KB. No dependencies.
Use with browserify, gluejs, etc.
npm install alerts
AMD supported.
If used in good old <script>
tag, it attaches itself to the window
object as al
.
String
Object
Object
an Alert instanceNumber
Time in miliseconds after which the alert is dismissedString
Custom class name to be added to each alert elementFunction
To be called when alert gets shown, with the alert element as context plus the options object as first argument, so anything you pass in is thereFunction
To be called just before the alert gets dismissed, with the Alert instance (the element is about to be removed from the DOM) as context and options object as first argumentPretty straightforward.
var alert = require('alert');
alert('Foo');
Passing in some options.
var alerted = alert('Some error', {
timeout: 4000,
className: 'alert-error'
});
// The HTML element is available at alerted.el
This is the least CSS you need to get it working. (Set z-index
to something reasonable according to the rest of your stylesheet.)
.alerts {
position: fixed;
z-index: 10000;
}
And this is a copy/paste example more like in the screenshot above.
.alerts {
position: fixed;
z-index: 10000;
width: 13.500em;
top: 1em;
right: 1em;
}
.alerts > div {
padding: .8em;
margin-bottom: .4em;
background-color: rgba(200, 200, 200, 0.8);
cursor: default;
}
If you want to use CSS transitions to either fade alerts in and out or swap them from right to left and viceversa, you can. Just set the alert.transitionTime
property to the transition duration in miliseconds.
alert.transitionTime = 200;
And then get creative with your CSS.
.alerts > div {
transition: opacity .2s;
}
.alerts > .alert,
.alerts > .alert-dismiss {
opacity: 0;
}
.alerts > .alert-show {
opacity: 1;
}
You also have the Alert
constructor plus the container
element at your disposal.
// The constructor
var alerted = new alert.Alert('Foo');
// The element
alert.container.style.backgroundColor = 'lime';
This code should work everywhere.
(MIT)
Copyright (c) 2013 Arturo Castillo Delgado 19@8302.net
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Simple and straigtforward notifications for the browser.
The npm package alerts receives a total of 77 weekly downloads. As such, alerts popularity was classified as not popular.
We found that alerts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.