// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
//
// extended javascript-api-methods :
// * jsApi-extension-name / file-name : "jsApi.NumberString.flexibleConverting.light.js"
// * original download-location : "http://www.pseliger.de/jsExtendedApi/"
//
// last revision : march 2003 - code of all methods, I belief, is on its edge now;
//
function forceToNumber() {[native code]}
String.prototype.forceToNumber = forceToNumber; // - wird nur auf Strings angewandt - versucht, einen formatierten dezimalzahl-string in einen zahlenwert umzuwandeln - liefert diesen wert oder NaN zurueck;
// - to be used with Strings only - tries to convert a formatted string that represents a decimal-number into a number - returns this value or returns NaN;
//
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
//
// extended javascript-api-methods :
// * jsApi-extension-name / file-name : "jsApi.ObjectArray.clone.js"
// * original download-location : "http://www.pseliger.de/jsExtendedApi/"
//
// last revision : april 28-2003 - methods(prototype-functions), global and anonymous
// functions now get identified by the "clone"-method;
// - functions get assigned if they exist at clone-time
// and also have a valid name that is understood by
// the "window"-instance that runs all this stuff;
// - functions need to be cloned if they got constructed
// by this term "new Function(arg1,arg2, .. ,fctBody)"
// since their names remain hidden to the js-engine;
// - functions also get cloned if assigned to a variable
// by the keyword "function()" only since the variables
// name remains hidden to the js-engine in this case as
// well;
// ! object-method "getConstructorName()" was born !
//
// first revision : april 23-2003 - code is shorter now since arrays get cloned by the
// same method that already does handle objects - why:
// * "Array" just is a development/offspring of "Object";
// * arrays differ from objects only by specific arguments ("length") and methods ("push()", "pop()", "join()", ...);
// * arrays vary in their appearance - "pure": reference by integerTypeIndex - "associative": reference by stringTypeIndex (this variation is almost object-like but also features all array-specifications) - "mixed": this variation is the most complex one;
// * myArray["someName"] == myArray.someName (common knowledge - ok) - but: myArray[0] == myArray["0"] is also true (I never did think of it and never tried this so far);
// * arrays can be uniquely identified from objects by their constructors only ([array].constructor.toString() = "function Array() {[native code]}" vs. [object].constructor.toString() = "function Object() {[native code]}");
// ( now it is much more obvious why both arrays and objects return "object" when called with the operator "typeof"; )
// first public release: april 17-2003 - clones every js-object whose constructor is "array"
// or "object" regardless of its level of complexity;
//
function clone() {[native code]}
/* (01) - EN: applies to every js-object that features a constructor - ["Boolean()", "Number()", "String()", "Array()", "Function()", "RegExp()", "Date()"];
DE: ist auf jedes js-objekt mit einem konstruktor anwendbar - ["Boolean()", "Number()", "String()", "Array()", "Function()", "RegExp()", "Date()"];
(02) - EN: an optional integer-type parameter >= 1 is allowed that represents the limit of the depth an objects will be duplicated to - without or with nonsense parameters the method always returns a full clone;
DE: ein optionaler parameter vom typ "integer", welcher mindestens 1 sein muss ist erlaubt - er markiert die tiefe, bis zu welcher ein objekt dupliziert wird - ohne parameter oder bei sinnlosen angaben liefert die methode stets eine vollstaendige kopie des objekts zurueck;
(03) - EN: object-types get cloned RECURSIVELY;
DE: object-typen werden REKURSIV geklont;
(04) - EN: if functions can't be referenced they will be duplicated;
DE: falls funktionen nicht referenzierbar sind, werden diese dupliziert;
(05) - EN: primitive types simply get assigned;
DE: primitive typen werden einfach zugewiesen;
(06) - EN: leaves all prototype-properties untouched - "clone" for example already is a prototype of "Object" and therefore doesn't need to be duplicated anymore;
DE: prototyp-eigenschaften werden uebergangen - "clone" z.b. ist schon ein prototyp von "Object" und muss deshalb nicht noch einmal dupliziert werden;
[ps] - no idea how to avoid using the evil "eval"-operator;
- the problem is the unknown number of potential arguments;
- every function has limited arguments, but how to transform this fact into a solution that uses the "Function"-constructor, that is short and elegant as well and that doesn't endanger the 100%-duplication-ability of the "clone"-method ???
*/
Object.prototype.clone = clone;
function getConstructorName() {[native code]}
/* (01) - EN: returns the name of an objects constructor (like "className");
DE: liefert den namen des objekt-konstruktors zurueck (bei einem oo-klassenkonzept entspraeche dies dem klassennamen);
*/
Object.prototype.getConstructorName = getConstructorName;
//
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
//
// extended javascript-api-methods :
// * jsApi-extension-name / file-name : "jsApi.ObjectArray.getScanLog.js"
// * original download-location : "http://www.pseliger.de/jsExtendedApi/"
//
// first public release: april 2003 - scans every js-object whose constructor is "array"
// or "object" regardless of its level of complexity;
// returns a tab-formatted log; the log comments and
// visualizes the complete structure of the js-object;
// (properties: methods,arguments)
//
function arrayGetScanLog(tabulators) {[native code]}
/* (01) - EN: array-types get scanned RECURSIVELY - object-types get explored by the method "Object.getScanLog()";
DE: array-typen werden REKURSIV gescannt - object-typen werden mit der methode "Object.getScanLog()" erforscht;
(02) - EN: the bodies of function-types will not be logged;
DE: die bodies der function-typen werden nicht mitgeschrieben;
(03) - EN: information regarding primitive types simply gets logged;
DE: informationen zu primitiven typen werden einfach mitgeschrieben;
*/
function objectGetScanLog(tabulators) {[native code]}
/* (01) - EN: object-types get scanned RECURSIVELY - array-types get explored by the method "Array.getScanLog()";
DE: object-typen werden REKURSIV gescannt - array-typen werden mit der methode "Array.getScanLog()" erforscht;
(02) - EN: the bodies of function-types will not be logged;
DE: die bodies der function-typen werden nicht mitgeschrieben;
(03) - EN: information regarding primitive types simply gets logged;
DE: informationen zu primitiven typen werden einfach mitgeschrieben;
*/
Array.prototype.getScanLog = arrayGetScanLog;
Object.prototype.getScanLog = objectGetScanLog;
//
/* [ps] - EN: if you are going to use the method "getScanLog()" make sure that method "getConstructorName()" is part of the jsApi as well - right now "getConstructorName()" is provided together with the jsApi-package "jsApi.ObjectArray.clone.js" - alternatively you could enable line [40] and line [44];
- DE: bevor auf die methode "getScanLog()" zurueckgegriffen wird, sollte sichergestellt sein, dass die methode "getConstructorName()" ebenfalls bestandteil der jsApi ist - im moment wird diese methode zusammen mit dem jsApi-package "jsApi.ObjectArray.clone.js" ausgeliefert - alternativ koennen die zeilen [40] und [44] auskommentiert werden;
*/
//function getConstructorName() {var thisConstructor=((this.constructor)?(this.constructor):(null));if(thisConstructor){new RegExp("^\\s*function\\s+([a-zA-Z0-9_\\(]{2,}[^\\)])\\)","").exec(this.constructor.toString());return(RegExp.$1+")");}else{return null;}}
/* (01) - EN: returns the name of an objects constructor (like "className");
DE: liefert den namen des objekt-konstruktors zurueck (bei einem oo-klassenkonzept entspraeche dies dem klassennamen);
*/
//Object.prototype.getConstructorName = getConstructorName;
//
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// --------------------------------------------//
// CONSTRUCTOR: "Table" ---------------begin---//
// constructor : "Table" - methods: "Table.isDefaultProperty()" ---//
// subConstructor: "TableRow" - methods: "TableRow.isDefaultProperty()" ---//
// subConstructor: "TableCell" - methods: "TableCell.isDefaultProperty()" ---//
function tableIsDefaultProperty(propertyName) {
[native code]
}
function tableRowIsDefaultProperty(propertyName) {
[native code]
}
function tableCellIsDefaultProperty(propertyName) {
[native code]
}
// hilfsfunktion - vereint den quellcode aller drei "Object.isDefaultProperty()"-methoden;
function tableGetPropertyStatus(tableObject,propertyName) {
[native code]
}
// subConstructor: "TableCell" - methods: "TableCell.isDefaultProperty()" ---//
// subConstructor: "TableRow" - methods: "TableRow.isDefaultProperty()" ---//
// constructor : "Table" - methods: "Table.isDefaultProperty()" ---//
// constructor : "Table" - methods: "Table.refreshArguments()" ---//
// subConstructor: "TableRow" - methods: "TableRow.refreshArguments()" ---//
// subConstructor: "TableCell" - methods: "TableCell.refreshArguments()" ---//
function tableRefreshArguments() {
[native code]
}
function tableRowRefreshArguments() {
[native code]
}
function tableCellRefreshArguments() {
[native code]
}
// hilfsfunktion - vereint den quellcode aller drei "Object.refreshArguments()"-methoden;
function tableGetCurrentArguments(tableObject) {
[native code]
}
// subConstructor: "TableCell" - methods: "TableCell.refreshArguments()" ---//
// subConstructor: "TableRow" - methods: "TableRow.refreshArguments()" ---//
// constructor : "Table" - methods: "Table.refreshArguments()" ---//
// constructor : "Table" - methods: "Table.removeArguments()" ---//
// subConstructor: "TableRow" - methods: "TableRow.removeArguments()" ---//
// subConstructor: "TableCell" - methods: "TableCell.removeArguments()" ---//
function tableRemoveArguments() {
[native code]
}
function tableRowRemoveArguments() {
[native code]
}
function tableCellRemoveArguments() {
[native code]
}
// subConstructor: "TableCell" - methods: "TableCell.removeArguments()" ---//
// subConstructor: "TableRow" - methods: "TableRow.removeArguments()" ---//
// constructor : "Table" - methods: "Table.removeArguments()" ---//
// constructor : "Table" - methods: "Table.setArguments()" ---//
// subConstructor: "TableRow" - methods: "TableRow.setArguments()" ---//
// subConstructor: "TableCell" - methods: "TableCell.setArguments()" ---//
function tableSetArguments() {
[native code]
}
function tableRowSetArguments() {
[native code]
}
function tableCellSetArguments() {
[native code]
}
// subConstructor: "TableCell" - methods: "TableCell.setArguments()" ---//
// subConstructor: "TableRow" - methods: "TableRow.setArguments()" ---//
// constructor : "Table" - methods: "Table.setArguments()" ---//
// constructor: "Table" - method: "Table.getCode()" ---//
function tableGetCode() {
[native code]
}
// die hilfsfunktion "tableGetSpanMap" liefert die zweidimensionale boolsche "ansicht" der row- und colspan- gebiete eines jeden Table-objekts zurueck;
function tableGetSpanMap(tableObject) {
[native code]
}
// constructor: "Table" - method: "Table.getCode()" ---//
// constructor: "Table" - method: "Table.insertRows()" ---//
// constructor: "Table" - method: "Table.appendRows()" ---//
function tableInsertRows(rowsAmount,rowNumber) { // (amountOfRowsToBeInserted[mandatory], positionOfRowWhereInsertingShallTakePlace[default:alwaysFirstRow]);
[native code]
}
function tableAppendRows(rowsAmount,rowNumber) { // (amountOfRowsToBeAppended[mandatory], positionOfRowWhereAppendingShallTakePlace[default:alwaysLastRow]);
[native code]
}
// hilfsfunktion fuer die methoden "Table.insertRows()" und "Table.appendRows()";
function tableAddRows(tableObject,rowsAmount,rowNumber,addMethod) { // (tableObjectItself, amountOfRowsToBeAdded, positionOfRowWhereAdditionShallTakePlace, keywordThatIdentifiesTheMethodOfAddition:["insert" or "append"]);
[native code]
}
// constructor: "Table" - method: "Table.appendRows()" ---//
// constructor: "Table" - method: "Table.insertRows()" ---//
// constructor: "Table" - method: "Table.insertCols()" ---//
// constructor: "Table" - method: "Table.appendCols()" ---//
function tableInsertCols(colsAmount,colNumber) { // (amountOfColumnsToBeInserted[mandatory], positionOfColumnWhereInsertingShallTakePlace[default:alwaysFirstColumn]);
[native code]
}
function tableAppendCols(colsAmount,colNumber) { // (amountOfColumnsToBeAppended[mandatory], positionOfColumnWhereAppendingShallTakePlace[default:alwaysLastColumn]);
[native code]
}
// hilfsfunktion fuer die methoden "Table.insertCols()" und "Table.appendCols()";
function tableAddCols(tableObject,colsAmount,colNumber,addMethod) { // (tableObjectItself, amountOfColumnsToBeAdded, positionOfColumnWhereAdditionShallTakePlace, keywordThatIdentifiesTheMethodOfAddition:["insert" or "append"]);
[native code]
}
// constructor: "Table" - method: "Table.appendCols()" ---//
// constructor: "Table" - method: "Table.insertCols()" ---//
// constructor: "Table" - method: "Table.removeRows()" ---//
function tableRemoveRows() {
[native code]
}
// constructor: "Table" - method: "Table.removeRows()" ---//
// constructor: "Table" - method: "Table.removeCols()" ---//
function tableRemoveCols() {
[native code]
}
// constructor: "Table" - method: "Table.removeCols()" ---//
// constructor: "Table" - properties: "Table.rows[].cols[]" ---//
// CONSTRUCTOR: "TableRow" --------------begin---//
function TableRow(tableCols) {
// die 3 standardmaessigen (und finalen) argumente eines "TableRow"-objekts;
this.defaults = null; // liste alle per default definierten "TableRow"-argumente und -methoden;
this.arguments = null; // liste aller defaultmaessigen und aller noch zu vereinbarenden "TableRow"-argumente (wird vor jeder tabellen-internen berechnung ueber die methode "TableRow.refreshArguments()" auf den neuesten stand gebracht);
this.cols = null;
this.defaults = tableGetDefaultProperties(this); // siehe erklaerungen zur hilfsfunktion "tableGetDefaultProperties" und kommentar 3 zeilen hoeher;
this.cols = tableGetDefaultCols(tableCols); // siehe hilfsfunktion "tableGetDefaultCols";
}
// die 4 standardmaessigen (und finalen prototypen-)methoden eines "TableRow"-objekts;
TableRow.prototype.isDefaultProperty = tableRowIsDefaultProperty;
TableRow.prototype.refreshArguments = tableRowRefreshArguments;
TableRow.prototype.removeArguments = tableRowRemoveArguments;
TableRow.prototype.setArguments = tableRowSetArguments;
// CONSTRUCTOR: "TableRow" --------------end-----//
// CONSTRUCTOR: "TableCell" -------------begin---//
function TableCell() {
// die 3 standardmaessigen (und finalen) argumente eines "TableCell"-objekts;
this.defaults = null; // liste alle per default definierten "TableCell"-argumente und -methoden;
this.arguments = null; // liste aller defaultmaessigen und aller noch zu vereinbarenden "TableCell"-argumente (wird vor jeder tabellen-internen berechnung ueber die methode "TableCell.refreshArguments()" auf den neuesten stand gebracht);
this.value = " "; // default-zuweisung von "TableCell"-inhalten;
this.defaults = tableGetDefaultProperties(this); // siehe erklaerungen zur hilfsfunktion "tableGetDefaultProperties" und kommentar 3 zeilen hoeher;
}
// die 4 standardmaessigen (und finalen prototypen-)methoden eines "TableCell"-objekts;
TableCell.prototype.isDefaultProperty = tableCellIsDefaultProperty;
TableCell.prototype.refreshArguments = tableCellRefreshArguments;
TableCell.prototype.removeArguments = tableCellRemoveArguments;
TableCell.prototype.setArguments = tableCellSetArguments;
// CONSTRUCTOR: "TableCell" -------------end-----//
//die hilfsfunktion "tableGetDefaultRows" gibt der eigenschaft "Table.rows" ein array komplexer zeilen- und zellen-objekte zurueck;
function tableGetDefaultRows(tableRows,tableCols) {
var rowsArray = new Array();
for (var i=0;i<tableRows;i++) {
rowsArray[i] = new TableRow(tableCols); // vorbereitung fuer die initialisierung von spalten/zellen;
}
return rowsArray ;
}
//die hilfsfunktion "tableGetDefaultCols" gibt der eigenschaft "TableRow.cols" ein array von zellen-objekten zurueck;
function tableGetDefaultCols(tableCols) {
var colsArray = new Array();
for (var i=0;i<tableCols;i++) {
colsArray[i] = new TableCell(); // initialisierung von zellen-eigenschaften;
}
return colsArray;
}
// constructor: "Table" - properties: "Table.rows[].cols[]" ---//
// constructor: "Table" - "CONSTRUCTOR" --//
// constructor: "Table" - "CONSTRUCTOR" --//
function Table() {
var constructorArguments = Table.arguments;
var constructorArgumentsLength = constructorArguments.length;
var argumentName = "";
var tableRows = 1;
var tableCols = 1;
var argumentsObject = null;
// die 3 standardmaessigen (und finalen) argumente eines "Table"-objekts;
this.defaults = null; // liste alle per default definierten "Table"-argumente und -methoden;
this.arguments = null; // liste aller defaultmaessigen und aller initialisierten "Table"-argumente (wird vor jeder tabellen-internen berechnung ueber die methode "Table.refreshArguments()" auf den neuesten stand gebracht);
this.rows = null; // die hilfsfunktion "tableGetDefaultRows" weist im weiteren initialisierungsprozess diesem element ein array komplexer zeilen- und zellen-objekte zu;
this.defaults = tableGetDefaultProperties(this); // siehe erklaerungen zur hilfsfunktion "tableGetDefaultProperties" und kommentar 3 zeilen hoeher;
if ((constructorArgumentsLength == 1) && (typeof(constructorArguments[0]) == "string")) {
constructorArguments = constructorArguments.split(",");
constructorArgumentsLength = constructorArguments.length;
}
for (var i=0;i<constructorArgumentsLength;i++) {
if (constructorArguments[i].getConstructorName() == "Object()") { // because typeof(new Array()) returns "object" as well;
// akzeptiert ein objektliteral oder mehrere objektliterale als argumente des klassen-konstruktors;
argumentsObject = constructorArguments[i];
for (argumentName in argumentsObject) {
if (argumentName == "rows") {
tableRows = argumentsObject["rows"].toString().forceToNumber();
} else if (argumentName == "cols") {
tableCols = argumentsObject["cols"].toString().forceToNumber();
} else {
this[argumentName] = argumentsObject[argumentName]; // ueberschreiben einer existierenden oder initilisieren einer neuen "Table"-eigenschaft;
this[argumentName] = this[argumentName].toString();
}
}
} else if (typeof(constructorArguments[i]) == "string") {
// akzeptiert ein stringliteral oder mehrere stringliterale als argumente des klassen-konstruktors;
argumentName = ((constructorArguments[i].indexOf("=") >= 1) ? (constructorArguments[i].split("=")[0]) : (null));
if ((argumentName) && (argumentName.search(/\s/) == -1)) {
if (argumentName == "rows") {
tableRows = constructorArguments[i].split("=")[1].forceToNumber();
tableRows = ((isNaN(tableRows)) ? (1) : (tableRows));
} else if (argumentName == "cols") {
tableCols = constructorArguments[i].split("=")[1].forceToNumber();
tableCols = ((isNaN(tableCols)) ? (1) : (tableCols));
} else {
eval("this." + constructorArguments[i]); // ueberschreiben einer existierenden oder initilisieren einer neuen "Table"-eigenschaft;
this[argumentName] = this[argumentName].toString();
}
}
}
}
this.rows = tableGetDefaultRows(tableRows,tableCols); // hilfsfunktion zum generieren der zeilen- und spalten- defaults eines neuen "Table"-objekts;
}
// die 11 standardmaessigen (und finalen prototypen-)methoden eines "Table-objekts;
Table.prototype.isDefaultProperty = tableIsDefaultProperty;
Table.prototype.refreshArguments = tableRefreshArguments;
Table.prototype.removeArguments = tableRemoveArguments;
Table.prototype.setArguments = tableSetArguments;
Table.prototype.getCode = tableGetCode;
Table.prototype.insertRows = tableInsertRows;
Table.prototype.appendRows = tableAppendRows;
Table.prototype.removeRows = tableRemoveRows;
Table.prototype.insertCols = tableInsertCols;
Table.prototype.appendCols = tableAppendCols;
Table.prototype.removeCols = tableRemoveCols;
//Table.prototype.sortByCols = tableSortByCols;
//Table.prototype.sortByRows = tableSortByRows;
// die hilfsfunktion "tableGetDefaultProperties" gibt der eigenschaft "Table.defaults" ("TableRow.defaults", "TableCell.defaults")
// ein array aller standardmaessigen eigenschaften der gerade initialisierten tabelle
// zurueck - in dieser liste stehen alle methoden und argumente einer tabelle, die im
// nachhinein nicht mehr veraendert oder geloescht werden duerfen (js kennt eben kein
// abgestuftes sicherheits-/oeffentlichkeits-protokoll fuer datentypen mit schluessel-
// woertern wie z.b. "public", "privat" oder "final") - die liste wiederum kann nicht
// schon statisch vordefiniert sein, da eine js-tabelle ja immer ein objekt ist und
// bedingt durch das prototypenkonzept von javascript auch prototypen-eigenschaften
// von "Object" enthaelt welche jetzt noch nicht bekannt sind, die aber ohne weiteres
// zur laufzeit ausgelesen werden koennen - bsp.: ein benutzer verwendet den table-
// konstruktor in einer js-umgebung, in der dem "Object"-prototypen die eigenschaft
// "xyz" zugewiesen wurde ("Object.prototype.xyz = whatever;") - in dieser umgebung
// besitzt jetzt jedes table-object auch die prototypen-eigenschaft "xyz" zusaetzlich
// zu den schon bekannten nativen prototypen-methoden und tabellen-eigenen argumenten;
function tableGetDefaultProperties(rawObject) {
var defaultsArray = new Array();
var propertyName = "";
for (propertyName in rawObject) { // findet sowohl alle prototypen-eigenschaften als auch alle bis zum aufruf dieser funktion vereinbarten internen eigenschaften des uebergebenen constructor-objects "rawObject" ("Table", "TableRow", "TableCell");
defaultsArray[defaultsArray.length] = propertyName;
}
return defaultsArray;
}
// constructor: "Table" - "CONSTRUCTOR" --//
// constructor: "Table" - "CONSTRUCTOR" --//
// CONSTRUCTOR: "Table" ---------------end-----//
// --------------------------------------------//