Menus HTML / javaScript arborescents

Partagez votre expérience de PureBasic avec les autres utilisateurs.
fweil
Messages : 505
Inscription : dim. 16/mai/2004 17:50
Localisation : Bayonne (64)
Contact :

Menus HTML / javaScript arborescents

Message par fweil »

Sais pas si le titre est assez clair !

Voila un exemple de code ré-utilisable pour génerer des pages HTML/ JS à partir d'une liste en utilisant PureBasic comme générateur de pages ///

Amusez-vous avec et revenez pour toutes questions ou commentaires ...

Code : Tout sélectionner

CR.s = Chr(13)
LF.s = Chr(10)
TAB.s = Chr(9)
QC.s = Chr(34)
EOL.s = CR + LF

HTML_FrameSet_FileName.s = "FrameSet.htm"
HTML_Left_FileName.s = "Left.htm"
HTML_Middle_FileName.s = "Arbre.htm"
HTML_CSS_FileName.s = "Arbre.css"
HTML_Right_FileName.s = "Right.htm"
JSFileName.s = "Arbre.js"

Structure Item
  ID.l
  Parent.l
  Label.s
  Link.s
EndStructure

NewList Items.Item()

;
; Descritptor tree example file design
;
If FileSize("Arbre.txt") = -1
    If CreateFile(0, "Arbre.txt")
        WriteStringN("PureBasic" + Chr(9) + "#")
        WriteStringN("PureBasic" + Chr(9) + "PureBasic home" + Chr(9) + "http://www.purebasic.com/")
        WriteStringN("PureBasic" + Chr(9) + "PureBasic updates" + Chr(9) + "http://www.purebasic.com/update/")
        WriteStringN("PureBasic" + Chr(9) + "PureBasic Forum EN" + Chr(9) + "http://forums.purebasic.com/")
        WriteStringN("PureBasic" + Chr(9) + "PureBasic Forum FR" + Chr(9) + "http://forums.purebasic.fr/")
        WriteStringN("PureBasic" + Chr(9) + "PureBasic Associated links" + Chr(9) + "#")
        WriteStringN("PureBasic Associated links" + Chr(9) + "PureArea Net EN" + Chr(9) + "http://www.purearea.net/pb/english/index.htm")
        WriteStringN("PureBasic Associated links" + Chr(9) + "CodeArchiv" + Chr(9) + "http://www.purearea.net/pb/CodeArchiv/CodeArchiv.html")
        WriteStringN("Microsoft" + Chr(9) + "#")
        WriteStringN("Microsoft" + Chr(9) + "Microsoft.com" + Chr(9) + "http://www.microsoft.com/")
        WriteStringN("Microsoft" + Chr(9) + "MSDN" + Chr(9) + "http://msdn.microsoft.com/")
        WriteStringN("Search" + Chr(9) + "#")
        WriteStringN("Search" + Chr(9) + "Google" + Chr(9) + "http://www.google.com/")
        WriteStringN("Search" + Chr(9) + "Alltheweb" + Chr(9) + "http://www.alltheweb.com/")
        WriteStringN("Search" + Chr(9) + "Yahoo.com" + Chr(9) + "http://www.yahoo.com/")
        WriteStringN("Search" + Chr(9) + "Yahoo.fr" + Chr(9) + "http://www.yahoo.fr/")
        WriteStringN("Search" + Chr(9) + "Voila" + Chr(9) + "http://www.voila.fr/")
        WriteStringN("Search" + Chr(9) + "AltaVista" + Chr(9) + "http://www.altavista.com/")
        WriteStringN("Search" + Chr(9) + "Kartoo" + Chr(9) + "http://www.kartoo.com/")
        CloseFile(0)
    EndIf
EndIf

i = 0
If ReadFile(0, "Arbre.txt")
    Repeat
      i + 1
      LastElement(Items())
      AddElement(Items())
      a$ = ReadString()
      If Right(a$, 1) = "#" And StringField(a$, 2, Chr(9)) = "#"
          Items()\ID = i
          Items()\Label = StringField(a$, 1, Chr(9))
          Items()\Parent = 0
        ElseIf Right(a$, 1) = "#" And StringField(a$, 3, Chr(9)) = "#"
          Items()\ID = i
          Items()\Label = StringField(a$, 2, Chr(9))
          OldListIndex = ListIndex(Items())
          ResetList(Items())
          While NextElement(Items())
            If Items()\Label = StringField(a$, 1, Chr(9))
                Parent = ListIndex(Items()) + 1
                Break
            EndIf
          Wend
          LastElement(Items())
          Items()\Parent = Parent
        Else
          Items()\ID = i
          Items()\Label = StringField(a$, 2, Chr(9))
          Items()\Link = StringField(a$, 3, Chr(9))
          OldListIndex = ListIndex(Items())
          ResetList(Items())
          While NextElement(Items())
            If Items()\Label = StringField(a$, 1, Chr(9))
                Parent = ListIndex(Items()) + 1
                Break
            EndIf
          Wend
          LastElement(Items())
          Items()\Parent = Parent
      EndIf
    Until Eof(0)
    CloseFile(0)
