Browse Source

* moved the serverUrl generation into own function getCgiBinPath() in the gcf js-library gcf.js

* now we can use this function to get the serverUrl in the mail script file haltestellen.js
master
T. Meissner 12 years ago
parent
commit
cfe5aefb7e
2 changed files with 23 additions and 13 deletions
  1. +21
    -1
      scripts/gcf.js
  2. +2
    -12
      scripts/haltestellen.js

+ 21
- 1
scripts/gcf.js View File

@ -29,6 +29,26 @@ var gcf = {
},
// get the path of the cgi-bin dir with correct http(s) protocol
// for using with ajax calls (to with same origin policy)
getCgiBinPath : function () {
// 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
var serverUrl = window.location.protocol + "//" + window.location.hostname;
if (serverUrl.indexOf("https") === -1) {
serverUrl += "/cgi-bin/";
} else {
serverUrl += "/" + window.location.pathname.split("/")[1] + "/cgi-bin/";
}
return serverUrl;
},
// xmlhttp object function
getHTTPObject : function () {
@ -88,4 +108,4 @@ var gcf = {
}
}
};

+ 2
- 12
scripts/haltestellen.js View File

@ -9,7 +9,7 @@ var DEBUG;
//variable definitions
var serverUrl, // this will hold the url we call with the ajaxCall() function
var serverUrl = gcf.getCgiBinPath(), // the url of the cgi-bin folder with the scripts we call with the ajaxCall() function
target = document.getElementById("output"), // get the html area where we print out the data
searchForm = document.getElementById("search-form"), // get the search form
haltestelle; // object with methods to get and process the data
@ -17,16 +17,6 @@ var DEBUG;
// debug log
if (DEBUG === 1) {console.log("anonymous function");}
// 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 += "/" + window.location.pathname.split("/")[1] + "/cgi-bin/";
}
// haltestelle object
haltestelle = {
@ -64,7 +54,7 @@ var DEBUG;
// process of response only if it's not empty
if (data.indexOf("[]") !== -1) { // there was an empty response
haltestelle.getHaltestellen();
this.getHaltestellen();
} else {


Loading…
Cancel
Save