[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Svnweb-commits] r781 - in static/trunk: . fsforg/img fsforg/js
From: |
sysadmin |
Subject: |
[Svnweb-commits] r781 - in static/trunk: . fsforg/img fsforg/js |
Date: |
Tue, 10 Nov 2009 12:59:25 -0500 |
Author: mattl
Date: Tue Nov 10 12:59:18 2009
New Revision: 781
Log:
script for making tables of contents, under X11 license.
Added:
static/trunk/fsforg/img/favicon.ico (contents, props changed)
static/trunk/generated_toc.js
Modified:
static/trunk/fsforg/img/meditate-a-alpha.png
static/trunk/fsforg/js/widget.js
Added: static/trunk/fsforg/img/favicon.ico
==============================================================================
Binary file. No diff available.
Modified: static/trunk/fsforg/img/meditate-a-alpha.png
==============================================================================
Binary file (source and/or target). No diff available.
Modified: static/trunk/fsforg/js/widget.js
==============================================================================
--- static/trunk/fsforg/js/widget.js Fri Nov 6 12:15:25 2009 (r780)
+++ static/trunk/fsforg/js/widget.js Tue Nov 10 12:59:18 2009 (r781)
@@ -1,44 +1,16 @@
-/*
- * widget.js -- Fundraising web widget
- * Copyright (c) 2007 Creative Commons
- * Copyright (c) 2007 Free Software Foundation, Inc.
- *
- * Modified by the FSF in November 2007 to make it FSF-specific.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * A copy of the GNU Lesser General Public License is available at
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- */
-
-if (fsf_widget_text == "Help protect your freedom!") {
- var fsf_widget_text = "Get updates from the FSF";
- }
-
-if (fsf_widget_text == "Help fight DRM!") {
- var fsf_widget_text = "Get updates from the FSF";
- }
-
-document.write("<link
href=\"http://www.fsf.org/graphics/widget/campaignwidget.css?1.0.1\"
rel=\"stylesheet\" type=\"text/css\" />");
-document.write("");
-document.write("<div id=\"fsf_campaign_widget\" class=\"" + fsf_widget_size +
"\">");
-document.write("<div id=\"fsf_campaign_widget_bg\"><div
id=\"fsf_campaign_widget_bg_logo\">");
-document.write("<h1 id=\"fsf_widget_title\"><span><a
href=\"http://www.fsf.org\">Free Software Foundation</a></span></h1>");
-document.write("<p style='text-align:center;'><a
href=\"http://www.fsf.org/associate/support_freedom/join_fsf?referrer=" +
fsf_associate_id + "\">Support software freedom!</a></p>");
-document.write("<p style='text-align:center;'>Get <span id='thinhide'>the new
monthly newsletter — <br /><em></span>the Free Software
Supporter</em></p>");
-document.write("<form
action=\"http://lists.gnu.org/mailman/subscribe/info-fsf\" method=\"post\">");
-document.write("<p style='text-align:center;'><input type=\"text\"
id=\"txtbx\" name=\"email\" size=\"10\" value=\"address@hidden"
onfocus=\"this.value=''\" /></p>");
-document.write("<p style='text-align: center; margin-top: 10px;'><input
type=\"submit\" value=\"Subscribe Me\" /></p>");
-document.write("</form>");
-document.write("");
-document.write("</div></div>");
-document.write("</div>");
-document.write("");
\ No newline at end of file
+
+//function incjs(f) { document.write ('<script type="text/javascript" src="' +
f + '"></scr' + 'ipt>'); }
+
+//incjs('http://static.fsf.org/nosvn/v/' + fsf_widget_size + '.js');
+
+document.write('<a href="javascript:playvideo()"><img usemap="#fsf-widget"
src=\'http://static.fsf.org/nosvn/v/' + fsf_widget_size +
'-jra.png\'></a><style type=\"text/css\">#tinybox {position:absolute;
display:none; -moz-border-radius: 0.5em; padding:0px; background:#fff
url(images/preload.gif) no-repeat 50% 50%; border:10px solid #e3e3e3;
z-index:2000} #tinymask {position:absolute; display:none; top:0; left:0;
height:100%; width:100%; background:#000; z-index:1500} #tinycontent
{background:#fff}');
+
+
+var TINY={};function T$(i){return
document.getElementById(i)}TINY.box=function(){var
p,m,b,fn,ic,iu,iw,ih,ia,f=0;return{show:function(c,u,w,h,a,t){if(!f){p=document.createElement('div');p.id='tinybox';m=document.createElement('div');m.id='tinymask';b=document.createElement('div');b.id='tinycontent';document.body.appendChild(m);document.body.appendChild(p);p.appendChild(b);m.onclick=TINY.box.hide;window.onresize=TINY.box.resize;f=1}if(!a&&!u){p.style.width=w?w+'px':'auto';p.style.height=h?h+'px':'auto';p.style.backgroundImage='none';b.innerHTML=c}else{b.style.display='none';p.style.width=p.style.height='100px'}this.mask();ic=c;iu=u;iw=w;ih=h;ia=a;this.alpha(m,1,80,3);if(t){setTimeout(function(){TINY.box.hide()},1000*t)}},fill:function(c,u,w,h,a){if(u){p.style.backgroundImage='';var
x=window.XMLHttpRequest?new XMLHttpRequest():new
ActiveXObject('Microsoft.XMLHTTP');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){TINY.box.psh(x.responseText,w,h,a)}};x.open('GET',c,1);x.send(null)}else{this.psh(c,w,h,a)}},psh:function(c,w,h,a){if(a){if(!w||!h){var
x=p.style.width,y=p.style.height;b.innerHTML=c;p.style.width=w?w+'px':'';p.style.height=h?h+'px':'';b.style.display='';w=parseInt(b.offsetWidth);h=parseInt(b.offsetHeight);b.style.display='none';p.style.width=x;p.style.height=y}else{b.innerHTML=c}this.size(p,w,h,4)}else{p.style.backgroundImage='none'}},hide:function(){TINY.box.alpha(p,-1,0,3)},resize:function(){TINY.box.pos();TINY.box.mask()},mask:function(){m.style.height=TINY.page.theight()+'px';m.style.width='';m.style.width=TINY.page.twidth()+'px'},pos:function(){var
t=(TINY.page.height()/2)-(p.offsetHeight/2);t=t<10?10:t;p.style.top=(t+TINY.page.top())+'px';p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px'},alpha:function(e,d,a,s){clearInterval(e.ai);if(d==1){e.style.opacity=0;e.style.filter='alpha(opacity=0)';e.style.display='block';this.pos()}e.ai=setInterval(function(){TINY.box.twalpha(e,a,d,s)},20)},twalpha:function(e,a,d,s){var
o=Math.round(e.style.opacity*100);if(o==a){clearInterval(e.ai);if(d==-1){e.style.display='none';e==p?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''}else{e==m?this.alpha(p,1,100,5):TINY.box.fill(ic,iu,iw,ih,ia)}}else{var
n=o+Math.ceil(Math.abs(a-o)/s)*d;e.style.opacity=n/100;e.style.filter='alpha(opacity='+n+')'}},size:function(e,w,h,s){e=typeof
e=='object'?e:T$(e);clearInterval(e.si);var
ow=e.offsetWidth,oh=e.offsetHeight,wo=ow-parseInt(e.style.width),ho=oh-parseInt(e.style.height);var
wd=ow-wo>w?-1:1,hd=(oh-ho>h)?-1:1;e.si=setInterval(function(){TINY.box.twsize(e,w,wo,wd,h,ho,hd,s)},20)},twsize:function(e,w,wo,wd,h,ho,hd,s){var
ow=e.offsetWidth-wo,oh=e.offsetHeight-ho;if(ow==w&&oh==h){clearInterval(e.si);p.style.backgroundImage='none';b.style.display='block'}else{if(ow!=w){e.style.width=ow+(Math.ceil(Math.abs(w-ow)/s)*wd)+'px'}if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}this.pos()}}}}();TINY.page=function(){return{top:function(){return
document.body.scrollTop||document.documentElement.scrollTop},width:function(){return
self.innerWidth||document.documentElement.clientWidth},height:function(){return
self.innerHeight||document.documentElement.clientHeight},theight:function(){var
d=document,b=d.body,e=d.documentElement;return
Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight))},twidth:function(){var
d=document,b=d.body,e=d.documentElement;return
Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))}}}();
+
+
+function playvideo(v) {
+
+ TINY.box.show('<iframe src=\"http://static.fsf.org/nosvn/v/jra.html?r=' +
fsf_associate_id + '\" width=100% height=480 scrolling="no"
frameborder="0">',0,480,480,1);
+
+}
\ No newline at end of file
Added: static/trunk/generated_toc.js
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ static/trunk/generated_toc.js Tue Nov 10 12:59:18 2009 (r781)
@@ -0,0 +1,315 @@
+/** Generated TOC
+ Stuart Langridge, July 2007
+
+ Generate a table of contents, based on headings in the page.
+
+ To place the TOC on the page, add
+
+ <div id="generated-toc"></div>
+
+ to the page where you want the TOC to appear. If this element
+ is not present, the TOC will not appear.
+
+ The TOC defaults to displaying all headings that are contained within
+ the same element as it itself is contained in (or all headings on the
+ page if you did not provide a generated-toc container). To override this,
+ provide a "highest heading" value by adding class="generate_from_h3"
+ (or h2, h4, etc) to the container. (If unspecified, this will display all
+ headings, as if class="generate_from_h1" was specified.)
+
+ The TOC defaults to operating only on headings contained within the same
+ element as it itself, i.e., in a page like this:
+
+ <div>
+ <div>
+ <div id="generated-toc"></div>
+ <h1>foo</h1>
+ <h2>bar</h2>
+ </div>
+ <h1>quux</h1>
+ </div>
+
+ The "quux" heading will not appear in the TOC. To override this,
+ add class="generate_for_page" to the container, which will process
+ all headings on the page wheresoever they may be.
+
+*/
+
+generated_toc = {
+ generate: function() {
+ // Identify our TOC element, and what it applies to
+ generate_from = '0';
+ generate_for = 'unset';
+ tocparent = document.getElementById('generated-toc');
+ if (tocparent) {
+ // there is a div class="generated-toc" in the document
+ // dictating where the TOC should appear
+ classes = tocparent.className.split(/\s+/);
+ for (var i=0; i<classes.length; i++) {
+ // if it specifies which heading level to generate from,
+ // or what level to generate for, save these specifications
+ if (classes[i].match(/^generate_from_h[1-6]$/)) {
+ generate_from = classes[i].substr(classes[i].length-1,1);
+ } else if (classes[i].match(/^generate_for_[a-z]+$/)) {
+ generate_for = classes[i].match(/^generate_for_([a-z])+$/)[1];
+ }
+ }
+ } else {
+ // They didn't specify a TOC element; exit
+ return;
+ }
+
+ // set top_node to be the element in the document under which
+ // we'll be analysing headings
+ if (generate_for == 'page') {
+ top_node = document.getElementsByTagName('body');
+ } else {
+ // i.e., explicitly set to "parent", left blank (so "unset"),
+ // or some invalid value
+ top_node = tocparent.parentNode;
+ }
+
+ // If there isn't a specified header level to generate from, work
+ // out what the first header level inside top_node is
+ // and make that the specified header level
+ if (generate_from == 0) {
+ first_header_found = generated_toc.findFirstHeader(top_node);
+ if (!first_header_found) {
+ // there were no headers at all inside top_node!
+ return;
+ } else {
+ generate_from = first_header_found.toLowerCase().substr(1);
+ }
+ }
+
+ // add all levels of heading we're paying attention to to the
+ // headings_to_treat dictionary, ready to be filled in later
+ headings_to_treat = {"h6":''};
+ for (var i=5; i>= parseInt(generate_from); i--) {
+ headings_to_treat["h" + i] = '';
+ }
+
+ // get headings. We can't say
+ // getElementsByTagName("h1" or "h2" or "h3"), etc, so get all
+ // elements and filter them ourselves
+ // need to use .all here because IE doesn't support gEBTN('*')
+ nodes = top_node.all ? top_node.all : top_node.getElementsByTagName('*');
+
+ // put all the headings we care about in headings
+ headings = [];
+ for (var i=0; i<nodes.length;i++) {
+ if (nodes[i].nodeName.toLowerCase() in headings_to_treat) {
+ // if heading has class no-TOC, skip it
+ if ((' ' + nodes[i].className + ' ').indexOf('no-TOC') != -1) {
+ continue;
+ }
+ headings.push(nodes[i]);
+ }
+ }
+
+ // make the basic elements of the TOC itself, ready to fill into
+
+ // first, check if there's a cookie defined to save the state as open
+ status = generated_toc.readCookie("generated_toc_display");
+ if (status && status == "open") {
+ display_initially = "block";
+ toggle_initially = "Hide table of contents";
+ } else {
+ display_initially = "none";
+ toggle_initially = "Show table of contents";
+ }
+
+ cur_head_lvl = "h" + generate_from;
+ cur_list_el = document.createElement('ul');
+ cur_list_el.style.display = display_initially;
+ p = document.createElement('p');
+ span = document.createElement('span');
+ span.className = 'hidden';
+ a = document.createElement('a');
+ a.href = '#aftertoc';
+ a.appendChild(document.createTextNode('skip table of contents'));
+ span.appendChild(a);
+ p.appendChild(span);
+ tocparent.appendChild(p);
+ p = document.createElement('p');
+ p.id = 'toggle-container';
+ a = document.createElement('a');
+ a.id = 'generated_toc_d_toggle';
+ a.appendChild(document.createTextNode(toggle_initially));
+ p.appendChild(a);
+ a.onclick = generated_toc.wrapOpenClose(a,cur_list_el);
+ a.href = '#';
+ tocparent.appendChild(p);
+ tocparent.appendChild(cur_list_el);
+
+ // now walk through our saved heading nodes
+ for (var i=0; i<headings.length; i++) {
+ this_head_el = headings[i];
+ this_head_lvl = headings[i].nodeName.toLowerCase();
+ if (!this_head_el.id) {
+ // if heading doesn't have an ID, give it one
+ this_head_el.id = 'heading_toc_j_' + i;
+ this_head_el.setAttribute('tabindex','-1');
+ }
+
+ while(this_head_lvl > cur_head_lvl) {
+ // this heading is at a lower level than the last one;
+ // create additional nested lists to put it at the right level
+
+ // get the *last* LI in the current list, and add our new UL to it
+ var last_listitem_el = null;
+ for (var j=0; j<cur_list_el.childNodes.length; j++) {
+ if (cur_list_el.childNodes[j].nodeName.toLowerCase() == 'li') {
+ last_listitem_el = cur_list_el.childNodes[j];
+ }
+ }
+ if (!last_listitem_el) {
+ // there aren't any LIs, so create a new one to add the UL to
+ last_listitem_el = document.createElement('li');
+ }
+ new_list_el = document.createElement('ul');
+ last_listitem_el.appendChild(new_list_el);
+ cur_list_el.appendChild(last_listitem_el);
+ cur_list_el = new_list_el;
+ cur_head_lvl = 'h' + (parseInt(cur_head_lvl.substr(1,1)) + 1);
+ }
+
+ while (this_head_lvl < cur_head_lvl) {
+ // this heading is at a higher level than the last one;
+ // go back up the TOC to put it at the right level
+ cur_list_el = cur_list_el.parentNode.parentNode;
+ cur_head_lvl = 'h' + (parseInt(cur_head_lvl.substr(1,1)) - 1);
+ }
+
+ // create a link to this heading, and add it to the TOC
+ li = document.createElement('li');
+ a = document.createElement('a');
+ a.href = '#' + this_head_el.id;
+
a.appendChild(document.createTextNode(generated_toc.innerText(this_head_el)));
+ li.appendChild(a);
+ cur_list_el.appendChild(li);
+ }
+
+ // add an aftertoc paragraph as destination for the skip-toc link
+ p = document.createElement('p');
+ p.id = 'aftertoc';
+ tocparent.appendChild(p);
+
+ // go through the TOC and find all LIs that are "empty", i.e., contain
+ // only ULs and no links, and give them class="missing"
+ var alllis = tocparent.getElementsByTagName("li");
+ for (var i=0; i<alllis.length; i++) {
+ var foundlink = false;
+ for (var j=0; j<alllis[i].childNodes.length; j++) {
+ if (alllis[i].childNodes[j].nodeName.toLowerCase() == 'a') {
+ foundlink = true;
+ }
+ }
+ if (!foundlink) {
+ alllis[i].className = "missing";
+ } else {
+ alllis[i].className = "notmissing";
+ }
+ }
+
+ },
+
+ wrapOpenClose: function(a, cur_list_el) {
+ // we return a function here so that it acts as a closure;
+ // in essence the inner function, which is the event handler
+ // for clicking on the toggle-toc link, remembers the a and cur_list_el
+ // elements as they are when they're passed in to it.
+ // This is an explicit function rather than an anonymous function
+ // defined where it's called so it's easier to understand.
+ return function(e) {
+ d = cur_list_el.style.display;
+ a.firstChild.nodeValue = (d == 'block' ? 'Show' : 'Hide') + ' table of
contents';
+ a.className = (d == 'block' ? 'toggle-closed' : 'toggle-open');
+ cur_list_el.style.display = d == 'block' ? 'none' : 'block';
+ // set a cookie to "open" or "closed" to save the state of the TOC
+ if (cur_list_el.style.display == "block") {
+ generated_toc.createCookie("generated_toc_display","open",21);
+ } else {
+ generated_toc.createCookie("generated_toc_display","closed",21);
+ }
+ if (window.event) {
+ window.event.returnValue = false;
+ window.event.cancelBubble = true;
+ } else {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ }
+ },
+
+ /* cookie handling: http://www.quirksmode.org/js/cookies.html */
+ createCookie: function(name,value,days) {
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime()+(days*24*60*60*1000));
+ var expires = "; expires="+date.toGMTString();
+ }
+ else var expires = "";
+ document.cookie = name+"="+value+expires+"; path=/";
+ },
+
+ readCookie: function(name) {
+ var nameEQ = name + "=";
+ var ca = document.cookie.split(';');
+ for(var i=0;i < ca.length;i++) {
+ var c = ca[i];
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
+ if (c.indexOf(nameEQ) == 0)
+ return c.substring(nameEQ.length,c.length);
+ }
+ return null;
+ },
+
+ eraseCookie: function(name) {
+ createCookie(name,"",-1);
+ },
+
+ innerText: function(el) {
+ return (typeof(el.innerText) != 'undefined') ? el.innerText :
+ (typeof(el.textContent) != 'undefined') ? el.textContent :
+ el.innerHTML.replace(/<[^>]+>/g, '');
+ },
+
+ findFirstHeader: function(node) {
+ // a recursive function which returns the first header it finds inside
+ // node, or null if there are no functions inside node.
+ var nn = node.nodeName.toLowerCase();
+ if (nn.match(/^h[1-6]$/)) {
+ // this node is itself a header; return our name
+ return nn;
+ } else {
+ for (var i=0; i<node.childNodes.length; i++) {
+ var subvalue = generated_toc.findFirstHeader(node.childNodes[i]);
+ // if one of the subnodes finds a header, abort the loop and return it
+ if (subvalue) return subvalue;
+ }
+ // no headers in this node at all
+ return null;
+ }
+ },
+
+ init: function() {
+ // quit if this function has already been called
+ if (arguments.callee.done) return;
+
+ // flag this function so we don't do the same thing twice
+ arguments.callee.done = true;
+
+ generated_toc.generate();
+ }
+};
+
+(function(i) {var u =navigator.userAgent;var e=/address@hidden@*/false; var st
=
+setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
+if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
+else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
+document.addEventListener("DOMContentLoaded",i,false); } else if(e){ (
+function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
+i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}})(generated_toc.init);
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Svnweb-commits] r781 - in static/trunk: . fsforg/img fsforg/js,
sysadmin <=