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

local-connection

v2.0.9

Published

API to use Localconnection between iframes in same window

Downloads

2

Readme

LOCALCONNECTION API 2.0

Connect iframes published on another domain (foreign sandbox)

local-connection npm GitHub last commit Travis

Get in contact for help from developer:

Gitter chat Get help on Codementor Website

SYNCRONIZE IFRAMES IN WINDOW

This script is used to communicate and synchronise iframes placed in same parent window.

After you add this script to your project, it defines global LC object.

How it works:

Each and every window, those served in iFrames and need to connect to each other needs:

  • A unique key. A unique Key is important, so only and only companion windows(iframes) connects to each other.
  • A name belongs to themselves.
  • List of names of other frames, those having same key

If all required parameters given correctly, each connect method search for other windows those having correct key ,and then tries to match with given name

As soon as it finds any acceptable window, registers it as an element to LC object with it's name parameter.

From now on all connected windows can communicate with each other.

OPTIONS

|Name|Type| Required| Description | |----|-----|---------|-------| |key | String | YES|Unique connection string. Set this value for all iframes that should communicate each other. Avoid using same key for all projects. | |name | String | YES|Give a different name to each banner.| |frames | String [Array] | YES|Define name of all other banners that will be connected to.| |onConnect|Function|NO| Define a function that will be called as soon as successfully connected to other iframes.| |timeout | Number | NO| Quit trying to connect after defined time in seconds. Default is 0 which means no timeout and keeps continuously try to connect. | |onTimeout | Function | NO| Define a function that will be called if timeout occurs. It will only be called if timeout is greater then 0. |

PROPERTIES

connected : Boolean property that shows if connection established.

HOW TO USE IT

First thing ist first : link to LocalconnectionAPI (localconnection.min.js) script to each index.html. Minified version doesn't give any message to Browsers Console. During development it's also possible to use un-minified version localconnection.js to see logs, but It's not suggested to leave un-minified version in the final creative.

Place LocalconnectionAPI (localconnection.min.js) preferably just before the closing </head> tag, as follow:

<script src="localconnection.min.js"></script>

Then define options in each HTML page (which needs to connect with other)

<script>
    new LocalConnection({
        key: 'uniqueConnectionString',
        name: 'left',
        frames: ['top', 'right'],
        onConnect: function () {
                /*
                    From this point window of left and top will be available as
                    LC.left and LC.top
                    for example :
                */
                
                LC.left.document.getElementsByTagName('body')[0].style.backgroundColor = 'pink';
                }
        timeout: 0, // If you want to quit after a given amount of time set here as second 
        onTimeout: function () {
                    // If you set timeout property bigger than '0'
                    // this function will be called if no succes in connection
                }
            });
</script>

SAMPLE

A working sample available in /test folder

IMPORTANT

-As soon as local connection established:

  • runs onConnect function. Therefore, stop or pause video, canvas or css animations and initialize these functions through onConnect method.
  • all defined frames are available to current LC object as child. For example banner left becomes child of LC in the frame top as LC.left as so on.