From f2a5ac49e8df89b52b700f2663afbfaa1b914491 Mon Sep 17 00:00:00 2001
From: Kevin XU <kevin-xu@hotmail.fr>
Date: Thu, 22 Nov 2018 20:54:21 +0100
Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20recherche=20de=20cha=C3=AEne?=
 =?UTF-8?q?=20sur=20Youtube?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 js/recherche.js                 | 10 +++++++++-
 page_welcome/index.php          |  8 ++++----
 youtube-api/userSuggestions.php |  4 ++--
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/js/recherche.js b/js/recherche.js
index 8797961..b499c54 100644
--- a/js/recherche.js
+++ b/js/recherche.js
@@ -28,7 +28,15 @@
                 document.getElementById('suggestionButtons').innerHTML = options;
             }
         };
-        xhttp.open("GET", "../API_Twitter/userSuggestions.php?w="+keyword, true);
+
+        var API = "API_Twitter";
+        if (document.getElementById("radio_3").checked == true) {
+            API = "API_Twitter";
+        }
+        else if (document.getElementById("radio_2").checked == true) {
+            API = "youtube-api"
+        }
+        xhttp.open("GET", "../"+API+"/userSuggestions.php?w="+keyword, true);
         xhttp.send();
     }
 </script>
diff --git a/page_welcome/index.php b/page_welcome/index.php
index 228ed8d..ac2cbb1 100644
--- a/page_welcome/index.php
+++ b/page_welcome/index.php
@@ -36,16 +36,16 @@ session_start();
 
 									<!-- <input type="submit" value="Search"> -->
 									<div style="display: inline-flex;">
-									    <input class="img" type="radio" id="radio_1" name="radio[]" value="1" />
+									    <input class="img" type="radio" id="radio_1" name="radio[]" value="1" onchange="showSuggestions();"/>
 									    <label for="radio_1"><img src="../images/ins.png" width="50" height="50"/></label>
 
-									    <input class="img" type="radio" id="radio_2" name="radio[]" value="2" />
+									    <input class="img" type="radio" id="radio_2" name="radio[]" value="2" onchange="showSuggestions();"/>
 									    <label for="radio_2"><img src="../images/youtube.jpeg" width="50" height="50"/></label>
 
-									    <input class="img" type="radio" id="radio_3" name="radio[]" value="3" />
+									    <input class="img" type="radio" id="radio_3" name="radio[]" value="3" onchange="showSuggestions();"/>
 									    <label for="radio_3"><img src="../images/twitter.png" width="50" height="50"/></label>
 
-									    <input class="img" type="radio" id="radio_4" name="radio[]" value="4" />
+									    <input class="img" type="radio" id="radio_4" name="radio[]" value="4" onchange="showSuggestions();"/>
 									    <label for="radio_4"><img src="../images/facebook.png" width="50" height="50"/></label>
 									</div>
 									<input id="searchField" style="height: 50px; font-size: 20px;" list="usernames" name="username" type="text" size="40" maxlength="100" autocomplete="off" placeholder="Search here..." onkeyup="
diff --git a/youtube-api/userSuggestions.php b/youtube-api/userSuggestions.php
index dc7a30d..e38473c 100644
--- a/youtube-api/userSuggestions.php
+++ b/youtube-api/userSuggestions.php
@@ -2,13 +2,13 @@
 require './userInfos.php';
 
 
-$results = searchByKey($_GET['key']);
+$results = searchByKey($_GET['w']);
 
 
 $res=array();
 
 for ($i=0; $i<5; $i++){
-    $res[$i]['channelTitle'] = $results[$i]->snippet->channelTitle;
+    $res[$i]['username'] = $results[$i]->snippet->channelTitle;
     $res[$i]['profile_image'] = $results[$i]->snippet->thumbnails->default->url;
 }
 
-- 
GitLab