Browse Source

remove parentheses and their content from the response data

some more comments for documentation
master
T. Meissner 12 years ago
parent
commit
d6357250bf
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      scripts/haltestellen.js

+ 8
- 5
scripts/haltestellen.js View File

@ -78,8 +78,8 @@ function ajaxCall(dataUrl, outputElement, callback) {
console.log("received data: " + data); console.log("received data: " + data);
data = data.replace(/\],\[/gi, '#'); data = data.replace(/\],\[/gi, '#');
data = data.slice(2,-2);
data = data.split("#");
data = data.replace(/\(.+\),\[/gi, '#');
data = data.slice(2,-2).split("#");
console.log("parsed data: " + data); console.log("parsed data: " + data);
@ -88,6 +88,7 @@ function ajaxCall(dataUrl, outputElement, callback) {
var htmlOutput; var htmlOutput;
var dataLength = data.length; var dataLength = data.length;
// generate table header
htmlOutput = "<table>"; htmlOutput = "<table>";
htmlOutput += "<tr>"; htmlOutput += "<tr>";
htmlOutput += "<th>Linie</th>"; htmlOutput += "<th>Linie</th>";
@ -95,17 +96,19 @@ function ajaxCall(dataUrl, outputElement, callback) {
htmlOutput += "<th>Abfahrt</th>"; htmlOutput += "<th>Abfahrt</th>";
htmlOutput += "</tr>"; htmlOutput += "</tr>";
// generate table entries
for (i = 0; i < dataLength; i++) { for (i = 0; i < dataLength; i++) {
htmlOutput += "<tr>"; htmlOutput += "<tr>";
var trala = data[i].split(",");
data = data[i].split(",");
console.log("part " + i + " of parsed data: " + data); console.log("part " + i + " of parsed data: " + data);
for (y = 0; y < 3; y++) { for (y = 0; y < 3; y++) {
console.log("part " + y + ": " + trala[y]);
htmlOutput += "<td>" + trala[y].slice(1,-1) + "</td>";
console.log("part " + y + ": " + data[y]);
htmlOutput += "<td>" + data[y].slice(1,-1) + "</td>";
} }
htmlOutput += "</tr>"; htmlOutput += "</tr>";
} }
// close table
htmlOutput += "</table>"; htmlOutput += "</table>";
// print table into web page // print table into web page


Loading…
Cancel
Save