Allosoft Clipboard Access

Version 1.5

What is this

This is a Google Chrome extension that provides the pages that are viewed via the browser, the ability to set and get the clipboard textual contents. It is mainly targeted for the development of web apps of your own, that need clipboard access and meet the two following criteria:

  • You are only interested in using Chrome - that's the only browser supported for now
  • You only need to copy or paste textual data

It is used instead of the Flash libraries available (like ZeroClipboard) that often crash and thus resulting not only in your page loosing it's clipboard related functionality, but also trashes the display with the nasty puzzle-piece-skull icon.

In order to use this extension, you must also include the asclip.js script in your page.

License

Please respect the license under which this work is distributed, which is a Creative Commons Attribution-ShareAlike 3.0 Unported License

Important! While you can use this work or it's derivatives as part of a commercial project, you can not sell this work or any of it's derivatives. Take your time and examine carefully the license as it is presented here.

Download, Installation, Usage

Download
Extension

There are three ways to download the extension:

  • Since this is a chrome extension you will be able to find it and download it from Chrome web store soon. Not implemented yet
  • Alternatively you will be able to get it from github repository
  • Or get it from our server by clicking here

Either way you acquire it, it contains all the files of the chrome extension plus the asclip.js (of the correct version) that must be included in your web page in order to access the extension.

Local lib asclip.js

If you already have the plugin you can download only the asclip.js file from here:

Installation

Unless you got the extension from the Chrome web store, you need to follow these steps in order to install it to your browser.

  1. Locate the folder on your computer that contains the files (if you downloaded the .zip file you must unzip it first in some folder, at a permanent location)
  2. From the chrome menu go to Tools > Extensions, or on the url type: chrome://extensions/
  3. Check the Developer mode (see point I in image below) if not already checked
  4. Click on the "Load unpacked extension..." button (see point II in image below) and select the folder from step #1

The file is present in our server so that you can use it without downloading it separately.

Usage

Your HTML must include the asclip.js using something like:


<script src="asclip.js"></script>
				

or (recomended) use the hosted always available link to our server:


<script src="http://www.allos.gr/downloads/prod/asClickToCopy/v1.5/asclip.js"></script>
				

Sample code

Version check

You can (and you should) check the compatibility of the asclip.js script with the extension loaded once in your page, prior to using the other methods. This is simply done by calling the check() method with an optional callback function as an argument. If the check fails, a message appears to the user informing for the incompatibility and giving the option to come to this page in order to download the correct version of the asclip.js. If the callback is present then you can take the result and use it in your script as you like.

asClipboardXS.check(
	function (R) {
		console.log("The check is complete!");
                console.log("The result is: " + R.compatibilityCheck);
	}
);
				
Set clipboard data

Given that the extension is installed and enabled (and that you already included asclip.js in your page) you can use it to put some text to clipboard with the following command.

asClipboardXS.copy("Clip text!",
	function (R) {
		console.log("The copy was a success: " + R.res);
	}
);
				

The copy method takes two arguments. The first is the text to copy, and the optional second one is a callback function that returns the result success or failure (true or false) of the operation. The only argument of the callback function is an object whose only interesing attribute is the res that holds the success or failure.

Get clipboard data

In order to read the clipboard textual contents you can use the paste method givind a mandatory callback function, like:

asClipboardXS.paste(
	function (R) {
            if (r.res)
                    console.log(r.content);
            else
                    console.log("Err"); });
	}
);
				

Contact us

Regarding the chrome extensions please contact us either via the github tools, or via e-mail at: chrome@allos.gr using the name of the extension in the subject (e.g. for this extension include the word clipboard).


Creative Commons License
This work by AlloSoft is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.