EndIf

;
; HTML design
;
HTMLCode.s = ""
HTMLCode + "<html>" + EOL
HTMLCode + "  <head>" + EOL
HTMLCode + "    <title>Arbre</title>" + EOL
HTMLCode + "    <meta http-equiv=" + Chr(34) + "Content-Type" + Chr(34) + " content=" + Chr(34) + "text/html; charset=iso-8859-1" + Chr(34) + "> " + EOL
HTMLCode + "    <link rel=" + Chr(34) + "StyleSheet" + Chr(34) + " href=" + Chr(34) + HTML_CSS_FileName + Chr(34) + " type=" + Chr(34) + "text/css" + Chr(34) + ">" + EOL
HTMLCode + "    <script type=" + Chr(34) + "text/javascript" + Chr(34) + " src=" + Chr(34) + JSFileName + Chr(34) + "></script>" + EOL
HTMLCode + "    <script type=" + Chr(34) + "text/javascript" + Chr(34) + ">" + EOL
HTMLCode + "      <!--" + EOL
HTMLCode + "      var Arbre = new Array;" + EOL
HTMLCode + "      // nodeId | parentNodeId | nodeName | nodeUrl" + EOL
ResetList(Items())
i = 0
While NextElement(Items())
  If Items()\Link <> ""
      String.s = Str(Items()\ID) + "|" + Str(Items()\Parent) + "|" + Items()\Label + "|" + Items()\Link
      HTMLCode + "      Arbre[" + Str(i) + "]  = " + Chr(34) + String + Chr(34) + ";" + EOL
    Else
      String.s = Str(Items()\ID) + "|" + Str(Items()\Parent) + "|" + Items()\Label
      HTMLCode + "      Arbre[" + Str(i) + "]  = " + Chr(34) + String + Chr(34) + ";" + EOL
  EndIf
  Debug String
  i + 1
