To add Youtube URL & Edit option also

by Prabakaran 2013-11-28 10:22:43

<script type='text/javascript' src="jquery.min.js"></script>
<script type='text/javascript'>
var a=3;
function inArray(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
}

function edit_url(args) {
$("#add_url").show();
$("#youtube").val(args);
var urls=$("#ytlInfo").html();
var urls1=$("#you_tube").val();

var temp = ' //alert(urls+"
"+temp);

var res = urls.replace(temp+",",'');
var res1 = urls1.replace(args+",",'');

//alert("Final
"+res1);
$("#ytlInfo").html(res);
$("#you_tube").val(res1);
$('#ytlInfoerror').html('');
}

function ytVidId() {
var url=$("#youtube").val();
url=$.trim(url)
var p = /^(?:https?://)?(?:www.)?(?:youtu.be/|youtube.com/(?:embed/|v/|watch?v=|watch?.+&v=))((w|-){11})(?:S+)?$/;
if (url.match(p)) {
var con=$("#ytlInfo").html();
var y = $("#you_tube").val();
var str= con.split(",");
var str1= y.split(",");
var inval = inArray(url, str1);
//alert(str.length+"==="+a)
//alert(y)
if (str1.length
if (!inval) {
if (con=="") {
con = '
y= url;
}else{
con = con+',
y= y+","+url;
}
//alert(y)
$('#ytlInfo').html(con);
$('#you_tube').val(y);
$('#ytlInfoerror').html('');
$("#youtube").val("");
}else{
$('#ytlInfoerror').html('Please try to some other youtube URL...!');
}
}else{
$('#ytlInfoerror').html('Your limit has been crossed....');
$("#add_url").hide();
}
}else{
$('#ytlInfoerror').html('Kindly Enter Valid youtube URL...!');
}
}
</script>
<div id='add_url'>
<input type="text" name="youtube" id ="youtube" value="" size=100/><input type='button' onclick='ytVidId();' value='Add Url'>
</div>
<textarea id='you_tube' style='width:1000px;height:100px;'>
1053
like
0
dislike
0
mail
flag

You must LOGIN to add comments