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

@garyliao/pattern-lock-js-advanced

v1.0.1

Published

An pattern lock project forked from @tympanix/pattern-lock-js, but with more options and functions to operate with.

Downloads

6

Readme

pattern-lock-js

A passcode mechanism built with scalable vector graphics (SVG) and javascript for modern web application with mobile and tablet support

Demo

Install

Install using npm:

npm i @garyliao/pattern-lock-js-advanced

Getting started

Import dependecies:

<script src="jquery.js" charset="utf-8"></script>

Import the module:

<link rel="stylesheet" href="patternlock.min.css">
<script src="patternlock.min.js" charset="utf-8"></script>

Design your desired svg pattern (or use the default one below). Your svg graphics must as a minimum have the patternlock class and three groups <g> with the classes lock-actives, lock-lines and lock-dots

<svg class="patternlock" id="lock" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
    <g class="lock-actives"></g>
    <g class="lock-lines"></g>
    <g class="lock-dots">
        <circle cx="20" cy="20" r="2"/>
        <circle cx="50" cy="20" r="2"/>
        <circle cx="80" cy="20" r="2"/>

        <circle cx="20" cy="50" r="2"/>
        <circle cx="50" cy="50" r="2"/>
        <circle cx="80" cy="50" r="2"/>

        <circle cx="20" cy="80" r="2"/>
        <circle cx="50" cy="80" r="2"/>
        <circle cx="80" cy="80" r="2"/>
    </g>
</svg>

Initialise the component

var lock = new PatternLock("#lock", {
  onPattern: function(result) {
    console.log(result.rspCode);
    // check rspCode equals 0000 before you retrieve result.pattern
   }
});

Options

The returned object from new PatternLock(...) has the following utility functions:

  • clear() Clears the current pattern
  • success() Validates the pattern as correct
  • error() Validates the pattern as incorrect
  • switchHide() Hide or Show line when running
  • getPattern() Return an object contains rspCode and pattern result.
    • 0000 -> Success
    • 1001 -> Input nodes number invalid(Smaller than minimun number)
    • 1002 -> Input nodes number invalid(Exceed manimun accepted number)

The pattern lock constructor accepts a second argument - an object literal with the following properties:

  • onPattern: function Called when a pattern is drawn with the pattern as argument. Returning true/false validates/invalidates the pattern - the same as calling success() and error(). The context is set to the pattern lock instance itself.
  • allowRepeat: boolean Defines if nodes can be selected repeatly(But can't select one node continuosly). Default: true
  • hideLine: boolean Hide the lines if needed. Default: false
  • checkMin: boolean Defines if need check min input nodes. Default: true
  • checkMax: boolean Defines if need check max input nodes. Default: true
  • min: number Defines the minimum valid numbers of input nodes. Default: 4
  • max: number Defines the maximun valid numbers of input nodes. Default: 9