From d6357250bfb7a9b0f585b40a65238fa02de86ad7 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 25 Feb 2013 18:17:23 +0100 Subject: [PATCH] remove parentheses and their content from the response data some more comments for documentation --- scripts/haltestellen.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/haltestellen.js b/scripts/haltestellen.js index 1ac94da..dcf2e47 100644 --- a/scripts/haltestellen.js +++ b/scripts/haltestellen.js @@ -78,8 +78,8 @@ function ajaxCall(dataUrl, outputElement, callback) { console.log("received data: " + data); 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); @@ -88,6 +88,7 @@ function ajaxCall(dataUrl, outputElement, callback) { var htmlOutput; var dataLength = data.length; + // generate table header htmlOutput = ""; htmlOutput += ""; htmlOutput += ""; @@ -95,17 +96,19 @@ function ajaxCall(dataUrl, outputElement, callback) { htmlOutput += ""; htmlOutput += ""; + // generate table entries for (i = 0; i < dataLength; i++) { htmlOutput += ""; - var trala = data[i].split(","); + data = data[i].split(","); console.log("part " + i + " of parsed data: " + data); for (y = 0; y < 3; y++) { - console.log("part " + y + ": " + trala[y]); - htmlOutput += ""; + console.log("part " + y + ": " + data[y]); + htmlOutput += ""; } htmlOutput += ""; } + // close table htmlOutput += "
LinieAbfahrt
" + trala[y].slice(1,-1) + "" + data[y].slice(1,-1) + "
"; // print table into web page