jShortener Plugin Version 2.0 Documentation

Posted by | February 10, 2014 | | No Comments




The jQuery plugin is built for the Premium URL Shortener that is available at CodeCanyon. This will not work with any other URL shorteners and I will not implement it to other scripts. This is distributed freely to all of my customers who bought the script from CodeCanyon.

Basically, this little plugin uses jQuery to shorten URLs on your site using the API of your URL shortener. Before setting it up, you need to include the script ‘urlshortener.js’ using the following tag. You can put it before </head> or </body> (recommended). Don’t forget the path if you uploaded it into a folder. Also don’t forget to include the jQuery library.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="urlshortener.js"></script>

Developers

If you know your way through the web console, then you can debug this plugin using that as errors are output directly to the console.

Javascript Version

<script type="text/javascript">
	$('SELECTOR').shorten({ 
		url:'URL TO THE YOUR SHORTENER', //e.g. http://yoursite.com
		key:'API KEY'
	});
</script>

The first thing you must do is to choose a selector. If you are not familiar with jQuery, you select elements using either the tag, id or class. For example $(‘a’) will select all links or $(‘.style’) will select all tags that have the “style” class. You can also use a child selector for example $(‘.comments a’) or $(‘.comments’).find(‘a).

The next thing you must do is to set up the URL to the your shortener. If you choose the javascript version then the URL to the API is simply http://YOURSITE.com. If you wish to distribute this plugin to your users, you can just add your URL in urlshortener.js (see below). You can just directly link the javascript file to your own server.

  var defaults = {
  	url:"ADD YOUR URL HERE",
    key:null,
  };

Finally, add your API key which you can get from http://YOUSITE.com/user (You must login before). Below is an example of usage. Here “http://google.com” will be replaced by the short URL automatically.

<a class="style" href="http://google.com">Google</a>
<!-- Scripts -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="urlshortener.js"></script>
<script type="text/javascript">
	$('a.style').shorten({
		url:'http://MYSITE.com/',
		key:'HMFyPspqbopm'
	});
</script>

If you have any questions, you can contact me via My Profile, Facebook Page or Submit a ticket.