Advertisement
BrunoDeOliveira

index.html

Mar 2nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.  
  3. const fetchVideoIds = (cb) => {
  4.     const http = new XMLHttpRequest();
  5.     const url = 'http://localhost/fetchIds.php';
  6.     http.open("GET", url, true);
  7.     http.onreadystatechange = function()
  8.     {
  9.         if(http.readyState == 4 && http.status == 200) {
  10.             cb(http.responseText);
  11.         }
  12.     }
  13.     http.send(null);
  14. };
  15.  
  16. const openVideoWindow = (videoIds) => {
  17.     const youtube = 'https://www.youtube.com/watch?v=';
  18.     const videos = JSON.parse(videoIds) || {};
  19.  
  20.     for (let i in videos) {
  21.         window.open(youtube + videos[i]);
  22.     }
  23. }
  24.  
  25. fetchVideoIds(openVideoWindow);
  26.  
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement