From 237a24b2d3fe03354c155c416ff7a36e79b92082 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Tue, 5 Mar 2013 20:11:37 +0100 Subject: [PATCH] rewrite of serverUrl construction * dependent on the window.location.protocol result, we construct the serverUrl * for strato ssl-proxy, we hve to insert the 1st part of the window.location.path result --- scripts/haltestellen.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/haltestellen.js b/scripts/haltestellen.js index 88a5d6a..1667366 100644 --- a/scripts/haltestellen.js +++ b/scripts/haltestellen.js @@ -65,19 +65,23 @@ function ajaxCall(dataUrl, outputElement, callback, responseType) { // wrap all in anonymous function to get out of global scope (function() { + //variable definitions var serverUrl; var target = document.getElementById("output"); - var origin = window.location.origin.indexOf("www.goodcleanfun.de"); // debug log if (DEBUG === 1) {console.log("anonymous function");} - // server url - if (origin === -1) { - serverUrl = "http://goodcleanfun.de/cgi-bin/"; + // parse actual url and parse for protocol type (http/https) + // 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 { - serverUrl = "http://www.goodcleanfun.de/cgi-bin/"; + var path = "/" + window.location.pathname.split("/")[1]; + serverUrl += path + "/cgi-bin/"; } // get the search form