pis #1
							
								
								
									
										16
									
								
								js/pis.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								js/pis.js
									
									
									
									
									
								
							@ -26,7 +26,21 @@ async function displayData(json) {
 | 
				
			|||||||
    // Receives the JSON Respose ([{},{}]) containing one or more possible
 | 
					    // Receives the JSON Respose ([{},{}]) containing one or more possible
 | 
				
			||||||
    // PIS codes.  Display the code and the stops with a method of scrolling between them.
 | 
					    // PIS codes.  Display the code and the stops with a method of scrolling between them.
 | 
				
			||||||
    // Maybe as a table or a carousel?
 | 
					    // Maybe as a table or a carousel?
 | 
				
			||||||
    log(`displayData: ${JSON.stringify(json)}`)
 | 
					    const div = document.getElementById('result-box')
 | 
				
			||||||
 | 
					    const tableHtml = `<table id="result-table">
 | 
				
			||||||
 | 
					                      <tr>
 | 
				
			||||||
 | 
					                        <th class="code">Code</th>
 | 
				
			||||||
 | 
					                        <th class="stops">Stations</th>
 | 
				
			||||||
 | 
					                      </tr>
 | 
				
			||||||
 | 
					                    </table>`
 | 
				
			||||||
 | 
					    div.insertAdjacentHTML("beforeend", tableHtml)
 | 
				
			||||||
 | 
					    const table = document.getElementById('result-table')
 | 
				
			||||||
 | 
					    const data = JSON.parse(json)
 | 
				
			||||||
 | 
					    for(var i = 0; i < data.length; i++) {
 | 
				
			||||||
 | 
					        let row = `<tr><td class="code">${data[i][code]}</td>
 | 
				
			||||||
 | 
					                         <td class="stops">${data[i][stops]}</td></tr>`
 | 
				
			||||||
 | 
					        table.insertAdjacentHTML("beforeend", row)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function noData() {
 | 
					async function noData() {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user