//============================================================================ // GeoShopClient Information JavaScript Functions // // infoGrips GmbH, Obstgartenstrasse 7, 8006 Zürich //============================================================================ // Description: // // Contains JavaScript Functions to process URL-Informations from // the GeoShop-Database //============================================================================ // // Autor: Thomas Gruetter Date: 26.06.2001 // // Revision: 1.1 // Autor: Thomas Gruetter Date: 21.08.2001 // Description: StringClean new. // //============================================================================ //============================================================================ // DocumentInitialize() // // Initializes the Document. //============================================================================ function DocumentInitialize(width,height) { var status; // Initialize status = true; if (navigator.appName != "Netscape") height = height + 200; // Set Document window.features = "width=100,height=200"; window.resizeTo(width,height); window.moveTo(50,20); window.focus(); // Return return status; } //============================================================================ // StringClean // // Clean a String for Umlaute //============================================================================ function StringClean(string) { var s; var c; var h; var i; // Initialize s = ""; // Clean i = 0; while (i < string.length) { c = string.charAt(i); if (c.charCodeAt(0) == 37) { c = String.fromCharCode(parseInt("0x" + string.substr(i+1,2))); i=i+2; } s = s + c; i++; } // Return return s; } //============================================================================ // AttributeValueGetFromString // // Extracts Attribute-Values from a String identified by an Attribute-Name // // The String must contain the Attribute-Name and Attribut-Value seperated // by a '='. Other pairs of Attribute-Name and Attribut-Value must be separated // by a '&'. // // e.g. // p=123&a=15.20 // Attribute-Name 1 = p // Attribute-Value 1 = 123 // Attribute-Name 2 = a // Attribute-Value 2 = 15.20 //============================================================================ function AttributeValueGetFromString(string, attrname, attrvaluedefault) { var status; var s; var p1; var p2; // Initialize status = true; attrvalue=""; // Read Attribute if (status == true) { s = attrname + "="; p1 = string.indexOf(s,0); if (p1 < 0) status = false; p1 = p1 + s.length; } if (status == true) { p2 = string.indexOf("&",p1); if (p2 < 0) p2 = string.length; if (p2 < p1) status = false; } if (status == true) { attrvalue = string.substring(p1,p2); } else { attrvalue = attrvaluedefault; } // Return return StringClean(attrvalue); } //============================================================================ // Attribute Value Search Write // // Extracts and writes an Attribute-Value from the active Document-Search-String // location.search identified by an Attribute-Name. // // e.g. // http://128.0.1.80:3530/data/parzelle_1.html?p=123&a=12.50 // Attribute-Name = p // Attribute-Value = 123 // // The HTML is called like // e.g. // http://128.0.1.80:3530/data/parzelle_1.html?p=123&a=12.50 // // The Function can be called at any Position in the HTML. // e.g. // AttributeValueSearchWrite("p") //============================================================================ function AttributeValueSearchWrite(attrname) { // variables var status; var attrvalue; // Initialize status = true; // Get Values attrvalue = AttributeValueGetFromString(location.search, attrname, "-"); attrvalue = attrvalue.replace(/%20/g," "); document.write(attrvalue); // Return return status; } //============================================================================ // Attribute Value File Include Write // // Extracts and a Filename and includes it. // // e.g. // http://128.0.1.80:3530/data/parzelle_3.html?f=/data/parzelle_3.dat&r=5 // Filecode = f // Filename = /data/parzelle_3.dat // // The HTML is called like // e.g. // http://128.0.1.80:3530/data/parzelle_3.html?f=/data/parzelle_3.dat&r=3 // // The Function can be called at any Position in the HTML. // e.g. // AttributeValueFileInclude("f") //============================================================================ function AttributeValueFileInclude(fileattrname) { // variables var status; var filename; // Initialize status = true; attrvalue = "-"; // Get File filename = AttributeValueGetFromString(location.search, fileattrname, "-"); filename = "http://" + document.domain + filename; document.write(""); // Return return status; } //============================================================================ // Attribute Value File Write // // Extracts and writes an Attribute-Value from a File identified by the Filename an // the Attribute-Name. // // The File with the data must be included first with AttributeValueFileInclude // // e.g. // http://128.0.1.80:3530/data/parzelle_2.html?f=/data/parzelle_2.dat // Filecode = f // Filename = /data/parzelle_2.dat // // The Data in the File must be in the JavaScript-Arrays AttrName and AttrValue // e.g. // var AttrName = new Array(); // var AttrValue = new Array(); // AttrName[1]="Parzelle";AttrValue[1]="100"; // AttrName[2]="Flaeche";AttrValue[2]="12.50"; // // The HTML is called like // e.g. // http://128.0.1.80:3530/data/parzelle_2.html?f=/data/parzelle_2.dat // // The Function can be called at any Position in the HTML. // e.g. // AttributeValueFileWrite("Parzelle") //============================================================================ function AttributeValueFileWrite(attrname) { // variables var status; var attrvalue; var i; // Initialize status = true; attrvalue = "-"; // Get Attribute Value for (i=0;i