Sugar OS (OLPC)
OLPC.html — HTML, 450 kB (461797 bytes)
Continguts del fitxer
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script id="versionArea" type="text/javascript"> //<![CDATA[ var version = {title: "TiddlyWiki", major: 2, minor: 4, revision: 0, date: new Date("May 9, 2008"), extensions: {}}; //]]> </script> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="copyright" content=" TiddlyWiki created by Jeremy Ruston, (jeremy [at] osmosoft [dot] com) Copyright (c) UnaMesa Association 2004-2008 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 UnaMesa Association 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. " /> <!--PRE-HEAD-START--> <!--{{{--> <link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/> <!--}}}--> <!--PRE-HEAD-END--> <title> One Laptop Per Child - Azúcar! </title> <style id="styleArea" type="text/css"> #saveTest {display:none;} #messageArea {display:none;} #copyright {display:none;} #storeArea {display:none;} #storeArea div {padding:0.5em; margin:1em 0em 0em 0em; border-color:#fff #666 #444 #ddd; border-style:solid; border-width:2px; overflow:auto;} #shadowArea {display:none;} #javascriptWarning {width:100%; text-align:center; font-weight:bold; background-color:#dd1100; color:#fff; padding:1em 0em;} </style> <!--POST-HEAD-START--> <!--POST-HEAD-END--> </head> <body onload="main();" onunload="if(window.checkUnsavedChanges) checkUnsavedChanges(); if(window.scrubNodes) scrubNodes(document.body);"> <!--PRE-BODY-START--> <!--PRE-BODY-END--> <div id="copyright"> Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association </div> <noscript> <div id="javascriptWarning">This page requires JavaScript to function properly.<br /><br />If you are using Microsoft Internet Explorer you may need to click on the yellow bar above and select 'Allow Blocked Content'. You must then click 'Yes' on the following security warning.</div> </noscript> <div id="saveTest"></div> <div id="backstageCloak"></div> <div id="backstageButton"></div> <div id="backstageArea"><div id="backstageToolbar"></div></div> <div id="backstage"> <div id="backstagePanel"></div> </div> <div id="contentWrapper"></div> <div id="contentStash"></div> <div id="shadowArea"> <div title="MarkupPreHead"> <pre><!--{{{--> <link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/> <!--}}}--></pre> </div> <div title="ColorPalette"> <pre>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</pre> </div> <div title="StyleSheetColors"> <pre>/*{{{*/ body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];} a {color:[[ColorPalette::PrimaryMid]];} a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];} a img {border:0;} h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;} h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];} h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];} .button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];} .button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];} .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];} .header {background:[[ColorPalette::PrimaryMid]];} .headerShadow {color:[[ColorPalette::Foreground]];} .headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];} .headerForeground {color:[[ColorPalette::Background]];} .headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];} .tabSelected{color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border-left:1px solid [[ColorPalette::TertiaryLight]]; border-top:1px solid [[ColorPalette::TertiaryLight]]; border-right:1px solid [[ColorPalette::TertiaryLight]]; } .tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];} .tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];} .tabContents .button {border:0;} #sidebar {} #sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];} #sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];} #sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];} #sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];} #sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];} .wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];} .wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;} .wizard h2 {color:[[ColorPalette::Foreground]]; border:none;} .wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]]; border:1px solid [[ColorPalette::PrimaryMid]];} .wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];} .wizardFooter {background:[[ColorPalette::PrimaryPale]];} .wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];} .wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid; border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];} .wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];} .wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid; border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];} #messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];} #messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;} .popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];} .popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];} .popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;} .popup li.disabled {color:[[ColorPalette::TertiaryMid]];} .popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;} .popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;} .popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;} .popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];} .listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];} .tiddler .defaultCommand {font-weight:bold;} .shadow .title {color:[[ColorPalette::TertiaryDark]];} .title {color:[[ColorPalette::SecondaryDark]];} .subtitle {color:[[ColorPalette::TertiaryDark]];} .toolbar {color:[[ColorPalette::PrimaryMid]];} .toolbar a {color:[[ColorPalette::TertiaryLight]];} .selected .toolbar a {color:[[ColorPalette::TertiaryMid]];} .selected .toolbar a:hover {color:[[ColorPalette::Foreground]];} .tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];} .selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];} .tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];} .tagging .button, .tagged .button {border:none;} .footer {color:[[ColorPalette::TertiaryLight]];} .selected .footer {color:[[ColorPalette::TertiaryMid]];} .sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;} .sparktick {background:[[ColorPalette::PrimaryDark]];} .error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];} .warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];} .lowlight {background:[[ColorPalette::TertiaryLight]];} .zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];} .imageLink, #displayArea .imageLink {background:transparent;} .annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];} .viewer .listTitle {list-style-type:none; margin-left:-2em;} .viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];} .viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];} .viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];} .viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];} .viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];} .viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];} .viewer code {color:[[ColorPalette::SecondaryDark]];} .viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];} .highlight, .marked {background:[[ColorPalette::SecondaryLight]];} .editor input {border:1px solid [[ColorPalette::PrimaryMid]];} .editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;} .editorFooter {color:[[ColorPalette::TertiaryMid]];} #backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];} #backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;} #backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; } #backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];} #backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;} #backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;} #backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];} .backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];} .backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];} #backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';} /*}}}*/</pre> </div> <div title="StyleSheetLayout"> <pre>/*{{{*/ * html .tiddler {height:1%;} body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;} h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;} h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;} h4,h5,h6 {margin-top:1em;} h1 {font-size:1.35em;} h2 {font-size:1.25em;} h3 {font-size:1.1em;} h4 {font-size:1em;} h5 {font-size:.9em;} hr {height:1px;} a {text-decoration:none;} dt {font-weight:bold;} ol {list-style-type:decimal;} ol ol {list-style-type:lower-alpha;} ol ol ol {list-style-type:lower-roman;} ol ol ol ol {list-style-type:decimal;} ol ol ol ol ol {list-style-type:lower-alpha;} ol ol ol ol ol ol {list-style-type:lower-roman;} ol ol ol ol ol ol ol {list-style-type:decimal;} .txtOptionInput {width:11em;} #contentWrapper .chkOptionInput {border:0;} .externalLink {text-decoration:underline;} .indent {margin-left:3em;} .outdent {margin-left:3em; text-indent:-3em;} code.escaped {white-space:nowrap;} .tiddlyLinkExisting {font-weight:bold;} .tiddlyLinkNonExisting {font-style:italic;} /* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */ a.tiddlyLinkNonExisting.shadow {font-weight:bold;} #mainMenu .tiddlyLinkExisting, #mainMenu .tiddlyLinkNonExisting, #sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;} #sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;} .header {position:relative;} .header a:hover {background:transparent;} .headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;} .headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;} .siteTitle {font-size:3em;} .siteSubtitle {font-size:1.2em;} #mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;} #sidebar {position:absolute; right:3px; width:16em; font-size:.9em;} #sidebarOptions {padding-top:0.3em;} #sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;} #sidebarOptions input {margin:0.4em 0.5em;} #sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;} #sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;} #sidebarOptions .sliderPanel input {margin:0 0 .3em 0;} #sidebarTabs .tabContents {width:15em; overflow:hidden;} .wizard {padding:0.1em 1em 0em 2em;} .wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;} .wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;} .wizardStep {padding:1em 1em 1em 1em;} .wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;} .wizardFooter {padding:0.8em 0.4em 0.8em 0em;} .wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;} .wizard .button {padding:0.1em 0.2em 0.1em 0.2em;} #messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;} .messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;} #messageArea a {text-decoration:underline;} .tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;} .popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;} .popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;} .popup .popupMessage {padding:0.4em;} .popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;} .popup li.disabled {padding:0.4em;} .popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;} .listBreak {font-size:1px; line-height:1px;} .listBreak div {margin:2px 0;} .tabset {padding:1em 0em 0em 0.5em;} .tab {margin:0em 0em 0em 0.25em; padding:2px;} .tabContents {padding:0.5em;} .tabContents ul, .tabContents ol {margin:0; padding:0;} .txtMainTab .tabContents li {list-style:none;} .tabContents li.listLink { margin-left:.75em;} #contentWrapper {display:block;} #splashScreen {display:none;} #displayArea {margin:1em 17em 0em 14em;} .toolbar {text-align:right; font-size:.9em;} .tiddler {padding:1em 1em 0em 1em;} .missing .viewer,.missing .title {font-style:italic;} .title {font-size:1.6em; font-weight:bold;} .missing .subtitle {display:none;} .subtitle {font-size:1.1em;} .tiddler .button {padding:0.2em 0.4em;} .tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;} .isTag .tagging {display:block;} .tagged {margin:0.5em; float:right;} .tagging, .tagged {font-size:0.9em; padding:0.25em;} .tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;} .tagClear {clear:both;} .footer {font-size:.9em;} .footer li {display:inline;} .annotation {padding:0.5em; margin:0.5em;} * html .viewer pre {width:99%; padding:0 0 1em 0;} .viewer {line-height:1.4em; padding-top:0.5em;} .viewer .button {margin:0em 0.25em; padding:0em 0.25em;} .viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;} .viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;} .viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;} .viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;} table.listView {font-size:0.85em; margin:0.8em 1.0em;} table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;} .viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;} .viewer code {font-size:1.2em; line-height:1.4em;} .editor {font-size:1.1em;} .editor input, .editor textarea {display:block; width:100%; font:inherit;} .editorFooter {padding:0.25em 0em; font-size:.9em;} .editorFooter .button {padding-top:0px; padding-bottom:0px;} .fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;} .sparkline {line-height:1em;} .sparktick {outline:0;} .zoomer {font-size:1.1em; position:absolute; overflow:hidden;} .zoomer div {padding:1em;} * html #backstage {width:99%;} * html #backstageArea {width:99%;} #backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;} #backstageToolbar {position:relative;} #backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;} #backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;} #backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;} #backstage {position:relative; width:100%; z-index:50;} #backstagePanel {display:none; z-index:100; position:absolute; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;} .backstagePanelFooter {padding-top:0.2em; float:right;} .backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;} #backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;} .whenBackstage {display:none;} .backstageVisible .whenBackstage {display:block;} /*}}}*/</pre> </div> <div title="StyleSheetLocale"> <pre>/*** StyleSheet for use when a translation requires any css style changes. This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes. ***/ /*{{{*/ body {font-size:0.8em;} #sidebarOptions {font-size:1.05em;} #sidebarOptions a {font-style:normal;} #sidebarOptions .sliderPanel {font-size:0.95em;} .subtitle {font-size:0.8em;} .viewer table.listView {font-size:0.95em;} /*}}}*/</pre> </div> <div title="StyleSheetPrint"> <pre>/*{{{*/ @media print { #mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;} #displayArea {margin: 1em 1em 0em 1em;} /* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */ noscript {display:none;} } /*}}}*/</pre> </div> <div title="PageTemplate"> <pre><!--{{{--> <div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'> <div class='headerShadow'> <span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp; <span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span> </div> <div class='headerForeground'> <span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp; <span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span> </div> </div> <div id='mainMenu' refresh='content' tiddler='MainMenu'></div> <div id='sidebar'> <div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div> <div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div> </div> <div id='displayArea'> <div id='messageArea'></div> <div id='tiddlerDisplay'></div> </div> <!--}}}--></pre> </div> <div title="ViewTemplate"> <pre><!--{{{--> <div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div> <div class='title' macro='view title'></div> <div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div> <div class='tagging' macro='tagging'></div> <div class='tagged' macro='tags'></div> <div class='viewer' macro='view text wikified'></div> <div class='tagClear'></div> <!--}}}--></pre> </div> <div title="EditTemplate"> <pre><!--{{{--> <div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></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> <!--}}}--></pre> </div> <div title="GettingStarted"> <pre>To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers: * SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar) * MainMenu: The menu (usually on the left) * DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened You'll also need to enter your username for signing your edits: <<option txtUserName>></pre> </div> <div title="OptionsPanel"> <pre>These InterfaceOptions for customising TiddlyWiki are saved in your browser Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs) <<option txtUserName>> <<option chkSaveBackups>> SaveBackups <<option chkAutoSave>> AutoSave <<option chkRegExpSearch>> RegExpSearch <<option chkCaseSensitiveSearch>> CaseSensitiveSearch <<option chkAnimate>> EnableAnimations ---- Also see AdvancedOptions</pre> </div> <div title="ImportTiddlers"> <pre><<importTiddlers>></pre> </div> </div> <!--POST-SHADOWAREA--> <div id="storeArea"> <div title="Allan Kay" modifier="Xavier" created="200807042118" modified="200807052343" tags="slide [[Thinking BIG: Education]]" changecount="11"> <pre>!Allan Kay * Of object-oriented, Xerox PARC, ~SmallTalk, ~GUIs, *... fame [>img[http://croquetconsortium.org/images/1/16/Kay.jpg][http://en.wikipedia.org/wiki/Alan_Kay]] * 2003 Turing Award for work on object-oriented programming * Education software projects: Squeak, eToys, [[Croquet|http://croquetconsortium.org/index.php/Overview]]... * 2006 ~EuroPython Key Note: //Children First// ([[Post by Guido on it|http://www.artima.com/weblogs/viewpost.jsp?thread=167318]]) {{attribution{ (Aside: if interested in education and/or metaverses, do take a look to [[Croquet|http://www.youtube.com/watch?v=etBpUcNGVlU]]!) }}}</pre> </div> <div title="CloseOnCancelPlugin" modifier="MPTW" created="200803080053" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|CloseOnCancelPlugin| |Description:|Closes the tiddler if you click new tiddler then cancel. Default behaviour is to leave it open| |Version:|3.0.1 ($Rev: 3861 $)| |Date:|$Date: 2008-03-08 10:53:09 +1000 (Sat, 08 Mar 2008) $| |Source:|http://mptw.tiddlyspot.com/#CloseOnCancelPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| ***/ //{{{ merge(config.commands.cancelTiddler,{ handler_mptw_orig_closeUnsaved: config.commands.cancelTiddler.handler, handler: function(event,src,title) { this.handler_mptw_orig_closeUnsaved(event,src,title); if (!store.tiddlerExists(title) && !store.isShadowTiddler(title)) story.closeTiddler(title,true); return false; } }); //}}} </pre> </div> <div title="ColorPalette" modifier="Xavier" created="200807031933" changecount="1"> <pre>Name: MptwGreen Background: #fff Foreground: #000 PrimaryPale: #9b9 PrimaryLight: #385 PrimaryMid: #031 PrimaryDark: #020 SecondaryPale: #ffc SecondaryLight: #fe8 SecondaryMid: #db4 SecondaryDark: #841 TertiaryPale: #eee TertiaryLight: #ccc TertiaryMid: #999 TertiaryDark: #666 Error: #f88 </pre> </div> <div title="Constructionism" modifier="Xavier" created="200807042042" modified="200807052344" tags="slide [[Thinking BIG: Education]]" changecount="8"> <pre>!Constructionism * learning-by-making ** learning as a reconstruction rather than as a transmission of knowledge ([[Constructivism|http://en.wikipedia.org/wiki/Constructivism_%28learning_theory%29]] - Jean Piaget) ** learning is most effective when part of an activity the learner experiences as constructing a meaningful product {{attribution{ http://en.wikipedia.org/wiki/Constructionism_%28learning_theory%29 }}} </pre> </div> <div title="DefaultTiddlers" modifier="Xavier" created="200807040637" modified="200807060106" changecount="4"> <pre>[[Hola!]]</pre> </div> <div title="Dynabook" modifier="Xavier" created="200807040629" modified="200807050521" changecount="5"> <pre>[img[http://wiki.laptop.org/images/c/c3/XO-2-strip.jpg]]</pre> </div> <div title="ExtendTagButtonPlugin" modifier="MPTW" created="200803080053" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|ExtentTagButtonPlugin| |Description:|Adds a New tiddler button in the tag drop down| |Version:|3.2 ($Rev: 3861 $)| |Date:|$Date: 2008-03-08 10:53:09 +1000 (Sat, 08 Mar 2008) $| |Source:|http://mptw.tiddlyspot.com/#ExtendTagButtonPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License|http://mptw.tiddlyspot.com/#TheBSDLicense| ***/ //{{{ window.onClickTag_mptw_orig = window.onClickTag; window.onClickTag = function(e) { window.onClickTag_mptw_orig.apply(this,arguments); var tag = this.getAttribute("tag"); var title = this.getAttribute("tiddler"); // Thanks Saq, you're a genius :) var popup = Popup.stack[Popup.stack.length-1].popup; createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div"); wikify("<<newTiddler label:'New tiddler' tag:'"+tag+"'>>",createTiddlyElement(popup,"li")); return false; } //}}} </pre> </div> <div title="GreenMachineStyle" modifier="Xavier" created="200807032003" modified="200807040659" tags="css" changecount="27"> <pre>body { background: #93D511; color: #000; } .tiddler { background-color: #93D511; background-image: url('http://wiki.laptop.org/skins/common/images/OLPC_wiki_logo.png'); background-repeat: no-repeat; background-attachment:fixed; background-position: 1% 1%; padding: 1em 1em 0.5em 1em; margin-bottom: 1em; border: none; } .viewer { margin-left:10%; margin-right:10%; } .viewer .button { background: #e4ff70; color: #000; border: none; } .viewer .button:hover { background: #228b22; color: #fffaae; } .title { background: #E3EE0C; -moz-border-radius: 0.5em; padding: 0.2em; margin: 0.1em 2em 0.1em 2em; text-align:center; } .slideFooterOff #navigator{ visibility: visible; } /* remove clock .slideClock{ display: none; }*/</pre> </div> <div title="HideWhenPlugin" modifier="MPTW" created="200803121603" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|HideWhenPlugin| |Description:|Allows conditional inclusion/exclusion in templates| |Version:|3.1 ($Rev: 3919 $)| |Date:|$Date: 2008-03-13 02:03:12 +1000 (Thu, 13 Mar 2008) $| |Source:|http://mptw.tiddlyspot.com/#HideWhenPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| For use in ViewTemplate and EditTemplate. Example usage: {{{<div macro="showWhenTagged Task">[[TaskToolbar]]</div>}}} {{{<div macro="showWhen tiddler.modifier == 'BartSimpson'"><img src="bart.gif"/></div>}}} ***/ //{{{ window.hideWhenLastTest = false; window.removeElementWhen = function(test,place) { window.hideWhenLastTest = test; if (test) { removeChildren(place); place.parentNode.removeChild(place); } }; merge(config.macros,{ hideWhen: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( eval(paramString), place); }}, showWhen: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( !eval(paramString), place); }}, hideWhenTagged: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( tiddler.tags.containsAll(params), place); }}, showWhenTagged: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( !tiddler.tags.containsAll(params), place); }}, hideWhenTaggedAny: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( tiddler.tags.containsAny(params), place); }}, showWhenTaggedAny: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( !tiddler.tags.containsAny(params), place); }}, hideWhenTaggedAll: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( tiddler.tags.containsAll(params), place); }}, showWhenTaggedAll: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( !tiddler.tags.containsAll(params), place); }}, hideWhenExists: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( store.tiddlerExists(params[0]) || store.isShadowTiddler(params[0]), place); }}, showWhenExists: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( !(store.tiddlerExists(params[0]) || store.isShadowTiddler(params[0])), place); }}, hideWhenTitleIs: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( tiddler.title == params[0], place); }}, showWhenTitleIs: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( tiddler.title != params[0], place); }}, 'else': { handler: function(place,macroName,params,wikifier,paramString,tiddler) { removeElementWhen( !window.hideWhenLastTest, place); }} }); //}}} </pre> </div> <div title="Hola!" modifier="Xavier" created="200807060050" modified="200807060109" changecount="11"> <pre>[[View the OLPC Presentation|One Laptop Per Child]] Notes: * This is [[TiddlyWiki|http://tiddlywiki.com/]], a brilliant single-file self-contained wiki * If you are using IE, my apologies: some content will be missing and the layout will be very ugly. * The presentation is built using Paulo Soare's [[SlideShowPlugin|http://www.math.ist.utl.pt/~psoares/addons.html#SlideShowPlugin]] ---- <<tiddler [[Jornades de Programari Lliure]]>> ---- [[View the OLPC Presentation|One Laptop Per Child]]</pre> </div> <div title="Houston! We have a problem!" modifier="Xavier" created="200807050450" modified="200807052350" tags="slide Problems" changecount="5"> <pre>!Houston! We have a problem! * Price hasn't droped as much as expected * Mass deployment is a very difficult problem * Some governments not happy with [[Constructionism]] * Some governments not happy with non Microsoft software * Microsoft not happy with millions of future decission makers growing up with Linux * Intel not happy losing market share to AMD * Part of the OLPC team not happy with [[Nicholas Negroponte]] * Part of the Open Source Community not happy with [[Nicholas Negroponte]] * Key OLPC people leaving * ...</pre> </div> <div title="InlineSlidersPlugin" modifier="YourName" created="200701261600" modified="200706070757" tags="systemConfig" server.type="file" server.host="tw.lewcid.org/sandbox" server.page.revision="200706070757"> <pre>//{{{ config.formatters.unshift( { name: "inlinesliders", match: "\\+\\+\\+\\+|\\<slider", lookaheadRegExp: /(?:\+\+\+\+|<slider) (.*?)(?:>?)\n((?:.|\n)*?)\n(?:====|<\/slider>)/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source) if(lookaheadMatch && lookaheadMatch.index == w.matchStart ) { var btn = createTiddlyButton(w.output,lookaheadMatch[1] + " "+"\u00BB",lookaheadMatch[1],this.onClickSlider,"button sliderButton"); var panel = createTiddlyElement(w.output,"div",null,"sliderPanel"); panel.style.display = "none"; wikify(lookaheadMatch[2],panel); w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length; } }, onClickSlider : function(e) { if(!e) var e = window.event; var n = this.nextSibling; n.style.display = (n.style.display=="none") ? "block" : "none"; return false; } }) //}}}</pre> </div> <div title="InlineTabsPlugin" modifier="saq" created="200702021053" modified="200702021053" tags="systemConfig" server.type="file" server.host="tw.lewcid.org/sandbox" server.page.revision="200702021053"> <pre>//{{{ config.formatters.unshift( { name: "inlinetabs", match: "\\<tabs", lookaheadRegExp: /(?:<tabs (.*)>\n)((?:.|\n)*?)(?:\n<\/tabs>)/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source) if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { var cookie = lookaheadMatch[1]; var wrapper = createTiddlyElement(null,"div",null,cookie); var tabset = createTiddlyElement(wrapper,"div",null,"tabset"); tabset.setAttribute("cookie",cookie); var validTab = false; var firstTab = ''; var tabregexp = /(?:<tab (.*)>)(?:(?:\n)?)((?:.|\n)*?)(?:<\/tab>)/mg; while((m = tabregexp.exec(lookaheadMatch[2])) != null) { if (firstTab == '') firstTab = m[1]; var tab = createTiddlyButton(tabset,m[1],m[1],story.onClickInlineTab,"tab tabUnselected"); tab.setAttribute("tab",m[1]); tab.setAttribute("content",m[2]); tab.title = m[1]; if(config.options[cookie] == m[1]) validTab = true; } if(!validTab) config.options[cookie] = firstTab; w.output.appendChild(wrapper); story.switchInlineTab(tabset,config.options[cookie]); w.nextMatch = this.lookaheadRegExp.lastIndex; } } }) Story.prototype.switchInlineTab = 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"); tabset.parentNode.insertBefore(tabContent,tabset.nextSibling); wikify(theTab.getAttribute("content"),tabContent); if(cookie) { config.options[cookie] = tab; saveOptionCookie(cookie); } } } Story.prototype.onClickInlineTab = function(e) { story.switchInlineTab(this.parentNode,this.getAttribute("tab")); return false; } //}}}</pre> </div> <div title="InstantTimestampPlugin" modifier="MPTW" created="200805181400" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|InstantTimestampPlugin| |Description:|A handy way to insert timestamps in your tiddler content| |Version:|1.0.10 ($Rev: 3646 $)| |Date:|$Date: 2008-02-27 02:34:38 +1000 (Wed, 27 Feb 2008) $| |Source:|http://mptw.tiddlyspot.com/#InstantTimestampPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| !!Usage If you enter {ts} in your tiddler content (without the spaces) it will be replaced with a timestamp when you save the tiddler. Full list of formats: * {ts} or {t} -> timestamp * {ds} or {d} -> datestamp * !ts or !t at start of line -> !!timestamp * !ds or !d at start of line -> !!datestamp (I added the extra ! since that's how I like it. Remove it from translations below if required) !!Notes * Change the timeFormat and dateFormat below to suit your preference. * See also http://mptw2.tiddlyspot.com/#AutoCorrectPlugin * You could invent other translations and add them to the translations array below. ***/ //{{{ config.InstantTimestamp = { // adjust to suit timeFormat: 'DD/0MM/YY 0hh:0mm', dateFormat: 'DD/0MM/YY', translations: [ [/^!ts?$/img, "'!!{{ts{'+now.formatString(config.InstantTimestamp.timeFormat)+'}}}'"], [/^!ds?$/img, "'!!{{ds{'+now.formatString(config.InstantTimestamp.dateFormat)+'}}}'"], // thanks Adapted Cat [/\{ts?\}(?!\}\})/ig,"'{{ts{'+now.formatString(config.InstantTimestamp.timeFormat)+'}}}'"], [/\{ds?\}(?!\}\})/ig,"'{{ds{'+now.formatString(config.InstantTimestamp.dateFormat)+'}}}'"] ], excludeTags: [ "noAutoCorrect", "noTimestamp", "html", "CSS", "css", "systemConfig", "systemConfigDisabled", "zsystemConfig", "Plugins", "Plugin", "plugins", "plugin", "javascript", "code", "systemTheme", "systemPalette" ], excludeTiddlers: [ "StyleSheet", "StyleSheetLayout", "StyleSheetColors", "StyleSheetPrint" // more? ] }; TiddlyWiki.prototype.saveTiddler_mptw_instanttimestamp = TiddlyWiki.prototype.saveTiddler; TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created) { tags = tags ? tags : []; // just in case tags is null tags = (typeof(tags) == "string") ? tags.readBracketedList() : tags; var conf = config.InstantTimestamp; if ( !tags.containsAny(conf.excludeTags) && !conf.excludeTiddlers.contains(newTitle) ) { var now = new Date(); var trans = conf.translations; for (var i=0;i<trans.length;i++) { newBody = newBody.replace(trans[i][0], eval(trans[i][1])); } } // TODO: use apply() instead of naming all args? return this.saveTiddler_mptw_instanttimestamp(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created); } // you can override these in StyleSheet setStylesheet(".ts,.ds { font-style:italic; }","instantTimestampStyles"); //}}} </pre> </div> <div title="Jornades de Programari Lliure" modifier="Xavier" created="200807040548" modified="200807060100" tags="slide Intro" changecount="20"> <pre>{{centerColumn{ [img[http://www.jornadespl.org/logo.jpg][http://www.jornadespl.org/]] [img[http://img.meetup.com/img/logo/small/p/python.png][http://python.meetup.com/185/]] Barcelona, 2008/07/05 Xavier Vergés xverges at gmail.com [[XdeXavier.verg.es|http://xdexavier.verg.es]] [>img[Creative Commons License|http://i.creativecommons.org/l/by/2.5/es/88x31.png][http://creativecommons.org/licenses/by/2.5/es/]] }}}</pre> </div> <div title="LCD" modifier="Xavier" created="200807050106" modified="200807052346" tags="slide Technology" changecount="11"> <pre>!Display * Displays are the most expensive component of any laptop, and a very significan power drain[>img[http://pixelqi.com/yahoo_site_admin/assets/images/closer_closeup_mlj.5123739_std.jpg]] * [[Mary Lou Jepsen|http://en.wikipedia.org/wiki/Mary_Lou_Jepsen]], former Chief Technology Officer at OLPC, invented a low consumption, inexpensive, dual mode display * Perception-wise resolution: 1200x900 gray (sunlit, or room with backlight off), 1024x768 color (room with backlight on); 800x600 closet (total darkness) * Official/simpler story: "1200x900 (mono), 693x520 (color)" {{midImage{ [img[http://upload.wikimedia.org/wikipedia/commons/c/cb/XO_screen_01_Pengo.jpg][http://wiki.laptop.org/go/Display]]}}} </pre> </div> <div title="LessBackupsPlugin" modifier="MPTW" created="200803240532" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|LessBackupsPlugin| |Description:|Intelligently limit the number of backup files you create| |Version:|3.0.1 ($Rev: 2320 $)| |Date:|$Date: 2007-06-18 22:37:46 +1000 (Mon, 18 Jun 2007) $| |Source:|http://mptw.tiddlyspot.com/#LessBackupsPlugin| |Author:|Simon Baird| |Email:|simon.baird@gmail.com| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| !!Description You end up with just backup one per year, per month, per weekday, per hour, minute, and second. So total number won't exceed about 200 or so. Can be reduced by commenting out the seconds/minutes/hours line from modes array !!Notes Works in IE and Firefox only. Algorithm by Daniel Baird. IE specific code by by Saq Imtiaz. ***/ //{{{ var MINS = 60 * 1000; var HOURS = 60 * MINS; var DAYS = 24 * HOURS; if (!config.lessBackups) { config.lessBackups = { // comment out the ones you don't want or set config.lessBackups.modes in your 'tweaks' plugin modes: [ ["YYYY", 365*DAYS], // one per year for ever ["MMM", 31*DAYS], // one per month ["ddd", 7*DAYS], // one per weekday //["d0DD", 1*DAYS], // one per day of month ["h0hh", 24*HOURS], // one per hour ["m0mm", 1*HOURS], // one per minute ["s0ss", 1*MINS], // one per second ["latest",0] // always keep last version. (leave this). ] }; } window.getSpecialBackupPath = function(backupPath) { var now = new Date(); var modes = config.lessBackups.modes; for (var i=0;i<modes.length;i++) { // the filename we will try var specialBackupPath = backupPath.replace(/(\.)([0-9]+\.[0-9]+)(\.html)$/, '$1'+now.formatString(modes[i][0]).toLowerCase()+'$3') // open the file try { if (config.browser.isIE) { var fsobject = new ActiveXObject("Scripting.FileSystemObject") var fileExists = fsobject.FileExists(specialBackupPath); if (fileExists) { var fileObject = fsobject.GetFile(specialBackupPath); var modDate = new Date(fileObject.DateLastModified).valueOf(); } } else { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(specialBackupPath); var fileExists = file.exists(); if (fileExists) { var modDate = file.lastModifiedTime; } } } catch(e) { // give up return backupPath; } // expiry is used to tell if it's an 'old' one. Eg, if the month is June and there is a // June file on disk that's more than an month old then it must be stale so overwrite // note that "latest" should be always written because the expiration period is zero (see above) var expiry = new Date(modDate + modes[i][1]); if (!fileExists || now > expiry) return specialBackupPath; } } // hijack the core function window.getBackupPath_mptw_orig = window.getBackupPath; window.getBackupPath = function(localPath) { return getSpecialBackupPath(getBackupPath_mptw_orig(localPath)); } //}}} </pre> </div> <div title="MPTW" modifier="MPTW" created="200803080020" modified="200806181402"> <pre>MPTW is a distribution or edition of TiddlyWiki that includes a standard TiddlyWiki core packaged with some plugins designed to improve usability and provide a better way to organise your information. For more information see http://mptw.tiddlyspot.com/. </pre> </div> <div title="MainMenu" modifier="Xavier" created="200807040637" modified="200807060054" changecount="3"> <pre>[[View the OLPC Presentation|One Laptop Per Child]]</pre> </div> <div title="Mission Statement" modifier="Xavier" created="200807050406" modified="200807052342" tags="slide [[Thinking BIG: Education]]" changecount="4"> <pre>!Mission Statement [img[http://laptop.org/img/mission.jpg]] To create educational opportunities for the world's poorest children by providing each child with a rugged, low-cost, low-power, connected laptop with content and software designed for collaborative, joyful, self-empowered learning.</pre> </div> <div title="MptwBlack" modifier="MPTW" created="200803062257" modified="200806181402" tags="systemPalette"> <pre>Name: MptwBlack Background: #000 Foreground: #fff PrimaryPale: #333 PrimaryLight: #555 PrimaryMid: #888 PrimaryDark: #aaa SecondaryPale: #111 SecondaryLight: #222 SecondaryMid: #555 SecondaryDark: #888 TertiaryPale: #222 TertiaryLight: #666 TertiaryMid: #888 TertiaryDark: #aaa Error: #300 This is in progress. Help appreciated. </pre> </div> <div title="MptwBlue" modifier="MPTW" created="200803062257" modified="200806181402" tags="systemPalette"> <pre>Name: MptwBlue Background: #fff Foreground: #000 PrimaryPale: #cdf PrimaryLight: #57c PrimaryMid: #114 PrimaryDark: #012 SecondaryPale: #ffc SecondaryLight: #fe8 SecondaryMid: #db4 SecondaryDark: #841 TertiaryPale: #eee TertiaryLight: #ccc TertiaryMid: #999 TertiaryDark: #666 Error: #f88 </pre> </div> <div title="MptwConfigPlugin" modifier="MPTW" created="200806181402" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|MptwConfigPlugin| |Description:|Miscellaneous tweaks used by MPTW| |Version:|1.0 ($Rev: 3646 $)| |Date:|$Date: 2008-02-27 02:34:38 +1000 (Wed, 27 Feb 2008) $| |Source:|http://mptw.tiddlyspot.com/#MptwConfigPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#MptwConfigPlugin| !!Note: instead of editing this you should put overrides in MptwUserConfigPlugin ***/ //{{{ var originalReadOnly = readOnly; var originalShowBackstage = showBackstage; config.options.chkHttpReadOnly = false; // means web visitors can experiment with your site by clicking edit readOnly = false; // needed because the above doesn't work any more post 2.1 (??) showBackstage = true; // show backstage for same reason config.options.chkInsertTabs = true; // tab inserts a tab when editing a tiddler config.views.wikified.defaultText = ""; // don't need message when a tiddler doesn't exist config.views.editor.defaultText = ""; // don't need message when creating a new tiddler config.options.chkSaveBackups = true; // do save backups config.options.txtBackupFolder = 'twbackup'; // put backups in a backups folder config.options.chkAutoSave = (window.location.protocol == "file:"); // do autosave if we're in local file config.mptwVersion = "2.4.5"; config.macros.mptwVersion={handler:function(place){wikify(config.mptwVersion,place);}}; if (config.options.txtTheme == '') config.options.txtTheme = 'MptwTheme'; // add to default GettingStarted config.shadowTiddlers.GettingStarted += "\n\nSee also [[MPTW]]."; // add select theme and palette controls in default OptionsPanel config.shadowTiddlers.OptionsPanel = config.shadowTiddlers.OptionsPanel.replace(/(\n\-\-\-\-\nAlso see AdvancedOptions)/, "{{select{<<selectTheme>>\n<<selectPalette>>}}}$1"); // these are used by ViewTemplate config.mptwDateFormat = 'DD/MM/YY'; config.mptwJournalFormat = 'Journal DD/MM/YY'; //}}} </pre> </div> <div title="MptwGreen" modifier="MPTW" created="200803062256" modified="200806181402" tags="systemPalette"> <pre>Name: MptwGreen Background: #fff Foreground: #000 PrimaryPale: #9b9 PrimaryLight: #385 PrimaryMid: #031 PrimaryDark: #020 SecondaryPale: #ffc SecondaryLight: #fe8 SecondaryMid: #db4 SecondaryDark: #841 TertiaryPale: #eee TertiaryLight: #ccc TertiaryMid: #999 TertiaryDark: #666 Error: #f88 </pre> </div> <div title="MptwRed" modifier="MPTW" created="200803062256" modified="200806181402" tags="systemPalette"> <pre>Name: MptwRed Background: #fff Foreground: #000 PrimaryPale: #eaa PrimaryLight: #c55 PrimaryMid: #711 PrimaryDark: #500 SecondaryPale: #ffc SecondaryLight: #fe8 SecondaryMid: #db4 SecondaryDark: #841 TertiaryPale: #eee TertiaryLight: #ccc TertiaryMid: #999 TertiaryDark: #666 Error: #f88 </pre> </div> <div title="MptwRoundTheme" modifier="MPTW" created="200804271350" modified="200806181402" tags="systemTheme"> <pre>|Name|MptwRounded| |Description|Mptw Theme with some rounded corners (Firefox only)| |ViewTemplate|MptwTheme##ViewTemplate| |EditTemplate|MptwTheme##EditTemplate| |PageTemplate|MptwTheme##PageTemplate| |StyleSheet|##StyleSheet| !StyleSheet /*{{{*/ [[MptwTheme##StyleSheet]] .tiddler, .sliderPanel, .button, .tiddlyLink, .tabContents { -moz-border-radius: 1em; } .tab { -moz-border-radius-topleft: 0.5em; -moz-border-radius-topright: 0.5em; } #topMenu { -moz-border-radius-bottomleft: 2em; -moz-border-radius-bottomright: 2em; } /*}}}*/ </pre> </div> <div title="MptwSmoke" modifier="MPTW" created="200803062256" modified="200806181402" tags="systemPalette"> <pre>Name: MptwSmoke Background: #fff Foreground: #000 PrimaryPale: #aaa PrimaryLight: #777 PrimaryMid: #111 PrimaryDark: #000 SecondaryPale: #ffc SecondaryLight: #fe8 SecondaryMid: #db4 SecondaryDark: #841 TertiaryPale: #eee TertiaryLight: #ccc TertiaryMid: #999 TertiaryDark: #666 Error: #f88 </pre> </div> <div title="MptwStandardTheme" modifier="MPTW" created="200804250142" modified="200806181402" tags="systemTheme"> <pre>|Name|MptwStandard| |Description|Mptw Theme with the default TiddlyWiki PageLayout and Styles| |ViewTemplate|MptwTheme##ViewTemplate| |EditTemplate|MptwTheme##EditTemplate| </pre> </div> <div title="MptwTeal" modifier="MPTW" created="200803062256" modified="200806181402" tags="systemPalette"> <pre>Name: MptwTeal Background: #fff Foreground: #000 PrimaryPale: #B5D1DF PrimaryLight: #618FA9 PrimaryMid: #1a3844 PrimaryDark: #000 SecondaryPale: #ffc SecondaryLight: #fe8 SecondaryMid: #db4 SecondaryDark: #841 TertiaryPale: #f8f8f8 TertiaryLight: #bbb TertiaryMid: #999 TertiaryDark: #888 Error: #f88 </pre> </div> <div title="MptwTheme" modifier="MPTW" created="200804250140" modified="200806181402" tags="systemTheme"> <pre>|Name|MptwTheme| |Description|Mptw Theme including custom PageLayout| |PageTemplate|##PageTemplate| |ViewTemplate|##ViewTemplate| |EditTemplate|##EditTemplate| |StyleSheet|##StyleSheet| http://mptw.tiddlyspot.com/#MptwTheme ($Rev: 1829 $) !PageTemplate <!--{{{--> <div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'> <div class='headerShadow'> <span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp; <span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span> </div> <div class='headerForeground'> <span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp; <span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span> </div> </div> <!-- horizontal MainMenu --> <div id='topMenu' refresh='content' tiddler='MainMenu'></div> <!-- original MainMenu menu --> <!-- <div id='mainMenu' refresh='content' tiddler='MainMenu'></div> --> <div id='sidebar'> <div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div> <div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div> </div> <div id='displayArea'> <div id='messageArea'></div> <div id='tiddlerDisplay'></div> </div> <!--}}}--> !ViewTemplate <!--{{{--> [[MptwTheme##ViewTemplateToolbar]] <div class="tagglyTagged" macro="tags"></div> <div class='titleContainer'> <span class='title' macro='view title'></span> <span macro="miniTag"></span> </div> <div class='subtitle'> (updated <span macro='view modified date {{config.mptwDateFormat?config.mptwDateFormat:"MM/0DD/YY"}}'></span> by <span macro='view modifier link'></span>) <!-- (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date {{config.mptwDateFormat?config.mptwDateFormat:"MM/0DD/YY"}}'></span>) --> </div> <div macro="showWhen tiddler.tags.containsAny(['css','html','pre','systemConfig']) && !tiddler.text.match('{{'+'{')"> <div class='viewer'><pre macro='view text'></pre></div> </div> <div macro="else"> <div class='viewer' macro='view text wikified'></div> </div> <div class="tagglyTagging" macro="tagglyTagging"></div> <!--}}}--> !ViewTemplateToolbar <!--{{{--> <div class='toolbar'> <span macro="showWhenTagged systemConfig"> <span macro="toggleTag systemConfigDisable . '[[disable|systemConfigDisable]]'"></span> </span> <span macro="showWhenTagged systemTheme"><span macro="applyTheme"></span></span> <span macro="showWhenTagged systemPalette"><span macro="applyPalette"></span></span> <span macro="showWhen tiddler.tags.contains('css') || tiddler.title == 'StyleSheet'"><span macro="refreshAll"></span></span> <span style="padding:1em;"></span> <span macro='toolbar closeTiddler closeOthers +editTiddler deleteTiddler > fields syncing permalink references jump'></span> <span macro='newHere label:"new here"'></span> <span macro='newJournalHere {{config.mptwJournalFormat?config.mptwJournalFormat:"MM/0DD/YY"}}'></span> </div> <!--}}}--> !EditTemplate <!--{{{--> <div class="toolbar" macro="toolbar +saveTiddler saveCloseTiddler closeOthers -cancelTiddler cancelCloseTiddler deleteTiddler"></div> <div class="title" macro="view title"></div> <div class="editLabel">Title</div><div class="editor" macro="edit title"></div> <div macro='annotations'></div> <div class="editLabel">Content</div><div class="editor" macro="edit text"></div> <div class="editLabel">Tags</div><div class="editor" macro="edit tags"></div> <div class="editorFooter"><span macro="message views.editor.tagPrompt"></span><span macro="tagChooser"></span></div> <!--}}}--> !StyleSheet /*{{{*/ /* a contrasting background so I can see where one tiddler ends and the other begins */ body { background: [[ColorPalette::TertiaryLight]]; } /* sexy colours and font for the header */ .headerForeground { color: [[ColorPalette::PrimaryPale]]; } .headerShadow, .headerShadow a { color: [[ColorPalette::PrimaryMid]]; } /* separate the top menu parts */ .headerForeground, .headerShadow { padding: 1em 1em 0; } .headerForeground, .headerShadow { font-family: 'Trebuchet MS' sans-serif; font-weight:bold; } .headerForeground .siteSubtitle { color: [[ColorPalette::PrimaryLight]]; } .headerShadow .siteSubtitle { color: [[ColorPalette::PrimaryMid]]; } /* make shadow go and down right instead of up and left */ .headerShadow { left: 1px; top: 1px; } /* prefer monospace for editing */ .editor textarea, .editor input { font-family: 'Consolas' monospace; background-color:[[ColorPalette::TertiaryPale]]; } /* sexy tiddler titles */ .title { font-size: 250%; color: [[ColorPalette::PrimaryLight]]; font-family: 'Trebuchet MS' sans-serif; } /* more subtle tiddler subtitle */ .subtitle { padding:0px; margin:0px; padding-left:1em; font-size: 90%; color: [[ColorPalette::TertiaryMid]]; } .subtitle .tiddlyLink { color: [[ColorPalette::TertiaryMid]]; } /* a little bit of extra whitespace */ .viewer { padding-bottom:3px; } /* don't want any background color for headings */ h1,h2,h3,h4,h5,h6 { background-color: transparent; color: [[ColorPalette::Foreground]]; } /* give tiddlers 3d style border and explicit background */ .tiddler { background: [[ColorPalette::Background]]; border-right: 2px [[ColorPalette::TertiaryMid]] solid; border-bottom: 2px [[ColorPalette::TertiaryMid]] solid; margin-bottom: 1em; padding:1em 2em 2em 1.5em; } /* make options slider look nicer */ #sidebarOptions .sliderPanel { border:solid 1px [[ColorPalette::PrimaryLight]]; } /* the borders look wrong with the body background */ #sidebar .button { border-style: none; } /* this means you can put line breaks in SidebarOptions for readability */ #sidebarOptions br { display:none; } /* undo the above in OptionsPanel */ #sidebarOptions .sliderPanel br { display:inline; } /* horizontal main menu stuff */ #displayArea { margin: 1em 15.7em 0em 1em; /* use the freed up space */ } #topMenu br { display: none; } #topMenu { background: [[ColorPalette::PrimaryMid]]; color:[[ColorPalette::PrimaryPale]]; } #topMenu { padding:2px; } #topMenu .button, #topMenu .tiddlyLink, #topMenu a { margin-left: 0.5em; margin-right: 0.5em; padding-left: 3px; padding-right: 3px; color: [[ColorPalette::PrimaryPale]]; font-size: 115%; } #topMenu .button:hover, #topMenu .tiddlyLink:hover { background: [[ColorPalette::PrimaryDark]]; } /* make 2.2 act like 2.1 with the invisible buttons */ .toolbar { visibility:hidden; } .selected .toolbar { visibility:visible; } /* experimental. this is a little borked in IE7 with the button * borders but worth it I think for the extra screen realestate */ .toolbar { float:right; } /* fix for TaggerPlugin. from sb56637. improved by FND */ .popup li .tagger a { display:inline; } /* makes theme selector look a little better */ #sidebarOptions .sliderPanel .select .button { padding:0.5em; display:block; } #sidebarOptions .sliderPanel .select br { display:none; } /* make it print a little cleaner */ @media print { #topMenu { display: none ! important; } /* not sure if we need all the importants */ .tiddler { border-style: none ! important; margin:0px ! important; padding:0px ! important; padding-bottom:2em ! important; } .tagglyTagging .button, .tagglyTagging .hidebutton { display: none ! important; } .headerShadow { visibility: hidden ! important; } .tagglyTagged .quickopentag, .tagged .quickopentag { border-style: none ! important; } .quickopentag a.button, .miniTag { display: none ! important; } } /* get user styles specified in StyleSheet */ [[StyleSheet]] /*}}}*/ </pre> </div> <div title="MptwTrimTheme" modifier="MPTW" created="200804250141" modified="200806181402" tags="systemTheme"> <pre>|Name|MptwTrim| |Description|Mptw Theme with a reduced header to increase useful space| |ViewTemplate|MptwTheme##ViewTemplate| |EditTemplate|MptwTheme##EditTemplate| |StyleSheet|MptwTheme##StyleSheet| |PageTemplate|##PageTemplate| !PageTemplate <!--{{{--> <!-- horizontal MainMenu --> <div id='topMenu' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'> <span refresh='content' tiddler='SiteTitle' style="padding-left:1em;font-weight:bold;"></span>: <span refresh='content' tiddler='MainMenu'></span> </div> <div id='sidebar'> <div id='sidebarOptions'> <div refresh='content' tiddler='SideBarOptions'></div> <div style="margin-left:0.1em;" macro='slider chkTabSliderPanel SideBarTabs {{"tabs \u00bb"}} "Show Timeline, All, Tags, etc"'></div> </div> </div> <div id='displayArea'> <div id='messageArea'></div> <div id='tiddlerDisplay'></div> </div> </pre> </div> <div title="MptwUpgradeURL" modifier="MPTW" created="200803062254" modified="200806181402" tags="systemServer"> <pre>For upgrading. See [[ImportTiddlers]]. URL: http://mptw.tiddlyspot.com/upgrade.html </pre> </div> <div title="MptwUserConfigPlugin" modifier="MPTW" created="200804250246" modified="200806181402" tags="systemConfig"> <pre>/*** |Description:|A place to put your config tweaks so they aren't overwritten when you upgrade MPTW| See http://www.tiddlywiki.org/wiki/Configuration_Options for other options you can set. In some cases where there are clashes with other plugins it might help to rename this to zzMptwUserConfigPlugin so it gets executed last. ***/ //{{{ // example: set your preferred date format //config.mptwDateFormat = 'MM/0DD/YY'; //config.mptwJournalFormat = 'Journal MM/0DD/YY'; // example: set the theme you want to start with //config.options.txtTheme = 'MptwRoundTheme'; // example: switch off autosave, switch on backups and set a backup folder //config.options.chkSaveBackups = true; //config.options.chkAutoSave = false; //config.options.txtBackupFolder = 'backups'; //}}} </pre> </div> <div title="New Metaphores" modifier="Xavier" created="200807050353" modified="200807052348" tags="slide Technology" changecount="10"> <pre>!New Metaphores * Desktop? * Files and folders? * Overlapping windows? * Applications? WTF is an "application"? [[David Wheeler|http://en.wikipedia.org/wiki/David_Wheeler_%28computer_scientist%29]]: //Compatibility means deliberately repeating other people's mistakes//</pre> </div> <div title="NewHerePlugin" modifier="MPTW" created="200803080053" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|NewHerePlugin| |Description:|Creates the new here and new journal macros| |Version:|3.0 ($Rev: 3861 $)| |Date:|$Date: 2008-03-08 10:53:09 +1000 (Sat, 08 Mar 2008) $| |Source:|http://mptw.tiddlyspot.com/#NewHerePlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License|http://mptw.tiddlyspot.com/#TheBSDLicense| ***/ //{{{ merge(config.macros, { newHere: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { wikify("<<newTiddler "+paramString+" tag:[["+tiddler.title+"]]>>",place,null,tiddler); } }, newJournalHere: { handler: function(place,macroName,params,wikifier,paramString,tiddler) { wikify("<<newJournal "+paramString+" tag:[["+tiddler.title+"]]>>",place,null,tiddler); } } }); //}}} </pre> </div> <div title="NewMeansNewPlugin" modifier="MPTW" created="200804091514" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|NewMeansNewPlugin| |Description:|If 'New Tiddler' already exists then create 'New Tiddler (1)' and so on| |Version:|1.1 ($Rev: 2263 $)| |Date:|$Date: 2007-06-13 04:22:32 +1000 (Wed, 13 Jun 2007) $| |Source:|http://mptw.tiddlyspot.com/empty.html#NewMeansNewPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License|http://mptw.tiddlyspot.com/#TheBSDLicense| !!Note: I think this should be in the core ***/ //{{{ String.prototype.getNextFreeName = function() { var numberRegExp = / \(([0-9]+)\)$/; var match = numberRegExp.exec(this); if (match) { var num = parseInt(match[1]) + 1; return this.replace(numberRegExp," ("+num+")"); } else { return this + " (1)"; } } config.macros.newTiddler.checkForUnsaved = function(newName) { var r = false; story.forEachTiddler(function(title,element) { if (title == newName) r = true; }); return r; } config.macros.newTiddler.getName = function(newName) { while (store.getTiddler(newName) || config.macros.newTiddler.checkForUnsaved(newName)) newName = newName.getNextFreeName(); return newName; } config.macros.newTiddler.onClickNewTiddler = function() { var title = this.getAttribute("newTitle"); if(this.getAttribute("isJournal") == "true") { var now = new Date(); title = now.formatString(title.trim()); } title = config.macros.newTiddler.getName(title); // <--- only changed bit var params = this.getAttribute("params"); var tags = params ? params.split("|") : []; var focus = this.getAttribute("newFocus"); var template = this.getAttribute("newTemplate"); var customFields = this.getAttribute("customFields"); story.displayTiddler(null,title,template,false,null,null); var tiddlerElem = document.getElementById(story.idPrefix + title); if(customFields) story.addCustomFields(tiddlerElem,customFields); var text = this.getAttribute("newText"); if(typeof text == "string") story.getTiddlerField(title,"text").value = text.format([title]); for(var t=0;t<tags.length;t++) story.setTiddlerTag(title,tags[t],+1); story.focusTiddler(title,focus); return false; }; //}}} </pre> </div> <div title="Nicholas Negroponte" modifier="Xavier" created="200807042217" modified="200807052343" tags="slide tedtalks [[Thinking BIG: Education]]" changecount="17"> <pre>!Nicholas Negroponte * Of MIT Media Lab, Wired Magazine and //Being Digital// fame {{midImage{[>img[$100 Laptop Launch by dweekly, on Flickr|http://farm1.static.flickr.com/26/64221235_2dcdb61c12_d.jpg]]}}} * Self confesed "better visionary than manager" * Python? {{dummy{ >The OLPC comes with three different languages: squeak, logo and another one that I've never even seen before {{attribution{at EG (TED Talks). December 2007. [[One Laptop per Child, two years on|http://www.ted.com/index.php/talks/nicholas_negroponte_on_one_laptop_per_child_two_years_on.html]].}}} }}} </pre> </div> <div title="One Laptop Per Child" modifier="Xavier" created="200807031946" modified="200807060101" changecount="123"> <pre>Click on this button to view in much nicer presentation/powerpointish format. Use the browser in full screen mode (F11) for better layout. Things will be uglier if using IE <<slideShow noClicks style:'GreenMachineStyle' clock:'-30'>> -s- <<tiddler [[Jornades de Programari Lliure]]>> -s- <<tiddler [[Table of contents (first draft)]]>> -s- <<tiddler [[Table of contents (second draft)]]>> -s- <<tiddler [[Table of contents]]>> -s- <<tiddler [[Thinking BIG: Education]]>> -s- <<tiddler Principles>> -s- <<tiddler [[Mission Statement]]>> -s- <<tiddler [[Seymour Papert]]>> -s- <<tiddler [[Allan Kay]]>> -s- <<tiddler [[Nicholas Negroponte]]>> -s- <<tiddler Constructionism>> -s- <<tiddler [[Technology: the amazing guts of the small rabbit-eared green beast]]>> -s- <<tiddler [[Proofs of concept]]>> -s- <<tiddler LCD>> -s- <<tiddler [[Wifi and collaboration]]>> -s- <<tiddler [[Power Consumption]]>> -s- <<tiddler [[Power Generation and Batteries]]>> -s- <<tiddler Software>> -s- <<tiddler [[New Metaphores]]>> -s- <<tiddler [[Sugar is Sweet]]>> -s- <<tiddler [[Security]]>> -s- <<tiddler [[Houston! We have a problem!]]>> -s- <<tiddler [[Sic Transit Gloria Laptopi?]]>> -s- <<tiddler [[Still thinking BIG]]>> -s- <<tiddler [[The movement marches on]]>> -s- <<tiddler [[The XO-2]]>> -s- <<tiddler [[The lab 0.1]]>> -s- <<tiddler [[The lab 0.1 design]]>> -s- <<tiddler [[The lab 0.1 implementation]]>> -s- <<tiddler [[The lab 0.2]]>> -s- <<tiddler [[The lab 0.3]]>> -s- <<tiddler [[Think BIG!]]>> </pre> </div> <div title="Power Consumption" modifier="Xavier" created="200807041906" modified="200807052347" tags="slide Technology" changecount="15"> <pre>!Power Consumption * Peak consumption: 4-5 Watts (vs 40-50 Watts in a regular laptop) {{floatRight{ <html> <a href="http://www.flickr.com/photos/andycarvin/64453940/" title="$100 laptop demo at WSIS by andycarvin, on Flickr"><img src="http://farm1.static.flickr.com/33/64453940_66cad72daf.jpg" width="500" height="375" alt="$100 laptop demo at WSIS" /></a> </html> }}} * Regular use: 1-2 Watts * No Hard Drive * Very efficent display (specially when no backlight, Black and White mode) * Very aggressive power management ** Turn off everything as soon as possible ** Keep the display visible and turn off the CPU ** Keep the mesh network running and turn off the CPU</pre> </div> <div title="Power Generation and Batteries" modifier="Xavier" created="200807042334" modified="200807052347" tags="slide Technology" changecount="8"> <pre>!Power Generation and Batteries * Cheap, durable, light weight batteries (~LiFe) * Happy with almost any DC source * The inboard hand-crank was probably just a brilliant marketing idea * :-( but powering servers is a problem [img[http://www.freeplayenergy.com/resources/contentfiles/freeplayenergy/assets/images/1532/image/olpc-crank-featured.png][http://www.freeplayenergy.com/]][img[http://www.potenco.com/wp-content/themes/potenco/images/page_pics/6_big.jpg][http://www.potenco.com/whats-new/]][img[http://www.potenco.com/wp-content/uploads/2008/03/img_6057_small_1.jpg][http://www.potenco.com/whats-new/]]</pre> </div> <div title="Prelude" modifier="Xavier" created="200807040936" modified="200807041804" tags="slide" changecount="10"> <pre>!Prelude * An ugly premonition reading yesterday's feeds... {{centerText{ [[A Real Spectacle|http://indexed.blogspot.com/2008/07/real-spectacle.html]] [img[http://bp3.blogger.com/_FBXGhy-QmVw/SGzPDOGpC5I/AAAAAAAAB5A/MaAjb72JJZE/s320/card1641.JPG]] ~~by [[Jessica Hagy|http://www.jessicahagy.com]] ([[indexed.blogspot.com|indexed.blogspot.com]])~~ }}}</pre> </div> <div title="PrettyDatesPlugin" modifier="MPTW" created="200803080025" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|PrettyDatesPlugin| |Description:|Provides a new date format ('pppp') that displays times such as '2 days ago'| |Version:|1.0 ($Rev: 3646 $)| |Date:|$Date: 2008-02-27 02:34:38 +1000 (Wed, 27 Feb 2008) $| |Source:|http://mptw.tiddlyspot.com/#PrettyDatesPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| !!Notes * If you want to you can rename this plugin. :) Some suggestions: LastUpdatedPlugin, RelativeDatesPlugin, SmartDatesPlugin, SexyDatesPlugin. * Inspired by http://ejohn.org/files/pretty.js ***/ //{{{ Date.prototype.prettyDate = function() { var diff = (((new Date()).getTime() - this.getTime()) / 1000); var day_diff = Math.floor(diff / 86400); if (isNaN(day_diff)) return ""; else if (diff < 0) return "in the future"; else if (diff < 60) return "just now"; else if (diff < 120) return "1 minute ago"; else if (diff < 3600) return Math.floor(diff/60) + " minutes ago"; else if (diff < 7200) return "1 hour ago"; else if (diff < 86400) return Math.floor(diff/3600) + " hours ago"; else if (day_diff == 1) return "Yesterday"; else if (day_diff < 7) return day_diff + " days ago"; else if (day_diff < 14) return "a week ago"; else if (day_diff < 31) return Math.ceil(day_diff/7) + " weeks ago"; else if (day_diff < 62) return "a month ago"; else if (day_diff < 365) return "about " + Math.ceil(day_diff/31) + " months ago"; else if (day_diff < 730) return "a year ago"; else return Math.ceil(day_diff/365) + " years ago"; } Date.prototype.formatString_orig_mptw = Date.prototype.formatString; Date.prototype.formatString = function(template) { return this.formatString_orig_mptw(template).replace(/pppp/,this.prettyDate()); } // for MPTW. otherwise edit your ViewTemplate as required. // config.mptwDateFormat = 'pppp (DD/MM/YY)'; config.mptwDateFormat = 'pppp'; //}}} </pre> </div> <div title="Principles" modifier="Xavier" created="200807041954" modified="200807052341" tags="slide tedtalks [[Thinking BIG: Education]]" changecount="9"> <pre>!The basic principles * children are the most precious natural resource * the solution to poverty, peace, environment is education * teaching is one but not the only way to achieve learning {{attribution{Source: [[Nicholas Negroponte]] at TED. February 2006. [[The vision behind One Laptop Per Child|http://www.ted.com/index.php/talks/nicholas_negroponte_on_one_laptop_per_child.html]]. }}} </pre> </div> <div title="Proofs of concept" modifier="Xavier" created="200807042340" modified="200807052345" tags="slide Technology iframe" changecount="5"> <pre>!Proofs of concept <html> <iframe src="http://www.dcontinuum.com/content/show.php?id=4" width="100%" height="500" name="flickrFrame" scrolling="auto" frameborder="0">sorry no iframes allowed in your browser</iframe> </html></pre> </div> <div title="QuickOpenTagPlugin" modifier="MPTW" created="200803080053" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|QuickOpenTagPlugin| |Description:|Changes tag links to make it easier to open tags as tiddlers| |Version:|3.0.1 ($Rev: 3861 $)| |Date:|$Date: 2008-03-08 10:53:09 +1000 (Sat, 08 Mar 2008) $| |Source:|http://mptw.tiddlyspot.com/#QuickOpenTagPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| ***/ //{{{ config.quickOpenTag = { dropdownChar: (document.all ? "\u25bc" : "\u25be"), // the little one doesn't work in IE? createTagButton: function(place,tag,excludeTiddler) { // little hack so we can do this: <<tag PrettyTagName|RealTagName>> var splitTag = tag.split("|"); var pretty = tag; if (splitTag.length == 2) { tag = splitTag[1]; pretty = splitTag[0]; } var sp = createTiddlyElement(place,"span",null,"quickopentag"); createTiddlyText(createTiddlyLink(sp,tag,false),pretty); var theTag = createTiddlyButton(sp,config.quickOpenTag.dropdownChar, config.views.wikified.tag.tooltip.format([tag]),onClickTag); theTag.setAttribute("tag",tag); if (excludeTiddler) theTag.setAttribute("tiddler",excludeTiddler); return(theTag); }, miniTagHandler: function(place,macroName,params,wikifier,paramString,tiddler) { var tagged = store.getTaggedTiddlers(tiddler.title); if (tagged.length > 0) { var theTag = createTiddlyButton(place,config.quickOpenTag.dropdownChar, config.views.wikified.tag.tooltip.format([tiddler.title]),onClickTag); theTag.setAttribute("tag",tiddler.title); theTag.className = "miniTag"; } }, allTagsHandler: function(place,macroName,params) { var tags = store.getTags(params[0]); var filter = params[1]; // new feature var ul = createTiddlyElement(place,"ul"); if(tags.length == 0) createTiddlyElement(ul,"li",null,"listTitle",this.noTags); for(var t=0; t<tags.length; t++) { var title = tags[t][0]; if (!filter || (title.match(new RegExp('^'+filter)))) { var info = getTiddlyLinkInfo(title); var theListItem =createTiddlyElement(ul,"li"); var theLink = createTiddlyLink(theListItem,tags[t][0],true); var theCount = " (" + tags[t][1] + ")"; theLink.appendChild(document.createTextNode(theCount)); var theDropDownBtn = createTiddlyButton(theListItem," " + config.quickOpenTag.dropdownChar,this.tooltip.format([tags[t][0]]),onClickTag); theDropDownBtn.setAttribute("tag",tags[t][0]); } } }, // todo fix these up a bit styles: [ "/*{{{*/", "/* created by QuickOpenTagPlugin */", ".tagglyTagged .quickopentag, .tagged .quickopentag ", " { margin-right:1.2em; border:1px solid #eee; padding:2px; padding-right:0px; padding-left:1px; }", ".quickopentag .tiddlyLink { padding:2px; padding-left:3px; }", ".quickopentag a.button { padding:1px; padding-left:2px; padding-right:2px;}", "/* extra specificity to make it work right */", "#displayArea .viewer .quickopentag a.button, ", "#displayArea .viewer .quickopentag a.tiddyLink, ", "#mainMenu .quickopentag a.tiddyLink, ", "#mainMenu .quickopentag a.tiddyLink ", " { border:0px solid black; }", "#displayArea .viewer .quickopentag a.button, ", "#mainMenu .quickopentag a.button ", " { margin-left:0px; padding-left:2px; }", "#displayArea .viewer .quickopentag a.tiddlyLink, ", "#mainMenu .quickopentag a.tiddlyLink ", " { margin-right:0px; padding-right:0px; padding-left:0px; margin-left:0px; }", "a.miniTag {font-size:150%;} ", "#mainMenu .quickopentag a.button ", " /* looks better in right justified main menus */", " { margin-left:0px; padding-left:2px; margin-right:0px; padding-right:0px; }", "#topMenu .quickopentag { padding:0px; margin:0px; border:0px; }", "#topMenu .quickopentag .tiddlyLink { padding-right:1px; margin-right:0px; }", "#topMenu .quickopentag .button { padding-left:1px; margin-left:0px; border:0px; }", "/*}}}*/", ""].join("\n"), init: function() { // we fully replace these builtins. can't hijack them easily window.createTagButton = this.createTagButton; config.macros.allTags.handler = this.allTagsHandler; config.macros.miniTag = { handler: this.miniTagHandler }; config.shadowTiddlers["QuickOpenTagStyles"] = this.styles; store.addNotification("QuickOpenTagStyles",refreshStyles); } } config.quickOpenTag.init(); //}}} </pre> </div> <div title="RenameTagsPlugin" modifier="MPTW" created="200806101312" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|RenameTagsPlugin| |Description:|Allows you to easily rename or delete tags across multiple tiddlers| |Version:|3.0 ($Rev: 5501 $)| |Date:|$Date: 2008-06-10 23:11:55 +1000 (Tue, 10 Jun 2008) $| |Source:|http://mptw.tiddlyspot.com/#RenameTagsPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License|http://mptw.tiddlyspot.com/#TheBSDLicense| Rename a tag and you will be prompted to rename it in all its tagged tiddlers. ***/ //{{{ config.renameTags = { prompts: { rename: "Rename the tag '%0' to '%1' in %2 tidder%3?", remove: "Remove the tag '%0' from %1 tidder%2?" }, removeTag: function(tag,tiddlers) { store.suspendNotifications(); for (var i=0;i<tiddlers.length;i++) { store.setTiddlerTag(tiddlers[i].title,false,tag); } store.resumeNotifications(); store.notifyAll(); }, renameTag: function(oldTag,newTag,tiddlers) { store.suspendNotifications(); for (var i=0;i<tiddlers.length;i++) { store.setTiddlerTag(tiddlers[i].title,false,oldTag); // remove old store.setTiddlerTag(tiddlers[i].title,true,newTag); // add new } store.resumeNotifications(); store.notifyAll(); }, storeMethods: { saveTiddler_orig_renameTags: TiddlyWiki.prototype.saveTiddler, saveTiddler: function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created) { if (title != newTitle) { var tagged = this.getTaggedTiddlers(title); if (tagged.length > 0) { // then we are renaming a tag if (confirm(config.renameTags.prompts.rename.format([title,newTitle,tagged.length,tagged.length>1?"s":""]))) config.renameTags.renameTag(title,newTitle,tagged); if (!this.tiddlerExists(title) && newBody == "") // dont create unwanted tiddler return null; } } return this.saveTiddler_orig_renameTags(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created); }, removeTiddler_orig_renameTags: TiddlyWiki.prototype.removeTiddler, removeTiddler: function(title) { var tagged = this.getTaggedTiddlers(title); if (tagged.length > 0) if (confirm(config.renameTags.prompts.remove.format([title,tagged.length,tagged.length>1?"s":""]))) config.renameTags.removeTag(title,tagged); return this.removeTiddler_orig_renameTags(title); } }, init: function() { merge(TiddlyWiki.prototype,this.storeMethods); } } config.renameTags.init(); //}}} </pre> </div> <div title="SaveCloseTiddlerPlugin" modifier="MPTW" created="200806101331" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|SaveCloseTiddlerPlugin| |Description:|Provides two extra toolbar commands, saveCloseTiddler and cancelCloseTiddler| |Version:|3.0 ($Rev: 5502 $)| |Date:|$Date: 2008-06-10 23:31:39 +1000 (Tue, 10 Jun 2008) $| |Source:|http://mptw.tiddlyspot.com/#SaveCloseTiddlerPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| To use these you must add them to the tool bar in your EditTemplate ***/ //{{{ merge(config.commands,{ saveCloseTiddler: { text: 'done/close', tooltip: 'Save changes to this tiddler and close it', handler: function(ev,src,title) { var closeTitle = title; var newTitle = story.saveTiddler(title,ev.shiftKey); if (newTitle) closeTitle = newTitle; return config.commands.closeTiddler.handler(ev,src,closeTitle); } }, cancelCloseTiddler: { text: 'cancel/close', tooltip: 'Undo changes to this tiddler and close it', handler: function(ev,src,title) { // the same as closeTiddler now actually return config.commands.closeTiddler.handler(ev,src,title); } } }); //}}} </pre> </div> <div title="Security" modifier="Xavier" created="200807050606" modified="200807052350" tags="slide Technology" changecount="2"> <pre>!Security * Passwords? Security prompts? Huge challange! * Every --applicattion-- activity used to run in its own Linux-VServer sandox. I don't know what they use right now * Huge homogeneous install base: huge interest by black hats as an attack vector</pre> </div> <div title="SelectThemePlugin" modifier="MPTW" created="200803121559" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|SelectThemePlugin| |Description:|Lets you easily switch theme and palette| |Version:|1.0 ($Rev: 3646 $)| |Date:|$Date: 2008-02-27 02:34:38 +1000 (Wed, 27 Feb 2008) $| |Source:|http://mptw.tiddlyspot.com/#SelectThemePlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| !Notes * Borrows largely from ThemeSwitcherPlugin by Martin Budden http://www.martinswiki.com/#ThemeSwitcherPlugin * Theme is cookie based. But set a default by setting config.options.txtTheme in MptwConfigPlugin (for example) * Palette is not cookie based. It actually overwrites your ColorPalette tiddler when you select a palette, so beware. !Usage * {{{<<selectTheme>>}}} makes a dropdown selector * {{{<<selectPalette>>}}} makes a dropdown selector * {{{<<applyTheme>>}}} applies the current tiddler as a theme * {{{<<applyPalette>>}}} applies the current tiddler as a palette * {{{<<applyTheme TiddlerName>>}}} applies TiddlerName as a theme * {{{<<applyPalette TiddlerName>>}}} applies TiddlerName as a palette ***/ //{{{ config.macros.selectTheme = { label: { selectTheme:"select theme", selectPalette:"select palette" }, prompt: { selectTheme:"Select the current theme", selectPalette:"Select the current palette" }, tags: { selectTheme:'systemTheme', selectPalette:'systemPalette' } }; config.macros.selectTheme.handler = function(place,macroName) { var btn = createTiddlyButton(place,this.label[macroName],this.prompt[macroName],this.onClick); // want to handle palettes and themes with same code. use mode attribute to distinguish btn.setAttribute('mode',macroName); }; config.macros.selectTheme.onClick = function(ev) { var e = ev ? ev : window.event; var popup = Popup.create(this); var mode = this.getAttribute('mode'); var tiddlers = store.getTaggedTiddlers(config.macros.selectTheme.tags[mode]); // for default if (mode == "selectPalette") { var btn = createTiddlyButton(createTiddlyElement(popup,'li'),"(default)","default color palette",config.macros.selectTheme.onClickTheme); btn.setAttribute('theme',"(default)"); btn.setAttribute('mode',mode); } for(var i=0; i<tiddlers.length; i++) { var t = tiddlers[i].title; var name = store.getTiddlerSlice(t,'Name'); var desc = store.getTiddlerSlice(t,'Description'); var btn = createTiddlyButton(createTiddlyElement(popup,'li'),name ? name : title,desc ? desc : config.macros.selectTheme.label['mode'],config.macros.selectTheme.onClickTheme); btn.setAttribute('theme',t); btn.setAttribute('mode',mode); } Popup.show(); return stopEvent(e); }; config.macros.selectTheme.onClickTheme = function(ev) { var mode = this.getAttribute('mode'); var theme = this.getAttribute('theme'); if (mode == 'selectTheme') story.switchTheme(theme); else // selectPalette config.macros.selectTheme.updatePalette(theme); return false; }; config.macros.selectTheme.updatePalette = function(title) { if (title != "") { store.deleteTiddler("ColorPalette"); if (title != "(default)") store.saveTiddler("ColorPalette","ColorPalette",store.getTiddlerText(title), config.options.txtUserName,undefined,""); refreshAll(); if(config.options.chkAutoSave) saveChanges(true); } }; config.macros.applyTheme = { label: "apply", prompt: "apply this theme or palette" // i'm lazy }; config.macros.applyTheme.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var useTiddler = params[0] ? params[0] : tiddler.title; var btn = createTiddlyButton(place,this.label,this.prompt,config.macros.selectTheme.onClickTheme); btn.setAttribute('theme',useTiddler); btn.setAttribute('mode',macroName=="applyTheme"?"selectTheme":"selectPalette"); // a bit untidy here } config.macros.selectPalette = config.macros.selectTheme; config.macros.applyPalette = config.macros.applyTheme; config.macros.refreshAll = { handler: function(place,macroName,params,wikifier,paramString,tiddler) { createTiddlyButton(place,"refresh","refresh layout and styles",function() { refreshAll(); }); }}; //}}} </pre> </div> <div title="Seymour Papert" modifier="Xavier" created="200807042017" modified="200807052342" tags="slide [[Thinking BIG: Education]]" changecount="14"> <pre>!Seymour Papert * Of Logo and Artificial Intelligence fame [>img[http://www.hln.nf.ca/hook99/images/seymour.gif][http://en.wikipedia.org/wiki/Seymour_Papert]] * Long time focus on education. Father of [[Constructionism]] ** //Mindstorms: Children, Computers and Powerful Ideas// (1980) ** //The Children's Machine: Rethinking School in the Age of the Computer// (1992) * Worked with Jean Piaget in the 60s > //Some of the most crucial steps in mental growth are based not simply on acquiring new skills, but on acquiring new administrative ways to use what one already knows.// </pre> </div> <div title="Sic Transit Gloria Laptopi?" modifier="Xavier" created="200807041655" modified="200807052351" tags="slide Problems" changecount="5"> <pre>!Sic Transit Gloria Laptopi? * Excellent post by Ivan Krstić, former director of security architecture and several other things in OLPC: http://radian.org/notebook/sic-transit-gloria-laptopi {{centerColumn{ <html> <a href="http://www.flickr.com/photos/70148893@N00/2636995516/" title="Wordle from Ivan Krstić's Sic Transit Gloria Laptopi by -Xv, on Flickr"><img src="http://farm4.static.flickr.com/3192/2636995516_d95418d711.jpg" width="500" height="360" alt="Wordle from Ivan Krstić's Sic Transit Gloria Laptopi" /></a> </html> }}} </pre> </div> <div title="SiteSubtitle" modifier="Xavier" created="200807031932" changecount="1"> <pre>Azúcar!</pre> </div> <div title="SiteTitle" modifier="Xavier" created="200807031932" changecount="1"> <pre>One Laptop Per Child</pre> </div> <div title="SlideShowPageTemplate" modifier="Xavier" created="200807032024" modified="200807032042" changecount="7"> <pre><!--{{{--> <div id='displayArea'> <div id='tiddlerDisplay'> </div> </div> <!--}}}--></pre> </div> <div title="SlideShowPlugin" modifier="PauloSoares" created="200706141122" modified="200802131452" tags="systemConfig" server.type="file" server.host="www.math.ist.utl.pt/~psoares/addons.html" server.page.revision="200802131452"> <pre>/*** |''Name:''|SlideShowPlugin| |''Description:''|Creates a simple slide show type display| |''Version:''|1.6| |''Date:''|Feb 12, 2008| |''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; case 66: // B blankScreen(); break; } } return false; } } function blankScreen(){ var blanker = document.getElementById('slideBlanker'); if (blanker.style.display == 'block'){ blanker.style.display = 'none'; } else { blanker.style.display = 'block'; } } 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); } GoToSlide = function(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;} setClock = function(){ 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 var blanker= createTiddlyElement(viewer,"DIV","slideBlanker"); blanker.style.display="none"; 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 = ""; refreshPageTemplate(); setStylesheet("#backstageShow{display: block;}","SlideShowStyleSheet"); changeStyleSheet(); } else{ contentWrapper.className = "slideShowMode"; refreshPageTemplate("SlideShowPageTemplate"); setStylesheet(store.getRecursiveTiddlerText("SlideShowStyleSheet"),"SlideShowStyleSheet"); if(slideShowStyleSheet) changeStyleSheet(slideShowStyleSheet); } } config.shadowTiddlers.SlideShowPageTemplate="<!--{{{-->\n<div id='displayArea'>\n<div id='tiddlerDisplay'></div>\n</div>\n<!--}}}-->"; config.shadowTiddlers.SlideShowViewTemplate="<!--{{{-->\n<div class='title' macro='view title'></div>\n<div class='viewer' macro='view text wikified'></div>\n<!--}}}-->"; config.shadowTiddlers.SlideShowStyleSheet = "/***\n!Slide Mode Styles\n***/\n/*{{{*/\n#slideBlanker {\n position:absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 90; \n background-color: #000;\n}\n#backstageShow{\n display: none !important;\n}\n\n#contentWrapper.slideShowMode #slideContainer{\n display: block;\n}\n\n#contentWrapper.slideShowMode .Comment{\n display: none;\n}\n\n#contentWrapper.slideShowMode .nextOverlay{\n visibility: hidden;\n}\n\n#contentWrapper.slideShowMode .currentOverlay{\n visibility: visible;\n}\n\n#contentWrapper.slideShowMode .previousOverlay{\n visibility: visible;\n}\n\n#jump{\n text-align: right;\n}\n\n.slideFooterOff #navigator{\n visibility: hidden;\n}\n\n.slideFooterOn #navigator{\n visibility: visible;\n}\n\n#contentWrapper.slideShowMode #slideClock{\n cursor: pointer; margin: 0 5px 0 5px; border: 1px solid #db4\n}\n\n#contentWrapper.slideShowMode,\n #contentWrapper.slideShowMode #displayArea{\n width: 100%;\n font-size: 1.5em;\n margin: 0 !important;\n padding: 0;\n}\n\n#slideContainer{\n display: none;\n}\n\n.indexNumbers{\n cursor: pointer;\n}\n\n#navigator{\n visibility: hidden;\n bottom: 0;\n}\n\n#toc{\n display: none;\n position: absolute;\n font-size: .75em;\n bottom: 2em;\n right: 0;\n background: #fff;\n border: 1px solid #000;\n text-align: left;\n}\n\nul#toc, #toc li{\n margin: 0;\n padding: 0;\n list-style: none;\n line-height: 1em;\n}\n\n.tocJumpItem{\n margin-right: 2em;\n}\n\n.tocJumpItem input{\nmargin-right: 1em;\n border: 0;\n}\n\n#toc a,\n#toc a.button{\n display: block;\n padding: .1em;\n}\n\n#toc .tocLevel1{\nfont-size: .8em;\n}\n\n#toc .tocLevel2{\n margin-left: 1em;\n font-size: .75em;\n}\n\n#toc .tocLevel3{\n margin-left: 2em;\nfont-size: .75em;\n}\n\n#toc .tocLevel4{\n margin-left: 3em;\nfont-size: .65em;\n}\n\n#toc a{\n cursor: pointer;\n}\n\nh1{\n min-height: 1em;\n}\n\n.slide h1{\n min-height: 0;\n}\n\n/* The '>' selector is ignored by IE6 and earlier so the proper rules are given */\n#slideFooter{\n position: fixed;\n bottom: 2px;\n right: 2px;\n width: 100%;\n text-align: right;\n}\n\n/* This is a hack to trick IE6 and earlier to put the navbar on the bottom of the page */\n* html #slideFooter {\n position: absolute;\n width: 100%;\n text-align: right;\n right: auto; bottom: auto;\n left: expression( ( -20 - slideFooter.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );\n top: expression( ( -10 - slideFooter.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );\n}\n\n\n\n/*}}}*/"; config.shadowTiddlers.SlideShowPluginDoc="The documentation is missing. It is available [[here|http://www.math.ist.utl.pt/~psoares/addons.html#SlideShowPluginDoc]]."; //}}}</pre> </div> <div title="Software" modifier="Xavier" created="200807050404" modified="200807052347" tags="slide Technology" changecount="4"> <pre>!Software * Linux 2.6.22 Based on a very stripped down Fedora 7 * Inter-process communiction: [[D-Bus|http://en.wikipedia.org/wiki/D-Bus]] * Try to use Python for everything else! ** Remember [[Constructionism]]? View the code! ** Would be nice if Python was more smalltalkish and allowed debug+edit+continue ** Sugar is the user interface + some basic services</pre> </div> <div title="Still thinking BIG" modifier="Xavier" created="200807050013" modified="200807052353" tags="slide [[Still thinking BIG]]" changecount="9"> <pre>!Still thinking BIG * Everyone wins? ** Microsoft: makes Windows XP available for $3 for the OLPC ** [[SugarLabs|http://wiki.sugarlabs.org]] working making Sugar also available for non XO hardware (e.g. the Intel ~ClassMate) * It may not be always Free software, it may not be always collaborative hardware, it may not be always "constructionist" software... but pretty soon millions of kids in poor countries are going to get access to knowledge that is currently not avaiable to them [img[http://www.xconomy.com/wordpress/wp-content/images/2008/05/sugar_labs_logo.jpg][http://wiki.sugarlabs.org]]</pre> </div> <div title="StyleSheet" modifier="Xavier" created="200807032208" modified="200807042244" tags="css" changecount="19"> <pre>.centerColumn { margin-left:25%; margin-right:25%; } .centerText { text-align: center; } .floatRight { float: right; } .hideDeck { display: none; } .attribution { font-size: 80%; text-align: right; } .midImage img { width: 400px; } .midLandscapeImage img { height: 400px; } </pre> </div> <div title="Sugar is Sweet" modifier="Xavier" created="200807042318" modified="200807052349" tags="slide Technology" changecount="8"> <pre>!Sugar is Sweet {{centerColumn{ [img[http://wiki.sugarlabs.org/images/f/fc/Taxonomy.png]] http://wiki.sugarlabs.org/go/Taxonomy }}}</pre> </div> <div title="TabAllTags" modifier="MPTW" created="200802220317" modified="200806181402"> <pre><<allTags excludeLists>> </pre> </div> <div title="TabMore" modifier="MPTW" created="200802220317" modified="200806181402"> <pre><<tabs txtMoreTab "Tags" "All Tags" TabAllTags "Miss" "Missing tiddlers" TabMoreMissing "Orph" "Orphaned tiddlers" TabMoreOrphans "Shad" "Shadowed tiddlers" TabMoreShadowed>> </pre> </div> <div title="TabTags" modifier="MPTW" created="200802220317" modified="200806181402"> <pre><<allTags excludeLists [a-z]>> </pre> </div> <div title="Table of contents" modifier="Xavier" created="200807040618" modified="200807052340" tags="slide Intro" changecount="9"> <pre>!Table of contents * [[Thinking BIG: Education]] * [[Technology: the amazing guts of the small rabbit-eared green beast]] * [[Houston! We have a problem!]] * [[Still thinking BIG]] * [[Short hands-on lab (sort of)|The lab 0.1]]</pre> </div> <div title="Table of contents (first draft)" modifier="Xavier" created="200807040545" modified="200807052339" tags="slide Intro" changecount="6"> <pre>!Table of contents (first draft) * Thinking BIG: Education * Technology: the amazing guts of the small rabbit-eared green beast * Houston! We have a problem! * Still thinking BIG * Short hands-on lab</pre> </div> <div title="Table of contents (second draft)" modifier="Xavier" created="200807040624" modified="200807052339" tags="slide Intro" changecount="8"> <pre>!Table of contents (second draft) * Go out for some coffee/frisbee playing/sunbathing and later watch an our own this excellent [[Google Tech Talk|http://video.google.com/videoplay?docid=-4285568518538296189]] video by [[Ivan Krstić|http://radian.org/]] (60 minutes, a bit outdated) {{centerColumn{ <html> <embed id="VideoPlayback" style="width:400px;height:326px" allowFullScreen="true" src="http://video.google.com/googleplayer.swf?docid=-4285568518538296189&hl=en&fs=true" type="application/x-shockwave-flash"> </embed> </html> }}}</pre> </div> <div title="TagglyTaggingPlugin" modifier="MPTW" created="200806181350" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|TagglyTaggingPlugin| |Description:|tagglyTagging macro is a replacement for the builtin tagging macro in your ViewTemplate| |Version:|3.1 ($Rev: 5655 $)| |Date:|$Date: 2008-06-18 23:50:30 +1000 (Wed, 18 Jun 2008) $| |Source:|http://mptw.tiddlyspot.com/#TagglyTaggingPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| !Notes See http://mptw.tiddlyspot.com/#TagglyTagging ***/ //{{{ config.taggly = { // for translations lingo: { labels: { asc: "\u2191", // down arrow desc: "\u2193", // up arrow title: "title", modified: "modified", created: "created", show: "+", hide: "-", normal: "normal", group: "group", commas: "commas", sitemap: "sitemap", numCols: "cols\u00b1", // plus minus sign label: "Tagged as '%0':", excerpts: "excerpts", descr: "descr", slices: "slices", contents: "contents", sliders: "sliders", noexcerpts: "title only" }, tooltips: { title: "Click to sort by title", modified: "Click to sort by modified date", created: "Click to sort by created date", show: "Click to show tagging list", hide: "Click to hide tagging list", normal: "Click to show a normal ungrouped list", group: "Click to show list grouped by tag", sitemap: "Click to show a sitemap style list", commas: "Click to show a comma separated list", numCols: "Click to change number of columns", excerpts: "Click to show excerpts", descr: "Click to show the description slice", slices: "Click to show all slices", contents: "Click to show entire tiddler contents", sliders: "Click to show tiddler contents in sliders", noexcerpts: "Click to show entire title only" }, tooDeepMessage: "* //sitemap too deep...//" }, config: { showTaggingCounts: true, listOpts: { // the first one will be the default sortBy: ["title","modified","created"], sortOrder: ["asc","desc"], hideState: ["show","hide"], listMode: ["normal","group","sitemap","commas"], numCols: ["1","2","3","4","5","6"], excerpts: ["noexcerpts","excerpts","descr","slices","contents","sliders"] }, valuePrefix: "taggly.", excludeTags: ["excludeLists","excludeTagging"], excerptSize: 50, excerptMarker: "/%"+"%/", siteMapDepthLimit: 25 }, getTagglyOpt: function(title,opt) { var val = store.getValue(title,this.config.valuePrefix+opt); return val ? val : this.config.listOpts[opt][0]; }, setTagglyOpt: function(title,opt,value) { if (!store.tiddlerExists(title)) // create it silently store.saveTiddler(title,title,config.views.editor.defaultText.format([title]),config.options.txtUserName,new Date(),""); // if value is default then remove it to save space return store.setValue(title, this.config.valuePrefix+opt, value == this.config.listOpts[opt][0] ? null : value); }, getNextValue: function(title,opt) { var current = this.getTagglyOpt(title,opt); var pos = this.config.listOpts[opt].indexOf(current); // a little usability enhancement. actually it doesn't work right for grouped or sitemap var limit = (opt == "numCols" ? store.getTaggedTiddlers(title).length : this.config.listOpts[opt].length); var newPos = (pos + 1) % limit; return this.config.listOpts[opt][newPos]; }, toggleTagglyOpt: function(title,opt) { var newVal = this.getNextValue(title,opt); this.setTagglyOpt(title,opt,newVal); }, createListControl: function(place,title,type) { var lingo = config.taggly.lingo; var label; var tooltip; var onclick; if ((type == "title" || type == "modified" || type == "created")) { // "special" controls. a little tricky. derived from sortOrder and sortBy label = lingo.labels[type]; tooltip = lingo.tooltips[type]; if (this.getTagglyOpt(title,"sortBy") == type) { label += lingo.labels[this.getTagglyOpt(title,"sortOrder")]; onclick = function() { config.taggly.toggleTagglyOpt(title,"sortOrder"); return false; } } else { onclick = function() { config.taggly.setTagglyOpt(title,"sortBy",type); config.taggly.setTagglyOpt(title,"sortOrder",config.taggly.config.listOpts.sortOrder[0]); return false; } } } else { // "regular" controls, nice and simple label = lingo.labels[type == "numCols" ? type : this.getNextValue(title,type)]; tooltip = lingo.tooltips[type == "numCols" ? type : this.getNextValue(title,type)]; onclick = function() { config.taggly.toggleTagglyOpt(title,type); return false; } } // hide button because commas don't have columns if (!(this.getTagglyOpt(title,"listMode") == "commas" && type == "numCols")) createTiddlyButton(place,label,tooltip,onclick,type == "hideState" ? "hidebutton" : "button"); }, makeColumns: function(orig,numCols) { var listSize = orig.length; var colSize = listSize/numCols; var remainder = listSize % numCols; var upperColsize = colSize; var lowerColsize = colSize; if (colSize != Math.floor(colSize)) { // it's not an exact fit so.. upperColsize = Math.floor(colSize) + 1; lowerColsize = Math.floor(colSize); } var output = []; var c = 0; for (var j=0;j<numCols;j++) { var singleCol = []; var thisSize = j < remainder ? upperColsize : lowerColsize; for (var i=0;i<thisSize;i++) singleCol.push(orig[c++]); output.push(singleCol); } return output; }, drawTable: function(place,columns,theClass) { var newTable = createTiddlyElement(place,"table",null,theClass); var newTbody = createTiddlyElement(newTable,"tbody"); var newTr = createTiddlyElement(newTbody,"tr"); for (var j=0;j<columns.length;j++) { var colOutput = ""; for (var i=0;i<columns[j].length;i++) colOutput += columns[j][i]; var newTd = createTiddlyElement(newTr,"td",null,"tagglyTagging"); // todo should not need this class wikify(colOutput,newTd); } return newTable; }, createTagglyList: function(place,title) { switch(this.getTagglyOpt(title,"listMode")) { case "group": return this.createTagglyListGrouped(place,title); break; case "normal": return this.createTagglyListNormal(place,title,false); break; case "commas": return this.createTagglyListNormal(place,title,true); break; case "sitemap":return this.createTagglyListSiteMap(place,title); break; } }, getTaggingCount: function(title) { // thanks to Doug Edmunds if (this.config.showTaggingCounts) { var tagCount = store.getTaggedTiddlers(title).length; if (tagCount > 0) return " ("+tagCount+")"; } return ""; }, getExcerpt: function(inTiddlerTitle,title,indent) { if (!indent) indent = 1; var displayMode = this.getTagglyOpt(inTiddlerTitle,"excerpts"); var t = store.getTiddler(title); if (t && displayMode == "excerpts") { var text = t.text.replace(/\n/," "); var marker = text.indexOf(this.config.excerptMarker); if (marker != -1) { return " {{excerpt{<nowiki>" + text.substr(0,marker) + "</nowiki>}}}"; } else if (text.length < this.config.excerptSize) { return " {{excerpt{<nowiki>" + t.text + "</nowiki>}}}"; } else { return " {{excerpt{<nowiki>" + t.text.substr(0,this.config.excerptSize) + "..." + "</nowiki>}}}"; } } else if (t && displayMode == "contents") { return "\n{{contents indent"+indent+"{\n" + t.text + "\n}}}"; } else if (t && displayMode == "sliders") { return "<slider slide>\n{{contents{\n" + t.text + "\n}}}\n</slider>"; } else if (t && displayMode == "descr") { var descr = store.getTiddlerSlice(title,'Description'); return descr ? " {{excerpt{" + descr + "}}}" : ""; } else if (t && displayMode == "slices") { var result = ""; var slices = store.calcAllSlices(title); for (var s in slices) result += "|%0|<nowiki>%1</nowiki>|\n".format([s,slices[s]]); return result ? "\n{{excerpt excerptIndent{\n" + result + "}}}" : ""; } return ""; }, notHidden: function(t,inTiddler) { if (typeof t == "string") t = store.getTiddler(t); return (!t || !t.tags.containsAny(this.config.excludeTags) || (inTiddler && this.config.excludeTags.contains(inTiddler))); }, // this is for normal and commas mode createTagglyListNormal: function(place,title,useCommas) { var list = store.getTaggedTiddlers(title,this.getTagglyOpt(title,"sortBy")); if (this.getTagglyOpt(title,"sortOrder") == "desc") list = list.reverse(); var output = []; var first = true; for (var i=0;i<list.length;i++) { if (this.notHidden(list[i],title)) { var countString = this.getTaggingCount(list[i].title); var excerpt = this.getExcerpt(title,list[i].title); if (useCommas) output.push((first ? "" : ", ") + "[[" + list[i].title + "]]" + countString + excerpt); else output.push("*[[" + list[i].title + "]]" + countString + excerpt + "\n"); first = false; } } return this.drawTable(place, this.makeColumns(output,useCommas ? 1 : parseInt(this.getTagglyOpt(title,"numCols"))), useCommas ? "commas" : "normal"); }, // this is for the "grouped" mode createTagglyListGrouped: function(place,title) { var sortBy = this.getTagglyOpt(title,"sortBy"); var sortOrder = this.getTagglyOpt(title,"sortOrder"); var list = store.getTaggedTiddlers(title,sortBy); if (sortOrder == "desc") list = list.reverse(); var leftOvers = [] for (var i=0;i<list.length;i++) leftOvers.push(list[i].title); var allTagsHolder = {}; for (var i=0;i<list.length;i++) { for (var j=0;j<list[i].tags.length;j++) { if (list[i].tags[j] != title) { // not this tiddler if (this.notHidden(list[i].tags[j],title)) { if (!allTagsHolder[list[i].tags[j]]) allTagsHolder[list[i].tags[j]] = ""; if (this.notHidden(list[i],title)) { allTagsHolder[list[i].tags[j]] += "**[["+list[i].title+"]]" + this.getTaggingCount(list[i].title) + this.getExcerpt(title,list[i].title) + "\n"; leftOvers.setItem(list[i].title,-1); // remove from leftovers. at the end it will contain the leftovers } } } } } var allTags = []; for (var t in allTagsHolder) allTags.push(t); var sortHelper = function(a,b) { if (a == b) return 0; if (a < b) return -1; return 1; }; allTags.sort(function(a,b) { var tidA = store.getTiddler(a); var tidB = store.getTiddler(b); if (sortBy == "title") return sortHelper(a,b); else if (!tidA && !tidB) return 0; else if (!tidA) return -1; else if (!tidB) return +1; else return sortHelper(tidA[sortBy],tidB[sortBy]); }); var leftOverOutput = ""; for (var i=0;i<leftOvers.length;i++) if (this.notHidden(leftOvers[i],title)) leftOverOutput += "*[["+leftOvers[i]+"]]" + this.getTaggingCount(leftOvers[i]) + this.getExcerpt(title,leftOvers[i]) + "\n"; var output = []; if (sortOrder == "desc") allTags.reverse(); else if (leftOverOutput != "") // leftovers first... output.push(leftOverOutput); for (var i=0;i<allTags.length;i++) if (allTagsHolder[allTags[i]] != "") output.push("*[["+allTags[i]+"]]" + this.getTaggingCount(allTags[i]) + this.getExcerpt(title,allTags[i]) + "\n" + allTagsHolder[allTags[i]]); if (sortOrder == "desc" && leftOverOutput != "") // leftovers last... output.push(leftOverOutput); return this.drawTable(place, this.makeColumns(output,parseInt(this.getTagglyOpt(title,"numCols"))), "grouped"); }, // used to build site map treeTraverse: function(title,depth,sortBy,sortOrder) { var list = store.getTaggedTiddlers(title,sortBy); if (sortOrder == "desc") list.reverse(); var indent = ""; for (var j=0;j<depth;j++) indent += "*" var childOutput = ""; if (depth > this.config.siteMapDepthLimit) childOutput += indent + this.lingo.tooDeepMessage; else for (var i=0;i<list.length;i++) if (list[i].title != title) if (this.notHidden(list[i].title,this.config.inTiddler)) childOutput += this.treeTraverse(list[i].title,depth+1,sortBy,sortOrder); if (depth == 0) return childOutput; else return indent + "[["+title+"]]" + this.getTaggingCount(title) + this.getExcerpt(this.config.inTiddler,title,depth) + "\n" + childOutput; }, // this if for the site map mode createTagglyListSiteMap: function(place,title) { this.config.inTiddler = title; // nasty. should pass it in to traverse probably var output = this.treeTraverse(title,0,this.getTagglyOpt(title,"sortBy"),this.getTagglyOpt(title,"sortOrder")); return this.drawTable(place, this.makeColumns(output.split(/(?=^\*\[)/m),parseInt(this.getTagglyOpt(title,"numCols"))), // regexp magic "sitemap" ); }, macros: { tagglyTagging: { handler: function (place,macroName,params,wikifier,paramString,tiddler) { var refreshContainer = createTiddlyElement(place,"div"); // do some refresh magic to make it keep the list fresh - thanks Saq refreshContainer.setAttribute("refresh","macro"); refreshContainer.setAttribute("macroName",macroName); if (params[0]) refreshContainer.setAttribute("title",params[0]); else { refreshContainer.setAttribute("title",tiddler.title); } this.refresh(refreshContainer); }, refresh: function(place) { var title = place.getAttribute("title"); removeChildren(place); addClass(place,"tagglyTagging"); if (store.getTaggedTiddlers(title).length > 0) { var lingo = config.taggly.lingo; config.taggly.createListControl(place,title,"hideState"); if (config.taggly.getTagglyOpt(title,"hideState") == "show") { createTiddlyElement(place,"span",null,"tagglyLabel",lingo.labels.label.format([title])); config.taggly.createListControl(place,title,"title"); config.taggly.createListControl(place,title,"modified"); config.taggly.createListControl(place,title,"created"); config.taggly.createListControl(place,title,"listMode"); config.taggly.createListControl(place,title,"excerpts"); config.taggly.createListControl(place,title,"numCols"); config.taggly.createTagglyList(place,title); } } } } }, // todo fix these up a bit styles: [ "/*{{{*/", "/* created by TagglyTaggingPlugin */", ".tagglyTagging { padding-top:0.5em; }", ".tagglyTagging li.listTitle { display:none; }", ".tagglyTagging ul {", " margin-top:0px; padding-top:0.5em; padding-left:2em;", " margin-bottom:0px; padding-bottom:0px;", "}", ".tagglyTagging { vertical-align: top; margin:0px; padding:0px; }", ".tagglyTagging table { margin:0px; padding:0px; }", ".tagglyTagging .button { visibility:hidden; margin-left:3px; margin-right:3px; }", ".tagglyTagging .button, .tagglyTagging .hidebutton {", " color:[[ColorPalette::TertiaryLight]]; font-size:90%;", " border:0px; padding-left:0.3em;padding-right:0.3em;", "}", ".tagglyTagging .button:hover, .hidebutton:hover, ", ".tagglyTagging .button:active, .hidebutton:active {", " border:0px; background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]];", "}", ".selected .tagglyTagging .button { visibility:visible; }", ".tagglyTagging .hidebutton { color:[[ColorPalette::Background]]; }", ".selected .tagglyTagging .hidebutton { color:[[ColorPalette::TertiaryLight]] }", ".tagglyLabel { color:[[ColorPalette::TertiaryMid]]; font-size:90%; }", ".tagglyTagging ul {padding-top:0px; padding-bottom:0.5em; margin-left:1em; }", ".tagglyTagging ul ul {list-style-type:disc; margin-left:-1em;}", ".tagglyTagging ul ul li {margin-left:0.5em; }", ".editLabel { font-size:90%; padding-top:0.5em; }", ".tagglyTagging .commas { padding-left:1.8em; }", "/* not technically tagglytagging but will put them here anyway */", ".tagglyTagged li.listTitle { display:none; }", ".tagglyTagged li { display: inline; font-size:90%; }", ".tagglyTagged ul { margin:0px; padding:0px; }", ".excerpt { color:[[ColorPalette::TertiaryDark]]; }", ".excerptIndent { margin-left:4em; }", "div.tagglyTagging table,", "div.tagglyTagging table tr,", "td.tagglyTagging", " {border-style:none!important; }", ".tagglyTagging .contents { border-bottom:2px solid [[ColorPalette::TertiaryPale]]; padding:0 1em 1em 0.5em;", " margin-bottom:0.5em; }", ".tagglyTagging .indent1 { margin-left:3em; }", ".tagglyTagging .indent2 { margin-left:4em; }", ".tagglyTagging .indent3 { margin-left:5em; }", ".tagglyTagging .indent4 { margin-left:6em; }", ".tagglyTagging .indent5 { margin-left:7em; }", ".tagglyTagging .indent6 { margin-left:8em; }", ".tagglyTagging .indent7 { margin-left:9em; }", ".tagglyTagging .indent8 { margin-left:10em; }", ".tagglyTagging .indent9 { margin-left:11em; }", ".tagglyTagging .indent10 { margin-left:12em; }", "/*}}}*/", ""].join("\n"), init: function() { merge(config.macros,this.macros); config.shadowTiddlers["TagglyTaggingStyles"] = this.styles; store.addNotification("TagglyTaggingStyles",refreshStyles); } }; config.taggly.init(); //}}} /*** InlineSlidersPlugin By Saq Imtiaz http://tw.lewcid.org/sandbox/#InlineSlidersPlugin // syntax adjusted to not clash with NestedSlidersPlugin // added + syntax to start open instead of closed ***/ //{{{ config.formatters.unshift( { name: "inlinesliders", // match: "\\+\\+\\+\\+|\\<slider", match: "\\<slider", // lookaheadRegExp: /(?:\+\+\+\+|<slider) (.*?)(?:>?)\n((?:.|\n)*?)\n(?:====|<\/slider>)/mg, lookaheadRegExp: /(?:<slider)(\+?) (.*?)(?:>)\n((?:.|\n)*?)\n(?:<\/slider>)/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source) if(lookaheadMatch && lookaheadMatch.index == w.matchStart ) { var btn = createTiddlyButton(w.output,lookaheadMatch[2] + " "+"\u00BB",lookaheadMatch[2],this.onClickSlider,"button sliderButton"); var panel = createTiddlyElement(w.output,"div",null,"sliderPanel"); panel.style.display = (lookaheadMatch[1] == '+' ? "block" : "none"); wikify(lookaheadMatch[3],panel); w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length; } }, onClickSlider : function(e) { if(!e) var e = window.event; var n = this.nextSibling; n.style.display = (n.style.display=="none") ? "block" : "none"; return false; } }); //}}} </pre> </div> <div title="Technology: the amazing guts of the small rabbit-eared green beast" modifier="Xavier" created="200807050033" modified="200807052344" tags="slide Technology" changecount="9"> <pre>!Technology: the amazing guts of the small rabbit-eared green beast * Design goals {{midImage{ [>img[http://wiki.laptop.org/images/2/25/Green-and-white-e-book.jpg]] }}} ** Low cost (but not "cheap") ** Low power consumption ** Durability ** Openess and collaboration ** Hackability and recoverability: kids should not be afraid to break it </pre> </div> <div title="The XO-2" modifier="Xavier" created="200807032042" modified="200807052354" tags="slide [[Still thinking BIG]] iframe" changecount="7"> <pre>!The XO-2 <html> <iframe src="http://www.flickr.com/photos/curiouslee/tags/xo2/show/" width="100%" height="500" name="flickrFrame" scrolling="auto" frameborder="0">sorry no iframes allowed in your browser</iframe> </html></pre> </div> <div title="The lab 0.1" modifier="Xavier" created="200807040609" modified="200807060019" tags="slide Lab" changecount="9"> <pre>! The lab 0.1 <html> <img src="http://www.orospakr.ca/assets/2006/11/6/first_run2.png" style="width:100%;"/> </html></pre> </div> <div title="The lab 0.1 design" modifier="Xavier" created="200807050524" modified="200807060007" tags="slide Lab" changecount="7"> <pre>!The lab 0.1 design {{centerColumn{ [img[http://upload.wikimedia.org/wikipedia/en/8/88/Rubenvent.jpg]] }}} ~~''Cunning plan'': I'll get one or more machines from Amazon's Elastic Computing Cloud ([[EC2|http://aws.amazon.com/ec2]]). Inside the machines I can run a few emulated ~OLPCs, that will be in the same network so we will be able to collaborate like the kids in a classroom. We will access ~OLPCs using VNC from our laptops/classroom machines.~~</pre> </div> <div title="The lab 0.1 implementation" modifier="Xavier" created="200807050525" modified="200807060010" tags="slide Lab" changecount="3"> <pre>!The lab 0.1 implementation * Alternatives considered ** [[Several QEMU instances|http://olpcaustria.org/mediawiki/index.php/Devserver]] ** [[Several User Mode Linux instances|http://osdir.com/ml/laptop.olpc.sugar/2006-11/msg00014.html]] * Alternatives implemented ** ? * Morale ** [[Optimism is an occupational hazard of programming|http://safari.oreilly.com/0201616416/ch07lev1sec3]] (Kent Beck) ** [[Don't Shave That Yak!|http://sethgodin.typepad.com/seths_blog/2005/03/dont_shave_that.html]] (Seth Godin)</pre> </div> <div title="The lab 0.2" modifier="Xavier" created="200807050528" modified="200807060021" tags="slide Lab" changecount="2"> <pre>!The lab 0.2 * Plan ** Burn some Life CDs so that people can play * Issues ** My CD writter is dead</pre> </div> <div title="The lab 0.3" modifier="Xavier" created="200807050529" modified="200807060021" tags="slide Lab" changecount="3"> <pre>!The lab 0.3 * Watch how I play with an OLPC in QEMU * Get to touch my daughter's OLPC</pre> </div> <div title="The movement marches on" modifier="Xavier" created="200807052331" modified="200807052353" tags="slide [[Still thinking BIG]]" changecount="7"> <pre>!The movement marches on >Remember that OLPC is not just a company, but also an eponymous movement. We owe [[Nicholas Negroponte]] a collective debt of gratitude for starting it, but good movements are far larger than their leaders >(...) Things could be better. The company could be sticking to its principles and doing what’s right. Sad as it is that this isn’t happening, (...) the movement marches on. And learning will win. Freedom will win. Children will win. {{attribution{Ivan Krstić: [[This, too, shall pass, or: Things to remember when reading news about OLPC|http://radian.org/notebook/this-too-shall-pass]] }}}</pre> </div> <div title="Think BIG!" modifier="Xavier" created="200807041805" modified="200807060026" tags="slide [[Still thinking BIG]]" changecount="9"> <pre>!Think BIG! {{centerColumn{ [[The movement marches on]]... isn't it important enough to jump on board? <html> <a href="http://www.flickr.com/photos/psd/2197292703/" title="dreamer, coder, hacker by psd, on Flickr"><img src="http://farm3.static.flickr.com/2285/2197292703_306b403598.jpg" width="500" height="357" alt="dreamer, coder, hacker" /></a> </html> }}} </pre> </div> <div title="Thinking BIG: Education" modifier="Xavier" created="200807041851" modified="200807060028" tags="slide [[Thinking BIG: Education]]" changecount="9"> <pre>!Thinking BIG: Education * [[Principles]] * [[Mission Statement]] * [[Some visionaries|Thinking BIG: Education]] ** [[Seymour Papert]] ** [[Allan Kay]] ** [[Nicholas Negroponte]] * [[Constructionism]]</pre> </div> <div title="TiddlerWithEditPlugin" modifier="Saq" created="200607191629" tags="lewcidExtension systemConfig" server.type="file" server.host="tw.lewcid.org" server.page.revision="200607191629"> <pre>/*** |Name|TiddlerWithEditPlugin| |Created by|SaqImtiaz| |Location|http://tw.lewcid.org/#TiddlerWithEditPlugin| |Version|0.2| |Requires|~TW2.x| !Description: Adds 'doubleclick to edit source' capabilites to the core {{{<<tiddler>>}}} macro. !Notes: *because of the rewrite, only clicking on actual embedded text opens the source tiddler for editing. Clicking on any white space opens the containing tiddler for editing. !History *29-04-06, version 0.2, rewritten after input from Udo. *28-04-06, version 0.1, working. !Code ***/ //{{{ config.macros.tiddler.onTiddlerMacroDblClick = function(e){ if (!e) var e = window.event; var theTarget = resolveTarget(e); var title= this.getAttribute("source"); if ((version.extensions.PartTiddlerPlugin)&&(title.indexOf("/")!=-1)) {if (!oldFetchTiddler.call(this, [title])) {title=title.slice(0,title.lastIndexOf("/"))}} story.displayTiddler(theTarget,title,2,false,null) e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); return false; } var oldTiddlerHandler=config.macros.tiddler.handler; config.macros.tiddler.handler = function(place,macroName,params){ oldTiddlerHandler.apply(this,arguments); place.lastChild.setAttribute("source",params[0]); place.lastChild.ondblclick = this.onTiddlerMacroDblClick; } //}}}</pre> </div> <div title="ToggleTagPlugin" modifier="MPTW" created="200805121716" modified="200806181402" tags="systemConfig"> <pre>/*** |Name:|ToggleTagPlugin| |Description:|Makes a checkbox which toggles a tag in a tiddler| |Version:|3.1.0 ($Rev: 4907 $)| |Date:|$Date: 2008-05-13 03:15:46 +1000 (Tue, 13 May 2008) $| |Source:|http://mptw.tiddlyspot.com/#ToggleTagPlugin| |Author:|Simon Baird <simon.baird@gmail.com>| |License:|http://mptw.tiddlyspot.com/#TheBSDLicense| !!Usage {{{<<toggleTag }}}//{{{TagName TiddlerName LabelText}}}//{{{>>}}} * TagName - the tag to be toggled, default value "checked" * TiddlerName - the tiddler to toggle the tag in, default value the current tiddler * LabelText - the text (gets wikified) to put next to the check box, default value is '{{{[[TagName]]}}}' or '{{{[[TagName]] [[TiddlerName]]}}}' (If a parameter is '.' then the default will be used) * TouchMod flag - if non empty then touch the tiddlers mod date. Note, can set config.toggleTagAlwaysTouchModDate to always touch mod date !!Examples |Code|Description|Example|h |{{{<<toggleTag>>}}}|Toggles the default tag (checked) in this tiddler|<<toggleTag>>| |{{{<<toggleTag TagName>>}}}|Toggles the TagName tag in this tiddler|<<toggleTag TagName>>| |{{{<<toggleTag TagName TiddlerName>>}}}|Toggles the TagName tag in the TiddlerName tiddler|<<toggleTag TagName TiddlerName>>| |{{{<<toggleTag TagName TiddlerName 'click me'>>}}}|Same but with custom label|<<toggleTag TagName TiddlerName 'click me'>>| |{{{<<toggleTag . . 'click me'>>}}}|dot means use default value|<<toggleTag . . 'click me'>>| !!Notes * If TiddlerName doesn't exist it will be silently created * Set label to '-' to specify no label * See also http://mgtd-alpha.tiddlyspot.com/#ToggleTag2 !!Known issues * Doesn't smoothly handle the case where you toggle a tag in a tiddler that is current open for editing * Should convert to use named params ***/ //{{{ if (config.toggleTagAlwaysTouchModDate == undefined) config.toggleTagAlwaysTouchModDate = false; merge(config.macros,{ toggleTag: { createIfRequired: true, shortLabel: "[[%0]]", longLabel: "[[%0]] [[%1]]", handler: function(place,macroName,params,wikifier,paramString,tiddler) { var tiddlerTitle = tiddler ? tiddler.title : ''; var tag = (params[0] && params[0] != '.') ? params[0] : "checked"; var title = (params[1] && params[1] != '.') ? params[1] : tiddlerTitle; var defaultLabel = (title == tiddlerTitle ? this.shortLabel : this.longLabel); var label = (params[2] && params[2] != '.') ? params[2] : defaultLabel; var touchMod = (params[3] && params[3] != '.') ? params[3] : ""; label = (label == '-' ? '' : label); // dash means no label var theTiddler = (title == tiddlerTitle ? tiddler : store.getTiddler(title)); var cb = createTiddlyCheckbox(place, label.format([tag,title]), theTiddler && theTiddler.isTagged(tag), function(e) { if (!store.tiddlerExists(title)) { if (config.macros.toggleTag.createIfRequired) { var content = store.getTiddlerText(title); // just in case it's a shadow store.saveTiddler(title,title,content?content:"",config.options.txtUserName,new Date(),null); } else return false; } if ((touchMod != "" || config.toggleTagAlwaysTouchModDate) && theTiddler) theTiddler.modified = new Date(); store.setTiddlerTag(title,this.checked,tag); return true; }); } } }); //}}} </pre> </div> <div title="Wifi and collaboration" modifier="Xavier" created="200807050122" modified="200807052346" tags="slide Technology" changecount="4"> <pre>!Wifi + collaboration * Mesh network (peer to peer) * Wifi not handled by the CPU but has its own processor * When suspended, Wifi is still on to keep the mesh alive * [[Antenna diversity|http://en.wikipedia.org/wiki/Antenna_diversity]]: having more than one antenna improves the quality and reliability of a wireless link * 2 Mb/s maximum to keep the power consumtion down * 2 Km range in the Australian Outback * Built-in camera and microphone</pre> </div> <div title="YourSearchPlugin" modifier="UdoBorkowski" created="200601161427" modified="200804160908" tags="Plugin UdoBorkowski YourSearchProject systemConfig" server.type="file" server.host="tiddlywiki.abego-software.de" server.page.revision="200804160908"> <pre>/*** |''Name:''|YourSearchPlugin| |''Version:''|2.1.3 (2008-04-16)| |''Source:''|http://tiddlywiki.abego-software.de/#YourSearchPlugin| |''Author:''|UdoBorkowski (ub [at] abego-software [dot] de)| |''Licence:''|[[BSD open source license (abego Software)|http://www.abego-software.de/legal/apl-v10.html]]| |''Copyright:''|&copy; 2005-2008 [[abego Software|http://www.abego-software.de]]| |''~CoreVersion:''|2.1.0| |''Community:''|[[del.icio.us|http://del.icio.us/post?url=http://tiddlywiki.abego-software.de/index.html%23YourSearchPlugin]]| |''Browser:''|Firefox 1.0.4+; Firefox 1.5; ~InternetExplorer 6.0| !About YourSearch YourSearch gives you a bunch of new features to simplify and speed up your daily searches in TiddlyWiki. It seamlessly integrates into the standard TiddlyWiki search: just start typing into the 'search' field and explore! For more information see [[Help|YourSearch Help]]. !Compatibility This plugin requires TiddlyWiki 2.1. Check the [[archive|http://tiddlywiki.abego-software.de/archive]] for ~YourSearchPlugins supporting older versions of TiddlyWiki. !Source Code ***/ /*** This plugin's source code is compressed (and hidden). Use this [[link|http://tiddlywiki.abego-software.de/archive/YourSearchPlugin/Plugin-YourSearch-src.2.1.3.js]] to get the readable source code. ***/ ///% if(!version.extensions.YourSearchPlugin){version.extensions.YourSearchPlugin={major:2,minor:1,revision:3,source:"http://tiddlywiki.abego-software.de/#YourSearchPlugin",licence:"[[BSD open source license (abego Software)|http://www.abego-software.de/legal/apl-v10.html]]",copyright:"Copyright (c) abego Software GmbH, 2005-2008 (www.abego-software.de)"};if(!window.abego){window.abego={};} if(!Array.forEach){Array.forEach=function(_1,_2,_3){for(var i=0,len=_1.length;i<len;i++){_2.call(_3,_1[i],i,_1);}};Array.prototype.forEach=function(_5,_6){for(var i=0,len=this.length;i<len;i++){_5.call(_6,this[i],i,this);}};} abego.toInt=function(s,_9){if(!s){return _9;} var n=parseInt(s);return(n==NaN)?_9:n;};abego.createEllipsis=function(_b){var e=createTiddlyElement(_b,"span");e.innerHTML="&hellip;";};abego.shallowCopy=function(_d){if(!_d){return _d;} var _e={};for(var n in _d){_e[n]=_d[n];} return _e;};abego.copyOptions=function(_10){return!_10?{}:abego.shallowCopy(_10);};abego.countStrings=function(_11,s){if(!s){return 0;} var len=s.length;var n=0;var _15=0;while(1){var i=_11.indexOf(s,_15);if(i<0){return n;} n++;_15=i+len;} return n;};abego.getBracedText=function(_17,_18,_19){if(!_18){_18=0;} var re=/\{([^\}]*)\}/gm;re.lastIndex=_18;var m=re.exec(_17);if(m){var s=m[1];var _1d=abego.countStrings(s,"{");if(!_1d){if(_19){_19.lastIndex=re.lastIndex;} return s;} var len=_17.length;for(var i=re.lastIndex;i<len&&_1d;i++){var c=_17.charAt(i);if(c=="{"){_1d++;}else{if(c=="}"){_1d--;}}} if(!_1d){if(_19){_19.lastIndex=i-1;} return _17.substring(m.index+1,i-1);}}};abego.select=function(_21,_22,_23,_24){if(!_24){_24=[];} _21.forEach(function(t){if(_22.call(_23,t)){_24.push(t);}});return _24;};abego.consumeEvent=function(e){if(e.stopPropagation){e.stopPropagation();} if(e.preventDefault){e.preventDefault();} e.cancelBubble=true;e.returnValue=true;};abego.TiddlerFilterTerm=function(_27,_28){if(!_28){_28={};} var _29=_27;if(!_28.textIsRegExp){_29=_27.escapeRegExp();if(_28.fullWordMatch){_29="\\b"+_29+"\\b";}} var _2a=new RegExp(_29,"m"+(_28.caseSensitive?"":"i"));this.tester=new abego.MultiFieldRegExpTester(_2a,_28.fields,_28.withExtendedFields);};abego.TiddlerFilterTerm.prototype.test=function(_2b){return this.tester.test(_2b);};abego.parseNewTiddlerCommandLine=function(s){var m=/(.*?)\.(?:\s+|$)([^#]*)(#.*)?/.exec(s);if(!m){m=/([^#]*)()(#.*)?/.exec(s);} if(m){var r;if(m[3]){var s2=m[3].replace(/#/g,"");r=s2.parseParams("tag");}else{r=[[]];} var _30=m[2]?m[2].trim():"";r.push({name:"text",value:_30});r[0].text=[_30];return{title:m[1].trim(),params:r};}else{return{title:s.trim(),params:[[]]};}};abego.parseTiddlerFilterTerm=function(_31,_32,_33){var re=/\s*(?:(?:\{([^\}]*)\})|(?:(=)|([#%!])|(?:(\w+)\s*\:(?!\/\/))|(?:(?:("(?:(?:\\")|[^"])+")|(?:\/((?:(?:\\\/)|[^\/])+)\/)|(\w+\:\/\/[^\s]+)|([^\s\)\-\"]+)))))/mg;var _35={"!":"title","%":"text","#":"tags"};var _36={};var _37;re.lastIndex=_32;while(1){var i=re.lastIndex;var m=re.exec(_31);if(!m||m.index!=i){throw"Word or String literal expected";} if(m[1]){var _3a={};var _3b=abego.getBracedText(_31,0,_3a);if(!_3b){throw"Invalid {...} syntax";} var f=Function("tiddler","return ("+_3b+");");return{func:f,lastIndex:_3a.lastIndex,markRE:null};} if(m[2]){_37=true;}else{if(m[3]){_36[_35[m[3]]]=1;}else{if(m[4]){_36[m[4]]=1;}else{var _3d=m[6];var _3e=m[5]?window.eval(m[5]):m[6]?m[6]:m[7]?m[7]:m[8];var _33=abego.copyOptions(_33);_33.fullWordMatch=_37;_33.textIsRegExp=_3d;var _3f=[];for(var n in _36){_3f.push(n);} if(_3f.length==0){_33.fields=_33.defaultFields;}else{_33.fields=_3f;_33.withExtendedFields=false;} var _41=new abego.TiddlerFilterTerm(_3e,_33);var _42=_3d?_3e:_3e.escapeRegExp();if(_42&&_37){_42="\\b"+_42+"\\b";} return{func:function(_43){return _41.test(_43);},lastIndex:re.lastIndex,markRE:_42?"(?:"+_42+")":null};}}}}};abego.BoolExp=function(s,_45,_46){this.s=s;var _47=_46&&_46.defaultOperationIs_OR;var _48=/\s*(?:(\-|not)|(\())/gi;var _49=/\s*\)/g;var _4a=/\s*(?:(and|\&\&)|(or|\|\|))/gi;var _4b=/\s*[^\)\s]/g;var _4c=/\s*(\-|not)?(\s*\()?/gi;var _4d;var _4e=function(_4f){_4c.lastIndex=_4f;var m=_4c.exec(s);var _51;var _52;if(m&&m.index==_4f){_4f+=m[0].length;_51=m[1];if(m[2]){var e=_4d(_4f);_49.lastIndex=e.lastIndex;if(!_49.exec(s)){throw"Missing ')'";} _52={func:e.func,lastIndex:_49.lastIndex,markRE:e.markRE};}} if(!_52){_52=_45(s,_4f,_46);} if(_51){_52.func=(function(f){return function(_55){return!f(_55);};})(_52.func);_52.markRE=null;} return _52;};_4d=function(_56){var _57=_4e(_56);while(1){var l=_57.lastIndex;_4a.lastIndex=l;var m=_4a.exec(s);var _5a;var _5b;if(m&&m.index==l){_5a=!m[1];_5b=_4e(_4a.lastIndex);}else{try{_5b=_4e(l);} catch(e){return _57;} _5a=_47;} _57.func=(function(_5c,_5d,_5e){return _5e?function(_5f){return _5c(_5f)||_5d(_5f);}:function(_60){return _5c(_60)&&_5d(_60);};})(_57.func,_5b.func,_5a);_57.lastIndex=_5b.lastIndex;if(!_57.markRE){_57.markRE=_5b.markRE;}else{if(_5b.markRE){_57.markRE=_57.markRE+"|"+_5b.markRE;}}}};var _61=_4d(0);this.evalFunc=_61.func;if(_61.markRE){this.markRegExp=new RegExp(_61.markRE,_46.caseSensitive?"mg":"img");}};abego.BoolExp.prototype.exec=function(){return this.evalFunc.apply(this,arguments);};abego.BoolExp.prototype.getMarkRegExp=function(){return this.markRegExp;};abego.BoolExp.prototype.toString=function(){return this.s;};abego.MultiFieldRegExpTester=function(re,_63,_64){this.re=re;this.fields=_63?_63:["title","text","tags"];this.withExtendedFields=_64;};abego.MultiFieldRegExpTester.prototype.test=function(_65){var re=this.re;for(var i=0;i<this.fields.length;i++){var s=store.getValue(_65,this.fields[i]);if(typeof s=="string"&&re.test(s)){return this.fields[i];}} if(this.withExtendedFields){return store.forEachField(_65,function(_69,_6a,_6b){return typeof _6b=="string"&&re.test(_6b)?_6a:null;},true);} return null;};abego.TiddlerQuery=function(_6c,_6d,_6e,_6f,_70){if(_6e){this.regExp=new RegExp(_6c,_6d?"mg":"img");this.tester=new abego.MultiFieldRegExpTester(this.regExp,_6f,_70);}else{this.expr=new abego.BoolExp(_6c,abego.parseTiddlerFilterTerm,{defaultFields:_6f,caseSensitive:_6d,withExtendedFields:_70});} this.getQueryText=function(){return _6c;};this.getUseRegExp=function(){return _6e;};this.getCaseSensitive=function(){return _6d;};this.getDefaultFields=function(){return _6f;};this.getWithExtendedFields=function(){return _70;};};abego.TiddlerQuery.prototype.test=function(_71){if(!_71){return false;} if(this.regExp){return this.tester.test(_71);} return this.expr.exec(_71);};abego.TiddlerQuery.prototype.filter=function(_72){return abego.select(_72,this.test,this);};abego.TiddlerQuery.prototype.getMarkRegExp=function(){if(this.regExp){return"".search(this.regExp)>=0?null:this.regExp;} return this.expr.getMarkRegExp();};abego.TiddlerQuery.prototype.toString=function(){return(this.regExp?this.regExp:this.expr).toString();};abego.PageWiseRenderer=function(){this.firstIndexOnPage=0;};merge(abego.PageWiseRenderer.prototype,{setItems:function(_73){this.items=_73;this.setFirstIndexOnPage(0);},getMaxPagesInNavigation:function(){return 10;},getItemsCount:function(_74){return this.items?this.items.length:0;},getCurrentPageIndex:function(){return Math.floor(this.firstIndexOnPage/this.getItemsPerPage());},getLastPageIndex:function(){return Math.floor((this.getItemsCount()-1)/this.getItemsPerPage());},setFirstIndexOnPage:function(_75){this.firstIndexOnPage=Math.min(Math.max(0,_75),this.getItemsCount()-1);},getFirstIndexOnPage:function(){this.firstIndexOnPage=Math.floor(this.firstIndexOnPage/this.getItemsPerPage())*this.getItemsPerPage();return this.firstIndexOnPage;},getLastIndexOnPage:function(){return Math.min(this.getFirstIndexOnPage()+this.getItemsPerPage()-1,this.getItemsCount()-1);},onPageChanged:function(_76,_77){},renderPage:function(_78){if(_78.beginRendering){_78.beginRendering(this);} try{if(this.getItemsCount()){var _79=this.getLastIndexOnPage();var _7a=-1;for(var i=this.getFirstIndexOnPage();i<=_79;i++){_7a++;_78.render(this,this.items[i],i,_7a);}}} finally{if(_78.endRendering){_78.endRendering(this);}}},addPageNavigation:function(_7c){if(!this.getItemsCount()){return;} var _7d=this;var _7e=function(e){if(!e){var e=window.event;} abego.consumeEvent(e);var _80=abego.toInt(this.getAttribute("page"),0);var _81=_7d.getCurrentPageIndex();if(_80==_81){return;} var _82=_80*_7d.getItemsPerPage();_7d.setFirstIndexOnPage(_82);_7d.onPageChanged(_80,_81);};var _83;var _84=this.getCurrentPageIndex();var _85=this.getLastPageIndex();if(_84>0){_83=createTiddlyButton(_7c,"Previous","Go to previous page (Shortcut: Alt-'<')",_7e,"prev");_83.setAttribute("page",(_84-1).toString());_83.setAttribute("accessKey","<");} for(var i=-this.getMaxPagesInNavigation();i<this.getMaxPagesInNavigation();i++){var _87=_84+i;if(_87<0){continue;} if(_87>_85){break;} var _88=(i+_84+1).toString();var _89=_87==_84?"currentPage":"otherPage";_83=createTiddlyButton(_7c,_88,"Go to page %0".format([_88]),_7e,_89);_83.setAttribute("page",(_87).toString());} if(_84<_85){_83=createTiddlyButton(_7c,"Next","Go to next page (Shortcut: Alt-'>')",_7e,"next");_83.setAttribute("page",(_84+1).toString());_83.setAttribute("accessKey",">");}}});abego.LimitedTextRenderer=function(){var _8a=40;var _8b=4;var _8c=function(_8d,_8e,_8f){var n=_8d.length;if(n==0){_8d.push({start:_8e,end:_8f});return;} var i=0;for(;i<n;i++){var _92=_8d[i];if(_92.start<=_8f&&_8e<=_92.end){var r;var _94=i+1;for(;_94<n;_94++){r=_8d[_94];if(r.start>_8f||_8e>_92.end){break;}} var _95=_8e;var _96=_8f;for(var j=i;j<_94;j++){r=_8d[j];_95=Math.min(_95,r.start);_96=Math.max(_96,r.end);} _8d.splice(i,_94-i,{start:_95,end:_96});return;} if(_92.start>_8f){break;}} _8d.splice(i,0,{start:_8e,end:_8f});};var _98=function(_99){var _9a=0;for(var i=0;i<_99.length;i++){var _9c=_99[i];_9a+=_9c.end-_9c.start;} return _9a;};var _9d=function(c){return(c>="a"&&c<="z")||(c>="A"&&c<="Z")||c=="_";};var _9f=function(s,_a1){if(!_9d(s[_a1])){return null;} for(var i=_a1-1;i>=0&&_9d(s[i]);i--){} var _a3=i+1;var n=s.length;for(i=_a1+1;i<n&&_9d(s[i]);i++){} return{start:_a3,end:i};};var _a5=function(s,_a7,_a8){var _a9;if(_a8){_a9=_9f(s,_a7);}else{if(_a7<=0){return _a7;} _a9=_9f(s,_a7-1);} if(!_a9){return _a7;} if(_a8){if(_a9.start>=_a7-_8b){return _a9.start;} if(_a9.end<=_a7+_8b){return _a9.end;}}else{if(_a9.end<=_a7+_8b){return _a9.end;} if(_a9.start>=_a7-_8b){return _a9.start;}} return _a7;};var _aa=function(s,_ac){var _ad=[];if(_ac){var _ae=0;var n=s.length;var _b0=0;do{_ac.lastIndex=_ae;var _b1=_ac.exec(s);if(_b1){if(_ae<_b1.index){var t=s.substring(_ae,_b1.index);_ad.push({text:t});} _ad.push({text:_b1[0],isMatch:true});_ae=_b1.index+_b1[0].length;}else{_ad.push({text:s.substr(_ae)});break;}}while(true);}else{_ad.push({text:s});} return _ad;};var _b3=function(_b4){var _b5=0;for(var i=0;i<_b4.length;i++){if(_b4[i].isMatch){_b5++;}} return _b5;};var _b7=function(s,_b9,_ba,_bb,_bc){var _bd=Math.max(Math.floor(_bc/(_bb+1)),_8a);var _be=Math.max(_bd-(_ba-_b9),0);var _bf=Math.min(Math.floor(_ba+_be/3),s.length);var _c0=Math.max(_bf-_bd,0);_c0=_a5(s,_c0,true);_bf=_a5(s,_bf,false);return{start:_c0,end:_bf};};var _c1=function(_c2,s,_c4){var _c5=[];var _c6=_b3(_c2);var pos=0;for(var i=0;i<_c2.length;i++){var t=_c2[i];var _ca=t.text;if(t.isMatch){var _cb=_b7(s,pos,pos+_ca.length,_c6,_c4);_8c(_c5,_cb.start,_cb.end);} pos+=_ca.length;} return _c5;};var _cc=function(s,_ce,_cf){var _d0=_cf-_98(_ce);while(_d0>0){if(_ce.length==0){_8c(_ce,0,_a5(s,_cf,false));return;}else{var _d1=_ce[0];var _d2;var _d3;if(_d1.start==0){_d2=_d1.end;if(_ce.length>1){_d3=_ce[1].start;}else{_8c(_ce,_d2,_a5(s,_d2+_d0,false));return;}}else{_d2=0;_d3=_d1.start;} var _d4=Math.min(_d3,_d2+_d0);_8c(_ce,_d2,_d4);_d0-=(_d4-_d2);}}};var _d5=function(_d6,s,_d8,_d9,_da){if(_d9.length==0){return;} var _db=function(_dc,s,_de,_df,_e0){var t;var _e2;var pos=0;var i=0;var _e5=0;for(;i<_de.length;i++){t=_de[i];_e2=t.text;if(_df<pos+_e2.length){_e5=_df-pos;break;} pos+=_e2.length;} var _e6=_e0-_df;for(;i<_de.length&&_e6>0;i++){t=_de[i];_e2=t.text.substr(_e5);_e5=0;if(_e2.length>_e6){_e2=_e2.substr(0,_e6);} if(t.isMatch){createTiddlyElement(_dc,"span",null,"marked",_e2);}else{createTiddlyText(_dc,_e2);} _e6-=_e2.length;} if(_e0<s.length){abego.createEllipsis(_dc);}};if(_d9[0].start>0){abego.createEllipsis(_d6);} var _e7=_da;for(var i=0;i<_d9.length&&_e7>0;i++){var _e9=_d9[i];var len=Math.min(_e9.end-_e9.start,_e7);_db(_d6,s,_d8,_e9.start,_e9.start+len);_e7-=len;}};this.render=function(_eb,s,_ed,_ee){if(s.length<_ed){_ed=s.length;} var _ef=_aa(s,_ee);var _f0=_c1(_ef,s,_ed);_cc(s,_f0,_ed);_d5(_eb,s,_ef,_f0,_ed);};};(function(){function alertAndThrow(msg){alert(msg);throw msg;} if(version.major<2||(version.major==2&&version.minor<1)){alertAndThrow("YourSearchPlugin requires TiddlyWiki 2.1 or newer.\n\nCheck the archive for YourSearch plugins\nsupporting older versions of TiddlyWiki.\n\nArchive: http://tiddlywiki.abego-software.de/archive");} abego.YourSearch={};var _f2;var _f3;var _f4=function(_f5){_f2=_f5;};var _f6=function(){return _f2?_f2:[];};var _f7=function(){return _f2?_f2.length:0;};var _f8=4;var _f9=10;var _fa=2;var _fb=function(s,re){var m=s.match(re);return m?m.length:0;};var _ff=function(_100,_101){var _102=_101.getMarkRegExp();if(!_102){return 1;} var _103=_100.title.match(_102);var _104=_103?_103.length:0;var _105=_fb(_100.getTags(),_102);var _106=_103?_103.join("").length:0;var _107=_100.title.length>0?_106/_100.title.length:0;var rank=_104*_f8+_105*_fa+_107*_f9+1;return rank;};var _109=function(_10a,_10b,_10c,_10d,_10e,_10f){_f3=null;var _110=_10a.reverseLookup("tags",_10f,false);try{var _111=[];if(config.options.chkSearchInTitle){_111.push("title");} if(config.options.chkSearchInText){_111.push("text");} if(config.options.chkSearchInTags){_111.push("tags");} _f3=new abego.TiddlerQuery(_10b,_10c,_10d,_111,config.options.chkSearchExtendedFields);} catch(e){return[];} var _112=_f3.filter(_110);var _113=abego.YourSearch.getRankFunction();for(var i=0;i<_112.length;i++){var _115=_112[i];var rank=_113(_115,_f3);_115.searchRank=rank;} if(!_10e){_10e="title";} var _117=function(a,b){var _11a=a.searchRank-b.searchRank;if(_11a==0){if(a[_10e]==b[_10e]){return(0);}else{return(a[_10e]<b[_10e])?-1:+1;}}else{return(_11a>0)?-1:+1;}};_112.sort(_117);return _112;};var _11b=80;var _11c=50;var _11d=250;var _11e=50;var _11f=25;var _120=10;var _121="yourSearchResult";var _122="yourSearchResultItems";var _123;var _124;var _125;var _126;var _127;var _128=function(){if(version.extensions.YourSearchPlugin.styleSheetInited){return;} version.extensions.YourSearchPlugin.styleSheetInited=true;setStylesheet(store.getTiddlerText("YourSearchStyleSheet"),"yourSearch");};var _129=function(){return _124!=null&&_124.parentNode==document.body;};var _12a=function(){if(_129()){document.body.removeChild(_124);}};var _12b=function(e){_12a();var _12d=this.getAttribute("tiddlyLink");if(_12d){var _12e=this.getAttribute("withHilite");var _12f=highlightHack;if(_12e&&_12e=="true"&&_f3){highlightHack=_f3.getMarkRegExp();} story.displayTiddler(this,_12d);highlightHack=_12f;} return(false);};var _130=function(){if(!_125){return;} var root=_125;var _132=findPosX(root);var _133=findPosY(root);var _134=root.offsetHeight;var _135=_132;var _136=_133+_134;var _137=findWindowWidth();if(_137<_124.offsetWidth){_124.style.width=(_137-100)+"px";_137=findWindowWidth();} var _138=_124.offsetWidth;if(_135+_138>_137){_135=_137-_138-30;} if(_135<0){_135=0;} _124.style.left=_135+"px";_124.style.top=_136+"px";_124.style.display="block";};var _139=function(){if(_124){window.scrollTo(0,ensureVisible(_124));} if(_125){window.scrollTo(0,ensureVisible(_125));}};var _13a=function(){_130();_139();};var _13b;var _13c;var _13d=new abego.PageWiseRenderer();var _13e=function(_13f){this.itemHtml=store.getTiddlerText("YourSearchItemTemplate");if(!this.itemHtml){alertAndThrow("YourSearchItemTemplate not found");} this.place=document.getElementById(_122);if(!this.place){this.place=createTiddlyElement(_13f,"div",_122);}};merge(_13e.prototype,{render:function(_140,_141,_142,_143){_13b=_143;_13c=_141;var item=createTiddlyElement(this.place,"div",null,"yourSearchItem");item.innerHTML=this.itemHtml;applyHtmlMacros(item,null);refreshElements(item,null);},endRendering:function(_145){_13c=null;}});var _146=function(){if(!_124||!_125){return;} var html=store.getTiddlerText("YourSearchResultTemplate");if(!html){html="<b>Tiddler YourSearchResultTemplate not found</b>";} _124.innerHTML=html;applyHtmlMacros(_124,null);refreshElements(_124,null);var _148=new _13e(_124);_13d.renderPage(_148);_13a();};_13d.getItemsPerPage=function(){var n=(config.options.chkPreviewText)?abego.toInt(config.options.txtItemsPerPageWithPreview,_120):abego.toInt(config.options.txtItemsPerPage,_11f);return(n>0)?n:1;};_13d.onPageChanged=function(){_146();};var _14a=function(){if(_125==null||!config.options.chkUseYourSearch){return;} if((_125.value==_123)&&_123&&!_129()){if(_124&&(_124.parentNode!=document.body)){document.body.appendChild(_124);_13a();}else{abego.YourSearch.onShowResult(true);}}};var _14b=function(){_12a();_124=null;_123=null;};var _14c=function(self,e){while(e!=null){if(self==e){return true;} e=e.parentNode;} return false;};var _14f=function(e){if(e.target==_125){return;} if(e.target==_126){return;} if(_124&&_14c(_124,e.target)){return;} _12a();};var _151=function(e){if(e.keyCode==27){_12a();}};addEvent(document,"click",_14f);addEvent(document,"keyup",_151);var _153=function(text,_155,_156){_123=text;_f4(_109(store,text,_155,_156,"title","excludeSearch"));abego.YourSearch.onShowResult();};var _157=function(_158,_159,_15a,_15b,_15c,_15d){_128();_123="";var _15e=null;var _15f=function(txt){if(config.options.chkUseYourSearch){_153(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);}else{story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);} _123=txt.value;};var _161=function(e){_15f(_125);return false;};var _163=function(e){if(!e){var e=window.event;} _125=this;switch(e.keyCode){case 13:if(e.ctrlKey&&_127&&_129()){_127.onclick.apply(_127,[e]);}else{_15f(this);} break;case 27:if(_129()){_12a();}else{this.value="";clearMessage();} break;} if(String.fromCharCode(e.keyCode)==this.accessKey||e.altKey){_14a();} if(this.value.length<3&&_15e){clearTimeout(_15e);} if(this.value.length>2){if(this.value!=_123){if(!config.options.chkUseYourSearch||config.options.chkSearchAsYouType){if(_15e){clearTimeout(_15e);} var txt=this;_15e=setTimeout(function(){_15f(txt);},500);}}else{if(_15e){clearTimeout(_15e);}}} if(this.value.length==0){_12a();}};var _166=function(e){this.select();clearMessage();_14a();};var args=_15c.parseParams("list",null,true);var _169=getFlag(args,"buttonAtRight");var _16a=getParam(args,"sizeTextbox",this.sizeTextbox);var btn;if(!_169){btn=createTiddlyButton(_158,this.label,this.prompt,_161);} var txt=createTiddlyElement(_158,"input",null,null,null);if(_15a[0]){txt.value=_15a[0];} txt.onkeyup=_163;txt.onfocus=_166;txt.setAttribute("size",_16a);txt.setAttribute("accessKey",this.accessKey);txt.setAttribute("autocomplete","off");if(config.browser.isSafari){txt.setAttribute("type","search");txt.setAttribute("results","5");}else{txt.setAttribute("type","text");} if(_169){btn=createTiddlyButton(_158,this.label,this.prompt,_161);} _125=txt;_126=btn;};var _16d=function(){_12a();var _16e=_f6();var n=_16e.length;if(n){var _170=[];for(var i=0;i<n;i++){_170.push(_16e[i].title);} story.displayTiddlers(null,_170);}};var _172=function(_173,_174,_175,_176){invokeMacro(_173,"option",_174,_175,_176);var elem=_173.lastChild;var _178=elem.onclick;elem.onclick=function(e){var _17a=_178.apply(this,arguments);_146();return _17a;};return elem;};var _17b=function(s){var _17d=["''","{{{","}}}","//","<<<","/***","***/"];var _17e="";for(var i=0;i<_17d.length;i++){if(i!=0){_17e+="|";} _17e+="("+_17d[i].escapeRegExp()+")";} return s.replace(new RegExp(_17e,"mg"),"").trim();};var _180=function(){var i=_13b;return(i>=0&&i<=9)?(i<9?(i+1):0):-1;};var _182=new abego.LimitedTextRenderer();var _183=function(_184,s,_186){_182.render(_184,s,_186,_f3.getMarkRegExp());};var _187=TiddlyWiki.prototype.saveTiddler;TiddlyWiki.prototype.saveTiddler=function(_188,_189,_18a,_18b,_18c,tags,_18e){_187.apply(this,arguments);_14b();};var _18f=TiddlyWiki.prototype.removeTiddler;TiddlyWiki.prototype.removeTiddler=function(_190){_18f.apply(this,arguments);_14b();};config.macros.yourSearch={label:"yourSearch",prompt:"Gives access to the current/last YourSearch result",handler:function(_191,_192,_193,_194,_195,_196){if(_193.length==0){return;} var name=_193[0];var func=config.macros.yourSearch.funcs[name];if(func){func(_191,_192,_193,_194,_195,_196);}},tests:{"true":function(){return true;},"false":function(){return false;},"found":function(){return _f7()>0;},"previewText":function(){return config.options.chkPreviewText;}},funcs:{itemRange:function(_199){if(_f7()){var _19a=_13d.getLastIndexOnPage();var s="%0 - %1".format([_13d.getFirstIndexOnPage()+1,_19a+1]);createTiddlyText(_199,s);}},count:function(_19c){createTiddlyText(_19c,_f7().toString());},query:function(_19d){if(_f3){createTiddlyText(_19d,_f3.toString());}},version:function(_19e){var t="YourSearch %0.%1.%2".format([version.extensions.YourSearchPlugin.major,version.extensions.YourSearchPlugin.minor,version.extensions.YourSearchPlugin.revision]);var e=createTiddlyElement(_19e,"a");e.setAttribute("href","http://tiddlywiki.abego-software.de/#YourSearchPlugin");e.innerHTML="<font color=\"black\" face=\"Arial, Helvetica, sans-serif\">"+t+"<font>";},copyright:function(_1a1){var e=createTiddlyElement(_1a1,"a");e.setAttribute("href","http://www.abego-software.de");e.innerHTML="<font color=\"black\" face=\"Arial, Helvetica, sans-serif\">&copy; 2005-2008 <b><font color=\"red\">abego</font></b> Software<font>";},newTiddlerButton:function(_1a3){if(_f3){var r=abego.parseNewTiddlerCommandLine(_f3.getQueryText());var btn=config.macros.newTiddler.createNewTiddlerButton(_1a3,r.title,r.params,"new tiddler","Create a new tiddler based on search text. (Shortcut: Ctrl-Enter; Separators: '.', '#')",null,"text");var _1a6=btn.onclick;btn.onclick=function(){_12a();_1a6.apply(this,arguments);};_127=btn;}},linkButton:function(_1a7,_1a8,_1a9,_1aa,_1ab,_1ac){if(_1a9<2){return;} var _1ad=_1a9[1];var text=_1a9<3?_1ad:_1a9[2];var _1af=_1a9<4?text:_1a9[3];var _1b0=_1a9<5?null:_1a9[4];var btn=createTiddlyButton(_1a7,text,_1af,_12b,null,null,_1b0);btn.setAttribute("tiddlyLink",_1ad);},closeButton:function(_1b2,_1b3,_1b4,_1b5,_1b6,_1b7){var _1b8=createTiddlyButton(_1b2,"close","Close the Search Results (Shortcut: ESC)",_12a);},openAllButton:function(_1b9,_1ba,_1bb,_1bc,_1bd,_1be){var n=_f7();if(n==0){return;} var _1c0=n==1?"open tiddler":"open all %0 tiddlers".format([n]);var _1c1=createTiddlyButton(_1b9,_1c0,"Open all found tiddlers (Shortcut: Alt-O)",_16d);_1c1.setAttribute("accessKey","O");},naviBar:function(_1c2,_1c3,_1c4,_1c5,_1c6,_1c7){_13d.addPageNavigation(_1c2);},"if":function(_1c8,_1c9,_1ca,_1cb,_1cc,_1cd){if(_1ca.length<2){return;} var _1ce=_1ca[1];var _1cf=(_1ce=="not");if(_1cf){if(_1ca.length<3){return;} _1ce=_1ca[2];} var test=config.macros.yourSearch.tests[_1ce];var _1d1=false;try{if(test){_1d1=test(_1c8,_1c9,_1ca,_1cb,_1cc,_1cd)!=_1cf;}else{_1d1=(!eval(_1ce))==_1cf;}} catch(ex){} if(!_1d1){_1c8.style.display="none";}},chkPreviewText:function(_1d2,_1d3,_1d4,_1d5,_1d6,_1d7){var _1d8=_1d4.slice(1).join(" ");var elem=_172(_1d2,"chkPreviewText",_1d5,_1d7);elem.setAttribute("accessKey","P");elem.title="Show text preview of found tiddlers (Shortcut: Alt-P)";return elem;}}};config.macros.foundTiddler={label:"foundTiddler",prompt:"Provides information on the tiddler currently processed on the YourSearch result page",handler:function(_1da,_1db,_1dc,_1dd,_1de,_1df){var name=_1dc[0];var func=config.macros.foundTiddler.funcs[name];if(func){func(_1da,_1db,_1dc,_1dd,_1de,_1df);}},funcs:{title:function(_1e2,_1e3,_1e4,_1e5,_1e6,_1e7){if(!_13c){return;} var _1e8=_180();var _1e9=_1e8>=0?"Open tiddler (Shortcut: Alt-%0)".format([_1e8.toString()]):"Open tiddler";var btn=createTiddlyButton(_1e2,null,_1e9,_12b,null);btn.setAttribute("tiddlyLink",_13c.title);btn.setAttribute("withHilite","true");_183(btn,_13c.title,_11b);if(_1e8>=0){btn.setAttribute("accessKey",_1e8.toString());}},tags:function(_1eb,_1ec,_1ed,_1ee,_1ef,_1f0){if(!_13c){return;} _183(_1eb,_13c.getTags(),_11c);},text:function(_1f1,_1f2,_1f3,_1f4,_1f5,_1f6){if(!_13c){return;} _183(_1f1,_17b(_13c.text),_11d);},field:function(_1f7,_1f8,_1f9,_1fa,_1fb,_1fc){if(!_13c){return;} var name=_1f9[1];var len=_1f9.length>2?abego.toInt(_1f9[2],_11e):_11e;var v=store.getValue(_13c,name);if(v){_183(_1f7,_17b(v),len);}},number:function(_200,_201,_202,_203,_204,_205){var _206=_180();if(_206>=0){var text="%0)".format([_206.toString()]);createTiddlyElement(_200,"span",null,"shortcutNumber",text);}}}};var opts={chkUseYourSearch:true,chkPreviewText:true,chkSearchAsYouType:true,chkSearchInTitle:true,chkSearchInText:true,chkSearchInTags:true,chkSearchExtendedFields:true,txtItemsPerPage:_11f,txtItemsPerPageWithPreview:_120};for(var n in opts){if(config.options[n]==undefined){config.options[n]=opts[n];}} config.shadowTiddlers.AdvancedOptions+="\n<<option chkUseYourSearch>> Use 'Your Search' //([[more options|YourSearch Options]]) ([[help|YourSearch Help]])// ";config.shadowTiddlers["YourSearch Help"]="!Field Search\nWith the Field Search you can restrict your search to certain fields of a tiddler, e.g"+" only search the tags or only the titles. The general form is //fieldname//'':''//textToSearch// (e."+"g. {{{title:intro}}}). In addition one-character shortcuts are also supported for the standard field"+"s {{{title}}}, {{{text}}} and {{{tags}}}:\n|!What you want|!What you type|!Example|\n|Search ''titles "+"only''|start word with ''!''|{{{!jonny}}} (shortcut for {{{title:jonny}}})|\n|Search ''contents/text "+"only''|start word with ''%''|{{{%football}}} (shortcut for {{{text:football}}})|\n|Search ''tags only"+"''|start word with ''#''|{{{#Plugin}}} (shortcut for {{{tags:Plugin}}})|\n\nUsing this feature you may"+" also search the extended fields (\"Metadata\") introduced with TiddlyWiki 2.1, e.g. use {{{priority:1"+"}}} to find all tiddlers with the priority field set to \"1\".\n\nYou may search a word in more than one"+" field. E.g. {{{!#Plugin}}} (or {{{title:tags:Plugin}}} in the \"long form\") finds tiddlers containin"+"g \"Plugin\" either in the title or in the tags (but does not look for \"Plugin\" in the text). \n\n!Boole"+"an Search\nThe Boolean Search is useful when searching for multiple words.\n|!What you want|!What you "+"type|!Example|\n|''All words'' must exist|List of words|{{{jonny jeremy}}} (or {{{jonny and jeremy}}}"+")|\n|''At least one word'' must exist|Separate words by ''or''|{{{jonny or jeremy}}}|\n|A word ''must "+"not exist''|Start word with ''-''|{{{-jonny}}} (or {{{not jonny}}})|\n\n''Note:'' When you specify two"+" words, separated with a space, YourSearch finds all tiddlers that contain both words, but not neces"+"sarily next to each other. If you want to find a sequence of word, e.g. '{{{John Brown}}}', you need"+" to put the words into quotes. I.e. you type: {{{\"john brown\"}}}.\n\nUsing parenthesis you may change "+"the default \"left to right\" evaluation of the boolean search. E.g. {{{not (jonny or jeremy)}}} finds"+" all tiddlers that contain neither \"jonny\" nor \"jeremy. In contrast to this {{{not jonny or jeremy}}"+"} (i.e. without parenthesis) finds all tiddlers that either don't contain \"jonny\" or that contain \"j"+"eremy\".\n\n!'Exact Word' Search\nBy default a search result all matches that 'contain' the searched tex"+"t. E.g. if you search for {{{Task}}} you will get all tiddlers containing 'Task', but also '~Complet"+"edTask', '~TaskForce' etc.\n\nIf you only want to get the tiddlers that contain 'exactly the word' you"+" need to prefix it with a '='. E.g. typing '=Task' will find the tiddlers that contain the word 'Tas"+"k', ignoring words that just contain 'Task' as a substring.\n\n!~CaseSensitiveSearch and ~RegExpSearch"+"\nThe standard search options ~CaseSensitiveSearch and ~RegExpSearch are fully supported by YourSearc"+"h. However when ''~RegExpSearch'' is on Filtered and Boolean Search are disabled.\n\nIn addition you m"+"ay do a \"regular expression\" search even with the ''~RegExpSearch'' set to false by directly enterin"+"g the regular expression into the search field, framed with {{{/.../}}}. \n\nExample: {{{/m[ae][iy]er/"+"}}} will find all tiddlers that contain either \"maier\", \"mayer\", \"meier\" or \"meyer\".\n\n!~JavaScript E"+"xpression Filtering\nIf you are familiar with JavaScript programming and know some TiddlyWiki interna"+"ls you may also use JavaScript expression for the search. Just enter a JavaScript boolean expression"+" into the search field, framed with {{{ { ... } }}}. In the code refer to the variable tiddler and e"+"valuate to {{{true}}} when the given tiddler should be included in the result. \n\nExample: {{{ { tidd"+"ler.modified > new Date(\"Jul 4, 2005\")} }}} returns all tiddler modified after July 4th, 2005.\n\n!Com"+"bined Search\nYou are free to combine the various search options. \n\n''Examples''\n|!What you type|!Res"+"ult|\n|{{{!jonny !jeremy -%football}}}|all tiddlers with both {{{jonny}}} and {{{jeremy}}} in its tit"+"les, but no {{{football}}} in content.|\n|{{{#=Task}}}|All tiddlers tagged with 'Task' (the exact wor"+"d). Tags named '~CompletedTask', '~TaskForce' etc. are not considered.|\n\n!Access Keys\nYou are encour"+"aged to use the access keys (also called \"shortcut\" keys) for the most frequently used operations. F"+"or quick reference these shortcuts are also mentioned in the tooltip for the various buttons etc.\n\n|"+"!Key|!Operation|\n|{{{Alt-F}}}|''The most important keystroke'': It moves the cursor to the search in"+"put field so you can directly start typing your query. Pressing {{{Alt-F}}} will also display the pr"+"evious search result. This way you can quickly display multiple tiddlers using \"Press {{{Alt-F}}}. S"+"elect tiddler.\" sequences.|\n|{{{ESC}}}|Closes the [[YourSearch Result]]. When the [[YourSearch Resul"+"t]] is already closed and the cursor is in the search input field the field's content is cleared so "+"you start a new query.|\n|{{{Alt-1}}}, {{{Alt-2}}},... |Pressing these keys opens the first, second e"+"tc. tiddler from the result list.|\n|{{{Alt-O}}}|Opens all found tiddlers.|\n|{{{Alt-P}}}|Toggles the "+"'Preview Text' mode.|\n|{{{Alt-'<'}}}, {{{Alt-'>'}}}|Displays the previous or next page in the [[Your"+"Search Result]].|\n|{{{Return}}}|When you have turned off the 'as you type' search mode pressing the "+"{{{Return}}} key actually starts the search (as does pressing the 'search' button).|\n\n//If some of t"+"hese shortcuts don't work for you check your browser if you have other extensions installed that alr"+"eady \"use\" these shortcuts.//";config.shadowTiddlers["YourSearch Options"]="|>|!YourSearch Options|\n|>|<<option chkUseYourSearch>> Use 'Your Search'|\n|!|<<option chkPreviewText"+">> Show Text Preview|\n|!|<<option chkSearchAsYouType>> 'Search As You Type' Mode (No RETURN required"+" to start search)|\n|!|Default Search Filter:<<option chkSearchInTitle>>Title ('!') <<option chk"+"SearchInText>>Text ('%') <<option chkSearchInTags>>Tags ('#') <<option chkSearchExtendedFiel"+"ds>>Extended Fields<html><br><font size=\"-2\">The fields of a tiddlers that are searched when you don"+"'t explicitly specify a filter in the search text <br>(Explictly specify fields using one or more '!"+"', '%', '#' or 'fieldname:' prefix before the word/text to find).</font></html>|\n|!|Number of items "+"on search result page: <<option txtItemsPerPage>>|\n|!|Number of items on search result page with pre"+"view text: <<option txtItemsPerPageWithPreview>>|\n";config.shadowTiddlers["YourSearchStyleSheet"]="/***\n!~YourSearchResult Stylesheet\n***/\n/*{{{*/\n.yourSearchResult {\n\tposition: absolute;\n\twidth: 800"+"px;\n\n\tpadding: 0.2em;\n\tlist-style: none;\n\tmargin: 0;\n\n\tbackground: #ffd;\n\tborder: 1px solid DarkGra"+"y;\n}\n\n/*}}}*/\n/***\n!!Summary Section\n***/\n/*{{{*/\n.yourSearchResult .summary {\n\tborder-bottom-width:"+" thin;\n\tborder-bottom-style: solid;\n\tborder-bottom-color: #999999;\n\tpadding-bottom: 4px;\n}\n\n.yourSea"+"rchRange, .yourSearchCount, .yourSearchQuery {\n\tfont-weight: bold;\n}\n\n.yourSearchResult .summary ."+"button {\n\tfont-size: 10px;\n\n\tpadding-left: 0.3em;\n\tpadding-right: 0.3em;\n}\n\n.yourSearchResult .summa"+"ry .chkBoxLabel {\n\tfont-size: 10px;\n\n\tpadding-right: 0.3em;\n}\n\n/*}}}*/\n/***\n!!Items Area\n***/\n/*{{{*"+"/\n.yourSearchResult .marked {\n\tbackground: none;\n\tfont-weight: bold;\n}\n\n.yourSearchItem {\n\tmargin-to"+"p: 2px;\n}\n\n.yourSearchNumber {\n\tcolor: #808080;\n}\n\n\n.yourSearchTags {\n\tcolor: #008000;\n}\n\n.yourSearc"+"hText {\n\tcolor: #808080;\n\tmargin-bottom: 6px;\n}\n\n/*}}}*/\n/***\n!!Footer\n***/\n/*{{{*/\n.yourSearchFoote"+"r {\n\tmargin-top: 8px;\n\tborder-top-width: thin;\n\tborder-top-style: solid;\n\tborder-top-color: #999999;"+"\n}\n\n.yourSearchFooter a:hover{\n\tbackground: none;\n\tcolor: none;\n}\n/*}}}*/\n/***\n!!Navigation Bar\n***/"+"\n/*{{{*/\n.yourSearchNaviBar a {\n\tfont-size: 16px;\n\tmargin-left: 4px;\n\tmargin-right: 4px;\n\tcolor: bla"+"ck;\n\ttext-decoration: underline;\n}\n\n.yourSearchNaviBar a:hover {\n\tbackground-color: none;\n}\n\n.yourSe"+"archNaviBar .prev {\n\tfont-weight: bold;\n\tcolor: blue;\n}\n\n.yourSearchNaviBar .currentPage {\n\tcolor: #"+"FF0000;\n\tfont-weight: bold;\n\ttext-decoration: none;\n}\n\n.yourSearchNaviBar .next {\n\tfont-weight: bold"+";\n\tcolor: blue;\n}\n/*}}}*/\n";config.shadowTiddlers["YourSearchResultTemplate"]="<!--\n{{{\n-->\n<span macro=\"yourSearch if found\">\n<!-- The Summary Header ============================"+"================ -->\n<table class=\"summary\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">"+"<tbody>\n <tr>\n\t<td align=\"left\">\n\t\tYourSearch Result <span class=\"yourSearchRange\" macro=\"yourSearc"+"h itemRange\"></span>\n\t\t&nbsp;of&nbsp;<span class=\"yourSearchCount\" macro=\"yourSearch count\"></span>\n"+"\t\tfor&nbsp;<span class=\"yourSearchQuery\" macro=\"yourSearch query\"></span>\n\t</td>\n\t<td class=\"yourSea"+"rchButtons\" align=\"right\">\n\t\t<span macro=\"yourSearch chkPreviewText\"></span><span class=\"chkBoxLabel"+"\">preview text</span>\n\t\t<span macro=\"yourSearch newTiddlerButton\"></span>\n\t\t<span macro=\"yourSearch openAllButton\"></span>\n\t\t<span macro=\"yourSearch lin"+"kButton 'YourSearch Options' options 'Configure YourSearch'\"></span>\n\t\t<span macro=\"yourSearch linkB"+"utton 'YourSearch Help' help 'Get help how to use YourSearch'\"></span>\n\t\t<span macro=\"yourSearch clo"+"seButton\"></span>\n\t</td>\n </tr>\n</tbody></table>\n\n<!-- The List of Found Tiddlers ================="+"=========================== -->\n<div id=\"yourSearchResultItems\" itemsPerPage=\"25\" itemsPerPageWithPr"+"eview=\"10\"></div>\n\n<!-- The Footer (with the Navigation) ==========================================="+"= -->\n<table class=\"yourSearchFooter\" border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tbody"+">\n <tr>\n\t<td align=\"left\">\n\t\tResult page: <span class=\"yourSearchNaviBar\" macro=\"yourSearch naviBar"+"\"></span>\n\t</td>\n\t<td align=\"right\"><span macro=\"yourSearch version\"></span>, <span macro=\"yourSearc"+"h copyright\"></span>\n\t</td>\n </tr>\n</tbody></table>\n<!-- end of the 'tiddlers found' case ========="+"================================== -->\n</span>\n\n\n<!-- The \"No tiddlers found\" case ================="+"========================== -->\n<span macro=\"yourSearch if not found\">\n<table class=\"summary\" border="+"\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tbody>\n <tr>\n\t<td align=\"left\">\n\t\tYourSearch Resu"+"lt: No tiddlers found for <span class=\"yourSearchQuery\" macro=\"yourSearch query\"></span>.\n\t</td>\n\t<t"+"d class=\"yourSearchButtons\" align=\"right\">\n\t\t<span macro=\"yourSearch newTiddlerButton\"></span>\n\t\t<span macro=\"yourSearch linkButton 'YourSearch Options'"+" options 'Configure YourSearch'\"></span>\n\t\t<span macro=\"yourSearch linkButton 'YourSearch Help' help"+" 'Get help how to use YourSearch'\"></span>\n\t\t<span macro=\"yourSearch closeButton\"></span>\n\t</td>\n <"+"/tr>\n</tbody></table>\n</span>\n\n\n<!--\n}}}\n-->\n";config.shadowTiddlers["YourSearchItemTemplate"]="<!--\n{{{\n-->\n<span class='yourSearchNumber' macro='foundTiddler number'></span>\n<span class='yourSea"+"rchTitle' macro='foundTiddler title'/></span>&nbsp;-&nbsp;\n<span class='yourSearchTags' macro='found"+"Tiddler field tags 50'/></span>\n<span macro=\"yourSearch if previewText\"><div class='yourSearchText' macro='fo"+"undTiddler field text 250'/></div></span>\n<!--\n}}}\n-->";config.shadowTiddlers["YourSearch"]="<<tiddler [[YourSearch Help]]>>";config.shadowTiddlers["YourSearch Result"]="The popup-like window displaying the result of a YourSearch query.";config.macros.search.handler=_157;var _20a=function(){if(config.macros.search.handler!=_157){alert("Message from YourSearchPlugin:\n\n\nAnother plugin has disabled the 'Your Search' features.\n\n\nYou may "+"disable the other plugin or change the load order of \nthe plugins (by changing the names of the tidd"+"lers)\nto enable the 'Your Search' features.");}};setTimeout(_20a,5000);abego.YourSearch.getStandardRankFunction=function(){return _ff;};abego.YourSearch.getRankFunction=function(){return abego.YourSearch.getStandardRankFunction();};abego.YourSearch.getCurrentTiddler=function(){return _13c;};abego.YourSearch.closeResult=function(){_12a();};abego.YourSearch.getFoundTiddlers=function(){return _f2;};abego.YourSearch.getQuery=function(){return _f3;};abego.YourSearch.onShowResult=function(_20b){highlightHack=_f3?_f3.getMarkRegExp():null;if(!_20b){_13d.setItems(_f6());} if(!_124){_124=createTiddlyElement(document.body,"div",_121,"yourSearchResult");}else{if(_124.parentNode!=document.body){document.body.appendChild(_124);}} _146();highlightHack=null;};})();} //%/ </pre> </div> <div title="systemConfig" modifier="MPTW" created="200806181402" modified="200806181402" taggly.excerpts="descr" taggly.sortby="created" taggly.sortorder="desc"> <pre></pre> </div> </div> <!--POST-STOREAREA--> <!--POST-BODY-START--> <!--POST-BODY-END--> <script id="jsArea" type="text/javascript"> //<![CDATA[ // // Please note: // // * This code is designed to be readable but for compactness it only includes brief comments. You can see fuller comments // in the project Subversion repository at http://svn.tiddlywiki.org/Trunk/core/ // // * You should never need to modify this source code directly. TiddlyWiki is carefully designed to allow deep customisation // without changing the core code. Please consult the development group at http://groups.google.com/group/TiddlyWikiDev // //-- //-- Configuration repository //-- // Miscellaneous options var config = { numRssItems: 20, // Number of items in the RSS feed animDuration: 400, // Duration of UI animations in milliseconds cascadeFast: 20, // Speed for cascade animations (higher == slower) cascadeSlow: 60, // Speed for EasterEgg cascade animations cascadeDepth: 5, // Depth of cascade animation locale: "en" // W3C language tag }; // Hashmap of alternative parsers for the wikifier config.parsers = {}; // Adaptors config.adaptors = {}; config.defaultAdaptor = null; // Backstage tasks config.tasks = {}; // Annotations config.annotations = {}; // Custom fields to be automatically added to new tiddlers config.defaultCustomFields = {}; // Messages config.messages = { messageClose: {}, dates: {}, tiddlerPopup: {} }; // Options that can be set in the options panel and/or cookies config.options = { chkRegExpSearch: false, chkCaseSensitiveSearch: false, chkIncrementalSearch: true, chkAnimate: true, chkSaveBackups: true, chkAutoSave: false, chkGenerateAnRssFeed: false, chkSaveEmptyTemplate: false, chkOpenInNewWindow: true, chkToggleLinks: false, chkHttpReadOnly: true, chkForceMinorUpdate: false, chkConfirmDelete: true, chkInsertTabs: false, chkUsePreForStorage: true, // Whether to use <pre> format for storage chkDisplayInstrumentation: false, txtBackupFolder: "", txtEditorFocus: "text", txtMainTab: "tabTimeline", txtMoreTab: "moreTabAll", txtMaxEditRows: "30", txtFileSystemCharSet: "UTF-8", txtTheme: "" }; config.optionsDesc = {}; // List of notification functions to be called when certain tiddlers are changed or deleted config.notifyTiddlers = [ {name: "StyleSheetLayout", notify: refreshStyles}, {name: "StyleSheetColors", notify: refreshStyles}, {name: "StyleSheet", notify: refreshStyles}, {name: "StyleSheetPrint", notify: refreshStyles}, {name: "PageTemplate", notify: refreshPageTemplate}, {name: "SiteTitle", notify: refreshPageTitle}, {name: "SiteSubtitle", notify: refreshPageTitle}, {name: "ColorPalette", notify: refreshColorPalette}, {name: null, notify: refreshDisplay} ]; // Default tiddler templates var DEFAULT_VIEW_TEMPLATE = 1; var DEFAULT_EDIT_TEMPLATE = 2; config.tiddlerTemplates = { 1: "ViewTemplate", 2: "EditTemplate" }; // More messages (rather a legacy layout that shouldn't really be like this) config.views = { wikified: { tag: {} }, editor: { tagChooser: {} } }; // Backstage tasks config.backstageTasks = ["save","sync","importTask","tweak","upgrade","plugins"]; // Macros; each has a 'handler' member that is inserted later config.macros = { today: {}, version: {}, search: {sizeTextbox: 15}, tiddler: {}, tag: {}, tags: {}, tagging: {}, timeline: {}, allTags: {}, list: { all: {}, missing: {}, orphans: {}, shadowed: {}, touched: {}, filter: {} }, closeAll: {}, permaview: {}, saveChanges: {}, slider: {}, option: {}, options: {}, newTiddler: {}, newJournal: {}, tabs: {}, gradient: {}, message: {}, view: {defaultView: "text"}, edit: {}, tagChooser: {}, toolbar: {}, plugins: {}, refreshDisplay: {}, importTiddlers: {}, upgrade: { source: "http://www.tiddlywiki.com/upgrade/", backupExtension: "pre.core.upgrade" }, sync: {}, annotations: {} }; // Commands supported by the toolbar macro config.commands = { closeTiddler: {}, closeOthers: {}, editTiddler: {}, saveTiddler: {hideReadOnly: true}, cancelTiddler: {}, deleteTiddler: {hideReadOnly: true}, permalink: {}, references: {type: "popup"}, jump: {type: "popup"}, syncing: {type: "popup"}, fields: {type: "popup"} }; // Browser detection... In a very few places, there's nothing else for it but to know what browser we're using. config.userAgent = navigator.userAgent.toLowerCase(); config.browser = { isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1, isGecko: config.userAgent.indexOf("gecko") != -1, ieVersion: /MSIE (\d.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0" isSafari: config.userAgent.indexOf("applewebkit") != -1, isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")), firefoxDate: /gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD" isOpera: config.userAgent.indexOf("opera") != -1, isLinux: config.userAgent.indexOf("linux") != -1, isUnix: config.userAgent.indexOf("x11") != -1, isMac: config.userAgent.indexOf("mac") != -1, isWindows: config.userAgent.indexOf("win") != -1 }; // Basic regular expressions config.textPrimitives = { upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]", lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]", anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]", anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]" }; if(config.browser.isBadSafari) { config.textPrimitives = { upperLetter: "[A-Z\u00c0-\u00de]", lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]", anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]", anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]" }; } config.textPrimitives.sliceSeparator = "::"; config.textPrimitives.sectionSeparator = "##"; config.textPrimitives.urlPattern = "(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)"; config.textPrimitives.unWikiLink = "~"; config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" + config.textPrimitives.lowerLetter + "+" + config.textPrimitives.upperLetter + config.textPrimitives.anyLetter + "*)|(?:" + config.textPrimitives.upperLetter + "{2,}" + config.textPrimitives.lowerLetter + "+))"; config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)"; config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg"); config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]"; config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]"; config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" + config.textPrimitives.brackettedLink + ")|(?:" + config.textPrimitives.urlPattern + ")","mg"); config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" + config.textPrimitives.brackettedLink + ")|(?:" + config.textPrimitives.urlPattern + ")","mg"); config.glyphs = { browsers: [ function() {return config.browser.isIE;}, function() {return true;} ], currBrowser: null, codes: { downTriangle: ["\u25BC","\u25BE"], downArrow: ["\u2193","\u2193"], bentArrowLeft: ["\u2190","\u21A9"], bentArrowRight: ["\u2192","\u21AA"] } }; //-- //-- Shadow tiddlers //-- config.shadowTiddlers = { StyleSheet: "", MarkupPreHead: "", MarkupPostHead: "", MarkupPreBody: "", MarkupPostBody: "", TabTimeline: '<<timeline>>', TabAll: '<<list all>>', TabTags: '<<allTags excludeLists>>', TabMoreMissing: '<<list missing>>', TabMoreOrphans: '<<list orphans>>', TabMoreShadowed: '<<list shadowed>>', AdvancedOptions: '<<options>>', PluginManager: '<<plugins>>' }; //-- //-- Translateable strings //-- // Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone merge(config.options,{ txtUserName: "YourName"}); merge(config.tasks,{ save: {text: "save", tooltip: "Save your changes to this TiddlyWiki", action: saveChanges}, sync: {text: "sync", tooltip: "Synchronise changes with other TiddlyWiki files and servers", content: '<<sync>>'}, importTask: {text: "import", tooltip: "Import tiddlers and plugins from other TiddlyWiki files and servers", content: '<<importTiddlers>>'}, tweak: {text: "tweak", tooltip: "Tweak the appearance and behaviour of TiddlyWiki", content: '<<options>>'}, upgrade: {text: "upgrade", tooltip: "Upgrade TiddlyWiki core code", content: '<<upgrade>>'}, plugins: {text: "plugins", tooltip: "Manage installed plugins", content: '<<plugins>>'} }); // Options that can be set in the options panel and/or cookies merge(config.optionsDesc,{ txtUserName: "Username for signing your edits", chkRegExpSearch: "Enable regular expressions for searches", chkCaseSensitiveSearch: "Case-sensitive searching", chkIncrementalSearch: "Incremental key-by-key searching", chkAnimate: "Enable animations", chkSaveBackups: "Keep backup file when saving changes", chkAutoSave: "Automatically save changes", chkGenerateAnRssFeed: "Generate an RSS feed when saving changes", chkSaveEmptyTemplate: "Generate an empty template when saving changes", chkOpenInNewWindow: "Open external links in a new window", chkToggleLinks: "Clicking on links to open tiddlers causes them to close", chkHttpReadOnly: "Hide editing features when viewed over HTTP", chkForceMinorUpdate: "Don't update modifier username and date when editing tiddlers", chkConfirmDelete: "Require confirmation before deleting tiddlers", chkInsertTabs: "Use the tab key to insert tab characters instead of moving between fields", txtBackupFolder: "Name of folder to use for backups", txtMaxEditRows: "Maximum number of rows in edit boxes", txtFileSystemCharSet: "Default character set for saving changes (Firefox/Mozilla only)"}); merge(config.messages,{ customConfigError: "Problems were encountered loading plugins. See PluginManager for details", pluginError: "Error: %0", pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag", pluginForced: "Executed because forced via 'systemConfigForce' tag", pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki", nothingSelected: "Nothing is selected. You must select one or more items first", 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", shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value", tiddlerLinkTooltip: "%0 - %1, %2", 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. Possible reasons include:\n- your browser doesn't support saving (Firefox, Internet Explorer, Safari and Opera all work if properly configured)\n- the pathname to your TiddlyWiki file contains illegal characters\n- the TiddlyWiki HTML file has been moved or renamed", 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 in macro <<\%0>>", macroErrorDetails: "Error while executing macro <<\%0>>:\n%1", missingMacro: "No such macro", 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", confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------", saveInstructions: "SaveChanges", unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'", tiddlerSaveError: "Error when saving tiddler '%0'", tiddlerLoadError: "Error when loading tiddler '%0'", wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.", invalidFieldName: "Invalid field name %0", fieldCannotBeChanged: "Field '%0' cannot be changed", loadingMissingTiddler: "Attempting to retrieve the tiddler '%0' from the '%1' server at:\n\n'%2' in the workspace '%3'", upgradeDone: "The upgrade to version %0 is now complete\n\nClick 'OK' to reload the newly upgraded TiddlyWiki"}); merge(config.messages.messageClose,{ text: "close", tooltip: "close this message area"}); config.messages.backstage = { open: {text: "backstage", tooltip: "Open the backstage area to perform authoring and editing tasks"}, close: {text: "close", tooltip: "Close the backstage area"}, prompt: "backstage: ", decal: { edit: {text: "edit", tooltip: "Edit the tiddler '%0'"} } }; config.messages.listView = { tiddlerTooltip: "Click for the full text of this tiddler", previewUnavailable: "(preview not available)" }; config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"]; config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; // suffixes for dates, eg "1st","2nd","3rd"..."30th","31st" config.messages.dates.daySuffixes = ["st","nd","rd","th","th","th","th","th","th","th", "th","th","th","th","th","th","th","th","th","th", "st","nd","rd","th","th","th","th","th","th","th", "st"]; config.messages.dates.am = "am"; config.messages.dates.pm = "pm"; merge(config.messages.tiddlerPopup,{ }); merge(config.views.wikified.tag,{ labelNoTags: "no tags", labelTags: "tags: ", openTag: "Open tag '%0'", tooltip: "Show tiddlers tagged with '%0'", openAllText: "Open all", openAllTooltip: "Open all of these tiddlers", popupNone: "No other tiddlers tagged with '%0'"}); merge(config.views.wikified,{ defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it", defaultModifier: "(missing)", shadowModifier: "(built-in shadow tiddler)", dateFormat: "DD MMM YYYY", createdPrompt: "created"}); merge(config.views.editor,{ tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing", defaultText: "Type the text for '%0'"}); merge(config.views.editor.tagChooser,{ text: "tags", tooltip: "Choose existing tags to add to this tiddler", popupNone: "There are no tags defined", tagTooltip: "Add the tag '%0'"}); merge(config.messages,{ sizeTemplates: [ {unit: 1024*1024*1024, template: "%0\u00a0GB"}, {unit: 1024*1024, template: "%0\u00a0MB"}, {unit: 1024, template: "%0\u00a0KB"}, {unit: 1, template: "%0\u00a0B"} ]}); merge(config.macros.search,{ label: "search", prompt: "Search this TiddlyWiki", accessKey: "F", successMsg: "%0 tiddlers found matching %1", failureMsg: "No tiddlers found matching %0"}); merge(config.macros.tagging,{ label: "tagging: ", labelNotTag: "not tagging", tooltip: "List of tiddlers tagged with '%0'"}); merge(config.macros.timeline,{ dateFormat: "DD MMM YYYY"}); merge(config.macros.allTags,{ tooltip: "Show tiddlers tagged with '%0'", noTags: "There are no tagged tiddlers"}); config.macros.list.all.prompt = "All tiddlers in alphabetical order"; config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined"; config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers"; config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents"; config.macros.list.touched.prompt = "Tiddlers that have been modified locally"; merge(config.macros.closeAll,{ label: "close all", prompt: "Close all displayed tiddlers (except any that are being edited)"}); merge(config.macros.permaview,{ label: "permaview", prompt: "Link to an URL that retrieves all the currently displayed tiddlers"}); merge(config.macros.saveChanges,{ label: "save changes", prompt: "Save all tiddlers to create a new TiddlyWiki", accessKey: "S"}); merge(config.macros.newTiddler,{ label: "new tiddler", prompt: "Create a new tiddler", title: "New Tiddler", accessKey: "N"}); merge(config.macros.newJournal,{ label: "new journal", prompt: "Create a new tiddler from the current date and time", accessKey: "J"}); merge(config.macros.options,{ wizardTitle: "Tweak advanced options", step1Title: "These options are saved in cookies in your browser", step1Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='false' name='chkUnknown'>Show unknown options</input>", unknownDescription: "//(unknown)//", listViewTemplate: { columns: [ {name: 'Option', field: 'option', title: "Option", type: 'String'}, {name: 'Description', field: 'description', title: "Description", type: 'WikiText'}, {name: 'Name', field: 'name', title: "Name", type: 'String'} ], rowClasses: [ {className: 'lowlight', field: 'lowlight'} ]} }); merge(config.macros.plugins,{ wizardTitle: "Manage plugins", step1Title: "Currently loaded plugins", step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE skippedText: "(This plugin has not been executed because it was added since startup)", noPluginText: "There are no plugins installed", confirmDeleteText: "Are you sure you want to delete these plugins:\n\n%0", removeLabel: "remove systemConfig tag", removePrompt: "Remove systemConfig tag", deleteLabel: "delete", deletePrompt: "Delete these tiddlers forever", listViewTemplate: { columns: [ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'}, {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'}, {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'}, {name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'}, {name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'}, {name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"}, {name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'}, {name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"}, {name: 'Log', field: 'log', title: "Log", type: 'StringList'} ], rowClasses: [ {className: 'error', field: 'error'}, {className: 'warning', field: 'warning'} ]} }); merge(config.macros.toolbar,{ moreLabel: "more", morePrompt: "Reveal further commands" }); merge(config.macros.refreshDisplay,{ label: "refresh", prompt: "Redraw the entire TiddlyWiki display" }); merge(config.macros.importTiddlers,{ readOnlyWarning: "You cannot import into a read-only TiddlyWiki file. Try opening it from a file:// URL", wizardTitle: "Import tiddlers from another file or server", step1Title: "Step 1: Locate the server or TiddlyWiki file", step1Html: "Specify the type of the server: <select name='selTypes'><option value=''>Choose...</option></select><br>Enter the URL or pathname here: <input type='text' size=50 name='txtPath'><br>...or browse for a file: <input type='file' size=50 name='txtBrowse'><br><hr>...or select a pre-defined feed: <select name='selFeeds'><option value=''>Choose...</option></select>", openLabel: "open", openPrompt: "Open the connection to this file or server", openError: "There were problems fetching the tiddlywiki file", statusOpenHost: "Opening the host", statusGetWorkspaceList: "Getting the list of available workspaces", step2Title: "Step 2: Choose the workspace", step2Html: "Enter a workspace name: <input type='text' size=50 name='txtWorkspace'><br>...or select a workspace: <select name='selWorkspace'><option value=''>Choose...</option></select>", cancelLabel: "cancel", cancelPrompt: "Cancel this import", statusOpenWorkspace: "Opening the workspace", statusGetTiddlerList: "Getting the list of available tiddlers", errorGettingTiddlerList: "Error getting list of tiddlers, click Cancel to try again", step3Title: "Step 3: Choose the tiddlers to import", step3Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='true' name='chkSync'>Keep these tiddlers linked to this server so that you can synchronise subsequent changes</input><br><input type='checkbox' name='chkSave'>Save the details of this server in a 'systemServer' tiddler called:</input> <input type='text' size=25 name='txtSaveTiddler'>", importLabel: "import", importPrompt: "Import these tiddlers", confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0", step4Title: "Step 4: Importing %0 tiddler(s)", step4Html: "<input type='hidden' name='markReport'></input>", // DO NOT TRANSLATE doneLabel: "done", donePrompt: "Close this wizard", statusDoingImport: "Importing tiddlers", statusDoneImport: "All tiddlers imported", systemServerNamePattern: "%2 on %1", systemServerNamePatternNoWorkspace: "%1", confirmOverwriteSaveTiddler: "The tiddler '%0' already exists. Click 'OK' to overwrite it with the details of this server, or 'Cancel' to leave it unchanged", serverSaveTemplate: "|''Type:''|%0|\n|''URL:''|%1|\n|''Workspace:''|%2|\n\nThis tiddler was automatically created to record the details of this server", serverSaveModifier: "(System)", listViewTemplate: { columns: [ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'}, {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'}, {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'}, {name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'} ], rowClasses: [ ]} }); merge(config.macros.upgrade,{ wizardTitle: "Upgrade TiddlyWiki core code", step1Title: "Update or repair this TiddlyWiki to the latest release", step1Html: "You are about to upgrade to the latest release of the TiddlyWiki core code (from <a href='%0' class='externalLink' target='_blank'>%1</a>). Your content will be preserved across the upgrade.<br><br>Note that core upgrades have been known to interfere with older plugins. If you run into problems with the upgraded file, see <a href='http://www.tiddlywiki.org/wiki/CoreUpgrades' class='externalLink' target='_blank'>http://www.tiddlywiki.org/wiki/CoreUpgrades</a>", errorCantUpgrade: "Unable to upgrade this TiddlyWiki. You can only perform upgrades on TiddlyWiki files stored locally", errorNotSaved: "You must save changes before you can perform an upgrade", step2Title: "Confirm the upgrade details", step2Html_downgrade: "You are about to downgrade to TiddlyWiki version %0 from %1.<br><br>Downgrading to an earlier version of the core code is not recommended", step2Html_restore: "This TiddlyWiki appears to be already using the latest version of the core code (%0).<br><br>You can continue to upgrade anyway to ensure that the core code hasn't been corrupted or damaged", step2Html_upgrade: "You are about to upgrade to TiddlyWiki version %0 from %1", upgradeLabel: "upgrade", upgradePrompt: "Prepare for the upgrade process", statusPreparingBackup: "Preparing backup", statusSavingBackup: "Saving backup file", errorSavingBackup: "There was a problem saving the backup file", statusLoadingCore: "Loading core code", errorLoadingCore: "Error loading the core code", errorCoreFormat: "Error with the new core code", statusSavingCore: "Saving the new core code", statusReloadingCore: "Reloading the new core code", startLabel: "start", startPrompt: "Start the upgrade process", cancelLabel: "cancel", cancelPrompt: "Cancel the upgrade process", step3Title: "Upgrade cancelled", step3Html: "You have cancelled the upgrade process" }); merge(config.macros.sync,{ listViewTemplate: { columns: [ {name: 'Selected', field: 'selected', rowName: 'title', type: 'Selector'}, {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'}, {name: 'Server Type', field: 'serverType', title: "Server type", type: 'String'}, {name: 'Server Host', field: 'serverHost', title: "Server host", type: 'String'}, {name: 'Server Workspace', field: 'serverWorkspace', title: "Server workspace", type: 'String'}, {name: 'Status', field: 'status', title: "Synchronisation status", type: 'String'}, {name: 'Server URL', field: 'serverUrl', title: "Server URL", text: "View", type: 'Link'} ], rowClasses: [ ], buttons: [ {caption: "Sync these tiddlers", name: 'sync'} ]}, wizardTitle: "Synchronize with external servers and files", step1Title: "Choose the tiddlers you want to synchronize", step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE syncLabel: "sync", syncPrompt: "Sync these tiddlers", hasChanged: "Changed while unplugged", hasNotChanged: "Unchanged while unplugged", syncStatusList: { none: {text: "...", color: "transparent"}, changedServer: {text: "Changed on server", color: '#80ff80'}, changedLocally: {text: "Changed while unplugged", color: '#80ff80'}, changedBoth: {text: "Changed while unplugged and on server", color: '#ff8080'}, notFound: {text: "Not found on server", color: '#ffff80'}, putToServer: {text: "Saved update on server", color: '#ff80ff'}, gotFromServer: {text: "Retrieved update from server", color: '#80ffff'} } }); merge(config.macros.annotations,{ }); merge(config.commands.closeTiddler,{ text: "close", tooltip: "Close this tiddler"}); merge(config.commands.closeOthers,{ text: "close others", tooltip: "Close all other tiddlers"}); merge(config.commands.editTiddler,{ text: "edit", tooltip: "Edit this tiddler", readOnlyText: "view", readOnlyTooltip: "View the source of this tiddler"}); merge(config.commands.saveTiddler,{ text: "done", tooltip: "Save changes to this tiddler"}); merge(config.commands.cancelTiddler,{ text: "cancel", tooltip: "Undo changes to this tiddler", warning: "Are you sure you want to abandon your changes to '%0'?", readOnlyText: "done", readOnlyTooltip: "View this tiddler normally"}); merge(config.commands.deleteTiddler,{ text: "delete", tooltip: "Delete this tiddler", warning: "Are you sure you want to delete '%0'?"}); merge(config.commands.permalink,{ text: "permalink", tooltip: "Permalink for this tiddler"}); merge(config.commands.references,{ text: "references", tooltip: "Show tiddlers that link to this one", popupNone: "No references"}); merge(config.commands.jump,{ text: "jump", tooltip: "Jump to another open tiddler"}); merge(config.commands.syncing,{ text: "syncing", tooltip: "Control synchronisation of this tiddler with a server or external file", currentlySyncing: "<div>Currently syncing via <span class='popupHighlight'>'%0'</span> to:</"+"div><div>host: <span class='popupHighlight'>%1</span></"+"div><div>workspace: <span class='popupHighlight'>%2</span></"+"div>", // Note escaping of closing <div> tag notCurrentlySyncing: "Not currently syncing", captionUnSync: "Stop synchronising this tiddler", chooseServer: "Synchronise this tiddler with another server:", currServerMarker: "\u25cf ", notCurrServerMarker: " "}); merge(config.commands.fields,{ text: "fields", tooltip: "Show the extended fields of this tiddler", emptyText: "There are no extended fields for this tiddler", listViewTemplate: { columns: [ {name: 'Field', field: 'field', title: "Field", type: 'String'}, {name: 'Value', field: 'value', title: "Value", type: 'String'} ], rowClasses: [ ], buttons: [ ]}}); merge(config.shadowTiddlers,{ DefaultTiddlers: "GettingStarted", MainMenu: "GettingStarted", SiteTitle: "My TiddlyWiki", SiteSubtitle: "a reusable non-linear personal web notebook", SiteUrl: "http://www.tiddlywiki.com/", SideBarOptions: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options \u00bb" "Change TiddlyWiki advanced options">>', SideBarTabs: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>', TabMore: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>', ToolbarCommands: "|~ViewToolbar|closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|\n|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|"}); merge(config.annotations,{ AdvancedOptions: "This shadow tiddler provides access to several advanced options", ColorPalette: "These values in this shadow tiddler determine the colour scheme of the ~TiddlyWiki user interface", DefaultTiddlers: "The tiddlers listed in this shadow tiddler will be automatically displayed when ~TiddlyWiki starts up", EditTemplate: "The HTML template in this shadow tiddler determines how tiddlers look while they are being edited", GettingStarted: "This shadow tiddler provides basic usage instructions", ImportTiddlers: "This shadow tiddler provides access to importing tiddlers", MainMenu: "This shadow tiddler is used as the contents of the main menu in the left-hand column of the screen", MarkupPreHead: "This tiddler is inserted at the top of the <head> section of the TiddlyWiki HTML file", MarkupPostHead: "This tiddler is inserted at the bottom of the <head> section of the TiddlyWiki HTML file", MarkupPreBody: "This tiddler is inserted at the top of the <body> section of the TiddlyWiki HTML file", MarkupPostBody: "This tiddler is inserted at the end of the <body> section of the TiddlyWiki HTML file immediately after the script block", OptionsPanel: "This shadow tiddler is used as the contents of the options panel slider in the right-hand sidebar", PageTemplate: "The HTML template in this shadow tiddler determines the overall ~TiddlyWiki layout", PluginManager: "This shadow tiddler provides access to the plugin manager", SideBarOptions: "This shadow tiddler is used as the contents of the option panel in the right-hand sidebar", SideBarTabs: "This shadow tiddler is used as the contents of the tabs panel in the right-hand sidebar", SiteSubtitle: "This shadow tiddler is used as the second part of the page title", SiteTitle: "This shadow tiddler is used as the first part of the page title", SiteUrl: "This shadow tiddler should be set to the full target URL for publication", StyleSheetColors: "This shadow tiddler contains CSS definitions related to the color of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler", StyleSheet: "This tiddler can contain custom CSS definitions", StyleSheetLayout: "This shadow tiddler contains CSS definitions related to the layout of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler", StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale", StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing", TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar", TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar", TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar", TabMoreOrphans: "This shadow tiddler contains the contents of the 'Orphans' tab in the right-hand sidebar", TabMoreShadowed: "This shadow tiddler contains the contents of the 'Shadowed' tab in the right-hand sidebar", TabTags: "This shadow tiddler contains the contents of the 'Tags' tab in the right-hand sidebar", TabTimeline: "This shadow tiddler contains the contents of the 'Timeline' tab in the right-hand sidebar", ToolbarCommands: "This shadow tiddler determines which commands are shown in tiddler toolbars", ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look" }); //-- //-- Main //-- var params = null; // Command line parameters var store = null; // TiddlyWiki storage var story = null; // Main story var formatter = null; // Default formatters for the wikifier var anim = typeof Animator == "function" ? new Animator() : null; // Animation engine var readOnly = false; // Whether we're in readonly mode var highlightHack = null; // Embarrassing hack department... var hadConfirmExit = false; // Don't warn more than once var safeMode = false; // Disable all plugins and cookies var showBackstage; // Whether to include the backstage area var installedPlugins = []; // Information filled in when plugins are executed var startingUp = false; // Whether we're in the process of starting up var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins() // Whether to use the JavaSaver applet var useJavaSaver = (config.browser.isSafari || config.browser.isOpera) && (document.location.toString().substr(0,4) != "http"); // Starting up function main() { var t10,t9,t8,t7,t6,t5,t4,t3,t2,t1,t0 = new Date(); startingUp = true; window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();}; params = getParameters(); if(params) params = params.parseParams("open",null,false); store = new TiddlyWiki(); invokeParamifier(params,"oninit"); story = new Story("tiddlerDisplay","tiddler"); addEvent(document,"click",Popup.onDocumentClick); saveTest(); loadOptionsCookie(); for(var s=0; s<config.notifyTiddlers.length; s++) store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify); t1 = new Date(); loadShadowTiddlers(); t2 = new Date(); store.loadFromDiv("storeArea","store",true); t3 = new Date(); invokeParamifier(params,"onload"); t4 = new Date(); readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly; showBackstage = !readOnly; var pluginProblem = loadPlugins(); t5 = new Date(); formatter = new Formatter(config.formatters); story.switchTheme(config.options.txtTheme); invokeParamifier(params,"onconfig"); t6 = new Date(); store.notifyAll(); t7 = new Date(); restart(); refreshDisplay(); t8 = new Date(); if(pluginProblem) { story.displayTiddler(null,"PluginManager"); displayMessage(config.messages.customConfigError); } for(var m in config.macros) { if(config.macros[m].init) config.macros[m].init(); } t9 = new Date(); if(showBackstage) backstage.init(); t10 = new Date(); if(config.options.chkDisplayInstrumentation) { displayMessage("LoadShadows " + (t2-t1) + " ms"); displayMessage("LoadFromDiv " + (t3-t2) + " ms"); displayMessage("LoadPlugins " + (t5-t4) + " ms"); displayMessage("Notify " + (t7-t6) + " ms"); displayMessage("Restart " + (t8-t7) + " ms"); displayMessage("Macro init " + (t9-t8) + " ms"); displayMessage("Total: " + (t10-t0) + " ms"); } startingUp = false; } // Restarting function restart() { invokeParamifier(params,"onstart"); if(story.isEmpty()) { var tiddlers = store.filterTiddlers(store.getTiddlerText("DefaultTiddlers")); story.displayTiddlers(null,tiddlers); } window.scrollTo(0,0); } function saveTest() { var s = document.getElementById("saveTest"); if(s.hasChildNodes()) alert(config.messages.savedSnapshotError); s.appendChild(document.createTextNode("savetest")); } function loadShadowTiddlers() { var shadows = new TiddlyWiki(); shadows.loadFromDiv("shadowArea","shadows",true); shadows.forEachTiddler(function(title,tiddler){config.shadowTiddlers[title] = tiddler.text;}); delete shadows; } function loadPlugins() { if(safeMode) return false; var tiddlers = store.getTaggedTiddlers("systemConfig"); var toLoad = []; var nLoaded = 0; var map = {}; var nPlugins = tiddlers.length; installedPlugins = []; for(var i=0; i<nPlugins; i++) { var p = getPluginInfo(tiddlers[i]); installedPlugins[i] = p; var n = p.Name; if(n) map[n] = p; n = p.Source; if(n) map[n] = p; } var visit = function(p) { if(!p || p.done) return; p.done = 1; var reqs = p.Requires; if(reqs) { reqs = reqs.readBracketedList(); for(var i=0; i<reqs.length; i++) visit(map[reqs[i]]); } toLoad.push(p); }; for(i=0; i<nPlugins; i++) visit(installedPlugins[i]); for(i=0; i<toLoad.length; i++) { p = toLoad[i]; pluginInfo = p; tiddler = p.tiddler; if(isPluginExecutable(p)) { if(isPluginEnabled(p)) { p.executed = true; var startTime = new Date(); try { if(tiddler.text) window.eval(tiddler.text); nLoaded++; } catch(ex) { p.log.push(config.messages.pluginError.format([exceptionText(ex)])); p.error = true; } pluginInfo.startupTime = String((new Date()) - startTime) + "ms"; } else { nPlugins--; } } else { p.warning = true; } } return nLoaded != nPlugins; } function getPluginInfo(tiddler) { var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","Requires","CoreVersion","Date","Source","Author","License","Browsers"]); p.tiddler = tiddler; p.title = tiddler.title; p.log = []; return p; } // Check that a particular plugin is valid for execution function isPluginExecutable(plugin) { if(plugin.tiddler.isTagged("systemConfigForce")) return verifyTail(plugin,true,config.messages.pluginForced); if(plugin["CoreVersion"]) { var coreVersion = plugin["CoreVersion"].split("."); var w = parseInt(coreVersion[0]) - version.major; if(w == 0 && coreVersion[1]) w = parseInt(coreVersion[1]) - version.minor; if(w == 0 && coreVersion[2]) w = parseInt(coreVersion[2]) - version.revision; if(w > 0) return verifyTail(plugin,false,config.messages.pluginVersionError); } return true; } function isPluginEnabled(plugin) { if(plugin.tiddler.isTagged("systemConfigDisable")) return verifyTail(plugin,false,config.messages.pluginDisabled); return true; } function verifyTail(plugin,result,message) { plugin.log.push(message); return result; } function invokeMacro(place,macro,params,wikifier,tiddler) { try { var m = config.macros[macro]; if(m && m.handler) m.handler(place,macro,params.readMacroParams(),wikifier,params,tiddler); else createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro])); } catch(ex) { createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()])); } } //-- //-- Paramifiers //-- function getParameters() { var p = null; if(window.location.hash) { p = decodeURIComponent(window.location.hash.substr(1)); if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111") p = convertUTF8ToUnicode(p); } return p; } function invokeParamifier(params,handler) { if(!params || params.length == undefined || params.length <= 1) return; for(var t=1; t<params.length; t++) { var p = config.paramifiers[params[t].name]; if(p && p[handler] instanceof Function) p[handler](params[t].value); } } config.paramifiers = {}; config.paramifiers.start = { oninit: function(v) { safeMode = v.toLowerCase() == "safe"; } }; config.paramifiers.open = { onstart: function(v) { if(!readOnly || store.tiddlerExists(v) || store.isShadowTiddler(v)) story.displayTiddler("bottom",v,null,false,null); } }; config.paramifiers.story = { onstart: function(v) { var list = store.getTiddlerText(v,"").parseParams("open",null,false); invokeParamifier(list,"onstart"); } }; config.paramifiers.search = { onstart: function(v) { story.search(v,false,false); } }; config.paramifiers.searchRegExp = { onstart: function(v) { story.prototype.search(v,false,true); } }; config.paramifiers.tag = { onstart: function(v) { var tagged = store.getTaggedTiddlers(v,"title"); story.displayTiddlers(null,tagged,null,false,null); } }; config.paramifiers.newTiddler = { onstart: function(v) { if(!readOnly) { story.displayTiddler(null,v,DEFAULT_EDIT_TEMPLATE); story.focusTiddler(v,"text"); } } }; config.paramifiers.newJournal = { onstart: function(v) { if(!readOnly) { var now = new Date(); var title = now.formatString(v.trim()); story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE); story.focusTiddler(title,"text"); } } }; config.paramifiers.readOnly = { onconfig: function(v) { var p = v.toLowerCase(); readOnly = p == "yes" ? true : (p == "no" ? false : readOnly); } }; config.paramifiers.theme = { onconfig: function(v) { story.switchTheme(v); } }; config.paramifiers.upgrade = { onstart: function(v) { upgradeFrom(v); } }; //-- //-- Formatter helpers //-- function Formatter(formatters) { this.formatters = []; var pattern = []; for(var n=0; n<formatters.length; n++) { pattern.push("(" + formatters[n].match + ")"); this.formatters.push(formatters[n]); } this.formatterRegExp = new RegExp(pattern.join("|"),"mg"); } config.formatterHelpers = { createElementAndWikify: function(w) { w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp); }, inlineCssHelper: function(w) { var styles = []; config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch; var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source); while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) { var s,v; if(lookaheadMatch[1]) { s = lookaheadMatch[1].unDash(); v = lookaheadMatch[2]; } else { s = lookaheadMatch[3].unDash(); v = lookaheadMatch[4]; } if(s=="bgcolor") s = "backgroundColor"; styles.push({style: s, value: v}); w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length; config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch; lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source); } return styles; }, applyCssHelper: function(e,styles) { for(var t=0; t< styles.length; t++) { try { e.style[styles[t].style] = styles[t].value; } catch (ex) { } } }, enclosedTextHelper: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.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,this.element,null,null,text); w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length; } }, isExternalLink: function(link) { if(store.tiddlerExists(link) || store.isShadowTiddler(link)) { return false; } var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg"); if(urlRegExp.exec(link)) { return true; } if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) { return true; } return false; } }; //-- //-- Standard formatters //-- config.formatters = [ { name: "table", match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$", lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg, rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg, cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg, cellTermRegExp: /((?:\x20*)\|)/mg, rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"}, handler: function(w) { var table = createTiddlyElement(w.output,"table",null,"twtable"); var prevColumns = []; var currRowType = null; var rowContainer; var rowCount = 0; w.nextMatch = w.matchStart; this.lookaheadRegExp.lastIndex = w.nextMatch; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) { var nextRowType = lookaheadMatch[2]; if(nextRowType == "k") { table.className = lookaheadMatch[1]; w.nextMatch += lookaheadMatch[0].length+1; } else { if(nextRowType != currRowType) { rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]); currRowType = nextRowType; } if(currRowType == "c") { // Caption w.nextMatch++; if(rowContainer != table.firstChild) table.insertBefore(rowContainer,table.firstChild); rowContainer.setAttribute("align",rowCount == 0?"top":"bottom"); w.subWikifyTerm(rowContainer,this.rowTermRegExp); } else { var theRow = createTiddlyElement(rowContainer,"tr",null,(rowCount&1)?"oddRow":"evenRow"); theRow.onmouseover = function() {addClass(this,"hoverRow");}; theRow.onmouseout = function() {removeClass(this,"hoverRow");}; this.rowHandler(w,theRow,prevColumns); rowCount++; } } this.lookaheadRegExp.lastIndex = w.nextMatch; lookaheadMatch = this.lookaheadRegExp.exec(w.source); } }, rowHandler: function(w,e,prevColumns) { var col = 0; var colSpanCount = 1; var prevCell = null; this.cellRegExp.lastIndex = w.nextMatch; var cellMatch = this.cellRegExp.exec(w.source); while(cellMatch && cellMatch.index == w.nextMatch) { if(cellMatch[1] == "~") { // Rowspan var last = prevColumns[col]; if(last) { last.rowSpanCount++; last.element.setAttribute("rowspan",last.rowSpanCount); last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE last.element.valign = "center"; } w.nextMatch = this.cellRegExp.lastIndex-1; } else if(cellMatch[1] == ">") { // Colspan colSpanCount++; w.nextMatch = this.cellRegExp.lastIndex-1; } else if(cellMatch[2]) { // End of row if(prevCell && colSpanCount > 1) { prevCell.setAttribute("colspan",colSpanCount); prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE } w.nextMatch = this.cellRegExp.lastIndex; break; } else { // Cell w.nextMatch++; var styles = config.formatterHelpers.inlineCssHelper(w); var spaceLeft = false; var chr = w.source.substr(w.nextMatch,1); while(chr == " ") { spaceLeft = true; w.nextMatch++; chr = w.source.substr(w.nextMatch,1); } var cell; if(chr == "!") { cell = createTiddlyElement(e,"th"); w.nextMatch++; } else { cell = createTiddlyElement(e,"td"); } prevCell = cell; prevColumns[col] = {rowSpanCount:1,element:cell}; if(colSpanCount > 1) { cell.setAttribute("colspan",colSpanCount); cell.setAttribute("colSpan",colSpanCount); // Needed for IE colSpanCount = 1; } config.formatterHelpers.applyCssHelper(cell,styles); w.subWikifyTerm(cell,this.cellTermRegExp); if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight cell.align = spaceLeft ? "center" : "left"; else if(spaceLeft) cell.align = "right"; w.nextMatch--; } col++; this.cellRegExp.lastIndex = w.nextMatch; cellMatch = this.cellRegExp.exec(w.source); } } }, { name: "heading", match: "^!{1,6}", termRegExp: /(\n)/mg, handler: function(w) { w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp); } }, { name: "list", match: "^(?:[\\*#;:]+)", lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg, termRegExp: /(\n)/mg, handler: function(w) { var stack = [w.output]; var currLevel = 0, currType = null; var listLevel, listType, itemType, baseType; w.nextMatch = w.matchStart; this.lookaheadRegExp.lastIndex = w.nextMatch; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) { if(lookaheadMatch[1]) { listType = "ul"; itemType = "li"; } else if(lookaheadMatch[2]) { listType = "ol"; itemType = "li"; } else if(lookaheadMatch[3]) { listType = "dl"; itemType = "dt"; } else if(lookaheadMatch[4]) { listType = "dl"; itemType = "dd"; } if(!baseType) baseType = listType; listLevel = lookaheadMatch[0].length; w.nextMatch += lookaheadMatch[0].length; var t; if(listLevel > currLevel) { for(t=currLevel; t<listLevel; t++) { var target = (currLevel == 0) ? stack[stack.length-1] : stack[stack.length-1].lastChild; stack.push(createTiddlyElement(target,listType)); } } else if(listType!=baseType && listLevel==1) { w.nextMatch -= lookaheadMatch[0].length; return; } else if(listLevel < currLevel) { for(t=currLevel; t>listLevel; t--) stack.pop(); } else if(listLevel == currLevel && listType != currType) { stack.pop(); stack.push(createTiddlyElement(stack[stack.length-1].lastChild,listType)); } currLevel = listLevel; currType = listType; var e = createTiddlyElement(stack[stack.length-1],itemType); w.subWikifyTerm(e,this.termRegExp); this.lookaheadRegExp.lastIndex = w.nextMatch; lookaheadMatch = this.lookaheadRegExp.exec(w.source); } } }, { name: "quoteByBlock", match: "^<<<\\n", termRegExp: /(^<<<(\n|$))/mg, element: "blockquote", handler: config.formatterHelpers.createElementAndWikify }, { name: "quoteByLine", match: "^>+", lookaheadRegExp: /^>+/mg, termRegExp: /(\n)/mg, element: "blockquote", handler: function(w) { var stack = [w.output]; var currLevel = 0; var newLevel = w.matchLength; var t; do { if(newLevel > currLevel) { for(t=currLevel; t<newLevel; t++) stack.push(createTiddlyElement(stack[stack.length-1],this.element)); } else if(newLevel < currLevel) { for(t=currLevel; t>newLevel; t--) stack.pop(); } currLevel = newLevel; w.subWikifyTerm(stack[stack.length-1],this.termRegExp); createTiddlyElement(stack[stack.length-1],"br"); this.lookaheadRegExp.lastIndex = w.nextMatch; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch; if(matched) { newLevel = lookaheadMatch[0].length; w.nextMatch += lookaheadMatch[0].length; } } while(matched); } }, { name: "rule", match: "^----+$\\n?", handler: function(w) { createTiddlyElement(w.output,"hr"); } }, { name: "monospacedByLine", match: "^(?:/\\*\\{\\{\\{\\*/|\\{\\{\\{|//\\{\\{\\{|<!--\\{\\{\\{-->)\\n", element: "pre", handler: function(w) { switch(w.matchText) { case "/*{{{*/\n": // CSS this.lookaheadRegExp = /\/\*\{\{\{\*\/\n*((?:^[^\n]*\n)+?)(\n*^\/\*\}\}\}\*\/$\n?)/mg; break; case "{{{\n": // monospaced block this.lookaheadRegExp = /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/mg; break; case "//{{{\n": // plugin this.lookaheadRegExp = /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\/\/\}\}\}$\n?)/mg; break; case "<!--{{{-->\n": //template this.lookaheadRegExp = /<!--\{\{\{-->\n*((?:^[^\n]*\n)+?)(\n*^<!--\}\}\}-->$\n?)/mg; break; default: break; } config.formatterHelpers.enclosedTextHelper.call(this,w); } }, { name: "wikifyComment", match: "^(?:/\\*\\*\\*|<!---)\\n", handler: function(w) { var termRegExp = (w.matchText == "/***\n") ? (/(^\*\*\*\/\n)/mg) : (/(^--->\n)/mg); w.subWikifyTerm(w.output,termRegExp); } }, { name: "macro", match: "<<", lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) { w.nextMatch = this.lookaheadRegExp.lastIndex; invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler); } } }, { name: "prettyLink", match: "\\[\\[", lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { var e; var text = lookaheadMatch[1]; if(lookaheadMatch[3]) { // Pretty bracketted link var link = lookaheadMatch[3]; e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link)) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler); } else { // Simple bracketted link e = createTiddlyLink(w.output,text,false,null,w.isStatic,w.tiddler); } createTiddlyText(e,text); w.nextMatch = this.lookaheadRegExp.lastIndex; } } }, { name: "wikiLink", match: config.textPrimitives.unWikiLink+"?"+config.textPrimitives.wikiLink, handler: function(w) { if(w.matchText.substr(0,1) == config.textPrimitives.unWikiLink) { w.outputText(w.output,w.matchStart+1,w.nextMatch); return; } if(w.matchStart > 0) { var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg"); preRegExp.lastIndex = w.matchStart-1; var preMatch = preRegExp.exec(w.source); if(preMatch.index == w.matchStart-1) { w.outputText(w.output,w.matchStart,w.nextMatch); return; } } if(w.autoLinkWikiWords || store.isShadowTiddler(w.matchText)) { var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic,w.tiddler); w.outputText(link,w.matchStart,w.nextMatch); } else { w.outputText(w.output,w.matchStart,w.nextMatch); } } }, { name: "urlLink", match: config.textPrimitives.urlPattern, handler: function(w) { w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch); } }, { name: "image", match: "\\[[<>]?[Ii][Mm][Gg]\\[", lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { var e = w.output; if(lookaheadMatch[5]) { var link = lookaheadMatch[5]; e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler); addClass(e,"imageLink"); } var img = createTiddlyElement(e,"img"); if(lookaheadMatch[1]) img.align = "left"; else if(lookaheadMatch[2]) img.align = "right"; if(lookaheadMatch[3]) { img.title = lookaheadMatch[3]; img.setAttribute("alt",lookaheadMatch[3]); } img.src = lookaheadMatch[4]; w.nextMatch = this.lookaheadRegExp.lastIndex; } } }, { name: "html", match: "<[Hh][Tt][Mm][Ll]>", lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1]; w.nextMatch = this.lookaheadRegExp.lastIndex; } } }, { name: "commentByBlock", match: "/%", lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) w.nextMatch = this.lookaheadRegExp.lastIndex; } }, { name: "characterFormat", match: "''|//|__|\\^\\^|~~|--(?!\\s|$)|\\{\\{\\{", handler: function(w) { switch(w.matchText) { case "''": w.subWikifyTerm(w.output.appendChild(document.createElement("strong")),/('')/mg); break; case "//": w.subWikifyTerm(createTiddlyElement(w.output,"em"),/(\/\/)/mg); break; case "__": w.subWikifyTerm(createTiddlyElement(w.output,"u"),/(__)/mg); break; case "^^": w.subWikifyTerm(createTiddlyElement(w.output,"sup"),/(\^\^)/mg); break; case "~~": w.subWikifyTerm(createTiddlyElement(w.output,"sub"),/(~~)/mg); break; case "--": w.subWikifyTerm(createTiddlyElement(w.output,"strike"),/(--)/mg); break; case "{{{": var lookaheadRegExp = /\{\{\{((?:.|\n)*?)\}\}\}/mg; lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]); w.nextMatch = lookaheadRegExp.lastIndex; } break; } } }, { name: "customFormat", match: "@@|\\{\\{", handler: function(w) { switch(w.matchText) { case "@@": var e = createTiddlyElement(w.output,"span"); var styles = config.formatterHelpers.inlineCssHelper(w); if(styles.length == 0) e.className = "marked"; else config.formatterHelpers.applyCssHelper(e,styles); w.subWikifyTerm(e,/(@@)/mg); break; case "{{": lookaheadRegExp = /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg; lookaheadRegExp.lastIndex = w.matchStart; lookaheadMatch = lookaheadRegExp.exec(w.source); if(lookaheadMatch) { w.nextMatch = lookaheadRegExp.lastIndex; e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]); w.subWikifyTerm(e,/(\}\}\})/mg); } break; } } }, { name: "mdash", match: "--", handler: function(w) { createTiddlyElement(w.output,"span").innerHTML = "—"; } }, { name: "lineBreak", match: "\\n|<br ?/?>", handler: function(w) { createTiddlyElement(w.output,"br"); } }, { name: "rawText", match: "\\\"{3}|<nowiki>", lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg, handler: function(w) { this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]); w.nextMatch = this.lookaheadRegExp.lastIndex; } } }, { name: "htmlEntitiesEncoding", match: "(?:(?:&#?[a-zA-Z0-9]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9a-fA-F]|1D[c-fC-F][0-9a-fA-F]|20[d-fD-F][0-9a-fA-F]|FE2[0-9a-fA-F])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[a-zA-Z0-9]{2,8};)", handler: function(w) { createTiddlyElement(w.output,"span").innerHTML = w.matchText; } } ]; //-- //-- Wikifier //-- function getParser(tiddler,format) { if(tiddler) { if(!format) format = tiddler.fields["wikiformat"]; var i; if(format) { for(i in config.parsers) { if(format == config.parsers[i].format) return config.parsers[i]; } } else { for(i in config.parsers) { if(tiddler.isTagged(config.parsers[i].formatTag)) return config.parsers[i]; } } } return formatter; } function wikify(source,output,highlightRegExp,tiddler) { if(source && source != "") { var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler); wikifier.subWikify(output); } } function wikifyStatic(source,highlightRegExp,tiddler,format) { var e = createTiddlyElement(document.body,"pre"); e.style.display = "none"; var html = ""; if(source && source != "") { if(!tiddler) tiddler = new Tiddler("temp"); var wikifier = new Wikifier(source,getParser(tiddler,format),highlightRegExp,tiddler); wikifier.isStatic = true; wikifier.subWikify(e); html = e.innerHTML; removeNode(e); } return html; } function wikifyPlain(title,theStore,limit) { if(!theStore) theStore = store; if(theStore.tiddlerExists(title) || theStore.isShadowTiddler(title)) { return wikifyPlainText(theStore.getTiddlerText(title),limit,tiddler); } else { return ""; } } function wikifyPlainText(text,limit,tiddler) { if(limit > 0) text = text.substr(0,limit); var wikifier = new Wikifier(text,formatter,null,tiddler); return wikifier.wikifyPlain(); } function highlightify(source,output,highlightRegExp,tiddler) { if(source && source != "") { var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler); wikifier.outputText(output,0,source.length); } } function Wikifier(source,formatter,highlightRegExp,tiddler) { this.source = source; this.output = null; this.formatter = formatter; this.nextMatch = 0; this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true; this.highlightRegExp = highlightRegExp; this.highlightMatch = null; this.isStatic = false; if(highlightRegExp) { highlightRegExp.lastIndex = 0; this.highlightMatch = highlightRegExp.exec(source); } this.tiddler = tiddler; } Wikifier.prototype.wikifyPlain = function() { var e = createTiddlyElement(document.body,"div"); e.style.display = "none"; this.subWikify(e); var text = getPlainText(e); removeNode(e); return text; }; Wikifier.prototype.subWikify = function(output,terminator) { try { if(terminator) this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg")); else this.subWikifyUnterm(output); } catch(ex) { showException(ex); } }; Wikifier.prototype.subWikifyUnterm = function(output) { var oldOutput = this.output; this.output = output; this.formatter.formatterRegExp.lastIndex = this.nextMatch; var formatterMatch = this.formatter.formatterRegExp.exec(this.source); while(formatterMatch) { // Output any text before the match if(formatterMatch.index > this.nextMatch) this.outputText(this.output,this.nextMatch,formatterMatch.index); // Set the match parameters for the handler this.matchStart = formatterMatch.index; this.matchLength = formatterMatch[0].length; this.matchText = formatterMatch[0]; this.nextMatch = this.formatter.formatterRegExp.lastIndex; for(var t=1; t<formatterMatch.length; t++) { if(formatterMatch[t]) { this.formatter.formatters[t-1].handler(this); this.formatter.formatterRegExp.lastIndex = this.nextMatch; break; } } formatterMatch = this.formatter.formatterRegExp.exec(this.source); } if(this.nextMatch < this.source.length) { this.outputText(this.output,this.nextMatch,this.source.length); this.nextMatch = this.source.length; } this.output = oldOutput; }; Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp) { var oldOutput = this.output; this.output = output; terminatorRegExp.lastIndex = this.nextMatch; var terminatorMatch = terminatorRegExp.exec(this.source); this.formatter.formatterRegExp.lastIndex = this.nextMatch; var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source); while(terminatorMatch || formatterMatch) { if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) { if(terminatorMatch.index > this.nextMatch) this.outputText(this.output,this.nextMatch,terminatorMatch.index); this.matchText = terminatorMatch[1]; this.matchLength = terminatorMatch[1].length; this.matchStart = terminatorMatch.index; this.nextMatch = this.matchStart + this.matchLength; this.output = oldOutput; return; } if(formatterMatch.index > this.nextMatch) this.outputText(this.output,this.nextMatch,formatterMatch.index); this.matchStart = formatterMatch.index; this.matchLength = formatterMatch[0].length; this.matchText = formatterMatch[0]; this.nextMatch = this.formatter.formatterRegExp.lastIndex; for(var t=1; t<formatterMatch.length; t++) { if(formatterMatch[t]) { this.formatter.formatters[t-1].handler(this); this.formatter.formatterRegExp.lastIndex = this.nextMatch; break; } } terminatorRegExp.lastIndex = this.nextMatch; terminatorMatch = terminatorRegExp.exec(this.source); formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source); } if(this.nextMatch < this.source.length) { this.outputText(this.output,this.nextMatch,this.source.length); this.nextMatch = this.source.length; } this.output = oldOutput; }; Wikifier.prototype.outputText = function(place,startPos,endPos) { while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) { if(this.highlightMatch.index > startPos) { createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index)); startPos = this.highlightMatch.index; } var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos); var theHighlight = createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd)); startPos = highlightEnd; if(startPos >= this.highlightRegExp.lastIndex) this.highlightMatch = this.highlightRegExp.exec(this.source); } if(startPos < endPos) { createTiddlyText(place,this.source.substring(startPos,endPos)); } }; //-- //-- Macro definitions //-- config.macros.today.handler = function(place,macroName,params) { var now = new Date(); var text = params[0] ? now.formatString(params[0].trim()) : now.toLocaleString(); createTiddlyElement(place,"span",null,null,text); }; config.macros.version.handler = function(place) { createTiddlyElement(place,"span",null,null,formatVersion()); }; config.macros.list.handler = function(place,macroName,params) { var type = params[0] ? params[0] : "all"; var list = document.createElement("ul"); place.appendChild(list); if(this[type].prompt) createTiddlyElement(list,"li",null,"listTitle",this[type].prompt); var results; if(this[type].handler) results = this[type].handler(params); for(var t = 0; t < results.length; t++) { var li = document.createElement("li"); list.appendChild(li); createTiddlyLink(li,typeof results[t] == "string" ? results[t] : 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.list.shadowed.handler = function(params) { return store.getShadowed(); }; config.macros.list.touched.handler = function(params) { return store.getTouched(); }; config.macros.list.filter.handler = function(params) { var filter = params[1]; var results = []; if(filter) { var tiddlers = store.filterTiddlers(filter); for(var t=0; t<tiddlers.length; t++) results.push(tiddlers[t].title); } return results; }; config.macros.allTags.handler = function(place,macroName,params) { var tags = store.getTags(params[0]); var ul = createTiddlyElement(place,"ul"); if(tags.length == 0) createTiddlyElement(ul,"li",null,"listTitle",this.noTags); for(var t=0; t<tags.length; t++) { var title = tags[t][0]; var info = getTiddlyLinkInfo(title); var li = createTiddlyElement(ul,"li"); var btn = createTiddlyButton(li,title + " (" + tags[t][1] + ")",this.tooltip.format([title]),onClickTag,info.classes); btn.setAttribute("tag",title); btn.setAttribute("refresh","link"); btn.setAttribute("tiddlyLink",title); } }; config.macros.timeline.handler = function(place,macroName,params) { var field = params[0] ? params[0] : "modified"; var tiddlers = store.reverseLookup("tags","excludeLists",false,field); var lastDay = ""; var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1])) : 0; var dateFormat = params[2] ? params[2] : this.dateFormat; for(var t=tiddlers.length-1; t>=last; t--) { var tiddler = tiddlers[t]; var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8); if(theDay != lastDay) { var ul = document.createElement("ul"); place.appendChild(ul); createTiddlyElement(ul,"li",null,"listTitle",tiddler[field].formatString(dateFormat)); lastDay = theDay; } createTiddlyElement(ul,"li",null,"listLink").appendChild(createTiddlyLink(place,tiddler.title,true)); } }; config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler) { params = paramString.parseParams("name",null,true,false,true); var names = params[0]["name"]; var tiddlerName = names[0]; var className = names[1] ? names[1] : null; var args = params[0]["with"]; var wrapper = createTiddlyElement(place,"span",null,className); if(!args) { wrapper.setAttribute("refresh","content"); wrapper.setAttribute("tiddler",tiddlerName); } var text = store.getTiddlerText(tiddlerName); if(text) { var stack = config.macros.tiddler.tiddlerStack; if(stack.indexOf(tiddlerName) !== -1) return; stack.push(tiddlerName); try { var n = args ? Math.min(args.length,9) : 0; for(var i=0; i<n; i++) { var placeholderRE = new RegExp("\\$" + (i + 1),"mg"); text = text.replace(placeholderRE,args[i]); } config.macros.tiddler.renderText(wrapper,text,tiddlerName,params); } finally { stack.pop(); } } }; config.macros.tiddler.renderText = function(place,text,tiddlerName,params) { wikify(text,place,null,store.getTiddler(tiddlerName)); }; config.macros.tiddler.tiddlerStack = []; config.macros.tag.handler = function(place,macroName,params) { createTagButton(place,params[0],null,params[1],params[2]); }; config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler) { params = paramString.parseParams("anon",null,true,false,false); var ul = createTiddlyElement(place,"ul"); var title = getParam(params,"anon",""); if(title && store.tiddlerExists(title)) tiddler = store.getTiddler(title); var sep = getParam(params,"sep"," "); var lingo = config.views.wikified.tag; var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags; createTiddlyElement(ul,"li",null,"listTitle",prompt.format([tiddler.title])); for(var t=0; t<tiddler.tags.length; t++) { createTagButton(createTiddlyElement(ul,"li"),tiddler.tags[t],tiddler.title); if(t<tiddler.tags.length-1) createTiddlyText(ul,sep); } }; config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler) { params = paramString.parseParams("anon",null,true,false,false); var ul = createTiddlyElement(place,"ul"); var title = getParam(params,"anon",""); if(title == "" && tiddler instanceof Tiddler) title = tiddler.title; var sep = getParam(params,"sep"," "); ul.setAttribute("title",this.tooltip.format([title])); var tagged = store.getTaggedTiddlers(title); var prompt = tagged.length == 0 ? this.labelNotTag : this.label; createTiddlyElement(ul,"li",null,"listTitle",prompt.format([title,tagged.length])); for(var t=0; t<tagged.length; t++) { createTiddlyLink(createTiddlyElement(ul,"li"),tagged[t].title,true); if(t<tagged.length-1) createTiddlyText(ul,sep); } }; config.macros.closeAll.handler = function(place) { createTiddlyButton(place,this.label,this.prompt,this.onClick); }; config.macros.closeAll.onClick = function(e) { story.closeAllTiddlers(); return false; }; config.macros.permaview.handler = function(place) { createTiddlyButton(place,this.label,this.prompt,this.onClick); }; config.macros.permaview.onClick = function(e) { story.permaView(); return false; }; config.macros.saveChanges.handler = function(place,macroName,params) { if(!readOnly) createTiddlyButton(place,params[0] || this.label,params[1] || this.prompt,this.onClick,null,null,this.accessKey); }; config.macros.saveChanges.onClick = function(e) { saveChanges(); return false; }; config.macros.slider.onClickSlider = function(ev) { var e = ev ? ev : window.event; var n = this.nextSibling; var cookie = n.getAttribute("cookie"); var isOpen = n.style.display != "none"; if(config.options.chkAnimate && anim && typeof Slider == "function") anim.startAnimating(new Slider(n,!isOpen,null,"none")); else n.style.display = isOpen ? "none" : "block"; config.options[cookie] = !isOpen; saveOptionCookie(cookie); return false; }; config.macros.slider.createSlider = function(place,cookie,title,tooltip) { var c = cookie ? cookie : ""; var btn = createTiddlyButton(place,title,tooltip,this.onClickSlider); var panel = createTiddlyElement(null,"div",null,"sliderPanel"); panel.setAttribute("cookie",c); panel.style.display = config.options[c] ? "block" : "none"; place.appendChild(panel); return panel; }; config.macros.slider.handler = function(place,macroName,params) { var panel = this.createSlider(place,params[0],params[2],params[3]); var text = store.getTiddlerText(params[1]); panel.setAttribute("refresh","content"); panel.setAttribute("tiddler",params[1]); if(text) wikify(text,panel,null,store.getTiddler(params[1])); }; // <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >> config.macros.gradient.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var panel = wikifier ? createTiddlyElement(place,"div",null,"gradient") : place; panel.style.position = "relative"; panel.style.overflow = "hidden"; panel.style.zIndex = "0"; if(wikifier) { var styles = config.formatterHelpers.inlineCssHelper(wikifier); config.formatterHelpers.applyCssHelper(panel,styles); } params = paramString.parseParams("color"); var locolors = [], hicolors = []; for(var t=2; t<params.length; t++) { var c = new RGB(params[t].value); if(params[t].name == "snap") { hicolors[hicolors.length-1] = c; } else { locolors.push(c); hicolors.push(c); } } drawGradient(panel,params[1].value != "vert",locolors,hicolors); if(wikifier) wikifier.subWikify(panel,">>"); if(document.all) { panel.style.height = "100%"; panel.style.width = "100%"; } }; config.macros.message.handler = function(place,macroName,params) { if(params[0]) { var names = params[0].split("."); var lookupMessage = function(root,nameIndex) { if(names[nameIndex] in root) { if(nameIndex < names.length-1) return (lookupMessage(root[names[nameIndex]],nameIndex+1)); else return root[names[nameIndex]]; } else return null; }; var m = lookupMessage(config,0); if(m == null) m = lookupMessage(window,0); createTiddlyText(place,m.toString().format(params.splice(1))); } }; config.macros.view.views = { text: function(value,place,params,wikifier,paramString,tiddler) { highlightify(value,place,highlightHack,tiddler); }, link: function(value,place,params,wikifier,paramString,tiddler) { createTiddlyLink(place,value,true); }, wikified: function(value,place,params,wikifier,paramString,tiddler) { if(params[2]) value=params[2].unescapeLineBreaks().format([value]); wikify(value,place,highlightHack,tiddler); }, date: function(value,place,params,wikifier,paramString,tiddler) { value = Date.convertFromYYYYMMDDHHMM(value); createTiddlyText(place,value.formatString(params[2] ? params[2] : config.views.wikified.dateFormat)); } }; config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler) { if((tiddler instanceof Tiddler) && params[0]) { var value = store.getValue(tiddler,params[0]); if(value) { var type = params[1] ? params[1] : config.macros.view.defaultView; var handler = config.macros.view.views[type]; if(handler) handler(value,place,params,wikifier,paramString,tiddler); } } }; config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var field = params[0]; var rows = params[1] || 0; var defVal = params[2] || ''; if((tiddler instanceof Tiddler) && field) { story.setDirty(tiddler.title,true); var e,v; if(field != "text" && !rows) { e = createTiddlyElement(null,"input"); if(tiddler.isReadOnly()) e.setAttribute("readOnly","readOnly"); e.setAttribute("edit",field); e.setAttribute("type","text"); e.value = store.getValue(tiddler,field) || defVal; e.setAttribute("size","40"); e.setAttribute("autocomplete","off"); place.appendChild(e); } else { var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix"); var wrapper2 = createTiddlyElement(wrapper1,"div"); e = createTiddlyElement(wrapper2,"textarea"); if(tiddler.isReadOnly()) e.setAttribute("readOnly","readOnly"); e.value = v = store.getValue(tiddler,field) || defVal; rows = rows ? rows : 10; var lines = v.match(/\n/mg); var maxLines = Math.max(parseInt(config.options.txtMaxEditRows),5); if(lines != null && lines.length > rows) rows = lines.length + 5; rows = Math.min(rows,maxLines); e.setAttribute("rows",rows); e.setAttribute("edit",field); place.appendChild(wrapper1); } return e; } }; config.macros.tagChooser.onClick = function(ev) { var e = ev ? ev : window.event; if(e.metaKey || e.ctrlKey) stopEvent(e); //# keep popup open on CTRL-click var lingo = config.views.editor.tagChooser; var popup = Popup.create(this); var tags = store.getTags(); if(tags.length == 0) createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone); for(var t=0; t<tags.length; t++) { var tag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick); tag.setAttribute("tag",tags[t][0]); tag.setAttribute("tiddler",this.getAttribute("tiddler")); } Popup.show(); e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); return false; }; config.macros.tagChooser.onTagClick = function(ev) { var e = ev ? ev : window.event; var tag = this.getAttribute("tag"); var title = this.getAttribute("tiddler"); if(!readOnly) story.setTiddlerTag(title,tag,0); return false; }; config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler) { if(tiddler instanceof Tiddler) { var lingo = config.views.editor.tagChooser; var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick); btn.setAttribute("tiddler",tiddler.title); } }; config.macros.refreshDisplay.handler = function(place) { createTiddlyButton(place,this.label,this.prompt,this.onClick); }; config.macros.refreshDisplay.onClick = function(e) { refreshAll(); return false; }; config.macros.annotations.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var title = tiddler ? tiddler.title : null; var a = title ? config.annotations[title] : null; if(!tiddler || !title || !a) return; var text = a.format([title]); wikify(text,createTiddlyElement(place,"div",null,"annotation"),null,tiddler); }; //-- //-- NewTiddler and NewJournal macros //-- config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal) { var tags = []; for(var t=1; t<params.length; t++) { if((params[t].name == "anon" && t != 1) || (params[t].name == "tag")) tags.push(params[t].value); } label = getParam(params,"label",label); prompt = getParam(params,"prompt",prompt); accessKey = getParam(params,"accessKey",accessKey); newFocus = getParam(params,"focus",newFocus); var customFields = getParam(params,"fields",""); if(!customFields && !store.isShadowTiddler(title)) customFields = String.encodeHashMap(config.defaultCustomFields); var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey); btn.setAttribute("newTitle",title); btn.setAttribute("isJournal",isJournal ? "true" : "false"); if(tags.length > 0) btn.setAttribute("params",tags.join("|")); btn.setAttribute("newFocus",newFocus); btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE)); if(customFields !== "") btn.setAttribute("customFields",customFields); var text = getParam(params,"text"); if(text !== undefined) btn.setAttribute("newText",text); return btn; }; config.macros.newTiddler.onClickNewTiddler = function() { var title = this.getAttribute("newTitle"); if(this.getAttribute("isJournal") == "true") { var now = new Date(); title = now.formatString(title.trim()); } var params = this.getAttribute("params"); var tags = params ? params.split("|") : []; var focus = this.getAttribute("newFocus"); var template = this.getAttribute("newTemplate"); var customFields = this.getAttribute("customFields"); story.displayTiddler(null,title,template,false,null,null); var tiddlerElem = story.getTiddler(title); if(customFields) story.addCustomFields(tiddlerElem,customFields); var text = this.getAttribute("newText"); if(typeof text == "string") story.getTiddlerField(title,"text").value = text.format([title]); for(var t=0;t<tags.length;t++) story.setTiddlerTag(title,tags[t],+1); story.focusTiddler(title,focus); return false; }; config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler) { if(!readOnly) { params = paramString.parseParams("anon",null,true,false,false); var title = params[1] && params[1].name == "anon" ? params[1].value : this.title; title = getParam(params,"title",title); this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false); } }; config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString,tiddler) { if(!readOnly) { params = paramString.parseParams("anon",null,true,false,false); var title = params[1] && params[1].name == "anon" ? params[1].value : config.macros.timeline.dateFormat; title = getParam(params,"title",title); config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true); } }; //-- //-- Search macro //-- config.macros.search.handler = function(place,macroName,params) { var searchTimeout = null; var btn = createTiddlyButton(place,this.label,this.prompt,this.onClick,"searchButton"); var txt = createTiddlyElement(place,"input",null,"txtOptionInput searchField"); if(params[0]) txt.value = params[0]; txt.onkeyup = this.onKeyPress; txt.onfocus = this.onFocus; txt.setAttribute("size",this.sizeTextbox); txt.setAttribute("accessKey",this.accessKey); txt.setAttribute("autocomplete","off"); txt.setAttribute("lastSearchText",""); if(config.browser.isSafari) { txt.setAttribute("type","search"); txt.setAttribute("results","5"); } else { txt.setAttribute("type","text"); } }; // Global because there's only ever one outstanding incremental search timer config.macros.search.timeout = null; config.macros.search.doSearch = function(txt) { if(txt.value.length > 0) { story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch); txt.setAttribute("lastSearchText",txt.value); } }; config.macros.search.onClick = function(e) { config.macros.search.doSearch(this.nextSibling); return false; }; config.macros.search.onKeyPress = function(ev) { var e = ev ? ev : window.event; switch(e.keyCode) { case 13: // Ctrl-Enter case 10: // Ctrl-Enter on IE PC config.macros.search.doSearch(this); break; case 27: // Escape this.value = ""; clearMessage(); break; } if(config.options.chkIncrementalSearch) { if(this.value.length > 2) { if(this.value != this.getAttribute("lastSearchText")) { if(config.macros.search.timeout) clearTimeout(config.macros.search.timeout); var txt = this; config.macros.search.timeout = setTimeout(function() {config.macros.search.doSearch(txt);},500); } } else { if(config.macros.search.timeout) clearTimeout(config.macros.search.timeout); } } }; config.macros.search.onFocus = function(e) { this.select(); }; //-- //-- Tabs macro //-- config.macros.tabs.handler = function(place,macroName,params) { var cookie = params[0]; var numTabs = (params.length-1)/3; var wrapper = createTiddlyElement(null,"div",null,"tabsetWrapper " + cookie); var tabset = createTiddlyElement(wrapper,"div",null,"tabset"); 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("tab",label); tab.setAttribute("content",content); tab.title = prompt; if(config.options[cookie] == label) validTab = true; } if(!validTab) config.options[cookie] = params[1]; place.appendChild(wrapper); this.switchTab(tabset,config.options[cookie]); }; config.macros.tabs.onClickTab = function(e) { config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab")); return false; }; 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") removeNode(tabset.nextSibling); var tabContent = createTiddlyElement(null,"div",null,"tabContents"); tabset.parentNode.insertBefore(tabContent,tabset.nextSibling); var contentTitle = theTab.getAttribute("content"); wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle)); if(cookie) { config.options[cookie] = tab; saveOptionCookie(cookie); } } }; //-- //-- Tiddler toolbar //-- // Create a toolbar command button config.macros.toolbar.createCommand = function(place,commandName,tiddler,className) { if(typeof commandName != "string") { var c = null; for(var t in config.commands) { if(config.commands[t] == commandName) c = t; } commandName = c; } if((tiddler instanceof Tiddler) && (typeof commandName == "string")) { var command = config.commands[commandName]; if(command.isEnabled ? command.isEnabled(tiddler) : this.isCommandEnabled(command,tiddler)) { var text = command.getText ? command.getText(tiddler) : this.getCommandText(command,tiddler); var tooltip = command.getTooltip ? command.getTooltip(tiddler) : this.getCommandTooltip(command,tiddler); var cmd; switch(command.type) { case "popup": cmd = this.onClickPopup; break; case "command": default: cmd = this.onClickCommand; break; } var btn = createTiddlyButton(null,text,tooltip,cmd); btn.setAttribute("commandName",commandName); btn.setAttribute("tiddler",tiddler.title); if(className) addClass(btn,className); place.appendChild(btn); } } }; config.macros.toolbar.isCommandEnabled = function(command,tiddler) { var title = tiddler.title; var ro = tiddler.isReadOnly(); var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title); return (!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow); }; config.macros.toolbar.getCommandText = function(command,tiddler) { return tiddler.isReadOnly() && command.readOnlyText ? command.readOnlyText : command.text; }; config.macros.toolbar.getCommandTooltip = function(command,tiddler) { return tiddler.isReadOnly() && command.readOnlyTooltip ? command.readOnlyTooltip : command.tooltip; }; config.macros.toolbar.onClickCommand = function(ev) { var e = ev ? ev : window.event; e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); var command = config.commands[this.getAttribute("commandName")]; return command.handler(e,this,this.getAttribute("tiddler")); }; config.macros.toolbar.onClickPopup = function(ev) { var e = ev ? ev : window.event; e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); var popup = Popup.create(this); var command = config.commands[this.getAttribute("commandName")]; var title = this.getAttribute("tiddler"); var tiddler = store.fetchTiddler(title); popup.setAttribute("tiddler",title); command.handlePopup(popup,title); Popup.show(); return false; }; // Invoke the first command encountered from a given place that is tagged with a specified class config.macros.toolbar.invokeCommand = function(place,className,event) { var children = place.getElementsByTagName("a"); for(var t=0; t<children.length; t++) { var c = children[t]; if(hasClass(c,className) && c.getAttribute && c.getAttribute("commandName")) { if(c.onclick instanceof Function) c.onclick.call(c,event); break; } } }; config.macros.toolbar.onClickMore = function(ev) { var e = this.nextSibling; e.style.display = "inline"; removeNode(this); return false; }; config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler) { for(var t=0; t<params.length; t++) { var c = params[t]; switch(c) { case '>': var btn = createTiddlyButton(place,this.moreLabel,this.morePrompt,config.macros.toolbar.onClickMore); addClass(btn,"moreCommand"); var e = createTiddlyElement(place,"span",null,"moreCommand"); e.style.display = "none"; place = e; break; default: var className = ""; switch(c.substr(0,1)) { case "+": className = "defaultCommand"; c = c.substr(1); break; case "-": className = "cancelCommand"; c = c.substr(1); break; } if(c in config.commands) this.createCommand(place,c,tiddler,className); break; } } }; //-- //-- Menu and toolbar commands //-- config.commands.closeTiddler.handler = function(event,src,title) { if(story.isDirty(title) && !readOnly) { if(!confirm(config.commands.cancelTiddler.warning.format([title]))) return false; } story.setDirty(title,false); story.closeTiddler(title,true); return false; }; config.commands.closeOthers.handler = function(event,src,title) { story.closeAllTiddlers(title); return false; }; config.commands.editTiddler.handler = function(event,src,title) { clearMessage(); var tiddlerElem = story.getTiddler(title); var fields = tiddlerElem.getAttribute("tiddlyFields"); story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,fields); story.focusTiddler(title,config.options.txtEditorFocus||"text"); return false; }; config.commands.saveTiddler.handler = function(event,src,title) { var newTitle = story.saveTiddler(title,event.shiftKey); if(newTitle) story.displayTiddler(null,newTitle); return false; }; config.commands.cancelTiddler.handler = function(event,src,title) { if(story.hasChanges(title) && !readOnly) { if(!confirm(this.warning.format([title]))) return false; } story.setDirty(title,false); story.displayTiddler(null,title); return false; }; config.commands.deleteTiddler.handler = function(event,src,title) { var deleteIt = true; if(config.options.chkConfirmDelete) deleteIt = confirm(this.warning.format([title])); if(deleteIt) { store.removeTiddler(title); story.closeTiddler(title,true); autoSaveChanges(); } return false; }; config.commands.permalink.handler = function(event,src,title) { var t = encodeURIComponent(String.encodeTiddlyLink(title)); if(window.location.hash != t) window.location.hash = t; return false; }; config.commands.references.handlePopup = function(popup,title) { var references = store.getReferringTiddlers(title); var c = false; for(var r=0; r<references.length; r++) { if(references[r].title != title && !references[r].isTagged("excludeLists")) { createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true); c = true; } } if(!c) createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),this.popupNone); }; config.commands.jump.handlePopup = function(popup,title) { story.forEachTiddler(function(title,element) { createTiddlyLink(createTiddlyElement(popup,"li"),title,true,null,false,null,true); }); }; config.commands.syncing.handlePopup = function(popup,title) { var tiddler = store.fetchTiddler(title); if(!tiddler) return; var serverType = tiddler.getServerType(); var serverHost = tiddler.fields['server.host']; var serverWorkspace = tiddler.fields['server.workspace']; if(!serverWorkspace) serverWorkspace = ""; if(serverType) { var e = createTiddlyElement(popup,"li",null,"popupMessage"); e.innerHTML = config.commands.syncing.currentlySyncing.format([serverType,serverHost,serverWorkspace]); } else { createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.notCurrentlySyncing); } if(serverType) { createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div"); var btn = createTiddlyButton(createTiddlyElement(popup,"li"),this.captionUnSync,null,config.commands.syncing.onChooseServer); btn.setAttribute("tiddler",title); btn.setAttribute("server.type",""); } createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div"); createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.chooseServer); var feeds = store.getTaggedTiddlers("systemServer","title"); for(var t=0; t<feeds.length; t++) { var f = feeds[t]; var feedServerType = store.getTiddlerSlice(f.title,"Type"); if(!feedServerType) feedServerType = "file"; var feedServerHost = store.getTiddlerSlice(f.title,"URL"); if(!feedServerHost) feedServerHost = ""; var feedServerWorkspace = store.getTiddlerSlice(f.title,"Workspace"); if(!feedServerWorkspace) feedServerWorkspace = ""; var caption = f.title; if(serverType == feedServerType && serverHost == feedServerHost && serverWorkspace == feedServerWorkspace) { caption = config.commands.syncing.currServerMarker + caption; } else { caption = config.commands.syncing.notCurrServerMarker + caption; } btn = createTiddlyButton(createTiddlyElement(popup,"li"),caption,null,config.commands.syncing.onChooseServer); btn.setAttribute("tiddler",title); btn.setAttribute("server.type",feedServerType); btn.setAttribute("server.host",feedServerHost); btn.setAttribute("server.workspace",feedServerWorkspace); } }; config.commands.syncing.onChooseServer = function(e) { var tiddler = this.getAttribute("tiddler"); var serverType = this.getAttribute("server.type"); if(serverType) { store.addTiddlerFields(tiddler,{ 'server.type': serverType, 'server.host': this.getAttribute("server.host"), 'server.workspace': this.getAttribute("server.workspace") }); } else { store.setValue(tiddler,'server',null); } return false; }; config.commands.fields.handlePopup = function(popup,title) { var tiddler = store.fetchTiddler(title); if(!tiddler) return; var fields = {}; store.forEachField(tiddler,function(tiddler,fieldName,value) {fields[fieldName] = value;},true); var items = []; for(var t in fields) { items.push({field: t,value: fields[t]}); } items.sort(function(a,b) {return a.field < b.field ? -1 : (a.field == b.field ? 0 : +1);}); if(items.length > 0) ListView.create(popup,items,this.listViewTemplate); else createTiddlyElement(popup,"div",null,null,this.emptyText); }; //-- //-- Tiddler() object //-- function Tiddler(title) { this.title = title; this.text = ""; this.modifier = null; this.created = new Date(); this.modified = this.created; this.links = []; this.linksUpdated = false; this.tags = []; this.fields = {}; return this; } Tiddler.prototype.getLinks = function() { if(this.linksUpdated==false) this.changed(); return this.links; }; // Returns the fields that are inherited in string field:"value" field2:"value2" format Tiddler.prototype.getInheritedFields = function() { var f = {}; for(i in this.fields) { if(i=="server.host" || i=="server.workspace" || i=="wikiformat"|| i=="server.type") { f[i] = this.fields[i]; } } return String.encodeHashMap(f); }; // Increment the changeCount of a tiddler Tiddler.prototype.incChangeCount = function() { var c = this.fields['changecount']; c = c ? parseInt(c) : 0; this.fields['changecount'] = String(c+1); }; // Clear the changeCount of a tiddler Tiddler.prototype.clearChangeCount = function() { if(this.fields['changecount']) { delete this.fields['changecount']; } }; Tiddler.prototype.doNotSave = function() { return this.fields['doNotSave']; }; // Returns true if the tiddler has been updated since the tiddler was created or downloaded Tiddler.prototype.isTouched = function() { var changeCount = this.fields['changecount']; if(changeCount === undefined) changeCount = 0; return changeCount > 0; }; // Return the tiddler as an RSS item Tiddler.prototype.toRssItem = function(uri) { var s = []; s.push("<title" + ">" + this.title.htmlEncode() + "</title" + ">"); s.push("<description>" + wikifyStatic(this.text,null,this).htmlEncode() + "</description>"); for(var t=0; t<this.tags.length; t++) s.push("<category>" + this.tags[t] + "</category>"); s.push("<link>" + uri + "#" + encodeURIComponent(String.encodeTiddlyLink(this.title)) + "</link>"); s.push("<pubDate>" + this.modified.toGMTString() + "</pubDate>"); return s.join("\n"); }; // Format the text for storage in an RSS item Tiddler.prototype.saveToRss = function(uri) { return "<item>\n" + this.toRssItem(uri) + "\n</item>"; }; // Change the text and other attributes of a tiddler Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields) { this.assign(title,text,modifier,modified,tags,created,fields); this.changed(); return this; }; // Change the text and other attributes of a tiddler without triggered a tiddler.changed() call Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields) { 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(created != undefined) this.created = created; if(fields != undefined) this.fields = fields; if(tags != undefined) this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags; else if(this.tags == undefined) this.tags = []; return this; }; // Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces) Tiddler.prototype.getTags = function() { return String.encodeTiddlyLinkList(this.tags); }; // Test if a tiddler carries a tag Tiddler.prototype.isTagged = function(tag) { return this.tags.indexOf(tag) != -1; }; // Static method to convert "\n" to newlines, "\s" to "\" Tiddler.unescapeLineBreaks = function(text) { return text ? text.unescapeLineBreaks() : ""; }; // Convert newlines to "\n", "\" to "\s" Tiddler.prototype.escapeLineBreaks = function() { return this.text.escapeLineBreaks(); }; // Updates the secondary information (like links[] array) after a change to a tiddler Tiddler.prototype.changed = function() { this.links = []; var t = this.autoLinkWikiWords() ? 0 : 1; var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp; tiddlerLinkRegExp.lastIndex = 0; var formatMatch = tiddlerLinkRegExp.exec(this.text); while(formatMatch) { var lastIndex = tiddlerLinkRegExp.lastIndex; if(t==0 && formatMatch[1] && formatMatch[1] != this.title) { // wikiWordLink if(formatMatch.index > 0) { var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg"); preRegExp.lastIndex = formatMatch.index-1; var preMatch = preRegExp.exec(this.text); if(preMatch.index != formatMatch.index-1) this.links.pushUnique(formatMatch[1]); } else { this.links.pushUnique(formatMatch[1]); } } else if(formatMatch[2-t] && !config.formatterHelpers.isExternalLink(formatMatch[3-t])) // titledBrackettedLink this.links.pushUnique(formatMatch[3-t]); else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink this.links.pushUnique(formatMatch[4-t]); tiddlerLinkRegExp.lastIndex = lastIndex; formatMatch = tiddlerLinkRegExp.exec(this.text); } this.linksUpdated = true; }; Tiddler.prototype.getSubtitle = function() { var modifier = this.modifier; if(!modifier) modifier = config.messages.subtitleUnknown; var modified = this.modified; if(modified) modified = modified.toLocaleString(); else modified = config.messages.subtitleUnknown; return config.messages.tiddlerLinkTooltip.format([this.title,modifier,modified]); }; Tiddler.prototype.isReadOnly = function() { return readOnly; }; Tiddler.prototype.autoLinkWikiWords = function() { return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing")); }; Tiddler.prototype.generateFingerprint = function() { return "0x" + Crypto.hexSha1Str(this.text); }; Tiddler.prototype.getServerType = function() { var serverType = null; if(this.fields && this.fields['server.type']) serverType = this.fields['server.type']; if(!serverType) serverType = this.fields['wikiformat']; if(serverType && !config.adaptors[serverType]) serverType = null; return serverType; }; Tiddler.prototype.getAdaptor = function() { var serverType = this.getServerType(); return serverType ? new config.adaptors[serverType] : null; }; //-- //-- TiddlyWiki() object contains Tiddler()s //-- function TiddlyWiki() { var tiddlers = {}; // Hashmap by name of tiddlers this.tiddlersUpdated = false; this.namedNotifications = []; // Array of {name:,notify:} of notification functions this.notificationLevel = 0; this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy. this.clear = function() { tiddlers = {}; this.setDirty(false); }; this.fetchTiddler = function(title) { var t = tiddlers[title]; return t instanceof Tiddler ? t : null; }; this.deleteTiddler = function(title) { delete this.slices[title]; delete tiddlers[title]; }; this.addTiddler = function(tiddler) { delete this.slices[tiddler.title]; tiddlers[tiddler.title] = tiddler; }; this.forEachTiddler = function(callback) { for(var t in tiddlers) { var tiddler = tiddlers[t]; if(tiddler instanceof Tiddler) callback.call(this,t,tiddler); } }; } TiddlyWiki.prototype.setDirty = function(dirty) { this.dirty = dirty; }; TiddlyWiki.prototype.isDirty = function() { return this.dirty; }; TiddlyWiki.prototype.suspendNotifications = function() { this.notificationLevel--; }; TiddlyWiki.prototype.resumeNotifications = function() { this.notificationLevel++; }; // Invoke the notification handlers for a particular tiddler TiddlyWiki.prototype.notify = function(title,doBlanket) { if(!this.notificationLevel) { for(var t=0; t<this.namedNotifications.length; t++) { var n = this.namedNotifications[t]; if((n.name == null && doBlanket) || (n.name == title)) n.notify(title); } } }; // Invoke the notification handlers for all tiddlers TiddlyWiki.prototype.notifyAll = function() { if(!this.notificationLevel) { for(var t=0; t<this.namedNotifications.length; t++) { var n = this.namedNotifications[t]; if(n.name) n.notify(n.name); } } }; // Add a notification handler to a tiddler TiddlyWiki.prototype.addNotification = function(title,fn) { for(var i=0; i<this.namedNotifications.length; i++) { if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn)) return this; } this.namedNotifications.push({name: title, notify: fn}); return this; }; TiddlyWiki.prototype.removeTiddler = function(title) { var tiddler = this.fetchTiddler(title); if(tiddler) { this.deleteTiddler(title); this.notify(title,true); this.setDirty(true); } }; TiddlyWiki.prototype.tiddlerExists = function(title) { var t = this.fetchTiddler(title); return t != undefined; }; TiddlyWiki.prototype.isShadowTiddler = function(title) { return typeof config.shadowTiddlers[title] == "string"; }; TiddlyWiki.prototype.getTiddler = function(title) { var t = this.fetchTiddler(title); if(t != undefined) return t; else return null; }; TiddlyWiki.prototype.getTiddlerText = function(title,defaultText) { if(!title) return defaultText; var pos = title.indexOf(config.textPrimitives.sectionSeparator); var section = null; if(pos != -1) { section = title.substr(pos + config.textPrimitives.sectionSeparator.length); title = title.substr(0,pos); } pos = title.indexOf(config.textPrimitives.sliceSeparator); if(pos != -1) { var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length)); if(slice) return slice; } var tiddler = this.fetchTiddler(title); if(tiddler) { if(!section) return tiddler.text; var re = new RegExp("(^!{1,6}" + section.escapeRegExp() + "[ \t]*\n)","mg"); re.lastIndex = 0; var match = re.exec(tiddler.text); if(match) { var t = tiddler.text.substr(match.index+match[1].length); var re2 = /^!/mg; re2.lastIndex = 0; match = re2.exec(t); //# search for the next heading if(match) t = t.substr(0,match.index-1);//# don't include final \n return t; } return defaultText; } if(this.isShadowTiddler(title)) return config.shadowTiddlers[title]; if(defaultText != undefined) return defaultText; return null; }; TiddlyWiki.prototype.slicesRE = /(?:[\'\/]*~?([\.\w]+)[\'\/]*\:[\'\/]*\s*(.*?)\s*$)|(?:\|[\'\/]*~?([\.\w]+)\:?[\'\/]*\|\s*(.*?)\s*\|)/gm; // @internal TiddlyWiki.prototype.calcAllSlices = function(title) { var slices = {}; var text = this.getTiddlerText(title,""); this.slicesRE.lastIndex = 0; do { var m = this.slicesRE.exec(text); if(m) { if(m[1]) slices[m[1]] = m[2]; else slices[m[3]] = m[4]; } } while(m); return slices; }; // Returns the slice of text of the given name TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName) { var slices = this.slices[title]; if(!slices) { slices = this.calcAllSlices(title); this.slices[title] = slices; } return slices[sliceName]; }; // Build an hashmap of the specified named slices of a tiddler TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames) { var r = {}; for(var t=0; t<sliceNames.length; t++) { var slice = this.getTiddlerSlice(title,sliceNames[t]); if(slice) r[sliceNames[t]] = slice; } return r; }; TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth) { var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg"); var text = this.getTiddlerText(title,null); if(text == null) return defaultText; 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(depth <= 0) textOut.push(match[1]); else textOut.push(this.getRecursiveTiddlerText(match[1],"[[" + match[1] + "]]",depth-1)); } lastPos = match.index + match[0].length; } else { textOut.push(text.substr(lastPos)); } } while(match); return textOut.join(""); }; TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag) { var tiddler = this.fetchTiddler(title); if(tiddler) { var t = tiddler.tags.indexOf(tag); if(t != -1) tiddler.tags.splice(t,1); if(status) tiddler.tags.push(tag); tiddler.changed(); this.incChangeCount(title); this.notify(title,true); this.setDirty(true); } }; TiddlyWiki.prototype.addTiddlerFields = function(title,fields) { var tiddler = this.fetchTiddler(title); if(!tiddler) return; merge(tiddler.fields,fields); tiddler.changed(); this.incChangeCount(title); this.notify(title,true); this.setDirty(true); }; TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created) { var tiddler = this.fetchTiddler(title); if(tiddler) { created = created ? created : tiddler.created; // Preserve created date this.deleteTiddler(title); } else { created = created ? created : modified; tiddler = new Tiddler(); } tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields); this.addTiddler(tiddler); if(clearChangeCount) tiddler.clearChangeCount(); else tiddler.incChangeCount(); if(title != newTitle) this.notify(title,true); this.notify(newTitle,true); this.setDirty(true); return tiddler; }; // Reset the sync status of a freshly synced tiddler TiddlyWiki.prototype.resetTiddler = function(title) { var tiddler = this.fetchTiddler(title); if(tiddler) { tiddler.clearChangeCount(); this.notify(title,true); this.setDirty(true); } }; TiddlyWiki.prototype.incChangeCount = function(title) { var tiddler = this.fetchTiddler(title); if(tiddler) tiddler.incChangeCount(); }; TiddlyWiki.prototype.createTiddler = function(title) { var tiddler = this.fetchTiddler(title); if(!tiddler) { tiddler = new Tiddler(title); this.addTiddler(tiddler); this.setDirty(true); } return tiddler; }; // Load contents of a TiddlyWiki from an HTML DIV TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate) { this.idPrefix = idPrefix; var storeElem = (typeof src == "string") ? document.getElementById(src) : src; if(!storeElem) return; var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes); this.setDirty(false); if(!noUpdate) { for(var i = 0;i<tiddlers.length; i++) tiddlers[i].changed(); } }; // Load contents of a TiddlyWiki from a string // Returns null if there's an error TiddlyWiki.prototype.importTiddlyWiki = function(text) { var posDiv = locateStoreArea(text); if(!posDiv) return null; var content = "<" + "html><" + "body>" + text.substring(posDiv[0],posDiv[1] + endSaveArea.length) + "<" + "/body><" + "/html>"; // Create the iframe var iframe = document.createElement("iframe"); iframe.style.display = "none"; document.body.appendChild(iframe); var doc = iframe.document; if(iframe.contentDocument) doc = iframe.contentDocument; // For NS6 else if(iframe.contentWindow) doc = iframe.contentWindow.document; // For IE5.5 and IE6 // Put the content in the iframe doc.open(); doc.writeln(content); doc.close(); // Load the content into a TiddlyWiki() object var storeArea = doc.getElementById("storeArea"); this.loadFromDiv(storeArea,"store"); // Get rid of the iframe iframe.parentNode.removeChild(iframe); return this; }; TiddlyWiki.prototype.updateTiddlers = function() { this.tiddlersUpdated = true; this.forEachTiddler(function(title,tiddler) { tiddler.changed(); }); }; // Return all tiddlers formatted as an HTML string TiddlyWiki.prototype.allTiddlersAsHtml = function() { return store.getSaver().externalize(store); }; // Return an array of tiddlers matching a search regular expression TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag,match) { var candidates = this.reverseLookup("tags",excludeTag,!!match); var results = []; for(var t=0; t<candidates.length; t++) { if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1)) results.push(candidates[t]); } if(!sortField) sortField = "title"; results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);}); return results; }; // Returns a list of all tags in use // excludeTag - if present, excludes tags that are themselves tagged with excludeTag // Returns an array of arrays where [tag][0] is the name of the tag and [tag][1] is the number of occurances TiddlyWiki.prototype.getTags = function(excludeTag) { var results = []; this.forEachTiddler(function(title,tiddler) { for(var g=0; g<tiddler.tags.length; g++) { var tag = tiddler.tags[g]; var n = true; for(var c=0; c<results.length; c++) { if(results[c][0] == tag) { n = false; results[c][1]++; } } if(n && excludeTag) { var t = store.fetchTiddler(tag); if(t && t.isTagged(excludeTag)) n = false; } if(n) results.push([tag,1]); } }); results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +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,unusedParameter,sortField) { if(!this.tiddlersUpdated) this.updateTiddlers(); 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 = []; this.forEachTiddler(function(title,tiddler) { 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) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);}); return results; }; // Return the tiddlers as a sorted array TiddlyWiki.prototype.getTiddlers = function(field,excludeTag) { var results = []; this.forEachTiddler(function(title,tiddler) { if(excludeTag == undefined || !tiddler.isTagged(excludeTag)) results.push(tiddler); }); if(field) results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);}); return results; }; // Return array of names of tiddlers that are referred to but not defined TiddlyWiki.prototype.getMissingLinks = function(sortField) { if(!this.tiddlersUpdated) this.updateTiddlers(); var results = []; this.forEachTiddler(function (title,tiddler) { if(tiddler.isTagged("excludeMissing") || tiddler.isTagged("systemConfig")) return; for(var n=0; n<tiddler.links.length;n++) { var link = tiddler.links[n]; if(this.fetchTiddler(link) == null && !this.isShadowTiddler(link)) 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 = []; this.forEachTiddler(function (title,tiddler) { if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists")) results.push(title); }); results.sort(); return results; }; // Return an array of names of all the shadow tiddlers TiddlyWiki.prototype.getShadowed = function() { var results = []; for(var t in config.shadowTiddlers) { if(typeof config.shadowTiddlers[t] == "string") results.push(t); } results.sort(); return results; }; // Return an array of tiddlers that have been touched since they were downloaded or created TiddlyWiki.prototype.getTouched = function() { var results = []; this.forEachTiddler(function(title,tiddler) { if(tiddler.isTouched()) results.push(tiddler); }); results.sort(); return results; }; // Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist TiddlyWiki.prototype.resolveTiddler = function(tiddler) { var t = (typeof tiddler == 'string') ? this.getTiddler(tiddler) : tiddler; return t instanceof Tiddler ? t : null; }; TiddlyWiki.prototype.getLoader = function() { if(!this.loader) this.loader = new TW21Loader(); return this.loader; }; TiddlyWiki.prototype.getSaver = function() { if(!this.saver) this.saver = new TW21Saver(); return this.saver; }; // Filter a list of tiddlers TiddlyWiki.prototype.filterTiddlers = function(filter) { var results = []; if(filter) { var tiddler; var re = /([^\s\[\]]+)|(?:\[([ \w]+)\[([^\]]+)\]\])|(?:\[\[([^\]]+)\]\])/mg; var match = re.exec(filter); while(match) { if(match[1] || match[4]) { var title = match[1] ? match[1] : match[4]; tiddler = this.fetchTiddler(title); if(tiddler) { results.pushUnique(tiddler); } else if(store.isShadowTiddler(title)) { tiddler = new Tiddler(); tiddler.set(title,store.getTiddlerText(title)); results.pushUnique(tiddler); } } else if(match[2]) { switch(match[2]) { case "tag": var matched = this.getTaggedTiddlers(match[3]); for(var m = 0; m < matched.length; m++) results.pushUnique(matched[m]); break; case "sort": results = this.sortTiddlers(results,match[3]); break; } } match = re.exec(filter); } } return results; }; // Sort a list of tiddlers TiddlyWiki.prototype.sortTiddlers = function(tiddlers,field) { var asc = +1; switch(field.substr(0,1)) { case "-": asc = -1; // Note: this fall-through is intentional case "+": field = field.substr(1); break; } if(TiddlyWiki.standardFieldAccess[field]) tiddlers.sort(function(a,b) {return a[field] < b[field] ? -asc : (a[field] == b[field] ? 0 : asc);}); else tiddlers.sort(function(a,b) {return a.fields[field] < b.fields[field] ? -asc : (a.fields[field] == b.fields[field] ? 0 : +asc);}); return tiddlers; }; // Returns true if path is a valid field name (path), // i.e. a sequence of identifiers, separated by '.' TiddlyWiki.isValidFieldName = function(name) { var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name); return match && (match[0] == name); }; // Throws an exception when name is not a valid field name. TiddlyWiki.checkFieldName = function(name) { if(!TiddlyWiki.isValidFieldName(name)) throw config.messages.invalidFieldName.format([name]); }; function StringFieldAccess(n,readOnly) { this.set = readOnly ? function(t,v) {if(v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);} : function(t,v) {if(v != t[n]) {t[n] = v; return true;}}; this.get = function(t) {return t[n];}; } function DateFieldAccess(n) { this.set = function(t,v) { var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v); if(d != t[n]) { t[n] = d; return true; } }; this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();}; } function LinksFieldAccess(n) { this.set = function(t,v) { var s = (typeof v == "string") ? v.readBracketedList() : v; if(s.toString() != t[n].toString()) { t[n] = s; return true; } }; this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);}; } TiddlyWiki.standardFieldAccess = { // The set functions return true when setting the data has changed the value. "title": new StringFieldAccess("title",true), // Handle the "tiddler" field name as the title "tiddler": new StringFieldAccess("title",true), "text": new StringFieldAccess("text"), "modifier": new StringFieldAccess("modifier"), "modified": new DateFieldAccess("modified"), "created": new DateFieldAccess("created"), "tags": new LinksFieldAccess("tags") }; TiddlyWiki.isStandardField = function(name) { return TiddlyWiki.standardFieldAccess[name] != undefined; }; // Sets the value of the given field of the tiddler to the value. // Setting an ExtendedField's value to null or undefined removes the field. // Setting a namespace to undefined removes all fields of that namespace. // The fieldName is case-insensitive. // All values will be converted to a string value. TiddlyWiki.prototype.setValue = function(tiddler,fieldName,value) { TiddlyWiki.checkFieldName(fieldName); var t = this.resolveTiddler(tiddler); if(!t) return; fieldName = fieldName.toLowerCase(); var isRemove = (value === undefined) || (value === null); var accessor = TiddlyWiki.standardFieldAccess[fieldName]; if(accessor) { if(isRemove) // don't remove StandardFields return; var h = TiddlyWiki.standardFieldAccess[fieldName]; if(!h.set(t,value)) return; } else { var oldValue = t.fields[fieldName]; if(isRemove) { if(oldValue !== undefined) { // deletes a single field delete t.fields[fieldName]; } else { // no concrete value is defined for the fieldName // so we guess this is a namespace path. // delete all fields in a namespace var re = new RegExp('^'+fieldName+'\\.'); var dirty = false; for(var n in t.fields) { if(n.match(re)) { delete t.fields[n]; dirty = true; } } if(!dirty) return; } } else { // the "normal" set case. value is defined (not null/undefined) // For convenience provide a nicer conversion Date->String value = value instanceof Date ? value.convertToYYYYMMDDHHMMSSMMM() : String(value); if(oldValue == value) return; t.fields[fieldName] = value; } } // When we are here the tiddler/store really was changed. this.notify(t.title,true); if(!fieldName.match(/^temp\./)) this.setDirty(true); }; // Returns the value of the given field of the tiddler. // The fieldName is case-insensitive. // Will only return String values (or undefined). TiddlyWiki.prototype.getValue = function(tiddler,fieldName) { var t = this.resolveTiddler(tiddler); if(!t) return undefined; fieldName = fieldName.toLowerCase(); var accessor = TiddlyWiki.standardFieldAccess[fieldName]; if(accessor) { return accessor.get(t); } return t.fields[fieldName]; }; // Calls the callback function for every field in the tiddler. // When callback function returns a non-false value the iteration stops // and that value is returned. // The order of the fields is not defined. // @param callback a function(tiddler,fieldName,value). TiddlyWiki.prototype.forEachField = function(tiddler,callback,onlyExtendedFields) { var t = this.resolveTiddler(tiddler); if(!t) return undefined; var n,result; for(n in t.fields) { result = callback(t,n,t.fields[n]); if(result) return result; } if(onlyExtendedFields) return undefined; for(n in TiddlyWiki.standardFieldAccess) { if(n == "tiddler") // even though the "title" field can also be referenced through the name "tiddler" // we only visit this field once. continue; result = callback(t,n,TiddlyWiki.standardFieldAccess[n].get(t)); if(result) return result; } return undefined; }; //-- //-- Story functions //-- function Story(containerId,idPrefix) { this.container = containerId; this.idPrefix = idPrefix; this.highlightRegExp = null; this.tiddlerId = function(title) { return this.idPrefix + title; }; this.containerId = function() { return this.container; }; } Story.prototype.forEachTiddler = function(fn) { var place = this.getContainer(); if(!place) return; var e = place.firstChild; while(e) { var n = e.nextSibling; var title = e.getAttribute("tiddler"); fn.call(this,title,e); e = n; } }; Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,unused,customFields,toggle) { for(var t = titles.length-1;t>=0;t--) this.displayTiddler(srcElement,titles[t],template,animate,unused,customFields); }; Story.prototype.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle) { var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler; var tiddlerElem = this.getTiddler(title); if(tiddlerElem) { if(toggle) this.closeTiddler(title,true); else this.refreshTiddler(title,template,false,customFields); } else { var place = this.getContainer(); var before = this.positionTiddler(srcElement); tiddlerElem = this.createTiddler(place,before,title,template,customFields); } if(srcElement && typeof srcElement !== "string") { if(config.options.chkAnimate && (animate == undefined || animate == true) && anim && typeof Zoomer == "function" && typeof Scroller == "function") anim.startAnimating(new Zoomer(title,srcElement,tiddlerElem),new Scroller(tiddlerElem)); else window.scrollTo(0,ensureVisible(tiddlerElem)); } }; Story.prototype.positionTiddler = function(srcElement) { var place = this.getContainer(); var before = null; if(typeof srcElement == "string") { switch(srcElement) { case "top": before = place.firstChild; break; case "bottom": before = null; break; } } else { var after = this.findContainingTiddler(srcElement); if(after == null) { before = place.firstChild; } else if(after.nextSibling) { before = after.nextSibling; if(before.nodeType != 1) before = null; } } return before; }; Story.prototype.createTiddler = function(place,before,title,template,customFields) { var tiddlerElem = createTiddlyElement(null,"div",this.tiddlerId(title),"tiddler"); tiddlerElem.setAttribute("refresh","tiddler"); if(customFields) tiddlerElem.setAttribute("tiddlyFields",customFields); place.insertBefore(tiddlerElem,before); var defaultText = null; if(!store.tiddlerExists(title) && !store.isShadowTiddler(title)) defaultText = this.loadMissingTiddler(title,customFields,tiddlerElem); this.refreshTiddler(title,template,false,customFields,defaultText); return tiddlerElem; }; Story.prototype.loadMissingTiddler = function(title,fields,tiddlerElem) { var tiddler = new Tiddler(title); tiddler.fields = typeof fields == "string" ? fields.decodeHashMap() : (fields ? fields : {}); var serverType = tiddler.getServerType(); var host = tiddler.fields['server.host']; var workspace = tiddler.fields['server.workspace']; if(!serverType || !host) return null; var sm = new SyncMachine(serverType,{ start: function() { return this.openHost(host,"openWorkspace"); }, openWorkspace: function() { return this.openWorkspace(workspace,"getTiddler"); }, getTiddler: function() { return this.getTiddler(title,"onGetTiddler"); }, onGetTiddler: function(context) { var tiddler = context.tiddler; if(tiddler && tiddler.text) { var downloaded = new Date(); if(!tiddler.created) tiddler.created = downloaded; if(!tiddler.modified) tiddler.modified = tiddler.created; store.saveTiddler(tiddler.title,tiddler.title,tiddler.text,tiddler.modifier,tiddler.modified,tiddler.tags,tiddler.fields,true,tiddler.created); autoSaveChanges(); } delete this; return true; }, error: function(message) { displayMessage("Error loading missing tiddler from %0: %1".format([host,message])); } }); sm.go(); return config.messages.loadingMissingTiddler.format([title,serverType,host,workspace]); }; Story.prototype.chooseTemplateForTiddler = function(title,template) { if(!template) template = DEFAULT_VIEW_TEMPLATE; if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE) template = config.tiddlerTemplates[template]; return template; }; Story.prototype.getTemplateForTiddler = function(title,template,tiddler) { return store.getRecursiveTiddlerText(template,null,10); }; Story.prototype.refreshTiddler = function(title,template,force,customFields,defaultText) { var tiddlerElem = this.getTiddler(title); if(tiddlerElem) { if(tiddlerElem.getAttribute("dirty") == "true" && !force) return tiddlerElem; template = this.chooseTemplateForTiddler(title,template); var currTemplate = tiddlerElem.getAttribute("template"); if((template != currTemplate) || force) { var tiddler = store.getTiddler(title); if(!tiddler) { tiddler = new Tiddler(); if(store.isShadowTiddler(title)) { tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,[],version.date); } else { var text = template=="EditTemplate" ? config.views.editor.defaultText.format([title]) : config.views.wikified.defaultText.format([title]); text = defaultText ? defaultText : text; var fields = customFields ? customFields.decodeHashMap() : null; tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date,fields); } } tiddlerElem.setAttribute("tags",tiddler.tags.join(" ")); tiddlerElem.setAttribute("tiddler",title); tiddlerElem.setAttribute("template",template); tiddlerElem.onmouseover = this.onTiddlerMouseOver; tiddlerElem.onmouseout = this.onTiddlerMouseOut; tiddlerElem.ondblclick = this.onTiddlerDblClick; tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress; tiddlerElem.innerHTML = this.getTemplateForTiddler(title,template,tiddler); applyHtmlMacros(tiddlerElem,tiddler); if(store.getTaggedTiddlers(title).length > 0) addClass(tiddlerElem,"isTag"); else removeClass(tiddlerElem,"isTag"); if(store.tiddlerExists(title)) { removeClass(tiddlerElem,"shadow"); removeClass(tiddlerElem,"missing"); } else { addClass(tiddlerElem,store.isShadowTiddler(title) ? "shadow" : "missing"); } if(customFields) this.addCustomFields(tiddlerElem,customFields); forceReflow(); } } return tiddlerElem; }; Story.prototype.addCustomFields = function(place,customFields) { var fields = customFields.decodeHashMap(); var w = document.createElement("div"); w.style.display = "none"; place.appendChild(w); for(var t in fields) { var e = document.createElement("input"); e.setAttribute("type","text"); e.setAttribute("value",fields[t]); w.appendChild(e); e.setAttribute("edit",t); } }; Story.prototype.refreshAllTiddlers = function(force) { var place = this.getContainer(); var e = place.firstChild; if(!e) return; this.refreshTiddler(e.getAttribute("tiddler"),force ? null : e.getAttribute("template"),true); while((e = e.nextSibling) != null) this.refreshTiddler(e.getAttribute("tiddler"),force ? null : e.getAttribute("template"),true); }; Story.prototype.onTiddlerMouseOver = function(e) { if(window.addClass instanceof Function) addClass(this,"selected"); }; Story.prototype.onTiddlerMouseOut = function(e) { if(window.removeClass instanceof Function) removeClass(this,"selected"); }; Story.prototype.onTiddlerDblClick = function(ev) { var e = ev ? ev : window.event; var theTarget = resolveTarget(e); if(theTarget && theTarget.nodeName.toLowerCase() != "input" && theTarget.nodeName.toLowerCase() != "textarea") { if(document.selection && document.selection.empty) document.selection.empty(); config.macros.toolbar.invokeCommand(this,"defaultCommand",e); e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); return true; } else { return false; } }; Story.prototype.onTiddlerKeyPress = function(ev) { var e = ev ? ev : window.event; clearMessage(); var consume = false; var title = this.getAttribute("tiddler"); var target = resolveTarget(e); switch(e.keyCode) { case 9: // Tab if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea") { replaceSelection(target,String.fromCharCode(9)); consume = true; } if(config.isOpera) { target.onblur = function() { this.focus(); this.onblur = null; }; } break; case 13: // Ctrl-Enter case 10: // Ctrl-Enter on IE PC case 77: // Ctrl-Enter is "M" on some platforms if(e.ctrlKey) { blurElement(this); config.macros.toolbar.invokeCommand(this,"defaultCommand",e); consume = true; } break; case 27: // Escape blurElement(this); config.macros.toolbar.invokeCommand(this,"cancelCommand",e); consume = true; break; } e.cancelBubble = consume; if(consume) { if(e.stopPropagation) e.stopPropagation(); // Stop Propagation e.returnValue = true; // Cancel The Event in IE if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz } return !consume; }; Story.prototype.getTiddlerField = function(title,field) { var tiddlerElem = this.getTiddler(title); var e = null; if(tiddlerElem != null) { var children = tiddlerElem.getElementsByTagName("*"); for(var t=0; t<children.length; t++) { var c = children[t]; if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") { if(!e) e = c; if(c.getAttribute("edit") == field) e = c; } } } return e; }; Story.prototype.focusTiddler = function(title,field) { var e = this.getTiddlerField(title,field); if(e) { e.focus(); e.select(); } }; Story.prototype.blurTiddler = function(title) { var tiddlerElem = this.getTiddler(title); if(tiddlerElem != null && tiddlerElem.focus && tiddlerElem.blur) { tiddlerElem.focus(); tiddlerElem.blur(); } }; Story.prototype.setTiddlerField = function(title,tag,mode,field) { var c = story.getTiddlerField(title,field); var tags = c.value.readBracketedList(); tags.setItem(tag,mode); c.value = String.encodeTiddlyLinkList(tags); }; Story.prototype.setTiddlerTag = function(title,tag,mode) { Story.prototype.setTiddlerField(title,tag,mode,"tags"); }; Story.prototype.closeTiddler = function(title,animate,unused) { var tiddlerElem = this.getTiddler(title); if(tiddlerElem != null) { clearMessage(); this.scrubTiddler(tiddlerElem); if(config.options.chkAnimate && animate && anim && typeof Slider == "function") anim.startAnimating(new Slider(tiddlerElem,false,null,"all")); else { removeNode(tiddlerElem); forceReflow(); } } }; Story.prototype.scrubTiddler = function(tiddlerElem) { tiddlerElem.id = null; }; Story.prototype.setDirty = function(title,dirty) { var tiddlerElem = this.getTiddler(title); if(tiddlerElem != null) tiddlerElem.setAttribute("dirty",dirty ? "true" : "false"); }; Story.prototype.isDirty = function(title) { var tiddlerElem = this.getTiddler(title); if(tiddlerElem != null) return tiddlerElem.getAttribute("dirty") == "true"; return null; }; Story.prototype.areAnyDirty = function() { var r = false; this.forEachTiddler(function(title,element) { if(this.isDirty(title)) r = true; }); return r; }; Story.prototype.closeAllTiddlers = function(exclude) { clearMessage(); this.forEachTiddler(function(title,element) { if((title != exclude) && element.getAttribute("dirty") != "true") this.closeTiddler(title); }); window.scrollTo(0,ensureVisible(this.container)); }; Story.prototype.isEmpty = function() { var place = this.getContainer(); return place && place.firstChild == null; }; Story.prototype.search = function(text,useCaseSensitive,useRegExp) { this.closeAllTiddlers(); highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img"); var matches = store.search(highlightHack,"title","excludeSearch"); this.displayTiddlers(null,matches); highlightHack = null; var q = useRegExp ? "/" : "'"; if(matches.length > 0) displayMessage(config.macros.search.successMsg.format([matches.length.toString(),q + text + q])); else displayMessage(config.macros.search.failureMsg.format([q + text + q])); }; Story.prototype.findContainingTiddler = function(e) { while(e && !hasClass(e,"tiddler")) e = e.parentNode; return e; }; Story.prototype.gatherSaveFields = function(e,fields) { if(e && e.getAttribute) { var f = e.getAttribute("edit"); if(f) fields[f] = e.value.replace(/\r/mg,""); if(e.hasChildNodes()) { var c = e.childNodes; for(var t=0; t<c.length; t++) this.gatherSaveFields(c[t],fields); } } }; Story.prototype.hasChanges = function(title) { var e = this.getTiddler(title); if(e != null) { var fields = {}; this.gatherSaveFields(e,fields); var tiddler = store.fetchTiddler(title); if(!tiddler) return false; for(var n in fields) { if(store.getValue(title,n) != fields[n]) return true; } } return false; }; Story.prototype.saveTiddler = function(title,minorUpdate) { var tiddlerElem = this.getTiddler(title); if(tiddlerElem != null) { var fields = {}; this.gatherSaveFields(tiddlerElem,fields); var newTitle = fields.title ? fields.title : title; if(!store.tiddlerExists(newTitle)) newTitle = newTitle.trim(); if(store.tiddlerExists(newTitle) && newTitle != title) { if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()]))) return null; } if(newTitle != title) this.closeTiddler(newTitle,false); tiddlerElem.id = this.tiddlerId(newTitle); tiddlerElem.setAttribute("tiddler",newTitle); tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE); tiddlerElem.setAttribute("dirty","false"); if(config.options.chkForceMinorUpdate) minorUpdate = !minorUpdate; if(!store.tiddlerExists(newTitle)) minorUpdate = false; var newDate = new Date(); var extendedFields = store.tiddlerExists(newTitle) ? store.fetchTiddler(newTitle).fields : (newTitle!=title && store.tiddlerExists(title) ? store.fetchTiddler(title).fields : {}); for(var n in fields) { if(!TiddlyWiki.isStandardField(n)) extendedFields[n] = fields[n]; } var tiddler = store.saveTiddler(title,newTitle,fields.text,minorUpdate ? undefined : config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags,extendedFields); autoSaveChanges(null,[tiddler]); return newTitle; } return null; }; Story.prototype.permaView = function() { var links = []; this.forEachTiddler(function(title,element) { links.push(String.encodeTiddlyLink(title)); }); var t = encodeURIComponent(links.join(" ")); if(t == "") t = "#"; if(window.location.hash != t) window.location.hash = t; }; Story.prototype.switchTheme = function(theme) { if(safeMode) return; isAvailable = function(title) { var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1; if(s!=-1) title = title.substr(0,s); return store.tiddlerExists(title) || store.isShadowTiddler(title); }; getSlice = function(theme,slice) { var r; if(readOnly) r = store.getTiddlerSlice(theme,slice+"ReadOnly") || store.getTiddlerSlice(theme,"Web"+slice); r = r || store.getTiddlerSlice(theme,slice); if(r && r.indexOf(config.textPrimitives.sectionSeparator)==0) r = theme + r; return isAvailable(r) ? r : slice; }; replaceNotification = function(i,name,theme,slice) { var newName = getSlice(theme,slice); if(name!=newName && store.namedNotifications[i].name==name) { store.namedNotifications[i].name = newName; return newName; } return name; }; var pt = config.refresherData.pageTemplate; var vi = DEFAULT_VIEW_TEMPLATE; var vt = config.tiddlerTemplates[vi]; var ei = DEFAULT_EDIT_TEMPLATE; var et = config.tiddlerTemplates[ei]; for(var i=0; i<config.notifyTiddlers.length; i++) { var name = config.notifyTiddlers[i].name; switch(name) { case "PageTemplate": config.refresherData.pageTemplate = replaceNotification(i,config.refresherData.pageTemplate,theme,name); break; case "StyleSheet": removeStyleSheet(config.refresherData.styleSheet); config.refresherData.styleSheet = replaceNotification(i,config.refresherData.styleSheet,theme,name); break; case "ColorPalette": config.refresherData.colorPalette = replaceNotification(i,config.refresherData.colorPalette,theme,name); break; default: break; } } config.tiddlerTemplates[vi] = getSlice(theme,"ViewTemplate"); config.tiddlerTemplates[ei] = getSlice(theme,"EditTemplate"); if(!startingUp) { if(config.refresherData.pageTemplate!=pt || config.tiddlerTemplates[vi]!=vt || config.tiddlerTemplates[ei]!=et) { refreshAll(); story.refreshAllTiddlers(true); } else { setStylesheet(store.getRecursiveTiddlerText(config.refresherData.styleSheet,"",10),config.refreshers.styleSheet); } config.options.txtTheme = theme; saveOptionCookie("txtTheme"); } }; Story.prototype.getTiddler = function(title) { return document.getElementById(this.tiddlerId(title)); }; Story.prototype.getContainer = function() { return document.getElementById(this.containerId()); }; //-- //-- Backstage //-- var backstage = { area: null, toolbar: null, button: null, showButton: null, hideButton: null, cloak: null, panel: null, panelBody: null, panelFooter: null, currTabName: null, currTabElem: null, content: null, init: function() { var cmb = config.messages.backstage; this.area = document.getElementById("backstageArea"); this.toolbar = document.getElementById("backstageToolbar"); this.button = document.getElementById("backstageButton"); this.button.style.display = "block"; var t = cmb.open.text + " " + glyph("bentArrowLeft"); this.showButton = createTiddlyButton(this.button,t,cmb.open.tooltip, function (e) {backstage.show(); return false;},null,"backstageShow"); t = glyph("bentArrowRight") + " " + cmb.close.text; this.hideButton = createTiddlyButton(this.button,t,cmb.close.tooltip, function (e) {backstage.hide(); return false;},null,"backstageHide"); this.cloak = document.getElementById("backstageCloak"); this.panel = document.getElementById("backstagePanel"); this.panelFooter = createTiddlyElement(this.panel,"div",null,"backstagePanelFooter"); this.panelBody = createTiddlyElement(this.panel,"div",null,"backstagePanelBody"); this.cloak.onmousedown = function(e) { backstage.switchTab(null); }; createTiddlyText(this.toolbar,cmb.prompt); for(t=0; t<config.backstageTasks.length; t++) { var taskName = config.backstageTasks[t]; var task = config.tasks[taskName]; var handler = task.action ? this.onClickCommand : this.onClickTab; var text = task.text + (task.action ? "" : glyph("downTriangle")); var btn = createTiddlyButton(this.toolbar,text,task.tooltip,handler,"backstageTab"); btn.setAttribute("task",taskName); addClass(btn,task.action ? "backstageAction" : "backstageTask"); } this.content = document.getElementById("contentWrapper"); if(config.options.chkBackstage) this.show(); else this.hide(); }, isVisible: function() { return this.area ? this.area.style.display == "block" : false; }, show: function() { this.area.style.display = "block"; if(anim && config.options.chkAnimate) { backstage.toolbar.style.left = findWindowWidth() + "px"; var p = [ {style: "left", start: findWindowWidth(), end: 0, template: "%0px"} ]; anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p)); } else { backstage.area.style.left = "0px"; } this.showButton.style.display = "none"; this.hideButton.style.display = "block"; config.options.chkBackstage = true; saveOptionCookie("chkBackstage"); addClass(this.content,"backstageVisible"); }, hide: function() { if(this.currTabElem) { this.switchTab(null); } else { backstage.toolbar.style.left = "0px"; if(anim && config.options.chkAnimate) { var p = [ {style: "left", start: 0, end: findWindowWidth(), template: "%0px"} ]; var c = function(element,properties) {backstage.area.style.display = "none";}; anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p,c)); } else { this.area.style.display = "none"; } this.showButton.style.display = "block"; this.hideButton.style.display = "none"; config.options.chkBackstage = false; saveOptionCookie("chkBackstage"); removeClass(this.content,"backstageVisible"); } }, onClickCommand: function(e) { var task = config.tasks[this.getAttribute("task")]; displayMessage(task); if(task.action) { backstage.switchTab(null); task.action(); } return false; }, onClickTab: function(e) { backstage.switchTab(this.getAttribute("task")); return false; }, // Switch to a given tab, or none if null is passed switchTab: function(tabName) { var tabElem = null; var e = this.toolbar.firstChild; while(e) { if(e.getAttribute && e.getAttribute("task") == tabName) tabElem = e; e = e.nextSibling; } if(tabName == backstage.currTabName) return; if(backstage.currTabElem) { removeClass(this.currTabElem,"backstageSelTab"); } if(tabElem && tabName) { backstage.preparePanel(); addClass(tabElem,"backstageSelTab"); var task = config.tasks[tabName]; wikify(task.content,backstage.panelBody,null,null); backstage.showPanel(); } else if(backstage.currTabElem) { backstage.hidePanel(); } backstage.currTabName = tabName; backstage.currTabElem = tabElem; }, isPanelVisible: function() { return backstage.panel ? backstage.panel.style.display == "block" : false; }, preparePanel: function() { backstage.cloak.style.height = findWindowHeight() + "px"; backstage.cloak.style.display = "block"; removeChildren(backstage.panelBody); return backstage.panelBody; }, showPanel: function() { backstage.panel.style.display = "block"; if(anim && config.options.chkAnimate) { backstage.panel.style.top = (-backstage.panel.offsetHeight) + "px"; var p = [ {style: "top", start: -backstage.panel.offsetHeight, end: 0, template: "%0px"} ]; anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p),new Scroller(backstage.panel,false)); } else { backstage.panel.style.top = "0px"; } return backstage.panelBody; }, hidePanel: function() { backstage.currTabName = null; backstage.currTabElem = null; if(anim && config.options.chkAnimate) { var p = [ {style: "top", start: 0, end: -(backstage.panel.offsetHeight), template: "%0px"}, {style: "display", atEnd: "none"} ]; var c = function(element,properties) {backstage.cloak.style.display = "none";}; anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p,c)); } else { backstage.panel.style.display = "none"; backstage.cloak.style.display = "none"; } } }; config.macros.backstage = {}; config.macros.backstage.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var backstageTask = config.tasks[params[0]]; if(backstageTask) createTiddlyButton(place,backstageTask.text,backstageTask.tooltip,function(e) {backstage.switchTab(params[0]); return false;}); }; //-- //-- ImportTiddlers macro //-- config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler) { if(readOnly) { createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning); return; } var w = new Wizard(); w.createWizard(place,this.wizardTitle); this.restart(w); }; config.macros.importTiddlers.onCancel = function(e) { var wizard = new Wizard(this); var place = wizard.clear(); config.macros.importTiddlers.restart(wizard); return false; }; config.macros.importTiddlers.onClose = function(e) { backstage.hidePanel(); return false; }; config.macros.importTiddlers.restart = function(wizard) { wizard.addStep(this.step1Title,this.step1Html); var s = wizard.getElement("selTypes"); for(var t in config.adaptors) { var e = createTiddlyElement(s,"option",null,null,config.adaptors[t].serverLabel ? config.adaptors[t].serverLabel : t); e.value = t; } if(config.defaultAdaptor) s.value = config.defaultAdaptor; s = wizard.getElement("selFeeds"); var feeds = this.getFeeds(); for(t in feeds) { e = createTiddlyElement(s,"option",null,null,t); e.value = t; } wizard.setValue("feeds",feeds); s.onchange = config.macros.importTiddlers.onFeedChange; var fileInput = wizard.getElement("txtBrowse"); fileInput.onchange = config.macros.importTiddlers.onBrowseChange; fileInput.onkeyup = config.macros.importTiddlers.onBrowseChange; wizard.setButtons([{caption: this.openLabel, tooltip: this.openPrompt, onClick: config.macros.importTiddlers.onOpen}]); }; config.macros.importTiddlers.getFeeds = function() { var feeds = {}; var tagged = store.getTaggedTiddlers("systemServer","title"); for(var t=0; t<tagged.length; t++) { var title = tagged[t].title; var serverType = store.getTiddlerSlice(title,"Type"); if(!serverType) serverType = "file"; feeds[title] = {title: title, url: store.getTiddlerSlice(title,"URL"), workspace: store.getTiddlerSlice(title,"Workspace"), workspaceList: store.getTiddlerSlice(title,"WorkspaceList"), tiddlerFilter: store.getTiddlerSlice(title,"TiddlerFilter"), serverType: serverType, description: store.getTiddlerSlice(title,"Description")}; } return feeds; }; config.macros.importTiddlers.onFeedChange = function(e) { var wizard = new Wizard(this); var selTypes = wizard.getElement("selTypes"); var fileInput = wizard.getElement("txtPath"); var feeds = wizard.getValue("feeds"); var f = feeds[this.value]; if(f) { selTypes.value = f.serverType; fileInput.value = f.url; wizard.setValue("feedName",f.serverType); wizard.setValue("feedHost",f.url); wizard.setValue("feedWorkspace",f.workspace); wizard.setValue("feedWorkspaceList",f.workspaceList); wizard.setValue("feedTiddlerFilter",f.tiddlerFilter); } return false; }; config.macros.importTiddlers.onBrowseChange = function(e) { var wizard = new Wizard(this); var fileInput = wizard.getElement("txtPath"); fileInput.value = "file://" + this.value; var serverType = wizard.getElement("selTypes"); serverType.value = "file"; return false; }; config.macros.importTiddlers.onOpen = function(e) { var wizard = new Wizard(this); var fileInput = wizard.getElement("txtPath"); var url = fileInput.value; var serverType = wizard.getElement("selTypes").value || config.defaultAdaptor; var adaptor = new config.adaptors[serverType]; wizard.setValue("adaptor",adaptor); wizard.setValue("serverType",serverType); wizard.setValue("host",url); var ret = adaptor.openHost(url,null,wizard,config.macros.importTiddlers.onOpenHost); if(ret !== true) displayMessage(ret); wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenHost); return false; }; config.macros.importTiddlers.onOpenHost = function(context,wizard) { var adaptor = wizard.getValue("adaptor"); if(context.status !== true) displayMessage("Error in importTiddlers.onOpenHost: " + context.statusText); var ret = adaptor.getWorkspaceList(context,wizard,config.macros.importTiddlers.onGetWorkspaceList); if(ret !== true) displayMessage(ret); wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetWorkspaceList); }; config.macros.importTiddlers.onGetWorkspaceList = function(context,wizard) { if(context.status !== true) displayMessage("Error in importTiddlers.onGetWorkspaceList: " + context.statusText); wizard.setValue("context",context); var workspace = wizard.getValue("feedWorkspace"); if(!workspace && context.workspaces.length==1) workspace = context.workspaces[0].title; if(workspace) { var ret = context.adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace); if(ret !== true) displayMessage(ret); wizard.setValue("workspace",workspace); wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace); return; } wizard.addStep(config.macros.importTiddlers.step2Title,config.macros.importTiddlers.step2Html); var s = wizard.getElement("selWorkspace"); s.onchange = config.macros.importTiddlers.onWorkspaceChange; for(var t=0; t<context.workspaces.length; t++) { var e = createTiddlyElement(s,"option",null,null,context.workspaces[t].title); e.value = context.workspaces[t].title; } var workspaceList = wizard.getValue("feedWorkspaceList"); if(workspaceList) { var list = workspaceList.parseParams("workspace",null,false,true); for(var n=1; n<list.length; n++) { if(context.workspaces.findByField("title",list[n].value) == null) { e = createTiddlyElement(s,"option",null,null,list[n].value); e.value = list[n].value; } } } if(workspace) { t = wizard.getElement("txtWorkspace"); t.value = workspace; } wizard.setButtons([{caption: config.macros.importTiddlers.openLabel, tooltip: config.macros.importTiddlers.openPrompt, onClick: config.macros.importTiddlers.onChooseWorkspace}]); }; config.macros.importTiddlers.onWorkspaceChange = function(e) { var wizard = new Wizard(this); var t = wizard.getElement("txtWorkspace"); t.value = this.value; this.selectedIndex = 0; return false; }; config.macros.importTiddlers.onChooseWorkspace = function(e) { var wizard = new Wizard(this); var adaptor = wizard.getValue("adaptor"); var workspace = wizard.getElement("txtWorkspace").value; wizard.setValue("workspace",workspace); var context = wizard.getValue("context"); var ret = adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace); if(ret !== true) displayMessage(ret); wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace); return false; }; config.macros.importTiddlers.onOpenWorkspace = function(context,wizard) { if(context.status !== true) displayMessage("Error in importTiddlers.onOpenWorkspace: " + context.statusText); var adaptor = wizard.getValue("adaptor"); var ret = adaptor.getTiddlerList(context,wizard,config.macros.importTiddlers.onGetTiddlerList,wizard.getValue("feedTiddlerFilter")); if(ret !== true) displayMessage(ret); wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetTiddlerList); }; config.macros.importTiddlers.onGetTiddlerList = function(context,wizard) { if(context.status !== true) { wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.errorGettingTiddlerList); return; } // Extract data for the listview var listedTiddlers = []; if(context.tiddlers) { for(var n=0; n<context.tiddlers.length; n++) { var tiddler = context.tiddlers[n]; listedTiddlers.push({ title: tiddler.title, modified: tiddler.modified, modifier: tiddler.modifier, text: tiddler.text ? wikifyPlainText(tiddler.text,100) : "", tags: tiddler.tags, size: tiddler.text ? tiddler.text.length : 0, tiddler: tiddler }); } } listedTiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);}); // Display the listview wizard.addStep(config.macros.importTiddlers.step3Title,config.macros.importTiddlers.step3Html); var markList = wizard.getElement("markList"); var listWrapper = document.createElement("div"); markList.parentNode.insertBefore(listWrapper,markList); var listView = ListView.create(listWrapper,listedTiddlers,config.macros.importTiddlers.listViewTemplate); wizard.setValue("listView",listView); var txtSaveTiddler = wizard.getElement("txtSaveTiddler"); txtSaveTiddler.value = config.macros.importTiddlers.generateSystemServerName(wizard); wizard.setButtons([ {caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}, {caption: config.macros.importTiddlers.importLabel, tooltip: config.macros.importTiddlers.importPrompt, onClick: config.macros.importTiddlers.doImport} ]); }; config.macros.importTiddlers.generateSystemServerName = function(wizard) { var serverType = wizard.getValue("serverType"); var host = wizard.getValue("host"); var workspace = wizard.getValue("workspace"); var pattern = config.macros.importTiddlers[workspace ? "systemServerNamePattern" : "systemServerNamePatternNoWorkspace"]; return pattern.format([serverType,host,workspace]); }; config.macros.importTiddlers.saveServerTiddler = function(wizard) { var txtSaveTiddler = wizard.getElement("txtSaveTiddler").value; if(store.tiddlerExists(txtSaveTiddler)) { if(!confirm(config.macros.importTiddlers.confirmOverwriteSaveTiddler.format([txtSaveTiddler]))) return; store.suspendNotifications(); store.removeTiddler(txtSaveTiddler); store.resumeNotifications(); } var serverType = wizard.getValue("serverType"); var host = wizard.getValue("host"); var workspace = wizard.getValue("workspace"); var text = config.macros.importTiddlers.serverSaveTemplate.format([serverType,host,workspace]); store.saveTiddler(txtSaveTiddler,txtSaveTiddler,text,config.macros.importTiddlers.serverSaveModifier,new Date(),["systemServer"]); }; config.macros.importTiddlers.doImport = function(e) { var wizard = new Wizard(this); if(wizard.getElement("chkSave").checked) config.macros.importTiddlers.saveServerTiddler(wizard); var chkSync = wizard.getElement("chkSync").checked; wizard.setValue("sync",chkSync); var listView = wizard.getValue("listView"); var rowNames = ListView.getSelectedRows(listView); var adaptor = wizard.getValue("adaptor"); var overwrite = new Array(); var t; for(t=0; t<rowNames.length; t++) { if(store.tiddlerExists(rowNames[t])) overwrite.push(rowNames[t]); } if(overwrite.length > 0) { if(!confirm(config.macros.importTiddlers.confirmOverwriteText.format([overwrite.join(", ")]))) return false; } wizard.addStep(config.macros.importTiddlers.step4Title.format([rowNames.length]),config.macros.importTiddlers.step4Html); for(t=0; t<rowNames.length; t++) { var link = document.createElement("div"); createTiddlyLink(link,rowNames[t],true); var place = wizard.getElement("markReport"); place.parentNode.insertBefore(link,place); } wizard.setValue("remainingImports",rowNames.length); wizard.setButtons([ {caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel} ],config.macros.importTiddlers.statusDoingImport); for(t=0; t<rowNames.length; t++) { var context = {}; context.allowSynchronous = true; var inbound = adaptor.getTiddler(rowNames[t],context,wizard,config.macros.importTiddlers.onGetTiddler); } return false; }; config.macros.importTiddlers.onGetTiddler = function(context,wizard) { if(!context.status) displayMessage("Error in importTiddlers.onGetTiddler: " + context.statusText); var tiddler = context.tiddler; store.suspendNotifications(); store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created); if(!wizard.getValue("sync")) { store.setValue(tiddler.title,'server',null); } store.resumeNotifications(); if(!context.isSynchronous) store.notify(tiddler.title,true); var remainingImports = wizard.getValue("remainingImports")-1; wizard.setValue("remainingImports",remainingImports); if(remainingImports == 0) { if(context.isSynchronous) { store.notifyAll(); refreshDisplay(); } wizard.setButtons([ {caption: config.macros.importTiddlers.doneLabel, tooltip: config.macros.importTiddlers.donePrompt, onClick: config.macros.importTiddlers.onClose} ],config.macros.importTiddlers.statusDoneImport); autoSaveChanges(); } }; //-- //-- Upgrade macro //-- config.macros.upgrade.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var w = new Wizard(); w.createWizard(place,this.wizardTitle); w.addStep(this.step1Title,this.step1Html.format([this.source,this.source])); w.setButtons([{caption: this.upgradeLabel, tooltip: this.upgradePrompt, onClick: this.onClickUpgrade}]); }; config.macros.upgrade.onClickUpgrade = function(e) { var me = config.macros.upgrade; var w = new Wizard(this); if(window.location.protocol != "file:") { alert(me.errorCantUpgrade); return false; } if(story.areAnyDirty() || store.isDirty()) { alert(me.errorNotSaved); return false; } var localPath = getLocalPath(document.location.toString()); var backupPath = getBackupPath(localPath,me.backupExtension); w.setValue("backupPath",backupPath); w.setButtons([],me.statusPreparingBackup); var original = loadOriginal(localPath); w.setButtons([],me.statusSavingBackup); var backup = config.browser.isIE ? ieCopyFile(backupPath,localPath) : saveFile(backupPath,original); if(backup != true) { w.setButtons([],me.errorSavingBackup); alert(me.errorSavingBackup); return false; } w.setButtons([],me.statusLoadingCore); var load = loadRemoteFile(me.source,me.onLoadCore,w); if(typeof load == "string") { w.setButtons([],me.errorLoadingCore); alert(me.errorLoadingCore); return false; } return false; }; config.macros.upgrade.onLoadCore = function(status,params,responseText,url,xhr) { var me = config.macros.upgrade; var w = params; var errMsg; if(!status) errMsg = me.errorLoadingCore; var newVer = me.extractVersion(responseText); if(!newVer) errMsg = me.errorCoreFormat; if(errMsg) { w.setButtons([],errMsg); alert(errMsg); return; } var onStartUpgrade = function(e) { w.setButtons([],me.statusSavingCore); var localPath = getLocalPath(document.location.toString()); saveFile(localPath,responseText); w.setButtons([],me.statusReloadingCore); var backupPath = w.getValue("backupPath"); var newLoc = document.location.toString() + '?time=' + new Date().convertToYYYYMMDDHHMM() + '#upgrade:[[' + encodeURI(backupPath) + ']]'; window.setTimeout(function () {window.location = newLoc;},10) }; var step2 = [me.step2Html_downgrade,me.step2Html_restore,me.step2Html_upgrade][compareVersions(version,newVer) + 1]; w.addStep(me.step2Title,step2.format([formatVersion(newVer),formatVersion(version)])); w.setButtons([{caption: me.startLabel, tooltip: me.startPrompt, onClick: onStartUpgrade},{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}]); }; config.macros.upgrade.onCancel = function(e) { var me = config.macros.upgrade; var w = new Wizard(this); w.addStep(me.step3Title,me.step3Html); w.setButtons([]); return false; } config.macros.upgrade.extractVersion = function(upgradeFile) { var re = /^var version = \{title: "([^"]+)", major: (\d+), minor: (\d+), revision: (\d+)(, beta: (\d+)){0,1}, date: new Date\("([^"]+)"\)/mg; var m = re.exec(upgradeFile); return m ? {title: m[1], major: m[2], minor: m[3], revision: m[4], beta: m[6], date: new Date(m[7])} : null; }; function upgradeFrom(path) { var importStore = new TiddlyWiki(); var tw = loadFile(path); if(window.netscape !== undefined) tw = convertUTF8ToUnicode(tw); importStore.importTiddlyWiki(tw); importStore.forEachTiddler(function(title,tiddler) { if(!store.getTiddler(title)) { store.addTiddler(tiddler); } }); refreshDisplay(); saveChanges(); //# To create appropriate Markup* sections alert(config.messages.upgradeDone.format([formatVersion()])); window.location = window.location.toString().substr(0,window.location.toString().lastIndexOf('?')); } //-- //-- Sync macro //-- // Synchronisation handlers config.syncers = {}; // Sync state. var currSync = null; // sync macro config.macros.sync.handler = function(place,macroName,params,wikifier,paramString,tiddler) { if(!wikifier.isStatic) this.startSync(place); }; config.macros.sync.startSync = function(place) { if(currSync) config.macros.sync.cancelSync(); currSync = {}; currSync.syncList = this.getSyncableTiddlers(); this.createSyncTasks(); this.preProcessSyncableTiddlers(); var wizard = new Wizard(); currSync.wizard = wizard; wizard.createWizard(place,this.wizardTitle); wizard.addStep(this.step1Title,this.step1Html); var markList = wizard.getElement("markList"); var listWrapper = document.createElement("div"); markList.parentNode.insertBefore(listWrapper,markList); currSync.listView = ListView.create(listWrapper,currSync.syncList,this.listViewTemplate); this.processSyncableTiddlers(); wizard.setButtons([ {caption: this.syncLabel, tooltip: this.syncPrompt, onClick: this.doSync} ]); }; config.macros.sync.getSyncableTiddlers = function() { var list = []; store.forEachTiddler(function(title,tiddler) { var syncItem = {}; syncItem.serverType = tiddler.getServerType(); syncItem.serverHost = tiddler.fields['server.host']; syncItem.serverWorkspace = tiddler.fields['server.workspace']; syncItem.tiddler = tiddler; syncItem.title = tiddler.title; syncItem.isTouched = tiddler.isTouched(); syncItem.selected = syncItem.isTouched; syncItem.syncStatus = config.macros.sync.syncStatusList[syncItem.isTouched ? "changedLocally" : "none"]; syncItem.status = syncItem.syncStatus.text; if(syncItem.serverType && syncItem.serverHost) list.push(syncItem); }); list.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);}); return list; }; config.macros.sync.preProcessSyncableTiddlers = function() { for(var t=0; t<currSync.syncList.length; t++) { si = currSync.syncList[t]; var ti = si.syncTask.syncMachine.generateTiddlerInfo(si.tiddler); si.serverUrl = ti.uri; } }; config.macros.sync.processSyncableTiddlers = function() { for(var t=0; t<currSync.syncList.length; t++) { si = currSync.syncList[t]; si.rowElement.style.backgroundColor = si.syncStatus.color; } }; config.macros.sync.createSyncTasks = function() { currSync.syncTasks = []; for(var t=0; t<currSync.syncList.length; t++) { var si = currSync.syncList[t]; var r = null; for(var st=0; st<currSync.syncTasks.length; st++) { var cst = currSync.syncTasks[st]; if(si.serverType == cst.serverType && si.serverHost == cst.serverHost && si.serverWorkspace == cst.serverWorkspace) r = cst; } if(r == null) { si.syncTask = this.createSyncTask(si); currSync.syncTasks.push(si.syncTask); } else { si.syncTask = r; r.syncItems.push(si); } } }; config.macros.sync.createSyncTask = function(syncItem) { var st = {}; st.serverType = syncItem.serverType; st.serverHost = syncItem.serverHost; st.serverWorkspace = syncItem.serverWorkspace; st.syncItems = [syncItem]; st.syncMachine = new SyncMachine(st.serverType,{ start: function() { return this.openHost(st.serverHost,"openWorkspace"); }, openWorkspace: function() { return this.openWorkspace(st.serverWorkspace,"getTiddlerList"); }, getTiddlerList: function() { return this.getTiddlerList("onGetTiddlerList"); }, onGetTiddlerList: function(context) { var tiddlers = context.tiddlers; for(var t=0; t<st.syncItems.length; t++) { var si = st.syncItems[t]; var f = tiddlers.findByField("title",si.title); if(f !== null) { if(tiddlers[f].fields['server.page.revision'] > si.tiddler.fields['server.page.revision']) { si.syncStatus = config.macros.sync.syncStatusList[si.isTouched ? 'changedBoth' : 'changedServer']; } } else { si.syncStatus = config.macros.sync.syncStatusList.notFound; } config.macros.sync.updateSyncStatus(si); } }, getTiddler: function(title) { return this.getTiddler(title,"onGetTiddler"); }, onGetTiddler: function(context) { var tiddler = context.tiddler; var syncItem = st.syncItems.findByField("title",tiddler.title); if(syncItem !== null) { syncItem = st.syncItems[syncItem]; store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created); syncItem.syncStatus = config.macros.sync.syncStatusList.gotFromServer; config.macros.sync.updateSyncStatus(syncItem); } }, putTiddler: function(tiddler) { return this.putTiddler(tiddler,"onPutTiddler"); }, onPutTiddler: function(context) { var title = context.title; var syncItem = st.syncItems.findByField("title",title); if(syncItem !== null) { syncItem = st.syncItems[syncItem]; store.resetTiddler(title); syncItem.syncStatus = config.macros.sync.syncStatusList.putToServer; config.macros.sync.updateSyncStatus(syncItem); } } }); st.syncMachine.go(); return st; }; config.macros.sync.updateSyncStatus = function(syncItem) { var e = syncItem.colElements["status"]; removeChildren(e); createTiddlyText(e,syncItem.syncStatus.text); syncItem.rowElement.style.backgroundColor = syncItem.syncStatus.color; }; config.macros.sync.doSync = function(e) { var rowNames = ListView.getSelectedRows(currSync.listView); for(var t=0; t<currSync.syncList.length; t++) { var si = currSync.syncList[t]; if(rowNames.indexOf(si.title) != -1) { config.macros.sync.doSyncItem(si); } } return false; }; config.macros.sync.doSyncItem = function(syncItem) { var r = true; var sl = config.macros.sync.syncStatusList; switch(syncItem.syncStatus) { case sl.changedServer: r = syncItem.syncTask.syncMachine.go("getTiddler",syncItem.title); break; case sl.notFound: case sl.changedLocally: case sl.changedBoth: r = syncItem.syncTask.syncMachine.go("putTiddler",syncItem.tiddler); break; default: break; } if(r !== true) displayMessage("Error in doSyncItem: " + r); }; config.macros.sync.cancelSync = function() { currSync = null; }; function SyncMachine(serverType,steps) { this.serverType = serverType; this.adaptor = new config.adaptors[serverType]; this.steps = steps; } SyncMachine.prototype.go = function(step,context) { var r = context ? context.status : null; if(typeof r == "string") { this.invokeError(r); return r; } var h = this.steps[step ? step : "start"]; if(!h) return null; r = h.call(this,context); if(typeof r == "string") this.invokeError(r); return r; }; SyncMachine.prototype.invokeError = function(message) { if(this.steps.error) this.steps.error(message); }; SyncMachine.prototype.openHost = function(host,nextStep) { var me = this; return me.adaptor.openHost(host,null,null,function(context) {me.go(nextStep,context);}); }; SyncMachine.prototype.getWorkspaceList = function(nextStep) { var me = this; return me.adaptor.getWorkspaceList(null,null,function(context) {me.go(nextStep,context);}); }; SyncMachine.prototype.openWorkspace = function(workspace,nextStep) { var me = this; return me.adaptor.openWorkspace(workspace,null,null,function(context) {me.go(nextStep,context);}); }; SyncMachine.prototype.getTiddlerList = function(nextStep) { var me = this; return me.adaptor.getTiddlerList(null,null,function(context) {me.go(nextStep,context);}); }; SyncMachine.prototype.generateTiddlerInfo = function(tiddler) { return this.adaptor.generateTiddlerInfo(tiddler); }; SyncMachine.prototype.getTiddler = function(title,nextStep) { var me = this; return me.adaptor.getTiddler(title,null,null,function(context) {me.go(nextStep,context);}); }; SyncMachine.prototype.putTiddler = function(tiddler,nextStep) { var me = this; return me.adaptor.putTiddler(tiddler,null,null,function(context) {me.go(nextStep,context);}); }; //-- //-- Manager UI for groups of tiddlers //-- config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString,tiddler) { var wizard = new Wizard(); wizard.createWizard(place,this.wizardTitle); wizard.addStep(this.step1Title,this.step1Html); var markList = wizard.getElement("markList"); var listWrapper = document.createElement("div"); markList.parentNode.insertBefore(listWrapper,markList); listWrapper.setAttribute("refresh","macro"); listWrapper.setAttribute("macroName","plugins"); listWrapper.setAttribute("params",paramString); this.refresh(listWrapper,paramString); }; config.macros.plugins.refresh = function(listWrapper,params) { var wizard = new Wizard(listWrapper); var selectedRows = []; ListView.forEachSelector(listWrapper,function(e,rowName) { if(e.checked) selectedRows.push(e.getAttribute("rowName")); }); removeChildren(listWrapper); params = params.parseParams("anon"); var plugins = installedPlugins.slice(0); var t,tiddler,p; var configTiddlers = store.getTaggedTiddlers("systemConfig"); for(t=0; t<configTiddlers.length; t++) { tiddler = configTiddlers[t]; if(plugins.findByField("title",tiddler.title) == null) { p = getPluginInfo(tiddler); p.executed = false; p.log.splice(0,0,this.skippedText); plugins.push(p); } } for(t=0; t<plugins.length; t++) { p = plugins[t]; p.size = p.tiddler.text ? p.tiddler.text.length : 0; p.forced = p.tiddler.isTagged("systemConfigForce"); p.disabled = p.tiddler.isTagged("systemConfigDisable"); p.Selected = selectedRows.indexOf(plugins[t].title) != -1; } if(plugins.length == 0) { createTiddlyElement(listWrapper,"em",null,null,this.noPluginText); wizard.setButtons([]); } else { var listView = ListView.create(listWrapper,plugins,this.listViewTemplate,this.onSelectCommand); wizard.setValue("listView",listView); wizard.setButtons([ {caption: config.macros.plugins.removeLabel, tooltip: config.macros.plugins.removePrompt, onClick: config.macros.plugins.doRemoveTag}, {caption: config.macros.plugins.deleteLabel, tooltip: config.macros.plugins.deletePrompt, onClick: config.macros.plugins.doDelete} ]); } }; config.macros.plugins.doRemoveTag = function(e) { var wizard = new Wizard(this); var listView = wizard.getValue("listView"); var rowNames = ListView.getSelectedRows(listView); if(rowNames.length == 0) { alert(config.messages.nothingSelected); } else { for(var t=0; t<rowNames.length; t++) store.setTiddlerTag(rowNames[t],false,"systemConfig"); } }; config.macros.plugins.doDelete = function(e) { var wizard = new Wizard(this); var listView = wizard.getValue("listView"); var rowNames = ListView.getSelectedRows(listView); if(rowNames.length == 0) { alert(config.messages.nothingSelected); } else { if(confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")]))) { for(t=0; t<rowNames.length; t++) { store.removeTiddler(rowNames[t]); story.closeTiddler(rowNames[t],true); } } } }; //-- //-- Message area //-- function getMessageDiv() { var msgArea = document.getElementById("messageArea"); if(!msgArea) return null; if(!msgArea.hasChildNodes()) createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"), config.messages.messageClose.text, config.messages.messageClose.tooltip, clearMessage); msgArea.style.display = "block"; return createTiddlyElement(msgArea,"div"); } function displayMessage(text,linkText) { var e = getMessageDiv(); if(!e) { alert(text); return; } if(linkText) { var link = createTiddlyElement(e,"a",null,null,text); link.href = linkText; link.target = "_blank"; } else { e.appendChild(document.createTextNode(text)); } } function clearMessage() { var msgArea = document.getElementById("messageArea"); if(msgArea) { removeChildren(msgArea); msgArea.style.display = "none"; } return false; } //-- //-- Refresh mechanism //-- config.refreshers = { link: function(e,changeList) { var title = e.getAttribute("tiddlyLink"); refreshTiddlyLink(e,title); return true; }, tiddler: function(e,changeList) { var title = e.getAttribute("tiddler"); var template = e.getAttribute("template"); if(changeList && changeList.indexOf(title) != -1 && !story.isDirty(title)) story.refreshTiddler(title,template,true); else refreshElements(e,changeList); return true; }, content: function(e,changeList) { var title = e.getAttribute("tiddler"); var force = e.getAttribute("force"); if(force != null || changeList == null || changeList.indexOf(title) != -1) { removeChildren(e); wikify(store.getTiddlerText(title,title),e,null,store.fetchTiddler(title)); return true; } else return false; }, macro: function(e,changeList) { var macro = e.getAttribute("macroName"); var params = e.getAttribute("params"); if(macro) macro = config.macros[macro]; if(macro && macro.refresh) macro.refresh(e,params); return true; } }; config.refresherData = { styleSheet: "StyleSheet", defaultStyleSheet: "StyleSheet", pageTemplate: "PageTemplate", defaultPageTemplate: "PageTemplate", colorPalette: "ColorPalette", defaultColorPalette: "ColorPalette" }; function refreshElements(root,changeList) { var nodes = root.childNodes; for(var c=0; c<nodes.length; c++) { var e = nodes[c], type = null; if(e.getAttribute && (e.tagName ? e.tagName != "IFRAME" : true)) type = e.getAttribute("refresh"); var refresher = config.refreshers[type]; var refreshed = false; if(refresher != undefined) refreshed = refresher(e,changeList); if(e.hasChildNodes() && !refreshed) refreshElements(e,changeList); } } function applyHtmlMacros(root,tiddler) { var e = root.firstChild; while(e) { var nextChild = e.nextSibling; if(e.getAttribute) { var macro = e.getAttribute("macro"); if(macro) { var params = ""; var p = macro.indexOf(" "); if(p != -1) { params = macro.substr(p+1); macro = macro.substr(0,p); } invokeMacro(e,macro,params,null,tiddler); } } if(e.hasChildNodes()) applyHtmlMacros(e,tiddler); e = nextChild; } } function refreshPageTemplate(title) { var stash = createTiddlyElement(document.body,"div"); stash.style.display = "none"; var display = story.getContainer(); var nodes,t; if(display) { nodes = display.childNodes; for(t=nodes.length-1; t>=0; t--) stash.appendChild(nodes[t]); } var wrapper = document.getElementById("contentWrapper"); isAvailable = function(title) { var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1; if(s!=-1) title = title.substr(0,s); return store.tiddlerExists(title) || store.isShadowTiddler(title); }; if(!title || !isAvailable(title)) title = config.refresherData.pageTemplate; if(!isAvailable(title)) title = config.refresherData.defaultPageTemplate; //# this one is always avaialable html = store.getRecursiveTiddlerText(title,null,10); wrapper.innerHTML = html; applyHtmlMacros(wrapper); refreshElements(wrapper); display = story.getContainer(); removeChildren(display); if(!display) display = createTiddlyElement(wrapper,"div",story.containerId()); nodes = stash.childNodes; for(t=nodes.length-1; t>=0; t--) display.appendChild(nodes[t]); removeNode(stash); } function refreshDisplay(hint) { if(typeof hint == "string") hint = [hint]; var e = document.getElementById("contentWrapper"); refreshElements(e,hint); if(backstage.isPanelVisible()) { e = document.getElementById("backstage"); refreshElements(e,hint); } } function refreshPageTitle() { document.title = getPageTitle(); } function getPageTitle() { var st = wikifyPlain("SiteTitle"); var ss = wikifyPlain("SiteSubtitle"); return st + ((st == "" || ss == "") ? "" : " - ") + ss; } function refreshStyles(title,doc) { setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title,doc ? doc : document); } function refreshColorPalette(title) { if(!startingUp) refreshAll(); } function refreshAll() { refreshPageTemplate(); refreshDisplay(); refreshStyles("StyleSheetLayout"); refreshStyles("StyleSheetColors"); refreshStyles(config.refresherData.styleSheet); refreshStyles("StyleSheetPrint"); } //-- //-- Options stuff //-- config.optionHandlers = { 'txt': { get: function(name) {return encodeCookie(config.options[name].toString());}, set: function(name,value) {config.options[name] = decodeCookie(value);} }, 'chk': { get: function(name) {return config.options[name] ? "true" : "false";}, set: function(name,value) {config.options[name] = value == "true";} } }; function loadOptionsCookie() { if(safeMode) return; var cookies = document.cookie.split(";"); for(var c=0; c<cookies.length; c++) { var p = cookies[c].indexOf("="); if(p != -1) { var name = cookies[c].substr(0,p).trim(); var value = cookies[c].substr(p+1).trim(); var optType = name.substr(0,3); if(config.optionHandlers[optType] && config.optionHandlers[optType].set) config.optionHandlers[optType].set(name,value); } } } function saveOptionCookie(name) { if(safeMode) return; var c = name + "="; var optType = name.substr(0,3); if(config.optionHandlers[optType] && config.optionHandlers[optType].get) c += config.optionHandlers[optType].get(name); c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/"; document.cookie = c; } function encodeCookie(s) { return escape(manualConvertUnicodeToUTF8(s)); } function decodeCookie(s) { s = unescape(s); var re = /&#[0-9]{1,5};/g; return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));}); } config.macros.option.genericCreate = function(place,type,opt,className,desc) { var typeInfo = config.macros.option.types[type]; var c = document.createElement(typeInfo.elementType); if(typeInfo.typeValue) c.setAttribute("type",typeInfo.typeValue); c[typeInfo.eventName] = typeInfo.onChange; c.setAttribute("option",opt); if(className) c.className = className; else c.className = typeInfo.className; if(config.optionsDesc[opt]) c.setAttribute("title",config.optionsDesc[opt]); place.appendChild(c); if(desc != "no") createTiddlyText(place,config.optionsDesc[opt] ? config.optionsDesc[opt] : opt); c[typeInfo.valueField] = config.options[opt]; return c; }; config.macros.option.genericOnChange = function(e) { var opt = this.getAttribute("option"); if(opt) { var optType = opt.substr(0,3); var handler = config.macros.option.types[optType]; if(handler.elementType && handler.valueField) config.macros.option.propagateOption(opt,handler.valueField,this[handler.valueField],handler.elementType); } return true; }; config.macros.option.types = { 'txt': { elementType: "input", valueField: "value", eventName: "onkeyup", className: "txtOptionInput", create: config.macros.option.genericCreate, onChange: config.macros.option.genericOnChange }, 'chk': { elementType: "input", valueField: "checked", eventName: "onclick", className: "chkOptionInput", typeValue: "checkbox", create: config.macros.option.genericCreate, onChange: config.macros.option.genericOnChange } }; config.macros.option.propagateOption = function(opt,valueField,value,elementType) { config.options[opt] = value; 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] = value; } }; config.macros.option.handler = function(place,macroName,params,wikifier,paramString,tiddler) { params = paramString.parseParams("anon",null,true,false,false); var opt = (params[1] && params[1].name == "anon") ? params[1].value : getParam(params,"name",null); var className = (params[2] && params[2].name == "anon") ? params[2].value : getParam(params,"class",null); var desc = getParam(params,"desc","no"); var type = opt.substr(0,3); var h = config.macros.option.types[type]; if(h && h.create) h.create(place,type,opt,className,desc); }; config.macros.options.handler = function(place,macroName,params,wikifier,paramString,tiddler) { params = paramString.parseParams("anon",null,true,false,false); var showUnknown = getParam(params,"showUnknown","no"); var wizard = new Wizard(); wizard.createWizard(place,this.wizardTitle); wizard.addStep(this.step1Title,this.step1Html); var markList = wizard.getElement("markList"); var chkUnknown = wizard.getElement("chkUnknown"); chkUnknown.checked = showUnknown == "yes"; chkUnknown.onchange = this.onChangeUnknown; var listWrapper = document.createElement("div"); markList.parentNode.insertBefore(listWrapper,markList); wizard.setValue("listWrapper",listWrapper); this.refreshOptions(listWrapper,showUnknown == "yes"); }; config.macros.options.refreshOptions = function(listWrapper,showUnknown) { var opts = []; for(var n in config.options) { var opt = {}; opt.option = ""; opt.name = n; opt.lowlight = !config.optionsDesc[n]; opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n]; if(!opt.lowlight || showUnknown) opts.push(opt); } opts.sort(function(a,b) {return a.name.substr(3) < b.name.substr(3) ? -1 : (a.name.substr(3) == b.name.substr(3) ? 0 : +1);}); var listview = ListView.create(listWrapper,opts,this.listViewTemplate); for(n=0; n<opts.length; n++) { var type = opts[n].name.substr(0,3); var h = config.macros.option.types[type]; if(h && h.create) { h.create(opts[n].colElements['option'],type,opts[n].name,null,"no"); } } }; config.macros.options.onChangeUnknown = function(e) { var wizard = new Wizard(this); var listWrapper = wizard.getValue("listWrapper"); removeChildren(listWrapper); config.macros.options.refreshOptions(listWrapper,this.checked); return false; }; //-- //-- Saving //-- var saveUsingSafari = false; var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it var endSaveArea = '</d' + 'iv>'; // If there are unsaved changes, force the user to confirm before exitting function confirmExit() { hadConfirmExit = true; if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty())) return config.messages.confirmExit; } // Give the user a chance to save changes before exitting function checkUnsavedChanges() { if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false) { if(confirm(config.messages.unsavedChangesWarning)) saveChanges(); } } function updateLanguageAttribute(s) { if(config.locale) { var mRE = /(<html(?:.*?)?)(?: xml:lang\="([a-z]+)")?(?: lang\="([a-z]+)")?>/; var m = mRE.exec(s); if(m) { var t = m[1]; if(m[2]) t += ' xml:lang="' + config.locale + '"'; if(m[3]) t += ' lang="' + config.locale + '"'; t += ">"; s = s.substr(0,m.index) + t + s.substr(m.index+m[0].length); } } return s; } function updateMarkupBlock(s,blockName,tiddlerName) { return s.replaceChunk( "<!--%0-START-->".format([blockName]), "<!--%0-END-->".format([blockName]), "\n" + convertUnicodeToUTF8(store.getRecursiveTiddlerText(tiddlerName,"")) + "\n"); } function updateOriginal(original,posDiv) { if(!posDiv) posDiv = locateStoreArea(original); if(!posDiv) { alert(config.messages.invalidFileError.format([localPath])); return null; } var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" + convertUnicodeToUTF8(store.allTiddlersAsHtml()) + "\n" + original.substr(posDiv[1]); var newSiteTitle = convertUnicodeToUTF8(getPageTitle()).htmlEncode(); revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " "); revised = updateLanguageAttribute(revised); revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead"); revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead"); revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody"); revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody"); return revised; } function locateStoreArea(original) { // Locate the storeArea div's var posOpeningDiv = original.indexOf(startSaveArea); var limitClosingDiv = original.indexOf("<"+"!--POST-STOREAREA--"+">"); if(limitClosingDiv == -1) limitClosingDiv = original.indexOf("<"+"!--POST-BODY-START--"+">"); var posClosingDiv = original.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? original.length : limitClosingDiv); return (posOpeningDiv != -1 && posClosingDiv != -1) ? [posOpeningDiv,posClosingDiv] : null; } function autoSaveChanges(onlyIfDirty,tiddlers) { if(config.options.chkAutoSave) saveChanges(onlyIfDirty,tiddlers); } function loadOriginal(localPath) { return loadFile(localPath); } // Save this tiddlywiki with the pending changes function saveChanges(onlyIfDirty,tiddlers) { if(onlyIfDirty && !store.isDirty()) return; clearMessage(); var t0 = new Date(); var originalPath = document.location.toString(); if(originalPath.substr(0,5) != "file:") { alert(config.messages.notFileUrlError); if(store.tiddlerExists(config.messages.saveInstructions)) story.displayTiddler(null,config.messages.saveInstructions); return; } var localPath = getLocalPath(originalPath); var original = loadOriginal(localPath); if(original == null) { alert(config.messages.cantSaveError); if(store.tiddlerExists(config.messages.saveInstructions)) story.displayTiddler(null,config.messages.saveInstructions); return; } var posDiv = locateStoreArea(original); if(!posDiv) { alert(config.messages.invalidFileError.format([localPath])); return; } saveMain(localPath,original,posDiv); if(config.options.chkSaveBackups) saveBackup(localPath,original); if(config.options.chkSaveEmptyTemplate) saveEmpty(localPath,original,posDiv); if(config.options.chkGenerateAnRssFeed) saveRss(localPath); if(config.options.chkDisplayInstrumentation) displayMessage("saveChanges " + (new Date()-t0) + " ms"); } function saveMain(localPath,original,posDiv) { var save; try { var revised = updateOriginal(original,posDiv); save = saveFile(localPath,revised); } catch (ex) { showException(ex); } if(save) { displayMessage(config.messages.mainSaved,"file://" + localPath); store.setDirty(false); } else { alert(config.messages.mainFailed); } } function saveBackup(localPath,original) { var backupPath = getBackupPath(localPath); var backup = copyFile(backupPath,localPath); if(!backup) backup = saveFile(backupPath,original); if(backup) displayMessage(config.messages.backupSaved,"file://" + backupPath); else alert(config.messages.backupFailed); } function saveEmpty(localPath,original,posDiv) { var emptyPath,p; if((p = localPath.lastIndexOf("/")) != -1) emptyPath = localPath.substr(0,p) + "/"; else if((p = localPath.lastIndexOf("\\")) != -1) emptyPath = localPath.substr(0,p) + "\\"; else emptyPath = localPath + "."; emptyPath += "empty.html"; var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]); var emptySave = saveFile(emptyPath,empty); if(emptySave) displayMessage(config.messages.emptySaved,"file://" + emptyPath); else alert(config.messages.emptyFailed); } function saveRss(localPath) { var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml"; if(saveFile(rssPath,convertUnicodeToUTF8(generateRss()))) displayMessage(config.messages.rssSaved,"file://" + rssPath); else alert(config.messages.rssFailed); } function getLocalPath(origPath) { var originalPath = convertUriToUTF8(origPath,config.options.txtFileSystemCharSet); // Remove any location or query part of the URL var argPos = originalPath.indexOf("?"); if(argPos != -1) originalPath = originalPath.substr(0,argPos); var hashPos = originalPath.indexOf("#"); if(hashPos != -1) originalPath = originalPath.substr(0,hashPos); // Convert file://localhost/ to file:/// if(originalPath.indexOf("file://localhost/") == 0) originalPath = "file://" + originalPath.substr(16); // Convert to a native file format 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; } function getBackupPath(localPath,title,extension) { var slash = "\\"; var dirPathPos = localPath.lastIndexOf("\\"); if(dirPathPos == -1) { dirPathPos = localPath.lastIndexOf("/"); slash = "/"; } var backupFolder = config.options.txtBackupFolder; if(!backupFolder || backupFolder == "") backupFolder = "."; var backupPath = localPath.substr(0,dirPathPos) + slash + backupFolder + localPath.substr(dirPathPos); backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + "."; if(title) backupPath += title.replace(/[\\\/\*\?\":<> ]/g,"_") + "."; backupPath += (new Date()).convertToYYYYMMDDHHMMSSMMM() + "." + (extension ? extension : "html"); return backupPath; } function generateRss() { var s = []; var d = new Date(); var u = store.getTiddlerText("SiteUrl"); // Assemble the header s.push("<" + "?xml version=\"1.0\"?" + ">"); s.push("<rss version=\"2.0\">"); s.push("<channel>"); s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">"); if(u) s.push("<link>" + u.htmlEncode() + "</link>"); s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>"); s.push("<language>en-us</language>"); s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>"); s.push("<pubDate>" + d.toGMTString() + "</pubDate>"); s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>"); s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>"); s.push("<generator>TiddlyWiki " + formatVersion() + "</generator>"); // The body var tiddlers = store.getTiddlers("modified","excludeLists"); var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems; for(var t=tiddlers.length-1; t>=n; t--) { s.push("<item>\n" + tiddlers[t].toRssItem(u) + "\n</item>"); } // And footer s.push("</channel>"); s.push("</rss>"); // Save it all return s.join("\n"); } //-- //-- Filesystem code //-- function convertUTF8ToUnicode(u) { return window.netscape == undefined ? manualConvertUTF8ToUnicode(u) : mozConvertUTF8ToUnicode(u); } function manualConvertUTF8ToUnicode(utf) { var uni = utf; var src = 0; var dst = 0; var b1, b2, b3; var c; while(src < utf.length) { b1 = utf.charCodeAt(src++); if(b1 < 0x80) { dst++; } else if(b1 < 0xE0) { b2 = utf.charCodeAt(src++); c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F)); uni = uni.substring(0,dst++).concat(c,utf.substr(src)); } else { b2 = utf.charCodeAt(src++); b3 = utf.charCodeAt(src++); c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F)); uni = uni.substring(0,dst++).concat(c,utf.substr(src)); } } return uni; } function mozConvertUTF8ToUnicode(u) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter); converter.charset = "UTF-8"; } catch(ex) { return manualConvertUTF8ToUnicode(u); } // fallback var s = converter.ConvertToUnicode(u); var fin = converter.Finish(); return (fin.length > 0) ? s+fin : s; } function convertUnicodeToUTF8(s) { if(window.netscape == undefined) return manualConvertUnicodeToUTF8(s); else return mozConvertUnicodeToUTF8(s); } function manualConvertUnicodeToUTF8(s) { var re = /[^\u0000-\u007F]/g ; return s.replace(re,function($0) {return "&#" + $0.charCodeAt(0).toString() + ";";}); } function mozConvertUnicodeToUTF8(s) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter); converter.charset = "UTF-8"; } catch(ex) { return manualConvertUnicodeToUTF8(s); } // fallback var u = converter.ConvertFromUnicode(s); var fin = converter.Finish(); return fin.length > 0 ? u + fin : u; } function convertUriToUTF8(uri,charSet) { if(window.netscape == undefined || charSet == undefined || charSet == "") return uri; try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService); } catch(ex) { return uri; } return converter.convertURISpecToUTF8(uri,charSet); } function copyFile(dest,source) { return config.browser.isIE ? ieCopyFile(dest,source) : false; } function saveFile(fileUrl,content) { var r = mozillaSaveFile(fileUrl,content); if(!r) r = ieSaveFile(fileUrl,content); if(!r) r = javaSaveFile(fileUrl,content); return r; } function loadFile(fileUrl) { var r = mozillaLoadFile(fileUrl); if((r == null) || (r == false)) r = ieLoadFile(fileUrl); if((r == null) || (r == false)) r = javaLoadFile(fileUrl); return r; } function ieCreatePath(path) { try { var fso = new ActiveXObject("Scripting.FileSystemObject"); } catch(ex) { return null; } var pos = path.lastIndexOf("\\"); if(pos!=-1) path = path.substring(0, pos+1); var scan = []; scan.push(path); var i = 0; do { var parent = fso.GetParentFolderName(scan[i++]); if(fso.FolderExists(parent)) break; scan.push(parent); } while(true); for(i=scan.length-1;i>=0;i--) { if(!fso.FolderExists(scan[i])) fso.CreateFolder(scan[i]); } return true; } // Returns null if it can't do it, false if there's an error, true if it saved OK function ieSaveFile(filePath,content) { ieCreatePath(filePath); try { var fso = new ActiveXObject("Scripting.FileSystemObject"); } catch(ex) { return null; } var file = fso.OpenTextFile(filePath,2,-1,0); file.Write(content); file.Close(); return true; } // Returns null if it can't do it, false if there's an error, or a string of the content if successful function ieLoadFile(filePath) { try { var fso = new ActiveXObject("Scripting.FileSystemObject"); var file = fso.OpenTextFile(filePath,1); var content = file.ReadAll(); file.Close(); } catch(ex) { return null; } return content; } function ieCopyFile(dest,source) { ieCreatePath(dest); try { var fso = new ActiveXObject("Scripting.FileSystemObject"); fso.GetFile(source).Copy(dest); } catch(ex) { return false; } return true; } // Returns null if it can't do it, false if there's an error, true if it saved OK function mozillaSaveFile(filePath,content) { if(window.Components) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if(!file.exists()) file.create(0,0664); var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); out.init(file,0x20|0x02,00004,null); out.write(content,content.length); out.flush(); out.close(); return true; } catch(ex) { return false; } } return null; } // Returns null if it can't do it, false if there's an error, or a string of the content if successful function mozillaLoadFile(filePath) { if(window.Components) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if(!file.exists()) return null; var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file,0x01,00004,null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); var contents = sInputStream.read(sInputStream.available()); sInputStream.close(); inputStream.close(); return contents; } catch(ex) { return false; } } return null; } function javaUrlToFilename(url) { var f = "//localhost"; if(url.indexOf(f) == 0) return url.substring(f.length); var i = url.indexOf(":"); if(i > 0) return url.substring(i-1); return url; } function javaSaveFile(filePath,content) { try { if(document.applets["TiddlySaver"]) return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content); } catch(ex) { } try { var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath))); s.print(content); s.close(); } catch(ex) { return null; } return true; } function javaLoadFile(filePath) { try { if(document.applets["TiddlySaver"]) return String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8")); } catch(ex) { } var content = []; try { var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath))); var line; while((line = r.readLine()) != null) content.push(new String(line)); r.close(); } catch(ex) { return null; } return content.join("\n"); } //-- //-- Server adaptor for talking to static TiddlyWiki files //-- function FileAdaptor() { this.host = null; this.store = null; return this; } FileAdaptor.serverType = 'file'; FileAdaptor.serverLabel = 'TiddlyWiki'; FileAdaptor.prototype.setContext = function(context,userParams,callback) { if(!context) context = {}; context.userParams = userParams; if(callback) context.callback = callback; context.adaptor = this; if(!context.host) context.host = this.host; context.host = FileAdaptor.fullHostName(context.host); if(!context.workspace) context.workspace = this.workspace; return context; }; FileAdaptor.fullHostName = function(host) { if(!host) return ''; if(!host.match(/:\/\//)) host = 'http://' + host; return host; }; FileAdaptor.minHostName = function(host) { return host ? host.replace(/^http:\/\//,'').replace(/\/$/,'') : ''; }; // Open the specified host FileAdaptor.prototype.openHost = function(host,context,userParams,callback) { this.host = host; context = this.setContext(context,userParams,callback); context.status = true; if(callback) window.setTimeout(function() {context.callback(context,userParams);},10); return true; }; FileAdaptor.loadTiddlyWikiCallback = function(status,context,responseText,url,xhr) { context.status = status; if(!status) { context.statusText = "Error reading file"; } else { context.adaptor.store = new TiddlyWiki(); if(!context.adaptor.store.importTiddlyWiki(responseText)) context.statusText = config.messages.invalidFileError.format([url]); } context.complete(context,context.userParams); }; // Get the list of workspaces on a given server FileAdaptor.prototype.getWorkspaceList = function(context,userParams,callback) { context = this.setContext(context,userParams,callback); context.workspaces = [{title:"(default)"}]; context.status = true; if(callback) window.setTimeout(function() {callback(context,userParams);},10); return true; }; // Open the specified workspace FileAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback) { this.workspace = workspace; context = this.setContext(context,userParams,callback); context.status = true; if(callback) window.setTimeout(function() {callback(context,userParams);},10); return true; }; // Gets the list of tiddlers within a given workspace FileAdaptor.prototype.getTiddlerList = function(context,userParams,callback,filter) { context = this.setContext(context,userParams,callback); if(!context.filter) context.filter = filter; context.complete = FileAdaptor.getTiddlerListComplete; if(this.store) { var ret = context.complete(context,context.userParams); } else { ret = loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context); if(typeof ret != "string") ret = true; } return ret; }; FileAdaptor.getTiddlerListComplete = function(context,userParams) { if(context.status) { if(context.filter) { context.tiddlers = context.adaptor.store.filterTiddlers(context.filter); } else { context.tiddlers = []; context.adaptor.store.forEachTiddler(function(title,tiddler) {context.tiddlers.push(tiddler);}); } for(var i=0; i<context.tiddlers.length; i++) { context.tiddlers[i].fields['server.type'] = FileAdaptor.serverType; context.tiddlers[i].fields['server.host'] = FileAdaptor.minHostName(context.host); context.tiddlers[i].fields['server.page.revision'] = context.tiddlers[i].modified.convertToYYYYMMDDHHMM(); } context.status = true; } if(context.callback) { window.setTimeout(function() {context.callback(context,userParams);},10); } return true; }; FileAdaptor.prototype.generateTiddlerInfo = function(tiddler) { var info = {}; info.uri = tiddler.fields['server.host'] + "#" + tiddler.title; return info; }; // Retrieve a tiddler from a given workspace on a given server FileAdaptor.prototype.getTiddler = function(title,context,userParams,callback) { context = this.setContext(context,userParams,callback); context.title = title; context.complete = FileAdaptor.getTiddlerComplete; return context.adaptor.store ? context.complete(context,context.userParams) : loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context); }; FileAdaptor.getTiddlerComplete = function(context,userParams) { var t = context.adaptor.store.fetchTiddler(context.title); t.fields['server.type'] = FileAdaptor.serverType; t.fields['server.host'] = FileAdaptor.minHostName(context.host); t.fields['server.page.revision'] = t.modified.convertToYYYYMMDDHHMM(); context.tiddler = t; context.status = true; if(context.allowSynchronous) { context.isSynchronous = true; context.callback(context,userParams); } else { window.setTimeout(function() {context.callback(context,userParams);},10); } return true; }; FileAdaptor.prototype.close = function() { delete this.store; this.store = null; }; config.adaptors[FileAdaptor.serverType] = FileAdaptor; config.defaultAdaptor = FileAdaptor.serverType; //-- //-- Remote HTTP requests //-- function loadRemoteFile(url,callback,params) { return doHttp("GET",url,null,null,null,null,callback,params,null); } // HTTP status codes var httpStatus = { OK: 200, ContentCreated: 201, NoContent: 204, MultiStatus: 207, Unauthorized: 401, Forbidden: 403, NotFound: 404, MethodNotAllowed: 405 }; function doHttp(type,url,data,contentType,username,password,callback,params,headers,allowCache) { var x = getXMLHttpRequest(); if(!x) return "Can't create XMLHttpRequest object"; x.onreadystatechange = function() { try { var status = x.status; } catch(ex) { status = false; } if(x.readyState == 4 && callback && (status !== undefined)) { if([0, httpStatus.OK, httpStatus.ContentCreated, httpStatus.NoContent, httpStatus.MultiStatus].contains(status)) callback(true,params,x.responseText,url,x); else callback(false,params,null,url,x); x.onreadystatechange = function(){}; x = null; } }; if(window.Components && window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1) window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); try { if(!allowCache) url = url + (url.indexOf("?") < 0 ? "?" : "&") + "nocache=" + Math.random(); x.open(type,url,true,username,password); if(data) x.setRequestHeader("Content-Type", contentType ? contentType : "application/x-www-form-urlencoded"); if(x.overrideMimeType) x.setRequestHeader("Connection", "close"); if(headers) { for(var n in headers) x.setRequestHeader(n,headers[n]); } x.setRequestHeader("X-Requested-With", "TiddlyWiki " + formatVersion()); x.send(data); } catch(ex) { return exceptionText(ex); } return x; } function getXMLHttpRequest() { try { var x = new XMLHttpRequest(); // Modern } catch(ex) { try { x = new ActiveXObject("Msxml2.XMLHTTP"); // IE 6 } catch (ex2) { return null; } } return x; } //-- //-- TiddlyWiki-specific utility functions //-- formatVersion = function(v) { v = v || version; return v.major + "." + v.minor + "." + v.revision + (v.beta ? " (beta " + v.beta + ")" : ""); }; compareVersions = function(v1,v2) { var a = ["major","minor","revision"]; for(var i = 0; i<a.length; i++) { var x1 = v1[a[i]] || 0; var x2 = v2[a[i]] || 0; if(x1<x2) return 1; if(x1>x2) return -1; } x1 = v1.beta || 9999; x2 = v2.beta || 9999; if(x1<x2) return 1; return x1 > x2 ? -1 : 0; }; function createTiddlyButton(parent,text,tooltip,action,className,id,accessKey,attribs) { var btn = document.createElement("a"); if(action) { btn.onclick = action; btn.setAttribute("href","javascript:;"); } if(tooltip) btn.setAttribute("title",tooltip); if(text) btn.appendChild(document.createTextNode(text)); btn.className = className ? className : "button"; if(id) btn.id = id; if(attribs) { for(var n in attribs) { btn.setAttribute(n,attribs[n]); } } if(parent) parent.appendChild(btn); if(accessKey) btn.setAttribute("accessKey",accessKey); return btn; } function createTiddlyLink(place,title,includeText,className,isStatic,linkedFromTiddler,noToggle) { var text = includeText ? title : null; var i = getTiddlyLinkInfo(title,className); var btn = isStatic ? createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" + title) : createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes); btn.setAttribute("refresh","link"); btn.setAttribute("tiddlyLink",title); if(noToggle) btn.setAttribute("noToggle","true"); if(linkedFromTiddler) { var fields = linkedFromTiddler.getInheritedFields(); if(fields) btn.setAttribute("tiddlyFields",fields); } return btn; } function refreshTiddlyLink(e,title) { var i = getTiddlyLinkInfo(title,e.className); e.className = i.classes; e.title = i.subTitle; } function getTiddlyLinkInfo(title,currClasses) { var classes = currClasses ? currClasses.split(" ") : []; classes.pushUnique("tiddlyLink"); var tiddler = store.fetchTiddler(title); var subTitle; if(tiddler) { subTitle = tiddler.getSubtitle(); classes.pushUnique("tiddlyLinkExisting"); classes.remove("tiddlyLinkNonExisting"); classes.remove("shadow"); } else { classes.remove("tiddlyLinkExisting"); classes.pushUnique("tiddlyLinkNonExisting"); if(store.isShadowTiddler(title)) { subTitle = config.messages.shadowedTiddlerToolTip.format([title]); classes.pushUnique("shadow"); } else { subTitle = config.messages.undefinedTiddlerToolTip.format([title]); classes.remove("shadow"); } } if(typeof config.annotations[title]=="string") subTitle = config.annotations[title]; return {classes: classes.join(" "),subTitle: subTitle}; } function createExternalLink(place,url) { var link = document.createElement("a"); link.className = "externalLink"; link.href = url; link.title = config.messages.externalLinkTooltip.format([url]); if(config.options.chkOpenInNewWindow) link.target = "_blank"; place.appendChild(link); return link; } // Event handler for clicking on a tiddly link function onClickTiddlerLink(ev) { var e = ev ? ev : window.event; var target = resolveTarget(e); var link = target; var title = null; var fields = null; var noToggle = null; do { title = link.getAttribute("tiddlyLink"); fields = link.getAttribute("tiddlyFields"); noToggle = link.getAttribute("noToggle"); link = link.parentNode; } while(title == null && link != null); if(!store.isShadowTiddler(title)) { var f = fields ? fields.decodeHashMap() : {}; fields = String.encodeHashMap(merge(f,config.defaultCustomFields,true)); } if(title) { var toggling = e.metaKey || e.ctrlKey; if(config.options.chkToggleLinks) toggling = !toggling; if(noToggle) toggling = false; if(store.getTiddler(title)) fields = null; story.displayTiddler(target,title,null,true,null,fields,toggling); } clearMessage(); return false; } // Create a button for a tag with a popup listing all the tiddlers that it tags function createTagButton(place,tag,excludeTiddler,title,tooltip) { var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag); btn.setAttribute("tag",tag); if(excludeTiddler) btn.setAttribute("tiddler",excludeTiddler); return btn; } // Event handler for clicking on a tiddler tag function onClickTag(ev) { var e = ev ? ev : window.event; var popup = Popup.create(this); var tag = this.getAttribute("tag"); var title = this.getAttribute("tiddler"); if(popup && tag) { var tagged = store.getTaggedTiddlers(tag); var titles = []; var li,r; for(r=0;r<tagged.length;r++) { if(tagged[r].title != title) titles.push(tagged[r].title); } var lingo = config.views.wikified.tag; if(titles.length > 0) { var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll); openAll.setAttribute("tag",tag); createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div"); for(r=0; r<titles.length; r++) { createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true); } } else { createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag])); } createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div"); var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false); createTiddlyText(h,lingo.openTag.format([tag])); } Popup.show(); e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); return false; } // Event handler for 'open all' on a tiddler popup function onClickTagOpenAll(ev) { var e = ev ? ev : window.event; var tag = this.getAttribute("tag"); var tagged = store.getTaggedTiddlers(tag); story.displayTiddlers(this,tagged); return false; } function onClickError(ev) { var e = ev ? ev : window.event; var popup = Popup.create(this); var lines = this.getAttribute("errorText").split("\n"); for(var t=0; t<lines.length; t++) createTiddlyElement(popup,"li",null,null,lines[t]); Popup.show(); e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation(); return false; } function createTiddlyDropDown(place,onchange,options,defaultValue) { var sel = createTiddlyElement(place,"select"); sel.onchange = onchange; for(var t=0; t<options.length; t++) { var e = createTiddlyElement(sel,"option",null,null,options[t].caption); e.value = options[t].name; if(options[t].name == defaultValue) e.selected = true; } return sel; } function createTiddlyPopup(place,caption,tooltip,tiddler) { if(tiddler.text) { createTiddlyLink(place,caption,true); var btn = createTiddlyButton(place,glyph("downArrow"),tooltip,onClickTiddlyPopup,"tiddlerPopupButton"); btn.tiddler = tiddler; } else { createTiddlyText(place,caption); } } function onClickTiddlyPopup(ev) { var e = ev ? ev : window.event; var tiddler = this.tiddler; if(tiddler.text) { var popup = Popup.create(this,"div","popupTiddler"); wikify(tiddler.text,popup,null,tiddler); Popup.show(); } if(e) e.cancelBubble = true; if(e && e.stopPropagation) e.stopPropagation(); return false; } function createTiddlyError(place,title,text) { var btn = createTiddlyButton(place,title,null,onClickError,"errorButton"); if(text) btn.setAttribute("errorText",text); } function merge(dst,src,preserveExisting) { for(p in src) { if(!preserveExisting || dst[p] === undefined) dst[p] = src[p]; } return dst; } // Returns a string containing the description of an exception, optionally prepended by a message function exceptionText(e,message) { var s = e.description ? e.description : e.toString(); return message ? "%0:\n%1".format([message,s]) : s; } // Displays an alert of an exception description with optional message function showException(e,message) { alert(exceptionText(e,message)); } function alertAndThrow(m) { alert(m); throw(m); } function glyph(name) { var g = config.glyphs; var b = g.currBrowser; if(b == null) { b = 0; while(!g.browsers[b]() && b < g.browsers.length-1) b++; g.currBrowser = b; } if(!g.codes[name]) return ""; return g.codes[name][b]; } //- //- Animation engine //- function Animator() { this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled this.timerID = 0; // ID of the timer used for animating this.animations = []; // List of animations in progress return this; } // Start animation engine Animator.prototype.startAnimating = function() //# Variable number of arguments { for(var t=0; t<arguments.length; t++) this.animations.push(arguments[t]); if(this.running == 0) { var me = this; this.timerID = window.setInterval(function() {me.doAnimate(me);},10); } this.running += arguments.length; }; // Perform an animation engine tick, calling each of the known animation modules Animator.prototype.doAnimate = function(me) { var a = 0; while(a < me.animations.length) { var animation = me.animations[a]; if(animation.tick()) { a++; } else { me.animations.splice(a,1); if(--me.running == 0) window.clearInterval(me.timerID); } } }; Animator.slowInSlowOut = function(progress) { return(1-((Math.cos(progress * Math.PI)+1)/2)); }; //-- //-- Morpher animation //-- // Animate a set of properties of an element function Morpher(element,duration,properties,callback) { this.element = element; this.duration = duration; this.properties = properties; this.startTime = new Date(); this.endTime = Number(this.startTime) + duration; this.callback = callback; this.tick(); return this; } Morpher.prototype.assignStyle = function(element,style,value) { switch(style) { case "-tw-vertScroll": window.scrollTo(findScrollX(),value); break; case "-tw-horizScroll": window.scrollTo(value,findScrollY()); break; default: element.style[style] = value; break; } }; Morpher.prototype.stop = function() { for(var t=0; t<this.properties.length; t++) { var p = this.properties[t]; if(p.atEnd !== undefined) { this.assignStyle(this.element,p.style,p.atEnd); } } if(this.callback) this.callback(this.element,this.properties); }; Morpher.prototype.tick = function() { var currTime = Number(new Date()); progress = Animator.slowInSlowOut(Math.min(1,(currTime-this.startTime)/this.duration)); for(var t=0; t<this.properties.length; t++) { var p = this.properties[t]; if(p.start !== undefined && p.end !== undefined) { var template = p.template ? p.template : "%0"; switch(p.format) { case undefined: case "style": var v = p.start + (p.end-p.start) * progress; this.assignStyle(this.element,p.style,template.format([v])); break; case "color": break; } } } if(currTime >= this.endTime) { this.stop(); return false; } return true; }; //-- //-- Zoomer animation //-- function Zoomer(text,startElement,targetElement,unused) { var e = createTiddlyElement(document.body,"div",null,"zoomer"); createTiddlyElement(e,"div",null,null,text); var winWidth = findWindowWidth(); var winHeight = findWindowHeight(); var p = [ {style: 'left', start: findPosX(startElement), end: findPosX(targetElement), template: '%0px'}, {style: 'top', start: findPosY(startElement), end: findPosY(targetElement), template: '%0px'}, {style: 'width', start: Math.min(startElement.scrollWidth,winWidth), end: Math.min(targetElement.scrollWidth,winWidth), template: '%0px', atEnd: 'auto'}, {style: 'height', start: Math.min(startElement.scrollHeight,winHeight), end: Math.min(targetElement.scrollHeight,winHeight), template: '%0px', atEnd: 'auto'}, {style: 'fontSize', start: 8, end: 24, template: '%0pt'} ]; var c = function(element,properties) {removeNode(element);}; return new Morpher(e,config.animDuration,p,c); } //-- //-- Scroller animation //-- function Scroller(targetElement,unused) { var p = [ {style: '-tw-vertScroll', start: findScrollY(), end: ensureVisible(targetElement)} ]; return new Morpher(targetElement,config.animDuration,p); } //-- //-- Slider animation //-- // deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element] function Slider(element,opening,unused,deleteMode) { element.style.overflow = 'hidden'; if(opening) element.style.height = '0px'; // Resolves a Firefox flashing bug element.style.display = 'block'; var left = findPosX(element); var width = element.scrollWidth; var height = element.scrollHeight; var winWidth = findWindowWidth(); var p = []; var c = null; if(opening) { p.push({style: 'height', start: 0, end: height, template: '%0px', atEnd: 'auto'}); p.push({style: 'opacity', start: 0, end: 1, template: '%0'}); p.push({style: 'filter', start: 0, end: 100, template: 'alpha(opacity:%0)'}); } else { p.push({style: 'height', start: height, end: 0, template: '%0px'}); p.push({style: 'display', atEnd: 'none'}); p.push({style: 'opacity', start: 1, end: 0, template: '%0'}); p.push({style: 'filter', start: 100, end: 0, template: 'alpha(opacity:%0)'}); switch(deleteMode) { case "all": c = function(element,properties) {removeNode(element);}; break; case "children": c = function(element,properties) {removeChildren(element);}; break; } } return new Morpher(element,config.animDuration,p,c); } //-- //-- Popup menu //-- var Popup = { stack: [] // Array of objects with members root: and popup: }; Popup.create = function(root,elem,theClass) { var stackPosition = this.find(root,"popup"); Popup.remove(stackPosition+1); var popup = createTiddlyElement(document.body,elem ? elem : "ol","popup",theClass ? theClass : "popup"); popup.stackPosition = stackPosition; Popup.stack.push({root: root, popup: popup}); return popup; }; Popup.onDocumentClick = function(ev) { var e = ev ? ev : window.event; if(e.eventPhase == undefined) Popup.remove(); else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET) Popup.remove(); return true; }; Popup.show = function(valign,halign,offset) { var curr = Popup.stack[Popup.stack.length-1]; this.place(curr.root,curr.popup,valign,halign,offset); addClass(curr.root,"highlight"); if(config.options.chkAnimate && anim && typeof Scroller == "function") anim.startAnimating(new Scroller(curr.popup)); else window.scrollTo(0,ensureVisible(curr.popup)); }; Popup.place = function(root,popup,valign,halign,offset) { if(!offset) var offset = {x:0,y:0}; if(popup.stackPosition >= 0 && !valign && !halign) { offset.x = offset.x + root.offsetWidth; } else { offset.x = (halign == 'right') ? offset.x + root.offsetWidth : offset.x; offset.y = (valign == 'top') ? offset.y : offset.y + root.offsetHeight; } var rootLeft = findPosX(root); var rootTop = findPosY(root); var popupLeft = rootLeft + offset.x; var popupTop = rootTop + offset.y; var winWidth = findWindowWidth(); if(popup.offsetWidth > winWidth*0.75) popup.style.width = winWidth*0.75 + "px"; var popupWidth = popup.offsetWidth; var scrollWidth = winWidth - document.body.offsetWidth; if(popupLeft + popupWidth > winWidth - scrollWidth - 1) { if(halign == 'right') popupLeft = popupLeft - root.offsetWidth - popupWidth; else popupLeft = winWidth - popupWidth - scrollWidth - 1; } popup.style.left = popupLeft + "px"; popup.style.top = popupTop + "px"; popup.style.display = "block"; }; Popup.find = function(e) { var pos = -1; for (var t=this.stack.length-1; t>=0; t--) { if(isDescendant(e,this.stack[t].popup)) pos = i; } return pos; }; Popup.remove = function(pos) { if(!pos) var pos = 0; if(Popup.stack.length > pos) { Popup.removeFrom(pos); } }; Popup.removeFrom = function(from) { for(var t=Popup.stack.length-1; t>=from; t--) { var p = Popup.stack[t]; removeClass(p.root,"highlight"); removeNode(p.popup); } Popup.stack = Popup.stack.slice(0,from); }; //-- //-- Wizard support //-- function Wizard(elem) { if(elem) { this.formElem = findRelated(elem,"wizard","className"); this.bodyElem = findRelated(this.formElem.firstChild,"wizardBody","className","nextSibling"); this.footElem = findRelated(this.formElem.firstChild,"wizardFooter","className","nextSibling"); } else { this.formElem = null; this.bodyElem = null; this.footElem = null; } } Wizard.prototype.setValue = function(name,value) { if(this.formElem) this.formElem[name] = value; }; Wizard.prototype.getValue = function(name) { return this.formElem ? this.formElem[name] : null; }; Wizard.prototype.createWizard = function(place,title) { this.formElem = createTiddlyElement(place,"form",null,"wizard"); createTiddlyElement(this.formElem,"h1",null,null,title); this.bodyElem = createTiddlyElement(this.formElem,"div",null,"wizardBody"); this.footElem = createTiddlyElement(this.formElem,"div",null,"wizardFooter"); }; Wizard.prototype.clear = function() { removeChildren(this.bodyElem); }; Wizard.prototype.setButtons = function(buttonInfo,status) { removeChildren(this.footElem); for(var t=0; t<buttonInfo.length; t++) { createTiddlyButton(this.footElem,buttonInfo[t].caption,buttonInfo[t].tooltip,buttonInfo[t].onClick); insertSpacer(this.footElem); } if(typeof status == "string") { createTiddlyElement(this.footElem,"span",null,"status",status); } }; Wizard.prototype.addStep = function(stepTitle,html) { removeChildren(this.bodyElem); var w = createTiddlyElement(this.bodyElem,"div"); createTiddlyElement(w,"h2",null,null,stepTitle); var step = createTiddlyElement(w,"div",null,"wizardStep"); step.innerHTML = html; applyHtmlMacros(step,tiddler); }; Wizard.prototype.getElement = function(name) { return this.formElem.elements[name]; }; //-- //-- ListView gadget //-- var ListView = {}; // Create a listview ListView.create = function(place,listObject,listTemplate,callback,className) { var table = createTiddlyElement(place,"table",null,className ? className : "listView twtable"); var thead = createTiddlyElement(table,"thead"); var r = createTiddlyElement(thead,"tr"); for(var t=0; t<listTemplate.columns.length; t++) { var columnTemplate = listTemplate.columns[t]; var c = createTiddlyElement(r,"th"); var colType = ListView.columnTypes[columnTemplate.type]; if(colType && colType.createHeader) colType.createHeader(c,columnTemplate,t); } var tbody = createTiddlyElement(table,"tbody"); for(var rc=0; rc<listObject.length; rc++) { rowObject = listObject[rc]; r = createTiddlyElement(tbody,"tr"); for(c=0; c<listTemplate.rowClasses.length; c++) { if(rowObject[listTemplate.rowClasses[c].field]) addClass(r,listTemplate.rowClasses[c].className); } rowObject.rowElement = r; rowObject.colElements = {}; for(var cc=0; cc<listTemplate.columns.length; cc++) { c = createTiddlyElement(r,"td"); columnTemplate = listTemplate.columns[cc]; var field = columnTemplate.field; colType = ListView.columnTypes[columnTemplate.type]; if(colType && colType.createItem) colType.createItem(c,rowObject,field,columnTemplate,cc,rc); rowObject.colElements[field] = c; } } if(callback && listTemplate.actions) createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions); if(callback && listTemplate.buttons) { for(t=0; t<listTemplate.buttons.length; t++) { var a = listTemplate.buttons[t]; if(a && a.name != "") createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection)); } } return table; }; ListView.getCommandHandler = function(callback,name,allowEmptySelection) { return function(e) { var view = findRelated(this,"TABLE",null,"previousSibling"); var tiddlers = []; ListView.forEachSelector(view,function(e,rowName) { if(e.checked) tiddlers.push(rowName); }); if(tiddlers.length == 0 && !allowEmptySelection) { alert(config.messages.nothingSelected); } else { if(this.nodeName.toLowerCase() == "select") { callback(view,this.value,tiddlers); this.selectedIndex = 0; } else { callback(view,name,tiddlers); } } }; }; // Invoke a callback for each selector checkbox in the listview ListView.forEachSelector = function(view,callback) { var checkboxes = view.getElementsByTagName("input"); var hadOne = false; for(var t=0; t<checkboxes.length; t++) { var cb = checkboxes[t]; if(cb.getAttribute("type") == "checkbox") { var rn = cb.getAttribute("rowName"); if(rn) { callback(cb,rn); hadOne = true; } } } return hadOne; }; ListView.getSelectedRows = function(view) { var rowNames = []; ListView.forEachSelector(view,function(e,rowName) { if(e.checked) rowNames.push(rowName); }); return rowNames; }; ListView.columnTypes = {}; ListView.columnTypes.String = { createHeader: function(place,columnTemplate,col) { createTiddlyText(place,columnTemplate.title); }, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined) createTiddlyText(place,v); } }; ListView.columnTypes.WikiText = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined) wikify(v,place,null,null); } }; ListView.columnTypes.Tiddler = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined && v.title) createTiddlyPopup(place,v.title,config.messages.listView.tiddlerTooltip,v); } }; ListView.columnTypes.Size = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined) { var t = 0; while(t<config.messages.sizeTemplates.length-1 && v<config.messages.sizeTemplates[t].unit) t++; createTiddlyText(place,config.messages.sizeTemplates[t].template.format([Math.round(v/config.messages.sizeTemplates[t].unit)])); } } }; ListView.columnTypes.Link = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; var c = columnTemplate.text; if(v != undefined) createTiddlyText(createExternalLink(place,v),c ? c : v); } }; ListView.columnTypes.Date = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined) createTiddlyText(place,v.formatString(columnTemplate.dateFormat)); } }; ListView.columnTypes.StringList = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined) { for(var t=0; t<v.length; t++) { createTiddlyText(place,v[t]); createTiddlyElement(place,"br"); } } } }; ListView.columnTypes.Selector = { createHeader: function(place,columnTemplate,col) { createTiddlyCheckbox(place,null,false,this.onHeaderChange); }, createItem: function(place,listObject,field,columnTemplate,col,row) { var e = createTiddlyCheckbox(place,null,listObject[field],null); e.setAttribute("rowName",listObject[columnTemplate.rowName]); }, onHeaderChange: function(e) { var state = this.checked; var view = findRelated(this,"TABLE"); if(!view) return; ListView.forEachSelector(view,function(e,rowName) { e.checked = state; }); } }; ListView.columnTypes.Tags = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var tags = listObject[field]; createTiddlyText(place,String.encodeTiddlyLinkList(tags)); } }; ListView.columnTypes.Boolean = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { if(listObject[field] == true) createTiddlyText(place,columnTemplate.trueText); if(listObject[field] == false) createTiddlyText(place,columnTemplate.falseText); } }; ListView.columnTypes.TagCheckbox = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange); e.setAttribute("tiddler",listObject.title); e.setAttribute("tag",columnTemplate.tag); }, onChange : function(e) { var tag = this.getAttribute("tag"); var tiddler = this.getAttribute("tiddler"); store.setTiddlerTag(tiddler,this.checked,tag); } }; ListView.columnTypes.TiddlerLink = { createHeader: ListView.columnTypes.String.createHeader, createItem: function(place,listObject,field,columnTemplate,col,row) { var v = listObject[field]; if(v != undefined) { var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null); createTiddlyText(link,listObject[field]); } } }; //-- //-- Augmented methods for the JavaScript Number(), Array(), String() and Date() objects //-- // Clamp a number to a range Number.prototype.clamp = function(min,max) { var c = this; if(c < min) c = min; if(c > max) c = max; return c; }; // Add indexOf function if browser does not support it if(!Array.indexOf) { Array.prototype.indexOf = function(item,from) { if(!from) from = 0; for(var i=from; i<this.length; i++) { if(this[i] === item) return i; } return -1; };} // Find an entry in a given field of the members of an array Array.prototype.findByField = function(field,value) { for(var t=0; t<this.length; t++) { if(this[t][field] == value) return t; } return null; }; // Return whether an entry exists in an array Array.prototype.contains = function(item) { return this.indexOf(item) != -1; }; // Adds, removes or toggles a particular value within an array // value - value to add // mode - +1 to add value, -1 to remove value, 0 to toggle it Array.prototype.setItem = function(value,mode) { var p = this.indexOf(value); if(mode == 0) mode = (p == -1) ? +1 : -1; if(mode == +1) { if(p == -1) this.push(value); } else if(mode == -1) { if(p != -1) this.splice(p,1); } }; // Return whether one of a list of values exists in an array Array.prototype.containsAny = function(items) { for(var i=0; i<items.length; i++) { if(this.indexOf(items[i]) != -1) return true; } return false; }; // Return whether all of a list of values exists in an array Array.prototype.containsAll = function(items) { for(var i = 0; i<items.length; i++) { if(this.indexOf(items[i]) == -1) return false; } return true; }; // Push a new value into an array only if it is not already present in the array. If the optional unique parameter is false, it reverts to a normal push Array.prototype.pushUnique = function(item,unique) { if(unique === false) { this.push(item); } else { if(this.indexOf(item) == -1) this.push(item); } }; Array.prototype.remove = function(item) { var p = this.indexOf(item); if(p != -1) this.splice(p,1); }; if(!Array.prototype.map) { Array.prototype.map = function(fn,thisObj) { var scope = thisObj || window; var a = []; for(var i=0, j=this.length; i < j; ++i) { a.push(fn.call(scope,this[i],i,this)); } return a; };} // Get characters from the right end of a string String.prototype.right = function(n) { return n < this.length ? this.slice(this.length-n) : this; }; // Trim whitespace from both ends of a string String.prototype.trim = function() { return this.replace(/^\s*|\s*$/g,""); }; // Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor") String.prototype.unDash = function() { var s = this.split("-"); if(s.length > 1) { for(var t=1; t<s.length; t++) s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1); } return s.join(""); }; // Substitute substrings from an array into a format string that includes '%1'-type specifiers String.prototype.format = function(substrings) { var subRegExp = /(?:%(\d+))/mg; var currPos = 0; var r = []; do { var match = subRegExp.exec(this); if(match && match[1]) { if(match.index > currPos) r.push(this.substring(currPos,match.index)); r.push(substrings[parseInt(match[1])]); currPos = subRegExp.lastIndex; } } while(match); if(currPos < this.length) r.push(this.substring(currPos,this.length)); return r.join(""); }; // Escape any special RegExp characters with that character preceded by a backslash String.prototype.escapeRegExp = function() { var s = "\\^$*+?()=!|,{}[]."; var c = this; for(var t=0; t<s.length; t++) c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1)); return c; }; // Convert "\" to "\s", newlines to "\n" (and remove carriage returns) String.prototype.escapeLineBreaks = function() { return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,""); }; // Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns) String.prototype.unescapeLineBreaks = function() { return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,""); }; // Convert & to "&", < to "<", > to ">" and " to """ String.prototype.htmlEncode = function() { return this.replace(/&/mg,"&").replace(/</mg,"<").replace(/>/mg,">").replace(/\"/mg,"""); }; // Convert "&" to &, "<" to <, ">" to > and """ to " String.prototype.htmlDecode = function() { return this.replace(/</mg,"<").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&"); }; // Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org String.prototype.toJSONString = function() { var m = { '\b': '\\b', '\f': '\\f', '\n': '\\n', '\r': '\\r', '\t': '\\t', '"' : '\\"', '\\': '\\\\' }; var replaceFn = function(a,b) { var c = m[b]; if(c) return c; c = b.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }; if(/["\\\x00-\x1f]/.test(this)) return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"'; return '"' + this + '"'; }; // Parse a space-separated string of name:value parameters // The result is an array of objects: // result[0] = object with a member for each parameter name, value of that member being an array of values // result[1..n] = one object for each parameter, with 'name' and 'value' members String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults) { var parseToken = function(match,p) { var n; if(match[p]) // Double quoted n = match[p]; else if(match[p+1]) // Single quoted n = match[p+1]; else if(match[p+2]) // Double-square-bracket quoted n = match[p+2]; else if(match[p+3]) // Double-brace quoted try { n = match[p+3]; if(allowEval) n = window.eval(n); } catch(ex) { throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(ex); } else if(match[p+4]) // Unquoted n = match[p+4]; else if(match[p+5]) // empty quote n = ""; return n; }; var r = [{}]; var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")"; var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')"; var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])"; var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})"; var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)"; var emptyQuote = "((?:\"\")|(?:''))"; var skipSpace = "(?:\\s*)"; var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")"; var re = noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg"); var params = []; do { var match = re.exec(this); if(match) { var n = parseToken(match,1); if(noNames) { r.push({name:"",value:n}); } else { var v = parseToken(match,8); if(v == null && defaultName) { v = n; n = defaultName; } else if(v == null && defaultValue) { v = defaultValue; } r.push({name:n,value:v}); if(cascadeDefaults) { defaultName = n; defaultValue = v; } } } } while(match); // Summarise parameters into first element for(var t=1; t<r.length; t++) { if(r[0][r[t].name]) r[0][r[t].name].push(r[t].value); else r[0][r[t].name] = [r[t].value]; } return r; }; // Process a string list of macro parameters into an array. Parameters can be quoted with "", '', // [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in // an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name. String.prototype.readMacroParams = function() { var p = this.parseParams("list",null,true,true); var n = []; for(var t=1; t<p.length; t++) n.push(p[t].value); return n; }; // Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]] String.prototype.readBracketedList = function(unique) { var p = this.parseParams("list",null,false,true); var n = []; for(var t=1; t<p.length; t++) { if(p[t].value) n.pushUnique(p[t].value,unique); } return n; }; // Returns array with start and end index of chunk between given start and end marker, or undefined. String.prototype.getChunkRange = function(start,end) { var s = this.indexOf(start); if(s != -1) { s += start.length; var e = this.indexOf(end,s); if(e != -1) return [s,e]; } }; // Replace a chunk of a string given start and end markers String.prototype.replaceChunk = function(start,end,sub) { var r = this.getChunkRange(start,end); return r ? this.substring(0,r[0]) + sub + this.substring(r[1]) : this; }; // Returns a chunk of a string between start and end markers, or undefined String.prototype.getChunk = function(start,end) { var r = this.getChunkRange(start,end); if(r) return this.substring(r[0],r[1]); }; // Static method to bracket a string with double square brackets if it contains a space String.encodeTiddlyLink = function(title) { return title.indexOf(" ") == -1 ? title : "[[" + title + "]]"; }; // Static method to encodeTiddlyLink for every item in an array and join them with spaces String.encodeTiddlyLinkList = function(list) { if(list) { var results = []; for(var t=0; t<list.length; t++) results.push(String.encodeTiddlyLink(list[t])); return results.join(" "); } else { return ""; } }; // Convert a string as a sequence of name:"value" pairs into a hashmap String.prototype.decodeHashMap = function() { var fields = this.parseParams("anon","",false); var r = {}; for(var t=1; t<fields.length; t++) r[fields[t].name] = fields[t].value; return r; }; // Static method to encode a hashmap into a name:"value"... string String.encodeHashMap = function(hashmap) { var r = []; for(var t in hashmap) r.push(t + ':"' + hashmap[t] + '"'); return r.join(" "); }; // Static method to left-pad a string with 0s to a certain width String.zeroPad = function(n,d) { var s = n.toString(); if(s.length < d) s = "000000000000000000000000000".substr(0,d-s.length) + s; return s; }; String.prototype.startsWith = function(prefix) { return !prefix || this.substring(0,prefix.length) == prefix; }; // Returns the first value of the given named parameter. function getParam(params,name,defaultValue) { if(!params) return defaultValue; var p = params[0][name]; return p ? p[0] : defaultValue; } // Returns the first value of the given boolean named parameter. function getFlag(params,name,defaultValue) { return !!getParam(params,name,defaultValue); } // Substitute date components into a string Date.prototype.formatString = function(template) { var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2)); t = t.replace(/hh12/g,this.getHours12()); t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2)); t = t.replace(/hh/g,this.getHours()); t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]); t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2)); t = t.replace(/mm/g,this.getMinutes()); t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2)); t = t.replace(/ss/g,this.getSeconds()); t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase()); t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase()); t = t.replace(/wYYYY/g,this.getYearForWeekNo()); t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2)); t = t.replace(/YYYY/g,this.getFullYear()); t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2)); t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]); t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2)); t = t.replace(/MM/g,this.getMonth()+1); t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2)); t = t.replace(/WW/g,this.getWeek()); t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]); t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]); t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2)); t = t.replace(/DDth/g,this.getDate()+this.daySuffix()); t = t.replace(/DD/g,this.getDate()); var tz = this.getTimezoneOffset(); var atz = Math.abs(tz); t = t.replace(/TZD/g,(tz < 0 ? '+' : '-') + String.zeroPad(Math.floor(atz / 60),2) + ':' + String.zeroPad(atz % 60,2)); return t; }; Date.prototype.getWeek = function() { var dt = new Date(this.getTime()); var d = dt.getDay(); if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7 dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000); return Math.floor(n/7)+1; }; Date.prototype.getYearForWeekNo = function() { var dt = new Date(this.getTime()); var d = dt.getDay(); if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7 dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week return dt.getFullYear(); }; Date.prototype.getHours12 = function() { var h = this.getHours(); return h > 12 ? h-12 : ( h > 0 ? h : 12 ); }; Date.prototype.getAmPm = function() { return this.getHours() >= 12 ? config.messages.dates.pm : config.messages.dates.am; }; Date.prototype.daySuffix = function() { return config.messages.dates.daySuffixes[this.getDate()-1]; }; // Convert a date to local YYYYMMDDHHMM string format Date.prototype.convertToLocalYYYYMMDDHHMM = function() { return this.getFullYear() + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2); }; // Convert a date to UTC YYYYMMDDHHMM string format Date.prototype.convertToYYYYMMDDHHMM = function() { return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2); }; // Convert a date to UTC YYYYMMDD.HHMMSSMMM string format Date.prototype.convertToYYYYMMDDHHMMSSMMM = function() { return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),4); }; // Static method to create a date from a UTC YYYYMMDDHHMM format string Date.convertFromYYYYMMDDHHMM = function(d) { var hh = d.substr(8,2) || "00"; var mm = d.substr(10,2) || "00"; return new Date(Date.UTC(parseInt(d.substr(0,4),10), parseInt(d.substr(4,2),10)-1, parseInt(d.substr(6,2),10), parseInt(hh,10), parseInt(mm,10),0,0)); }; //-- //-- 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 function add32(a,b) { var lsw=(a&0xFFFF)+(b&0xFFFF); var msw=(a>>16)+(b>>16)+(lsw>>16); return (msw<<16)|(lsw&0xFFFF); } function AA(a,b,c,d,e) { b=(b>>>27)|(b<<5); 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); } function RR(w,j) { var n=w[j-3]^w[j-8]^w[j-14]^w[j-16]; return (n>>>31)|(n<<1); } var len=blen*8; x[len>>5] |= 0x80 << (24-len%32); 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=0; var t; var a=h0; var b=h1; var c=h2; var d=h3; var e=h4; while(j<16) { w[j]=x[i+j]; t=AA(e,a,d^(b&(c^d)),w[j],k1); e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++; } while(j<20) { w[j]=RR(w,j); t=AA(e,a,d^(b&(c^d)),w[j],k1); e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++; } while(j<40) { w[j]=RR(w,j); t=AA(e,a,b^c^d,w[j],k2); e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++; } while(j<60) { w[j]=RR(w,j); t=AA(e,a,(b&c)|(d&(b|c)),w[j],k3); e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++; } while(j<80) { w[j]=RR(w,j); t=AA(e,a,b^c^d,w[j],k4); e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++; } h0=add32(h0,a); h1=add32(h1,b); h2=add32(h2,c); h3=add32(h3,d); h4=add32(h4,e); } return [h0,h1,h2,h3,h4]; }; //-- //-- RGB colour object //-- // Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values function RGB(r,g,b) { this.r = 0; this.g = 0; this.b = 0; if(typeof r == "string") { if(r.substr(0,1) == "#") { if(r.length == 7) { this.r = parseInt(r.substr(1,2),16)/255; this.g = parseInt(r.substr(3,2),16)/255; this.b = parseInt(r.substr(5,2),16)/255; } else { this.r = parseInt(r.substr(1,1),16)/15; this.g = parseInt(r.substr(2,1),16)/15; this.b = parseInt(r.substr(3,1),16)/15; } } else { var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/; var c = r.match(rgbPattern); if(c) { this.r = parseInt(c[1],10)/255; this.g = parseInt(c[2],10)/255; this.b = parseInt(c[3],10)/255; } } } else { this.r = r; this.g = g; this.b = b; } return this; } // Mixes this colour with another in a specified proportion // c = other colour to mix // f = 0..1 where 0 is this colour and 1 is the new colour // Returns an RGB object RGB.prototype.mix = function(c,f) { return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f); }; // Return an rgb colour as a #rrggbb format hex string RGB.prototype.toString = function() { return "#" + ("0" + Math.floor(this.r.clamp(0,1) * 255).toString(16)).right(2) + ("0" + Math.floor(this.g.clamp(0,1) * 255).toString(16)).right(2) + ("0" + Math.floor(this.b.clamp(0,1) * 255).toString(16)).right(2); }; //-- //-- DOM utilities - many derived from www.quirksmode.org //-- function drawGradient(place,horiz,locolors,hicolors) { if(!hicolors) hicolors = locolors; for(var t=0; t<= 100; t+=2) { var bar = document.createElement("div"); place.appendChild(bar); bar.style.position = "absolute"; bar.style.left = horiz ? t + "%" : 0; bar.style.top = horiz ? 0 : t + "%"; bar.style.width = horiz ? (101-t) + "%" : "100%"; bar.style.height = horiz ? "100%" : (101-t) + "%"; bar.style.zIndex = -1; var p = t/100*(locolors.length-1); bar.style.backgroundColor = hicolors[Math.floor(p)].mix(locolors[Math.ceil(p)],p-Math.floor(p)).toString(); } } function createTiddlyText(parent,text) { return parent.appendChild(document.createTextNode(text)); } function createTiddlyCheckbox(parent,caption,checked,onChange) { var cb = document.createElement("input"); cb.setAttribute("type","checkbox"); cb.onclick = onChange; parent.appendChild(cb); cb.checked = checked; cb.className = "chkOptionInput"; if(caption) wikify(caption,parent); return cb; } function createTiddlyElement(parent,element,id,className,text,attribs) { var e = document.createElement(element); if(className != null) e.className = className; if(id != null) e.setAttribute("id",id); if(text != null) e.appendChild(document.createTextNode(text)); if(attribs) { for(var n in attribs) { e.setAttribute(n,attribs[n]); } } if(parent != null) parent.appendChild(e); return e; } function addEvent(obj,type,fn) { if(obj.attachEvent) { obj['e'+type+fn] = fn; obj[type+fn] = function(){obj['e'+type+fn](window.event);}; obj.attachEvent('on'+type,obj[type+fn]); } else { obj.addEventListener(type,fn,false); } } function removeEvent(obj,type,fn) { if(obj.detachEvent) { obj.detachEvent('on'+type,obj[type+fn]); obj[type+fn] = null; } else { obj.removeEventListener(type,fn,false); } } function addClass(e,className) { var currClass = e.className.split(" "); if(currClass.indexOf(className) == -1) e.className += " " + className; } function removeClass(e,className) { var currClass = e.className.split(" "); var i = currClass.indexOf(className); while(i != -1) { currClass.splice(i,1); i = currClass.indexOf(className); } e.className = currClass.join(" "); } function hasClass(e,className) { if(e.className) { if(e.className.split(" ").indexOf(className) != -1) return true; } return false; } // Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode) function findRelated(e,value,name,relative) { name = name ? name : "tagName"; relative = relative ? relative : "parentNode"; if(name == "className") { while(e && !hasClass(e,value)) { e = e[relative]; } } else { while(e && e[name] != value) { e = e[relative]; } } return e; } // Resolve the target object of an event function resolveTarget(e) { var obj; if(e.target) obj = e.target; else if(e.srcElement) obj = e.srcElement; if(obj.nodeType == 3) // defeat Safari bug obj = obj.parentNode; return obj; } // Prevent an event from bubbling function stopEvent(e) { var ev = e ? e : window.event; ev.cancelBubble = true; if(ev.stopPropagation) ev.stopPropagation(); return false; } // Return the content of an element as plain text with no formatting function getPlainText(e) { var text = ""; if(e.innerText) text = e.innerText; else if(e.textContent) text = e.textContent; return text; } // Get the scroll position for window.scrollTo necessary to scroll a given element into view function ensureVisible(e) { var posTop = findPosY(e); var posBot = posTop + e.offsetHeight; var winTop = findScrollY(); var winHeight = findWindowHeight(); var winBot = winTop + winHeight; if(posTop < winTop) { return posTop; } else if(posBot > winBot) { if(e.offsetHeight < winHeight) return posTop - (winHeight - e.offsetHeight); else return posTop; } else { return winTop; } } // Get the current width of the display window function findWindowWidth() { return window.innerWidth ? window.innerWidth : document.documentElement.clientWidth; } // Get the current height of the display window function findWindowHeight() { return window.innerHeight ? window.innerHeight : document.documentElement.clientHeight; } // Get the current horizontal page scroll position function findScrollX() { return window.scrollX ? window.scrollX : document.documentElement.scrollLeft; } // Get the current vertical page scroll position function findScrollY() { return window.scrollY ? window.scrollY : document.documentElement.scrollTop; } function findPosX(obj) { var curleft = 0; while(obj.offsetParent) { curleft += obj.offsetLeft; obj = obj.offsetParent; } return curleft; } function findPosY(obj) { var curtop = 0; while(obj.offsetParent) { curtop += obj.offsetTop; obj = obj.offsetParent; } return curtop; } // Blur a particular element function blurElement(e) { if(e != null && e.focus && e.blur) { e.focus(); e.blur(); } } // Create a non-breaking space function insertSpacer(place) { var e = document.createTextNode(String.fromCharCode(160)); if(place) place.appendChild(e); return e; } // Remove all children of a node function removeChildren(e) { while(e && e.hasChildNodes()) removeNode(e.firstChild); } // Remove a node and all it's children function removeNode(e) { scrubNode(e); e.parentNode.removeChild(e); } // Remove any event handlers or non-primitve custom attributes function scrubNode(e) { if(!config.browser.isIE) return; var att = e.attributes; if(att) { for(var t=0; t<att.length; t++) { var n = att[t].name; if(n !== 'style' && (typeof e[n] === 'function' || (typeof e[n] === 'object' && e[n] != null))) { try { e[n] = null; } catch(ex) { } } } } var c = e.firstChild; while(c) { scrubNode(c); c = c.nextSibling; } } // Add a stylesheet, replacing any previous custom stylesheet function setStylesheet(s,id,doc) { if(!id) id = "customStyleSheet"; if(!doc) doc = document; var n = doc.getElementById(id); if(doc.createStyleSheet) { // Test for IE's non-standard createStyleSheet method if(n) n.parentNode.removeChild(n); // This failed without the doc.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd"," <style id='" + id + "'>" + s + "</style>"); } else { if(n) { n.replaceChild(doc.createTextNode(s),n.firstChild); } else { n = doc.createElement("style"); n.type = "text/css"; n.id = id; n.appendChild(doc.createTextNode(s)); doc.getElementsByTagName("head")[0].appendChild(n); } } } function removeStyleSheet(id) { var e = document.getElementById(id); if(e) e.parentNode.removeChild(e); } // Force the browser to do a document reflow when needed to workaround browser bugs function forceReflow() { if(config.browser.isGecko) { setStylesheet("body {top:0px;margin-top:0px;}","forceReflow"); setTimeout(function() {setStylesheet("","forceReflow");},1); } } // Replace the current selection of a textarea or text input and scroll it into view function replaceSelection(e,text) { if(e.setSelectionRange) { var oldpos = e.selectionStart; var isRange = e.selectionEnd > e.selectionStart; e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionEnd); e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + text.length); var linecount = e.value.split('\n').length; var thisline = e.value.substr(0,e.selectionStart).split('\n').length-1; e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / linecount); } else if(document.selection) { var range = document.selection.createRange(); if(range.parentElement() == e) { var isCollapsed = range.text == ""; range.text = text; if(!isCollapsed) { range.moveStart('character', -text.length); range.select(); } } } } // Returns the text of the given (text) node, possibly merging subsequent text nodes function getNodeText(e) { var t = ""; while(e && e.nodeName == "#text") { t += e.nodeValue; e = e.nextSibling; } return t; } // Returns true if the element e has a given ancestor element function isDescendant(e,ancestor) { while(e) { if(e === ancestor) return true; e = e.parentNode; } return false; } //-- //-- LoaderBase and SaverBase //-- function LoaderBase() {} LoaderBase.prototype.loadTiddler = function(store,node,tiddlers) { var title = this.getTitle(store,node); if(safeMode && store.isShadowTiddler(title)) return; if(title) { var tiddler = store.createTiddler(title); this.internalizeTiddler(store,tiddler,title,node); tiddlers.push(tiddler); } }; LoaderBase.prototype.loadTiddlers = function(store,nodes) { var tiddlers = []; for(var t = 0; t < nodes.length; t++) { try { this.loadTiddler(store,nodes[t],tiddlers); } catch(ex) { showException(ex,config.messages.tiddlerLoadError.format([this.getTitle(store,nodes[t])])); } } return tiddlers; }; function SaverBase() {} SaverBase.prototype.externalize = function(store) { var results = []; var tiddlers = store.getTiddlers("title"); for(var t = 0; t < tiddlers.length; t++) { if(!tiddlers[t].doNotSave()) results.push(this.externalizeTiddler(store, tiddlers[t])); } return results.join("\n"); }; //-- //-- TW21Loader (inherits from LoaderBase) //-- function TW21Loader() {} TW21Loader.prototype = new LoaderBase(); TW21Loader.prototype.getTitle = function(store,node) { var title = null; if(node.getAttribute) { title = node.getAttribute("title"); if(!title) title = node.getAttribute("tiddler"); } if(!title && node.id) { var lenPrefix = store.idPrefix.length; if(node.id.substr(0,lenPrefix) == store.idPrefix) title = node.id.substr(lenPrefix); } return title; }; TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node) { var e = node.firstChild; var text = null; if(node.getAttribute("tiddler")) { text = getNodeText(e).unescapeLineBreaks(); } else { while(e.nodeName!="PRE" && e.nodeName!="pre") { e = e.nextSibling; } text = e.innerHTML.replace(/\r/mg,"").htmlDecode(); } var modifier = node.getAttribute("modifier"); var c = node.getAttribute("created"); var m = node.getAttribute("modified"); var created = c ? Date.convertFromYYYYMMDDHHMM(c) : version.date; var modified = m ? Date.convertFromYYYYMMDDHHMM(m) : created; var tags = node.getAttribute("tags"); var fields = {}; var attrs = node.attributes; for(var i = attrs.length-1; i >= 0; i--) { var name = attrs[i].name; if(attrs[i].specified && !TiddlyWiki.isStandardField(name)) { fields[name] = attrs[i].value.unescapeLineBreaks(); } } tiddler.assign(title,text,modifier,modified,tags,created,fields); return tiddler; }; //-- //-- TW21Saver (inherits from SaverBase) //-- function TW21Saver() {} TW21Saver.prototype = new SaverBase(); TW21Saver.prototype.externalizeTiddler = function(store,tiddler) { try { var extendedAttributes = ""; var usePre = config.options.chkUsePreForStorage; store.forEachField(tiddler, function(tiddler,fieldName,value) { // don't store stuff from the temp namespace if(typeof value != "string") value = ""; if(!fieldName.match(/^temp\./)) extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]); },true); var created = tiddler.created; var modified = tiddler.modified; var attributes = tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : ""; attributes += (usePre && created == version.date) ? "" :' created="' + created.convertToYYYYMMDDHHMM() + '"'; attributes += (usePre && modified == created) ? "" : ' modified="' + modified.convertToYYYYMMDDHHMM() +'"'; var tags = tiddler.getTags(); if(!usePre || tags) attributes += ' tags="' + tags.htmlEncode() + '"'; return ('<div %0="%1"%2%3>%4</'+'div>').format([ usePre ? "title" : "tiddler", tiddler.title.htmlEncode(), attributes, extendedAttributes, usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode() ]); } catch (ex) { throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title])); } }; //]]> </script> <script type="text/javascript"> //<![CDATA[ if(useJavaSaver) document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>"); //]]> </script> <!--POST-SCRIPT-START--> <!--POST-SCRIPT-END--> </body> </html>