-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurlcode.js
More file actions
64 lines (50 loc) · 1.82 KB
/
Copy pathurlcode.js
File metadata and controls
64 lines (50 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var myId;
// Get the input field
var input = document.getElementById("input");
// Execute a function when the user releases a key on the keyboard
input.addEventListener("keyup", function(event) {
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
// Cancel the default action, if needed
event.preventDefault();
// Trigger the button element with a click
document.getElementById("myBtn").click();
}
});
function getId(url) {
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
var match = url.match(regExp);
if (match && match[2].length == 11) {
return match[2];
} else {
return 'error';
}
}
$('#myBtn').click(function () {
var myUrl = $('#input').val();
myId = getId(myUrl);
$('#myId').html(myId);
if (!myUrl.includes('youtube') || myUrl.length<8){
console.log('\\Invalid Url//');
$('#BodyDiv1').html(`Enter A Valid Url`);
}else{
//window.location.href = ('/Second.html');
var x = document.getElementById("myBtn");
x.style.display = "none";
var y = document.getElementById("input");
y.style.display = "none";
$('#label1').remove();
$('#BodyDiv1').html('<iframe width="560" height="315" src="https://www.youtube.com/embed/' + myId + '" frameborder="0" allowfullscreen></iframe>');
console.log('video done');
//$('#BodyDiv1').html('<iframe width="560" height="315" src="https://www.youtube.com/embed/' + myId + '" frameborder="0" allowfullscreen></iframe>');
var y = document.getElementById("messageBox");
y.style.display = "inline-block"
//var z = document.getElementById("send");
//z.style.display = "inline-block";
/*
*/
/*
https://www.youtube.com/watch?v=iRusbYIyRNI
*/
}
});