Wend
HTMLCode + "      //-->" + EOL
HTMLCode + "    </script>" + EOL
HTMLCode + "  </head>" + EOL
HTMLCode + "  <body>" + EOL
HTMLCode + "    <DIV ID=" + Chr(34) + "middleobjects" + Chr(34) + " STYLE=" + Chr(34) + "position:absolute;left:0;top:0" + Chr(34) + ">" + EOL
HTMLCode + "      <TABLE CELLPADDING=0 CELLSPACING=2 BORDER=0 WIDTH=100%>" + EOL
HTMLCode + "        <TR>" + EOL
HTMLCode + "          <TD>" + EOL
HTMLCode + "            <A HREF=" + Chr(34) + "#" + Chr(34) + " onMouseDown=" + Chr(34) + "upb=true" + Chr(34) + " onMouseUp=" + Chr(34) + "upb=false" + Chr(34) + " onClick=" + Chr(34) + "return(false)" + Chr(34) + ">" + EOL
HTMLCode + "              <IMG SRC=" + Chr(34) + "images/up.gif" + Chr(34) + " BORDER=0 WIDTH=30 HEIGHT=30 ALIGN=" + Chr(34) + "RIGHT" + Chr(34) + ">" + EOL
HTMLCode + "            </A>" + EOL
HTMLCode + "          </TD>" + EOL
HTMLCode + "        </TR>" + EOL
HTMLCode + "        <TR>" + EOL
HTMLCode + "          <TD>" + EOL
HTMLCode + "            <A HREF=" + Chr(34) + "#" + Chr(34) + " onMouseDown=" + Chr(34) + "upa=true" + Chr(34) + " onMouseUp=" + Chr(34) + "upa=false" + Chr(34) + " onClick=" + Chr(34) + "return(false)" + Chr(34) + ">" + EOL
HTMLCode + "              <IMG SRC=" + Chr(34) + "images/down.gif" + Chr(34) + " BORDER=0 WIDTH=30 HEIGHT=30 ALIGN=" + Chr(34) + "RIGHT" + Chr(34) + ">" + EOL
HTMLCode + "            </A>" + EOL
HTMLCode + "          </TD>" + EOL
HTMLCode + "        </TR>" + EOL
HTMLCode + "      </TABLE>" + EOL
HTMLCode + "    </DIV>" + EOL
HTMLCode + "    <SCRIPT LANGUAGE=" + Chr(34) + "JavaScript1.2" + Chr(34) + ">" + EOL
HTMLCode + "      /*" + EOL
HTMLCode + "      FWeil  : 20050606 - www.francoisweil.com mailto:fweil@internext.fr" + EOL
HTMLCode + "      */" + EOL
HTMLCode + "      function placeObj(py)" + EOL
HTMLCode + "      {" + EOL
HTMLCode + "        document.getElementById(" + Chr(34) + "middleobjects" + Chr(34) + ").style.top=py;" + EOL
HTMLCode + "      }" + EOL
HTMLCode + "      upa = false" + EOL
HTMLCode + "      upb = false" + EOL
HTMLCode + "      n = 50" + EOL
HTMLCode + "      function DefilerHaut()" + EOL
HTMLCode + "      {" + EOL
HTMLCode + "        if(upa == true)" + EOL
HTMLCode + "          this.scroll(1,offsety+n);" + EOL
HTMLCode + "        t2 = setTimeout(" + Chr(34) + "DefilerHaut()" + Chr(34) + ",50);" + EOL
HTMLCode + "      }" + EOL
HTMLCode + "      function DefilerBas()" + EOL
HTMLCode + "      {" + EOL
HTMLCode + "        if(upb==true)" + EOL
HTMLCode + "          this.scroll(1,offsety-n);" + EOL
HTMLCode + "        t3 = setTimeout(" + Chr(34) + "DefilerBas()" + Chr(34) + ",50);" + EOL
HTMLCode + "      }" + EOL
HTMLCode + "      function voirMenu()" + EOL
HTMLCode + "      {" + EOL
HTMLCode + "        if (navigator.appName==" + Chr(34) + "Microsoft Internet Explorer" + Chr(34) + ")" + EOL
HTMLCode + "        {" + EOL
HTMLCode + "          offsety = document.body.scrollTop;" + EOL
HTMLCode + "        }" + EOL
HTMLCode + "        else" + EOL
HTMLCode + "        {" + EOL
HTMLCode + "          offsety = window.pageYOffset;" + EOL
HTMLCode + "        }" + EOL
HTMLCode + "        placeObj(offsety);" + EOL
HTMLCode + "        t = setTimeout(" + Chr(34) + "voirMenu()" + Chr(34) + ",1);" + EOL
HTMLCode + "      }" + EOL
HTMLCode + "      voirMenu();DefilerHaut();DefilerBas();" + EOL
HTMLCode + "    </SCRIPT>" + EOL
HTMLCode + "    <b>" + EOL
HTMLCode + "      Arbre de navigation" + EOL
HTMLCode + "    </b>" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <b>" + EOL
HTMLCode + "      Exemple :" + EOL
HTMLCode + "    </b>" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <div id=" + Chr(34) + "arbre" + Chr(34) + ">" + EOL
HTMLCode + "      <script type=" + Chr(34) + "text/javascript" + Chr(34) + ">" + EOL
HTMLCode + "        <!--" + EOL
HTMLCode + "        createTree(Arbre);" + EOL
HTMLCode + "        //-->" + EOL
HTMLCode + "      </script>" + EOL
HTMLCode + "    </div>" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <br />" + EOL
HTMLCode + "    <a href=" + Chr(34) + "mailto:fweil@internext.fr" + Chr(34) + ">Francois Weil</a>" + EOL
HTMLCode + "  </body>" + EOL
HTMLCode + "</html>" + EOL
Debug Len(HTMLCode)

If CreateFile(0, HTML_Middle_FileName)
    WriteString(HTMLCode)
    CloseFile(0)
EndIf

;
; JavaScript file
;
JavaScriptCode.s = ""
JavaScriptCode + "/**************************************************************************" + EOL
JavaScriptCode + "FWeil : 20040606 - www.francoisweil.com mailto:fweil@internext.fr" + EOL
JavaScriptCode + "Arbre JavaScript" + EOL
JavaScriptCode + "**************************************************************************/" + EOL
JavaScriptCode + "// Tableau des noeuds et images" + EOL
JavaScriptCode + "var nodes = new Array();" + EOL
JavaScriptCode + "var openNodes = new Array();" + EOL
JavaScriptCode + "var images = new Array(6);" + EOL
JavaScriptCode + "" + EOL
JavaScriptCode + "// Préchargement des images utilisées dans l'arbre" + EOL
JavaScriptCode + "function preloadimages()" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  images[0] = new Image();" + EOL
JavaScriptCode + "  images[0].src = " + Chr(34) + "images/plus.gif" + Chr(34) + ";" + EOL
JavaScriptCode + "  images[1] = new Image();" + EOL
JavaScriptCode + "  images[1].src = " + Chr(34) + "images/plusbottom.gif" + Chr(34) + ";" + EOL
JavaScriptCode + "  images[2] = new Image();" + EOL
JavaScriptCode + "  images[2].src = " + Chr(34) + "images/minus.gif" + Chr(34) + ";" + EOL
JavaScriptCode + "  images[3] = new Image();" + EOL
JavaScriptCode + "  images[3].src = " + Chr(34) + "images/minusbottom.gif" + Chr(34) + ";" + EOL
JavaScriptCode + "  images[4] = new Image();" + EOL
JavaScriptCode + "  images[4].src = " + Chr(34) + "images/folder.gif" + Chr(34) + ";" + EOL
JavaScriptCode + "  images[5] = new Image();" + EOL
JavaScriptCode + "  images[5].src = " + Chr(34) + "images/folderopen.gif" + Chr(34) + ";" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Création de l'arbre" + EOL
JavaScriptCode + "function createTree(arrName, startNode, openNode)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  nodes = arrName;" + EOL
JavaScriptCode + "  if (nodes.length > 0)" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    preloadimages();" + EOL
JavaScriptCode + "    if (startNode == null) startNode = 0;" + EOL
JavaScriptCode + "    if (openNode != 0 || openNode != null) setOpenNodes(openNode);" + EOL
JavaScriptCode + "    if (startNode !=0)" + EOL
JavaScriptCode + "    {" + EOL
JavaScriptCode + "      var nodeValues = nodes[getArrayId(startNode)].split(" + Chr(34) + "|" + Chr(34) + ");" + EOL
JavaScriptCode + "      document.write(" + Chr(34) + "<a href=\" + Chr(34) + "" + Chr(34) + " + nodeValues[3] + " + Chr(34) + "\" + Chr(34) + " onmouseover=\" + Chr(34) + "window.status='" + Chr(34) + " + nodeValues[2] + " + Chr(34) + "';return true;\" + Chr(34) + " onmouseout=\" + Chr(34) + "window.status=' ';return true;\" + Chr(34) + "><img border=\" + Chr(34) + "0\" + Chr(34) + " src=\" + Chr(34) + "images/folderopen.gif\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "\" + Chr(34) + " />" + Chr(34) + " + nodeValues[2] + " + Chr(34) + "</a><br />" + Chr(34) + ");" + EOL
JavaScriptCode + "    }" + EOL
JavaScriptCode + "    else document.write(" + Chr(34) + "<img src=\" + Chr(34) + "images/base.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "\" + Chr(34) + " />Website<br />" + Chr(34) + ");" + EOL
JavaScriptCode + "      var recursedNodes = new Array();" + EOL
JavaScriptCode + "      addNode(startNode, recursedNodes);" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Renvoie la position d'un noeud dans l'arbre" + EOL
JavaScriptCode + "function getArrayId(node)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  for (i=0; i<nodes.length; i++)" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    var nodeValues = nodes[i].split(" + Chr(34) + "|" + Chr(34) + ");" + EOL
JavaScriptCode + "    if (nodeValues[0]==node) return i;" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Chargement des noeuds à ouvrir" + EOL
JavaScriptCode + "function setOpenNodes(openNode)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  for (i=0; i<nodes.length; i++)" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    var nodeValues = nodes[i].split(" + Chr(34) + "|" + Chr(34) + ");" + EOL
JavaScriptCode + "    if (nodeValues[0]==openNode)" + EOL
JavaScriptCode + "    {" + EOL
JavaScriptCode + "      openNodes.push(nodeValues[0]);" + EOL
JavaScriptCode + "      setOpenNodes(nodeValues[1]);" + EOL
JavaScriptCode + "    }" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Vérifie si un noeud est ouvert" + EOL
JavaScriptCode + "function isNodeOpen(node)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  for (i=0; i<openNodes.length; i++)" + EOL
JavaScriptCode + "    if (openNodes[i]==node) return true;" + EOL
JavaScriptCode + "  return false;" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Vérifie si un noeud a des enfants" + EOL
JavaScriptCode + "function hasChildNode(parentNode)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  for (i=0; i< nodes.length; i++)" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    var nodeValues = nodes[i].split(" + Chr(34) + "|" + Chr(34) + ");" + EOL
JavaScriptCode + "    if (nodeValues[1] == parentNode) return true;" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "  return false;" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Vérifie si un noeud est le dernier enfant" + EOL
JavaScriptCode + "function lastSibling (node, parentNode)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  var lastChild = 0;" + EOL
JavaScriptCode + "  for (i=0; i< nodes.length; i++)" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    var nodeValues = nodes[i].split(" + Chr(34) + "|" + Chr(34) + ");" + EOL
JavaScriptCode + "    if (nodeValues[1] == parentNode)" + EOL
JavaScriptCode + "      lastChild = nodeValues[0];" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "  if (lastChild==node) return true;" + EOL
JavaScriptCode + "    return false;" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Ajoute un noeud à l'arbre" + EOL
JavaScriptCode + "function addNode(parentNode, recursedNodes)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  for (var i = 0; i < nodes.length; i++)" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    var nodeValues = nodes[i].split(" + Chr(34) + "|" + Chr(34) + ");" + EOL
JavaScriptCode + "    if (nodeValues[1] == parentNode)" + EOL
JavaScriptCode + "    {" + EOL
JavaScriptCode + "      var ls = lastSibling(nodeValues[0], nodeValues[1]);" + EOL
JavaScriptCode + "      var hcn = hasChildNode(nodeValues[0]);" + EOL
JavaScriptCode + "      var ino = isNodeOpen(nodeValues[0]);" + EOL
JavaScriptCode + "      // Edite une ligne et une image vide" + EOL
JavaScriptCode + "      for (g=0; g<recursedNodes.length; g++)" + EOL
JavaScriptCode + "      {" + EOL
JavaScriptCode + "        if (recursedNodes[g] == 1) document.write(" + Chr(34) + "<img src=\" + Chr(34) + "images/line.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "\" + Chr(34) + " />" + Chr(34) + ");" + EOL
JavaScriptCode + "        else  document.write(" + Chr(34) + "<img src=\" + Chr(34) + "images/empty.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "\" + Chr(34) + " />" + Chr(34) + ");" + EOL
JavaScriptCode + "      }" + EOL
JavaScriptCode + "      // ajoute la ligne et l'image vide à la liste" + EOL
JavaScriptCode + "      if (ls) recursedNodes.push(0);" + EOL
JavaScriptCode + "      else recursedNodes.push(1);" + EOL
JavaScriptCode + "      // Edite les images jointes" + EOL
JavaScriptCode + "      if (hcn)" + EOL
JavaScriptCode + "      {" + EOL
JavaScriptCode + "        if (ls)" + EOL
JavaScriptCode + "        {" + EOL
JavaScriptCode + "          document.write(" + Chr(34) + "<a href=\" + Chr(34) + "javascript: oc(" + Chr(34) + " + nodeValues[0] + " + Chr(34) + ", 1);\" + Chr(34) + "><img id=\" + Chr(34) + "join" + Chr(34) + " + nodeValues[0] + " + Chr(34) + "\" + Chr(34) + " src=\" + Chr(34) + "images/" + Chr(34) + ");" + EOL
JavaScriptCode + "          if (ino) document.write(" + Chr(34) + "minus" + Chr(34) + ");" + EOL
JavaScriptCode + "          else document.write(" + Chr(34) + "plus" + Chr(34) + ");" + EOL
JavaScriptCode + "          document.write(" + Chr(34) + "bottom.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "Open/Close node\" + Chr(34) + " /></a>" + Chr(34) + ");" + EOL
JavaScriptCode + "        }" + EOL
JavaScriptCode + "        else" + EOL
JavaScriptCode + "        {" + EOL
JavaScriptCode + "          document.write(" + Chr(34) + "<a href=\" + Chr(34) + "javascript: oc(" + Chr(34) + " + nodeValues[0] + " + Chr(34) + ", 0);\" + Chr(34) + "><img id=\" + Chr(34) + "join" + Chr(34) + " + nodeValues[0] + " + Chr(34) + "\" + Chr(34) + " src=\" + Chr(34) + "images/" + Chr(34) + ");" + EOL
JavaScriptCode + "          if (ino) document.write(" + Chr(34) + "minus" + Chr(34) + ");" + EOL
JavaScriptCode + "          else document.write(" + Chr(34) + "plus" + Chr(34) + ");" + EOL
JavaScriptCode + "            document.write(" + Chr(34) + ".gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "Open/Close node\" + Chr(34) + " /></a>" + Chr(34) + ");" + EOL
JavaScriptCode + "        }" + EOL
JavaScriptCode + "      }" + EOL
JavaScriptCode + "      else" + EOL
JavaScriptCode + "      {" + EOL
JavaScriptCode + "        if (ls) document.write(" + Chr(34) + "<img src=\" + Chr(34) + "images/join.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "\" + Chr(34) + " />" + Chr(34) + ");" + EOL
JavaScriptCode + "        else document.write(" + Chr(34) + "<img src=\" + Chr(34) + "images/joinbottom.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "\" + Chr(34) + " />" + Chr(34) + ");" + EOL
JavaScriptCode + "      }" + EOL
JavaScriptCode + "      // Création du lien" + EOL
JavaScriptCode + "      document.write(" + Chr(34) + "<a href=\" + Chr(34) + "" + Chr(34) + " + nodeValues[3] + " + Chr(34) + "\" + Chr(34) + " target=\" + Chr(34) + "mainFrame\" + Chr(34) + " onmouseover=\" + Chr(34) + "window.status='" + Chr(34) + " + nodeValues[2] + " + Chr(34) + "';return true;\" + Chr(34) + " onmouseout=\" + Chr(34) + "window.status=' ';return true;\" + Chr(34) + ">" + Chr(34) + ");" + EOL
JavaScriptCode + "      // Edite les images dossier et page" + EOL
JavaScriptCode + "      if (hcn)" + EOL
JavaScriptCode + "      {" + EOL
JavaScriptCode + "        document.write(" + Chr(34) + "<img id=\" + Chr(34) + "icon" + Chr(34) + " + nodeValues[0] + " + Chr(34) + "\" + Chr(34) + " src=\" + Chr(34) + "images/folder" + Chr(34) + ")" + EOL
JavaScriptCode + "        if (ino) document.write(" + Chr(34) + "open" + Chr(34) + ");" + EOL
JavaScriptCode + "          document.write(" + Chr(34) + ".gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "Folder\" + Chr(34) + " />" + Chr(34) + ");" + EOL
JavaScriptCode + "      }" + EOL
JavaScriptCode + "      else document.write(" + Chr(34) + "<img id=\" + Chr(34) + "icon" + Chr(34) + " + nodeValues[0] + " + Chr(34) + "\" + Chr(34) + " src=\" + Chr(34) + "images/page.gif\" + Chr(34) + " border=\" + Chr(34) + "0\" + Chr(34) + " align=\" + Chr(34) + "absbottom\" + Chr(34) + " alt=\" + Chr(34) + "Page\" + Chr(34) + " />" + Chr(34) + ");" + EOL
JavaScriptCode + "      // Edite le nom du noeud" + EOL
JavaScriptCode + "      document.write(nodeValues[2]);" + EOL
JavaScriptCode + "      // Fin du lien" + EOL
JavaScriptCode + "      document.write(" + Chr(34) + "</a><br />" + Chr(34) + ");" + EOL
JavaScriptCode + "      // Si le noeud a un enfant edite en profondeur" + EOL
JavaScriptCode + "      if (hcn)" + EOL
JavaScriptCode + "      {" + EOL
JavaScriptCode + "        document.write(" + Chr(34) + "<div id=\" + Chr(34) + "div" + Chr(34) + " + nodeValues[0] + " + Chr(34) + "\" + Chr(34) + "" + Chr(34) + ");" + EOL
JavaScriptCode + "        if (!ino) document.write(" + Chr(34) + " style=\" + Chr(34) + "display: none;\" + Chr(34) + "" + Chr(34) + ");" + EOL
JavaScriptCode + "          document.write(" + Chr(34) + ">" + Chr(34) + ");" + EOL
JavaScriptCode + "          addNode(nodeValues[0], recursedNodes);" + EOL
JavaScriptCode + "          document.write(" + Chr(34) + "</div>" + Chr(34) + ");" + EOL
JavaScriptCode + "      }" + EOL
JavaScriptCode + "      // Efface la dernièer ligne ou l'image vide" + EOL
JavaScriptCode + "      recursedNodes.pop();" + EOL
JavaScriptCode + "    }" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Ouvre ou ferme un noeud" + EOL
JavaScriptCode + "function oc(node, bottom)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  var theDiv = document.getElementById(" + Chr(34) + "div" + Chr(34) + " + node);" + EOL
JavaScriptCode + "  var theJoin = document.getElementById(" + Chr(34) + "join" + Chr(34) + " + node);" + EOL
JavaScriptCode + "  var theIcon = document.getElementById(" + Chr(34) + "icon" + Chr(34) + " + node);" + EOL
JavaScriptCode + "  if (theDiv.style.display == 'none')" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    if (bottom==1) theJoin.src = images[3].src;" + EOL
JavaScriptCode + "    else theJoin.src = images[2].src;" + EOL
JavaScriptCode + "      theIcon.src = images[5].src;" + EOL
JavaScriptCode + "      theDiv.style.display = '';" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "  else" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    if (bottom==1) theJoin.src = images[1].src;" + EOL
JavaScriptCode + "    else theJoin.src = images[0].src;" + EOL
JavaScriptCode + "      theIcon.src = images[4].src;" + EOL
JavaScriptCode + "      theDiv.style.display = 'none';" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "// Push / pop non valable pour IE (Voir opur Netscape!)" + EOL
JavaScriptCode + "if(!Array.prototype.push)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  function array_push()" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    for(var i=0;i<arguments.length;i++)" + EOL
JavaScriptCode + "      this[this.length]=arguments[i];" + EOL
JavaScriptCode + "      return this.length;" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "  Array.prototype.push = array_push;" + EOL
JavaScriptCode + "}" + EOL
JavaScriptCode + "if(!Array.prototype.pop)" + EOL
JavaScriptCode + "{" + EOL
JavaScriptCode + "  function array_pop()" + EOL
JavaScriptCode + "  {" + EOL
JavaScriptCode + "    lastElement = this[this.length-1];" + EOL
JavaScriptCode + "    this.length = Math.max(this.length-1,0);" + EOL
JavaScriptCode + "    return lastElement;" + EOL
JavaScriptCode + "  }" + EOL
JavaScriptCode + "  Array.prototype.pop = array_pop;" + EOL
JavaScriptCode + "}" + EOL
Debug Len(JavaScriptCode)

