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

facebook-opening-hours-to-table

v2.4.10

Published

Generates an html table from Facebook page opening hours data, such that days with equal opening hours are on one table row.

Downloads

25

Readme

facebook-opening-hours-to-table

Generates an html table from Facebook page opening hours data, such that days with equal opening hours are on one table row.

travis build codecov coverage version downloads MIT License

Open 24 hours

Installation

###npm

This package is distributed via npm:

npm i facebook-opening-hours-to-table

It has no dependencies.

###Browser Get the file from https://npmcdn.com/facebook-opening-hours-to-table/build and put it in a script tag:

<script src="entry.umd.min.js"></script>
//Functions now at facebookOpeningHoursToTable.getTableWithHours(hours, translationDict);

##Demo Facebook hours-data looks like this:

{
  "mon_1_open": "11:00",
  "mon_1_close": "20:30",
  "tue_1_open": "11:00",
  "tue_1_close": "20:30",
  "wed_1_open": "11:00",
  "wed_1_close": "20:30",
  "thu_1_open": "11:00",
  "thu_1_close": "21:00",
  "fri_1_open": "11:00",
  "fri_1_close": "21:00",
  "sat_1_open": "10:30",
  "sat_1_close": "20:30",
  "sun_1_open": "12:00",
  "sun_1_close": "19:00"
}

And this library creates:

Usage

###Getting the table Use this method if you want an html table.

Fetch the opening hours data from Facebook and pass it to getTableWithHours.

import { getTableWithHours } from Facebook-opening-hours-to-table;
//...
const table = getTableWithHoursData(yourFBHoursData, translationDict);
//do stuff with table

###Getting Intervals Data Use this method if you do not care for the table and just want the intervals data.

Fetch the opening hours data from Facebook and pass it to getIntervalsWithHours to get to the raw intervals data:

import { getIntervalsWithHours } from facebook-opening-hours-to-table;
//...
var intervals = getIntervalsWithHours(yourFBHoursData, translationDict);
//do stuff with intervals

###Intervals: Intervals is an array of intervals that is created form the opening hours data. You can use it, if you do not want a table to be generated from the Facebook hours data, but still want days with equal opening hours be compressed into one array entry:

//This is how intervals looks like
  var intervals = [
    { 
      "open": "11:00",
      "close": "20:30",
      "from": "mon",
      "to": "wed" 
    },
    {
      "open": "11:00",
      "close": "21:00",
      "from": "thu",
      "to": "fri" 
    }, 
    { 
      "open": "10:30",
      "close": "20:30",
      "from": "sat",
      "to": "sat" 
    },
    {
      "open": "12:00",
      "close": "19:00",
      "from": "sun",
      "to": "sun" 
    } 
  ]
//Generated from:

var hours = {
  "mon_1_open": "11:00",
  "mon_1_close": "20:30",
  "tue_1_open": "11:00",
  "tue_1_close": "20:30",
  "wed_1_open": "11:00",
  "wed_1_close": "20:30",
  "thu_1_open": "11:00",
  "thu_1_close": "21:00",
  "fri_1_open": "11:00",
  "fri_1_close": "21:00",
  "sat_1_open": "10:30",
  "sat_1_close": "20:30",
  "sun_1_open": "12:00",
  "sun_1_close": "19:00"
}

###Translation: Each method takes translationDict as an argument. This argument can be omitted if you are happy with Facebooks default "mon, tue,...". If not, you can supply a dictionary like so:

translationDict = {mon: "Mo", tue: "Di", wed: "Mi", thu: "Do", fri: "Fr", sat: "Sa", sun: "So"};

##Example Usage

	$.ajax({
		method: "GET",
		url: "https://graph.facebook.com/QuellenStr", //Schnitzelhaus Vienna :)
		data : {
			access_token: token,
			fields: "hours"
		}
	})
	.done(function( msg ) {
         var hours = msg.hours;
         var translationDict = {mon: "Mo", tue: "Di", wed: "Mi", thu: "Do", fri: "Fr", sat: "Sa", sun: "So"};
         var table = facebookOpeningHoursToTable.getTableWithHours(hours, translationDict);
         document.body.appendChild(table);
	})

Note: you can use any ajax-request library. I chose to use jQuery in this example. This library does NOT depend on jQuery

Other

If this helped you out, make my day by letting me know!

This library was crafted with care by Calvin Claus.