From 3861daec30e2df258d9cf8658cd5b6564e7af5fe Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 11 Mar 2013 23:27:23 +0100 Subject: [PATCH] code beautify --- scripts/haltestellen.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/haltestellen.js b/scripts/haltestellen.js index 5158a93..18a389f 100644 --- a/scripts/haltestellen.js +++ b/scripts/haltestellen.js @@ -79,6 +79,7 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { // set the ajax server url dependent on the protocol // for strato ssl-proxy, we have to insert the 1st part of the url path serverUrl = window.location.protocol + "//" + window.location.hostname; + if (serverUrl.indexOf("https") === -1) { serverUrl += "/cgi-bin/"; } else { @@ -146,17 +147,25 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { // generate table entries for (i = 0; i < dataLength; i++) { + htmlOutput += ""; entry = data[i].split(","); + // debug log if (DEBUG === 1) {console.log("part " + i + " of parsed data: " + entry);} + for (y = 0; y < 3; y++) { + // debug log if (DEBUG === 1) {console.log("part " + y + ": " + entry[y]);} htmlOutput += "" + entry[y].slice(1, -1) + ""; + } + htmlOutput += ""; + } + // close table htmlOutput += ""; // print content into web page @@ -197,7 +206,9 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { // process of response only if it's not empty if (data.indexOf("[]") !== -1) { + htmlOutput = "

unbekannte Haltstelle, bitte erneut versuchen

"; + } else { // replace useless chars & split string into array @@ -217,6 +228,7 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { // generate table entries for (i = 0; i < dataLength; i++) { + htmlOutput += ""; entry = data[i].split(","); // debug log @@ -224,7 +236,9 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { htmlOutput += "" + entry[0].slice(1, -1) + ""; htmlOutput += ""; + } + // close table htmlOutput += ""; @@ -232,6 +246,7 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { // print content into web page target.innerHTML = htmlOutput; + } };