Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="author" content="Frederick Wright">
- <title>Video Hider</title>
- <!-- Just for the ready handler -->
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <script type="text/javascript">
- /* I take no credit for the querystring function */
- var queryStringValue = window.location.search;
- location.querystring = (function() {
- // The return is a collection of key/value pairs
- var queryStringDictionary = {};
- // Gets the query string, starts with '?'
- var querystring = decodeURI(location.search);
- // document.location.search is empty if no query string
- if (!querystring) {
- return {};
- }
- // Remove the '?' via substring(1)
- querystring = querystring.substring(1);
- // '&' seperates key/value pairs
- var pairs = querystring.split("&");
- // Load the key/values of the return collection
- for (var i = 0; i < pairs.length; i++) {
- var keyValuePair = pairs[i].split("=");
- queryStringDictionary[keyValuePair[0]]
- = keyValuePair[1];
- }
- // toString() returns the key/value pairs concatenated
- queryStringDictionary.toString = function() {
- if (queryStringDictionary.length == 0) {
- return "";
- }
- var toString = "?";
- for (var key in queryStringDictionary) {
- toString += key + "=" +
- queryStringDictionary[key];
- }
- return toString;
- };
- // Return the key/value dictionary
- return queryStringDictionary;
- })();
- function generateVideo() {
- var videoURL = "http://www.youtube.com/v/" + location.querystring["video_id"] + "&feature&autoplay=1&rel=0&fs=0&showinfo=0";
- var videoWatchLink = "https://www.youtube.com/watch?v=" + location.querystring["video_id"];
- document.getElementById('video-container').style.display = 'block';
- document.getElementById('param1').value = videoURL;
- document.getElementById('param2').src = videoURL;
- document.getElementById('watch_on_yt').href = videoWatchLink;
- document.getElementById('video-container').style.display = 'block';
- }
- $(document).ready(function() {
- if(location.querystring["video_id"] != undefined) {
- generateVideo();
- }
- });
- function createLink() {
- var videoID = document.getElementById("video_url").value;
- document.location = "?video_id=" + videoID;
- }
- </script>
- <style type="text/css">
- body {
- font-family: Arial;
- font-size: 14px;
- text-align: center;
- }
- #video-container {
- height: 315px;
- width: 560px;
- margin: auto;
- display: none;
- }
- form {
- border-style: solid;
- border-width: 1px;
- border-color: black;
- width: 560px;
- margin: auto;
- padding: 12px;
- margin-bottom: 12px;
- }
- a {
- text-decoration: none;
- color: #1A1A1A;
- font-weight: bold;
- }
- </style>
- </head>
- <body>
- <form method="get" onsubmit="return false;">
- YouTube Video ID: <input type="text" name="video_url" id="video_url" /> <br /><br />
- <input type="submit" name="submit" value="Create Link" onclick="createLink();" />
- </form>
- <div id="video-container">
- <object width= "560" height="315"><param name="movie" value="http://www.youtube.com/v/vM1pvax-OTk&autoplay=1&showinfo=0&hd=1" id="param1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed id="param2" src="http://www.youtube.com/v/vM1pvax-OTk&autoplay=1&showinfo=0&hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="315" allowscriptaccess="always"></embed></object> <br /><br />
- <a href="" id="watch_on_yt" target="_new">Watch on YouTube</a>
- </div>
- <br /><br /><br />
- <i>NOTE: Some videos may not work as they do not support embedding.</i>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement