File size: 873 Bytes
5d56d1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
var table=document.getElementById("table");
table.style.display='none';
var loading=document.getElementById("loading");
loading.style.display='none';
var btn=document.getElementById("btn_search");
btn.addEventListener("click", classify);
var img_url=document.getElementById("img_url");
img_url.addEventListener("keyup",function(event) {
  if(event.keyCode === 13){
    btn.click();
  }
})

function classify() {
    table.innerHTML="";
    loading.style.display='block';
    var url="findtype?pokename="+img_url.value;
    $.get(url, function(data, status){
      table.style.display='block';
      loading.style.display='none';
      var row = table.insertRow(0);
      var cell1 = row.insertCell(0);
      cell1.innerHTML = data.results;
      var row = table.insertRow(0);
      var cell1 = row.insertCell(0);
      cell1.innerHTML = "Predicted Pokemon Type";
    });
}