YouTube iframe

by joaoManolo

HTML

<div class="box-midia">
    <div class="col-sm-6">
        <div class="well-media">
            <div class="vendor">
                <iframe src="//www.youtube.com/embed/" width="400" height="225" frameborder="0" id="yt-iframe"></iframe>
            </div>
            <div class="video-text">
                 <h2>Link do Youtube</h2>

                <div class="tag-nest">
                    <input type="text" id="yt-input" placeholder="Digite o Link" class="form-control" />
                </div>
            </div>
            <div class="video-category-bg">
                 <h3>Video</h3>
 <a class="link-media pull-right" href="#"> <span
                                                    class="fontawesome-film"></span>
                                                </a>

                <div class="triangle-white"></div>
                <div class="triangle-video-right"></div>
            </div>
        </div>
    </div>

CSS

/* maki */
[class*="maki-"]:before {
    font-family:'maki', sans-serif;
}
/* entypo */
[class*="entypo-"]:before {
    font-family:'entypo', sans-serif;
}
/* fontawesome */
[class*="fontawesome-"]:before {
    font-family:'FontAwesome', sans-serif;
}
body {
    color: #9ea7b3!important;
    font-family:"Open Sans", Arial, sans-serif!important;
    font-size: 13px!important;
    line-height: 20px;
    overflow-x: hidden!important;
    min-height: 100%;
    z-index: -2;
    margin: 0px !important;
    background: url('../img/bg.jpg') no-repeat top center fixed;
    -moz-background-size: cover;
    -webkit-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
/*
  PREALOADER
 */
 a:hover {
    text-decoration: none!important;
}
#preloader {
    background: transparent;
    \9;
    /* IE 8 and below */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(37, 45, 59, 0.8);
    /* change if the mask should have another color then white */
    z-index: 2000;
    /* makes sure it stays on top */
    /*   background-image: url("../img/overlays/06.png");
  background-repeat: repeat; */
}
#mapContainer {
    font-family: sans-serif;
    background: #fff;
    color: #444;
    height: 100%;
    padding: 0;
    margin: 0;
}
#logo {
    left: 19px;
    position: relative;
    top: -34px;
    max-width: 191px;
}
#logo-mobile {
    left: -33px;
    position: absolute;
    top: -14px;
    z-index: 0;
}
#logo h1, #logo-mobile h1 {
    font-size: 30px;
    font-weight: 200;
    letter-spacing: -1px;
    text-decoration: inherit;
    text-transform: uppercase;
    color: #fff;
}
#logo h1 span, #logo-mobile h1 span {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    font-size: 11px;
    margin-left: 0;
    padding: 0 5px;
    position: relative;
    top: -3px;
}
/**
 * BOOTSRAP COUSTOM
 */
 .container-fluid {
    padding-left: 0!important;
    padding-right:...

JavaScript

$('#yt-input').change(function () {
    alert("Entrou no metodo!");

    var inputValue = $('#yt-input').val();
    var iframe = $('#yt-iframe').val();
    var result = inputValue.split("=");

    if (result[0] == "https://www.youtube.com/watch?v" || result[0] == "www.youtube.com/watch?v") {
        $('#yt-iframe').attr('src', '//www.youtube.com/embed/' + result[1]);

    } else {
        $('#yt-iframe').attr('src', 'https://www.youtube.com/watch?v=');
        alert("Por Favor, selecione um link válido do Youtube");
    }
})