JavaScript szort.us URL shortener: Shorten URLs using szort.us API

Recommend this page to a friend!
     
  Info   Example   View files Files   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 85 All time: 446 This week: 3Up
Version License JavaScript version Categories
szortus-js 1.0Freeware1.0jQuery, Web services
Description 

Author

This object can shorten URLs using szort.us API.

It can send a HTTP request via AJAX to the szort.API Web server to shorten a given URL.

Innovation Award
JavaScript Programming Innovation award nominee
August 2014
Number 4
URL shortening is often necessary to allow the user to share URLs that are simpler to memorize and type.

This object implements a URL shortening solution using the szort.us API.

Manuel Lemos
Picture of Jakub Krol
Name: Jakub Krol <contact>
Classes: 2 packages by
Country: Poland Poland
Age: 32
All time rank: 1522 in Poland Poland
Week rank: 6 Up1 in Poland Poland Up
Innovation award
Innovation award
Nominee: 2x

Example

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!-- jQUery is required. --> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!-- JSON-js isn't required, but is needed for old browser. --> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js"></script> <!-- Library itself. --> <script type="text/javascript" src="szortus.class.js"></script> <!-- This is example script. --> <script type="text/javascript"> var Sz = new szortus(); $(function(){ $('#szortuj').click(function(){ var url = $('#long_url').val(); if ($('#async').is(':checked')){ $('#ans').html('Please wait...'); Sz.getShortURLAdv(url, function(short, long, html, bbcode){ $('#ans').html('Long URL: <b>'+long+'</b><br>Short URL: <b>'+short+'</b><br>Visit it: '+html); }); } else { var data = Sz.getShortURLAdvSync(url); $('#ans').html('Long URL: <b>'+data.orig_url+'</b><br>Short URL: <b>'+data.sz_url+'</b><br>Visit it: '+data.html_code); } }); }); </script> </head> <body> <h2>Make URL shorter using szort.us</h2><input type="text" id="long_url" value="http://example.com" /><input type="submit" id="szortuj"><input type="checkbox" id="async" checked="checked" />Async? <div id="ans"></div><br><br><br> EN: Our API can be used to shorten links. There is no limit of the shortened links and links are kept for ever, so it is worth considering the use of szort.us to create short links in your own application. Using the API is completely free and requires no registration. You can also create libraries or programs to help explore szort.us.<br> PL: Nasze API moze być wykorzystywane do skracania linków. Nie ma żadnego limitu co do skracanych linków (patrz regulamin->4.) a linki są przechowywane dożywotnio (regulamin->5.), dlatego warto zastanowić się nad wykorzystaniem szort.us do tworzenia krótkich linków we włąsnej aplikacji. Korzystanie z API jest w pełni darmowe i nie wymaga żadnej rejestracji. Można również tworzyć biblioteki lub programy pomagające wykorzystać szort.us. </body> </html>

  Files folder image Files (3)  
File Role Description
Plain text file szortus.class.js Class Class source, full commented
Plain text file szortus.class.min.js Class Minified version of class source
Accessible without login Plain text file example.html Example Example of use

 Version Control Unique User Downloads Download Rankings  
 0%
Total:85
This week:0
All time:446
This week:3Up