Added automatic table of contents generation.

Added external CSS
This commit is contained in:
Tom Keffer
2011-02-16 18:23:06 +00:00
parent c35c316044
commit 6c11940c40
7 changed files with 4175 additions and 4215 deletions

View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

256
docs/samaxesjs.toc-1.3.2.js Normal file
View File

@@ -0,0 +1,256 @@
/*!
* samaxesJS JavaScript Library
* http://code.google.com/p/samaxesjs/
*
* Copyright (c) 2010 samaxes.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @projectDescription samaxesJS JavaScript Library.
* @author <a href="http://www.samaxes.com/">Samuel Santos</a>
* @namespace samaxesJS
* @type {Object}
*/
var samaxesJS = {
/**
* Logging and debugging.
* @param {Object} obj The object to log.
*/
debug: function(obj) {
if (window.console && window.console.log) {
window.console.log(obj);
}
},
/**
* Adds a load event handler to the target object.
* @param {Function} func Function to add a load event handler.
*/
addLoadEvent: function(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
};
}
},
/**
* Used for trimming whitespace.
* @param {String} str The String to trim.
* @return {String} The trimmed string.
*/
trim: function(str) {
return (str || '').replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g, '');
},
/**
* Used for getting the size of an associative array.
* @param {Object} obj Associative array to check size.
* @return {Number} The size of the associative array.
*/
size: function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
size++;
}
}
return size;
},
/**
* Used for getting only the direct decendents of an element node by tag name.
* @param {Object} parent The parent node element.
* @param {String} node The node name.
* @return {Array} The direct decendents of an element node.
*/
getDirectElementsByTagName: function(parent, node) {
var directElementsByTagName = [];
var children = parent.childNodes;
var length = children.length;
for (var i = 0; i < length; i++) {
// nodeType === 1 --> Node.ELEMENT_NODE
if (children[i].nodeType === 1 && children[i].nodeName.match(new RegExp(node, 'i'))) {
directElementsByTagName.push(children[i]);
}
}
return directElementsByTagName;
}
};
/*!
* TOC JavaScript Library v1.3.2
*/
/**
* The TOC control dynamically builds a table of contents from the headings in
* a document and prepends legal-style section numbers to each of the headings.
* @namespace samaxesJS.toc
*/
samaxesJS.toc = function() {
var document = this.document;
/**
* Creates a TOC element link.
* @private
* @param {String} nodeId The node id attribute.
* @param {String} innerHTML The node text.
* @return {HTMLElement} The element link.
*/
function createLink(nodeId, innerHTML) {
var a = document.createElement('a');
if (nodeId !== '') {
a.setAttribute('href', '#' + nodeId);
}
a.innerHTML = innerHTML;
return a;
}
/**
* Checks if the last node is a <code>ul</code> element. If not, a new one is created.
* @private
* @param {Number} header The heading counter.
* @param {Object} toc The container element.
*/
function checkContainer(header, toc) {
if (header === 0 && toc.getElementsByTagName('li').length > 0 &&
!toc.getElementsByTagName('li')[toc.getElementsByTagName('li').length - 1].lastChild.nodeName.match(new RegExp('ul', 'i'))) {
toc.getElementsByTagName('li')[toc.getElementsByTagName('li').length - 1].appendChild(document.createElement('ul'));
}
}
/**
* Updates headers numeration.
* @private
* @param {Object} headers The heading counters associative array.
* @param {String} header The heading element node name.
*/
function updateNumeration(headers, header) {
for (var i = 1; i <= samaxesJS.size(headers); i++) {
if ('h' + i === header) {
++headers['h' + i];
} else if ('h' + i > header) {
headers['h' + i] = 0;
}
}
}
/**
* Generate an anchor id from a string by replacing unwanted characters.
* @private
* @param {String} text The original string.
* @return {String} The string without any unwanted characters.
*/
function generateId(text) {
return text.replace(/[ <#\/\\?&]/g, '_');
}
/**
* Prepends the numeration to a heading.
* @private
* @param {Object} headers The heading counters associative array.
* @param {String} header The heading element node name.
* @param {String} innerHTML The node text.
* @return {String} The heading element with section heading prepended.
*/
function addNumeration(headers, header, text) {
var numeration = '';
for (var i = 1; i <= samaxesJS.size(headers); i++) {
if ('h' + i <= header && headers['h' + i] > 0) {
numeration += headers['h' + i] + '.';
}
}
return numeration + ' ' + text;
}
/**
* Appends a new node to the TOC.
* @private
* @param {Object} toc The container element.
* @param {Number} index The heading element index.
* @param {String} id The node id attribute.
* @param {String} text The node text.
*/
function appendToTOC(toc, index, id, text) {
var parent = toc;
for (var i = 1; i < index; i++) {
if (samaxesJS.getDirectElementsByTagName(parent, 'li').length > 0) {
/*if (samaxesJS.getDirectElementsByTagName(samaxesJS.getDirectElementsByTagName(parent, 'li')[samaxesJS.getDirectElementsByTagName(parent, 'li').length - 1], 'ul').length === 0) {
parent.appendChild(document.createElement('li')).appendChild(document.createElement('ul'));
}*/
parent = samaxesJS.getDirectElementsByTagName(parent, 'li')[samaxesJS.getDirectElementsByTagName(parent, 'li').length - 1].getElementsByTagName('ul')[0];
}
}
if (id == null) {
parent.appendChild(document.createElement('li')).innerHTML = text;
} else {
parent.appendChild(document.createElement('li')).appendChild(createLink(id, text));
}
}
return function(options) {
samaxesJS.addLoadEvent(function() {
var headers = [];
var context = (options && options.context) ? document.getElementById(options.context) : document.body;
var autoId = options && options.autoId;
var nodes = context.getElementsByTagName('*');
var exclude = (!options || options.exclude === undefined) ? 'h1, h5, h6' : options.exclude;
for (var node in nodes) {
if (/h\d/i.test(nodes[node].nodeName) && !exclude.match(new RegExp(nodes[node].nodeName, 'i'))) {
headers.push(nodes[node]);
}
}
if (headers.length > 0) {
var toc = document.getElementById((options && options.container) || 'toc').appendChild(document.createElement('ul'));
var index = 0;
var headersNumber = {h1: 0, h2: 0, h3: 0, h4: 0, h5: 0, h6: 0};
var indexes = {h1: 0, h2: 0, h3: 0, h4: 0, h5: 0, h6: 0};
for (var i = 1; i <= 6; i++) {
indexes['h' + i] = (exclude.match(new RegExp('h' + i, 'i')) === null && document.getElementsByTagName('h' + i).length > 0) ? ++index : 0;
}
for (var header in headers) {
try {
for (var i = 6; i >= 1; i--) {
if (headers[header].nodeName.match(new RegExp('h' + i, 'i'))) {
checkContainer(headersNumber['h' + i], toc);
updateNumeration(headersNumber, 'h' + i);
if (autoId && !headers[header].getAttribute('id')) {
headers[header].setAttribute('id', generateId(headers[header].innerHTML));
}
headers[header].innerHTML = addNumeration(headersNumber, 'h' + i, headers[header].innerHTML);
appendToTOC(toc, indexes['h' + i], headers[header].getAttribute('id'), headers[header].innerHTML);
}
}
} catch (error) {
samaxesJS.debug('Error message: ' + error.message);
}
}
}
});
};
}();

23
docs/samaxesjs.toc-1.3.2.min.js vendored Normal file
View File

@@ -0,0 +1,23 @@
/*
* samaxesJS JavaScript Library
* http://code.google.com/p/samaxesjs/
*
* Copyright (c) 2010 samaxes.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var samaxesJS={debug:function(a){if(window.console&&window.console.log){window.console.log(a)}},addLoadEvent:function(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){if(b){b()}a()}}},trim:function(a){return(a||"").replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,"")},size:function(c){var b=0,a;for(a in c){if(c.hasOwnProperty(a)){b++}}return b},getDirectElementsByTagName:function(c,e){var f=[];var b=c.childNodes;var d=b.length;for(var a=0;a<d;a++){if(b[a].nodeType===1&&b[a].nodeName.match(new RegExp(e,"i"))){f.push(b[a])}}return f}};
/*
* TOC JavaScript Library v1.3.2
*/
samaxesJS.toc=function(){var a=this.document;function e(i,j){var h=a.createElement("a");if(i!==""){h.setAttribute("href","#"+i)}h.innerHTML=j;return h}function c(i,h){if(i===0&&h.getElementsByTagName("li").length>0&&!h.getElementsByTagName("li")[h.getElementsByTagName("li").length-1].lastChild.nodeName.match(new RegExp("ul","i"))){h.getElementsByTagName("li")[h.getElementsByTagName("li").length-1].appendChild(a.createElement("ul"))}}function d(j,k){for(var h=1;h<=samaxesJS.size(j);h++){if("h"+h===k){++j["h"+h]}else{if("h"+h>k){j["h"+h]=0}}}}function b(h){return h.replace(/[ <#\/\\?&]/g,"_")}function g(l,m,k){var h="";for(var j=1;j<=samaxesJS.size(l);j++){if("h"+j<=m&&l["h"+j]>0){h+=l["h"+j]+"."}}return h+" "+k}function f(n,h,m,l){var k=n;for(var j=1;j<h;j++){if(samaxesJS.getDirectElementsByTagName(k,"li").length>0){k=samaxesJS.getDirectElementsByTagName(k,"li")[samaxesJS.getDirectElementsByTagName(k,"li").length-1].getElementsByTagName("ul")[0]}}if(m==null){k.appendChild(a.createElement("li")).innerHTML=l}else{k.appendChild(a.createElement("li")).appendChild(e(m,l))}}return function(h){samaxesJS.addLoadEvent(function(){var n=[];var k=(h&&h.context)?a.getElementById(h.context):a.body;var v=h&&h.autoId;var j=k.getElementsByTagName("*");var l=(!h||h.exclude===undefined)?"h1, h5, h6":h.exclude;for(var o in j){if(/h\d/i.test(j[o].nodeName)&&!l.match(new RegExp(j[o].nodeName,"i"))){n.push(j[o])}}if(n.length>0){var p=a.getElementById((h&&h.container)||"toc").appendChild(a.createElement("ul"));var t=0;var m={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};var s={h1:0,h2:0,h3:0,h4:0,h5:0,h6:0};for(var q=1;q<=6;q++){s["h"+q]=(l.match(new RegExp("h"+q,"i"))===null&&a.getElementsByTagName("h"+q).length>0)?++t:0}for(var r in n){try{for(var q=6;q>=1;q--){if(n[r].nodeName.match(new RegExp("h"+q,"i"))){c(m["h"+q],p);d(m,"h"+q);if(v&&!n[r].getAttribute("id")){n[r].setAttribute("id",b(n[r].innerHTML))}n[r].innerHTML=g(m,"h"+q,n[r].innerHTML);f(p,s["h"+q],n[r].getAttribute("id"),n[r].innerHTML)}}}catch(u){samaxesJS.debug("Error message: "+u.message)}}}})}}();

View File

@@ -7,133 +7,8 @@
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Porting to the SheevaPlug</title>
<style type="text/css">
body {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
p {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
ol {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
ul {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
li {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dl {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dt {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dd {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
h1 {
font: bold xx-large Verdana, arial, sans-serif;
color: #FFFFFF;
border: 1px solid black;
border-bottom: 2px solid black;
border-right: 2px solid black;
background-color: #008080;
padding-left: .5em;
padding-right: .5em;
margin-top: 60pt;
border-right-width: medium;
border-bottom-width: medium;
}
h2 {
font: bold x-large Verdana, arial, sans-serif;
color: teal;
border: 1px solid black;
background-color: #e8e8e8;
padding-left: .5em;
padding-right: .5em;
margin-top: 30pt;
}
h3 {
font: bold medium Verdana, arial, sans-serif;
color: teal;
border: 1px solid black;
background-color: #e8e8e8;
padding-left: .5em;
padding-right: .5em;
}
h4 {
font: bold medium Verdana, arial, sans-serif;
color: black;
text-decoration: underline;
}
.code {
font-family: "Courier New", Courier, monospace;
}
table {
border-style: solid;
border-width: 1px;
border-collapse: collapse;
}
td {
border-style: solid;
border-width: 1px;
padding: 5px;
}
.indent {
margin-left: 40px;
}
.tty, pre {
font-family: "Courier New", Courier, monospace;
margin-left: 40px;
margin-top: 0px;
margin-bottom: 0px;
background-color: #FFFFCC;
}
.title {
text-align: center;
margin-top: 0px;
}
.config_option {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
}
.config_section {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
}
.config_important {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
color: #0000FF;
}
.bold_n_blue {
color: #0000FF;
}
.xxsmall {
font-size: xx-small;
}
.highlight {
background-color: #FFFF66;
}
.center {
text-align: center;
}
.Example_output {
padding: 10px;
border: thin #000000 dotted;
font-family: "Times New Roman", Times, serif;
margin-left: 40px;
}
</style>
<!-- CSS -->
<link href="weewx_docs.css" rel="stylesheet" />
</head>
<body>

View File

@@ -7,133 +7,8 @@
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading weewx</title>
<style type="text/css">
body {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
p {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
ol {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
ul {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
li {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dl {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dt {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dd {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
h1 {
font: bold xx-large Verdana, arial, sans-serif;
color: #FFFFFF;
border: 1px solid black;
border-bottom: 2px solid black;
border-right: 2px solid black;
background-color: #008080;
padding-left: .5em;
padding-right: .5em;
margin-top: 60pt;
border-right-width: medium;
border-bottom-width: medium;
}
h2 {
font: bold x-large Verdana, arial, sans-serif;
color: teal;
border: 1px solid black;
background-color: #e8e8e8;
padding-left: .5em;
padding-right: .5em;
margin-top: 30pt;
}
h3 {
font: bold medium Verdana, arial, sans-serif;
color: teal;
border: 1px solid black;
background-color: #e8e8e8;
padding-left: .5em;
padding-right: .5em;
}
h4 {
font: bold medium Verdana, arial, sans-serif;
color: black;
text-decoration: underline;
}
.code {
font-family: "Courier New", Courier, monospace;
}
table {
border-style: solid;
border-width: 1px;
border-collapse: collapse;
}
td {
border-style: solid;
border-width: 1px;
padding: 5px;
}
.indent {
margin-left: 40px;
}
.tty, pre {
font-family: "Courier New", Courier, monospace;
margin-left: 40px;
margin-top: 0px;
margin-bottom: 0px;
background-color: #FFFFCC;
}
.title {
text-align: center;
margin-top: 0px;
}
.config_option {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
}
.config_section {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
}
.config_important {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
color: #0000FF;
}
.bold_n_blue {
color: #0000FF;
}
.xxsmall {
font-size: xx-small;
}
.highlight {
background-color: #FFFF66;
}
.center {
text-align: center;
}
.Example_output {
padding: 10px;
border: thin #000000 dotted;
font-family: "Times New Roman", Times, serif;
margin-left: 40px;
}
</style>
<!-- CSS -->
<link href="weewx_docs.css" rel="stylesheet" />
</head>
<body>

144
docs/weewx_docs.css Normal file
View File

@@ -0,0 +1,144 @@
/*
* $Revision$
* $Author$
* $Date$
*/
body {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
p {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
ol {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
ul {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
li {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dl {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dt {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
dd {
font: 11pt Verdana,arial,sans-serif;
color: black;
}
h1 {
font: bold xx-large Verdana, arial, sans-serif;
color: #FFFFFF;
border: 1px solid black;
border-bottom: 2px solid black;
border-right: 2px solid black;
background-color: #008080;
padding-left: .5em;
padding-right: .5em;
margin-top: 60pt;
border-right-width: medium;
border-bottom-width: medium;
}
h2 {
font: bold x-large Verdana, arial, sans-serif;
color: teal;
border: 1px solid black;
background-color: #e8e8e8;
padding-left: .5em;
padding-right: .5em;
margin-top: 30pt;
}
h3 {
font: bold medium Verdana, arial, sans-serif;
color: teal;
border: 1px solid black;
background-color: #e8e8e8;
padding-left: .5em;
padding-right: .5em;
}
h4 {
font: bold medium Verdana, arial, sans-serif;
color: black;
text-decoration: underline;
}
.code {
font-family: "Courier New", Courier, monospace;
}
table {
border-style: solid;
border-width: 1px;
border-collapse: collapse;
}
td {
border-style: solid;
border-width: 1px;
padding: 5px;
}
.indent {
margin-left: 40px;
}
.tty, pre {
font-family: "Courier New", Courier, monospace;
margin-left: 40px;
margin-top: 0px;
margin-bottom: 0px;
background-color: #FFFFCC;
}
.title {
text-align: center;
margin-top: 0px;
}
.config_option {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
}
.config_section {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
}
.config_important {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
color: #0000FF;
}
.bold_n_blue {
color: #0000FF;
}
.xxsmall {
font-size: xx-small;
}
.highlight {
background-color: #FFFF66;
}
.center {
text-align: center;
}
.Example_output {
padding: 10px;
border: thin #000000 dotted;
font-family: "Times New Roman", Times, serif;
margin-left: 40px;
}
.style1 {
border-style: solid;
}
div#toc ul {
list-style: none;
}
div#toc ul li ul {
margin-bottom: 0.75em;
}
div#toc ul li ul li ul {
margin-bottom: 0.25em;
}