Menu

API Reference

This document is a work-in-progress that is currently being written as development on the API takes place. It is in no way complete, but offers developers a place to catch a glimpse of what the future API will look like and how it will function.

Summary

Starting with the 3.0 release of Clip and Share, an API will be offered in order to make building on new features much easier. For example, adding on a new social network that hasn't already been included can be much easier when using the API. Rather than writing lines and lines and lines of repetitive code, only a few, simple JavaScript objects need to be created and then fed to the API.

Who is this document for?

  • Advanced end-users familiar with JavaScript who wish to add on basic new features.
  • Developers who wish to build new functionality into the existing API.

Who is this document NOT for?

  • The everyday user who just wishes to share a funny picture to Tumblr from time-to-time.

API Top-level

All Clip and Share API functions are called from the top-level object of clipAndShare.*. This object serves as the parent to every API call for the sake of simplicity and does nothing when called by itself.

Testing the API

A function for testing the API has been added for convenience. To ensure that you are calling the API properly, simply include the following code in your background layer:

clipAndShare.test()

This function does nothing more than call up an alert dialog informing you that your API implementation is working properly.

Adding Social Networks

Social networking sites are added using the following API call:

clipAndShare.addNetwork(object networkInfo)

The networkInfo object can include the following attributes:

Attribute Required Type Description
networkName Yes String name of network
baseURL Yes String portion of share endpoint preceding the question mark
sharePages No Boolean defines whether pages will be shared; defaults to true
shareLinks No Boolean defines whether links will be shared; defaults to true
shareImages No Boolean defines whether images will be shared; defaults to false
shareQuotes No Boolean defines whether quotes will be shared; defaults to false
titleAttribute No String the URL attribute defining the title of the item shared
linkAttribute Yes String the URL attribute defining the link to the item shared
otherQuery No Associative Array other site-specific querys

Here's an example of how Facebook would be added to the extension:

networkInfo = new Object();
networkInfo.networkName = "Facebook";
networkInfo.baseURL = "https://www.facebook.com/dialog/feed";
networkInfo.shareImages = True;
networkInfo.shareQuotes = True;
networkInfo.titleAttribute = "name";
networkInfo.linkAttribute = "link";

clipAndShare.addNetwork(networkInfo);

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.