File: example.html

Recommend this page to a friend!
  Classes of Jakub Krol   JavaScript szort.us URL shortener   example.html   Download  
File: example.html
Role: Example script
Content type: text/plain
Description: Example of use
Class: JavaScript szort.us URL shortener
Shorten URLs using szort.us API
Author: By
Last change:
Date: 9 years ago
Size: 2,372 bytes
 

Contents

Class file image Download
<!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>