npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prophetjs

v1.0.0

Published

A very lean dependency free javascript library to display toast messages on web pages.

Downloads

20

Readme

prophetjs

A very lean dependency free javascript library to display toast messages on web pages. This project adheres to Semantic Versioning. Sometimes I do screw up though. Prophet currently supports:

  • Chrome upto v26
  • Firefox upto v20
  • IE upto v10 (sorry)
  • Safari upto v5

Version 1.0.0

default

Table of Contents

Installation

Get the files:

Choose any of the ways to get prophet:

  • clone from github git clone https://github.com/binarybaba/prophetjs.git
  • Install from bower bower install prophetjs --save

Find the files

You'll see the files in the dist folder:

dist
├── css
│   ├── prophet.css
│   └── prophet.min.css
└── js
    ├── prophet.js
    ├── prophet.js.map
    └── prophet-min.js

Wire it up

Include the css and js files in your webpage:

<link rel="stylesheet" href="dist/css/prophet.min.css">

<script src="dist/js/prophet-min.js"></script>

API

Prophet exposes a Message API. All customizations and configurations are done through this API. To show a message, you will have to instantiate an instance of Message.

The toast message stays for a default duration of 4000 milliseconds or until the user clicks on it. After which, the toast message is removed from the DOM.

Simplest display

var toast = new Message('Harambe for president!').show();

Callback

You can also provide a callback to every toast message. The callback will be triggered after the toast message is removed or when the user clicks on it. The callback sends the autogenerated ID of the toast message (which can be overridden).

callback no-callback

var toast = new Message("Awesome! We'll contact you soon!", function(id){
    console.log('Message ID:', id);
    // some more code...
    });
    toast.show();
}

Options

You can also optionally include a set of options as a second argument (followed by the callback if any ) on every toast message. If the values are not implemented, the default values take up. (Prophet was written in TypeScript which enforces type checking for development. Hence, it implements an interface IMessageOptions. More on that here...) The following are the keys that options takes

  • id The id is autogenerated per toast message.

    • default: auto-generated
    • Type: number
  • type Prophet has 3 presets types: success, error and default. You can also set more presets. Click here to see how.

    error

    • default: "default"
    • Type: string
  • duration The time each toast message stays on the web page before disappearing. Takes value in miliseconds.

    • default: 4000
    • Type: number
  • class You can further customize the look of every toast message by providing extra CSS classes to override. Takes a single string of class names seperated by spaces.

    • default: ""
    • Type: string
Example
var ppap = new Message("Awesome! Pen Pineapple Apple Pen.", {
        id:i++, //i defined somewhere up above
        duration: 8000,
        type: 'success',
        class : 'blue-background white-text thin-border'
    }).show();

Custom Types

You can also add more types by providing the background-color, color and type for more uses. Please note, all the keys are mandatory.

Message.config.types({
    type: "tip",
    backgroundColor:"#fafafa",
    color:"#313131"
})

Now you can use the type while invoking a new Message:

var ppap = new Message("Awesome! Pen Pineapple Apple Pen.", { type: 'tip'}, function(id){
     console.log(id);
 })
 ppap.show();

stackUp

Contributing

Thanks for taking out time for actually reading this block. You're awesome! Prophetjs is written in TypeScript. I started writing this library as my venture into getting to know TypeScript better so if you're thinking of contributing, please do install TypeScript as your dev dependencies. I'll be further updating this section to include guides on how to get your way around the compiler and how you can install it per your IDE/editor (and maybe put this whole section in a new file)

License

Open source under the MIT License. All rights reserved.