/lib/rdbms/doc/rdbms.html
HTML | 4272 lines | 4045 code | 194 blank | 33 comment | 0 complexity | 717ff9ac828a9d56723462f69c458b51 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <script type="text/javascript">
- var version = {major: 1, minor: 2, revision: 32, date: new Date("Aug 18, 2005"), extensions: {}};
- </script>
- <!--
- TiddlyWiki 1.2.32 by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
- Published under a BSD open source license
- Incorporating improvements by Isao Sonobe, http://www-gauge.scphys.kyoto-u.ac.jp/~sonobe/OgreKit/OgreKitWiki.html
- Copyright (c) Osmosoft Limited, 14 April 2005
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
- list of conditions and the following disclaimer in the documentation and/or other
- materials provided with the distribution.
- Neither the name of the Osmosoft Limited nor the names of its contributors may be
- used to endorse or promote products derived from this software without specific
- prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGE.
- -->
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
- <title>RDBMS</title>
- <script type="text/javascript">
- // ---------------------------------------------------------------------------------
- // Configuration repository
- // ---------------------------------------------------------------------------------
- var config = {
- // Options that can be set in the options panel and/or cookies
- options: {
- chkRegExpSearch: false,
- chkCaseSensitiveSearch: false,
- chkAnimate: true,
- txtUserName: "YourName",
- chkSaveBackups: true,
- chkAutoSave: false,
- chkGenerateAnRssFeed: false,
- chkSaveEmptyTemplate: false,
- chkOpenInNewWindow: true,
- chkToggleLinks: false,
- chkHttpReadOnly: false,
- txtMainTab: "tabTimeline",
- txtMoreTab: "moreTabAll"
- },
- // Hashmap of notification functions to be called when certain tiddlers are changed or deleted
- notifyNamedTiddlers: {
- SiteTitle: refreshTitle,
- SiteSubtitle: refreshSubtitle,
- SideBarOptions: refreshSidebar,
- StyleSheet: refreshStyles
- },
- // List of notification functions to be called when any tiddler is changed or deleted
- notifyTiddlers: [
- refreshMenu,
- refreshStory,
- refreshTabs
- ],
- // Shadow tiddlers for emergencies
- shadowTiddlers: {
- SideBarOptions: "<<search>><<closeAll>><<permaview>><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel options 'Change TiddlyWiki advanced options'>>",
- OptionsPanel: "These InterfaceOptions for customising TiddlyWiki are saved in your browser\n\nYour username for signing your edits. Write it as a WikiWord (eg JoeBloggs)\n\n<<option txtUserName>>\n<<option chkSaveBackups>> SaveBackups\n<<option chkAutoSave>> AutoSave\n<<option chkGenerateAnRssFeed>> GenerateAnRssFeed\n<<option chkRegExpSearch>> RegExpSearch\n<<option chkCaseSensitiveSearch>> CaseSensitiveSearch\n<<option chkAnimate>> EnableAnimations\n\nSee AdvancedOptions",
- AdvancedOptions: "<<option chkOpenInNewWindow>> OpenLinksInNewWindow\n<<option chkSaveEmptyTemplate>> SaveEmptyTemplate\n<<option chkToggleLinks>> Clicking on links to tiddlers that are already open causes them to close\n^^(override with Control or other modifier key)^^\n<<option chkHttpReadOnly>> HideEditingFeatures when viewed over HTTP",
- SideBarTabs: "<<tabs txtMainTab Timeline Timeline TabTimeline All 'All tiddlers' TabAll Tags 'All tags' TabTags More 'More lists' TabMore>>",
- TabTimeline: "<<timeline>>",
- TabAll: "<<list all>>",
- TabTags: "<<allTags>>",
- TabMore: "<<tabs txtMoreTab Missing 'Missing tiddlers' TabMoreMissing Orphans 'Orphaned tiddlers' TabMoreOrphans>>",
- TabMoreMissing: "<<list missing>>",
- TabMoreOrphans: "<<list orphans>>"
- },
- // Miscellaneous options
- numRssItems: 20, // Number of items in the RSS feed
- animFast: 0.12, // Speed for animations (lower == slower)
- animSlow: 0.01, // Speed for EasterEgg animations
- // Messages
- messages: {
- customConfigError: "Error in customConfig - %0",
- savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#DownloadSoftware for details",
- subtitleUnknown: "(unknown)",
- undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
- externalLinkTooltip: "External link to %0",
- noTags: "There are no tagged tiddlers",
- notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
- cantSaveError: "It's not possible to save changes using this browser. Use FireFox if you can",
- invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
- backupSaved: "Backup saved",
- backupFailed: "Failed to save backup file",
- rssSaved: "RSS feed saved",
- rssFailed: "Failed to save RSS feed file",
- emptySaved: "Empty template saved",
- emptyFailed: "Failed to save empty template file",
- mainSaved: "Main TiddlyWiki file saved",
- mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
- macroError: "Error executing macro '%0'",
- overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
- unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
- dates: {
- months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"],
- days: ["Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
- }
- },
- views: {
- wikified: {
- tag: {labelNoTags: "no tags", labelTags: "tags: ", tooltip: "Show tiddlers tagged with '%0'", openAllText: "Open all", openAllTooltip: "Open all of these tiddlers", popupNone: "No other tiddlers tagged with '%0'"},
- toolbarClose: {text: "close", tooltip: "Close this tiddler"},
- toolbarEdit: {text: "edit", tooltip: "Edit this tiddler"},
- toolbarPermalink: {text: "permalink", tooltip: "Permalink for this tiddler"},
- toolbarReferences: {text: "references", tooltip: "Show tiddlers that link to this one", popupNone: "No references"},
- defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it"
- },
- editor: {
- tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
- tagChooser: {text: "tags", tooltip: "Choose existing tags to add to this tiddler", popupNone: "There are no tags defined", tagTooltip: "Add the tag '%0'"},
- toolbarDone: {text: "done", tooltip: "Save changes to this tiddler"},
- toolbarCancel: {text: "cancel", tooltip: "Undo changes to this tiddler"},
- toolbarDelete: {text: "delete", tooltip: "Delete this tiddler"},
- defaultText: "Type the text for '%0'"
- }
- },
- macros: { // Each has a 'handler' member that is inserted later
- today: {},
- version: {},
- search: {label: "search", prompt: "Search this TiddlyWiki", sizeTextbox: 15, successMsg: "%0 tiddlers found matching %1", failureMsg: "No tiddlers found matching %0"},
- tiddler: {},
- tag: {},
- timeline: {dateFormat: "DD MMM YYYY"},
- allTags: {tooltip: "Show tiddlers tagged with '%0'", noTags: "There are no tagged tiddlers"},
- list: {
- all: {prompt: "All tiddlers in alphabetical order"},
- missing: {prompt: "Tiddlers that have links to them but are not defined"},
- orphans: {prompt: "Tiddlers that are not linked to from any other tiddlers"}
- },
- closeAll: {label: "close all", prompt: "Close all displayed tiddlers (except any that are being edited)"},
- permaview: {label: "permaview", prompt: "Link to an URL that retrieves all the currently displayed tiddlers"},
- saveChanges: {label: "save changes", prompt: "Save all tiddlers to create a new TiddlyWiki"},
- slider: {},
- option: {},
- newTiddler: {label: "new tiddler", prompt: "Create a new tiddler", title: "New Tiddler"},
- newJournal: {label: "new journal", prompt: "Create a new tiddler from the current date and time"},
- sparkline: {},
- tabs: {}
- }
- };
- // ---------------------------------------------------------------------------------
- // Main
- // ---------------------------------------------------------------------------------
- // TiddlyWiki storage
- var store = new TiddlyWiki();
- // Animation engine
- var anim = new Animator();
- var readOnly = false;
- // Starting up
- function main()
- {
- setupRegexp();
- saveTest();
- loadOptionsCookie();
- var s;
- for(s in config.notifyNamedTiddlers)
- store.addNotification(s,config.notifyNamedTiddlers[s]);
- for(s=0; s<config.notifyTiddlers.length; s++)
- store.addNotification(null,config.notifyTiddlers[s]);
- store.loadFromDiv("storeArea","store");
- loadSystemConfig();
- readOnly = (document.location.toString().substr(0,7) == "http://") ? config.options.chkHttpReadOnly : false;
- store.notifyAll();
- var start = store.getTiddlerText("DefaultTiddlers");
- if(window.location.hash)
- displayTiddlers(null,convertUTF8ToUnicode(decodeURI(window.location.hash.substr(1))),1,null,null);
- else if(start)
- displayTiddlers(null,start,1,null,null);
- }
- function saveTest()
- {
- var saveTest = document.getElementById("saveTest");
- if(saveTest.hasChildNodes())
- alert(config.messages.savedSnapshotError);
- saveTest.appendChild(document.createTextNode("savetest"));
- }
- function loadSystemConfig()
- {
- var configTiddlers = store.getTaggedTiddlers("systemConfig");
- for(var t=0; t<configTiddlers.length; t++)
- {
- var ex = processConfig(configTiddlers[t].text);
- if(ex)
- displayMessage(config.messages.customConfigError.format([ex]));
- }
- }
- // ---------------------------------------------------------------------------------
- // Macro definitions
- // ---------------------------------------------------------------------------------
- config.macros.today.handler = function(place)
- {
- createTiddlyElement(place,"span",null,null,(new Date()).toLocaleString());
- }
- config.macros.version.handler = function(place)
- {
- createTiddlyElement(place,"span",null,null,version.major + "." + version.minor + "." + version.revision);
- }
- config.macros.list.handler = function(place,macroName,params)
- {
- var type = params[0] ? params[0] : "all";
- var theList = document.createElement("ul");
- place.appendChild(theList);
- if(this[type].prompt)
- createTiddlyElement(theList,"li",null,"listTitle",this[type].prompt);
- var results;
- if(this[type].handler)
- results = this[type].handler(params);
- for (t = 0; t < results.length; t++)
- {
- theListItem = document.createElement("li")
- theList.appendChild(theListItem);
- if(typeof results[t] == "string")
- createTiddlyLink(theListItem,results[t],true);
- else
- createTiddlyLink(theListItem,results[t].title,true);
- }
- }
- config.macros.list.all.handler = function(params)
- {
- return store.reverseLookup("tags","excludeLists",false,"title");
- }
- config.macros.list.missing.handler = function(params)
- {
- return store.getMissingLinks();
- }
- config.macros.list.orphans.handler = function(params)
- {
- return store.getOrphans();
- }
- config.macros.allTags.handler = function(place,macroName,params)
- {
- var tags = store.getTags();
- var theDateList = createTiddlyElement(place,"ul",null,null,null);
- if(tags.length == 0)
- createTiddlyElement(theDateList,"li",null,"listTitle",this.noTags);
- for (t=0; t<tags.length; t++)
- {
- var theListItem =createTiddlyElement(theDateList,"li",null,null,null);
- var theTag = createTiddlyButton(theListItem,tags[t][0] + " (" + tags[t][1] + ")",this.tooltip.format([tags[t][0]]),onClickTag);
- theTag.setAttribute("tag",tags[t][0]);
- }
- }
- config.macros.timeline.handler = function(place,macroName,params)
- {
- var tiddlers = store.reverseLookup("tags","excludeLists",false,"modified");
- var lastDay = "";
- for (t=tiddlers.length-1; t>=0; t--)
- {
- var tiddler = tiddlers[t];
- var theDay = tiddler.modified.convertToYYYYMMDDHHMM().substr(0,8);
- if(theDay != lastDay)
- {
- var theDateList = document.createElement("ul");
- place.appendChild(theDateList);
- createTiddlyElement(theDateList,"li",null,"listTitle",tiddler.modified.formatString(this.dateFormat));
- lastDay = theDay;
- }
- var theDateListItem = createTiddlyElement(theDateList,"li",null,"listLink",null);
- theDateListItem.appendChild(createTiddlyLink(place,tiddler.title,true));
- }
- }
- config.macros.search.handler = function(place,macroName,params)
- {
- var lastSearchText = "";
- var searchTimeout = null;
- var doSearch = function(txt)
- {
- closeAllTiddlers();
- var matches = store.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch,"title","excludeSearch");
- for(var t=matches.length-1; t>=0; t--)
- displayTiddler(null,matches[t].title,0,txt.value,config.options.chkCaseSensitiveSearch,false,false);
- var q = config.options.chkRegExpSearch ? "/" : "'";
- if(matches.length > 0)
- displayMessage(config.macros.search.successMsg.format([matches.length.toString(),q + txt.value + q]));
- else
- displayMessage(config.macros.search.failureMsg.format([q + txt.value + q]));
- lastSearchText = txt.value;
- };
- var clickHandler = function(e)
- {
- doSearch(this.nextSibling);
- };
- var keyHandler = function(e)
- {
- if (!e) var e = window.event;
- switch(e.keyCode)
- {
- case 27:
- this.value = "";
- clearMessage();
- break;
- }
- if((this.value.length > 2) && (this.value != lastSearchText))
- {
- if(searchTimeout)
- clearTimeout(searchTimeout);
- var txt = this;
- searchTimeout = setTimeout(function() {doSearch(txt);},200);
- }
- };
- var focusHandler = function(e)
- {
- this.select();
- };
- var btn = createTiddlyButton(place,this.label,this.prompt,clickHandler);
- var txt = createTiddlyElement(place,"input",null,null,null);
- if(params[0])
- txt.value = params[0];
- txt.onkeyup = keyHandler;
- txt.onfocus = focusHandler;
- txt.setAttribute("size",this.sizeTextbox);
- txt.setAttribute("autocomplete","off");
- if(navigator.userAgent.toLowerCase().indexOf("safari") == -1)
- txt.setAttribute("type","text");
- else
- {
- txt.setAttribute("type","search");
- txt.setAttribute("results","5");
- }
- }
- config.macros.tiddler.handler = function(place,macroName,params)
- {
- var wrapper = createTiddlyElement(place,"span",null,params[1] ? params[1] : null,null);
- var text = store.getTiddlerText(params[0]);
- if(text)
- wikify(text,wrapper,null,null);
- }
- config.macros.tag.handler = function(place,macroName,params)
- {
- createTagButton(place,params[0]);
- }
- config.macros.closeAll.handler = function(place)
- {
- createTiddlyButton(place,this.label,this.prompt,closeAllTiddlers);
- }
- config.macros.permaview.handler = function(place)
- {
- createTiddlyButton(place,this.label,this.prompt,onClickPermaView);
- }
- config.macros.saveChanges.handler = function(place)
- {
- if(!readOnly)
- createTiddlyButton(place,this.label,this.prompt,saveChanges);
- }
- config.macros.slider.onClickSlider = function(e)
- {
- if (!e) var e = window.event;
- var n = this.nextSibling;
- var cookie = n.getAttribute("cookie");
- var isOpen = n.style.display != "none";
- if(config.options.chkAnimate)
- anim.startAnimating(new Slider(n,!isOpen,e.shiftKey || e.altKey,"none"));
- else
- n.style.display = isOpen ? "none" : "block";
- config.options[cookie] = !isOpen;
- saveOptionCookie(cookie);
- }
- config.macros.slider.handler = function(place,macroName,params)
- {
- var cookie = params[0] ? params[0] : "";
- var text = store.getTiddlerText(params[1]);
- var btn = createTiddlyButton(place,params[2],params[3],this.onClickSlider);
- var panel = createTiddlyElement(place,"div",null,"sliderPanel",null);
- panel.setAttribute("cookie",cookie);
- panel.style.display = config.options[cookie] ? "block" : "none";
- if(text)
- wikify(text,panel,null,null);
- }
- config.macros.option.onChangeOption = function(e)
- {
- var opt = this.getAttribute("option");
- var elementType,valueField;
- if(opt)
- {
- switch(opt.substr(0,3))
- {
- case "txt":
- elementType = "input";
- valueField = "value";
- break;
- case "chk":
- elementType = "input";
- valueField = "checked";
- break;
- }
- config.options[opt] = this[valueField];
- saveOptionCookie(opt);
- var nodes = document.getElementsByTagName(elementType);
- for(var t=0; t<nodes.length; t++)
- {
- var optNode = nodes[t].getAttribute("option");
- if(opt == optNode)
- nodes[t][valueField] = this[valueField];
- }
- }
- return(true);
- }
- config.macros.option.handler = function(place,macroName,params)
- {
- var opt = params[0];
- if(config.options[opt] == undefined)
- return;
- var c;
- switch(opt.substr(0,3))
- {
- case "txt":
- c = document.createElement("input");
- c.onkeyup = this.onChangeOption;
- c.setAttribute("option",opt);
- c.size = 15;
- c.value = config.options[opt];
- place.appendChild(c);
- break;
- case "chk":
- c = document.createElement("input");
- c.setAttribute("type","checkbox");
- c.onclick = this.onChangeOption;
- c.setAttribute("option",opt);
- c.checked = config.options[opt];
- place.appendChild(c);
- break;
- }
- }
- config.macros.newTiddler.onClick = function()
- {
- displayTiddler(null,config.macros.newTiddler.title,2,null,null,false,false);
- var e = document.getElementById("editorTitle" + config.macros.newTiddler.title);
- e.focus();
- e.select();
- }
- config.macros.newTiddler.handler = function(place)
- {
- if(!readOnly)
- createTiddlyButton(place,this.label,this.prompt,this.onClick);
- }
- config.macros.newJournal.handler = function(place,macroName,params)
- {
- if(!readOnly)
- {
- var now = new Date();
- var title = now.formatString(params[0].trim());
- var createJournal = function() {
- displayTiddler(null,title,2,null,null,false,false);
- var tagsBox = document.getElementById("editorTags" + title);
- if(tagsBox && params[1])
- tagsBox.value += " " + String.encodeTiddlyLink(params[1]);
- };
- createTiddlyButton(place,this.label,this.prompt,createJournal);
- }
- }
- config.macros.sparkline.handler = function(place,macroName,params)
- {
- var data = [];
- var min = 0;
- var max = 0;
- for(var t=0; t<params.length; t++)
- {
- var v = parseInt(params[t]);
- if(v < min)
- min = v;
- if(v > max)
- max = v;
- data.push(v);
- }
- if(data.length < 1)
- return;
- var box = createTiddlyElement(place,"span",null,"sparkline",String.fromCharCode(160));
- box.title = data.join(",");
- var w = box.offsetWidth;
- var h = box.offsetHeight;
- box.style.paddingRight = (data.length * 2 - w) + "px";
- box.style.position = "relative";
- for(var d=0; d<data.length; d++)
- {
- var tick = document.createElement("img");
- tick.border = 0;
- tick.className = "sparktick";
- tick.style.position = "absolute";
- tick.src = "data:image/gif,GIF89a%01%00%01%00%91%FF%00%FF%FF%FF%00%00%00%C0%C0%C0%00%00%00!%F9%04%01%00%00%02%00%2C%00%00%00%00%01%00%01%00%40%02%02T%01%00%3B";
- tick.style.left = d*2 + "px";
- tick.style.width = "2px";
- var v = Math.floor(((data[d] - min)/(max-min)) * h);
- tick.style.top = (h-v) + "px";
- tick.style.height = v + "px";
- box.appendChild(tick);
- }
- }
- config.macros.tabs.handler = function(place,macroName,params)
- {
- var cookie = params[0];
- var numTabs = (params.length-1)/3;
- var wrapper = createTiddlyElement(place,"div",null,cookie,null);
- var tabset = createTiddlyElement(wrapper,"div",null,"tabset",null);
- tabset.setAttribute("cookie",cookie);
- var validTab = false;
- for(var t=0; t<numTabs; t++)
- {
- var label = params[t*3+1];
- var prompt = params[t*3+2];
- var content = params[t*3+3];
- var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
- tab.setAttribute("href","javascript:;");
- tab.onclick = this.onClickTab;
- tab.setAttribute("tab",label);
- tab.setAttribute("content",content);
- tab.title = prompt;
- if(config.options[cookie] == label)
- validTab = true;
- }
- if(!validTab)
- config.options[cookie] = params[1];
- this.switchTab(tabset,config.options[cookie]);
- }
- config.macros.tabs.onClickTab = function(e)
- {
- config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
- }
- config.macros.tabs.switchTab = function(tabset,tab)
- {
- var cookie = tabset.getAttribute("cookie");
- var theTab = null
- var nodes = tabset.childNodes;
- for(var t=0; t<nodes.length; t++)
- if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab)
- {
- theTab = nodes[t];
- theTab.className = "tab tabSelected";
- }
- else
- nodes[t].className = "tab tabUnselected"
- if(theTab)
- {
- if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
- tabset.parentNode.removeChild(tabset.nextSibling);
- var tabContent = createTiddlyElement(null,"div",null,"tabContents",null);
- tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
- wikify(store.getTiddlerText(theTab.getAttribute("content")),tabContent,null,null);
- if(cookie)
- {
- config.options[cookie] = tab;
- saveOptionCookie(cookie);
- }
- }
- }
- // ---------------------------------------------------------------------------------
- // Config and macro stuff
- // ---------------------------------------------------------------------------------
- // Merge a custom configuration over the top of the current configuration
- // Returns a string error message or null if it went OK
- function processConfig(customConfig)
- {
- try
- {
- if(customConfig && customConfig != "")
- window.eval(customConfig);
- }
- catch(e)
- {
- return(e.toString());
- }
- return null;
- }
- // Render a macro
- function insertMacro(place,macroName,macroParams)
- {
- var params = macroParams.readMacroParams();
- try
- {
- var macro = config.macros[macroName];
- if(macro && macro.handler)
- macro.handler(place,macroName,params);
- else
- createTiddlyElement(place,"span",null,"errorNoSuchMacro","<<" + macroName + ">>");
- }
- catch(e)
- {
- displayMessage(config.messages.macroError.format([macroName]));
- displayMessage(e.toString());
- }
- }
- // ---------------------------------------------------------------------------------
- // Tiddler() object
- // ---------------------------------------------------------------------------------
- function Tiddler()
- {
- this.title = null;
- this.text = null;
- this.modifier = null;
- this.modified = new Date();
- this.links = [];
- this.tags = [];
- return this;
- }
- // Load a tiddler from an HTML DIV
- Tiddler.prototype.loadFromDiv = function(divRef,title)
- {
- var text = Tiddler.unescapeLineBreaks(divRef.firstChild ? divRef.firstChild.nodeValue : "");
- var modifier = divRef.getAttribute("modifier");
- var modified = Date.convertFromYYYYMMDDHHMM(divRef.getAttribute("modified"));
- var tags = divRef.getAttribute("tags");
- this.set(title,text,modifier,modified,tags);
- return this;
- }
- // Format the text for storage in an HTML DIV
- Tiddler.prototype.saveToDiv = function()
- {
- return '<div tiddler="' + this.title + '" modified="' +
- this.modified.convertToYYYYMMDDHHMM() + '" modifier="' + this.modifier +
- '" tags="' + this.getTags() + '">' +
- this.escapeLineBreaks().htmlEncode() + '</div>';
- }
- // Format the text for storage in an RSS item
- Tiddler.prototype.saveToRss = function(url)
- {
- var s = [];
- s.push("<item>");
- s.push("<title>" + this.title.htmlEncode() + "</title>");
- s.push("<description>" + this.text.replace(regexpNewLine,"<br />").htmlEncode() + "</description>");
- for(var t=0; t<this.tags.length; t++)
- s.push("<category>" + this.tags[t] + "</category>");
- s.push("<link>" + url + "#" + encodeURIComponent(String.encodeTiddlyLink(this.title)) + "</link>");
- s.push("<pubDate>" + this.modified.toGMTString() + "</pubDate>");
- s.push("</item>");
- return(s.join("\n"));
- }
- // Change the text and other attributes of a tiddler
- Tiddler.prototype.set = function(title,text,modifier,modified,tags)
- {
- if(title != undefined)
- this.title = title;
- if(text != undefined)
- this.text = text;
- if(modifier != undefined)
- this.modifier = modifier;
- if(modified != undefined)
- this.modified = modified;
- if(tags != undefined)
- this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
- else
- this.tags = [];
- this.changed();
- return this;
- }
- // Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
- Tiddler.prototype.getTags = function()
- {
- if(this.tags)
- {
- var results = [];
- for(var t=0; t<this.tags.length; t++)
- results.push(String.encodeTiddlyLink(this.tags[t]));
- return results.join(" ");
- }
- else
- return "";
- }
- 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");
- // Static method to Convert "\n" to newlines, "\s" to "\"
- Tiddler.unescapeLineBreaks = function(text)
- {
- if(text && text != "")
- return text.replace(regexpBackSlashEn,"\n").replace(regexpBackSlashEss,"\\").replace(regexpCarriageReturn,"");
- else
- return "";
- }
- // Convert newlines to "\n", "\" to "\s"
- Tiddler.prototype.escapeLineBreaks = function()
- {
- return this.text.replace(regexpBackSlash,"\\s").replace(regexpNewLine,"\\n").replace(regexpCarriageReturn,"");
- }
- // Updates the secondary information (like links[] array) after a change to a tiddler
- Tiddler.prototype.changed = function()
- {
- this.links = [];
- var nextPos = 0;
- var theLink;
- do {
- var formatMatch = wikiNameRegExp.exec(this.text);
- if(formatMatch)
- {
- if(!formatMatch[1] && formatMatch[2] && formatMatch[2] != this.title)
- this.links.pushUnique(formatMatch[2]);
- else if(formatMatch[4] && store.tiddlers[formatMatch[5]] != undefined)
- this.links.pushUnique(formatMatch[5]);
- else if(formatMatch[6] && formatMatch[6] != this.title)
- this.links.pushUnique(formatMatch[6]);
- }
- } while(formatMatch);
- return;
- }
- Tiddler.prototype.getSubtitle = function()
- {
- var theModifier = this.modifier;
- if(!theModifier)
- theModifier = config.messages.subtitleUnknown;
- var theModified = this.modified;
- if(theModified)
- theModified = theModified.toLocaleString();
- else
- theModified = config.messages.subtitleUnknown;
- return(theModifier + ", " + theModified);
- }
- // ---------------------------------------------------------------------------------
- // TiddlyWiki() object contains Tiddler()s
- // ---------------------------------------------------------------------------------
- function TiddlyWiki()
- {
- this.tiddlers = {}; // Hashmap by name of tiddlers
- this.namedNotifications = {}; // Hashmap by name of array of notification functions
- this.blanketNotifications = []; // Array of blanket notifications to be invoked on any change
- this.dirty = false;
- }
- // Set the dirty flag
- TiddlyWiki.prototype.setDirty = function(dirty)
- {
- this.dirty = dirty;
- }
- // Invoke the notification handlers for a particular tiddler
- TiddlyWiki.prototype.notify = function(title,doBlanket)
- {
- var notification = this.namedNotifications[title];
- if(notification)
- for(var t=0; t<notification.length; t++)
- notification[t](title);
- if(doBlanket)
- for(var n=0; n<this.blanketNotifications.length; n++)
- this.blanketNotifications[n](title);
- }
- // Invoke the notification handlers for all tiddlers
- TiddlyWiki.prototype.notifyAll = function()
- {
- var notifyTitle;
- for(notifyTitle in this.tiddlers)
- this.notify(notifyTitle,false);
- for(notifyTitle in config.shadowTiddlers)
- if(this.tiddlers[notifyTitle] == undefined)
- this.notify(notifyTitle,false);
- for(var n=0; n<this.blanketNotifications.length; n++)
- this.blanketNotifications[n]();
- }
- // Add a notification handler to a tiddler
- TiddlyWiki.prototype.addNotification = function(title,fn)
- {
- var notification;
- if(title)
- {
- notification = this.namedNotifications[title];
- if(!notification)
- {
- notification = [];
- this.namedNotifications[title] = notification;
- }
- }
- else
- notification = this.blanketNotifications;
- notification.push(fn);
- return this;
- }
- // Clear a TiddlyWiki so that it contains no tiddlers
- TiddlyWiki.prototype.clear = function(src)
- {
- this.tiddlers = {};
- this.dirty = false;
- }
- TiddlyWiki.prototype.removeTiddler = function(title)
- {
- var tiddler = this.tiddlers[title];
- if(tiddler)
- {
- delete this.tiddlers[title];
- this.notify(title,true);
- this.dirty = true;
- }
- }
- TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
- {
- if(!title)
- return(defaultText);
- var tiddler = this.tiddlers[title];
- if(tiddler)
- return tiddler.text;
- else if(config.shadowTiddlers[title])
- return config.shadowTiddlers[title];
- else if(defaultText)
- return defaultText;
- else
- return null;
- }
- TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,ignoreList)
- {
- var childIgnoreList = ignoreList ? ignoreList : {};
- childIgnoreList[title] = true;
- var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
- var text = this.getTiddlerText(title,defaultText);
- if(text == null)
- return "";
- var textOut = [];
- var lastPos = 0;
- do {
- var match = bracketRegExp.exec(text);
- if(match)
- {
- textOut.push(text.substr(lastPos,match.index-lastPos));
- if(match[1])
- {
- if(childIgnoreList[match[1]])
- textOut.push(match[1]);
- else
- {
- var subText = this.getRecursiveTiddlerText(match[1],match[1],childIgnoreList);
- textOut.push(subText);
- }
- }
- lastPos = match.index + match[1].length + 4;
- }
- else
- textOut.push(text.substr(lastPos));
- } while(match);
- delete childIgnoreList[title];
- return(textOut.join(""));
- }
- TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags)
- {
- var tiddler = this.tiddlers[title];
- if(tiddler)
- delete this.tiddlers[title];
- else
- tiddler = new Tiddler();
- tiddler.set(newTitle,newBody,modifier,modified,tags);
- this.tiddlers[newTitle] = tiddler;
- if(title != newTitle)
- this.notify(title,true);
- this.notify(newTitle,true);
- this.dirty = true;
- return tiddler;
- }
- TiddlyWiki.prototype.createTiddler = function(title)
- {
- tiddler = this.tiddlers[title];
- if(!tiddler)
- {
- tiddler = new Tiddler();
- this.tiddlers[title] = tiddler;
- this.dirty = true;
- }
- return tiddler;
- }
- // Load contents of a tiddlywiki from an HTML DIV
- TiddlyWiki.prototype.loadFromDiv = function(srcID,idPrefix)
- {
- if(document.normalize)
- document.normalize();
- var lenPrefix = idPrefix.length;
- var store = document.getElementById(srcID).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 = this.createTiddler(title);
- tiddler.loadFromDiv(e,title);
- }
- }
- this.dirty = false;
- }
- // Return an array of tiddlers matching a search string
- TiddlyWiki.prototype.search = function(searchText,caseSensitive,useRegExp,sortField,excludeTag)
- {
- if (!useRegExp)
- searchText = searchText.escapeRegExp();
- var regExp = new RegExp(searchText,caseSensitive ? "m" : "im");
- var candidates = this.reverseLookup("tags",excludeTag,false);
- var results = [];
- for(var t=0; t<candidates.length; t++)
- {
- if(regExp.test(candidates[t].title) || regExp.test(candidates[t].text))
- results.push(candidates[t]);
- }
- if(!sortField)
- sortField = "title";
- results.sort(function (a,b) {if(a[sortField] == b[sortField]) return(0); else return (a[sortField] < b[sortField]) ? -1 : +1; });
- return results;
- }
- // Return an array of all the tags in use. Each member of the array is another array where [0] is the name of the tag and [1] is the number of occurances
- TiddlyWiki.prototype.getTags = function()
- {
- var results = [];
- for(var t in this.tiddlers)
- {
- var tiddler = this.tiddlers[t];
- for(g=0; g<tiddler.tags.length; g++)
- {
- var tag = tiddler.tags[g];
- var f = false;
- for(var c=0; c<results.length; c++)
- if(results[c][0] == tag)
- {
- f = true;
- results[c][1]++;
- }
- if(!f)
- results.push([tag,1]);
- }
- }
- results.sort(function (a,b) {if(a[0] == b[0]) return(0); else return (a[0] < b[0]) ? -1 : +1; });
- return results;
- }
- // Return an array of the tiddlers that are tagged with a given tag
- TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
- {
- return this.reverseLookup("tags",tag,true,sortField);
- }
- // Return an array of the tiddlers that link to a given tiddler
- TiddlyWiki.prototype.getReferringTiddlers = function(title,exclude,sortField)
- {
- return this.reverseLookup("links",title,true,sortField);
- }
- // Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
- // lookupMatch == true to match tiddlers, false to exclude tiddlers
- TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
- {
- var results = [];
- for(var t in this.tiddlers)
- {
- var tiddler = this.tiddlers[t];
- var f = !lookupMatch;
- for(var lookup=0; lookup<tiddler[lookupField].length; lookup++)
- if(tiddler[lookupField][lookup] == lookupValue)
- f = lookupMatch;
- if(f)
- results.push(tiddler);
- }
- if(!sortField)
- sortField = "title";
- results.sort(function (a,b) {if(a[sortField] == b[sortField]) return(0); else return (a[sortField] < b[sortField]) ? -1 : +1; });
- return results;
- }
- // Return the tiddlers as a sorted array
- TiddlyWiki.prototype.getTiddlers = function(field)
- {
- var results = [];
- for(var t in this.tiddlers)
- results.push(this.tiddlers[t]);
- if(field)
- results.sort(function (a,b) {if(a[field] == b[field]) return(0); else return (a[field] < b[field]) ? -1 : +1; });
- return results;
- }
- // Return array of names of tiddlers that are referred to but not defined
- TiddlyWiki.prototype.getMissingLinks = function(sortField)
- {
- var results = [];
- for(var t in this.tiddlers)
- {
- var tiddler = this.tiddlers[t];
- for(var n=0; n<tiddler.links.length;n++)
- {
- var link = tiddler.links[n];
- if(this.tiddlers[link] == null)
- results.pushUnique(link);
- }
- }
- results.sort();
- return results;
- }
- // Return an array of names of tiddlers that are defined but not referred to
- TiddlyWiki.prototype.getOrphans = function()
- {
- var results = [];
- for(var t in this.tiddlers)
- if(this.getReferringTiddlers(t).length == 0)
- results.push(t);
- results.sort();
- return results;
- }
- // ---------------------------------------------------------------------------------
- // Tiddler functions
- // ---------------------------------------------------------------------------------
- // Display several tiddlers from a list of space separated titles
- function displayTiddlers(src,titles,state,highlightText,highlightCaseSensitive,animate,slowly)
- {
- var tiddlerNames = titles.readBracketedList();
- for(var t = tiddlerNames.length-1;t>=0;t--)
- displayTiddler(src,tiddlerNames[t],state,highlightText,highlightCaseSensitive,animate,slowly);
- }
- // Display a tiddler with animation and scrolling, as though a link to it has been clicked on
- // src = source element object (eg link) for animation effects and positioning
- // title = title of tiddler to display
- // state = 0 is default or current state, 1 is read only and 2 is edittable
- // highlightText = text to highlight in the displayed tiddler
- // highlightCaseSensitive = flag for whether the highlight text is case sensitive
- function displayTiddler(src,title,state,highlightText,highlightCaseSensitive,animate,slowly)
- {
- var place = document.getElementById("tiddlerDisplay");
- var after = findContainingTiddler(src); // Which tiddler this one will be positioned after
- var before;
- if(after == null)
- before = place.firstChild;
- else if(after.nextSibling)
- before = after.nextSibling;
- else
- before = null;
- var theTiddler = createTiddler(place,before,title,state,highlightText,highlightCaseSensitive);
- if(src)
- {
- if(config.options.chkAnimate && (animate == undefined || animate == true))
- anim.startAnimating(new Zoomer(title,src,theTiddler,slowly),new Scroller(theTiddler,slowly));
- else
- window.scrollTo(0,ensureVisible(theTiddler));
- }
- }
- // Create a tiddler if it doesn't exist (with no fancy animating)
- // place = parent element
- // before = node before which to create/move the tiddler
- // title = title of tiddler to display
- // state = 0 is default or current state, 1 is read only and 2 is edittable
- // highlightText = text to highlight in the displayed tiddler
- // highlightCaseSensitive = flag for whether the highlight text is case sensitive
- function createTiddler(place,before,title,state,highlightText,highlightCaseSensitive)
- {
- var theTiddler = createTiddlerSkeleton(place,before,title);
- createTiddlerTitle(title,highlightText,highlightCaseSensitive);
- var theViewer = document.getElementById("viewer" + title);
- var theEditor = document.getElementById("editorWrapper" + title);
- switch(state)
- {
- case 0:
- if(!theViewer && !theEditor)
- {
- createTiddlerToolbar(title,false);
- createTiddlerViewer(title,highlightText,highlightCaseSensitive);
- createTiddlerFooter(title,false);
- }
- break;
- case 1: // Viewer
- if(theViewer)
- theViewer.parentNode.removeChild(theViewer);
- if(theEditor)
- theEditor.parentNode.removeChild(theEditor);
- createTiddlerToolbar(title,false);
- createTiddlerViewer(title,highlightText,highlightCaseSensitive);
- createTiddlerFooter(title,false);
- break;
- case 2: // Editor
- if(!theEditor)
- {
- if(theViewer)
- theViewer.parentNode.removeChild(theViewer);
- createTiddlerToolbar(title,true);
- createTiddlerEditor(title);
- createTiddlerFooter(title,true);
- }
- break;
- }
- return(theTiddler);
- }
- function refreshTiddler(title)
- {
- var theViewer = document.getElementById("viewer" + title);
- if(theViewer)
- {
- theViewer.parentNode.removeChild(theViewer);
- createTiddlerViewer(title,null,null);
- }
- }
- function createTiddlerSkeleton(place,before,title)
- {
- var theTiddler = document.getElementById("tiddler" + title);
- if(!theTiddler)
- {
- theTiddler = createTiddlyElement(null,"div","tiddler" + title,"tiddler",null);
- theTiddler.onmouseover = onMouseOverTiddler;
- theTiddler.onmouseout = onMouseOutTiddler;
- theTiddler.ondblclick = onDblClickTiddler;
- var theInnerTiddler = createTiddlyElement(theTiddler,"div",null,"unselectedTiddler",null);
- var theToolbar = createTiddlyElement(theInnerTiddler,"div","toolbar" + title,"toolbar", null);
- var theTitle = createTiddlyElement(theInnerTiddler,"div","title" + title,"title",null);
- var theBody = createTiddlyElement(theInnerTiddler,"div","body" + title,"body",null);
- var theFooter = createTiddlyElement(theInnerTiddler,"div","footer" + title,"footer",null);
- place.insertBefore(theTiddler,before);
- }
- return(theTiddler);
- }
- function createTiddlerTitle(title,highlightText,highlightCaseSensitive)
- {
- var theTitle = document.getElementById("title" + title);
- if(theTitle)
- {
- removeChildren(theTitle);
- if(highlightText == "")
- highlightText = null;
- var highlightRegExp,highlightMatch;
- if(highlightText)
- {
- highlightRegExp = new RegExp(highlightText,highlightCaseSensitive ? "mg" : "img");
- highlightMatch = highlightRegExp.exec(title);
- }
- highlightMatch = subWikify(theTitle,title,0,title.length,highlightRegExp,highlightMatch);
- var tiddler = store.tiddlers[title];
- if(tiddler)
- theTitle.title = tiddler.getSubtitle();
- }
- }
- // Create a tiddler toolbar according to whether it's an editor or not
- function createTiddlerToolbar(title,isEditor)
- {
- var theToolbar = document.getElementById("toolbar" + title);
- var lingo = config.views;
- if(theToolbar)
- {
- removeChildren(theToolbar);
- insertSpacer(theToolbar);
- if(isEditor)
- {
- // Editor toolbar
- lingo = lingo.editor;
- createTiddlyButton(theToolbar,lingo.toolbarDone.text,lingo.toolbarDone.tooltip,onClickToolbarSave);
- insertSpacer(theToolbar);
- createTiddlyButton(theToolbar,lingo.toolbarCancel.text,lingo.toolbarCancel.tooltip,onClickToolbarUndo);
- insertSpacer(theToolbar);
- createTiddlyButton(theToolbar,lingo.toolbarDelete.text,lingo.toolbarDelete.tooltip,onClickToolbarDelete);
- }
- else
- {
- // Viewer toolbar
- lingo = lingo.wikified;
- createTiddlyButton(theToolbar,lingo.toolbarClose.text,lingo.toolbarClose.tooltip,onClickToolbarClose);
- insertSpacer(theToolbar);
- if(!readOnly)
- {
- createTiddlyButton(theToolbar,lingo.toolbarEdit.text,lingo.toolbarEdit.tooltip,onClickToolbarEdit);
- insertSpacer(theToolbar);
- }
- createTiddlyButton(theToolbar,lingo.toolbarPermalink.text,lingo.toolbarPermalink.tooltip,onClickToolbarPermaLink);
- insertSpacer(theToolbar);
- createTiddlyButton(theToolbar,lingo.toolbarReferences.text,lingo.toolbarReferences.tooltip,onClickToolbarReferences);
- }
- insertSpacer(theToolbar);
- }
- }
- function createTiddlerPopup(srcElement)
- {
- var popup = document.getElementById("popup");
- if(popup && popup.nextSibling == srcElement)
- {
- hideTiddlerPopup();
- return null;
- }
- if(popup)
- popup.parentNode.removeChild(popup);
- popup = createTiddlyElement(null,"div","popup",null,null);
- var leftPx = srcElement.offsetLeft;
- var topPx = srcElement.offsetTop;
- var heightPx = srcElement.offsetHeight;
- if (leftPx <= 1 && srcElement.parentNode.offsetLeft > 0)
- leftPx = srcElement.parentNode.offsetLeft;
- if (topPx <= 1 && srcElement.parentNode.offsetTop > 0)
- topPx = srcElement.parentNode.offsetTop;
- if (heightPx <= 1 && srcElement.parentNode.offsetHeight > 0)
- heightPx = srcElement.parentNode.offsetHeight;
- popup.style.left = leftPx + "px";
- popup.style.top = topPx + heightPx + "px";
- popup.style.display = "block";
- srcElement.onmouseout = onMouseOutTiddlerPopup;
- srcElement.appendChild(popup);
- return popup;
- }
- function scrollToTiddlerPopup(popup,slowly)
- {
- if(config.options.chkAnimate)
- anim.startAnimating(new Scroller(popup,slowly));
- else
- window.scrollTo(0,ensureVisible(popup));
- }
- function onMouseOutTiddlerPopup(e)
- {
- if (!e) var e = window.event;
- var related = (e.relatedTarget) ? e.relatedTarget : e.toElement;
- try
- {
- while (related != this && related && related.nodeName && related.nodeName.toLowerCase() != "body")
- related = related.parentNode;
- }
- catch(e)
- {
- related = null;
- }
- if(related != this)
- {
- this.onmouseout = null;
- hideTiddlerPopup();
- }
- e.cancelBubble = true;
- if (e.stopPropagation) e.stopPropagation();
- return(false);
- }
- function hideTiddlerPopup()
- {
- var popup = document.getElementById("popup");
- if(popup)
- popup.parentNode.removeChild(popup);
- }
- // Create the body section of a read-only tiddler
- function createTiddlerViewer(title,highlightText,highlightCaseSensitive,htmlElement)
- {
- var theBody = document.getElementById("body" + title);
- if(theBody)
- {
- var tiddler = store.tiddlers[title];
- var tiddlerText = store.getTiddlerText(title);
- var theViewer = createTiddlyElement(theBody,htmlElement ? htmlElement : "div","viewer" + title,"viewer",null);
- if(tiddler)
- theViewer.setAttribute("tags",tiddler.tags.join(" "));
- if(tiddlerText == null)
- {
- tiddlerText = config.views.wikified.defaultText.format([title]);
- theViewer.style.fontStyle = "italic";
- }
- wikify(tiddlerText,theViewer,highlightText,highlightCaseSensitive);
- }
- }
- // Create the footer section of a tiddler
- function createTiddlerFooter(title,isEditor)
- {
- var theFooter = document.getElementById("footer" + title);
- var tiddler = store.tiddlers[title];
- if(theFooter && tiddler)
- {
- removeChildren(theFooter);
- insertSpacer(theFooter);
- if(isEditor)
- {
- }
- else
- {
- var lingo = config.views.wikified.tag;
- var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags;
- var theTags = createTiddlyElement(theFooter,"div",null,null,prompt);
- for(var t=0; t<tiddler.tags.length; t++)
- {
- var theTag = createTagButton(theTags,tiddler.tags[t],tiddler.title);
- insertSpacer(theTags);
- }
- }
- }
- }
- // Create a button for a tag with a popup listing all the tiddlers that it tags
- function createTagButton(place,tag,excludeTiddler)
- {
- var theTag = createTiddlyButton(place,tag,config.views.wikified.tag.tooltip.format([tag]),onClickTag);
- theTag.setAttribute("tag",tag);
- if(excludeTiddler)
- theTag.setAttribute("tiddler",excludeTiddler);
- return(theTag);
- }
- // Create the body section of an edittable tiddler
- function createTiddlerEditor(title)
- {
- var theBody = document.getElementById("body" + title);
- if(theBody)
- {
- var tiddlerText = store.getTiddlerText(title);
- var tiddlerExists = (tiddlerText != null);
- if(!tiddlerExists)
- tiddlerText = config.views.editor.defaultText.format([title]);
- var theEditor = createTiddlyElement(theBody,"div","editorWrapper" + title,"editor",null);
- theEditor.onkeypress = onEditKey;
- var theTitleBox = createTiddlyElement(theEditor,"input","editorTitle" + title,null,null);
- theTitleBox.setAttribute("type","text");
- theTitleBox.value = title;
- theTitleBox.setAttribute("size","40");
- var theBodyBox = createTiddlyElement(theEditor,"textarea","editorBody" + title,null,null);
- theBodyBox.value = tiddlerText;
- var rows = 10;
- var lines = tiddlerText.match(regexpNewLine);
- if(lines != null && lines.length > rows)
- rows = lines.length + 5;
- theBodyBox.setAttribute("rows",rows);
- var theTagsBox = createTiddlyElement(theEditor,"input","editorTags" + title,null,null);
- theTagsBox.setAttribute("type","text");
- var tiddler = store.tiddlers[title];
- theTagsBox.value = tiddler ? tiddler.getTags() : "";
- theTagsBox.setAttribute("size","40");
- var tagPrompt = createTiddlyElement(theEditor,"div",null,"editorFooter",config.views.editor.tagPrompt);
- insertSpacer(tagPrompt);
- var lingo = config.views.editor.tagChooser;
- var addTag = createTiddlyButton(tagPrompt,lingo.text,lingo.tooltip,onClickAddTag);
- addTag.setAttribute("tiddler",title);
- theBodyBox.focus();
- }
- }
- function saveTiddler(title)
- {
- var titleBox = document.getElementById("editorTitle" + title);
- var newTitle = titleBox.value;
- if(store.tiddlers[newTitle])
- {
- if(newTitle != title && !confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
- {
- titleBox.focus();
- titleBox.select();
- return;
- }
- }
- var body = document.getElementById("editorBody" + title);
- var newBody = body.value;
- var newTags = document.getElementById("editorTags" + title).value;
- blurTiddler(title);
- store.saveTiddler(title,newTitle,newBody.replace(regexpCarriageReturn,""),config.options.txtUserName,new Date(),newTags);
- displayTiddler(null,newTitle,1,null,null,null,false,false);
- // Close the old tiddler if this is a rename
- if(title != newTitle)
- {
- var oldTiddler = document.getElementById("tiddler" + title);
- var newTiddler = document.getElementById("tiddler" + newTitle);
- oldTiddler.parentNode.replaceChild(newTiddler,oldTiddler);
- }
- if(config.options.chkAutoSave)
- saveChanges();
- }
- function selectTiddler(title)
- {
- var e = document.getElementById("tiddler" + title);
- if(e != null)
- e.firstChild.className = "selectedTiddler";
- }
- function deselectTiddler(title)
- {
- var e = document.getElementById("tiddler" + title);
- if(e != null)
- e.firstChild.className = "unselectedTiddler";
- }
- function blurTiddler(title)
- {
- var body = document.getElementById("editorBody" + title);
- if(title)
- {
- body.focus();
- body.blur();
- }
- }
- function deleteTiddler(title)
- {
- closeTiddler(title,false);
- store.removeTiddler(title);
- // Autosave
- if(config.options.chkAutoSave)
- saveChanges();
- }
- function closeTiddler(title,slowly)
- {
- var tiddler = document.getElementById("tiddler" + title);
- if(tiddler != null)
- {
- scrubIds(tiddler);
- if(config.options.chkAnimate)
- anim.startAnimating(new Slider(tiddler,false,slowly,"all"));
- else
- tiddler.parentNode.removeChild(tiddler);
- }
- }
- function scrubIds(e)
- {
- if(e.id)
- e.id = null;
- var children = e.childNodes;
- for(var t=0; t<children.length; t++)
- {
- var c = children[t];
- if(c.id)
- c.id = null;
- }
- }
- function closeAllTiddlers()
- {
- clearMessage();
- var place = document.getElementById("tiddlerDisplay");
- var tiddler = place.firstChild;
- var nextTiddler;
- while(tiddler)
- {
- nextTiddler = tiddler.nextSibling;
- if(tiddler.id)
- if(tiddler.id.substr(0,7) == "tiddler")
- {
- var title = tiddler.id.substr(7);
- if(!document.getElementById("editorWrapper" + title))
- place.removeChild(tiddler);
- }
- tiddler = nextTiddler;
- }
- }
- // ---------------------------------------------------------------------------------
- // Regular expression stuff
- // ---------------------------------------------------------------------------------
- var upperLetter = "[A-Z\u00c0-\u00de\u0150\u0170]";
- var lowerLetter = "[a-z\u00df-\u00ff_0-9\\-\u0151\u0171]";
- var anyLetter = "[A-Za-z\u00c0-\u00de\u00df-\u00ff_0-9\\-\u0150\u0170\u0151\u0171]";
- var anyDigit = "[0-9]";
- var anyNumberChar = "[0-9\\.E]";
- var wikiNamePattern = "(~?)((?:" + upperLetter + "+" + lowerLetter + "+" + upperLetter + anyLetter + "*)|(?:" + upperLetter + "{2,}" + lowerLetter + "+))";
- var urlPattern = "((?:http|https|mailto|ftp):[^\\s'\"]+(?:/|\\b))";
- var explicitLinkPattern = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
- var bracketNamePattern = "\\[\\[([^\\]]+)\\]\\]";
- var wikiNamePatterns;
- var wikiNameRegExp;
- var structurePatterns;
- var stylePatterns;
- var tableRegExp;
- var tableRowColRegExp;
- var invalidPreWikiNamePattern;
- function setupRegexp()
- {
- // Table rows pattern
- var rowPattern = "^\\|([^\\n]*\\|)([fhc]?)$";
- tableRegExp = new RegExp(rowPattern,"mg");
- // Table columns pattern
- var elementPattern = "(?:(?:BGCOLOR|bgcolor)\\(([^\\)]+)\\):)?" +
- "("+
- "("+explicitLinkPattern+")?"+
- "("+bracketNamePattern+")?" +
- "[^\\|]*"+
- ")\\|";
- tableRowColRegExp = new RegExp(elementPattern,"g");
- // Link patterns
- wikiNamePatterns = "(?:" + wikiNamePattern +
- ")|(?:" + urlPattern +
- ")|(?:" + explicitLinkPattern +
- ")|(?:" + bracketNa…
Large files files are truncated, but you can click here to view the full file