cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<h1>MiniMe</h1>
<label for="url-input">Input a URL to Minify</label>
<div class="input-group">
  <span class="input-group-addon" id="basic-addon3">https://</span>
  <input type="text" class="form-control" id="url-input" placeholder="robertvalmassoi.com">
  <span class="input-group-addon btn btn-info" id="mini-btn">MiniMe!</span>
</div>

<label for="url-output">MiniMe URL</label>
<div class="input-group">
  <input type="text" class="form-control" id="url-output">
  <span class="input-group-addon btn btn-info" id="copy-btn">copy</span>
</div>

<div id="git">
<a href="https://github.com/valmassoi/url-shortener" target="_blank" id="git">
    <button type="button" class="btn btn-default btn-lg">
  <span aria-hidden="true"></span><i class="fa fa-github"></i> Github
  </button></a>
  <p><br>Using my API - <a href="https://minime.herokuapp.com/" target="_blank">minime.herokuapp.com/</a></p>
</div>
            
          
!
            
              body
  padding: 20px
label
  padding-top: 20px
  min-width: 300px !important
#form-control
  min-width: 300px !important
#copy-btn
  min-width: 85px
#mini-btn
  background-color: #2E6F9A !important
  width: 85px
  &:hover
    background-color: #217DBB !important
#git
  margin-top: 50px
  text-align: center
            
          
!
            
              const baseUrl = "http://cors.io/?u=https://minime.herokuapp.com/new/"
let input = "https://www.google.com"
let url = baseUrl + input


$(function() {

})

function urlMod(origUrl){
  let regexp = /^(https?):\/\//
  let url = origUrl
  if (regexp.test(url))
    console.log("begins with http")
  else//add http://
    url = 'http://' + url 
  return url
}
function urlCheck(url){
  let regexpTwo = /^(https?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
  return regexpTwo.test(url)
}

function api(origUrl){
  $.getJSON(baseUrl+origUrl, function (data) {
    console.log(data)
    $('#url-output').val(data.short_url)
  })
}

$("#mini-btn").on("click", function(){
  miniMe()
})
$("#url-output").css("cursor", "default")
function miniMe(){
  console.log("mini me!: "+ $('#url-input').val())
  let origUrl = $('#url-input').val()
  let url = urlMod(origUrl)
  if (urlCheck(url))
    api(url)
  else
    console.log("bad url")
}

$("#copy-btn").on("click", function(){
  let copyTextarea = document.querySelector('#url-output')
  copyTextarea.select()
  try {
    var successful = document.execCommand('copy')
    var msg = successful ? 'successful' : 'unsuccessful'
    console.log('Copying text command was ' + msg)
  } catch (err) {
    console.log('Oops, unable to copy')
  }
})

$("#url-input").keydown(function(e) {
    if(e.keyCode == 13){
      miniMe()
    }
});

            
          
!
999px
Loading ..................

Console