Coder Social home page Coder Social logo

jeffreycayao / wasap.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from conversabit/wasap.js

0.0 3.0 0.0 76 KB

Click to start a WhatsApp chat from your website!

Home Page: https://www.conversabit.com/wasap.js/

License: MIT License

HTML 69.64% CSS 13.70% JavaScript 16.66%

wasap.js's Introduction

wasap.js

wasap.js

wasap.jsDemos

Installation

First, add the data-whatsapp attribute to the nodes you want to be clickable:

<span data-whatsapp="5210000000000">Reach me via WhatsApp!</span>

Then include the JS file and initialize it.

wasap.init();

Element options

data-whatsapp is required, it's recommended to be a <span> tag (or any inline element for that matter), and it must not be an <a> element.

  • data-whatsapp (required) • Be sure to use the international phone format for better results and use just numbers—no hyphens, spaces or signs.
  • data-whatsapp-message (optional) • Preset a message.

API

enableIf (regex|function|boolean, defaults to /android|iphone|ipad/i)

Platforms supported currently, if regex, matches against window.navigator.userAgent. When used as a function it can be more modular, and the boolean disables or enables for every platform.

protocolIf (regex|function|boolean, defaults to /android|iphone|ipad/i)

If enabled, what conditions should be met to redirect the user to the whatsapp protocol instead of the http URL, which isn't working on mobile at the moment.

openCallback (function, defaults to window.open)

If elementCallback enabled, you could prevent a click from triggering to do a custom action. After this custom behaviour, this function defines how the user will be redirected.

elementCallback (function)

Callback made to each of the elements found, so you can customize its behaviour (click callbacks, other events, modify the node's content, etc.)

newNodeSelector (string, defaults to a)

The element that will be appended to the target element, which tag name should it have? If a, it will create the href attribute. It supports IDs and classes.

Contribute

  1. Install NodeJS (NVM)
  2. Run nvm use 4 && npm install
  3. Then npm run dev

Roadmap

  • Tests
  • Figure out what to do with WhatsApp Web

wasap.js's People

Contributors

pateketrueke avatar

Watchers

James Cloos avatar Jeffrey Cayao avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.