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

clippy2

v1.0.1

Published

Copy text to clipboard with javascript and flash

Downloads

8

Readme

Clippy2 - Copy text to your clipboard

Clippy2 is a very simple Flash widget that makes it possible to place arbitrary text onto the client's clipboard. Clippy2 could be looks like:

Clippy2 in action

This is a refactored fork of Clippy with enhanced functionality:

  • Passing the text to copy via HTML-attribute (which could be modified anytime you want), instead of as a flashvar (which passed into Flash only once on loading). This allows to use Clippy2 with frameworks like AngularJS.

  • Added possibility to copy text by calling a JavaScript callback window.clippyTextGetter() This allows for increased flexibility in retrieving the data to copy, e.g. if the text to be clipped is lengthy.

Usage

Download latest stable release, unzip and put it to your public directory or wherever your static assets can be found. Then use it in your project depending on cases described below.

Copying text from DOM attribute

Here is a sample HTML snippet that can be used to place Clippy2 button on a page:

<object clippy-text="{text-to-copy}" id="clippy-id" height="14" width="14" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
    <param name="movie" value="path/to/clippy2.swf">
    <param name="allowScriptAccess" value="always">
    <param name="quality" value="high">
    <param name="scale" value="exactfit">
    <param name="wmode" value="transparent">
    <param name="flashVars" value="">
    <embed name="clippy-id" src="path/to/clippy2.swf" height="14" width="14" flashVars="" allowscriptaccess="always" quality="high" scale="exactfit" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">
</object>

Use clippy-text attribute for placing text to copy. This attribute could be changed anytime you want with plain javascript document.getElementById('clippy-id').setAttribute('clippy-text', 'New text to copy') or jQuery $('#clippy-id').attr('clippy-text', 'New text to copy')

Make sure that you have the same values for id-attribute in tag and name-attribute in tag.

Remember that id-attribute should be unique across page. So, in case you use several Clippy2 buttons on page, take care for this.

For disabling embedded icon just set noIcon=true as value for flashVars attribute and parameter. You will get transparent flash buton and its width and height could be modified.

Copying text with JavaScript callback

In case window.clippyTextGetter() function is defined, it will be called with clicked Flash object id as argument.

window.clippyTextGetter = function(id) {
    // Determining which button was clicked.
    if (id === 'clippy-id-1') {
        // Returned text will be copied to clipboard
        return 'text-to-copy-for-specified-button'
    }
    // Empty string will be copied to clopboard (clearing buffer)
    return '';

    // DOM object could be accessed.
    var obj = document.getElementById(id);

    // Clippy2 will act by default, as if clippyTextGetter() was not defined
    return null;
    return undefined;
}

Compiling

In order to compile Clippy2 from source, you need to install the haXe 3.

The haXe code is in clippy2.hx, the button images are in assets, javascript code executing on button click is in clippy2.js and the compiler config is in clippy2.hxml. Make sure you look at all of these to see where and what you'll need to modify. To compile everything into a final SWF, run the following from Clippy2 root directory:

> haxe clippy2.hxml

If that is successful, use compiled clippy2.swf.

License

LICENSE (MIT)