If CreateFile(0, JSFileName)
    WriteString(JavaScriptCode)
    CloseFile(0)
EndIf

HTMLCode.s = ""
HTMLCode + "<!DOCTYPE HTML PUBLIC " + Chr(34) + "-//W3C//DTD HTML 4.01 Frameset//EN" + Chr(34) + " " + Chr(34) + "http://www.w3.org/TR/html4/frameset.dtd" + Chr(34) + ">" + EOL
HTMLCode + "<html>" + EOL
HTMLCode + "<head>" + EOL
HTMLCode + "<title>Untitled Document</title>" + EOL
HTMLCode + "<meta http-equiv=" + Chr(34) + "Content-Type" + Chr(34) + " content=" + Chr(34) + "text/html; charset=iso-8859-1" + Chr(34) + ">" + EOL
HTMLCode + "</head>" + EOL
HTMLCode + "" + EOL
HTMLCode + "<frameset frameborder=" + Chr(34) + "0" + Chr(34) + " border=" + Chr(34) + "0" + Chr(34) + " cols=" + Chr(34) + "20%,60%, 20%" + Chr(34) + ">" + EOL
HTMLCode + "  <frame scrolling=" + Chr(34) + "NO" + Chr(34) + " src=" + Chr(34) + HTML_Left_FileName + Chr(34) + ">" + EOL
HTMLCode + "  <frame scrolling=" + Chr(34) + "NO" + Chr(34) + " src=" + Chr(34) + HTML_Middle_FileName + Chr(34) + ">" + EOL
HTMLCode + "  <frame scrolling=" + Chr(34) + "NO" + Chr(34) + " src=" + Chr(34) + HTML_Right_FileName + Chr(34) + ">" + EOL
HTMLCode + "</frameset>" + EOL
HTMLCode + "<noframes><body>" + EOL
HTMLCode + "" + EOL
HTMLCode + "</body></noframes>" + EOL
HTMLCode + "</html>" + EOL

