Model databáze: javascript, css a obrázky pro zobrazování stromové struktury.
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue Jul 14 16:51:24 2009 +0200 (2009-07-14)
changeset 49083966fa9d9d
parent 48 7d3afd3cd47d
child 50 1eb68e2ac637
Model databáze: javascript, css a obrázky pro zobrazování stromové struktury.
java/sql-vyuka/nbproject/project.properties
java/sql-vyuka/web/grafika/strom-konec.png
java/sql-vyuka/web/grafika/strom-minus.gif
java/sql-vyuka/web/grafika/strom-plus.gif
java/sql-vyuka/web/grafika/strom-schema.png
java/sql-vyuka/web/grafika/strom-tabulka.png
java/sql-vyuka/web/hlavni.js
java/sql-vyuka/web/index.jsp
java/sql-vyuka/web/strom.css
java/sql-vyuka/web/strom.js
     1.1 --- a/java/sql-vyuka/nbproject/project.properties	Tue Jul 07 22:55:47 2009 +0200
     1.2 +++ b/java/sql-vyuka/nbproject/project.properties	Tue Jul 14 16:51:24 2009 +0200
     1.3 @@ -20,7 +20,7 @@
     1.4  dist.war=${dist.dir}/${war.name}
     1.5  excludes=
     1.6  includes=**
     1.7 -j2ee.deploy.on.save=true
     1.8 +j2ee.deploy.on.save=false
     1.9  j2ee.platform=1.5
    1.10  j2ee.server.type=J2EE
    1.11  jar.compress=false
    1.12 @@ -34,9 +34,7 @@
    1.13  javac.target=1.5
    1.14  javac.test.classpath=\
    1.15      ${javac.classpath}:\
    1.16 -    ${build.classes.dir}:\
    1.17 -    ${libs.junit.classpath}:\
    1.18 -    ${libs.junit_4.classpath}
    1.19 +    ${build.classes.dir}
    1.20  javadoc.additionalparam=
    1.21  javadoc.author=false
    1.22  javadoc.encoding=${source.encoding}
     2.1 Binary file java/sql-vyuka/web/grafika/strom-konec.png has changed
     3.1 Binary file java/sql-vyuka/web/grafika/strom-minus.gif has changed
     4.1 Binary file java/sql-vyuka/web/grafika/strom-plus.gif has changed
     5.1 Binary file java/sql-vyuka/web/grafika/strom-schema.png has changed
     6.1 Binary file java/sql-vyuka/web/grafika/strom-tabulka.png has changed
     7.1 --- a/java/sql-vyuka/web/hlavni.js	Tue Jul 07 22:55:47 2009 +0200
     7.2 +++ b/java/sql-vyuka/web/hlavni.js	Tue Jul 14 16:51:24 2009 +0200
     7.3 @@ -128,7 +128,8 @@
     7.4                  /** Změníme URL v prohlížeči */
     7.5                  urlOdkaz['pruvodce']  = 'pruvodce=' + encodeURIComponent(pruvodceAktualniId);
     7.6                  ulozURL();
     7.7 -            }
     7.8 +                sestavStromy();
     7.9 +                }
    7.10          };
    7.11          ajax.send(null);
    7.12      }
     8.1 --- a/java/sql-vyuka/web/index.jsp	Tue Jul 07 22:55:47 2009 +0200
     8.2 +++ b/java/sql-vyuka/web/index.jsp	Tue Jul 14 16:51:24 2009 +0200
     8.3 @@ -10,9 +10,11 @@
     8.4          <meta http-equiv="content-language" content="cs"/>
     8.5          <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
     8.6          <link href="styl.css" type="text/css" rel="StyleSheet"/>
     8.7 +        <link href="strom.css" type="text/css" rel="StyleSheet"/>
     8.8          <script type="text/javaScript" src="hlavni.js"></script>
     8.9          <script type="text/javaScript" src="vstupniPole.js"></script>
    8.10          <script type="text/javaScript" src="klavesoveZkratky.js"></script>
    8.11 +        <script type="text/javaScript" src="strom.js"></script>
    8.12          <title><fmt:message key="nazev"/></title>
    8.13      </head>
    8.14      <body>
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/java/sql-vyuka/web/strom.css	Tue Jul 14 16:51:24 2009 +0200
     9.3 @@ -0,0 +1,50 @@
     9.4 +ul.strom {
     9.5 +    display: none;
     9.6 +}
     9.7 +
     9.8 +ul.strom  li {
     9.9 +    list-style: none;
    9.10 +    margin: 3px;
    9.11 +}
    9.12 +
    9.13 +ul.strom, ul.strom ul , ul.strom li {
    9.14 +    margin-left: 10px;
    9.15 +    padding: 0px;
    9.16 +}
    9.17 +
    9.18 +ul.strom li .bullet {
    9.19 +    padding-left: 16px;
    9.20 +}
    9.21 +
    9.22 +ul.strom li.liOpen .bullet {
    9.23 +    cursor: pointer;
    9.24 +    background: url('grafika/strom-minus.gif') center left no-repeat;
    9.25 +}
    9.26 +
    9.27 +ul.strom li.liClosed .bullet {
    9.28 +    cursor: pointer;
    9.29 +    background: url('grafika/strom-plus.gif') center left no-repeat;
    9.30 +}
    9.31 +
    9.32 +ul.strom li.liBullet .bullet {
    9.33 +    cursor: default;
    9.34 +    background: url('grafika/strom-konec.png') center left no-repeat;
    9.35 +}
    9.36 +
    9.37 +ul.strom li.liOpen ul {
    9.38 +    display: block;
    9.39 +}
    9.40 +
    9.41 +ul.strom li.liClosed ul {
    9.42 +    display: none;
    9.43 +}
    9.44 +
    9.45 +ul.strom .schema {
    9.46 +    padding-left: 22px;
    9.47 +    background: url('grafika/strom-schema.png') center left no-repeat;
    9.48 +}
    9.49 +
    9.50 +ul.strom .tabulka {
    9.51 +    padding-left: 22px;
    9.52 +    background: url('grafika/strom-tabulka.png') center left no-repeat;
    9.53 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/java/sql-vyuka/web/strom.js	Tue Jul 14 16:51:24 2009 +0200
    10.3 @@ -0,0 +1,145 @@
    10.4 +/** Strom je načítaný AJAXem až po načtení stránky, takže je potřeba funkci zavolat ručně */
    10.5 +//pridejUdalost(window,"load",sestavStromy);
    10.6 +
    10.7 +function pridejUdalost(o, e, f) {
    10.8 +    if (o.addEventListener) {
    10.9 +        o.addEventListener(e,f,true);
   10.10 +        return true;
   10.11 +    } else if (o.attachEvent) {
   10.12 +        return o.attachEvent("on" + e, f);
   10.13 +    } else {
   10.14 +        return false;
   10.15 +    }
   10.16 +}
   10.17 +
   10.18 +function nastavKonstantu(name, val) {
   10.19 +    if (typeof(window[name]) == "undefined" || window[name] == null) {
   10.20 +        window[name] = val;
   10.21 +    }
   10.22 +}
   10.23 +
   10.24 +function rozbalStrom(treeId) {
   10.25 +    var ul = document.getElementById(treeId);
   10.26 +    if (ul == null) {
   10.27 +        return false;
   10.28 +    }
   10.29 +    rozbalSbalSeznam(ul, nodeOpenClass);
   10.30 +}
   10.31 +
   10.32 +function sbalStrom(treeId) {
   10.33 +    var ul = document.getElementById(treeId);
   10.34 +    if (ul == null) {
   10.35 +        return false;
   10.36 +    }
   10.37 +    rozbalSbalSeznam(ul, nodeClosedClass);
   10.38 +}
   10.39 +
   10.40 +function rozbalAzNaPolozku(treeId, itemId) {
   10.41 +    var ul = document.getElementById(treeId);
   10.42 +    if (ul == null) {
   10.43 +        return false;
   10.44 +    }
   10.45 +    var ret = rozbalSbalSeznam(ul, nodeOpenClass, itemId);
   10.46 +    if (ret) {
   10.47 +        var o = document.getElementById(itemId);
   10.48 +        if (o.scrollIntoView) {
   10.49 +            o.scrollIntoView(false);
   10.50 +        }
   10.51 +    }
   10.52 +}
   10.53 +
   10.54 +function rozbalSbalSeznam(ul, cName, itemId) {
   10.55 +    if(!ul.childNodes || ul.childNodes.length==0) {
   10.56 +        return false;
   10.57 +    }
   10.58 +    for (var itemi = 0; itemi < ul.childNodes.length; itemi++) {
   10.59 +        var item = ul.childNodes[itemi];
   10.60 +
   10.61 +        if (itemId != null && item.id == itemId) {
   10.62 +            return true;
   10.63 +        }
   10.64 +
   10.65 +        if (item.nodeName == "LI") {
   10.66 +            var subLists = false;
   10.67 +            for (var sitemi = 0; sitemi<item.childNodes.length; sitemi++) {
   10.68 +                var sitem = item.childNodes[sitemi];
   10.69 +                if (sitem.nodeName=="UL") {
   10.70 +                    subLists = true;
   10.71 +                    var ret = rozbalSbalSeznam(sitem, cName, itemId);
   10.72 +                    if (itemId != null && ret) {
   10.73 +                        item.className = cName;
   10.74 +                        return true;
   10.75 +                    }
   10.76 +                }
   10.77 +            }
   10.78 +
   10.79 +            if (subLists && itemId == null) {
   10.80 +                item.className = cName;
   10.81 +            }
   10.82 +        }
   10.83 +    }
   10.84 +}
   10.85 +
   10.86 +function sestavStromy() {
   10.87 +    nastavKonstantu("treeClass", "strom");
   10.88 +    nastavKonstantu("nodeClosedClass", "liClosed");
   10.89 +    nastavKonstantu("nodeOpenClass", "liOpen");
   10.90 +    nastavKonstantu("nodeBulletClass", "liBullet");
   10.91 +    nastavKonstantu("nodeLinkClass", "bullet");
   10.92 +    nastavKonstantu("preProcessTrees", true);
   10.93 +    if (preProcessTrees) {
   10.94 +        if (!document.createElement) {
   10.95 +            return;
   10.96 +        }
   10.97 +        uls = document.getElementsByTagName("ul");
   10.98 +        for (var uli = 0; uli < uls.length; uli++) {
   10.99 +            var ul = uls[uli];
  10.100 +            if (ul.nodeName == "UL" && ul.className == treeClass) {
  10.101 +                zpracujStrom(ul);
  10.102 +                ul.style.display = "block";
  10.103 +            }
  10.104 +        }
  10.105 +    }
  10.106 +}
  10.107 +
  10.108 +function zpracujStrom(ul) {
  10.109 +    if (!ul.childNodes || ul.childNodes.length==0) {
  10.110 +        return;
  10.111 +    }
  10.112 +    for (var itemi = 0; itemi < ul.childNodes.length; itemi++) {
  10.113 +        var item = ul.childNodes[itemi];
  10.114 +        if (item.nodeName == "LI") {
  10.115 +            var subLists = false;
  10.116 +            for (var sitemi = 0; sitemi < item.childNodes.length; sitemi++) {
  10.117 +                var sitem = item.childNodes[sitemi];
  10.118 +                if (sitem.nodeName == "UL") {
  10.119 +                    subLists = true;
  10.120 +                    zpracujStrom(sitem);
  10.121 +                }
  10.122 +            }
  10.123 +            var s = document.createElement("span");
  10.124 +            var t = '\u00A0';
  10.125 +            s.className = nodeLinkClass;
  10.126 +            if (subLists) {
  10.127 +                if (item.className == null || item.className == "") {
  10.128 +                    item.className = nodeClosedClass;
  10.129 +                }
  10.130 +                if (item.firstChild.nodeName == "#text") {
  10.131 +                    t = t + item.firstChild.nodeValue;
  10.132 +                    item.removeChild(item.firstChild);
  10.133 +                }
  10.134 +                s.onclick = function() {
  10.135 +                    this.parentNode.className = (this.parentNode.className==nodeOpenClass) ? nodeClosedClass : nodeOpenClass;
  10.136 +                    return false;
  10.137 +                }
  10.138 +            } else {
  10.139 +                item.className = nodeBulletClass;
  10.140 +                s.onclick = function() {
  10.141 +                    return false;
  10.142 +                }
  10.143 +            }
  10.144 +            s.appendChild(document.createTextNode(t));
  10.145 +            item.insertBefore(s, item.firstChild);
  10.146 +        }
  10.147 +    }
  10.148 +}