"shortener "
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html lang='en' class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/marnibrewster/pen/EKZBgL" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/css/bootstrap.min.css'> <style class="cp-pen-styles">.jumbotron { padding: 1em; background-color: #41CBD9; color: white; border-bottom: thick solid #1C828C; } .btn:hover { background-color: rgba(28, 130, 140, 0.5); } .btn { background-color: #41CBD9; border-color: #41CBD9; } h4 { color: #8C8A7E; } .input, .form-control, #result { color: #8C8A7E; } .form-control { } a:hover { color: #1C828C; text-decoration: none; } a { color: #DF59A4; } #output{ padding-bottom: 3em; }</style></head><body> <div class="jumbotron"> <h1>URL Shortener Service</h1> <p>Made by <a href="http://marnibuilds.com" target="_blank">Marni</a></p> </div> <div class="container"> <div class="blue-line"></div> <form> <div class="input form-group"> <label for="url">Enter URL:</label> <input type="text" id="longurl" name="url" class="form-control"/> <br/> <input class="btn btn-primary" type="button" value="Create Short" id="clickMe"/> </div> </form> <div id="result">Shortened URL:</div> <div id="output"></div> </div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js'></script><script src='https://apis.google.com/js/client.js'></script> <script >$("#clickMe").on('click', function(){ gapi.client.load('urlshortener','v1').then(function(){ var longUrl = $("input:text").val(); var request = gapi.client.urlshortener.url.insert({ 'resource': { 'longUrl': longUrl } }); request.execute(function(response){ //handle if valid url: if (response.id != null) { str = "<h4><a target = '_blank' href='" + response.id + "'>" + response.id + "</a></h4>"; $("#output").html(str); $("#longurl").val(''); } else { alert("please check that the url is correct and re-enter") } }) }) }); function load() { $("input:text").focus(); gapi.client.setApiKey('AIzaSyAOk_9SFVml-xdDoIi-mPVDP3BOUgsoF80'); gapi.client.load('urlshortener', 'v1', function() {}); } window.onload = load; //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: