Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
<html><div align="center"><a href="http://www.amazingcounter.com"><img border="0" src="http://cb.amazingcounters.com/counter.php?i=2138836&c=6416821" alt="Traffic Counters"></a>
<!-- <br><small><a href="http://www.smartdiets.info/coupons/weight-watchers.html"><font color="#8a8a8a">Success Stories</font></a></small> -->
</div></html>
/***
|''Name:''|CryptoFunctionsPlugin|
|''Description:''|Support for cryptographic functions|
***/
//{{{
if(!version.extensions.CryptoFunctionsPlugin) {
version.extensions.CryptoFunctionsPlugin = {installed:true};
//--
//-- Crypto functions and associated conversion routines
//--
// Crypto "namespace"
function Crypto() {}
// Convert a string to an array of big-endian 32-bit words
Crypto.strToBe32s = function(str)
{
var be = Array();
var len = Math.floor(str.length/4);
var i, j;
for(i=0, j=0; i<len; i++, j+=4) {
be[i] = ((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
}
while (j<str.length) {
be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
j++;
}
return be;
};
// Convert an array of big-endian 32-bit words to a string
Crypto.be32sToStr = function(be)
{
var str = "";
for(var i=0;i<be.length*32;i+=8)
str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
return str;
};
// Convert an array of big-endian 32-bit words to a hex string
Crypto.be32sToHex = function(be)
{
var hex = "0123456789ABCDEF";
var str = "";
for(var i=0;i<be.length*4;i++)
str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
return str;
};
// Return, in hex, the SHA-1 hash of a string
Crypto.hexSha1Str = function(str)
{
return Crypto.be32sToHex(Crypto.sha1Str(str));
};
// Return the SHA-1 hash of a string
Crypto.sha1Str = function(str)
{
return Crypto.sha1(Crypto.strToBe32s(str),str.length);
};
// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
Crypto.sha1 = function(x,blen)
{
// Add 32-bit integers, wrapping at 32 bits
add32 = function(a,b)
{
var lsw = (a&0xFFFF)+(b&0xFFFF);
var msw = (a>>16)+(b>>16)+(lsw>>16);
return (msw<<16)|(lsw&0xFFFF);
};
// Add five 32-bit integers, wrapping at 32 bits
add32x5 = function(a,b,c,d,e)
{
var lsw = (a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
var msw = (a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
return (msw<<16)|(lsw&0xFFFF);
};
// Bitwise rotate left a 32-bit integer by 1 bit
rol32 = function(n)
{
return (n>>>31)|(n<<1);
};
var len = blen*8;
// Append padding so length in bits is 448 mod 512
x[len>>5] |= 0x80 << (24-len%32);
// Append length
x[((len+64>>9)<<4)+15] = len;
var w = Array(80);
var k1 = 0x5A827999;
var k2 = 0x6ED9EBA1;
var k3 = 0x8F1BBCDC;
var k4 = 0xCA62C1D6;
var h0 = 0x67452301;
var h1 = 0xEFCDAB89;
var h2 = 0x98BADCFE;
var h3 = 0x10325476;
var h4 = 0xC3D2E1F0;
for(var i=0;i<x.length;i+=16) {
var j,t;
var a = h0;
var b = h1;
var c = h2;
var d = h3;
var e = h4;
for(j = 0;j<16;j++) {
w[j] = x[i+j];
t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
}
for(j=16;j<20;j++) {
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
}
for(j=20;j<40;j++) {
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k2);
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
}
for(j=40;j<60;j++) {
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
t = add32x5(e,(a>>>27)|(a<<5),(b&c)|(d&(b|c)),w[j],k3);
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
}
for(j=60;j<80;j++) {
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k4);
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
}
h0 = add32(h0,a);
h1 = add32(h1,b);
h2 = add32(h2,c);
h3 = add32(h3,d);
h4 = add32(h4,e);
}
return Array(h0,h1,h2,h3,h4);
};
}
//}}}
/***
|''Name:''|DeprecatedFunctionsPlugin|
|''Description:''|Support for deprecated functions removed from core|
***/
//{{{
if(!version.extensions.DeprecatedFunctionsPlugin) {
version.extensions.DeprecatedFunctionsPlugin = {installed:true};
//--
//-- Deprecated code
//--
// @Deprecated: Use createElementAndWikify and this.termRegExp instead
config.formatterHelpers.charFormatHelper = function(w)
{
w.subWikify(createTiddlyElement(w.output,this.element),this.terminator);
};
// @Deprecated: Use enclosedTextHelper and this.lookaheadRegExp instead
config.formatterHelpers.monospacedByLineHelper = function(w)
{
var lookaheadRegExp = new RegExp(this.lookahead,"mg");
lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = lookaheadRegExp.exec(w.source);
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
var text = lookaheadMatch[1];
if(config.browser.isIE)
text = text.replace(/\n/g,"\r");
createTiddlyElement(w.output,"pre",null,null,text);
w.nextMatch = lookaheadRegExp.lastIndex;
}
};
// @Deprecated: Use <br> or <br /> instead of <<br>>
config.macros.br = {};
config.macros.br.handler = function(place)
{
createTiddlyElement(place,"br");
};
// Find an entry in an array. Returns the array index or null
// @Deprecated: Use indexOf instead
Array.prototype.find = function(item)
{
var i = this.indexOf(item);
return i == -1 ? null : i;
};
// Load a tiddler from an HTML DIV. The caller should make sure to later call Tiddler.changed()
// @Deprecated: Use store.getLoader().internalizeTiddler instead
Tiddler.prototype.loadFromDiv = function(divRef,title)
{
return store.getLoader().internalizeTiddler(store,this,title,divRef);
};
// Format the text for storage in an HTML DIV
// @Deprecated Use store.getSaver().externalizeTiddler instead.
Tiddler.prototype.saveToDiv = function()
{
return store.getSaver().externalizeTiddler(store,this);
};
// @Deprecated: Use store.allTiddlersAsHtml() instead
function allTiddlersAsHtml()
{
return store.allTiddlersAsHtml();
}
// @Deprecated: Use refreshPageTemplate instead
function applyPageTemplate(title)
{
refreshPageTemplate(title);
}
// @Deprecated: Use story.displayTiddlers instead
function displayTiddlers(srcElement,titles,template,unused1,unused2,animate,unused3)
{
story.displayTiddlers(srcElement,titles,template,animate);
}
// @Deprecated: Use story.displayTiddler instead
function displayTiddler(srcElement,title,template,unused1,unused2,animate,unused3)
{
story.displayTiddler(srcElement,title,template,animate);
}
// @Deprecated: Use functions on right hand side directly instead
var createTiddlerPopup = Popup.create;
var scrollToTiddlerPopup = Popup.show;
var hideTiddlerPopup = Popup.remove;
// @Deprecated: Use right hand side directly instead
var regexpBackSlashEn = new RegExp("\\\\n","mg");
var regexpBackSlash = new RegExp("\\\\","mg");
var regexpBackSlashEss = new RegExp("\\\\s","mg");
var regexpNewLine = new RegExp("\n","mg");
var regexpCarriageReturn = new RegExp("\r","mg");
}
//}}}
<!--{{{-->
<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>
<!--}}}-->
//{{{
//============================================================================
//============================================================================
// ForEachTiddlerPlugin
//============================================================================
//============================================================================
// Only install once
if (!version.extensions.ForEachTiddlerPlugin) {
if (!window.abego) window.abego = {};
version.extensions.ForEachTiddlerPlugin = {
major: 1, minor: 0, revision: 8,
date: new Date(2007,3,12),
source: "http://tiddlywiki.abego-software.de/#ForEachTiddlerPlugin",
licence: "[[BSD open source license (abego Software)|http://www.abego-software.de/legal/apl-v10.html]]",
copyright: "Copyright (c) abego Software GmbH, 2005-2007 (www.abego-software.de)"
};
// For backward compatibility with TW 1.2.x
//
if (!TiddlyWiki.prototype.forEachTiddler) {
TiddlyWiki.prototype.forEachTiddler = function(callback) {
for(var t in this.tiddlers) {
callback.call(this,t,this.tiddlers[t]);
}
};
}
//============================================================================
// forEachTiddler Macro
//============================================================================
version.extensions.forEachTiddler = {
major: 1, minor: 0, revision: 8, date: new Date(2007,3,12), provider: "http://tiddlywiki.abego-software.de"};
// ---------------------------------------------------------------------------
// Configurations and constants
// ---------------------------------------------------------------------------
config.macros.forEachTiddler = {
// Standard Properties
label: "forEachTiddler",
prompt: "Perform actions on a (sorted) selection of tiddlers",
// actions
actions: {
addToList: {},
write: {}
}
};
// ---------------------------------------------------------------------------
// The forEachTiddler Macro Handler
// ---------------------------------------------------------------------------
config.macros.forEachTiddler.getContainingTiddler = function(e) {
while(e && !hasClass(e,"tiddler"))
e = e.parentNode;
var title = e ? e.getAttribute("tiddler") : null;
return title ? store.getTiddler(title) : null;
};
config.macros.forEachTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
// config.macros.forEachTiddler.traceMacroCall(place,macroName,params,wikifier,paramString,tiddler);
if (!tiddler) tiddler = config.macros.forEachTiddler.getContainingTiddler(place);
// --- Parsing ------------------------------------------
var i = 0; // index running over the params
// Parse the "in" clause
var tiddlyWikiPath = undefined;
if ((i < params.length) && params[i] == "in") {
i++;
if (i >= params.length) {
this.handleError(place, "TiddlyWiki path expected behind 'in'.");
return;
}
tiddlyWikiPath = this.paramEncode((i < params.length) ? params[i] : "");
i++;
}
// Parse the where clause
var whereClause ="true";
if ((i < params.length) && params[i] == "where") {
i++;
whereClause = this.paramEncode((i < params.length) ? params[i] : "");
i++;
}
// Parse the sort stuff
var sortClause = null;
var sortAscending = true;
if ((i < params.length) && params[i] == "sortBy") {
i++;
if (i >= params.length) {
this.handleError(place, "sortClause missing behind 'sortBy'.");
return;
}
sortClause = this.paramEncode(params[i]);
i++;
if ((i < params.length) && (params[i] == "ascending" || params[i] == "descending")) {
sortAscending = params[i] == "ascending";
i++;
}
}
// Parse the script
var scriptText = null;
if ((i < params.length) && params[i] == "script") {
i++;
scriptText = this.paramEncode((i < params.length) ? params[i] : "");
i++;
}
// Parse the action.
// When we are already at the end use the default action
var actionName = "addToList";
if (i < params.length) {
if (!config.macros.forEachTiddler.actions[params[i]]) {
this.handleError(place, "Unknown action '"+params[i]+"'.");
return;
} else {
actionName = params[i];
i++;
}
}
// Get the action parameter
// (the parsing is done inside the individual action implementation.)
var actionParameter = params.slice(i);
// --- Processing ------------------------------------------
try {
this.performMacro({
place: place,
inTiddler: tiddler,
whereClause: whereClause,
sortClause: sortClause,
sortAscending: sortAscending,
actionName: actionName,
actionParameter: actionParameter,
scriptText: scriptText,
tiddlyWikiPath: tiddlyWikiPath});
} catch (e) {
this.handleError(place, e);
}
};
// Returns an object with properties "tiddlers" and "context".
// tiddlers holds the (sorted) tiddlers selected by the parameter,
// context the context of the execution of the macro.
//
// The action is not yet performed.
//
// @parameter see performMacro
//
config.macros.forEachTiddler.getTiddlersAndContext = function(parameter) {
var context = config.macros.forEachTiddler.createContext(parameter.place, parameter.whereClause, parameter.sortClause, parameter.sortAscending, parameter.actionName, parameter.actionParameter, parameter.scriptText, parameter.tiddlyWikiPath, parameter.inTiddler);
var tiddlyWiki = parameter.tiddlyWikiPath ? this.loadTiddlyWiki(parameter.tiddlyWikiPath) : store;
context["tiddlyWiki"] = tiddlyWiki;
// Get the tiddlers, as defined by the whereClause
var tiddlers = this.findTiddlers(parameter.whereClause, context, tiddlyWiki);
context["tiddlers"] = tiddlers;
// Sort the tiddlers, when sorting is required.
if (parameter.sortClause) {
this.sortTiddlers(tiddlers, parameter.sortClause, parameter.sortAscending, context);
}
return {tiddlers: tiddlers, context: context};
};
// Returns the (sorted) tiddlers selected by the parameter.
//
// The action is not yet performed.
//
// @parameter see performMacro
//
config.macros.forEachTiddler.getTiddlers = function(parameter) {
return this.getTiddlersAndContext(parameter).tiddlers;
};
// Performs the macros with the given parameter.
//
// @param parameter holds the parameter of the macro as separate properties.
// The following properties are supported:
//
// place
// whereClause
// sortClause
// sortAscending
// actionName
// actionParameter
// scriptText
// tiddlyWikiPath
//
// All properties are optional.
// For most actions the place property must be defined.
//
config.macros.forEachTiddler.performMacro = function(parameter) {
var tiddlersAndContext = this.getTiddlersAndContext(parameter);
// Perform the action
var actionName = parameter.actionName ? parameter.actionName : "addToList";
var action = config.macros.forEachTiddler.actions[actionName];
if (!action) {
this.handleError(parameter.place, "Unknown action '"+actionName+"'.");
return;
}
var actionHandler = action.handler;
actionHandler(parameter.place, tiddlersAndContext.tiddlers, parameter.actionParameter, tiddlersAndContext.context);
};
// ---------------------------------------------------------------------------
// The actions
// ---------------------------------------------------------------------------
// Internal.
//
// --- The addToList Action -----------------------------------------------
//
config.macros.forEachTiddler.actions.addToList.handler = function(place, tiddlers, parameter, context) {
// Parse the parameter
var p = 0;
// Check for extra parameters
if (parameter.length > p) {
config.macros.forEachTiddler.createExtraParameterErrorElement(place, "addToList", parameter, p);
return;
}
// Perform the action.
var list = document.createElement("ul");
place.appendChild(list);
for (var i = 0; i < tiddlers.length; i++) {
var tiddler = tiddlers[i];
var listItem = document.createElement("li");
list.appendChild(listItem);
createTiddlyLink(listItem, tiddler.title, true);
}
};
abego.parseNamedParameter = function(name, parameter, i) {
var beginExpression = null;
if ((i < parameter.length) && parameter[i] == name) {
i++;
if (i >= parameter.length) {
throw "Missing text behind '%0'".format([name]);
}
return config.macros.forEachTiddler.paramEncode(parameter[i]);
}
return null;
}
// Internal.
//
// --- The write Action ---------------------------------------------------
//
config.macros.forEachTiddler.actions.write.handler = function(place, tiddlers, parameter, context) {
// Parse the parameter
var p = 0;
if (p >= parameter.length) {
this.handleError(place, "Missing expression behind 'write'.");
return;
}
var textExpression = config.macros.forEachTiddler.paramEncode(parameter[p]);
p++;
// Parse the "begin" option
var beginExpression = abego.parseNamedParameter("begin", parameter, p);
if (beginExpression !== null)
p += 2;
var endExpression = abego.parseNamedParameter("end", parameter, p);
if (endExpression !== null)
p += 2;
var noneExpression = abego.parseNamedParameter("none", parameter, p);
if (noneExpression !== null)
p += 2;
// Parse the "toFile" option
var filename = null;
var lineSeparator = undefined;
if ((p < parameter.length) && parameter[p] == "toFile") {
p++;
if (p >= parameter.length) {
this.handleError(place, "Filename expected behind 'toFile' of 'write' action.");
return;
}
filename = config.macros.forEachTiddler.getLocalPath(config.macros.forEachTiddler.paramEncode(parameter[p]));
p++;
if ((p < parameter.length) && parameter[p] == "withLineSeparator") {
p++;
if (p >= parameter.length) {
this.handleError(place, "Line separator text expected behind 'withLineSeparator' of 'write' action.");
return;
}
lineSeparator = config.macros.forEachTiddler.paramEncode(parameter[p]);
p++;
}
}
// Check for extra parameters
if (parameter.length > p) {
config.macros.forEachTiddler.createExtraParameterErrorElement(place, "write", parameter, p);
return;
}
// Perform the action.
var func = config.macros.forEachTiddler.getEvalTiddlerFunction(textExpression, context);
var count = tiddlers.length;
var text = "";
if (count > 0 && beginExpression)
text += config.macros.forEachTiddler.getEvalTiddlerFunction(beginExpression, context)(undefined, context, count, undefined);
for (var i = 0; i < count; i++) {
var tiddler = tiddlers[i];
text += func(tiddler, context, count, i);
}
if (count > 0 && endExpression)
text += config.macros.forEachTiddler.getEvalTiddlerFunction(endExpression, context)(undefined, context, count, undefined);
if (count == 0 && noneExpression)
text += config.macros.forEachTiddler.getEvalTiddlerFunction(noneExpression, context)(undefined, context, count, undefined);
if (filename) {
if (lineSeparator !== undefined) {
lineSeparator = lineSeparator.replace(/\\n/mg, "\n").replace(/\\r/mg, "\r");
text = text.replace(/\n/mg,lineSeparator);
}
saveFile(filename, convertUnicodeToUTF8(text));
} else {
var wrapper = createTiddlyElement(place, "span");
wikify(text, wrapper, null/* highlightRegExp */, context.inTiddler);
}
};
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
// Internal.
//
config.macros.forEachTiddler.createContext = function(placeParam, whereClauseParam, sortClauseParam, sortAscendingParam, actionNameParam, actionParameterParam, scriptText, tiddlyWikiPathParam, inTiddlerParam) {
return {
place : placeParam,
whereClause : whereClauseParam,
sortClause : sortClauseParam,
sortAscending : sortAscendingParam,
script : scriptText,
actionName : actionNameParam,
actionParameter : actionParameterParam,
tiddlyWikiPath : tiddlyWikiPathParam,
inTiddler : inTiddlerParam, // the tiddler containing the <<forEachTiddler ...>> macro call.
viewerTiddler : config.macros.forEachTiddler.getContainingTiddler(placeParam) // the tiddler showing the forEachTiddler result
};
};
// Internal.
//
// Returns a TiddlyWiki with the tiddlers loaded from the TiddlyWiki of
// the given path.
//
config.macros.forEachTiddler.loadTiddlyWiki = function(path, idPrefix) {
if (!idPrefix) {
idPrefix = "store";
}
var lenPrefix = idPrefix.length;
// Read the content of the given file
var content = loadFile(this.getLocalPath(path));
if(content === null) {
throw "TiddlyWiki '"+path+"' not found.";
}
var tiddlyWiki = new TiddlyWiki();
// Starting with TW 2.2 there is a helper function to import the tiddlers
if (tiddlyWiki.importTiddlyWiki) {
if (!tiddlyWiki.importTiddlyWiki(content))
throw "File '"+path+"' is not a TiddlyWiki.";
tiddlyWiki.dirty = false;
return tiddlyWiki;
}
// The legacy code, for TW < 2.2
// Locate the storeArea div's
var posOpeningDiv = content.indexOf(startSaveArea);
var posClosingDiv = content.lastIndexOf(endSaveArea);
if((posOpeningDiv == -1) || (posClosingDiv == -1)) {
throw "File '"+path+"' is not a TiddlyWiki.";
}
var storageText = content.substr(posOpeningDiv + startSaveArea.length, posClosingDiv);
// Create a "div" element that contains the storage text
var myStorageDiv = document.createElement("div");
myStorageDiv.innerHTML = storageText;
myStorageDiv.normalize();
// Create all tiddlers in a new TiddlyWiki
// (following code is modified copy of TiddlyWiki.prototype.loadFromDiv)
var store = myStorageDiv.childNodes;
for(var t = 0; t < store.length; t++) {
var e = store[t];
var title = null;
if(e.getAttribute)
title = e.getAttribute("tiddler");
if(!title && e.id && e.id.substr(0,lenPrefix) == idPrefix)
title = e.id.substr(lenPrefix);
if(title && title !== "") {
var tiddler = tiddlyWiki.createTiddler(title);
tiddler.loadFromDiv(e,title);
}
}
tiddlyWiki.dirty = false;
return tiddlyWiki;
};
// Internal.
//
// Returns a function that has a function body returning the given javaScriptExpression.
// The function has the parameters:
//
// (tiddler, context, count, index)
//
config.macros.forEachTiddler.getEvalTiddlerFunction = function (javaScriptExpression, context) {
var script = context["script"];
var functionText = "var theFunction = function(tiddler, context, count, index) { return "+javaScriptExpression+"}";
var fullText = (script ? script+";" : "")+functionText+";theFunction;";
return eval(fullText);
};
// Internal.
//
config.macros.forEachTiddler.findTiddlers = function(whereClause, context, tiddlyWiki) {
var result = [];
var func = config.macros.forEachTiddler.getEvalTiddlerFunction(whereClause, context);
tiddlyWiki.forEachTiddler(function(title,tiddler) {
if (func(tiddler, context, undefined, undefined)) {
result.push(tiddler);
}
});
return result;
};
// Internal.
//
config.macros.forEachTiddler.createExtraParameterErrorElement = function(place, actionName, parameter, firstUnusedIndex) {
var message = "Extra parameter behind '"+actionName+"':";
for (var i = firstUnusedIndex; i < parameter.length; i++) {
message += " "+parameter[i];
}
this.handleError(place, message);
};
// Internal.
//
config.macros.forEachTiddler.sortAscending = function(tiddlerA, tiddlerB) {
var result =
(tiddlerA.forEachTiddlerSortValue == tiddlerB.forEachTiddlerSortValue)
? 0
: (tiddlerA.forEachTiddlerSortValue < tiddlerB.forEachTiddlerSortValue)
? -1
: +1;
return result;
};
// Internal.
//
config.macros.forEachTiddler.sortDescending = function(tiddlerA, tiddlerB) {
var result =
(tiddlerA.forEachTiddlerSortValue == tiddlerB.forEachTiddlerSortValue)
? 0
: (tiddlerA.forEachTiddlerSortValue < tiddlerB.forEachTiddlerSortValue)
? +1
: -1;
return result;
};
// Internal.
//
config.macros.forEachTiddler.sortTiddlers = function(tiddlers, sortClause, ascending, context) {
// To avoid evaluating the sortClause whenever two items are compared
// we pre-calculate the sortValue for every item in the array and store it in a
// temporary property ("forEachTiddlerSortValue") of the tiddlers.
var func = config.macros.forEachTiddler.getEvalTiddlerFunction(sortClause, context);
var count = tiddlers.length;
var i;
for (i = 0; i < count; i++) {
var tiddler = tiddlers[i];
tiddler.forEachTiddlerSortValue = func(tiddler,context, undefined, undefined);
}
// Do the sorting
tiddlers.sort(ascending ? this.sortAscending : this.sortDescending);
// Delete the temporary property that holds the sortValue.
for (i = 0; i < tiddlers.length; i++) {
delete tiddlers[i].forEachTiddlerSortValue;
}
};
// Internal.
//
config.macros.forEachTiddler.trace = function(message) {
displayMessage(message);
};
// Internal.
//
config.macros.forEachTiddler.traceMacroCall = function(place,macroName,params) {
var message ="<<"+macroName;
for (var i = 0; i < params.length; i++) {
message += " "+params[i];
}
message += ">>";
displayMessage(message);
};
// Internal.
//
// Creates an element that holds an error message
//
config.macros.forEachTiddler.createErrorElement = function(place, exception) {
var message = (exception.description) ? exception.description : exception.toString();
return createTiddlyElement(place,"span",null,"forEachTiddlerError","<<forEachTiddler ...>>: "+message);
};
// Internal.
//
// @param place [may be null]
//
config.macros.forEachTiddler.handleError = function(place, exception) {
if (place) {
this.createErrorElement(place, exception);
} else {
throw exception;
}
};
// Internal.
//
// Encodes the given string.
//
// Replaces
// "$))" to ">>"
// "$)" to ">"
//
config.macros.forEachTiddler.paramEncode = function(s) {
var reGTGT = new RegExp("\\$\\)\\)","mg");
var reGT = new RegExp("\\$\\)","mg");
return s.replace(reGTGT, ">>").replace(reGT, ">");
};
// Internal.
//
// Returns the given original path (that is a file path, starting with "file:")
// as a path to a local file, in the systems native file format.
//
// Location information in the originalPath (i.e. the "#" and stuff following)
// is stripped.
//
config.macros.forEachTiddler.getLocalPath = function(originalPath) {
// Remove any location part of the URL
var hashPos = originalPath.indexOf("#");
if(hashPos != -1)
originalPath = originalPath.substr(0,hashPos);
// Convert to a native file format assuming
// "file:///x:/path/path/path..." - pc local file --> "x:\path\path\path..."
// "file://///server/share/path/path/path..." - FireFox pc network file --> "\\server\share\path\path\path..."
// "file:///path/path/path..." - mac/unix local file --> "/path/path/path..."
// "file://server/share/path/path/path..." - pc network file --> "\\server\share\path\path\path..."
var localPath;
if(originalPath.charAt(9) == ":") // pc local file
localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
else if(originalPath.indexOf("file://///") === 0) // FireFox pc network file
localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
else if(originalPath.indexOf("file:///") === 0) // mac/unix local file
localPath = unescape(originalPath.substr(7));
else if(originalPath.indexOf("file:/") === 0) // mac/unix local file
localPath = unescape(originalPath.substr(5));
else // pc network file
localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
return localPath;
};
// ---------------------------------------------------------------------------
// Stylesheet Extensions (may be overridden by local StyleSheet)
// ---------------------------------------------------------------------------
//
setStylesheet(
".forEachTiddlerError{color: #ffffff;background-color: #880000;}",
"forEachTiddler");
//============================================================================
// End of forEachTiddler Macro
//============================================================================
//============================================================================
// String.startsWith Function
//============================================================================
//
// Returns true if the string starts with the given prefix, false otherwise.
//
version.extensions["String.startsWith"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
String.prototype.startsWith = function(prefix) {
var n = prefix.length;
return (this.length >= n) && (this.slice(0, n) == prefix);
};
//============================================================================
// String.endsWith Function
//============================================================================
//
// Returns true if the string ends with the given suffix, false otherwise.
//
version.extensions["String.endsWith"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
String.prototype.endsWith = function(suffix) {
var n = suffix.length;
return (this.length >= n) && (this.right(n) == suffix);
};
//============================================================================
// String.contains Function
//============================================================================
//
// Returns true when the string contains the given substring, false otherwise.
//
version.extensions["String.contains"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
String.prototype.contains = function(substring) {
return this.indexOf(substring) >= 0;
};
//============================================================================
// Array.indexOf Function
//============================================================================
//
// Returns the index of the first occurance of the given item in the array or
// -1 when no such item exists.
//
// @param item [may be null]
//
version.extensions["Array.indexOf"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.indexOf = function(item) {
for (var i = 0; i < this.length; i++) {
if (this[i] == item) {
return i;
}
}
return -1;
};
//============================================================================
// Array.contains Function
//============================================================================
//
// Returns true when the array contains the given item, otherwise false.
//
// @param item [may be null]
//
version.extensions["Array.contains"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.contains = function(item) {
return (this.indexOf(item) >= 0);
};
//============================================================================
// Array.containsAny Function
//============================================================================
//
// Returns true when the array contains at least one of the elements
// of the item. Otherwise (or when items contains no elements) false is returned.
//
version.extensions["Array.containsAny"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.containsAny = function(items) {
for(var i = 0; i < items.length; i++) {
if (this.contains(items[i])) {
return true;
}
}
return false;
};
//============================================================================
// Array.containsAll Function
//============================================================================
//
// Returns true when the array contains all the items, otherwise false.
//
// When items is null false is returned (even if the array contains a null).
//
// @param items [may be null]
//
version.extensions["Array.containsAll"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};
//
Array.prototype.containsAll = function(items) {
for(var i = 0; i < items.length; i++) {
if (!this.contains(items[i])) {
return false;
}
}
return true;
};
} // of "install only once"
// Used Globals (for JSLint) ==============
// ... DOM
/*global document */
// ... TiddlyWiki Core
/*global convertUnicodeToUTF8, createTiddlyElement, createTiddlyLink,
displayMessage, endSaveArea, hasClass, loadFile, saveFile,
startSaveArea, store, wikify */
//}}}
<html>
<span>
<iframe src="http://tbalaschool.googlepages.com/ad125.htm" width="180px" frameborder="0" scrolling="no" ></iframe>
</span>
<span>
<iframe src="http://tbalaschool.googlepages.com/ad2.htm" width="180px" frameborder="0" scrolling="no" ></iframe>
</span></html>
<html>
<body>
<a href="http://tv.tbala.net/tbalakmfirefox/kmapp001.avi">Flash Demo</a>
</body>
</html>
<<top>><<icon img/top.bmp 16 16>>
<<jump j '' top>><<icon img/jump.bmp 16 16>>
/***
|Name|HoverMenuPlugin|
|Created by|SaqImtiaz|
|Location|http://tw.lewcid.org/#HoverMenuPlugin|
|Version|1.11|
|Requires|~TW2.x|
!Description:
Provides a hovering menu on the edge of the screen for commonly used commands, that scrolls with the page.
!Demo:
Observe the hovering menu on the right edge of the screen.
!Installation:
Copy the contents of this tiddler to your TW, tag with systemConfig, save and reload your TW.
To customize your HoverMenu, edit the HoverMenu shadow tiddler.
To customize whether the menu sticks to the right or left edge of the screen, and its start position, edit the HoverMenu configuration settings part of the code below. It's well documented, so don't be scared!
The menu has an id of hoverMenu, in case you want to style the buttons in it using css.
!Notes:
Since the default HoverMenu contains buttons for toggling the side bar and jumping to the top of the screen and to open tiddlers, the ToggleSideBarMacro, JumpMacro and the JumpToTopMacro are included in this tiddler, so you dont need to install them separately. Having them installed separately as well could lead to complications.
If you dont intend to use these three macros at all, feel free to remove those sections of code in this tiddler.
!Code
***/
/***
start HoverMenu plugin code
***/
//{{{
config.hoverMenu={};
//}}}
/***
HoverMenu configuration settings
***/
//{{{
config.hoverMenu.settings={
align: 'right', //align menu to right or left side of screen, possible values are 'right' and 'left'
x: 1, // horizontal distance of menu from side of screen, increase to your liking.
y: 158 //vertical distance of menu from top of screen at start, increase or decrease to your liking
};
//}}}
//{{{
//continue HoverMenu plugin code
config.hoverMenu.handler=function()
{
if (!document.getElementById("hoverMenu"))
{
var theMenu = createTiddlyElement(document.getElementById("contentWrapper"), "div","hoverMenu");
theMenu.setAttribute("refresh","content");
theMenu.setAttribute("tiddler","HoverMenu");
var menuContent = store.getTiddlerText("HoverMenu");
wikify(menuContent,theMenu);
}
var Xloc = this.settings.x;
Yloc =this.settings.y;
var ns = (navigator.appName.indexOf("Netscape") != -1);
function SetMenu(id)
{
var GetElements=document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id];
if(document.layers)GetElements.style=GetElements;
GetElements.sP=function(x,y){this.style[config.hoverMenu.settings.align]=x +"px";this.style.top=y +"px";};
GetElements.x = Xloc;
GetElements.y = findScrollY();
GetElements.y += Yloc;
return GetElements;
}
window.LoCate_XY=function()
{
var pY = findScrollY();
ftlObj.y += (pY + Yloc - ftlObj.y)/15;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("LoCate_XY()", 10);
}
ftlObj = SetMenu("hoverMenu");
LoCate_XY();
};
window.old_lewcid_hovermenu_restart = restart;
restart = function()
{
window.old_lewcid_hovermenu_restart();
config.hoverMenu.handler();
};
setStylesheet(
"#hoverMenu .imgLink, #hoverMenu .imgLink:hover {border:none; padding:0px; float:right; margin-bottom:2px; margin-top:0px;}\n"+
"#hoverMenu .button, #hoverMenu .tiddlyLink {border:none; font-weight:bold; background:#ccccff; color:#FFF; padding:0 5px; float:right; margin-bottom:0px;}\n"+
"#hoverMenu .button:hover, #hoverMenu .tiddlyLink:hover {font-weight:bold; border:none; color:#fff; background:#000;padding:0 5px; float:right; margin-bottom:2px;}\n"+
"#hoverMenu .button {width:100%; text-align:center}"+
"#hoverMenu { position:absolute; width:16px;}\n"+
"\n","hoverMenuStyles");
config.macros.renameButton={};
config.macros.renameButton.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
if (place.lastChild.tagName!="BR")
{
place.lastChild.firstChild.data = params[0];
if (params[1]) {place.lastChild.title = params[1];}
}
};
config.shadowTiddlers["HoverMenu"]="<<top>>\n<<toggleSideBar>><<renameButton '>' >>\n<<jump j '' top>>\n<<saveChanges>><<renameButton s 'Save TiddlyWiki'>>\n<<newTiddler>><<renameButton n>>\n";
//}}}
//end HoverMenu plugin code
//utility functions
//{{{
Popup.show = function(unused,slowly)
{
var curr = Popup.stack[Popup.stack.length-1];
var rootLeft = findPosX(curr.root);
var rootTop = findPosY(curr.root);
var rootHeight = curr.root.offsetHeight;
var popupLeft = rootLeft;
var popupTop = rootTop + rootHeight;
var popupWidth = curr.popup.offsetWidth;
var winWidth = findWindowWidth();
if (isChild(curr.root,'hoverMenu'))
var x = config.hoverMenu.settings.x;
else
var x = 0;
if(popupLeft + popupWidth+x > winWidth)
popupLeft = winWidth - popupWidth -x;
if (isChild(curr.root,'hoverMenu'))
{curr.popup.style.right = x + "px";}
else
curr.popup.style.left = popupLeft + "px";
curr.popup.style.top = popupTop + "px";
curr.popup.style.display = "block";
addClass(curr.root,"highlight");
if(config.options.chkAnimate)
anim.startAnimating(new Scroller(curr.popup,slowly));
else
window.scrollTo(0,ensureVisible(curr.popup));
}
window.isChild = function(e,parentId) {
while (e != null) {
var parent = document.getElementById(parentId);
if (parent == e) return true;
e = e.parentNode;
}
return false;
};
//}}}
//{{{
/* version: beta 1.1
replace macro buttons with icons
params[0] = image location
params[1] = image width
params[2] = image height
params[3] = image title (optional)
*/
config.macros.icon={};
config.macros.icon.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{
if (place.lastChild.tagName!="BR")
{
var tempTitle = place.lastChild.firstChild.title;
removeChildren(place.lastChild);
place.lastChild.className = "imgLink";
var img = createTiddlyElement(place.lastChild,"img");
img.src = params[0];
if (params[3])
img.title = params[3];
img.width= params[1];
img.height =params[2];
}
};
/*
use icons for toolbar commands.
used in view template like:
<span macro='commandIcon jump jump.bmp'></span>
params[0] = command name
params[1] = image location
*/
config.macros.commandIcon={};
config.macros.commandIcon.handler = function(place,macroName,params,wikifier,paramString,tiddler)
{if(!e) var e = window.event;
var img = createTiddlyElement(place,"img",null,"toolbarImg");
img.src = params[1];
img.onclick = function(){config.commands[params[0]].handler(e,place,story.findContainingTiddler(place).getAttribute("tiddler"));};
img.title = config.commands[params[0]].tooltip;
}
setStylesheet(".toolbarImg {vertical-align: middle; cursor:pointer;}\n","commandIconStyles");
//}}}
//{{{
version.extensions.inlineJavascript= {major: 1, minor: 7, revision: 0, date: new Date(2007,12,15)};
config.formatters.push( {
name: "inlineJavascript",
match: "\\<script",
lookahead: "\\<script(?: src=\\\"((?:.|\\n)*?)\\\")?(?: label=\\\"((?:.|\\n)*?)\\\")?(?: title=\\\"((?:.|\\n)*?)\\\")?( show)?\\>((?:.|\\n)*?)\\</script\\>",
handler: function(w) {
var lookaheadRegExp = new RegExp(this.lookahead,"mg");
lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = lookaheadRegExp.exec(w.source)
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
var src=lookaheadMatch[1];
var label=lookaheadMatch[2];
var tip=lookaheadMatch[3];
var show=lookaheadMatch[4];
var code=lookaheadMatch[5];
if (src) { // load a script library
// make script tag, set src, add to body to execute, then remove for cleanup
var script = document.createElement("script"); script.src = src;
document.body.appendChild(script); document.body.removeChild(script);
}
if (code) { // there is script code
if (show) // show inline script code in tiddler output
wikify("{{{\n"+lookaheadMatch[0]+"\n}}}\n",w.output);
if (label) { // create a link to an 'onclick' script
// add a link, define click handler, save code in link (pass 'place'), set link attributes
var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",wikifyPlainText(label));
link.onclick=function(){try{return(eval(this.code))}catch(e){alert(e.description?e.description:e.toString())}}
var fixup=code.replace(/document.write\s*\(/gi,'place.innerHTML+=(');
link.code="function _out(place){"+fixup+"\n};_out(this);"
link.setAttribute("title",tip?tip:"");
var URIcode='javascript:void(eval(decodeURIComponent(%22(function(){try{';
URIcode+=encodeURIComponent(encodeURIComponent(code.replace(/\n/g,' ')));
URIcode+='}catch(e){alert(e.description?e.description:e.toString())}})()%22)))';
link.setAttribute("href",URIcode);
link.style.cursor="pointer";
}
else { // run inline script code
var code="function _out(place){"+code.replace(/document.write\s*\(/gi,'place.innerHTML+=(')+"\n};_out(w.output);"
try { var out = eval(code); } catch(e) { out = e.description?e.description:e.toString(); }
if (out && out.length) wikify(out,w.output,w.highlightRegExp,w.tiddler);
}
}
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
}
}
} )
//}}}
{{{
config.macros.jump= {};
config.macros.jump.handler = function (place,macroName,params,wikifier,paramString,tiddler)
{
var label = (params[0] && params[0]!=".")? params[0]: 'jump';
var tooltip = (params[1] && params[1]!=".")? params[1]: 'jump to an open tiddler';
var top = (params[2] && params[2]=='top') ? true: false;
var btn =createTiddlyButton(place,label,tooltip,this.onclick);
if (top==true)
btn.setAttribute("top","true")
}
config.macros.jump.onclick = function(e)
{
if (!e) var e = window.event;
var theTarget = resolveTarget(e);
var top = theTarget.getAttribute("top");
var popup = Popup.create(this);
if(popup)
{
if(top=="true")
{createTiddlyButton(createTiddlyElement(popup,"li"),'Top ↑','Top of TW',config.macros.jump.top);
createTiddlyElement(popup,"hr");}
story.forEachTiddler(function(title,element) {
createTiddlyLink(createTiddlyElement(popup,"li"),title,true);
});
}
Popup.show(popup,false);
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return false;
}
config.macros.jump.top = function()
{
window.scrollTo(0,0);
}
}}}
{{{
config.macros.top={};
config.macros.top.handler=function(place,macroName)
{
createTiddlyButton(place,"^","jump to top",this.onclick);
}
config.macros.top.onclick=function()
{
window.scrollTo(0,0);
};
config.commands.top =
{
text:" ^ ",
tooltip:"jump to top"
};
config.commands.top.handler = function(event,src,title)
{
window.scrollTo(0,0);
}
}}}
//{{{
version.extensions.LaunchApplication = {major: 1, minor: 3, revision: 1, date: new Date(2007,8,7)};
config.macros.LaunchApplication = {};
function LaunchApplication(appToLaunch,appParams) {
if(! appToLaunch)
return;
var tiddlyBaseDir = self.location.pathname.substring(0,self.location.pathname.lastIndexOf("\\")+1);
if(!tiddlyBaseDir || tiddlyBaseDir == "") {
tiddlyBaseDir = self.location.pathname.substring(0,self.location.pathname.lastIndexOf("/")+1);
}
// if Returns with a leading slash, we don't want that.
if(tiddlyBaseDir.substring(0,1) == "/") {
tiddlyBaseDir = tiddlyBaseDir.substring(1);
}
if(appToLaunch.indexOf("file:///") == 0) // windows would have C:\ as the resulting file
{
tiddlyBaseDir = "";
appToLaunch = appToLaunch.substring(8);
}
if (config.browser.isIE) {
// want where the tiddly is actually located, excluding tiddly html file
var theShell = new ActiveXObject("WScript.Shell");
if(theShell) {
// the app name may have a directory component, need that too
// as we want to start with current working dir as the location
// of the app.
var appDir = appToLaunch.substring(0, appToLaunch.lastIndexOf("\\"));
if(! appDir || appDir == "") {
appDir = appToLaunch.substring(0, appToLaunch.lastIndexOf("/"));
}
appParams = appParams.length > 0 ? " \""+appParams.join("\" \"")+"\"" : "";
try {
theShell.CurrentDirectory = decodeURI(tiddlyBaseDir + appDir);
var commandString = ('"' +decodeURI(tiddlyBaseDir+appToLaunch) + '" ' + appParams);
pluginInfo.log.push(commandString);
theShell.run(commandString);
} catch (e) {
displayMessage("LaunchApplication cannot locate/execute file '"+tiddlyBaseDir+appToLaunch+"'");
return;
}
} else {
displayMessage("LaunchApplication failed to create ActiveX component WScript.Shell");
}
} else { // Not IE
// want where the tiddly is actually located, excluding tiddly html file
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
var launchString;
try { // try linux/unix format
launchString = decodeURI(tiddlyBaseDir+appToLaunch);
file.initWithPath(launchString);
} catch (e) {
try { // leading slash on tiddlyBaseDir
launchString = decodeURI("/"+tiddlyBaseDir+appToLaunch);
file.initWithPath(launchString);
} catch (e) {
try { // try windows format
launchString = decodeURI(appToLaunch).replace(/\//g,"\\");
file.initWithPath(launchString);
} catch (e) {
try { // try windows format
launchString = decodeURI(tiddlyBaseDir+appToLaunch).replace(/\//g,"\\");
file.initWithPath(launchString);
} catch (e) {
displayMessage("LaunchApplication cannot locate file '"+launchString+"' : "+e);
return;
} // try windows mode
} // try windows mode
}; // try with leading slash in tiddlyBaseDir
}; // try linux/unix mode
try {
if (file.isFile() && file.isExecutable()) {
displayMessage("LaunchApplication executing '"+launchString+"' "+appParams.join(" "));
var process = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
process.init(file);
process.run(false, appParams, appParams.length);
}
else
{
displayMessage("LaunchApplication launching '"+launchString+"' "+appParams.join(" "));
file.launch(); // No args available with this option
}
} catch (e) {
displayMessage("LaunchApplication cannot execute/launch file '"+launchString+"'");
}
}
};
config.macros.LaunchApplication.handler = function (place,macroName,params,wikifier,paramString,tiddler) {
// 0=ButtonText, 1=toolTip, 2=AppToLaunch, 3...AppParameters
if (params[0] && params[1] && params[2]) {
var theButton = createTiddlyButton(place, getParam(params,"buttonText",params[0]), getParam(params,"toolTip",params[1]), onClickLaunchApplication);
theButton.setAttribute("appToLaunch", getParam(params,"appToLaunch",params[2]));
params.splice(0,3);
theButton.setAttribute("appParameters", params.join(" "));
return;
}
}
function onClickLaunchApplication(e) {
var theAppToLaunch = this.getAttribute("appToLaunch");
var theAppParams = this.getAttribute("appParameters").readMacroParams();
LaunchApplication(theAppToLaunch,theAppParams);
}
//}}}
[[本站簡介]] | [[土芭樂公益課程]] | [[土芭樂技術工坊]] | [[TiddlyWiki 練功坊|http://tbalaschool.googlepages.com/]] | [[土芭樂 TV 站|http://tv.tbala.net/]] | [[土芭樂數位學堂|http://tbalaschool.blogspot.com]] | [[土芭樂論壇(會員制)|http://disscus.tbala.net/disscus1/login.php]] | [[下載區]]
<html><!--{{{-->
<head>
<link rel="alternate" type="application/rss+xml" title="RSS" href="index.xml">
<link rel="shortcut icon" href="http://tbala.net/img/tbala.ico" >
<link rel="icon" href="http://tbala.net/img/tbala_icon.gif" type="image/gif" >
<meta name="description" content="TiddlyWiki教學">
<meta name="keywords" content="tiddlywiki, TiddlyWiki, tbala tv, tbala, tbalaschool, tbala.net, tBala Web, tBala live cd, tobala, tubala, tiddlywiki tbala,
土芭樂, 土芭樂數位學堂, 電腦概論, 北海小英雄, Aba, Live CD, 土芭樂學園, 土芭樂論壇">
</head><!--}}}-->
<style type="text/css">#contentWrapper {display:none;}</style><div id="SplashScreen" style="border: 3px solid rgb(204, 204, 204); margin: 100px auto; padding: 30px; display: block; text-align: center; width: 320px; color: #0099cc; font-size: 25px; font-family: impact; background-color: rgb(238, 238, 238);">Welcome!!!<br> TiddlyWiki toBala 3.0<center><img src="http://tbala.net/img/tbalalogo.jpg" alt="Wait for me.....">
<br>loading ...<br></center><span style="font-size: 14px; color: red;">Requires Javascript.</span></div></html>
這些設定將暫存於瀏覽器
請簽名<<option txtUserName>>
(範例:tbala)
<<option chkSaveBackups>> 儲存備份
<<option chkAutoSave>> 自動儲存
<<option chkRegExpSearch>> 正規式搜尋
<<option chkCaseSensitiveSearch>> 區分大小寫搜尋
<<option chkAnimate>> 使用動畫顯示
<!--{{{-->
<!--template by potto http://tbala.net/ -->
<div id="cb">
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='跑馬燈' refresh='content' tiddler='跑馬燈'></div>
<div id="content">
<div id='sidebar'>
<div id="sidebarOptions" refresh='content' tiddler='SideBarOptions' ></div>
<!-- <div id="tbalalogo" refresh='content' tiddler='tbalalogo' ></div>-->
<div id="推薦連結" align="center" refresh='content' tiddler='推薦連結' ></div>
<div id='guestbook' align="center" refresh='content' force='true' tiddler='guestbook'></div>
<div id="Counter" align="center" refresh='content' tiddler='Counter' ></div>
<!-- <div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div> -->
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<em class="clear"> </em>
</div>
</div>
<div id="footer">
©2000-2008 tBala.net All Rights Reserved.<br>
<!-- <div id="授權模式" refresh='content' tiddler='授權模式' ></div> -->
CSS Layouts desing by tBala, powered by TiddlyWiki 2.3.0 (3282) <br>資料採用俗民分類法
</div>
<!--}}}-->
//{{{
//============================================================================
// PartTiddlerPlugin
// Ensure that the PartTiddler Plugin is only installed once.
//
if (!version.extensions.PartTiddlerPlugin) {
version.extensions.PartTiddlerPlugin = {
major: 1, minor: 0, revision: 9,
date: new Date(2007, 6, 14),
type: 'plugin',
source: "http://tiddlywiki.abego-software.de/#PartTiddlerPlugin"
};
if (!window.abego) window.abego = {};
if (version.major < 2) alertAndThrow("PartTiddlerPlugin requires TiddlyWiki 2.0 or newer.");
//============================================================================
// Common Helpers
// Looks for the next newline, starting at the index-th char of text.
//
// If there are only whitespaces between index and the newline
// the index behind the newline is returned,
// otherwise (or when no newline is found) index is returned.
//
var skipEmptyEndOfLine = function(text, index) {
var re = /(\n|[^\s])/g;
re.lastIndex = index;
var result = re.exec(text);
return (result && text.charAt(result.index) == '\n')
? result.index+1
: index;
}
//============================================================================
// Constants
var partEndOrStartTagRE = /(<\/part>)|(<part(?:\s+)((?:[^>])+)>)/mg;
var partEndTagREString = "<\\/part>";
var partEndTagString = "</part>";
//============================================================================
// Plugin Specific Helpers
// Parse the parameters inside a <part ...> tag and return the result.
//
// @return [may be null] {partName: ..., isHidden: ...}
//
var parseStartTagParams = function(paramText) {
var params = paramText.readMacroParams();
if (params.length == 0 || params[0].length == 0) return null;
var name = params[0];
var paramsIndex = 1;
var hidden = false;
if (paramsIndex < params.length) {
hidden = params[paramsIndex] == "hidden";
paramsIndex++;
}
return {
partName: name,
isHidden: hidden
};
}
// Returns the match to the next (end or start) part tag in the text,
// starting the search at startIndex.
//
// When no such tag is found null is returned, otherwise a "Match" is returned:
// [0]: full match
// [1]: matched "end" tag (or null when no end tag match)
// [2]: matched "start" tag (or null when no start tag match)
// [3]: content of start tag (or null if no start tag match)
//
var findNextPartEndOrStartTagMatch = function(text, startIndex) {
var re = new RegExp(partEndOrStartTagRE);
re.lastIndex = startIndex;
var match = re.exec(text);
return match;
}
//============================================================================
// Formatter
// Process the <part ...> ... </part> starting at (w.source, w.matchStart) for formatting.
//
// @return true if a complete part section (including the end tag) could be processed, false otherwise.
//
var handlePartSection = function(w) {
var tagMatch = findNextPartEndOrStartTagMatch(w.source, w.matchStart);
if (!tagMatch) return false;
if (tagMatch.index != w.matchStart || !tagMatch[2]) return false;
// Parse the start tag parameters
var arguments = parseStartTagParams(tagMatch[3]);
if (!arguments) return false;
// Continue processing
var startTagEndIndex = skipEmptyEndOfLine(w.source, tagMatch.index + tagMatch[0].length);
var endMatch = findNextPartEndOrStartTagMatch(w.source, startTagEndIndex);
if (endMatch && endMatch[1]) {
if (!arguments.isHidden) {
w.nextMatch = startTagEndIndex;
w.subWikify(w.output,partEndTagREString);
}
w.nextMatch = skipEmptyEndOfLine(w.source, endMatch.index + endMatch[0].length);
return true;
}
return false;
}
config.formatters.push( {
name: "part",
match: "<part\\s+[^>]+>",
handler: function(w) {
if (!handlePartSection(w)) {
w.outputText(w.output,w.matchStart,w.matchStart+w.matchLength);
}
}
} )
//============================================================================
// Extend "fetchTiddler" functionality to also recognize "part"s of tiddlers
// as tiddlers.
var currentParent = null; // used for the "." parent (e.g. in the "tiddler" macro)
// Return the match to the first <part ...> tag of the text that has the
// requrest partName.
//
// @return [may be null]
//
var findPartStartTagByName = function(text, partName) {
var i = 0;
while (true) {
var tagMatch = findNextPartEndOrStartTagMatch(text, i);
if (!tagMatch) return null;
if (tagMatch[2]) {
// Is start tag
// Check the name
var arguments = parseStartTagParams(tagMatch[3]);
if (arguments && arguments.partName == partName) {
return tagMatch;
}
}
i = tagMatch.index+tagMatch[0].length;
}
}
// Return the part "partName" of the given parentTiddler as a "readOnly" Tiddler
// object, using fullName as the Tiddler's title.
//
// All remaining properties of the new Tiddler (tags etc.) are inherited from
// the parentTiddler.
//
// @return [may be null]
//
var getPart = function(parentTiddler, partName, fullName) {
var text = parentTiddler.text;
var startTag = findPartStartTagByName(text, partName);
if (!startTag) return null;
var endIndexOfStartTag = skipEmptyEndOfLine(text, startTag.index+startTag[0].length);
var indexOfEndTag = text.indexOf(partEndTagString, endIndexOfStartTag);
if (indexOfEndTag >= 0) {
var partTiddlerText = text.substring(endIndexOfStartTag,indexOfEndTag);
var partTiddler = new Tiddler();
partTiddler.set(
fullName,
partTiddlerText,
parentTiddler.modifier,
parentTiddler.modified,
parentTiddler.tags,
parentTiddler.created);
partTiddler.abegoIsPartTiddler = true;
return partTiddler;
}
return null;
}
// Hijack the store.fetchTiddler to recognize the "part" addresses.
//
var hijackFetchTiddler = function() {
var oldFetchTiddler = store.fetchTiddler ;
store.fetchTiddler = function(title) {
var result = oldFetchTiddler.apply(this, arguments);
if (!result && title) {
var i = title.lastIndexOf('/');
if (i > 0) {
var parentName = title.substring(0, i);
var partName = title.substring(i+1);
var parent = (parentName == ".")
? store.resolveTiddler(currentParent)
: oldFetchTiddler.apply(this, [parentName]);
if (parent) {
return getPart(parent, partName, parent.title+"/"+partName);
}
}
}
return result;
};
};
// for debugging the plugin is not loaded through the systemConfig mechanism but via a script tag.
// At that point in the "store" is not yet defined. In that case hijackFetchTiddler through the restart function.
// Otherwise hijack now.
if (!store) {
var oldRestartFunc = restart;
window.restart = function() {
hijackFetchTiddler();
oldRestartFunc.apply(this,arguments);
};
} else
hijackFetchTiddler();
// The user must not edit a readOnly/partTiddler
//
config.commands.editTiddler.oldIsReadOnlyFunction = Tiddler.prototype.isReadOnly;
Tiddler.prototype.isReadOnly = function() {
// Tiddler.isReadOnly was introduced with TW 2.0.6.
// For older version we explicitly check the global readOnly flag
if (config.commands.editTiddler.oldIsReadOnlyFunction) {
if (config.commands.editTiddler.oldIsReadOnlyFunction.apply(this, arguments)) return true;
} else {
if (readOnly) return true;
}
return this.abegoIsPartTiddler;
}
config.commands.editTiddler.handler = function(event,src,title)
{
var t = store.getTiddler(title);
// Edit the tiddler if it either is not a tiddler (but a shadowTiddler)
// or the tiddler is not readOnly
if(!t || !t.abegoIsPartTiddler)
{
clearMessage();
story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
story.focusTiddler(title,"text");
return false;
}
}
// To allow the "./partName" syntax in macros we need to hijack
// the invokeMacro to define the "currentParent" while it is running.
//
var oldInvokeMacro = window.invokeMacro;
function myInvokeMacro(place,macro,params,wikifier,tiddler) {
var oldCurrentParent = currentParent;
if (tiddler) currentParent = tiddler;
try {
oldInvokeMacro.apply(this, arguments);
} finally {
currentParent = oldCurrentParent;
}
}
window.invokeMacro = myInvokeMacro;
// To correctly support the "./partName" syntax while refreshing we need to hijack
// the config.refreshers.tiddlers to define the "currentParent" while it is running.
//
(function() {
var oldTiddlerRefresher= config.refreshers.tiddler;
config.refreshers.tiddler = function(e,changeList) {
var oldCurrentParent = currentParent;
try {
currentParent = e.getAttribute("tiddler");
return oldTiddlerRefresher.apply(this,arguments);
} finally {
currentParent = oldCurrentParent;
}
};
})();
// Support "./partName" syntax inside <<tabs ...>> macro
(function() {
var extendRelativeNames = function(e, title) {
var nodes = e.getElementsByTagName("a");
for(var i=0; i<nodes.length; i++) {
var node = nodes[i];
var s = node.getAttribute("content");
if (s && s.indexOf("./") == 0)
node.setAttribute("content",title+s.substr(1));
}
};
var oldHandler = config.macros.tabs.handler;
config.macros.tabs.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
var result = oldHandler.apply(this,arguments);
if (tiddler)
extendRelativeNames(place, tiddler.title);
return result;
};
})();
// Scroll the anchor anchorName in the viewer of the given tiddler visible.
// When no tiddler is defined use the tiddler of the target given event is used.
window.scrollAnchorVisible = function(anchorName, tiddler, evt) {
var tiddlerElem = null;
if (tiddler) {
tiddlerElem = document.getElementById(story.idPrefix + tiddler);
}
if (!tiddlerElem && evt) {
var target = resolveTarget(evt);
tiddlerElem = story.findContainingTiddler(target);
}
if (!tiddlerElem) return;
var children = tiddlerElem.getElementsByTagName("a");
for (var i = 0; i < children.length; i++) {
var child = children[i];
var name = child.getAttribute("name");
if (name == anchorName) {
var y = findPosY(child);
window.scrollTo(0,y);
return;
}
}
}
} // of "install only once"
//}}}
/***
|''Name:''|PhotoGalleryPlugin|
|''Description:''|A browser for a photo gallery with navigational buttons and optional subtitles|
|''Version:''|1.0.0|
|''Date:''|Sep 12, 2007|
|''Source:''|http://www.math.ist.utl.pt/~psoares/addons.html|
|''Documentation:''|[[PhotoGalleryPlugin Documentation|PhotoGalleryPluginDoc]]|
|''Author:''|Paulo Soares|
|''License:''|[[Creative Commons Attribution-Share Alike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]]|
|''~CoreVersion:''|2.1.0|
***/
//{{{
config.macros.photoGallery = {};
var photoGalleryAutoAdvanceObject=null;
var photoGalleryLabels=null;
photoGalleryAutoAdvance = function() {
var viewer=document.getElementById("imageGallery");
var play=document.getElementById("photoGalleryPlayButton");
var time = parseFloat(viewer.getAttribute("AdvanceTime"));
if(photoGalleryAutoAdvanceObject) {
clearInterval(photoGalleryAutoAdvanceObject);
photoGalleryAutoAdvanceObject = null;
play.firstChild.data = '►';
} else {
if(time>0) {
photoGalleryAutoAdvanceObject = setInterval("photoGalleryJump('n')", time);
play.firstChild.data = '▣';
}
}
return;
}
photoGalleryJump = function(step) {
var viewer=document.getElementById("imageGallery");
var current = parseFloat(viewer.getAttribute("currentImage"));
var first = parseFloat(viewer.getAttribute("firstImage"));
var last = parseFloat(viewer.getAttribute("lastImage"));
switch (step) {
case "f":
var target=first;
break;
case "l":
var target=last;
break;
case "n":
var target = ((current+1)>last) ? first : current+1;
break;
case "p":
var target = ((current-1)<first) ? last : current-1;
}
document.getElementById( 'imageGalleryObject'+current).style.display='none';
viewer.setAttribute("currentImage",target);
document.getElementById( 'imageGalleryObject'+target).style.display='block';
var currentImage = document.getElementById('currentImage');
if(currentImage) currentImage.firstChild.data = (target-first+1) + '/'+ (last-first+1);
currentImage = document.getElementById('photoGalleryLabel');
if(currentImage) currentImage.firstChild.data = photoGalleryLabels[target-first];
return;
}
config.macros.photoGallery.handler= function(place,macroName,params,wikifier,paramString,tiddler) {
if (params.length<3) return;
var args = paramString.parseParams("list",null,true);
var title = tiddler.title;
var url = getParam(args,"url",undefined);
var first = getParam(args,"first",undefined);
var last = getParam(args,"last",undefined);
var height = getParam(args,"height",undefined);
var width = getParam(args,"width",undefined);
var time = getParam(args,"time",0);
var labels = getParam(args,"labels",undefined);
var numbers = getParam(args,"numbers",true);
var tiddlerElements = document.getElementById("tiddler"+title).childNodes;
for (var i = 0; i < tiddlerElements.length; i++){
if (tiddlerElements[i].className == "viewer"){
var viewer = tiddlerElements[i];
break;
}
}
var photoGalleryNextImage = function(e){photoGalleryJump('n');}
var photoGalleryPreviousImage = function(e){photoGalleryJump('p');}
var photoGalleryLastImage = function(e){photoGalleryJump('l');}
var photoGalleryFirstImage = function(e){photoGalleryJump('f');}
var pictureHolder = document.createElement('CENTER');
pictureHolder.id = "imageGallery";
createTiddlyButton(pictureHolder,"«","",photoGalleryFirstImage);
createTiddlyButton(pictureHolder,"‹","",photoGalleryPreviousImage);
if(time>0) {
var play = createTiddlyButton(pictureHolder,"►","",photoGalleryAutoAdvance);
play.id = 'photoGalleryPlayButton';
pictureHolder.setAttribute("advanceTime",time);
}
createTiddlyButton(pictureHolder,"›","",photoGalleryNextImage);
createTiddlyButton(pictureHolder,"»","",photoGalleryLastImage);
pictureHolder.setAttribute("currentImage",first);
pictureHolder.setAttribute("firstImage",first);
pictureHolder.setAttribute("lastImage",last);
var pos = url.indexOf('*');
var image;
var style='block';
if(labels) photoGalleryLabels = store.getTiddlerText(labels).split("\n");
for(i=first; i<=last; i++){
image=pictureHolder.appendChild(document.createElement('IMG'));
image.src = url.substring(0,pos)+i+url.substring(pos+1);
image.id = 'imageGalleryObject'+i;
image.style.display=style;
image.style.marginTop="0.5em";
image.style.marginBottom="0.5em";
style='none';
if(height) image.height = height;
if(width) image.width = width;
viewer.appendChild(pictureHolder);
}
if(labels) createTiddlyElement(pictureHolder,"DIV","photoGalleryLabel","",photoGalleryLabels[0]);
if(numbers==true){
var numImages=last-first+1;
createTiddlyElement(pictureHolder,"SPAN","currentImage","","1/"+numImages);
}
}
//}}}
/***
|''Name:''|PhotoShowPlugin|
|''Description:''|Photo gallery slide show|
|''Version:''|1.0.2|
|''Date:''|Oct 07, 2007|
|''Source:''|http://www.math.ist.utl.pt/~psoares/addons.html|
|''Documentation:''|[[PhotoShowPlugin Documentation|PhotoShowPluginDoc]]|
|''Author:''|Paulo Soares|
|''License:''|[[Creative Commons Attribution-Share Alike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]]|
|''~CoreVersion:''|2.1.0|
|''Requires:''|[[SlideShowPlugin]]|
***/
//{{{
config.macros.photoShow = {
handler: function(place,macroName,params,wikifier,paramString,tiddler) {
if (params.length<3) return;
title = tiddler.title;
var url = params[0];
var first = params[1];
var last = params[2];
var pos = url.indexOf('*');
// Grab the 'viewer' element
var tiddlerElements = document.getElementById("tiddler"+title).childNodes;
var viewer;
for (var i = 0; i < tiddlerElements.length; i++){
if (tiddlerElements[i].className == "viewer"){
viewer = tiddlerElements[i];
break;
}
}
var pictureHolder;
var separator;
for(i=first; i<=last; i++){
separator=document.createElement('HR');
separator.className="slideSeparator";
viewer.appendChild(separator);
pictureHolder = document.createElement('CENTER');
pictureHolder.appendChild(document.createElement('IMG'));
pictureHolder.lastChild.src = url.substring(0,pos)+i+url.substring(pos+1);
viewer.appendChild(pictureHolder);
}
}
};
config.shadowTiddlers.PhotoShowPluginDoc="The documentation is missing. It is available [[here|http://www.math.ist.utl.pt/~psoares/addons.html#PhotoShowPluginDoc]].";
//}}}
/%
|Name|SaveTiddlerToFile|
|Source|http://www.TiddlyTools.com/#SaveTiddlerToFile|
|Version|1.0.0|
|Author|Eric Shulman - ELS Design Studios|
|License|http://www.TiddlyTools.com/#LegalStatements <br>and [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|~CoreVersion|2.1|
|Type|script|
|Requires|InlineJavascriptPlugin|
|Overrides||
|Description|save tiddler SOURCE text to a local file|
Usage: <<tiddler SaveTiddlerToFile with: label tooltip filename path>>
where all parameters are optional, and:
* label - is text to be displayed as a clickable link
* tooltip - is guide text for when you mouseover the link
* filename and path - specify the location in which to save the file. Any "*" characters embedded in the filename or path are automatically replaced with the current tiddler title. If you omit the path, the current document directory is used. If you omit the filename, you will be automatically prompted to select a destination, using a system-specific "prompt for filename" dialog box.
%/
<script label="$1" title="$2">
function promptForFilename(msg,path,file,defext)
{
if(window.Components) { // moz
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var nsIFilePicker = window.Components.interfaces.nsIFilePicker;
var picker = Components.classes['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
picker.init(window, msg, nsIFilePicker.modeSave);
picker.displayDirectory=null;
picker.defaultExtension=defext;
picker.defaultString=file;
picker.appendFilters(nsIFilePicker.filterAll|nsIFilePicker.filterText|nsIFilePicker.filterHTML);
if (picker.show()!=nsIFilePicker.returnCancel) var result=picker.file.persistentDescriptor;
}
catch(e) { var result=prompt(msg,path+file); }
}
else { // IE
try { // XP only
var s = new ActiveXObject('UserAccounts.CommonDialog');
s.Filter='All files|*.*|Text files|*.txt|HTML files|*.htm;*.html|';
s.FilterIndex=1; // default to ALL files;
s.InitialDir=path;
s.FileName=file;
if (s.showOpen()) var result=s.FileName;
}
catch(e) { var result=prompt(msg,path+file); } // fallback for non-XP IE
}
return result;
}
var okmsg="Tiddler source written to %0";
var failmsg="An error occurred while creating %0";
var here=story.findContainingTiddler(place); if (!here) return;
var title=here.getAttribute('tiddler');
var tid=store.getTiddler(title);
var path=getLocalPath(document.location.href);
var slashpos=path.lastIndexOf("/"); if (slashpos==-1) slashpos=path.lastIndexOf("\\");
if (slashpos!=-1) path = path.substr(0,slashpos+1); // remove filename from path, leave the trailing slash
if ("$3"!="$"+"3") var fn="$3".replace(/\*/g,title); // custom filename with "*" marker to insert tiddlername
if ("$4"!="$"+"4") var path="$4".replace(/\*/g,title); // custom path with "*" marker to insert tiddlername
if ("$3"=="$"+"3") // not filename specified, ask user
var filename=promptForFilename("select an output filename for this tiddler",path,title,""); // ask
else
var filename=path+fn;
if (!filename || !filename.length) return;
var ok=saveFile(filename,tid.text);
var msg=ok?okmsg:failmsg;
var link=ok?"file:///"+filename.replace(/\\/g,'/'):""; // change local path to link text
clearMessage();
displayMessage(msg.format([filename]),link);
</script><script>
place.lastChild.style.fontWeight="normal";
if ("$1"=="$"+"1") place.lastChild.innerHTML="存入檔案";
if ("$2"=="$"+"2") place.lastChild.title="將本文存入指定檔案";
</script>
<<search>><<closeAll>><<newTiddler>>
<<tabs txtMainTab "最近更新" "依更新日期排序" TabTimeline "全部" "所有文章" TabAll "分類" "所有分類" TabTags "設定程序" "平台的設定程序" TabMoreShadowed>>
<html><span style="color:#6699cc">
本站版面、內容由土芭樂知識聯盟設計,系統原創於 Jeremy Ruston (TiddlyWiki 2.3.0)
</span></html>
<html><br><div style="color:#0099cc"> 土芭樂 3.0 - 數位新思路</div></html>
<!--{{{-->
<style>
#displayArea {
text-align:left;
width:90%;
height:80%;
overflow:auto
}
#tiddlerDisplay' {
width:100%;
height:100%;
overflow:auto
}
</style>
<div id='displayArea'>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
/***
|''Name:''|SlideShowPlugin|
|''Description:''|Creates a simple slide show type display|
|''Version:''|1.5.3|
|''Date:''|Sep 12, 2007|
|''Source:''|http://www.math.ist.utl.pt/~psoares/addons.html|
|''Documentation:''|[[SlideShowPlugin Documentation|SlideShowPluginDoc]]|
|''Author:''|Paulo Soares and [[Clint Checketts|http://www.checkettsweb.com]]|
|''License:''|[[Creative Commons Attribution-Share Alike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]]|
|''~CoreVersion:''|2.1.0|
***/
//{{{
config.macros.slideShow = {label: "slide show", maxTOCLength: 30};
config.macros.slideShow.messages = {gotoLabel: "Go to slide:"};
config.views.wikified.slideShow = {text: "slide show", tooltip: "Start slide show"};
config.views.wikified.slideShow.quit = {text: "end", tooltip: "Quit the slide show"};
config.views.wikified.slideShow.firstSlide = {text: "<<", tooltip: "first slide"};
config.views.wikified.slideShow.previousSlide = {text: "<", tooltip: "previous slide"};
config.views.wikified.slideShow.nextSlide = {text: ">", tooltip: "next slide"};
config.views.wikified.slideShow.lastSlide = {text: ">>", tooltip: "last slide"};
config.views.wikified.slideShow.resetClock = {text: " ", tooltip: "reset"};
config.formatters.push( {
name: "SlideSeparator",
match: "^-s-+$\\n?",
handler: function(w) {
createTiddlyElement(w.output,"hr",null,'slideSeparator');
}
});
function changeStyleSheet(tiddlerName) {
setStylesheet(store.getRecursiveTiddlerText("StyleSheetColors"),"StyleSheetColors");
setStylesheet(store.getRecursiveTiddlerText("StyleSheetLayout"),"StyleSheetLayout");
setStylesheet(store.getRecursiveTiddlerText(tiddlerName == null ? "StyleSheet" : tiddlerName,""),"StyleSheet");
}
//Excellent (and versatile) reparser created by Paul Petterson for parsing the paramString in a macro
function reparse( params ) {
var re = /([^:\s]+)(?:\:((?:\d+)|(?:["'](?:[^"']+)["']))|\s|$)/g;
var ret = new Array();
var m;
while( (m = re.exec( params )) != null ) ret[ m[1] ] = m[2]?m[2]:true;
return ret;
}
function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null ) node = document;
if ( tag == null ) tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
var j=0;
for (var i = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
// 'keys' code adapted from S5 which in turn was adapted from MozPoint (http://mozpoint.mozdev.org/)
function keys(key) {
with(config.macros.slideShow){
if (document.getElementById('contentWrapper').className == "slideShowMode"){
if (!key) {
key = event;
key.which = key.keyCode;
}
switch (key.which) {
case 32: // spacebar
if(time>0){
if(autoAdvance){
clearInterval(autoAdvance);
autoAdvance = null;
} else {
autoAdvance=setInterval("GoToSlide(1)", time);
}
}
break;
case 34: // page down
case 39: // rightkey
GoToSlide("n");
break;
case 40: // downkey
GoToSlide(1);
break;
case 33: // page up
case 37: // leftkey
GoToSlide("p");
break;
case 38: // upkey
GoToSlide(-1);
break;
case 36: // home
GoToSlide("f");
break;
case 35: // end
GoToSlide("l");
break;
case 27: // escape
endSlideShow();
break;
}
}
return false;
}
}
function clicker(e) {
if (!e) var e = window.event;
var target = resolveTarget(e);
//Whenever something is clicked that won't advance the slide make sure that the table of contents gets hidden
if (target.getAttribute('href') != null || isParentOrSelf(target, 'toc') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object') || isParentOrSelf(target, 'slideFooter') || isParentOrSelf(target, 'navigator')){
//Don't hide the TOC if the indexNumbers (which trigger the index) is clicked
if(isParentOrSelf(target,'indexNumbers') || isParentOrSelf(target,'jumpInput')){
return true;
}
showHideTOC('none');
return true;
}
//Advance a slide if the TOC is visible otherwise make sure that the TOC gets hidden
if ((!e.which && e.button == 1) || e.which == 1) {
if (document.getElementById('toc').style.display != 'block'){
GoToSlide("n");
} else {
showHideTOC('none');
}
}
if ((!e.which && e.button == 2) || e.which == 3) {
if (document.getElementById('toc').style.display != 'block'){
GoToSlide("p");
} else {
showHideTOC('none');
}
return false;
}
}
function isParentOrSelf(element, id) {
if (element == null || element.nodeName=='BODY') return false;
else if (element.id == id) return true;
else return isParentOrSelf(element.parentNode, id);
}
function GoToSlide(step) {
var new_pos;
var slideHolder = document.getElementById('slideContainer');
//The parse float ensures that the attribute is returned as a number and not a string.
var cur_pos = parseFloat(slideHolder.getAttribute('currentslide'));
var numberSlides = parseFloat(slideHolder.getAttribute('numberSlides'));
switch (step) {
case "f":
new_pos=0;
break;
case "l":
new_pos=numberSlides-1;
break;
case "n":
var numberOverlays = parseFloat(slideHolder.childNodes[cur_pos].getAttribute('numberOverlays'));
var currentOverlay = parseFloat(slideHolder.getAttribute('currentOverlay'));
if(numberOverlays==0 || currentOverlay==numberOverlays){
if(noClicks==false) new_pos=cur_pos+1;
} else {
var className="Overlay"+currentOverlay;
var overlay=getElementsByClass(className,slideHolder.childNodes[cur_pos]);
for(var i=0; i<overlay.length; i++) {overlay[i].className=className+' previousOverlay';}
currentOverlay++;
slideHolder.setAttribute('currentOverlay',currentOverlay);
className="Overlay"+currentOverlay;
overlay=getElementsByClass(className,slideHolder.childNodes[cur_pos]);
for(i=0; i<overlay.length; i++) {overlay[i].className=className+' currentOverlay';}
return false;
}
break;
case "p":
var numberOverlays = parseFloat(slideHolder.childNodes[cur_pos].getAttribute('numberOverlays'));
var currentOverlay = parseFloat(slideHolder.getAttribute('currentOverlay'));
if(numberOverlays==0 || currentOverlay==0){
if(noClicks==false) new_pos=cur_pos-1;
} else {
var className="Overlay"+currentOverlay;
var overlays=getElementsByClass(className,slideHolder.childNodes[cur_pos]);
for(var i=0; i<overlays.length; i++) {overlays[i].className=className+' nextOverlay';}
currentOverlay--;
className="Overlay"+currentOverlay;
overlays=getElementsByClass(className,slideHolder.childNodes[cur_pos]);
for(i=0; i<overlays.length; i++) {overlays[i].className=className+' currentOverlay';}
slideHolder.setAttribute('currentOverlay',currentOverlay);
return false;
}
break;
default:
new_pos=cur_pos+step;
}
if(slideShowCircularMode && new_pos == numberSlides) new_pos=0;
if(slideShowCircularMode && new_pos<0) new_pos=(numberSlides - 1);
if(step!=0 && new_pos>=0 && new_pos<numberSlides) {
slideHolder.childNodes[cur_pos].style.display='none';
slideHolder.childNodes[new_pos].style.display='block';
slideHolder.setAttribute('currentslide',new_pos);
var numberOverlays = parseFloat(slideHolder.childNodes[new_pos].getAttribute('numberOverlays'));
if(step=="p"){
var currentOverlay=numberOverlays;
var state=' previousOverlay';
} else {
var currentOverlay=0;
var state=' nextOverlay';
}
slideHolder.setAttribute('currentOverlay',currentOverlay);
if(numberOverlays>0) {
for(var i=1; i<=numberOverlays; i++){
var className="Overlay"+i;
var overlays=getElementsByClass(className,slideHolder.childNodes[new_pos]);
for(var j=0; j<overlays.length; j++) {overlays[j].className=className+state;}
}
if(step=="p"){
var className="Overlay"+numberOverlays;
var overlays=getElementsByClass(className,slideHolder.childNodes[new_pos]);
for(var j=0; j<overlays.length; j++) {overlays[j].className=className+' currentOverlay';}
}
}
new_pos++;
var indexNumbers = document.getElementById('indexNumbers');
indexNumbers.firstChild.data = new_pos+'/'+numberSlides;
if((new_pos==numberSlides) && !slideShowCircularMode && autoAdvance) clearInterval(autoAdvance);
return true;
}
return false;
}
function tocShowSlide(e) {
if (!e) var e = window.event;
var target = resolveTarget(e);
var slide = target.getAttribute('slideNumber');
var cur_pos = document.getElementById('slideContainer').getAttribute('currentslide');
var step = slide-cur_pos;
if(step!=0) GoToSlide(step);
showHideTOC('none');
return;
}
//Toggle the display of the table of contents
function showHideTOC(display){
var toc = document.getElementById('toc');
//Reset the input box
document.getElementById('jumpInput').value = "";
if (display == null || display.length == null){
if (toc.style.display == 'none' || toc.style.display == ''){
toc.style.display = 'block';
document.getElementById('jumpInput').focus();
} else {
toc.style.display = 'none';
}
} else {
toc.style.display = display;
if (display == 'block')
document.getElementById('jumpInput').focus();
}
}
function padZero(x){return (x>=10 || x<0 ? "" : "0")+x;}
function setClock(){
var actualTime = new Date();
var newTime = actualTime.getTime() - clockStartTime;
newTime = clockMultiplier*newTime+clockInterval+clockCorrection;
actualTime.setTime(newTime);
newTime = padZero(actualTime.getHours()) + ":" + padZero(actualTime.getMinutes())+ ":" + padZero(actualTime.getSeconds());
var clock = document.getElementById('slideClock');
clock.firstChild.nodeValue = newTime;
}
function resetClock(){
var time = new Date(0);
if(clockStartTime>time){
var startTime = new Date();
clockStartTime=startTime.getTime();
}
}
var title;
var place;
var autoAdvance=null;
var slideClock=null;
var noOverlays=false;
var noClicks=false;
var forceRefresh=false;
var time = 0;
var slideShowCircularMode;
var slideShowStyleSheet;
var slideShowParams;
var clockMultiplier;
var clockInterval;
var clockCorrection=0;
var clockStartTime;
var openTiddlers;
config.macros.slideShow.handler = function(aPlace,macroName,params,wikifier,paramString,tiddler){
if(tiddler instanceof Tiddler){
var lingo = config.views.wikified.slideShow;
if (!e) var e = window.event;
place = aPlace;
title = tiddler.title;
params = reparse(paramString);
var onclick = function(){config.macros.slideShow.onClickSlideShow(params);};
createTiddlyButton(aPlace,lingo.text,lingo.tooltip,onclick);
}
}
config.macros.slideShow.onClickSlideShow = function(newParams) {
// if(typeof(newParams)=="number") newParams=slideShowParams;
openTiddlers = new Array;
var viewer=document.getElementById('tiddlerDisplay');
for(var i=0; i<viewer.childNodes.length; i++){
var name = viewer.childNodes[i].getAttribute('tiddler');
openTiddlers.push(name);
}
document.oncontextmenu = function(e){return false;}
clockMultiplier = 1;
clockInterval = 0;
var startTime = new Date(0);
slideShowCircularMode = false;
time = 0;
slideShowStyleSheet = null;
if(newParams['style']){
slideShowStyleSheet = eval(newParams['style']);
}
if(newParams['repeat']){
slideShowCircularMode = true;
}
if(newParams['noClicks']){
noClicks = true;
}
if(newParams['forceRefresh']){
forceRefresh = true;
}
if(newParams['slidePause'] > 0){
time = newParams['slidePause'];
}
if(newParams['clock']){
clockCorrection=startTime.getTimezoneOffset()*60000;
startTime = new Date();
var clockType= eval(newParams['clock']);
if(clockType != '+') {
clockMultiplier = -1;
clockInterval = -clockType*60000;
}
}
clockStartTime=startTime.getTime();
if(newParams['noOverlays']){
noOverlays = true;
}
clearMessage();
//Attach the key and mouse listeners
document.onkeyup = keys;
document.onmouseup = clicker;
story.refreshTiddler(title,"SlideShowViewTemplate",true);
createSlides(newParams);
slideClock=setInterval("setClock()", 1000);
if(time>0) autoAdvance=setInterval("GoToSlide(1)", time);
story.closeAllTiddlers(title);
toggleSlideStyles();
return;
}
config.macros.slideShow.endSlideShow=function(){
var showHolder = document.getElementById('slideShowWrapper');
showHolder.parentNode.removeChild(showHolder);
document.oncontextmenu = function(e){};
if(autoAdvance) clearInterval(autoAdvance);
if(slideClock) clearInterval(slideClock);
noClicks=false;
story.refreshTiddler(title,null,true);
story.closeAllTiddlers();
toggleSlideStyles();
story.displayTiddlers(null,openTiddlers,DEFAULT_VIEW_TEMPLATE);
document.onmouseup = function(){};
}
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function jumpInputToSlide(e){
if (!e) {
e = window.event;
e.which = e.keyCode;
}
if(e.which==13){
var jumpInput= document.getElementById("jumpInput").value;
if(isInteger(jumpInput)){
var step=jumpInput-document.getElementById('slideContainer').getAttribute('currentslide')-1;
if (GoToSlide(step)){
showHideTOC('none');
}
}
}
return;
}
//Used to shorten the TOC fields
function abbreviateLabel(label){
var maxTOCLength = config.macros.slideShow.maxTOCLength;
if(label.length>maxTOCLength) {
var temp = new Array();
temp = label.split(' ');
label = temp[0];
for(var j=1; j<temp.length; j++){
if((label.length+temp[j].length)<=maxTOCLength){
label += " " + temp[j];
} else {
label += " ...";
break;
}
}
}
return label;
}
function createSlides(newParams){
var lingo = config.views.wikified.slideShow;
//Remove dblClick on edit function
var theTiddler = document.getElementById("tiddler"+title);
theTiddler.ondblclick = function() {};
// Grab the 'viewer' element and give it a signature so the show can be resumed if stopped
var tiddlerElements = theTiddler.childNodes;
var viewer;
for (var i = 0; i < tiddlerElements.length; i++){
if (tiddlerElements[i].className == "viewer") viewer = tiddlerElements[i];
}
viewer.id = 'slideShowWrapper';
//Hide the text that comes before the first H1 element (I think I may put this into a cover page type thing)
while(viewer.childNodes.length > 0 && viewer.firstChild.nodeName.toUpperCase() != "HR" && viewer.firstChild.className!="slideSeparator") {
viewer.removeChild(viewer.firstChild);
}
//Cycle through the content and each time you hit an H1 begin a new slide div
var slideNumber = 0;
var slideHolder = document.createElement('DIV');
slideHolder.id = "slideContainer";
slideHolder.setAttribute('currentslide',0);
while(viewer.childNodes.length > 0){
//Create a new slide a append it to the slide holder
if (viewer.firstChild.nodeName.toUpperCase() == "HR" && viewer.firstChild.className=="slideSeparator"){
slideNumber++;
var slide = document.createElement('DIV');
slide.id = "slideNumber"+slideNumber;
slide.className = "slide";
if (slideNumber > 1) {
//slideHolder.setAttribute('currentslide',0);
slide.style.display='none';
} else {
slide.style.display='block';
}
slideHolder.appendChild(slide);
viewer.removeChild(viewer.firstChild);
} else {
if(viewer.firstChild.nodeName=="SPAN" && viewer.firstChild.className=="" && viewer.firstChild.hasChildNodes()) {
var anchor=viewer.firstChild.nextSibling;
for (var ii=0;ii<viewer.firstChild.childNodes.length;ii++) {
var clone=viewer.firstChild.childNodes[ii].cloneNode(true);
viewer.insertBefore(clone,anchor);
}
viewer.removeChild(viewer.firstChild);
} else {
slide.appendChild(viewer.firstChild);
}
}
}
//Stick the slides back into the viewer
viewer.appendChild(slideHolder);
slideHolder.setAttribute('numberSlides',slideNumber);
//Create the navigation bar
var slidefooter = createTiddlyElement(viewer,"DIV","slideFooter","slideFooterOff");
var navigator = createTiddlyElement(slidefooter,"SPAN","navigator");
//Make it so that when the footer is hovered over the class will change to make it visible
slidefooter.onmouseover = function () {slidefooter.className = "slideFooterOn"};
slidefooter.onmouseout = function () {slidefooter.className = "slideFooterOff"};
//Create the control button for the navigation
var onClickQuit = function(){config.macros.slideShow.endSlideShow();};
createTiddlyButton(navigator,lingo.quit.text,lingo.quit.tooltip,onClickQuit);
createTiddlyButton(navigator,lingo.firstSlide.text,lingo.firstSlide.tooltip,first_slide);
createTiddlyButton(navigator,lingo.previousSlide.text,lingo.previousSlide.tooltip,previous_slide);
createTiddlyButton(navigator,lingo.nextSlide.text,lingo.nextSlide.tooltip,next_slide);
createTiddlyButton(navigator,lingo.lastSlide.text,lingo.lastSlide.tooltip,last_slide);
createTiddlyButton(navigator,lingo.resetClock.text,lingo.resetClock.tooltip,resetClock,"button","slideClock");
var indexNumbers = createTiddlyElement(slidefooter,"SPAN","indexNumbers","indexNumbers","1/"+slideNumber)
indexNumbers.onclick = showHideTOC;
var toc = createTiddlyElement(slidefooter,"UL","toc");
var ovl=1;
for (var i=0;i<slideHolder.childNodes.length;i++) {
if(!noOverlays) {
var ovl=1;
while(1){
var className="Overlay"+ovl;
var overlays=getElementsByClass(className,slideHolder.childNodes[i]);
if(overlays.length>0){
for(var j=0; j<overlays.length; j++) {overlays[j].className+=' nextOverlay';}
ovl++;
} else {break;}
}
}
slideHolder.childNodes[i].setAttribute("numberOverlays",ovl-1);
slideHolder.setAttribute("currentOverlay",0);
//Loop through each slide and check the header's content
var tocLabel = null;
for (var j=0;j<slideHolder.childNodes[i].childNodes.length;j++) {
var node = slideHolder.childNodes[i].childNodes[j];
if(node.nodeName=="H1" || node.nodeName=="H2" || node.nodeName=="H3" || node.nodeName=="H4") {
var htstring = node.innerHTML;
var stripped = htstring.replace(/(<([^>]+)>)/ig,"");
tocLabel = abbreviateLabel(stripped);
var tocLevel="tocLevel"+node.nodeName.charAt(1);
var tocItem = createTiddlyElement(toc,"LI",null,tocLevel);
var tocLink = createTiddlyElement(tocItem,"A",null,"tocItem",tocLabel);
tocLink.setAttribute("slideNumber",i);
tocLink.onclick=tocShowSlide;
}
}
}
//Input box to jump to s specific slide
var tocItem = createTiddlyElement(toc,"LI",null,"tocJumpItem",config.macros.slideShow.messages.gotoLabel);
var tocJumpInput = createTiddlyElement(tocItem,"INPUT","jumpInput");
tocJumpInput.type="text";
tocJumpInput.onkeyup=jumpInputToSlide;
}
var next_slide= function(e){GoToSlide(1);}
var first_slide= function(e){GoToSlide("f");}
var previous_slide= function(e){GoToSlide(-1);}
var last_slide= function(e){GoToSlide("l");}
function toggleSlideStyles(){
var contentWrapper = document.getElementById('contentWrapper');
if (contentWrapper.className == "slideShowMode"){
contentWrapper.className = "";
window.applyPageTemplate();
setStylesheet("#backstageShow{display: block;}","SlideShowStyleSheet");
changeStyleSheet();
} else{
contentWrapper.className = "slideShowMode";
window.applyPageTemplate("SlideShowPageTemplate");
setStylesheet(store.getRecu