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

@adwatch/socmechanics-adapter

v1.0.5

Published

Module SocMechanicsAdapter required for bind socmechanics items

Downloads

11

Readme

#SocMechanicsAdapter

Module SocMechanicsAdapter required for bind socmechanics items.

It works directly with SocMechanicsFactory to manage for data streams on client side

Install

$ npm install --save @adwatch/socmechanics-adapter

Usage

import SocMechanicsAdapter from '@adwatch/socmechanics-adapter';
// or
var SocMechanicsAdapter = require('@adwatch/form/socmechanics-adapter');

API

####init()

Initialize SocMechanicsAdapter

const socMechanicsAdapter = new SocMechanicsAdapter(options).init();

OPTIONS

When you create new exemplar SocMechanicsAdapter module you must to provide required argument options with options.

The Kit of options depends specific case. But module has common options which will be indicated separately

On current moment exists CASEs:

  • ' freeShare:onePost:allNetworks ' - (only: vk.com, facebook.com, ok.ru)
  • ' getAvatar:allNetworks ' - (only: vk.com, facebook.com, ok.ru, instagram.com, twitter.com)

###Common options

#####CASE Type string (Required)

Default: ''

let socMechanicsAdapter = new SocMechanicsAdapter({
    CASE: 'freeShare:onePost:allNetworks'
});

#####target Type string (Required)

Default: ''

let socMechanicsAdapter = new SocMechanicsAdapter({
    target: '.social button'
});

#####logger Type boolean

Default: 'false'

let socMechanicsAdapter = new SocMechanicsAdapter({
    logger: true
});

#####networks Type object (Required)

Default: '{}'

Authenticated data your apps

let socMechanicsAdapter = new SocMechanicsAdapter({
    networks: {
        'VK': {
            appId: XXXXXX
        },
        'FB': {
            appId: XXXXXX
        },
        'OK': {
            appId: XXXXXX,
            app_key: 'YYYYYY'
        },
        'TW': {
            proxy: '/tw.php'
        },
        'IN': {
            appId: 'XXXXXX'
        }
    }
});

#####action Type string

Default: '/'

A path to send summary result of module`s job

let socMechanicsAdapter = new SocMechanicsAdapter({
    action: '/share'
});

#####callSuccessSend Type function

Default: false

A callback after success send summary data about user to your server

let socMechanicsAdapter = new SocMechanicsAdapter({
    callSuccessSend: function(data, serverRes){
        console.log('Your data received server', data, serverRes);
    }
});

#####callErrorServer Type function

Default: false

A callback by server error

let socMechanicsAdapter = new SocMechanicsAdapter({
    callErrorServer: function(){
        console.log('Something wrong!');
    }
});

#####callBlockedModal Type function

Default: false

A callback when user blocked modal window in his browser

let socMechanicsAdapter = new SocMechanicsAdapter({
    callBlockedModal: function(){
        console.log('You need to enable modal windows');
    }
});

###Options for ' freeShare:onePost:allNetworks '

#####timeShareLimit Type number

Default: 4

Share limit time in seconds

let socMechanicsAdapter = new SocMechanicsAdapter({
    timeShareLimit: 4
});

#####infoShare Type object

Default: {}

You can to see most common information to https://www.npmjs.com/package/@adwatch/share

let socMechanicsAdapter = new SocMechanicsAdapter({
    infoShare: {
       description: 'Test page desc',
       img: 'http://example.ru/img/share.jpg',
       title: 'Test Share',
       url: window.location.href,
       workId: 2
   }
});

#####token Type object

Default: {}

User Token

let socMechanicsAdapter = new SocMechanicsAdapter({
    token: 'XXX'
});

#####callBadShareClient Type function

Default: false

Callback after Client Bad Share

let socMechanicsAdapter = new SocMechanicsAdapter({
    callBadShareClient: function(){
        console.log('Client Bad Share!!!');
    }
});

#####callErrorSend Type function

Default: false

Callback after Backend Bad Share

let socMechanicsAdapter = new SocMechanicsAdapter({
    callErrorSend: function(result){
        console.log('Backend Bad Share!!!', result);
    }
});

#####callClientAllow Type function

Default: false

let socMechanicsAdapter = new SocMechanicsAdapter({
    callClientAllow: function(){
        console.log('You must approve conditions of use application');
    }
});

#####callPrivateSettings Type function

Default: false

Required by Facebook

let socMechanicsAdapter = new SocMechanicsAdapter({
    callPrivateSettings: function(){
        console.log('You must approve conditions of use application');
    }
});

#####callShareStart Type function

Default: false

Callback when share start

let socMechanicsAdapter = new SocMechanicsAdapter({
    callShareStart: function(elem){
        elem.disabled = true;
        elem.classList.add('blocked');
    }
});

#####callShareEnd Type function

Default: false

Callback when share ends

let socMechanicsAdapter = new SocMechanicsAdapter({
    callShareEnd: function(){
       console.log('Share ends');
    }
});

#####callTimeStamp Type function

Default: false

Callback when share ends

let socMechanicsAdapter = new SocMechanicsAdapter({
    callTimeStamp: function(elem, timer, int, timeLimit){
       var status = elem.closest('.social').querySelector('.status');

        if(timer > timeLimit){
            clearInterval(int);
            elem.disabled = false;
            elem.classList.remove('blocked');
            status.innerHTML = '';
        }else{
            status.innerHTML = 'Will be available after ' + (timeLimit - timer);
        }
    }
});

License

MIT ©