W3C home > Mailing lists > Public > public-html-commits@w3.org > August 2010

html5/markup/js jump-indexes.js,NONE,1.1

From: Michael Smith via cvs-syncmail <cvsmail@w3.org>
Date: Mon, 02 Aug 2010 11:27:41 +0000
To: public-html-commits@w3.org
Message-Id: <E1OftBF-0004kD-NK@lionel-hutz.w3.org>
Update of /sources/public/html5/markup/js
In directory hutz:/tmp/cvs-serv17597/js

Added Files:
	jump-indexes.js 
Log Message:
added a "jump index" for quickly getting to per-element documentation


--- NEW FILE: jump-indexes.js ---
// No copyright is asserted on this file.

var jumpIndexA;
document.addEventListener('click', showjumpIndexA, false);

var elementList =
[
  ["a", "abbr", "address", "area", "article", "aside", "audio"],
  ["b", "base", "bdo", "blockquote", "body", "br", "button"],
  ["canvas", "caption", "cite", "code", "col", "colgroup", "command"],
  ["datalist", "dd", "del", "details", "dfn", "dir", "div", "dl", "dt"],
  ["em", "embed", "fieldset", "figcaption", "figure", "footer", "form"],
  ["h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html"],
  ["i", "iframe", "img", "input", "ins", "kbd", "keygen"],
  ["label", "legend", "li", "link", "map", "mark", "menu", "meta", "meter"],
  ["nav", "noscript", "object", "ol", "optgroup", "option", "output"],
  ["p", "param", "pre", "progress", "q", "rp", "rt", "ruby"],
  ["s", "samp", "script", "section", "select", "small", "source", "span"],
  ["strong", "style", "sub", "summary", "sup"],
  ["table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr"],
  ["ul", "var", "video", "wbr"],
  ["global-attributes"],
  ]


function showjumpIndexA(event) {
  var node = event.target;
  if (jumpIndexA) {
    jumpIndexA.parentNode.removeChild(jumpIndexA);
    jumpIndexA = null;
  } else if (node.id == 'jumpIndexA-button') {
    var indexDiv = document.createElement('div');
    var elements;
    indexDiv.className = 'jumpIndexA';
    for (var i=0, len=elementList.length; i<len; ++i) {
      var p = document.createElement('p');
      var elements = elementList[i];
      for (var j=0, jlen=elements.length; j<jlen; ++j) {
        var a = document.createElement('a');
        var separator = document.createTextNode(" ");
        var elementName = elements[j];
        if (document.body.className.indexOf("chunk") != -1) {
          a.setAttribute("href", elementName + ".html");
        } else {
          a.setAttribute("href", "#" + elementName);
        }
        if (elementName == 'global-attributes') {
          elementName = 'global attributes';
        p.setAttribute("class", "jumpIndexA-other");
        }
        a.textContent = elementName;
        p.appendChild(a);
        p.appendChild(separator);
      }
      indexDiv.appendChild(p);
    }
    var posY = event.pageY + 22;
    var posX = event.pageX - 399;
    indexDiv.setAttribute("style","top: " + posY+ "px; left: " + posX + "px;");
    document.getElementById('jump-indexes').appendChild(indexDiv);
    jumpIndexA = indexDiv;
  }
}
Received on Monday, 2 August 2010 11:27:42 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:09:58 UTC