If CreateFile(0, HTML_FrameSet_FileName)
    WriteString(HTMLCode)
    CloseFile(0)
EndIf

HTMLCode.s = ""
HTMLCode + "<!DOCTYPE HTML PUBLIC " + Chr(34) + "-//W3C//DTD HTML 4.01 Transitional//EN" + Chr(34) + ">" + EOL
HTMLCode + "<html>" + EOL
HTMLCode + "<head>" + EOL
HTMLCode + "<title>Untitled Document</title>" + EOL
HTMLCode + "<meta http-equiv=" + Chr(34) + "Content-Type" + Chr(34) + " content=" + Chr(34) + "text/html; charset=iso-8859-1" + Chr(34) + ">" + EOL
HTMLCode + "</head>" + EOL
HTMLCode + "" + EOL
HTMLCode + "<body>" + EOL
HTMLCode + " Left Frame<BR>" + EOL
HTMLCode + " Hello I am the left frame<BR>" + EOL
HTMLCode + " And do you know what ?<BR>" + EOL
HTMLCode + " I am not scrollable ...<BR>" + EOL
HTMLCode + " That's it !<BR>" + EOL
HTMLCode + " azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty" + EOL
HTMLCode + "</body>" + EOL
HTMLCode + "</html>" + EOL

If CreateFile(0, HTML_Left_FileName)
    WriteString(HTMLCode)
    CloseFile(0)
