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

nl.codeyellow.signature

v0.0.3

Published

Native view plugin to request and capture the user's written signature. Currently contains a native Android implementation and a pure JS fallback implementation for other devices (including desktop browsers).

Downloads

5

Readme

Cordova Signature View plugin

This plugin provides a simple "pad" for requesting a user's signature which you can use in Cordova/Phonegap applications. For efficiency reasons, the pad is implemented natively where available (currently only for Android). A JavaScript fallback is provided for other platforms, as well as for desktop browsers (for ease of testing).

This works best with an "active" pen, to get the most detailed output. It captures normal "touch" events, so you could use it with a pressure pen or fingers, but the results won't be as accurate.

In principle, you could use the plugin as a generic drawing/sketch capturing system, but it provides no drawing "tools" of any kind.

Usage

This extension is a little strange in that it installs a file called www/js/signature-view.js directly into your application. You can load this and it will provide the AMD module cordova.signature-view. If you're not using an AMD loader, it will define a global SignatureView variable (a property on "window"). It provides only one method, with the following signature (no pun intended):

:::javascript
SignatureView.getSignature(success, error, [title, [htmlPage]]);

The success argument is a callback function accepting one argument, which is either null (in case the user canceled the dialog) or an ImageData object containing the raw binary image data.

The error argument is a callback function accepting one argument, which is a string containing an error message indicating what went wrong.

The title argument is an optional string which indicates what the dialog should show as a heading.

The htmlPage argument is also an optional string which supplies a full HTML page which will be presented in a webview above the signature pad area. This allows you to place salient parts about the agreement just above the signature, which should help ensure that the user knows what they're signing. The base www directory is configured as its base URI, so you can use assets from your application.

Beware when converting the image data to a data URI: some mobile browsers (and IE) have length limitations on data URIs. It's better to use the image data with the canvas/2dcontext putImageData method or something equivalent.

Example

Here's a minimal working example. It assumes there's a CANVAS element in your HTML document which has an id of signature.

:::javascript
var Signature = cordova.require('nl.codeyellow.signature.Signature');
Signature.getSignature(
	function (imgData) {
		/* This is the "success" callback. */
		if (!imgData) return; // User clicked cancel, we got no image data.

		var canvas = document.getElementById('signature'),
		ctx = canvas.getContext('2d');
		canvas.width = imgData.width;
		canvas.height = imgData.height;
		ctx.clearRect(0, 0, canvas.width, canvas.height);
		ctx.putImageData(imgData, 0, 0);
	}, function (msg) {
		/* This is the "error" callback. */
		alert('Could not obtain a signature due to an error: '+msg);
	},
	/* This final string is optional and defaults to a similar string. */
	'Please put your signature down below');