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

fam-sdk

v0.0.2

Published

A javascript library to integrate FAM into web apps.

Downloads

6

Readme

Free All Media Javascript SDK

  • Helps you integrate FAM into your web site or web app with minimal setup.
  • Event callbacks for everything you need.
  • Can be included into an HTML document or imported directly via npm.
  • CDN hosted and non-hosted copies available.

Installation

CDN Hosted

You can always pull the latest version of the FAM Javascript SDK from our CDN at:

https://cdn.freeallmedia.com/sdk/js/0/latest/fam.js

HTML

<!-- Include this at the bottom of your 'body' tag -->
<script src="https://cdn.freeallmedia.com/sdk/js/0/latest/fam.js"></script>
<script type="text/javascript">
  (function (window) {
    const fam = new Fam();
  })(window);
</script>

NPM

You can install the FAM Javascript SDK from npm:

$ npm install fam-sdk --save

You can import FAM directly as a module via the import keyword:

import Fam from "fam-sdk";

const fam = new Fam()

There is a /dist/ directory for those that prefer directly including a local copy into their HTML documents:

$ npm install fam-sdk
$ ls ./node_modules/fam-sdk/dist/fam.js

Example Code

A complete example is available in the /dist/examples directory and on our CDN:

Usage

fam.window(url)

  1. Takes a FAM campaign URL
  2. Displays the FAM campaign in a new window or tab.
  3. Returns the new window object.
const famWindow = fam.window("https://cdn.freeallmedia.com/campaigns/my-campaign/index.html");

setTimeout(() => {
  famWindow.close();
}, 5000);

fam.iframe(domID, url)

  1. Takes a domID to an element on your HTML page and a FAM campaign URL.
  2. Creates an iFrame within the designated element that displays the FAM campaign.
  3. Returns the iFrame's DOM element.
const iFrameElement = fam.iframe("https://cdn.freeallmedia.com/campaigns/my-campaign/index.html");

fam.on(eventName, eventHandler)

  1. Takes an event name and event handler function.
  2. Calls the event handler function each time
  3. Returns the iFrame's DOM element.
fam.on("start", function () {
  console.log("FAM experience started.");
});
fam.on("end", function () {
  console.log("FAM experience ended.");
});
fam.on("close", function (activity) {
  console.log(`FAM experience closed by user while on activity named "${activity.name}"`);
});
fam.on("activity:start", function (activity) {
  console.log(`Activity named "${activity.name}" of type "${activity.type}" started.`);
});
fam.on("activity:end", function (activity, results) {
  console.log(`Activity named "${activity.name}" of type "${activity.type}" ended with the following results:`, results);
});
fam.on("image:impression", function (activity, creative) {
  console.log(`Image "${creative.name}" shown in activity "${activity.name}"`);
});
fam.on("image:clickthrough", function (activity, creative, url) {
  console.log(`Image "${creative.name}" clicked through to url "${url}" in activity "${activity.name}"`);
});
fam.on("video:play", function (activity) {
  console.log(`Video for activity "${activity.name}" playing.`);
});
fam.on("video:pause", function (activity) {
  console.log(`Video for activity "${activity.name}" paused.`);
});
fam.on("video:end", function (activity) {
  console.log(`Video for activity "${activity.name}" ended.`);
});
fam.on("video:mute", function (activity) {
  console.log(`Video for activity "${activity.name}" muted.`);
});
fam.on("video:unmute", function (activity) {
  console.log(`Video for activity "${activity.name}" un-muted.`);
});