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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jquery.dayparts

v1.0.0

Published

A jQuery Plugin for selecting Hours-of-Day

Downloads

18

Readme

jquery.dayparts

A jQuery Plugin for selecting Hours-of-Day. Demo at http://mcuznz.ca/2014/05/jquery-dayparts-plugin-for-selecting-hours-of-the-day/ I'll improve on the Demo later to display extra options and catching the update event.

Consider this a Beta at best; it works for the single use case that I needed it for, but might not work in all cases. It also needs some prettying up.

Call on an empty element such as a <div>, and it'll be populated with a Daypart selection table.

Note that this Plugin doesn't directly modify the content of a provided <input>, as it returns an array of Objects. It does, however, trigger a catchable 'daypartsUpdate' event when changes are made, which you cna listen to, fetch the resulting data, and morph accordingly.

I'll provide better documentation soon, I swear.

Configuration

All options can have their defaults overridden (overrode?) and also can be specified per-instance.

$.fn.dayparts.defaults = {
    disabled: false, 
    i18nfunc: function(input){ return input; },
    days: {0: 'Sunday', 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5: 'Friday', 6: 'Saturday'},
    weekStartsOn: 0,
    use24HFormat: true,
    change0Hour: true,
    show2DigitsHour: false,
    showPresets: true,
    presets: [
        {label:"Full Coverage", days:[0,1,2,3,4,5,6], hours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]},
        {label:"Afternoons", days:[0,1,2,3,4,5,6], hours:[12,13,14,15,16,17]},
        {label:"Evenings", days:[0,1,2,3,4,5,6], hours:[18,19,20,21,22,23]},
        {label:"Mornings", days:[0,1,2,3,4,5,6], hours:[6,7,8,9,10,11]},
        {label:"Weekdays", days:[1,2,3,4,5], hours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]},
        {label:"Weekends", days:[0,6], hours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]},
        {label:"Weekends including Friday", days:[0,5,6], hours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]}
    ],
    labels: {
        am: 'AM',
        pm: 'PM',
        presets: 'Presets',
        presetsSubtitle: '',
        choosePreset: 'Select a Preset'
    },
    data: []
};

Worth noting: all text - days of the week, preset names, and labels - is passed through the provided i18nfunc before being displayed. If this isn't behaviour you need, leave the default i18nfunc alone and just provide the values in the language of your choice. If you're creating a multilingual site, however, simply use Translation Keys in place of the Label/Day/Preset text, and pass your i18n Translator function as the i18nfunc option.

data is whatever selected dayparts you want to have initially selected. It takes the form of an array of objects as follows:

[{day: 0, hour: 23}, {day: 1, hour: 0}]

Values for day are 0-6 (Sunday to Saturday) and values for hour are 0-23.

This is an example to generate a Full Coverage data:

var data = [];
for (var day=0;day<7;day++){
    for (var hour=0;hour<24;hour++){
        data[data.length]={day: day, hour: hour};
    }
}

Most other options are self-explanitory.

A note about Timezones: You're on your own here!

Listening for Changes:

You'll want to set this up something like the following:

$(selector).dayparts({data: [...]});
$(selector).on("daypartsUpdate", function() {

  var parts = $(selector).dayparts.getValue();
  // Your Handler here - recurse over parts and morph as necessary.

});

Known Bugs

You can drag from one block to another to "paint" a section on or off, depending on the current state of the initial block. If you drag outside of the table and release the mouse, the Dayparting widget doesn't catch the resulting mouseup event, and sticks in paint mode. Clicking once will escape it, but you won't get the paint results you expected.

That's all she wrote!