pis #1
							
								
								
									
										13
									
								
								js/pis.js
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								js/pis.js
									
									
									
									
									
								
							@ -27,21 +27,24 @@ async function insertData(json) {
 | 
			
		||||
    // PIS codes.  Display the code and the stops with a method of scrolling between them.
 | 
			
		||||
    // Maybe as a table or a carousel?
 | 
			
		||||
    const div = document.getElementById('result-box')
 | 
			
		||||
    const tableHtml = `<table id="result-table">
 | 
			
		||||
    let tableData = `<table id="result-table">
 | 
			
		||||
        <tr>
 | 
			
		||||
        <th class="code">Code</th>
 | 
			
		||||
        <th class="stops">Stations</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
        </table>`
 | 
			
		||||
        </tr>`
 | 
			
		||||
    div.insertAdjacentHTML("beforeend", tableHtml)
 | 
			
		||||
    const table = document.getElementById('result-table')
 | 
			
		||||
    const data = JSON.parse(json)
 | 
			
		||||
    let results = 0
 | 
			
		||||
    for(var i = 0; i < data.length; i++) {  // Break into separate function.  Need to
 | 
			
		||||
                                            // iterate over stops.
 | 
			
		||||
        let row = `<tr><td class="code">${data[i][code]}</td>
 | 
			
		||||
        tableData += `<tr><td class="code">${data[i][code]}</td>
 | 
			
		||||
            <td class="stops">${data[i][stops]}</td></tr>`
 | 
			
		||||
        table.insertAdjacentHTML("beforeend", row)
 | 
			
		||||
        results++
 | 
			
		||||
    }
 | 
			
		||||
    tableData += "</table>"
 | 
			
		||||
    table.insertAdjacentHTML("beforeend", tableData)
 | 
			
		||||
    document.getElementById('result-count').textContent = results
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function noData() {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user