EndIf

HTMLCode.s = ""
HTMLCode + "<!DOCTYPE HTML PUBLIC " + Chr(34) + "-//W3C//DTD HTML 4.01 Transitional//EN" + Chr(34) + ">" + EOL
HTMLCode + "<html>" + EOL
HTMLCode + "<head>" + EOL
HTMLCode + "<title>Untitled Document</title>" + EOL
HTMLCode + "<meta http-equiv=" + Chr(34) + "Content-Type" + Chr(34) + " content=" + Chr(34) + "text/html; charset=iso-8859-1" + Chr(34) + ">" + EOL
HTMLCode + "</head>" + EOL
HTMLCode + "" + EOL
HTMLCode + "<body>" + EOL
HTMLCode + " Right Frame<BR>" + EOL
HTMLCode + " Hello I am the right  frame<BR>" + EOL
HTMLCode + " And do you know what ?<BR>" + EOL
HTMLCode + " I am not scrollable ...<BR>" + EOL
HTMLCode + " That's it !<BR>" + EOL
HTMLCode + " azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty azerty " + EOL
HTMLCode + "</body>" + EOL
HTMLCode + "</html>" + EOL

If CreateFile(0, HTML_Right_FileName)
    WriteString(HTMLCode)
    CloseFile(0)
