home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 March / CHIP0303.ISO / exe / quick.exe / data1.cab / Dat_HTML_QS / Gemeinsam / Javascripts / DropDown.js next >
Encoding:
JavaScript  |  2002-11-27  |  10.0 KB  |  448 lines

  1. // DropDown.js
  2. // alle Java Scripte f∩┐╜ DropDown Funktionalitπ▓_
  3.  
  4. function zeigeInFormularHilfe(str) {
  5.     if (str != "") {
  6.         var txt = parent.FormularHilfeFrame.document.body.createTextRange();
  7.         var found = txt.findText(str);
  8.         if (found) {
  9.             txt.moveStart("character", -1);
  10.             txt.findText(str);
  11.             txt.select();
  12.             txt.scrollIntoView();
  13.         }
  14.     }
  15. }
  16.  
  17. function DoFunktion(Element, Funktion)
  18. {
  19.     alert("Element: " + Element + " Funktion: " + Funktion);
  20. }
  21.  
  22.  
  23. function WriteNodeText(node,Text)
  24. {
  25. //    alert("WriteNodeText");
  26.     node.text = Text;
  27. }
  28.  
  29. function WriteNodeValue(node,Value)
  30. {
  31. //    alert("WriteNodeValue");
  32.     node.nodeTypedValue = Value;
  33. }
  34.  
  35. function GetNodeAttribute(node,Typ)
  36. {
  37.     Text = "";
  38.     var attr=node.attributes;
  39.     var item=attr.getNamedItem(Typ);
  40.     if ( item != null )
  41.         Text = item.text;
  42.  
  43.     return ( Text );
  44. }
  45.  
  46. function WriteNodeAttribute(node,Typ,AttrText)
  47. {
  48. var TmpNode;
  49. var source = document.XMLDocument;
  50.  
  51.     TmpNode=source.createAttribute(Typ);
  52.     attr=node.attributes.setNamedItem(TmpNode);
  53.     attr.text=AttrText;
  54. }
  55.  
  56.  
  57. function OpenDropDown(Name)
  58. {
  59.     // zunΣchst mal alle zumachen -> bis wir die Scrollbar haben sollten wir dies so tun
  60.     CloseAllDropDowns( Name );
  61.  
  62.     if ( IsDropDownOpen(Name) == false )
  63.         DropDown(Name);
  64. }
  65.  
  66. function IsDropDownOpen(Name)
  67. {
  68. var source = document.XMLDocument;
  69.  
  70.     startnode = source.selectSingleNode("//DEFINITION/NAME");
  71.  
  72.     // suche die Node mit dem Name
  73.     FindNode = SucheNode(startnode,"//NAME",Name);
  74.  
  75.     if ( FindNode != null )
  76.         {
  77.         // in dem nπó¿sten Sibling steht der Name
  78.         SHOWNode = FindNode.nextSibling;
  79.  
  80.         if(SHOWNode.nodeTypedValue==1)
  81.             return( true );
  82.         }
  83.  
  84.     return ( false );
  85. }
  86.  
  87. function SucheNode(startnode,typ,name)
  88. {
  89.     if (startnode!=null)
  90.     {
  91.         var nodes=startnode.selectNodes(typ);
  92.         for (var n=0;n<nodes.length;n++)
  93.         {
  94.             var node=nodes.item(n);
  95.             if (node.text == name)
  96.                 return(node);
  97.         }
  98.     }
  99.     return(null);
  100. }
  101.  
  102. function SucheDropDownTyp(startnode,typ)
  103. {
  104.     if (startnode!=null)
  105.     {
  106.         var nodes=startnode.selectNodes("//DROPDOWN");
  107.         for (var n=0;n<nodes.length;n++)
  108.         {
  109.             var node=nodes.item(n);
  110.             strTypDD = GetNodeAttribute(node,"TYPE");
  111.             if (  strTypDD == typ )
  112.                 return(node);
  113.         }
  114.     }
  115.     return(null);
  116. }
  117.  
  118.  
  119. function UpdateDropDown(NodeName, Text)
  120. {
  121. var stylesheet = document.XSLDocument;
  122. var source = document.XMLDocument;
  123. var startnode=source.selectSingleNode("//DROPDOWN_LIST");
  124.  
  125.     // suche die Node mit dem Name
  126.     FindNode = SucheNode(startnode,"//ID",NodeName);
  127.  
  128.     if ( FindNode != null )
  129.         {
  130.         // in dem nπó¿sten Sibling steht der Name
  131.         WriteNodeText(FindNode.nextSibling,Text);
  132.  
  133.         // Bildschirm neu aufbauen f∩┐╜ ID="listing"
  134.         listing.innerHTML = source.documentElement.transformNode(stylesheet);
  135.         InvokeDocumentComplete();
  136.         }
  137. }
  138.  
  139. // gleiche Fkt. wie UpdateDropDown nur wird kein Refresh gemacht, d.h. die Daten nicht aktualisiert!
  140. function SetData(NodeName, Text)
  141. {
  142. var source = document.XMLDocument;
  143. var startnode=source.selectSingleNode("//DROPDOWN_LIST");
  144.  
  145.     // suche die Node mit dem Name
  146.     FindNode = SucheNode(startnode,"//ID",NodeName);
  147.  
  148.     if ( FindNode != null )
  149.         {
  150.         // in dem nπó¿sten Sibling steht der Name
  151.         WriteNodeText(FindNode.nextSibling,Text);
  152.         }
  153. }
  154.  
  155.  
  156. // gleiche Fkt. wie UpdateDropDown nur wird kein Refresh gemacht, d.h. die Daten nicht aktualisiert!
  157. function RefreshBildschirm()
  158. {
  159. var stylesheet = document.XSLDocument;
  160. var source = document.XMLDocument;
  161.  
  162.  
  163.         listing.innerHTML = source.documentElement.transformNode(stylesheet);
  164.         InvokeDocumentComplete();
  165. }
  166.  
  167.  
  168. function TransformXml(File)
  169. {
  170. var stylesheet = document.XSLDocument;
  171. var source = document.XMLDocument;
  172.  
  173.     source.load(File);
  174.  
  175.     node = source.selectSingleNode("//DEFINITION/NAME");
  176.     //        alert( node.text + " wird geladen mit: " + File );
  177.  
  178.     // Bildschirm neu aufbauen f∩┐╜ ID="listing"
  179.     listing.innerHTML = source.documentElement.transformNode(stylesheet);
  180.     InvokeDocumentComplete();
  181. }
  182.  
  183. function DropDown(Name)
  184. {
  185.     ToggleByName( Name );
  186. }
  187.  
  188. function CloseAllDropDowns( BisAuf )
  189. {
  190.     startnode = source.selectSingleNode("//DEFINITION/NAME");
  191.     if (startnode == null )
  192.         return;
  193.  
  194.     var nodes=startnode.selectNodes("//NAME");
  195.     for (var n=0;n<nodes.length;n++)
  196.         {
  197.         var node=nodes.item(n);
  198.  
  199.         Parent = node.parentNode;
  200.  
  201.         if (node.text != BisAuf )
  202.             WriteNodeAttribute(Parent,"OPEN","NEIN");
  203.         else
  204.             WriteNodeAttribute(Parent,"OPEN","JA");
  205.         }
  206.  
  207.     // Bildschirm neu aufbauen f∩┐╜ ID="listing" sprich f∩┐╜ ganze TOPICLIST
  208.     listing.innerHTML = source.documentElement.transformNode(stylesheet);
  209.     InvokeDocumentComplete();
  210. }
  211.  
  212. function ChangeValue( DDNode , attributeName )
  213. {
  214.     strValue = "";
  215.  
  216.     strAttr = GetNodeAttribute(DDNode , attributeName);
  217.     switch( strAttr )
  218.         {
  219.         case "":
  220.             strValue = "JA";
  221.             break;
  222.         case "NEIN":
  223.             strValue = "JA";
  224.             break;
  225.         case "JA":
  226.             strValue = "NEIN";
  227.             break;        
  228.         }
  229.  
  230.     
  231.     WriteNodeAttribute(DDNode, attributeName ,strValue);
  232.  
  233.     // Bildschirm neu aufbauen f∩┐╜ ID="listing" sprich f∩┐╜ ganze TOPICLIST
  234.     listing.innerHTML = source.documentElement.transformNode(stylesheet);
  235.     InvokeDocumentComplete();
  236.  
  237.     return( strValue );
  238. }
  239.  
  240. function ToggleByTypeAndCallProg(Type)
  241. {
  242.     // auf und zumachen des DropDowns!
  243.     strOpen = ToggleByType(Type);
  244.  
  245.     // jetzt noch die Applikation informieren
  246.     InfoToggleDropDown( Type, strOpen );
  247. }
  248.  
  249. function ToggleByNameAndCallProg(Name,Type)
  250. {
  251.     // auf und zumachen des DropDowns!
  252.     strOpen = ToggleByName(Name);
  253.  
  254.     // jetzt noch die Applikation informieren
  255.     InfoToggleDropDown( Type, strOpen );
  256. }
  257.  
  258. function ToggleByName(Name)
  259. {
  260.     startnode = source.selectSingleNode("//START");
  261.  
  262.     // suche die Node mit dem Name
  263.     FindNode = SucheNode(startnode,"//NAME",Name);
  264.     if ( FindNode == null )
  265.         return;
  266.  
  267.     // in dem Parent steht das DropDown
  268.     DDNode = FindNode.parentNode;
  269.  
  270.     return ( ChangeValue( DDNode , "OPEN" ) );
  271. }
  272.  
  273. function ToggleById(Id)
  274. {
  275.     startnode = source.selectSingleNode("//START");
  276.  
  277.     // suche die Node mit dem Name
  278.     FindNode = SucheNode(startnode,"//ID",Id);
  279.     if ( FindNode == null )
  280.         return;
  281.  
  282.     // in dem Parent steht das DropDown
  283.     DDNode = FindNode.parentNode;
  284.  
  285.     return ( ChangeValue( DDNode, "OPEN" ) );
  286. }
  287.  
  288. function ToggleFAQShowAll()
  289. {
  290.     try
  291.     {
  292.         startnode = source.selectSingleNode("//START");
  293.         // suche DropDown node mit Typ FAQ (Es gibt davon genau einen!)
  294.         DDNode = SucheDropDownTyp(startnode,"FAQ");
  295.         // Σndere den Wert des Attributs ShowAll
  296.         neuerWert = ChangeValue( DDNode, "SHOWALL" );
  297.         // jetzt noch die Applikation informieren
  298.         InfoToggleFAQShowAll( neuerWert );
  299.     }
  300.     catch (exception)
  301.     {
  302.         alert("Fehler in Funktion 'ToggleFAQShowAll':\n" + exception.message);
  303.     }
  304. }
  305.  
  306. function ToggleByType(Typ)
  307. {
  308.     startnode = source.selectSingleNode("//START");
  309.  
  310.     // suche die Node mit dem Name
  311.     DDNode = SucheDropDownTyp(startnode,Typ);
  312.     if ( DDNode == null )
  313.         return;
  314.  
  315.     return( ChangeValue( DDNode, "OPEN" ) );
  316. }
  317.  
  318. function ActivateDropDown(Name)
  319. {
  320. var bGefunden = 0;
  321.  
  322. var stylesheet = document.XSLDocument;
  323. var source = document.XMLDocument;
  324.  
  325.     startnode = source.selectSingleNode("//DEFINITION/NAME");
  326.  
  327.     // suche die Node mit dem Name
  328.     FindNode = SucheNode(startnode,"//NAME",Name);
  329.  
  330.     if ( FindNode != null )
  331.         {
  332.         // den Parent updaten
  333.         Parent = FindNode.parentNode;
  334.         WriteNodeAttribute(Parent,"AKTIV","JA")
  335.         }
  336.     DropDown(Name);
  337. }
  338.  
  339. function DeActivateDropDown(Name)
  340. {
  341. var bGefunden = 0;
  342.  
  343. var stylesheet = document.XSLDocument;
  344. var source = document.XMLDocument;
  345.  
  346.     startnode = source.selectSingleNode("//DEFINITION/NAME");
  347.  
  348.     // suche die Node mit dem Name
  349.     FindNode = SucheNode(startnode,"//NAME",Name);
  350.  
  351.     if ( FindNode != null )
  352.         {
  353.         // in dem nπó¿sten Sibling steht der Name
  354.         Parent = FindNode.parentNode;
  355.         WriteNodeAttribute(Parent,"AKTIV","NEIN")
  356.         }
  357.  
  358.     DropDown(Name);
  359. }
  360.  
  361. function InsertAt(id, Zeile)
  362. {
  363. var stylesheet = document.XSLDocument;
  364. var source = document.XMLDocument;
  365.  
  366.     startnode = source.selectSingleNode("//DROPDOWN_LIST");
  367.     FindNode = SucheNode(startnode,"//ID",id);
  368.     if ( FindNode == null )
  369.         return;
  370.  
  371.     var oInsertAfter = FindNode.parentNode.parentNode;
  372.     for(var i=0;i<Zeile.length; i++)
  373.         {
  374.         var node=source.createElement("ITEM");
  375.         var item = oInsertAfter.appendChild(node);
  376.         WriteNodeAttribute(item,"TYP","TEXT_KLEIN")
  377.  
  378.         node=source.createElement("NAME");
  379.         var item = item.appendChild(node);
  380.         item.text = Zeile[i];
  381.         }
  382.  
  383. //    alert( source.xml );
  384.  
  385.     // Bildschirm neu aufbauen f∩┐╜ ID="listing" sprich f∩┐╜ ganze TOPICLIST
  386.     listing.innerHTML = source.documentElement.transformNode(stylesheet);
  387.     InvokeDocumentComplete();
  388. }
  389.  
  390. function ReplaceAt(id, Zeile)
  391. {
  392. var stylesheet = document.XSLDocument;
  393. var source = document.XMLDocument;
  394.  
  395.     startnode = source.selectSingleNode("//DROPDOWN_LIST");
  396.     FindNode = SucheNode(startnode,"//ID",id);
  397.     if ( FindNode == null )
  398.         return;
  399.  
  400.     // wir l÷schen alle Nodes ab der id
  401.     var node = FindNode.parentNode.parentNode;
  402.     var oInsertAfter = FindNode.parentNode.parentNode;
  403.     remove = 0;
  404.     for ( i=0; i<node.childNodes.length; i++)
  405.         {
  406.         var n=node.childNodes.item(i);
  407.         if ( remove == true )
  408.             node.removeChild( n );
  409.  
  410.         // wir prⁿfen ob wir schon bei der entsprechenden ID sind. Denn erst ab da, darf gel÷scht werden!
  411.         if( n.hasChildNodes() == true )
  412.             {
  413.             for ( var f=0; f<n.childNodes.length; f++)
  414.                 {
  415.                 var c=n.childNodes.item(f);
  416.                 if ( c.baseName == "ID" )
  417.                     if ( c.text == id )
  418.                         remove = true;
  419.                 }
  420.             }
  421.         }
  422.  
  423. //alert(source.xml);
  424.  
  425. //alert( oInsertAfter.baseName + ": " + oInsertAfter.text);
  426.  
  427.     for(var i=0;i<Zeile.length; i++)
  428.         {
  429.         var node=source.createElement("ITEM");
  430.         var item = oInsertAfter.appendChild(node);
  431.         WriteNodeAttribute(item,"TYP","TEXT_KLEIN")
  432.  
  433.         node=source.createElement("NAME");
  434.         var item = item.appendChild(node);
  435.         item.text = Zeile[i];
  436.         }
  437.  
  438. //alert(source.xml);
  439.  
  440.     // Bildschirm neu aufbauen f∩┐╜ ID="listing" sprich f∩┐╜ ganze TOPICLIST
  441.     listing.innerHTML = source.documentElement.transformNode(stylesheet);
  442.     InvokeDocumentComplete();
  443. }
  444.  
  445. function InvokeDocumentComplete()
  446. {
  447.     listing.fireEvent("onclick");
  448. }