Skip to content
OOP alerts
JavaScript Shell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
build
src
.gitignore
LICENSE
README.md
bower.json
package.json

README.md

notification.js

Basically an OOP wrapper for alert(), confirm() and prompt(), because OOP is sweet and global functions are not.

Docs

new Notification( type, message = null, promptDefault = null )

Legal types are:

Notification.TYPE_ALERT
Notification.TYPE_CONFIRM
Notification.TYPE_PROMPT

What are classes without methods?

new Notification(...)
    // Set alert/confirm/prompt message
    .setMessage('Hello World!')

    // Set prompt default value
    .setPromptDefault('Default value')

    // Trigger the notification
    // Confirm and prompt boxes will return values
    .trigger();

Examples

new Notification(Notification.TYPE_ALERT)
    .setMessage('Hello World!')
    .trigger();

let result = new Notification(Notification.TYPE_CONFIRM)
    .setMessage('Hello World!')
    .trigger();

let result = new Notification(Notification.TYPE_PROMPT)
    .setMessage('Hello World!')
    .setPromptDefault('Foo')
    .trigger();

Disclaimer

This project isn’t meant to be used in production. In fact, it’s pretty useless. You’re not going to die not using it.

Solely made for this tweet.

Something went wrong with that request. Please try again.