EndIf

HTMLCode.s = ""
HTMLCode + "#arbre {" + EOL
HTMLCode + " font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" + EOL
HTMLCode + " font-size: 11px;" + EOL
HTMLCode + "}" + EOL
HTMLCode + "#arbre a {" + EOL
HTMLCode + " color: #000;" + EOL
HTMLCode + " text-decoration: none;" + EOL
HTMLCode + "}" + EOL
HTMLCode + "#arbre img {" + EOL
HTMLCode + " border: 0px;" + EOL
HTMLCode + " width: 19px;" + EOL
HTMLCode + " height: 16px;" + EOL
HTMLCode + "}" + EOL

If CreateFile(0, HTML_CSS_FileName)
    WriteString(HTMLCode)
    CloseFile(0)
EndIf

;
; Web browser launch on the generated pages
;
ShellExecute_(0, "open", "Frameset.htm", #NULL, #NULL, #NULL)
et les images à mettre dans un sous-répertoire images\

Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Mon avatar reproduit l'image de 4x1.8m présentée au 'Salon international du meuble de Paris' en janvier 2004, dans l'exposition 'Shades' réunisant 22 créateurs autour de Matt Sindall. L'original est un stratifié en 150 dpi.
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

ça fonctionne très bien . ça pourra m'être utile le jour où je me déciderai à refaire mon site :)
J'ai vu que tu avais fait un truc de ce genre pour gérer des boutons , je ne sais plus où , mais je vais rechercher ,je pense que j'utiliserai d'abord les boutons .Enfin c'est pas pour tout de suite, mais c'est bon de savoir qu'il existe quelque part un bout de code qui me facilitera la vie quand je voudrai faire le changement :)
Répondre