"url 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/linuxenko/pen/pyrjXE?depth=everything&order=popularity&page=6&q=shortener&show_forks=false" /> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'><link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css'><link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'> <style class="cp-pen-styles">@import url(https://fonts.googleapis.com/css?family=Roboto); body, html, .container-wrapper { height: 100%; font-family: 'Roboto', sans-serif; } .container-wrapper { display: flex; } .shortener-container { display: flex; margin: auto; max-width: 480px; box-shadow: 0px 0px 4px #444; background: #924da3; border-radius: 5px; } .shortener { padding: 10px 20px; min-width: 380px; min-height: 80px; } .shortener .logo-wrap { color: #fff; font-size: 28px; margin: 10px 0px; text-transform: uppercase; } .shortener .logo { margin-bottom: 5px; } .shortener input[type=text] { background: transparent; border: 2px solid #fff; color: #fff; } .shortener input[type=text]:focus { box-shadow: 0px 0px 2px #fff; } .shortener .error-message { color: #fff; text-align: left; padding: 5px 0px; } .shortener button[type=submit] { width: 100%; margin: 10px 0px; height: 40px; background: none; border: 2px solid #fff; color: #fff; text-transform: uppercase; font-weight: bold; } .shortener button[type=submit]:hover, .shortener button[type=submit]:focus { box-shadow: 0px 0px 2px #fff; } .shortener .latest { list-style: none; margin-top: 10px; margin-left: 10px; padding: 0px; } .shortener .latest .latest-desc { color: #fff; font-size: 18px; font-weight: bold; margin-bottom: 5px; } .shortener .latest a { color: #fff; } .shortener .latest a i { position: relative; font-size: 9px; top: -4px; } </style></head><body> <div class="container-wrapper" ng-app="srApp"> <div class="shortener-container"> <div class="shortener" ng-controller="srCtrl"> <div class="text-center logo-wrap"> <div ng-if="isLoading === false"> <img class="logo" src="https://rawgit.com/linuxenko/linuxenko.github.io/master/showcase/freecodecamp/spring.svg" /> URL Shortener </div> <div ng-if="isLoading === true"> <img class="logo animated infinite rubberBand" src="https://rawgit.com/linuxenko/linuxenko.github.io/master/showcase/freecodecamp/spring.svg" /> please wait ... </div> </div> <div class="text-center" ng-if="isLoading === false && resultingURI === null"> <form ng-submit="submit(shortifierURI)"> <input class="form-control input-lg" type="text" name="url" placeholder="Shortify something ..." ng-change="isError = null" required ng-model="shortifierURI" /> <div class="error-message" ng-show="isError" >Invalid URI: {{shortifierURI}}</div> <button ng-show="shortifierURI.length" class="btn" type="submit"><i class="fa fa-compress"></i>   shortify</button> </form> </div> <div class="text-center" ng-if="resultingURI !== null"> <form ng-submit="resetResult()"> <input class="form-control input-lg" type="text" name="resulting" value={{resultingURI}} /> <button class="btn" type="submit"><i class="fa fa-refresh"></i>   one more</button> </form> </div> <ul class="latest" ng-hide="isLoading"> <li class="latest-desc">Last 3:</li> <li ng-repeat="l in latest"> <a ng-href={{l.url}} target="_blank"> {{l.url}} <i class="fa fa-external-link"></i></a> </li> </ul> </div> </div> </div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.2/angular.min.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/zepto/1.1.6/zepto.min.js'></script> <script >var SERVER_URI = 'url-shortener-freecodecamp.herokuapp.com'; var app = angular.module('srApp', []); app.factory('factoryURI', function($http) { return { fetch : $http.get('//'+ SERVER_URI +'/latest'), create : function(uri) { return $http({ method: 'POST', data : {url : uri}, url : '//' + SERVER_URI }); } } }); app.controller('srCtrl', function($scope, factoryURI) { $scope.isLoading = true; $scope.resultingURI = null; $scope.isError = false; $scope.latest = []; function updateURIS() { factoryURI.fetch.success(function(data) { $scope.latest = data.map(function(d) { d.url = 'https://'+ SERVER_URI +'/' + d.uid; return d; }); $scope.isLoading = false; }); } $scope.resetResult = function() { $scope.resultingURI = null; $scope.shortifierURI = null; } $scope.submit = function(shortifierURI) { $scope.isLoading = true; factoryURI.create(shortifierURI).then( function(data) { $scope.latest = [ {url : data.data.url}, $scope.latest.shift(), $scope.latest.shift() ]; $scope.resultingURI = data.data.url; $scope.isError = false; $scope.isLoading = false; }, function(err) { $scope.isLoading = false; $scope.resultingURI = null; $scope.isError = true; $scope.shortifierURI = shortifierURI; }); } updateURIS(); }); //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: