// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * Adds a random greeting to the page.
 */
async function fetchVideoData(id) {
  fetch('/data?videoId=' + id)  // sends a request to /data URl with a cursor and whether we want next page or not
    .then(response => response.json()) // parses the response as JSON
    .then((videoJson) => { // now we can reference the fields in myObject!
    document.getElementById("video-title").innerText = videoJson.title
    document.getElementById("video-description").innerText = videoJson.description;
  });
}

window.addEventListener("load", myInit, true); function myInit(){
  const queryString = window.location.search;
  const urlParams = new URLSearchParams(queryString);
  const id = urlParams.get('videoId')
  if(id === "") {
    alert("No ID Selected!");
    window.location.replace('/');
    return;
  } else {
    fetchVideoData(id)
  }
}
@@ -587,204 +587,269 @@
 .%0A%0A/
-**%0A * Adds a random greeting to the page.%0A */%0Aasync function fetchVideoData(id) %7B%0A  fetch('/data?videoId=' + id)  // sends a request to /data URl with a cursor and whether we want next page or not
+/CONSTS%0Aconst FormIDs = %7B%0A  title: %22video-title%22,%0A  description: %22video-description%22%0A%7D%0A%0A//This function is a GET request to our database to populate our mainpage elemetns with video information%0Aasync function fetchVideoData(id) %7B%0A  fetch('/data?videoId=' + id) 
 %0A   
@@ -1018,29 +1018,29 @@
 entById(
-%22video-
+FormIDs.
 title
-%22
 ).innerT
@@ -1089,23 +1089,24 @@
 entById(
-%22video-
+FormIDs.
 descript
@@ -1108,17 +1108,16 @@
 cription
-%22
 ).innerT
@@ -1154,16 +1154,74 @@
  %7D);%0A%7D%0A%0A
+//This event listener will listen for when the page loads%0A
 window.a
@@ -1278,16 +1278,65 @@
 Init()%7B%0A
+  //WHen the page loads check for URL parameters%0A
   const 
@@ -1465,16 +1465,84 @@
 deoId')%0A
+  //if the ID is empty alert the user and redirect back to mainpage%0A
   if(id 
@@ -1638,16 +1638,77 @@
  else %7B%0A
+    //if the ID is valid we do a GET request to our database%0A
     fetc

add consts to script.js and comments