• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

MIST (Media Integration Standard Toolkit)


Commit MetaInfo

修订版47d254088a22109a8c7a5e91bfe355c6f51d5f68 (tree)
时间2014-05-02 08:57:15
作者Stavros Vagionitis <stavros.vagionitis@gmai...>
CommiterStavros Vagionitis

Log Message

Add a notebook, tiddly wiki.

更改概述

差异

Binary files /dev/null and b/notebook/TiddlySaver.jar differ
--- /dev/null
+++ b/notebook/empty.html
@@ -0,0 +1,10149 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3+<head>
4+<script id="versionArea" type="text/javascript">
5+//<![CDATA[
6+var version = {title: "TiddlyWiki", major: 2, minor: 8, revision: 1, date: new Date("June 23, 2013"), extensions: {}};
7+
8+//]]>
9+</script>
10+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
11+<meta name="copyright" content="
12+TiddlyWiki created by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
13+
14+Copyright (c) Jeremy Ruston 2004-2007
15+Copyright (c) UnaMesa Association 2007-2012
16+
17+Redistribution and use in source and binary forms, with or without modification,
18+are permitted provided that the following conditions are met:
19+
20+Redistributions of source code must retain the above copyright notice, this
21+list of conditions and the following disclaimer.
22+
23+Redistributions in binary form must reproduce the above copyright notice, this
24+list of conditions and the following disclaimer in the documentation and/or other
25+materials provided with the distribution.
26+
27+Neither the name of the UnaMesa Association nor the names of its contributors may be
28+used to endorse or promote products derived from this software without specific
29+prior written permission.
30+
31+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY
32+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
34+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
36+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
40+DAMAGE.
41+
42+" />
43+<!--PRE-HEAD-START-->
44+<!--{{{-->
45+<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
46+<!--}}}-->
47+
48+<!--PRE-HEAD-END-->
49+<title> My TiddlyWiki - a reusable non-linear personal web notebook </title>
50+<style id="styleArea" type="text/css">
51+#saveTest {display:none;}
52+#messageArea {display:none;}
53+#copyright {display:none;}
54+#storeArea {display:none;}
55+#storeArea div {padding:0.5em; margin:1em 0em 0em 0em; border-color:#fff #666 #444 #ddd; border-style:solid; border-width:2px; overflow:auto;}
56+#shadowArea {display:none;}
57+#javascriptWarning {width:100%; text-align:center; font-weight:bold; background-color:#dd1100; color:#fff; padding:1em 0em;}
58+
59+</style>
60+<!--POST-HEAD-START-->
61+
62+<!--POST-HEAD-END-->
63+</head>
64+<body onload="main();" onunload="if(window.unload) unload();">
65+<!--PRE-BODY-START-->
66+
67+<!--PRE-BODY-END-->
68+<div id="copyright">
69+Welcome to TiddlyWiki created by Jeremy Ruston; Copyright &copy; 2004-2007 Jeremy Ruston, Copyright &copy; 2007-2011 UnaMesa Association
70+</div>
71+<noscript>
72+<div id="javascriptWarning">
73+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.
74+</div>
75+
76+</noscript>
77+<div id="saveTest"></div>
78+<div id="backstageCloak"></div>
79+<div id="backstageButton"></div>
80+<div id="backstageArea"><div id="backstageToolbar"></div></div>
81+<div id="backstage">
82+ <div id="backstagePanel"></div>
83+</div>
84+<div id="contentWrapper"></div>
85+<div id="contentStash"></div>
86+<div id="shadowArea">
87+<div title="ColorPalette">
88+<pre>Background: #fff
89+Foreground: #000
90+PrimaryPale: #8cf
91+PrimaryLight: #18f
92+PrimaryMid: #04b
93+PrimaryDark: #014
94+SecondaryPale: #ffc
95+SecondaryLight: #fe8
96+SecondaryMid: #db4
97+SecondaryDark: #841
98+TertiaryPale: #eee
99+TertiaryLight: #ccc
100+TertiaryMid: #999
101+TertiaryDark: #666
102+Error: #f88
103+</pre>
104+</div>
105+<div title="EditTemplate">
106+<pre>&lt;!--{{{--&gt;
107+&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'&gt;&lt;/div&gt;
108+&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
109+&lt;div class='editor' macro='edit title'&gt;&lt;/div&gt;
110+&lt;div macro='annotations'&gt;&lt;/div&gt;
111+&lt;div class='editor' macro='edit text'&gt;&lt;/div&gt;
112+&lt;div class='editor' macro='edit tags'&gt;&lt;/div&gt;&lt;div class='editorFooter'&gt;&lt;span macro='message views.editor.tagPrompt'&gt;&lt;/span&gt;&lt;span macro='tagChooser excludeLists'&gt;&lt;/span&gt;&lt;/div&gt;
113+&lt;!--}}}--&gt;
114+</pre>
115+</div>
116+<div title="GettingStarted">
117+<pre>To get started with this blank [[TiddlyWiki]], you'll need to modify the following tiddlers:
118+* [[SiteTitle]] &amp; [[SiteSubtitle]]: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
119+* [[MainMenu]]: The menu (usually on the left)
120+* [[DefaultTiddlers]]: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
121+You'll also need to enter your username for signing your edits: &lt;&lt;option txtUserName&gt;&gt;
122+</pre>
123+</div>
124+<div title="ImportTiddlers">
125+<pre>&lt;&lt;importTiddlers&gt;&gt;
126+</pre>
127+</div>
128+<div title="MarkupPreHead">
129+<pre>&lt;!--{{{--&gt;
130+&lt;link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' /&gt;
131+&lt;!--}}}--&gt;
132+</pre>
133+</div>
134+<div title="OptionsPanel">
135+<pre>These [[InterfaceOptions]] for customising [[TiddlyWiki]] are saved in your browser
136+
137+Your username for signing your edits. Write it as a [[WikiWord]] (eg [[JoeBloggs]])
138+
139+&lt;&lt;option txtUserName&gt;&gt;
140+&lt;&lt;option chkSaveBackups&gt;&gt; [[SaveBackups]]
141+&lt;&lt;option chkAutoSave&gt;&gt; [[AutoSave]]
142+&lt;&lt;option chkRegExpSearch&gt;&gt; [[RegExpSearch]]
143+&lt;&lt;option chkCaseSensitiveSearch&gt;&gt; [[CaseSensitiveSearch]]
144+&lt;&lt;option chkAnimate&gt;&gt; [[EnableAnimations]]
145+
146+----
147+Also see [[AdvancedOptions]]
148+</pre>
149+</div>
150+<div title="PageTemplate">
151+<pre>&lt;!--{{{--&gt;
152+&lt;div class='header' role='banner' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'&gt;
153+&lt;div class='headerShadow'&gt;
154+&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
155+&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
156+&lt;/div&gt;
157+&lt;div class='headerForeground'&gt;
158+&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
159+&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
160+&lt;/div&gt;
161+&lt;/div&gt;
162+&lt;div id='mainMenu' role='navigation' refresh='content' tiddler='MainMenu'&gt;&lt;/div&gt;
163+&lt;div id='sidebar'&gt;
164+&lt;div id='sidebarOptions' role='navigation' refresh='content' tiddler='SideBarOptions'&gt;&lt;/div&gt;
165+&lt;div id='sidebarTabs' role='complementary' refresh='content' force='true' tiddler='SideBarTabs'&gt;&lt;/div&gt;
166+&lt;/div&gt;
167+&lt;div id='displayArea' role='main'&gt;
168+&lt;div id='messageArea'&gt;&lt;/div&gt;
169+&lt;div id='tiddlerDisplay'&gt;&lt;/div&gt;
170+&lt;/div&gt;
171+&lt;!--}}}--&gt;
172+</pre>
173+</div>
174+<div title="StyleSheetColors">
175+<pre>/*{{{*/
176+body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
177+
178+a {color:[[ColorPalette::PrimaryMid]];}
179+a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
180+a img {border:0;}
181+
182+h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
183+h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
184+h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}
185+
186+.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
187+.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
188+.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}
189+
190+.header {background:[[ColorPalette::PrimaryMid]];}
191+.headerShadow {color:[[ColorPalette::Foreground]];}
192+.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
193+.headerForeground {color:[[ColorPalette::Background]];}
194+.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}
195+
196+.tabSelected {color:[[ColorPalette::PrimaryDark]];
197+ background:[[ColorPalette::TertiaryPale]];
198+ border-left:1px solid [[ColorPalette::TertiaryLight]];
199+ border-top:1px solid [[ColorPalette::TertiaryLight]];
200+ border-right:1px solid [[ColorPalette::TertiaryLight]];
201+}
202+.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
203+.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
204+.tabContents .button {border:0;}
205+
206+#sidebar {}
207+#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
208+#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
209+#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
210+#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
211+#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}
212+
213+.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
214+.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
215+.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
216+.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
217+ border:1px solid [[ColorPalette::PrimaryMid]];}
218+.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
219+.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
220+.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
221+.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
222+ border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
223+.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
224+.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
225+ border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
226+
227+.wizard .notChanged {background:transparent;}
228+.wizard .changedLocally {background:#80ff80;}
229+.wizard .changedServer {background:#8080ff;}
230+.wizard .changedBoth {background:#ff8080;}
231+.wizard .notFound {background:#ffff80;}
232+.wizard .putToServer {background:#ff80ff;}
233+.wizard .gotFromServer {background:#80ffff;}
234+
235+#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
236+#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}
237+
238+.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}
239+
240+.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]];}
241+.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
242+.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
243+.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
244+.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
245+.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
246+.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
247+.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
248+
249+.tiddler .defaultCommand {font-weight:bold;}
250+
251+.shadow .title {color:[[ColorPalette::TertiaryDark]];}
252+
253+.title {color:[[ColorPalette::SecondaryDark]];}
254+.subtitle {color:[[ColorPalette::TertiaryDark]];}
255+
256+.toolbar {color:[[ColorPalette::PrimaryMid]];}
257+.toolbar a {color:[[ColorPalette::TertiaryLight]];}
258+.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
259+.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}
260+
261+.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
262+.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
263+.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
264+.tagging .button, .tagged .button {border:none;}
265+
266+.footer {color:[[ColorPalette::TertiaryLight]];}
267+.selected .footer {color:[[ColorPalette::TertiaryMid]];}
268+
269+.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
270+.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
271+.lowlight {background:[[ColorPalette::TertiaryLight]];}
272+
273+.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}
274+
275+.imageLink, #displayArea .imageLink {background:transparent;}
276+
277+.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}
278+
279+.viewer .listTitle {list-style-type:none; margin-left:-2em;}
280+.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
281+.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}
282+
283+.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
284+.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
285+.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}
286+
287+.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
288+.viewer code {color:[[ColorPalette::SecondaryDark]];}
289+.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}
290+
291+.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}
292+
293+.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
294+.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
295+.editorFooter {color:[[ColorPalette::TertiaryMid]];}
296+.readOnly {background:[[ColorPalette::TertiaryPale]];}
297+
298+#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
299+#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
300+#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
301+#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
302+#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
303+#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
304+#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
305+.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
306+.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
307+#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:alpha(opacity=60);}
308+/*}}}*/
309+</pre>
310+</div>
311+<div title="StyleSheetLayout">
312+<pre>/*{{{*/
313+* html .tiddler {height:1%;}
314+
315+body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}
316+
317+h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
318+h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
319+h4,h5,h6 {margin-top:1em;}
320+h1 {font-size:1.35em;}
321+h2 {font-size:1.25em;}
322+h3 {font-size:1.1em;}
323+h4 {font-size:1em;}
324+h5 {font-size:.9em;}
325+
326+hr {height:1px;}
327+
328+a {text-decoration:none;}
329+
330+dt {font-weight:bold;}
331+
332+ol {list-style-type:decimal;}
333+ol ol {list-style-type:lower-alpha;}
334+ol ol ol {list-style-type:lower-roman;}
335+ol ol ol ol {list-style-type:decimal;}
336+ol ol ol ol ol {list-style-type:lower-alpha;}
337+ol ol ol ol ol ol {list-style-type:lower-roman;}
338+ol ol ol ol ol ol ol {list-style-type:decimal;}
339+
340+.txtOptionInput {width:11em;}
341+
342+#contentWrapper .chkOptionInput {border:0;}
343+
344+.externalLink {text-decoration:underline;}
345+
346+.indent {margin-left:3em;}
347+.outdent {margin-left:3em; text-indent:-3em;}
348+code.escaped {white-space:nowrap;}
349+
350+.tiddlyLinkExisting {font-weight:bold;}
351+.tiddlyLinkNonExisting {font-style:italic;}
352+
353+/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
354+a.tiddlyLinkNonExisting.shadow {font-weight:bold;}
355+
356+#mainMenu .tiddlyLinkExisting,
357+ #mainMenu .tiddlyLinkNonExisting,
358+ #sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
359+#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}
360+
361+.header {position:relative;}
362+.header a:hover {background:transparent;}
363+.headerShadow {position:relative; padding:4.5em 0 1em 1em; left:-1px; top:-1px;}
364+.headerForeground {position:absolute; padding:4.5em 0 1em 1em; left:0; top:0;}
365+
366+.siteTitle {font-size:3em;}
367+.siteSubtitle {font-size:1.2em;}
368+
369+#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;}
370+
371+#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
372+#sidebarOptions {padding-top:0.3em;}
373+#sidebarOptions a {margin:0 0.2em; padding:0.2em 0.3em; display:block;}
374+#sidebarOptions input {margin:0.4em 0.5em;}
375+#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
376+#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
377+#sidebarOptions .sliderPanel input {margin:0 0 0.3em 0;}
378+#sidebarTabs .tabContents {width:15em; overflow:hidden;}
379+
380+.wizard {padding:0.1em 1em 0 2em;}
381+.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
382+.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
383+.wizardStep {padding:1em 1em 1em 1em;}
384+.wizard .button {margin:0.5em 0 0; font-size:1.2em;}
385+.wizardFooter {padding:0.8em 0.4em 0.8em 0;}
386+.wizardFooter .status {padding:0 0.4em; margin-left:1em;}
387+.wizard .button {padding:0.1em 0.2em;}
388+
389+#messageArea {position:fixed; top:2em; right:0; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
390+.messageToolbar {display:block; text-align:right; padding:0.2em;}
391+#messageArea a {text-decoration:underline;}
392+
393+.tiddlerPopupButton {padding:0.2em;}
394+.popupTiddler {position: absolute; z-index:300; padding:1em; margin:0;}
395+
396+.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
397+.popup .popupMessage {padding:0.4em;}
398+.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0;}
399+.popup li.disabled {padding:0.4em;}
400+.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
401+.listBreak {font-size:1px; line-height:1px;}
402+.listBreak div {margin:2px 0;}
403+
404+.tabset {padding:1em 0 0 0.5em;}
405+.tab {margin:0 0 0 0.25em; padding:2px;}
406+.tabContents {padding:0.5em;}
407+.tabContents ul, .tabContents ol {margin:0; padding:0;}
408+.txtMainTab .tabContents li {list-style:none;}
409+.tabContents li.listLink { margin-left:.75em;}
410+
411+#contentWrapper {display:block;}
412+#splashScreen {display:none;}
413+
414+#displayArea {margin:1em 17em 0 14em;}
415+
416+.toolbar {text-align:right; font-size:.9em;}
417+
418+.tiddler {padding:1em 1em 0;}
419+
420+.missing .viewer,.missing .title {font-style:italic;}
421+
422+.title {font-size:1.6em; font-weight:bold;}
423+
424+.missing .subtitle {display:none;}
425+.subtitle {font-size:1.1em;}
426+
427+.tiddler .button {padding:0.2em 0.4em;}
428+
429+.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
430+.isTag .tagging {display:block;}
431+.tagged {margin:0.5em; float:right;}
432+.tagging, .tagged {font-size:0.9em; padding:0.25em;}
433+.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
434+.tagClear {clear:both;}
435+
436+.footer {font-size:.9em;}
437+.footer li {display:inline;}
438+
439+.annotation {padding:0.5em; margin:0.5em;}
440+
441+* html .viewer pre {width:99%; padding:0 0 1em 0;}
442+.viewer {line-height:1.4em; padding-top:0.5em;}
443+.viewer .button {margin:0 0.25em; padding:0 0.25em;}
444+.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
445+.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}
446+
447+.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
448+.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
449+table.listView {font-size:0.85em; margin:0.8em 1.0em;}
450+table.listView th, table.listView td, table.listView tr {padding:0 3px 0 3px;}
451+
452+.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
453+.viewer code {font-size:1.2em; line-height:1.4em;}
454+
455+.editor {font-size:1.1em;}
456+.editor input, .editor textarea {display:block; width:100%; font:inherit;}
457+.editorFooter {padding:0.25em 0; font-size:.9em;}
458+.editorFooter .button {padding-top:0; padding-bottom:0;}
459+
460+.fieldsetFix {border:0; padding:0; margin:1px 0px;}
461+
462+.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
463+.zoomer div {padding:1em;}
464+
465+* html #backstage {width:99%;}
466+* html #backstageArea {width:99%;}
467+#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em;}
468+#backstageToolbar {position:relative;}
469+#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em;}
470+#backstageButton {display:none; position:absolute; z-index:175; top:0; right:0;}
471+#backstageButton a {padding:0.1em 0.4em; margin:0.1em;}
472+#backstage {position:relative; width:100%; z-index:50;}
473+#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin-left:3em; padding:1em;}
474+.backstagePanelFooter {padding-top:0.2em; float:right;}
475+.backstagePanelFooter a {padding:0.2em 0.4em;}
476+#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}
477+
478+.whenBackstage {display:none;}
479+.backstageVisible .whenBackstage {display:block;}
480+/*}}}*/
481+</pre>
482+</div>
483+<div title="StyleSheetLocale">
484+<pre>/***
485+StyleSheet for use when a translation requires any css style changes.
486+This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
487+***/
488+/*{{{*/
489+body {font-size:0.8em;}
490+#sidebarOptions {font-size:1.05em;}
491+#sidebarOptions a {font-style:normal;}
492+#sidebarOptions .sliderPanel {font-size:0.95em;}
493+.subtitle {font-size:0.8em;}
494+.viewer table.listView {font-size:0.95em;}
495+/*}}}*/
496+</pre>
497+</div>
498+<div title="StyleSheetPrint">
499+<pre>/*{{{*/
500+@media print {
501+#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none !important;}
502+#displayArea {margin: 1em 1em 0em;}
503+noscript {display:none;} /* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
504+}
505+/*}}}*/
506+</pre>
507+</div>
508+<div title="ViewTemplate">
509+<pre>&lt;!--{{{--&gt;
510+&lt;div class='toolbar' role='navigation' macro='toolbar [[ToolbarCommands::ViewToolbar]]'&gt;&lt;/div&gt;
511+&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
512+&lt;div class='subtitle'&gt;&lt;span macro='view modifier link'&gt;&lt;/span&gt;, &lt;span macro='view modified date'&gt;&lt;/span&gt; (&lt;span macro='message views.wikified.createdPrompt'&gt;&lt;/span&gt; &lt;span macro='view created date'&gt;&lt;/span&gt;)&lt;/div&gt;
513+&lt;div class='tagging' macro='tagging'&gt;&lt;/div&gt;
514+&lt;div class='tagged' macro='tags'&gt;&lt;/div&gt;
515+&lt;div class='viewer' macro='view text wikified'&gt;&lt;/div&gt;
516+&lt;div class='tagClear'&gt;&lt;/div&gt;
517+&lt;!--}}}--&gt;
518+</pre>
519+</div>
520+
521+</div>
522+<!--POST-SHADOWAREA-->
523+<div id="storeArea">
524+<div title="How to read Japanese characters in Vim" creator="StavrosVagionitis" modifier="StavrosVagionitis" created="201405012259" modified="201405012308" changecount="3">
525+<pre>Currently if you open a file that contains Japanese characters you can see the following
526+
527+{{{
528+/// @file mist/mist.h
529+//!
530+//! @brief MIST&lt;82&gt;Ì&lt;8a&gt;î&lt;96&gt;{&lt;82&gt;Æ&lt;82&gt;È&lt;82&gt;é&lt;89&gt;¹&lt;90&gt;º&lt;81&gt;E&lt;89&gt;æ&lt;91&gt;&lt;9c&gt;&lt;82&gt;ð&lt;88&gt;µ&lt;82&gt;¤&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i
531+//!
532+//! MIST&lt;82&gt;Å&lt;92&gt;ñ&lt;8b&gt;&lt;9f&gt;&lt;82&gt;·&lt;82&gt;é&lt;91&gt;S&lt;82&gt;Ä&lt;82&gt;Ì&lt;83&gt;A&lt;83&gt;&lt;8b&gt;&lt;83&gt;S&lt;83&gt;&lt;8a&gt;&lt;83&gt;Y&lt;83&gt;&lt;80&gt;&lt;93&gt;&lt;99&gt;&lt;82&gt;Å&lt;97&gt;&lt;98&gt;&lt;97&gt;p&lt;82&gt;·&lt;82&gt;é&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;81&gt;iSTL&lt;95&gt;&lt;97&gt;&lt;81&gt;j&lt;82&gt;Ì&lt;8f&gt;W&lt;82&gt;Ü&lt;82&gt;è&lt;82&gt;Å&lt;82&gt;·&lt;81&gt;D
533+//! &lt;8a&gt;î&lt;96&gt;{&lt;93&gt;I&lt;82&gt;É&lt;82&gt;Í&lt;81&gt;CSTL&lt;81&gt;iStandard Template Library&lt;81&gt;j&lt;82&gt;Å&lt;92&gt;ñ&lt;8b&gt;&lt;9f&gt;&lt;82&gt;³&lt;82&gt;ê&lt;82&gt;Ä&lt;82&gt;¢&lt;82&gt;é&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;82&gt;Æ&lt;82&gt;Ù&lt;82&gt;Ú&lt;8c&gt;Ý&lt;8a&gt;·&lt;90&gt;«&lt;82&gt;ð&lt;8e&gt;&lt;9d&gt;&lt;82&gt;Á&lt;82&gt;Ä&lt;82&gt;¢&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
534+//! &lt;93&gt;Á&lt;92&gt;¥&lt;82&gt;Æ&lt;82&gt;µ&lt;82&gt;Ä&lt;82&gt;Í&lt;81&gt;C&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;93&gt;à&lt;82&gt;Ì&lt;83&gt;f&lt;81&gt;[&lt;83&gt;^&lt;82&gt;Í&lt;83&gt;&lt;81&gt;&lt;83&gt;&lt;82&gt;&lt;83&gt;&lt;8a&gt;&lt;8b&gt;ó&lt;8a&gt;Ô&lt;8f&gt;ã&lt;82&gt;Å&lt;98&gt;A&lt;91&gt;±&lt;82&gt;Æ&lt;82&gt;È&lt;82&gt;é&lt;82&gt;æ&lt;82&gt;¤&lt;82&gt;É&lt;8e&gt;À&lt;91&gt;&lt;95&gt;&lt;82&gt;³&lt;82&gt;ê&lt;82&gt;Ä&lt;82&gt;¢&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
535+//! &lt;82&gt;»&lt;82&gt;µ&lt;82&gt;Ä&lt;81&gt;CSTL&lt;82&gt;Ì&lt;83&gt;A&lt;83&gt;&lt;8b&gt;&lt;83&gt;S&lt;83&gt;&lt;8a&gt;&lt;83&gt;Y&lt;83&gt;&lt;80&gt;&lt;93&gt;&lt;99&gt;&lt;82&gt;Å&lt;97&gt;p&lt;82&gt;¢&lt;82&gt;é&lt;83&gt;C&lt;83&gt;e&lt;83&gt;&lt;8c&gt;&lt;81&gt;[&lt;83&gt;^&lt;82&gt;Ì&lt;93&gt;à&lt;81&gt;C&lt;83&gt;&lt;89&gt;&lt;83&gt;&lt;93&gt;&lt;83&gt;_&lt;83&gt;&lt;80&gt;&lt;83&gt;A&lt;83&gt;N&lt;83&gt;Z&lt;83&gt;X&lt;83&gt;C&lt;83&gt;e&lt;83&gt;&lt;8c&gt;&lt;81&gt;[&lt;83&gt;^&lt;82&gt;ð&lt;8e&gt;À&lt;91&gt;&lt;95&gt;&lt;82&gt;µ&lt;82&gt;Ä&lt;82&gt; &lt;82&gt;è&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
536+//! &lt;83&gt;C&lt;83&gt;e&lt;83&gt;&lt;8c&gt;&lt;81&gt;[&lt;83&gt;^&lt;82&gt;Ì&lt;8f&gt;Ú&lt;8d&gt;×&lt;82&gt;É&lt;8a&gt;Ö&lt;82&gt;µ&lt;82&gt;Ä&lt;82&gt;Í&lt;81&gt;CSTL&lt;82&gt;Ì&lt;89&gt;ð&lt;90&gt;à&lt;96&gt;{&lt;82&gt;É&lt;8f&gt;÷&lt;82&gt;è&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
537+//! &lt;82&gt;Ü&lt;82&gt;½&lt;81&gt;CMIST&lt;82&gt;Ì&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;82&gt;Å&lt;82&gt;Í&lt;91&gt;g&lt;82&gt;Ý&lt;8d&gt;&lt;9e&gt;&lt;82&gt;Ý&lt;8c&gt;^&lt;82&gt;Æ&lt;83&gt;&lt;86&gt;&lt;81&gt;[&lt;83&gt;U&lt;81&gt;[&lt;92&gt;è&lt;8b&gt;`&lt;8c&gt;^&lt;82&gt;Å&lt;81&gt;C&lt;97&gt;&lt;98&gt;&lt;97&gt;p&lt;82&gt;·&lt;82&gt;é&lt;83&gt;&lt;81&gt;&lt;83&gt;&lt;82&gt;&lt;83&gt;&lt;8a&gt;&lt;91&gt;&lt;80&gt;&lt;8d&gt;ì&lt;82&gt;ð&lt;8b&gt;æ&lt;95&gt;Ê&lt;82&gt;µ&lt;82&gt;Ä&lt;82&gt;¢&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
538+//! &lt;82&gt;»&lt;82&gt;¤&lt;82&gt;·&lt;82&gt;é&lt;82&gt;±&lt;82&gt;Æ&lt;82&gt;Å&lt;81&gt;C&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;82&gt;Ì&lt;91&gt;ã&lt;93&gt;ü&lt;93&gt;&lt;99&gt;&lt;82&gt;Å&lt;8e&gt;á&lt;8a&gt;±&lt;8d&gt;&lt;82&gt;&lt;91&gt;¬&lt;82&gt;È&lt;8e&gt;À&lt;8d&gt;s&lt;82&gt;ª&lt;89&gt;Â&lt;94&gt;\&lt;82&gt;Æ&lt;82&gt;È&lt;82&gt;Á&lt;82&gt;Ä&lt;82&gt;¢&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
539+//!
540+//! MIST&lt;83&gt;v&lt;83&gt;&lt;8d&gt;&lt;83&gt;W&lt;83&gt;F&lt;83&gt;N&lt;83&gt;g&lt;82&gt;Å&lt;92&gt;ñ&lt;8b&gt;&lt;9f&gt;&lt;82&gt;·&lt;82&gt;é&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;82&gt;Í&lt;81&gt;C&lt;88&gt;È&lt;89&gt;º&lt;82&gt;Ì&lt;8d&gt;&lt;87&gt;&lt;8c&gt;v6&lt;82&gt;Â&lt;82&gt;Ì&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;82&gt;Å&lt;8d&gt;\&lt;90&gt;¬&lt;82&gt;³&lt;82&gt;ê&lt;82&gt;Ä&lt;82&gt;¢&lt;82&gt;Ü&lt;82&gt;·&lt;81&gt;D
541+//!
542+//! - &lt;8a&gt;î&lt;92&gt;ê1&lt;8e&gt;&lt;9f&gt;&lt;8c&gt;³&lt;94&gt;z&lt;97&gt;ñ&lt;81&gt;iSTL&lt;95&gt;&lt;97&gt;&lt;82&gt;Ì1&lt;8e&gt;&lt;9f&gt;&lt;8c&gt;³&lt;94&gt;z&lt;97&gt;ñ&lt;97&gt;p&lt;83&gt;R&lt;83&gt;&lt;93&gt;&lt;83&gt;e&lt;83&gt;i&lt;81&gt;j
543+//! - &lt;89&gt;ð&lt;91&gt;&lt;9c&gt;&lt;93&gt;x&lt;95&gt;t1&lt;8e&gt;&lt;9f&gt;&lt;8c&gt;³&lt;94&gt;z&lt;97&gt;ñ&lt;81&gt;i&lt;8a&gt;e&lt;97&gt;v&lt;91&gt;f&lt;82&gt;Ì&lt;89&gt;ð&lt;91&gt;&lt;9c&gt;&lt;93&gt;x&lt;82&gt;Ì&lt;83&gt;f&lt;81&gt;[&lt;83&gt;^&lt;82&gt;ð&lt;95&gt;Û&lt;8e&gt;&lt;9d&gt;&lt;81&gt;C&lt;97&gt;á&lt;82&gt;¦&lt;82&gt;Î1mm&lt;82&gt;È&lt;82&gt;Ç&lt;81&gt;j
544+//! - &lt;89&gt;ð&lt;91&gt;&lt;9c&gt;&lt;93&gt;x&lt;95&gt;t2&lt;8e&gt;&lt;9f&gt;&lt;8c&gt;³&lt;94&gt;z&lt;97&gt;ñ
545+//! - &lt;89&gt;ð&lt;91&gt;&lt;9c&gt;&lt;93&gt;x&lt;95&gt;t3&lt;8e&gt;&lt;9f&gt;&lt;8c&gt;³&lt;94&gt;z&lt;97&gt;ñ
546+//! - &lt;8d&gt;s&lt;97&gt;ñ
547+//! - &lt;83&gt;x&lt;83&gt;N&lt;83&gt;g&lt;83&gt;&lt;8b&gt;
548+//!
549+}}}
550+
551+As can be seen the characters are not visible, because of different encoding. If the following line
552+
553+{{{
554+set fileencodings=ucs-bom,utf-8,sjis,default
555+}}}
556+
557+is added in {{{~/.vimrc}}} then the japanese symbols appear
558+
559+{{{
560+/// @file mist/mist.h
561+//!
562+//! @brief MISTの基本となる音声・画像を扱うコンテナ
563+//!
564+//! MISTで提供する全てのアルゴリズム等で利用するコンテナ(STL風)の集まりです.
565+//! 基本的には,STL(Standard Template Library)で提供されているコンテナとほぼ互換性を持っています.
566+//! 特徴としては,コンテナ内のデータはメモリ空間上で連続となるように実装されています.
567+//! そして,STLのアルゴリズム等で用いるイテレータの内,ランダムアクセスイテレータを実装してあります.
568+//! イテレータの詳細に関しては,STLの解説本に譲ります.
569+//! また,MISTのコンテナでは組み込み型とユーザー定義型で,利用するメモリ操作を区別しています.
570+//! そうすることで,コンテナの代入等で若干高速な実行が可能となっています.
571+//!
572+//! MISTプロジェクトで提供するコンテナは,以下の合計6つのコンテナで構成されています.
573+//!
574+//! - 基底1次元配列(STL風の1次元配列用コンテナ)
575+//! - 解像度付1次元配列(各要素の解像度のデータを保持,例えば1mmなど)
576+//! - 解像度付2次元配列
577+//! - 解像度付3次元配列
578+//! - 行列
579+//! - ベクトル
580+//!
581+}}}
582+
583+Source: http://stackoverflow.com/questions/4103970/how-to-read-sjis-encoded-file-in-vim</pre>
584+</div>
585+<div title="Translate the Japanese comments to English" creator="StavrosVagionitis" modifier="StavrosVagionitis" created="201405012237" modified="201405012253" changecount="4">
586+<pre>In order to get the Japanese comments in the command like, the following command can be executed
587+
588+{{{
589+find -name \*.cpp -exec /opt/local/bin/grep -PHn --color=always '[^\x00-\x7f]' {} \;
590+find -name \*.h -exec /opt/local/bin/grep -PHn --color=always '[^\x00-\x7f]' {} \;
591+}}}
592+
593+It is used the GNU grep. In Mac Os X, it is not installed by default the GNU grep. The {{{-P}}} option is for interpreting the pattern as a Perl regular expression. In Mac Os X this is not implemented and gives error. The {{{-H}}} option prints the filename for each match and the {{{-n}}} prints the line number. Next following an example of the above GNU grep command
594+
595+{{{
596+mac@StavrosMac-6:~/My.Projects/MIST-github/MIST (TranslateToEnglish) $/opt/local/bin/grep -PHn --color=always '[^\x00-\x7f]' unittest/main.cpp
597+unittest/main.cpp:41: // ?C?x???g?}?l?[?W????????????
598+unittest/main.cpp:44: // ?e?X?g?????????W?????I?u?W?F?N?g??????????
599+unittest/main.cpp:48: // ?e?X?g???s?????i?s???????\???????I?u?W?F?N?g??????????
600+unittest/main.cpp:52: // ?e?X?g?????i?[???e?X?g??????????
601+unittest/main.cpp:57: // ?e?X?g???????o??????
602+unittest/main.cpp:61: // ?e?X?g???????????????? 0 ???????C???s?????? 1 ??????
603+}}}
604+
605+As can be seen above, the Japanese characters are appearing as questions marks or other characters in console.
606+</pre>
607+</div>
608+</div>
609+<!--POST-STOREAREA-->
610+<!--POST-BODY-START-->
611+
612+<!--POST-BODY-END-->
613+<script id="jsArea" type="text/javascript">
614+//<![CDATA[
615+
616+//
617+// Please note:
618+//
619+// * This code is designed to be readable but for compactness it only includes brief comments. You can see fuller comments
620+// in the project repository at https://github.com/TiddlyWiki/tiddlywiki
621+//
622+// * You should never need to modify this source code directly. TiddlyWiki is carefully designed to allow deep customisation
623+// without changing the core code. Please consult the development group at http://groups.google.com/group/TiddlyWikiDev
624+//
625+// JSLint directives
626+/*global jQuery:false, version:false */
627+/*jslint bitwise:true, browser:true, confusion:true, eqeq:true, evil:true, forin:true, maxerr:100, plusplus:true, regexp:true, sloppy:true, sub:true, undef:true, unparam:true, vars:true, white:true */
628+//--
629+//-- Configuration repository
630+//--
631+
632+// Miscellaneous options
633+var config = {
634+ numRssItems: 20, // Number of items in the RSS feed
635+ animDuration: 400, // Duration of UI animations in milliseconds
636+ cascadeFast: 20, // Speed for cascade animations (higher == slower)
637+ cascadeSlow: 60, // Speed for EasterEgg cascade animations
638+ cascadeDepth: 5, // Depth of cascade animation
639+ locale: "en" // W3C language tag
640+};
641+
642+// Hashmap of alternative parsers for the wikifier
643+config.parsers = {};
644+
645+// Adaptors
646+config.adaptors = {};
647+config.defaultAdaptor = null;
648+
649+// Backstage tasks
650+config.tasks = {};
651+
652+// Annotations
653+config.annotations = {};
654+
655+// Custom fields to be automatically added to new tiddlers
656+config.defaultCustomFields = {};
657+
658+// Messages
659+config.messages = {
660+ messageClose: {},
661+ dates: {},
662+ tiddlerPopup: {}
663+};
664+
665+// Options that can be set in the options panel and/or cookies
666+config.options = {
667+ chkRegExpSearch: false,
668+ chkCaseSensitiveSearch: false,
669+ chkIncrementalSearch: true,
670+ chkAnimate: true,
671+ chkSaveBackups: true,
672+ chkAutoSave: false,
673+ chkGenerateAnRssFeed: false,
674+ chkSaveEmptyTemplate: false,
675+ chkOpenInNewWindow: true,
676+ chkToggleLinks: false,
677+ chkHttpReadOnly: true,
678+ chkForceMinorUpdate: false,
679+ chkConfirmDelete: true,
680+ chkInsertTabs: false,
681+ chkUsePreForStorage: true, // Whether to use <pre> format for storage
682+ chkDisplayInstrumentation: false,
683+ txtBackupFolder: "",
684+ txtEditorFocus: "text",
685+ txtMainTab: "tabTimeline",
686+ txtMoreTab: "moreTabAll",
687+ txtMaxEditRows: "30",
688+ txtFileSystemCharSet: "UTF-8",
689+ txtTheme: ""
690+ };
691+config.optionsDesc = {};
692+
693+config.optionsSource = {};
694+
695+// Default tiddler templates
696+var DEFAULT_VIEW_TEMPLATE = 1;
697+var DEFAULT_EDIT_TEMPLATE = 2;
698+config.tiddlerTemplates = {
699+ 1: "ViewTemplate",
700+ 2: "EditTemplate"
701+};
702+
703+// More messages (rather a legacy layout that should not really be like this)
704+config.views = {
705+ wikified: {
706+ tag: {}
707+ },
708+ editor: {
709+ tagChooser: {}
710+ }
711+};
712+
713+// Backstage tasks
714+config.backstageTasks = ["save","importTask","tweak","upgrade","plugins"];
715+
716+// Extensions
717+config.extensions = {};
718+
719+// Macros; each has a 'handler' member that is inserted later
720+config.macros = {
721+ today: {},
722+ version: {},
723+ search: {sizeTextbox: 15},
724+ tiddler: {},
725+ tag: {},
726+ tags: {},
727+ tagging: {},
728+ timeline: {},
729+ allTags: {},
730+ list: {
731+ all: {},
732+ missing: {},
733+ orphans: {},
734+ shadowed: {},
735+ touched: {},
736+ filter: {}
737+ },
738+ closeAll: {},
739+ permaview: {},
740+ saveChanges: {},
741+ slider: {},
742+ option: {},
743+ options: {},
744+ newTiddler: {},
745+ newJournal: {},
746+ tabs: {},
747+ gradient: {},
748+ message: {},
749+ view: {defaultView: "text"},
750+ edit: {},
751+ tagChooser: {},
752+ toolbar: {},
753+ plugins: {},
754+ refreshDisplay: {},
755+ importTiddlers: {},
756+ upgrade: {
757+ source: "http://tiddlywiki-releases.tiddlyspace.com/upgrade",
758+ backupExtension: "pre.core.upgrade"
759+ },
760+ sync: {},
761+ annotations: {}
762+};
763+
764+// Commands supported by the toolbar macro
765+config.commands = {
766+ closeTiddler: {},
767+ closeOthers: {},
768+ editTiddler: {},
769+ saveTiddler: {hideReadOnly: true},
770+ cancelTiddler: {},
771+ deleteTiddler: {hideReadOnly: true},
772+ permalink: {},
773+ references: {type: "popup"},
774+ jump: {type: "popup"},
775+ syncing: {type: "popup"},
776+ fields: {type: "popup"}
777+};
778+
779+// Control of macro parameter evaluation
780+config.evaluateMacroParameters = "all";
781+
782+// Basic regular expressions
783+config.textPrimitives = {
784+ upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]",
785+ lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]",
786+ anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]",
787+ anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]"
788+};
789+if(!((new RegExp("[\u0150\u0170]","g")).test("\u0150"))) {
790+ config.textPrimitives = {
791+ upperLetter: "[A-Z\u00c0-\u00de]",
792+ lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]",
793+ anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]",
794+ anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]"
795+ };
796+}
797+config.textPrimitives.sliceSeparator = "::";
798+config.textPrimitives.sectionSeparator = "##";
799+config.textPrimitives.urlPattern = "(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
800+config.textPrimitives.unWikiLink = "~";
801+config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" +
802+ config.textPrimitives.lowerLetter + "+" +
803+ config.textPrimitives.upperLetter +
804+ config.textPrimitives.anyLetter + "*)|(?:" +
805+ config.textPrimitives.upperLetter + "{2,}" +
806+ config.textPrimitives.lowerLetter + "+))";
807+
808+config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)";
809+config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg");
810+
811+config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]";
812+config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
813+config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" +
814+ config.textPrimitives.brackettedLink + ")|(?:" +
815+ config.textPrimitives.urlPattern + ")","mg");
816+config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" +
817+ config.textPrimitives.titledBrackettedLink + ")|(?:" +
818+ config.textPrimitives.brackettedLink + ")|(?:" +
819+ config.textPrimitives.urlPattern + ")","mg");
820+
821+config.glyphs = {
822+ currBrowser: null,
823+ browsers: [],
824+ codes: {}
825+};
826+
827+//--
828+//-- Shadow tiddlers
829+//--
830+
831+config.shadowTiddlers = {
832+ StyleSheet: "",
833+ MarkupPreHead: "",
834+ MarkupPostHead: "",
835+ MarkupPreBody: "",
836+ MarkupPostBody: "",
837+ TabTimeline: '<<timeline>>',
838+ TabAll: '<<list all>>',
839+ TabTags: '<<allTags excludeLists>>',
840+ TabMoreMissing: '<<list missing>>',
841+ TabMoreOrphans: '<<list orphans>>',
842+ TabMoreShadowed: '<<list shadowed>>',
843+ AdvancedOptions: '<<options>>',
844+ PluginManager: '<<plugins>>',
845+ SystemSettings: '',
846+ ToolbarCommands: '|~ViewToolbar|closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|\n|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|',
847+ WindowTitle: '<<tiddler SiteTitle>> - <<tiddler SiteSubtitle>>'
848+};
849+
850+// Browser detection... In a very few places, there's nothing else for it but to know what browser we're using.
851+config.userAgent = navigator.userAgent.toLowerCase();
852+config.browser = {
853+ isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1,
854+ isGecko: navigator.product == "Gecko" && config.userAgent.indexOf("WebKit") == -1,
855+ ieVersion: /MSIE (\d{1,2}.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0"
856+ isSafari: config.userAgent.indexOf("applewebkit") != -1,
857+ isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")),
858+ firefoxDate: /gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD"
859+ isOpera: config.userAgent.indexOf("opera") != -1,
860+ isChrome: config.userAgent.indexOf('chrome') > -1,
861+ isLinux: config.userAgent.indexOf("linux") != -1,
862+ isUnix: config.userAgent.indexOf("x11") != -1,
863+ isMac: config.userAgent.indexOf("mac") != -1,
864+ isWindows: config.userAgent.indexOf("win") != -1
865+};
866+
867+merge(config.glyphs,{
868+ browsers: [
869+ function() {return config.browser.isIE;},
870+ function() {return true;}
871+ ],
872+ codes: {
873+ downTriangle: ["\u25BC","\u25BE"],
874+ downArrow: ["\u2193","\u2193"],
875+ bentArrowLeft: ["\u2190","\u21A9"],
876+ bentArrowRight: ["\u2192","\u21AA"]
877+ }
878+});
879+
880+//--
881+//-- Translateable strings
882+//--
883+
884+// Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone
885+
886+merge(config.options,{
887+ txtUserName: "YourName"});
888+
889+merge(config.tasks,{
890+ save: {text: "save", tooltip: "Save your changes to this TiddlyWiki"},
891+ importTask: {text: "import", tooltip: "Import tiddlers and plugins from other TiddlyWiki files and servers", content: '<<importTiddlers>>'},
892+ tweak: {text: "tweak", tooltip: "Tweak the appearance and behaviour of TiddlyWiki", content: '<<options>>'},
893+ upgrade: {text: "upgrade", tooltip: "Upgrade TiddlyWiki core code", content: '<<upgrade>>'},
894+ plugins: {text: "plugins", tooltip: "Manage installed plugins", content: '<<plugins>>'}
895+});
896+
897+// Options that can be set in the options panel and/or cookies
898+merge(config.optionsDesc,{
899+ txtUserName: "Username for signing your edits",
900+ chkRegExpSearch: "Enable regular expressions for searches",
901+ chkCaseSensitiveSearch: "Case-sensitive searching",
902+ chkIncrementalSearch: "Incremental key-by-key searching",
903+ chkAnimate: "Enable animations",
904+ chkSaveBackups: "Keep backup file when saving changes",
905+ chkAutoSave: "Automatically save changes",
906+ chkGenerateAnRssFeed: "Generate an RSS feed when saving changes",
907+ chkSaveEmptyTemplate: "Generate an empty template when saving changes",
908+ chkOpenInNewWindow: "Open external links in a new window",
909+ chkToggleLinks: "Clicking on links to open tiddlers causes them to close",
910+ chkHttpReadOnly: "Hide editing features when viewed over HTTP",
911+ chkForceMinorUpdate: "Don't update modifier username and date when editing tiddlers",
912+ chkConfirmDelete: "Require confirmation before deleting tiddlers",
913+ chkInsertTabs: "Use the tab key to insert tab characters instead of moving between fields",
914+ txtBackupFolder: "Name of folder to use for backups",
915+ txtMaxEditRows: "Maximum number of rows in edit boxes",
916+ txtTheme: "Name of the theme to use",
917+ txtFileSystemCharSet: "Default character set for saving changes (Firefox/Mozilla only)"});
918+
919+merge(config.messages,{
920+ customConfigError: "Problems were encountered loading plugins. See PluginManager for details",
921+ pluginError: "Error: %0",
922+ pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag",
923+ pluginForced: "Executed because forced via 'systemConfigForce' tag",
924+ pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki",
925+ nothingSelected: "Nothing is selected. You must select one or more items first",
926+ savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#Download for details",
927+ subtitleUnknown: "(unknown)",
928+ undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
929+ shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value",
930+ tiddlerLinkTooltip: "%0 - %1, %2",
931+ externalLinkTooltip: "External link to %0",
932+ noTags: "There are no tagged tiddlers",
933+ notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
934+ 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",
935+ invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
936+ backupSaved: "Backup saved",
937+ backupFailed: "Failed to save backup file",
938+ rssSaved: "RSS feed saved",
939+ rssFailed: "Failed to save RSS feed file",
940+ emptySaved: "Empty template saved",
941+ emptyFailed: "Failed to save empty template file",
942+ mainSaved: "Main TiddlyWiki file saved",
943+ mainDownload: "Downloading/saving main TiddlyWiki file",
944+ mainDownloadManual: "RIGHT CLICK HERE to download/save main TiddlyWiki file",
945+ mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
946+ macroError: "Error in macro <<%0>>",
947+ macroErrorDetails: "Error while executing macro <<%0>>:\n%1",
948+ missingMacro: "No such macro",
949+ overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
950+ unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
951+ confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------",
952+ saveInstructions: "SaveChanges",
953+ unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'",
954+ tiddlerSaveError: "Error when saving tiddler '%0'",
955+ tiddlerLoadError: "Error when loading tiddler '%0'",
956+ wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.",
957+ invalidFieldName: "Invalid field name %0",
958+ fieldCannotBeChanged: "Field '%0' cannot be changed",
959+ loadingMissingTiddler: "Attempting to retrieve the tiddler '%0' from the '%1' server at:\n\n'%2' in the workspace '%3'",
960+ upgradeDone: "The upgrade to version %0 is now complete\n\nClick 'OK' to reload the newly upgraded TiddlyWiki",
961+ invalidCookie: "Invalid cookie '%0'"});
962+
963+merge(config.messages.messageClose,{
964+ text: "close",
965+ tooltip: "close this message area"});
966+
967+config.messages.backstage = {
968+ open: {text: "backstage", tooltip: "Open the backstage area to perform authoring and editing tasks"},
969+ close: {text: "close", tooltip: "Close the backstage area"},
970+ prompt: "backstage: ",
971+ decal: {
972+ edit: {text: "edit", tooltip: "Edit the tiddler '%0'"}
973+ }
974+};
975+
976+config.messages.listView = {
977+ tiddlerTooltip: "Click for the full text of this tiddler",
978+ previewUnavailable: "(preview not available)"
979+};
980+
981+config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
982+config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
983+config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
984+config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
985+// suffixes for dates, eg "1st","2nd","3rd"..."30th","31st"
986+config.messages.dates.daySuffixes = ["st","nd","rd","th","th","th","th","th","th","th",
987+ "th","th","th","th","th","th","th","th","th","th",
988+ "st","nd","rd","th","th","th","th","th","th","th",
989+ "st"];
990+config.messages.dates.am = "am";
991+config.messages.dates.pm = "pm";
992+
993+merge(config.messages.tiddlerPopup,{
994+ });
995+
996+merge(config.views.wikified.tag,{
997+ labelNoTags: "no tags",
998+ labelTags: "tags: ",
999+ openTag: "Open tag '%0'",
1000+ tooltip: "Show tiddlers tagged with '%0'",
1001+ openAllText: "Open all",
1002+ openAllTooltip: "Open all of these tiddlers",
1003+ popupNone: "No other tiddlers tagged with '%0'"});
1004+
1005+merge(config.views.wikified,{
1006+ defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it",
1007+ defaultModifier: "(missing)",
1008+ shadowModifier: "(built-in shadow tiddler)",
1009+ dateFormat: "DD MMM YYYY",
1010+ createdPrompt: "created"});
1011+
1012+merge(config.views.editor,{
1013+ tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
1014+ defaultText: "Type the text for '%0'"});
1015+
1016+merge(config.views.editor.tagChooser,{
1017+ text: "tags",
1018+ tooltip: "Choose existing tags to add to this tiddler",
1019+ popupNone: "There are no tags defined",
1020+ tagTooltip: "Add the tag '%0'"});
1021+
1022+merge(config.messages,{
1023+ sizeTemplates:
1024+ [
1025+ {unit: 1024*1024*1024, template: "%0\u00a0GB"},
1026+ {unit: 1024*1024, template: "%0\u00a0MB"},
1027+ {unit: 1024, template: "%0\u00a0KB"},
1028+ {unit: 1, template: "%0\u00a0B"}
1029+ ]});
1030+
1031+merge(config.macros.search,{
1032+ label: "search",
1033+ prompt: "Search this TiddlyWiki",
1034+ placeholder: "",
1035+ accessKey: "F",
1036+ successMsg: "%0 tiddlers found matching %1",
1037+ failureMsg: "No tiddlers found matching %0"});
1038+
1039+merge(config.macros.tagging,{
1040+ label: "tagging: ",
1041+ labelNotTag: "not tagging",
1042+ tooltip: "List of tiddlers tagged with '%0'"});
1043+
1044+merge(config.macros.timeline,{
1045+ dateFormat: "DD MMM YYYY"});
1046+
1047+merge(config.macros.allTags,{
1048+ tooltip: "Show tiddlers tagged with '%0'",
1049+ noTags: "There are no tagged tiddlers"});
1050+
1051+config.macros.list.all.prompt = "All tiddlers in alphabetical order";
1052+config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined";
1053+config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers";
1054+config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents";
1055+config.macros.list.touched.prompt = "Tiddlers that have been modified locally";
1056+
1057+merge(config.macros.closeAll,{
1058+ label: "close all",
1059+ prompt: "Close all displayed tiddlers (except any that are being edited)"});
1060+
1061+merge(config.macros.permaview,{
1062+ label: "permaview",
1063+ prompt: "Link to an URL that retrieves all the currently displayed tiddlers"});
1064+
1065+merge(config.macros.saveChanges,{
1066+ label: "save changes",
1067+ prompt: "Save all tiddlers to create a new TiddlyWiki",
1068+ accessKey: "S"});
1069+
1070+merge(config.macros.newTiddler,{
1071+ label: "new tiddler",
1072+ prompt: "Create a new tiddler",
1073+ title: "New Tiddler",
1074+ accessKey: "N"});
1075+
1076+merge(config.macros.newJournal,{
1077+ label: "new journal",
1078+ prompt: "Create a new tiddler from the current date and time",
1079+ accessKey: "J"});
1080+
1081+merge(config.macros.options,{
1082+ wizardTitle: "Tweak advanced options",
1083+ step1Title: "These options are saved in cookies in your browser",
1084+ step1Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='false' name='chkUnknown'>Show unknown options</input>",
1085+ unknownDescription: "//(unknown)//",
1086+ listViewTemplate: {
1087+ columns: [
1088+ {name: 'Option', field: 'option', title: "Option", type: 'String'},
1089+ {name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
1090+ {name: 'Name', field: 'name', title: "Name", type: 'String'}
1091+ ],
1092+ rowClasses: [
1093+ {className: 'lowlight', field: 'lowlight'}
1094+ ]}
1095+ });
1096+
1097+merge(config.macros.plugins,{
1098+ wizardTitle: "Manage plugins",
1099+ step1Title: "Currently loaded plugins",
1100+ step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
1101+ skippedText: "(This plugin has not been executed because it was added since startup)",
1102+ noPluginText: "There are no plugins installed",
1103+ confirmDeleteText: "Are you sure you want to delete these plugins:\n\n%0",
1104+ removeLabel: "remove systemConfig tag",
1105+ removePrompt: "Remove systemConfig tag",
1106+ deleteLabel: "delete",
1107+ deletePrompt: "Delete these tiddlers forever",
1108+ listViewTemplate: {
1109+ columns: [
1110+ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
1111+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
1112+ {name: 'Description', field: 'Description', title: "Description", type: 'String'},
1113+ {name: 'Version', field: 'Version', title: "Version", type: 'String'},
1114+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
1115+ {name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'},
1116+ {name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'},
1117+ {name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
1118+ {name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'},
1119+ {name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
1120+ {name: 'Log', field: 'log', title: "Log", type: 'StringList'}
1121+ ],
1122+ rowClasses: [
1123+ {className: 'error', field: 'error'},
1124+ {className: 'warning', field: 'warning'}
1125+ ]},
1126+ listViewTemplateReadOnly: {
1127+ columns: [
1128+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
1129+ {name: 'Description', field: 'Description', title: "Description", type: 'String'},
1130+ {name: 'Version', field: 'Version', title: "Version", type: 'String'},
1131+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
1132+ {name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
1133+ {name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'},
1134+ {name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
1135+ {name: 'Log', field: 'log', title: "Log", type: 'StringList'}
1136+ ],
1137+ rowClasses: [
1138+ {className: 'error', field: 'error'},
1139+ {className: 'warning', field: 'warning'}
1140+ ]}
1141+ });
1142+
1143+merge(config.macros.toolbar,{
1144+ moreLabel: "more",
1145+ morePrompt: "Show additional commands",
1146+ lessLabel: "less",
1147+ lessPrompt: "Hide additional commands",
1148+ separator: "|"
1149+ });
1150+
1151+merge(config.macros.refreshDisplay,{
1152+ label: "refresh",
1153+ prompt: "Redraw the entire TiddlyWiki display"
1154+ });
1155+
1156+merge(config.macros.importTiddlers,{
1157+ readOnlyWarning: "You cannot import into a read-only TiddlyWiki file. Try opening it from a file:// URL",
1158+ wizardTitle: "Import tiddlers from another file or server",
1159+ step1Title: "Step 1: Locate the server or TiddlyWiki file",
1160+ 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>",
1161+ openLabel: "open",
1162+ openPrompt: "Open the connection to this file or server",
1163+ statusOpenHost: "Opening the host",
1164+ statusGetWorkspaceList: "Getting the list of available workspaces",
1165+ step2Title: "Step 2: Choose the workspace",
1166+ 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>",
1167+ cancelLabel: "cancel",
1168+ cancelPrompt: "Cancel this import",
1169+ statusOpenWorkspace: "Opening the workspace",
1170+ statusGetTiddlerList: "Getting the list of available tiddlers",
1171+ errorGettingTiddlerList: "Error getting list of tiddlers, click Cancel to try again",
1172+ errorGettingTiddlerListHttp404: "Error retrieving tiddlers from url, please ensure the url exists. Click Cancel to try again.",
1173+ errorGettingTiddlerListHttp: "Error retrieving tiddlers from url, please ensure this url exists and is <a href='http://enable-cors.org/'>CORS</a> enabled",
1174+ errorGettingTiddlerListFile: "Error retrieving tiddlers from local file, please make sure the file is in the same directory as your TiddlyWiki. Click Cancel to try again.",
1175+ step3Title: "Step 3: Choose the tiddlers to import",
1176+ 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'>",
1177+ importLabel: "import",
1178+ importPrompt: "Import these tiddlers",
1179+ confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0",
1180+ step4Title: "Step 4: Importing %0 tiddler(s)",
1181+ step4Html: "<input type='hidden' name='markReport'></input>", // DO NOT TRANSLATE
1182+ doneLabel: "done",
1183+ donePrompt: "Close this wizard",
1184+ statusDoingImport: "Importing tiddlers",
1185+ statusDoneImport: "All tiddlers imported",
1186+ systemServerNamePattern: "%2 on %1",
1187+ systemServerNamePatternNoWorkspace: "%1",
1188+ confirmOverwriteSaveTiddler: "The tiddler '%0' already exists. Click 'OK' to overwrite it with the details of this server, or 'Cancel' to leave it unchanged",
1189+ serverSaveTemplate: "|''Type:''|%0|\n|''URL:''|%1|\n|''Workspace:''|%2|\n\nThis tiddler was automatically created to record the details of this server",
1190+ serverSaveModifier: "(System)",
1191+ listViewTemplate: {
1192+ columns: [
1193+ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
1194+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
1195+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
1196+ {name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
1197+ ],
1198+ rowClasses: [
1199+ ]}
1200+ });
1201+
1202+merge(config.macros.upgrade,{
1203+ wizardTitle: "Upgrade TiddlyWiki core code",
1204+ step1Title: "Update or repair this TiddlyWiki to the latest release",
1205+ 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>",
1206+ errorCantUpgrade: "Unable to upgrade this TiddlyWiki. You can only perform upgrades on TiddlyWiki files stored locally",
1207+ errorNotSaved: "You must save changes before you can perform an upgrade",
1208+ step2Title: "Confirm the upgrade details",
1209+ 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",
1210+ 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",
1211+ step2Html_upgrade: "You are about to upgrade to TiddlyWiki version %0 from %1",
1212+ upgradeLabel: "upgrade",
1213+ upgradePrompt: "Prepare for the upgrade process",
1214+ statusPreparingBackup: "Preparing backup",
1215+ statusSavingBackup: "Saving backup file",
1216+ errorSavingBackup: "There was a problem saving the backup file",
1217+ statusLoadingCore: "Loading core code",
1218+ errorLoadingCore: "Error loading the core code",
1219+ errorCoreFormat: "Error with the new core code",
1220+ statusSavingCore: "Saving the new core code",
1221+ statusReloadingCore: "Reloading the new core code",
1222+ startLabel: "start",
1223+ startPrompt: "Start the upgrade process",
1224+ cancelLabel: "cancel",
1225+ cancelPrompt: "Cancel the upgrade process",
1226+ step3Title: "Upgrade cancelled",
1227+ step3Html: "You have cancelled the upgrade process"
1228+ });
1229+
1230+merge(config.macros.annotations,{
1231+ });
1232+
1233+merge(config.commands.closeTiddler,{
1234+ text: "close",
1235+ tooltip: "Close this tiddler"});
1236+
1237+merge(config.commands.closeOthers,{
1238+ text: "close others",
1239+ tooltip: "Close all other tiddlers"});
1240+
1241+merge(config.commands.editTiddler,{
1242+ text: "edit",
1243+ tooltip: "Edit this tiddler",
1244+ readOnlyText: "view",
1245+ readOnlyTooltip: "View the source of this tiddler"});
1246+
1247+merge(config.commands.saveTiddler,{
1248+ text: "done",
1249+ tooltip: "Save changes to this tiddler"});
1250+
1251+merge(config.commands.cancelTiddler,{
1252+ text: "cancel",
1253+ tooltip: "Undo changes to this tiddler",
1254+ warning: "Are you sure you want to abandon your changes to '%0'?",
1255+ readOnlyText: "done",
1256+ readOnlyTooltip: "View this tiddler normally"});
1257+
1258+merge(config.commands.deleteTiddler,{
1259+ text: "delete",
1260+ tooltip: "Delete this tiddler",
1261+ warning: "Are you sure you want to delete '%0'?"});
1262+
1263+merge(config.commands.permalink,{
1264+ text: "permalink",
1265+ tooltip: "Permalink for this tiddler"});
1266+
1267+merge(config.commands.references,{
1268+ text: "references",
1269+ tooltip: "Show tiddlers that link to this one",
1270+ popupNone: "No references"});
1271+
1272+merge(config.commands.jump,{
1273+ text: "jump",
1274+ tooltip: "Jump to another open tiddler"});
1275+
1276+merge(config.commands.fields,{
1277+ text: "fields",
1278+ tooltip: "Show the extended fields of this tiddler",
1279+ emptyText: "There are no extended fields for this tiddler",
1280+ listViewTemplate: {
1281+ columns: [
1282+ {name: 'Field', field: 'field', title: "Field", type: 'String'},
1283+ {name: 'Value', field: 'value', title: "Value", type: 'String'}
1284+ ],
1285+ rowClasses: [
1286+ ],
1287+ buttons: [
1288+ ]}});
1289+
1290+merge(config.shadowTiddlers,{
1291+ DefaultTiddlers: "[[GettingStarted]]",
1292+ MainMenu: "[[GettingStarted]]",
1293+ SiteTitle: "My TiddlyWiki",
1294+ SiteSubtitle: "a reusable non-linear personal web notebook",
1295+ SiteUrl: "",
1296+ SideBarOptions: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options \u00bb" "Change TiddlyWiki advanced options">>',
1297+ SideBarTabs: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>',
1298+ TabMore: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>'
1299+ });
1300+
1301+merge(config.annotations,{
1302+ AdvancedOptions: "This shadow tiddler provides access to several advanced options",
1303+ ColorPalette: "These values in this shadow tiddler determine the colour scheme of the ~TiddlyWiki user interface",
1304+ DefaultTiddlers: "The tiddlers listed in this shadow tiddler will be automatically displayed when ~TiddlyWiki starts up",
1305+ EditTemplate: "The HTML template in this shadow tiddler determines how tiddlers look while they are being edited",
1306+ GettingStarted: "This shadow tiddler provides basic usage instructions",
1307+ ImportTiddlers: "This shadow tiddler provides access to importing tiddlers",
1308+ MainMenu: "This shadow tiddler is used as the contents of the main menu in the left-hand column of the screen",
1309+ MarkupPreHead: "This tiddler is inserted at the top of the <head> section of the TiddlyWiki HTML file",
1310+ MarkupPostHead: "This tiddler is inserted at the bottom of the <head> section of the TiddlyWiki HTML file",
1311+ MarkupPreBody: "This tiddler is inserted at the top of the <body> section of the TiddlyWiki HTML file",
1312+ MarkupPostBody: "This tiddler is inserted at the end of the <body> section of the TiddlyWiki HTML file immediately after the script block",
1313+ OptionsPanel: "This shadow tiddler is used as the contents of the options panel slider in the right-hand sidebar",
1314+ PageTemplate: "The HTML template in this shadow tiddler determines the overall ~TiddlyWiki layout",
1315+ PluginManager: "This shadow tiddler provides access to the plugin manager",
1316+ SideBarOptions: "This shadow tiddler is used as the contents of the option panel in the right-hand sidebar",
1317+ SideBarTabs: "This shadow tiddler is used as the contents of the tabs panel in the right-hand sidebar",
1318+ SiteSubtitle: "This shadow tiddler is used as the second part of the page title",
1319+ SiteTitle: "This shadow tiddler is used as the first part of the page title",
1320+ SiteUrl: "This shadow tiddler should be set to the full target URL for publication",
1321+ 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",
1322+ StyleSheet: "This tiddler can contain custom CSS definitions",
1323+ 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",
1324+ StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale",
1325+ StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing",
1326+ SystemSettings: "This tiddler is used to store configuration options for this TiddlyWiki document",
1327+ TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar",
1328+ TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar",
1329+ TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar",
1330+ TabMoreOrphans: "This shadow tiddler contains the contents of the 'Orphans' tab in the right-hand sidebar",
1331+ TabMoreShadowed: "This shadow tiddler contains the contents of the 'Shadowed' tab in the right-hand sidebar",
1332+ TabTags: "This shadow tiddler contains the contents of the 'Tags' tab in the right-hand sidebar",
1333+ TabTimeline: "This shadow tiddler contains the contents of the 'Timeline' tab in the right-hand sidebar",
1334+ ToolbarCommands: "This shadow tiddler determines which commands are shown in tiddler toolbars",
1335+ ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look"
1336+ });
1337+//--
1338+//-- Main
1339+//--
1340+
1341+var params = null; // Command line parameters
1342+var store = null; // TiddlyWiki storage
1343+var story = null; // Main story
1344+var formatter = null; // Default formatters for the wikifier
1345+var anim = typeof Animator == "function" ? new Animator() : null; // Animation engine
1346+var readOnly = false; // Whether we're in readonly mode
1347+var highlightHack = null; // Embarrassing hack department...
1348+var hadConfirmExit = false; // Don't warn more than once
1349+var safeMode = false; // Disable all plugins and cookies
1350+var showBackstage; // Whether to include the backstage area
1351+var installedPlugins = []; // Information filled in when plugins are executed
1352+var startingUp = false; // Whether we're in the process of starting up
1353+var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins()
1354+
1355+// Whether this file can be saved back to the same location [Preemption]
1356+window.allowSave = window.allowSave || function(l)
1357+{
1358+ return true;
1359+}
1360+
1361+// Whether this file is being viewed locally
1362+window.isLocal = function()
1363+{
1364+ return (document.location.protocol == "file:");
1365+}
1366+
1367+// Whether to use the JavaSaver applet
1368+var useJavaSaver = window.isLocal() && (config.browser.isSafari || config.browser.isOpera);
1369+
1370+// Allow preemption code a chance to tweak config and useJavaSaver [Preemption]
1371+if (window.tweakConfig) window.tweakConfig();
1372+
1373+if(!window || !window.console) {
1374+ console = {tiddlywiki:true,log:function(message) {displayMessage(message);}};
1375+}
1376+
1377+// Starting up
1378+function main()
1379+{
1380+ window.originalHTML=recreateOriginal();
1381+
1382+ var t10,t9,t8,t7,t6,t5,t4,t3,t2,t1,t0 = new Date();
1383+ startingUp = true;
1384+ var doc = jQuery(document);
1385+ jQuery.noConflict();
1386+ window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();};
1387+ params = getParameters();
1388+ if(params)
1389+ params = params.parseParams("open",null,false);
1390+ store = new TiddlyWiki({config:config});
1391+ invokeParamifier(params,"oninit");
1392+ story = new Story("tiddlerDisplay","tiddler");
1393+ addEvent(document,"click",Popup.onDocumentClick);
1394+ saveTest();
1395+ var s;
1396+ for(s=0; s<config.notifyTiddlers.length; s++)
1397+ store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify);
1398+ t1 = new Date();
1399+ loadShadowTiddlers();
1400+ doc.trigger("loadShadows");
1401+ t2 = new Date();
1402+ store.loadFromDiv("storeArea","store",true);
1403+ doc.trigger("loadTiddlers");
1404+ loadOptions();
1405+ t3 = new Date();
1406+ invokeParamifier(params,"onload");
1407+ t4 = new Date();
1408+ readOnly = window.isLocal() ? false : config.options.chkHttpReadOnly;
1409+ var pluginProblem = loadPlugins("systemConfig");
1410+ doc.trigger("loadPlugins");
1411+ t5 = new Date();
1412+ formatter = new Formatter(config.formatters);
1413+ invokeParamifier(params,"onconfig");
1414+ story.switchTheme(config.options.txtTheme);
1415+ showBackstage = showBackstage !== undefined ? showBackstage : !readOnly;
1416+ t6 = new Date();
1417+ var m;
1418+ for(m in config.macros) {
1419+ if(config.macros[m].init)
1420+ config.macros[m].init();
1421+ }
1422+ t7 = new Date();
1423+ store.notifyAll();
1424+ t8 = new Date();
1425+ restart();
1426+ refreshDisplay();
1427+ t9 = new Date();
1428+ if(pluginProblem) {
1429+ story.displayTiddler(null,"PluginManager");
1430+ displayMessage(config.messages.customConfigError);
1431+ }
1432+ if(showBackstage)
1433+ backstage.init();
1434+ t10 = new Date();
1435+ if(config.options.chkDisplayInstrumentation) {
1436+ displayMessage("LoadShadows " + (t2-t1) + " ms");
1437+ displayMessage("LoadFromDiv " + (t3-t2) + " ms");
1438+ displayMessage("LoadPlugins " + (t5-t4) + " ms");
1439+ displayMessage("Macro init " + (t7-t6) + " ms");
1440+ displayMessage("Notify " + (t8-t7) + " ms");
1441+ displayMessage("Restart " + (t9-t8) + " ms");
1442+ displayMessage("Total: " + (t10-t0) + " ms");
1443+ }
1444+ startingUp = false;
1445+ doc.trigger("startup");
1446+}
1447+
1448+// Called on unload. All functions called conditionally since they themselves may have been unloaded.
1449+function unload()
1450+{
1451+ if(window.checkUnsavedChanges)
1452+ checkUnsavedChanges();
1453+ if(window.scrubNodes)
1454+ scrubNodes(document.body);
1455+}
1456+
1457+// Restarting
1458+function restart()
1459+{
1460+ invokeParamifier(params,"onstart");
1461+ if(story.isEmpty()) {
1462+ story.displayDefaultTiddlers();
1463+ }
1464+ window.scrollTo(0,0);
1465+}
1466+
1467+function saveTest()
1468+{
1469+ var s = document.getElementById("saveTest");
1470+ if(s.hasChildNodes())
1471+ alert(config.messages.savedSnapshotError);
1472+ s.appendChild(document.createTextNode("savetest"));
1473+}
1474+
1475+function loadShadowTiddlers()
1476+{
1477+ var shadows = new TiddlyWiki();
1478+ shadows.loadFromDiv("shadowArea","shadows",true);
1479+ shadows.forEachTiddler(function(title,tiddler){config.shadowTiddlers[title] = tiddler.text;});
1480+}
1481+
1482+function loadPlugins(tag)
1483+{
1484+ if(safeMode)
1485+ return false;
1486+ var tiddlers = store.getTaggedTiddlers(tag);
1487+ tiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : 1);});
1488+ var toLoad = [];
1489+ var nLoaded = 0;
1490+ var map = {};
1491+ var nPlugins = tiddlers.length;
1492+ installedPlugins = [];
1493+ var i;
1494+ for(i=0; i<nPlugins; i++) {
1495+ var p = getPluginInfo(tiddlers[i]);
1496+ installedPlugins[i] = p;
1497+ var n = p.Name || p.title;
1498+ if(n)
1499+ map[n] = p;
1500+ n = p.Source;
1501+ if(n)
1502+ map[n] = p;
1503+ }
1504+ var visit = function(p) {
1505+ if(!p || p.done)
1506+ return;
1507+ p.done = 1;
1508+ var reqs = p.Requires;
1509+ if(reqs) {
1510+ reqs = reqs.readBracketedList();
1511+ var i;
1512+ for(i=0; i<reqs.length; i++)
1513+ visit(map[reqs[i]]);
1514+ }
1515+ toLoad.push(p);
1516+ };
1517+ for(i=0; i<nPlugins; i++)
1518+ visit(installedPlugins[i]);
1519+ for(i=0; i<toLoad.length; i++) {
1520+ p = toLoad[i];
1521+ pluginInfo = p;
1522+ tiddler = p.tiddler;
1523+ if(isPluginExecutable(p)) {
1524+ if(isPluginEnabled(p)) {
1525+ p.executed = true;
1526+ var startTime = new Date();
1527+ try {
1528+ if(tiddler.text)
1529+ window.eval(tiddler.text);
1530+ nLoaded++;
1531+ } catch(ex) {
1532+ p.log.push(config.messages.pluginError.format([exceptionText(ex)]));
1533+ p.error = true;
1534+ if(!console.tiddlywiki) {
1535+ console.log("error evaluating " + tiddler.title, ex);
1536+ }
1537+ }
1538+ pluginInfo.startupTime = String((new Date()) - startTime) + "ms";
1539+ } else {
1540+ nPlugins--;
1541+ }
1542+ } else {
1543+ p.warning = true;
1544+ }
1545+ }
1546+ return nLoaded != nPlugins;
1547+}
1548+
1549+function getPluginInfo(tiddler)
1550+{
1551+ var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","Requires","CoreVersion","Date","Source","Author","License","Browsers"]);
1552+ p.tiddler = tiddler;
1553+ p.title = tiddler.title;
1554+ p.log = [];
1555+ return p;
1556+}
1557+
1558+// Check that a particular plugin is valid for execution
1559+function isPluginExecutable(plugin)
1560+{
1561+ if(plugin.tiddler.isTagged("systemConfigForce")) {
1562+ plugin.log.push(config.messages.pluginForced);
1563+ return true;
1564+ }
1565+ if(plugin["CoreVersion"]) {
1566+ var coreVersion = plugin["CoreVersion"].split(".");
1567+ var w = parseInt(coreVersion[0],10) - version.major;
1568+ if(w == 0 && coreVersion[1])
1569+ w = parseInt(coreVersion[1],10) - version.minor;
1570+ if(w == 0 && coreVersion[2])
1571+ w = parseInt(coreVersion[2],10) - version.revision;
1572+ if(w > 0) {
1573+ plugin.log.push(config.messages.pluginVersionError);
1574+ return false;
1575+ }
1576+ }
1577+ return true;
1578+}
1579+
1580+function isPluginEnabled(plugin)
1581+{
1582+ if(plugin.tiddler.isTagged("systemConfigDisable")) {
1583+ plugin.log.push(config.messages.pluginDisabled);
1584+ return false;
1585+ }
1586+ return true;
1587+}
1588+
1589+//--
1590+//-- Paramifiers
1591+//--
1592+
1593+function getParameters()
1594+{
1595+ var p = null;
1596+ if(window.location.hash) {
1597+ p = decodeURIComponent(window.location.hash.substr(1));
1598+ if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111")
1599+ p = convertUTF8ToUnicode(p);
1600+ }
1601+ return p;
1602+}
1603+
1604+function invokeParamifier(params,handler)
1605+{
1606+ if(!params || params.length == undefined || params.length <= 1)
1607+ return;
1608+ var i;
1609+ for(i=1; i<params.length; i++) {
1610+ var p = config.paramifiers[params[i].name];
1611+ if(p && p[handler] instanceof Function)
1612+ p[handler](params[i].value);
1613+ else {
1614+ var h = config.optionHandlers[params[i].name.substr(0,3)];
1615+ if(h && h.set instanceof Function)
1616+ h.set(params[i].name,params[i].value);
1617+ }
1618+ }
1619+}
1620+
1621+config.paramifiers = {};
1622+
1623+config.paramifiers.start = {
1624+ oninit: function(v) {
1625+ safeMode = v.toLowerCase() == "safe";
1626+ }
1627+};
1628+
1629+config.paramifiers.open = {
1630+ onstart: function(v) {
1631+ if(!readOnly || store.tiddlerExists(v) || store.isShadowTiddler(v))
1632+ story.displayTiddler("bottom",v,null,false,null);
1633+ }
1634+};
1635+
1636+config.paramifiers.story = {
1637+ onstart: function(v) {
1638+ var list = store.getTiddlerText(v,"").parseParams("open",null,false);
1639+ invokeParamifier(list,"onstart");
1640+ }
1641+};
1642+
1643+config.paramifiers.search = {
1644+ onstart: function(v) {
1645+ story.search(v,false,false);
1646+ }
1647+};
1648+
1649+config.paramifiers.searchRegExp = {
1650+ onstart: function(v) {
1651+ story.prototype.search(v,false,true);
1652+ }
1653+};
1654+
1655+config.paramifiers.tag = {
1656+ onstart: function(v) {
1657+ story.displayTiddlers(null,store.filterTiddlers("[tag["+v+"]]"),null,false,null);
1658+ }
1659+};
1660+
1661+config.paramifiers.newTiddler = {
1662+ onstart: function(v) {
1663+ var args = v.parseParams("anon", null, null)[0];
1664+ var title = args.title ? args.title[0] : v;
1665+ var customFields = args.fields ? args.fields[0] : null;
1666+ if(!readOnly) {
1667+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,customFields);
1668+ story.focusTiddler(title,"text");
1669+ var i,tags = args.tag || [];
1670+ for(i=0;i<tags.length;i++) {
1671+ story.setTiddlerTag(title,tags[i],+1);
1672+ }
1673+ }
1674+ }
1675+};
1676+
1677+config.paramifiers.newJournal = {
1678+ onstart: function(v) {
1679+ if(!readOnly) {
1680+ var now = new Date();
1681+ var title = now.formatString(v.trim());
1682+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
1683+ story.focusTiddler(title,"text");
1684+ }
1685+ }
1686+};
1687+
1688+config.paramifiers.readOnly = {
1689+ onconfig: function(v) {
1690+ var p = v.toLowerCase();
1691+ readOnly = p == "yes" ? true : (p == "no" ? false : readOnly);
1692+ }
1693+};
1694+
1695+config.paramifiers.theme = {
1696+ onconfig: function(v) {
1697+ story.switchTheme(v);
1698+ }
1699+};
1700+
1701+config.paramifiers.upgrade = {
1702+ onstart: function(v) {
1703+ upgradeFrom(v);
1704+ }
1705+};
1706+
1707+config.paramifiers.recent= {
1708+ onstart: function(v) {
1709+ var titles=[];
1710+ var i,tiddlers=store.getTiddlers("modified","excludeLists").reverse();
1711+ for(i=0; i<v && i<tiddlers.length; i++)
1712+ titles.push(tiddlers[i].title);
1713+ story.displayTiddlers(null,titles);
1714+ }
1715+};
1716+
1717+config.paramifiers.filter = {
1718+ onstart: function(v) {
1719+ story.displayTiddlers(null,store.filterTiddlers(v),null,false);
1720+ }
1721+};
1722+
1723+//--
1724+//-- Formatter helpers
1725+//--
1726+
1727+function Formatter(formatters)
1728+{
1729+ var n;
1730+ this.formatters = [];
1731+ var pattern = [];
1732+ for(n=0; n<formatters.length; n++) {
1733+ pattern.push("(" + formatters[n].match + ")");
1734+ this.formatters.push(formatters[n]);
1735+ }
1736+ this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
1737+}
1738+
1739+config.formatterHelpers = {
1740+
1741+ createElementAndWikify: function(w)
1742+ {
1743+ w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
1744+ },
1745+
1746+ inlineCssHelper: function(w)
1747+ {
1748+ var styles = [];
1749+ config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
1750+ var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
1751+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
1752+ var s,v;
1753+ if(lookaheadMatch[1]) {
1754+ s = lookaheadMatch[1].unDash();
1755+ v = lookaheadMatch[2];
1756+ } else {
1757+ s = lookaheadMatch[3].unDash();
1758+ v = lookaheadMatch[4];
1759+ }
1760+ if(s=="bgcolor")
1761+ s = "backgroundColor";
1762+ if(s=="float")
1763+ s = "cssFloat";
1764+ styles.push({style: s, value: v});
1765+ w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
1766+ config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
1767+ lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
1768+ }
1769+ return styles;
1770+ },
1771+
1772+ applyCssHelper: function(e,styles)
1773+ {
1774+ var t;
1775+ for(t=0; t< styles.length; t++) {
1776+ try {
1777+ e.style[styles[t].style] = styles[t].value;
1778+ } catch (ex) {
1779+ }
1780+ }
1781+ },
1782+
1783+ enclosedTextHelper: function(w)
1784+ {
1785+ this.lookaheadRegExp.lastIndex = w.matchStart;
1786+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
1787+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
1788+ var text = lookaheadMatch[1];
1789+ if(config.browser.isIE && (config.browser.ieVersion[1] < 10))
1790+ text = text.replace(/\n/g,"\r");
1791+ createTiddlyElement(w.output,this.element,null,null,text);
1792+ w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
1793+ }
1794+ },
1795+
1796+ isExternalLink: function(link)
1797+ {
1798+ if(store.tiddlerExists(link) || store.isShadowTiddler(link)) {
1799+ return false;
1800+ }
1801+ var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
1802+ if(urlRegExp.exec(link)) {
1803+ return true;
1804+ }
1805+ if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) {
1806+ return true;
1807+ }
1808+ return false;
1809+ }
1810+
1811+};
1812+
1813+//--
1814+//-- Standard formatters
1815+//--
1816+
1817+config.formatters = [
1818+{
1819+ name: "table",
1820+ match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
1821+ lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
1822+ rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
1823+ cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
1824+ cellTermRegExp: /((?:\x20*)\|)/mg,
1825+ rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
1826+ handler: function(w)
1827+ {
1828+ var table = createTiddlyElement(w.output,"table",null,"twtable");
1829+ var prevColumns = [];
1830+ var currRowType = null;
1831+ var rowContainer;
1832+ var rowCount = 0;
1833+ var onmouseover = function() {jQuery(this).addClass("hoverRow");};
1834+ var onmouseout = function() {jQuery(this).removeClass("hoverRow");};
1835+ w.nextMatch = w.matchStart;
1836+ this.lookaheadRegExp.lastIndex = w.nextMatch;
1837+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
1838+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
1839+ var nextRowType = lookaheadMatch[2];
1840+ if(nextRowType == "k") {
1841+ table.className = lookaheadMatch[1];
1842+ w.nextMatch += lookaheadMatch[0].length+1;
1843+ } else {
1844+ if(nextRowType != currRowType) {
1845+ rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]);
1846+ currRowType = nextRowType;
1847+ }
1848+ if(currRowType == "c") {
1849+ // Caption
1850+ w.nextMatch++;
1851+ if(rowContainer != table.firstChild)
1852+ table.insertBefore(rowContainer,table.firstChild);
1853+ rowContainer.setAttribute("align",rowCount == 0?"top":"bottom");
1854+ w.subWikifyTerm(rowContainer,this.rowTermRegExp);
1855+ } else {
1856+ var theRow = createTiddlyElement(rowContainer,"tr",null,rowCount%2?"oddRow":"evenRow");
1857+ theRow.onmouseover = onmouseover;
1858+ theRow.onmouseout = onmouseout;
1859+ this.rowHandler(w,theRow,prevColumns);
1860+ rowCount++;
1861+ }
1862+ }
1863+ this.lookaheadRegExp.lastIndex = w.nextMatch;
1864+ lookaheadMatch = this.lookaheadRegExp.exec(w.source);
1865+ }
1866+ },
1867+ rowHandler: function(w,e,prevColumns)
1868+ {
1869+ var col = 0;
1870+ var colSpanCount = 1;
1871+ var prevCell = null;
1872+ this.cellRegExp.lastIndex = w.nextMatch;
1873+ var cellMatch = this.cellRegExp.exec(w.source);
1874+ while(cellMatch && cellMatch.index == w.nextMatch) {
1875+ if(cellMatch[1] == "~") {
1876+ // Rowspan
1877+ var last = prevColumns[col];
1878+ if(last) {
1879+ last.rowSpanCount++;
1880+ last.element.setAttribute("rowspan",last.rowSpanCount);
1881+ last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE
1882+ last.element.valign = "center";
1883+ if(colSpanCount > 1) {
1884+ last.element.setAttribute("colspan",colSpanCount);
1885+ last.element.setAttribute("colSpan",colSpanCount); // Needed for IE
1886+ colSpanCount = 1;
1887+ }
1888+ }
1889+ w.nextMatch = this.cellRegExp.lastIndex-1;
1890+ } else if(cellMatch[1] == ">") {
1891+ // Colspan
1892+ colSpanCount++;
1893+ w.nextMatch = this.cellRegExp.lastIndex-1;
1894+ } else if(cellMatch[2]) {
1895+ // End of row
1896+ if(prevCell && colSpanCount > 1) {
1897+ prevCell.setAttribute("colspan",colSpanCount);
1898+ prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE
1899+ }
1900+ w.nextMatch = this.cellRegExp.lastIndex;
1901+ break;
1902+ } else {
1903+ // Cell
1904+ w.nextMatch++;
1905+ var styles = config.formatterHelpers.inlineCssHelper(w);
1906+ var spaceLeft = false;
1907+ var chr = w.source.substr(w.nextMatch,1);
1908+ while(chr == " ") {
1909+ spaceLeft = true;
1910+ w.nextMatch++;
1911+ chr = w.source.substr(w.nextMatch,1);
1912+ }
1913+ var cell;
1914+ if(chr == "!") {
1915+ cell = createTiddlyElement(e,"th");
1916+ w.nextMatch++;
1917+ } else {
1918+ cell = createTiddlyElement(e,"td");
1919+ }
1920+ prevCell = cell;
1921+ prevColumns[col] = {rowSpanCount:1,element:cell};
1922+ if(colSpanCount > 1) {
1923+ cell.setAttribute("colspan",colSpanCount);
1924+ cell.setAttribute("colSpan",colSpanCount); // Needed for IE
1925+ colSpanCount = 1;
1926+ }
1927+ config.formatterHelpers.applyCssHelper(cell,styles);
1928+ w.subWikifyTerm(cell,this.cellTermRegExp);
1929+ if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
1930+ cell.align = spaceLeft ? "center" : "left";
1931+ else if(spaceLeft)
1932+ cell.align = "right";
1933+ w.nextMatch--;
1934+ }
1935+ col++;
1936+ this.cellRegExp.lastIndex = w.nextMatch;
1937+ cellMatch = this.cellRegExp.exec(w.source);
1938+ }
1939+ }
1940+},
1941+
1942+{
1943+ name: "heading",
1944+ match: "^!{1,6}",
1945+ termRegExp: /(\n)/mg,
1946+ handler: function(w)
1947+ {
1948+ w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp);
1949+ }
1950+},
1951+
1952+{
1953+ name: "list",
1954+ match: "^(?:[\\*#;:]+)",
1955+ lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
1956+ termRegExp: /(\n)/mg,
1957+ handler: function(w)
1958+ {
1959+ var stack = [w.output];
1960+ var currLevel = 0, currType = null;
1961+ var listLevel, listType, itemType, baseType;
1962+ w.nextMatch = w.matchStart;
1963+ this.lookaheadRegExp.lastIndex = w.nextMatch;
1964+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
1965+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
1966+ if(lookaheadMatch[1]) {
1967+ listType = "ul";
1968+ itemType = "li";
1969+ } else if(lookaheadMatch[2]) {
1970+ listType = "ol";
1971+ itemType = "li";
1972+ } else if(lookaheadMatch[3]) {
1973+ listType = "dl";
1974+ itemType = "dt";
1975+ } else if(lookaheadMatch[4]) {
1976+ listType = "dl";
1977+ itemType = "dd";
1978+ }
1979+ if(!baseType)
1980+ baseType = listType;
1981+ listLevel = lookaheadMatch[0].length;
1982+ w.nextMatch += lookaheadMatch[0].length;
1983+ var t;
1984+ if(listLevel > currLevel) {
1985+ for(t=currLevel; t<listLevel; t++) {
1986+ var target = (currLevel == 0) ? stack[stack.length-1] : stack[stack.length-1].lastChild;
1987+ stack.push(createTiddlyElement(target,listType));
1988+ }
1989+ } else if(listType!=baseType && listLevel==1) {
1990+ w.nextMatch -= lookaheadMatch[0].length;
1991+ return;
1992+ } else if(listLevel < currLevel) {
1993+ for(t=currLevel; t>listLevel; t--)
1994+ stack.pop();
1995+ } else if(listLevel == currLevel && listType != currType) {
1996+ stack.pop();
1997+ stack.push(createTiddlyElement(stack[stack.length-1].lastChild,listType));
1998+ }
1999+ currLevel = listLevel;
2000+ currType = listType;
2001+ var e = createTiddlyElement(stack[stack.length-1],itemType);
2002+ w.subWikifyTerm(e,this.termRegExp);
2003+ this.lookaheadRegExp.lastIndex = w.nextMatch;
2004+ lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2005+ }
2006+ }
2007+},
2008+
2009+{
2010+ name: "quoteByBlock",
2011+ match: "^<<<\\n",
2012+ termRegExp: /(^<<<(\n|$))/mg,
2013+ element: "blockquote",
2014+ handler: config.formatterHelpers.createElementAndWikify
2015+},
2016+
2017+{
2018+ name: "quoteByLine",
2019+ match: "^>+",
2020+ lookaheadRegExp: /^>+/mg,
2021+ termRegExp: /(\n)/mg,
2022+ element: "blockquote",
2023+ handler: function(w)
2024+ {
2025+ var stack = [w.output];
2026+ var currLevel = 0;
2027+ var newLevel = w.matchLength;
2028+ var t,matched;
2029+ do {
2030+ if(newLevel > currLevel) {
2031+ for(t=currLevel; t<newLevel; t++)
2032+ stack.push(createTiddlyElement(stack[stack.length-1],this.element));
2033+ } else if(newLevel < currLevel) {
2034+ for(t=currLevel; t>newLevel; t--)
2035+ stack.pop();
2036+ }
2037+ currLevel = newLevel;
2038+ w.subWikifyTerm(stack[stack.length-1],this.termRegExp);
2039+ createTiddlyElement(stack[stack.length-1],"br");
2040+ this.lookaheadRegExp.lastIndex = w.nextMatch;
2041+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2042+ matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
2043+ if(matched) {
2044+ newLevel = lookaheadMatch[0].length;
2045+ w.nextMatch += lookaheadMatch[0].length;
2046+ }
2047+ } while(matched);
2048+ }
2049+},
2050+
2051+{
2052+ name: "rule",
2053+ match: "^----+$\\n?|<hr ?/?>\\n?",
2054+ handler: function(w)
2055+ {
2056+ createTiddlyElement(w.output,"hr");
2057+ }
2058+},
2059+
2060+{
2061+ name: "monospacedByLine",
2062+ match: "^(?:/\\*\\{\\{\\{\\*/|\\{\\{\\{|//\\{\\{\\{|<!--\\{\\{\\{-->)\\n",
2063+ element: "pre",
2064+ handler: function(w)
2065+ {
2066+ switch(w.matchText) {
2067+ case "/*{{{*/\n": // CSS
2068+ this.lookaheadRegExp = /\/\*\{\{\{\*\/\n*((?:^[^\n]*\n)+?)(\n*^\f*\/\*\}\}\}\*\/$\n?)/mg;
2069+ break;
2070+ case "{{{\n": // monospaced block
2071+ this.lookaheadRegExp = /^\{\{\{\n((?:^[^\n]*\n)+?)(^\f*\}\}\}$\n?)/mg;
2072+ break;
2073+ case "//{{{\n": // plugin
2074+ this.lookaheadRegExp = /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\f*\/\/\}\}\}$\n?)/mg;
2075+ break;
2076+ case "<!--{{{-->\n": //template
2077+ this.lookaheadRegExp = /<!--\{\{\{-->\n*((?:^[^\n]*\n)+?)(\n*^\f*<!--\}\}\}-->$\n?)/mg;
2078+ break;
2079+ default:
2080+ break;
2081+ }
2082+ config.formatterHelpers.enclosedTextHelper.call(this,w);
2083+ }
2084+},
2085+
2086+{
2087+ name: "wikifyComment",
2088+ match: "^(?:/\\*\\*\\*|<!---)\\n",
2089+ handler: function(w)
2090+ {
2091+ var termRegExp = (w.matchText == "/***\n") ? (/(^\*\*\*\/\n)/mg) : (/(^--->\n)/mg);
2092+ w.subWikifyTerm(w.output,termRegExp);
2093+ }
2094+},
2095+
2096+{
2097+ name: "macro",
2098+ match: "<<",
2099+ lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
2100+ handler: function(w)
2101+ {
2102+ this.lookaheadRegExp.lastIndex = w.matchStart;
2103+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2104+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) {
2105+ w.nextMatch = this.lookaheadRegExp.lastIndex;
2106+ invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
2107+ }
2108+ }
2109+},
2110+
2111+{
2112+ name: "prettyLink",
2113+ match: "\\[\\[",
2114+ lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg,
2115+ handler: function(w)
2116+ {
2117+ this.lookaheadRegExp.lastIndex = w.matchStart;
2118+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2119+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
2120+ var e;
2121+ var text = lookaheadMatch[1];
2122+ if(lookaheadMatch[3]) {
2123+ // Pretty bracketted link
2124+ var link = lookaheadMatch[3];
2125+ e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link)) ?
2126+ createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
2127+ } else {
2128+ // Simple bracketted link
2129+ e = createTiddlyLink(w.output,text,false,null,w.isStatic,w.tiddler);
2130+ }
2131+ createTiddlyText(e,text);
2132+ w.nextMatch = this.lookaheadRegExp.lastIndex;
2133+ }
2134+ }
2135+},
2136+
2137+{
2138+ name: "wikiLink",
2139+ match: config.textPrimitives.unWikiLink+"?"+config.textPrimitives.wikiLink,
2140+ handler: function(w)
2141+ {
2142+ if(w.matchText.substr(0,1) == config.textPrimitives.unWikiLink) {
2143+ w.outputText(w.output,w.matchStart+1,w.nextMatch);
2144+ return;
2145+ }
2146+ if(w.matchStart > 0) {
2147+ var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg");
2148+ preRegExp.lastIndex = w.matchStart-1;
2149+ var preMatch = preRegExp.exec(w.source);
2150+ if(preMatch.index == w.matchStart-1) {
2151+ w.outputText(w.output,w.matchStart,w.nextMatch);
2152+ return;
2153+ }
2154+ }
2155+ if(w.autoLinkWikiWords || store.isShadowTiddler(w.matchText)) {
2156+ var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic,w.tiddler);
2157+ w.outputText(link,w.matchStart,w.nextMatch);
2158+ } else {
2159+ w.outputText(w.output,w.matchStart,w.nextMatch);
2160+ }
2161+ }
2162+},
2163+
2164+{
2165+ name: "urlLink",
2166+ match: config.textPrimitives.urlPattern,
2167+ handler: function(w)
2168+ {
2169+ w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
2170+ }
2171+},
2172+
2173+{
2174+ name: "image",
2175+ match: "\\[[<>]?[Ii][Mm][Gg]\\[",
2176+ lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
2177+ handler: function(w)
2178+ {
2179+ this.lookaheadRegExp.lastIndex = w.matchStart;
2180+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2181+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
2182+ var e = w.output;
2183+ if(lookaheadMatch[5]) {
2184+ var link = lookaheadMatch[5];
2185+ e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
2186+ jQuery(e).addClass("imageLink");
2187+ }
2188+ var img = createTiddlyElement(e,"img");
2189+ if(lookaheadMatch[1])
2190+ img.align = "left";
2191+ else if(lookaheadMatch[2])
2192+ img.align = "right";
2193+ if(lookaheadMatch[3]) {
2194+ img.title = lookaheadMatch[3];
2195+ img.setAttribute("alt",lookaheadMatch[3]);
2196+ }
2197+ img.src = lookaheadMatch[4];
2198+ w.nextMatch = this.lookaheadRegExp.lastIndex;
2199+ }
2200+ }
2201+},
2202+
2203+{
2204+ name: "html",
2205+ match: "<[Hh][Tt][Mm][Ll]>",
2206+ lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg,
2207+ handler: function(w)
2208+ {
2209+ this.lookaheadRegExp.lastIndex = w.matchStart;
2210+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2211+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
2212+ createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1];
2213+ w.nextMatch = this.lookaheadRegExp.lastIndex;
2214+ }
2215+ }
2216+},
2217+
2218+{
2219+ name: "commentByBlock",
2220+ match: "/%",
2221+ lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg,
2222+ handler: function(w)
2223+ {
2224+ this.lookaheadRegExp.lastIndex = w.matchStart;
2225+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2226+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
2227+ w.nextMatch = this.lookaheadRegExp.lastIndex;
2228+ }
2229+},
2230+
2231+{
2232+ name: "characterFormat",
2233+ match: "''|//|__|\\^\\^|~~|--(?!\\s|$)|\\{\\{\\{",
2234+ handler: function(w)
2235+ {
2236+ switch(w.matchText) {
2237+ case "''":
2238+ w.subWikifyTerm(w.output.appendChild(document.createElement("strong")),/('')/mg);
2239+ break;
2240+ case "//":
2241+ w.subWikifyTerm(createTiddlyElement(w.output,"em"),/(\/\/)/mg);
2242+ break;
2243+ case "__":
2244+ w.subWikifyTerm(createTiddlyElement(w.output,"u"),/(__)/mg);
2245+ break;
2246+ case "^^":
2247+ w.subWikifyTerm(createTiddlyElement(w.output,"sup"),/(\^\^)/mg);
2248+ break;
2249+ case "~~":
2250+ w.subWikifyTerm(createTiddlyElement(w.output,"sub"),/(~~)/mg);
2251+ break;
2252+ case "--":
2253+ w.subWikifyTerm(createTiddlyElement(w.output,"strike"),/(--)/mg);
2254+ break;
2255+ case "{{{":
2256+ var lookaheadRegExp = /\{\{\{((?:.|\n)*?)\}\}\}/mg;
2257+ lookaheadRegExp.lastIndex = w.matchStart;
2258+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
2259+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
2260+ createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]);
2261+ w.nextMatch = lookaheadRegExp.lastIndex;
2262+ }
2263+ break;
2264+ }
2265+ }
2266+},
2267+
2268+{
2269+ name: "customFormat",
2270+ match: "@@|\\{\\{",
2271+ handler: function(w)
2272+ {
2273+ switch(w.matchText) {
2274+ case "@@":
2275+ var e = createTiddlyElement(w.output,"span");
2276+ var styles = config.formatterHelpers.inlineCssHelper(w);
2277+ if(styles.length == 0)
2278+ e.className = "marked";
2279+ else
2280+ config.formatterHelpers.applyCssHelper(e,styles);
2281+ w.subWikifyTerm(e,/(@@)/mg);
2282+ break;
2283+ case "{{":
2284+ var lookaheadRegExp = /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg;
2285+ lookaheadRegExp.lastIndex = w.matchStart;
2286+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
2287+ if(lookaheadMatch) {
2288+ w.nextMatch = lookaheadRegExp.lastIndex;
2289+ e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]);
2290+ w.subWikifyTerm(e,/(\}\}\})/mg);
2291+ }
2292+ break;
2293+ }
2294+ }
2295+},
2296+
2297+{
2298+ name: "mdash",
2299+ match: "--",
2300+ handler: function(w)
2301+ {
2302+ createTiddlyElement(w.output,"span").innerHTML = "&mdash;";
2303+ }
2304+},
2305+
2306+{
2307+ name: "lineBreak",
2308+ match: "\\n|<br ?/?>",
2309+ handler: function(w)
2310+ {
2311+ createTiddlyElement(w.output,"br");
2312+ }
2313+},
2314+
2315+{
2316+ name: "rawText",
2317+ match: "\"{3}|<nowiki>",
2318+ lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg,
2319+ handler: function(w)
2320+ {
2321+ this.lookaheadRegExp.lastIndex = w.matchStart;
2322+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
2323+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
2324+ createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]);
2325+ w.nextMatch = this.lookaheadRegExp.lastIndex;
2326+ }
2327+ }
2328+},
2329+
2330+{
2331+ name: "htmlEntitiesEncoding",
2332+ 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};)",
2333+ handler: function(w)
2334+ {
2335+ createTiddlyElement(w.output,"span").innerHTML = w.matchText;
2336+ }
2337+}
2338+
2339+];
2340+
2341+//--
2342+//-- Wikifier
2343+//--
2344+
2345+function getParser(tiddler,format)
2346+{
2347+ if(tiddler) {
2348+ if(!format)
2349+ format = tiddler.fields["wikiformat"];
2350+ var i;
2351+ if(format) {
2352+ for(i in config.parsers) {
2353+ if(format == config.parsers[i].format)
2354+ return config.parsers[i];
2355+ }
2356+ } else {
2357+ for(i in config.parsers) {
2358+ if(tiddler.isTagged(config.parsers[i].formatTag))
2359+ return config.parsers[i];
2360+ }
2361+ }
2362+ }
2363+ return formatter;
2364+}
2365+
2366+function Wikifier(source,formatter,highlightRegExp,tiddler)
2367+{
2368+ this.source = source;
2369+ this.output = null;
2370+ this.formatter = formatter;
2371+ this.nextMatch = 0;
2372+ this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true;
2373+ this.highlightRegExp = highlightRegExp;
2374+ this.highlightMatch = null;
2375+ this.isStatic = false;
2376+ if(highlightRegExp) {
2377+ highlightRegExp.lastIndex = 0;
2378+ this.highlightMatch = highlightRegExp.exec(source);
2379+ }
2380+ this.tiddler = tiddler;
2381+}
2382+
2383+Wikifier.prototype.wikifyPlain = function()
2384+{
2385+ var e = createTiddlyElement(document.body,"div");
2386+ e.style.display = "none";
2387+ this.subWikify(e);
2388+ var text = jQuery(e).text();
2389+ jQuery(e).remove();
2390+ return text;
2391+};
2392+
2393+Wikifier.prototype.subWikify = function(output,terminator)
2394+{
2395+ try {
2396+ if(terminator)
2397+ this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
2398+ else
2399+ this.subWikifyUnterm(output);
2400+ } catch(ex) {
2401+ showException(ex);
2402+ }
2403+};
2404+
2405+Wikifier.prototype.subWikifyUnterm = function(output)
2406+{
2407+ var oldOutput = this.output;
2408+ this.output = output;
2409+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
2410+ var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
2411+ while(formatterMatch) {
2412+ // Output any text before the match
2413+ if(formatterMatch.index > this.nextMatch)
2414+ this.outputText(this.output,this.nextMatch,formatterMatch.index);
2415+ // Set the match parameters for the handler
2416+ this.matchStart = formatterMatch.index;
2417+ this.matchLength = formatterMatch[0].length;
2418+ this.matchText = formatterMatch[0];
2419+ this.nextMatch = this.formatter.formatterRegExp.lastIndex;
2420+ var t;
2421+ for(t=1; t<formatterMatch.length; t++) {
2422+ if(formatterMatch[t]) {
2423+ this.formatter.formatters[t-1].handler(this);
2424+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
2425+ break;
2426+ }
2427+ }
2428+ formatterMatch = this.formatter.formatterRegExp.exec(this.source);
2429+ }
2430+ if(this.nextMatch < this.source.length) {
2431+ this.outputText(this.output,this.nextMatch,this.source.length);
2432+ this.nextMatch = this.source.length;
2433+ }
2434+ this.output = oldOutput;
2435+};
2436+
2437+Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
2438+{
2439+ var oldOutput = this.output;
2440+ this.output = output;
2441+ terminatorRegExp.lastIndex = this.nextMatch;
2442+ var terminatorMatch = terminatorRegExp.exec(this.source);
2443+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
2444+ var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
2445+ while(terminatorMatch || formatterMatch) {
2446+ if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) {
2447+ if(terminatorMatch.index > this.nextMatch)
2448+ this.outputText(this.output,this.nextMatch,terminatorMatch.index);
2449+ this.matchText = terminatorMatch[1];
2450+ this.matchLength = terminatorMatch[1].length;
2451+ this.matchStart = terminatorMatch.index;
2452+ this.nextMatch = this.matchStart + this.matchLength;
2453+ this.output = oldOutput;
2454+ return;
2455+ }
2456+ if(formatterMatch.index > this.nextMatch)
2457+ this.outputText(this.output,this.nextMatch,formatterMatch.index);
2458+ this.matchStart = formatterMatch.index;
2459+ this.matchLength = formatterMatch[0].length;
2460+ this.matchText = formatterMatch[0];
2461+ this.nextMatch = this.formatter.formatterRegExp.lastIndex;
2462+ var t;
2463+ for(t=1; t<formatterMatch.length; t++) {
2464+ if(formatterMatch[t]) {
2465+ this.formatter.formatters[t-1].handler(this);
2466+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
2467+ break;
2468+ }
2469+ }
2470+ terminatorRegExp.lastIndex = this.nextMatch;
2471+ terminatorMatch = terminatorRegExp.exec(this.source);
2472+ formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
2473+ }
2474+ if(this.nextMatch < this.source.length) {
2475+ this.outputText(this.output,this.nextMatch,this.source.length);
2476+ this.nextMatch = this.source.length;
2477+ }
2478+ this.output = oldOutput;
2479+};
2480+
2481+Wikifier.prototype.outputText = function(place,startPos,endPos)
2482+{
2483+ while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) {
2484+ if(this.highlightMatch.index > startPos) {
2485+ createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
2486+ startPos = this.highlightMatch.index;
2487+ }
2488+ var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
2489+ createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
2490+ startPos = highlightEnd;
2491+ if(startPos >= this.highlightRegExp.lastIndex)
2492+ this.highlightMatch = this.highlightRegExp.exec(this.source);
2493+ }
2494+ if(startPos < endPos) {
2495+ createTiddlyText(place,this.source.substring(startPos,endPos));
2496+ }
2497+};
2498+
2499+function wikify(source,output,highlightRegExp,tiddler)
2500+{
2501+ if(source) {
2502+ var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
2503+ var t0 = new Date();
2504+ wikifier.subWikify(output);
2505+ if(tiddler && config.options.chkDisplayInstrumentation)
2506+ displayMessage("wikify:" +tiddler.title+ " in " + (new Date()-t0) + " ms");
2507+ }
2508+}
2509+
2510+function wikifyStatic(source,highlightRegExp,tiddler,format)
2511+{
2512+ var e = createTiddlyElement(document.body,"pre");
2513+ e.style.display = "none";
2514+ var html = "";
2515+ if(source && source != "") {
2516+ if(!tiddler)
2517+ tiddler = new Tiddler("temp");
2518+ var wikifier = new Wikifier(source,getParser(tiddler,format),highlightRegExp,tiddler);
2519+ wikifier.isStatic = true;
2520+ wikifier.subWikify(e);
2521+ html = e.innerHTML;
2522+ jQuery(e).remove();
2523+ }
2524+ return html;
2525+}
2526+
2527+function wikifyPlainText(text,limit,tiddler)
2528+{
2529+ if(limit > 0)
2530+ text = text.substr(0,limit);
2531+ var wikifier = new Wikifier(text,formatter,null,tiddler);
2532+ return wikifier.wikifyPlain();
2533+}
2534+
2535+function highlightify(source,output,highlightRegExp,tiddler)
2536+{
2537+ if(source) {
2538+ var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
2539+ wikifier.outputText(output,0,source.length);
2540+ }
2541+}
2542+
2543+//--
2544+//-- Macro definitions
2545+//--
2546+
2547+function invokeMacro(place,macro,params,wikifier,tiddler)
2548+{
2549+ try {
2550+ var m = config.macros[macro];
2551+ if(m && m.handler) {
2552+ var tiddlerElem = story.findContainingTiddler(place);
2553+ window.tiddler = tiddlerElem ? store.getTiddler(tiddlerElem.getAttribute("tiddler")) : null;
2554+ window.place = place;
2555+ var allowEval = true;
2556+ if(config.evaluateMacroParameters=="system") {
2557+ if(!tiddler || tiddler.tags.indexOf("systemAllowEval") == -1) {
2558+ allowEval = false;
2559+ }
2560+ }
2561+ m.handler(place,macro,m.noPreParse?null:params.readMacroParams(!allowEval),wikifier,params,tiddler);
2562+ } else {
2563+ createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro]));
2564+ }
2565+ } catch(ex) {
2566+ createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()]));
2567+ }
2568+}
2569+
2570+config.macros.version.handler = function(place)
2571+{
2572+ jQuery("<span/>").text(formatVersion()).appendTo(place);
2573+};
2574+
2575+config.macros.today.handler = function(place,macroName,params)
2576+{
2577+ var now = new Date();
2578+ var text = params[0] ? now.formatString(params[0].trim()) : now.toLocaleString();
2579+ jQuery("<span/>").text(text).appendTo(place);
2580+};
2581+
2582+config.macros.list.template = "<<view title link>>";
2583+config.macros.list.handler = function(place,macroName,params,wikifier,paramString)
2584+{
2585+ var list = document.createElement("ul");
2586+ jQuery(list).attr({ refresh: "macro", macroName: macroName }).data("params", paramString);
2587+ place.appendChild(list);
2588+ this.refresh(list);
2589+};
2590+
2591+config.macros.list.refresh = function(list) {
2592+ var paramString = jQuery(list).data("params");
2593+ var params = paramString.readMacroParams();
2594+ var args = paramString.parseParams("anon", null, null)[0];
2595+ var type = args.anon ? args.anon[0] : "all";
2596+ jQuery(list).empty().addClass("list list-" + type);
2597+ var template = args.template ? store.getTiddlerText(args.template[0]) : false;
2598+ if(!template) {
2599+ template = config.macros.list.template;
2600+ }
2601+ if(this[type].prompt)
2602+ createTiddlyElement(list,"li",null,"listTitle",this[type].prompt);
2603+ var results;
2604+ if(this[type].handler)
2605+ results = this[type].handler(params);
2606+ var t;
2607+ for(t = 0; t < results.length; t++) {
2608+ var li = document.createElement("li");
2609+ list.appendChild(li);
2610+ var tiddler = results[t];
2611+ if(typeof(tiddler) == 'string') { // deal with missing etc..
2612+ tiddler = store.getTiddler(tiddler) || new Tiddler(tiddler);
2613+ }
2614+ wikify(template, li, null, tiddler);
2615+ }
2616+ if(results.length === 0 && args.emptyMessage) {
2617+ jQuery(list).addClass("emptyList");
2618+ jQuery("<li />").text(args.emptyMessage[0]).appendTo(list);
2619+ }
2620+};
2621+
2622+config.macros.list.all.handler = function(params)
2623+{
2624+ return store.reverseLookup("tags","excludeLists",false,"title");
2625+};
2626+
2627+config.macros.list.missing.handler = function(params)
2628+{
2629+ return store.getMissingLinks();
2630+};
2631+
2632+config.macros.list.orphans.handler = function(params)
2633+{
2634+ return store.getOrphans();
2635+};
2636+
2637+config.macros.list.shadowed.handler = function(params)
2638+{
2639+ return store.getShadowed();
2640+};
2641+
2642+config.macros.list.touched.handler = function(params)
2643+{
2644+ return store.getTouched();
2645+};
2646+
2647+config.macros.list.filter.handler = function(params)
2648+{
2649+ var filter = params[1];
2650+ var results = [];
2651+ if(filter) {
2652+ var tiddlers = store.filterTiddlers(filter);
2653+ var t;
2654+ for(t=0; t<tiddlers.length; t++)
2655+ results.push(tiddlers[t].title);
2656+ }
2657+ return results;
2658+};
2659+
2660+config.macros.allTags.handler = function(place,macroName,params)
2661+{
2662+ var tags = store.getTags(params[0]);
2663+ var ul = createTiddlyElement(place,"ul");
2664+ if(tags.length == 0)
2665+ createTiddlyElement(ul,"li",null,"listTitle",this.noTags);
2666+ var t;
2667+ for(t=0; t<tags.length; t++) {
2668+ var title = tags[t][0];
2669+ var info = getTiddlyLinkInfo(title);
2670+ var li = createTiddlyElement(ul,"li");
2671+ var btn = createTiddlyButton(li,title + " (" + tags[t][1] + ")",this.tooltip.format([title]),onClickTag,info.classes);
2672+ btn.setAttribute("tag",title);
2673+ btn.setAttribute("refresh","link");
2674+ btn.setAttribute("tiddlyLink",title);
2675+ if(params[1]) {
2676+ btn.setAttribute("sortby",params[1]);
2677+ }
2678+ }
2679+};
2680+
2681+var macro = config.macros.timeline;
2682+merge(macro, {
2683+ handler: function(place,macroName,params, wikifier, paramString, tiddler) {
2684+ var container = jQuery("<div />").attr("params", paramString).
2685+ attr("macroName", macroName).appendTo(place)[0];
2686+ macro.refresh(container);
2687+ },
2688+ refresh: function(container) {
2689+ jQuery(container).attr("refresh", "macro").empty();
2690+ var paramString = jQuery(container).attr("params");
2691+ var args = paramString.parseParams("anon", null, null)[0];
2692+ var params = args.anon || [];
2693+
2694+ var field = params[0] || "modified";
2695+ var prefix = field.charAt(0);
2696+ var no_prefix_field = prefix === "-" || prefix === "+" ? field.substr(1, field.length) : field;
2697+ var dateFormat = params[2] || this.dateFormat;
2698+ var groupTemplate = macro.groupTemplate.format(no_prefix_field, dateFormat);
2699+ groupTemplate = args.groupTemplate ? store.getTiddlerText(args.groupTemplate[0]) || groupTemplate :
2700+ groupTemplate;
2701+
2702+ var itemTemplate = macro.itemTemplate;
2703+ itemTemplate = args.template ? store.getTiddlerText(args.template[0]) || itemTemplate :
2704+ itemTemplate;
2705+
2706+ var tiddlers = args.filter ? store.sortTiddlers(store.filterTiddlers(args.filter[0]), field) :
2707+ store.reverseLookup("tags", "excludeLists", false, field);
2708+ var lastGroup = "", ul;
2709+ var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1],10)) : 0;
2710+ var t;
2711+ for(t=tiddlers.length-1; t>=last; t--) {
2712+ var tiddler = tiddlers[t];
2713+ var theGroup = wikifyPlainText(groupTemplate,0,tiddler);
2714+ if(typeof(ul) == "undefined" || theGroup != lastGroup) {
2715+ ul = document.createElement("ul");
2716+ jQuery(ul).addClass("timeline");
2717+ container.appendChild(ul);
2718+ createTiddlyElement(ul,"li",null,"listTitle",theGroup);
2719+ lastGroup = theGroup;
2720+ }
2721+ var item = createTiddlyElement(ul,"li",null,"listLink");
2722+ wikify(itemTemplate,item,null,tiddler);
2723+ }
2724+ },
2725+ groupTemplate: "<<view %0 date '%1'>>",
2726+ itemTemplate: "<<view title link>>"
2727+});
2728+
2729+config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
2730+{
2731+ var allowEval = true;
2732+ var stack = config.macros.tiddler.tiddlerStack;
2733+ if(stack.length > 0 && config.evaluateMacroParameters == "system") {
2734+ // included tiddler and "system" evaluation required, so check tiddler tagged appropriately
2735+ var title = stack[stack.length-1];
2736+ var pos = title.indexOf(config.textPrimitives.sectionSeparator);
2737+ if(pos != -1) {
2738+ title = title.substr(0,pos); // get the base tiddler title
2739+ }
2740+ var t = store.getTiddler(title);
2741+ if(!t || t.tags.indexOf("systemAllowEval") == -1) {
2742+ allowEval = false;
2743+ }
2744+ }
2745+ params = paramString.parseParams("name",null,allowEval,false,true);
2746+ var names = params[0]["name"];
2747+ var tiddlerName = names[0];
2748+ var className = names[1] || null;
2749+ var args = params[0]["with"];
2750+ var wrapper = createTiddlyElement(place,"span",null,className,null,{
2751+ refresh: "content", tiddler: tiddlerName
2752+ });
2753+ if(args!==undefined)
2754+ wrapper.setAttribute("args","[["+args.join("]] [[")+"]]");
2755+ this.transclude(wrapper,tiddlerName,args);
2756+};
2757+
2758+config.macros.tiddler.transclude = function(wrapper,tiddlerName,args)
2759+{
2760+ var text = store.getTiddlerText(tiddlerName);
2761+ if(!text)
2762+ return;
2763+ var stack = config.macros.tiddler.tiddlerStack;
2764+ if(stack.indexOf(tiddlerName) !== -1)
2765+ return;
2766+ stack.push(tiddlerName);
2767+ try {
2768+ if(typeof args == "string")
2769+ args = args.readBracketedList();
2770+ var n = args ? Math.min(args.length,9) : 0;
2771+ var i;
2772+ for(i=0; i<n; i++) {
2773+ var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
2774+ text = text.replace(placeholderRE,args[i]);
2775+ }
2776+ config.macros.tiddler.renderText(wrapper,text,tiddlerName);
2777+ } finally {
2778+ stack.pop();
2779+ }
2780+};
2781+
2782+config.macros.tiddler.renderText = function(place,text,tiddlerName)
2783+{
2784+ wikify(text,place,null,store.getTiddler(tiddlerName));
2785+};
2786+
2787+config.macros.tiddler.tiddlerStack = [];
2788+
2789+config.macros.tag.handler = function(place,macroName,params)
2790+{
2791+ var btn = createTagButton(place,params[0],null,params[1],params[2]);
2792+ if(params[3]) {
2793+ btn.setAttribute('sortby',params[3]);
2794+ }
2795+};
2796+
2797+config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
2798+{
2799+ params = paramString.parseParams("anon",null,true,false,false);
2800+ var ul = createTiddlyElement(place,"ul");
2801+ var title = getParam(params,"anon","");
2802+ if(title && store.tiddlerExists(title))
2803+ tiddler = store.getTiddler(title);
2804+ var sep = getParam(params,"sep"," ");
2805+ var lingo = config.views.wikified.tag;
2806+ var label = null;
2807+ var t;
2808+ for(t=0; t<tiddler.tags.length; t++) {
2809+ var tag = store.getTiddler(tiddler.tags[t]);
2810+ if(!tag || !tag.tags.contains("excludeLists")) {
2811+ if(!label)
2812+ label = createTiddlyElement(ul,"li",null,"listTitle",lingo.labelTags.format([tiddler.title]));
2813+ createTagButton(createTiddlyElement(ul,"li"),tiddler.tags[t],tiddler.title);
2814+ if(t<tiddler.tags.length-1)
2815+ createTiddlyText(ul,sep);
2816+ }
2817+ }
2818+ if(!label)
2819+ createTiddlyElement(ul,"li",null,"listTitle",lingo.labelNoTags.format([tiddler.title]));
2820+};
2821+
2822+config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
2823+{
2824+ params = paramString.parseParams("anon",null,true,false,false);
2825+ var ul = createTiddlyElement(place,"ul");
2826+ var title = getParam(params,"anon","");
2827+ if(title == "" && tiddler instanceof Tiddler)
2828+ title = tiddler.title;
2829+ var sep = getParam(params,"sep"," ");
2830+ ul.setAttribute("title",this.tooltip.format([title]));
2831+ var sortby = getParam(params,"sortBy",false);
2832+ var tagged = store.getTaggedTiddlers(title,sortby);
2833+ var prompt = tagged.length == 0 ? this.labelNotTag : this.label;
2834+ createTiddlyElement(ul,"li",null,"listTitle",prompt.format([title,tagged.length]));
2835+ var t;
2836+ for(t=0; t<tagged.length; t++) {
2837+ createTiddlyLink(createTiddlyElement(ul,"li"),tagged[t].title,true);
2838+ if(t<tagged.length-1)
2839+ createTiddlyText(ul,sep);
2840+ }
2841+};
2842+
2843+config.macros.closeAll.handler = function(place)
2844+{
2845+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
2846+};
2847+
2848+config.macros.closeAll.onClick = function(e)
2849+{
2850+ story.closeAllTiddlers();
2851+ return false;
2852+};
2853+
2854+config.macros.permaview.handler = function(place)
2855+{
2856+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
2857+};
2858+
2859+config.macros.permaview.onClick = function(e)
2860+{
2861+ story.permaView();
2862+ return false;
2863+};
2864+
2865+config.macros.saveChanges.handler = function(place,macroName,params)
2866+{
2867+ if(!readOnly)
2868+ createTiddlyButton(place,params[0] || this.label,params[1] || this.prompt,this.onClick,null,null,this.accessKey);
2869+};
2870+
2871+config.macros.saveChanges.onClick = function(e)
2872+{
2873+ saveChanges();
2874+ return false;
2875+};
2876+
2877+config.macros.slider.onClickSlider = function(ev)
2878+{
2879+ var n = this.nextSibling;
2880+ var cookie = n.getAttribute("cookie");
2881+ var isOpen = n.style.display != "none";
2882+ if(config.options.chkAnimate && anim && typeof Slider == "function")
2883+ anim.startAnimating(new Slider(n,!isOpen,null,"none"));
2884+ else
2885+ n.style.display = isOpen ? "none" : "block";
2886+ config.options[cookie] = !isOpen;
2887+ saveOption(cookie);
2888+ return false;
2889+};
2890+
2891+config.macros.slider.createSlider = function(place,cookie,title,tooltip)
2892+{
2893+ var c = cookie || "";
2894+ createTiddlyButton(place,title,tooltip,this.onClickSlider);
2895+ var panel = createTiddlyElement(null,"div",null,"sliderPanel");
2896+ panel.setAttribute("cookie",c);
2897+ panel.style.display = config.options[c] ? "block" : "none";
2898+ place.appendChild(panel);
2899+ return panel;
2900+};
2901+
2902+config.macros.slider.handler = function(place,macroName,params)
2903+{
2904+ var panel = this.createSlider(place,params[0],params[2],params[3]);
2905+ var text = store.getTiddlerText(params[1]);
2906+ panel.setAttribute("refresh","content");
2907+ panel.setAttribute("tiddler",params[1]);
2908+ if(text)
2909+ wikify(text,panel,null,store.getTiddler(params[1]));
2910+};
2911+
2912+// <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >>
2913+config.macros.gradient.handler = function(place,macroName,params,wikifier,paramString,tiddler)
2914+{
2915+ var panel = wikifier ? createTiddlyElement(place,"div",null,"gradient") : place;
2916+ panel.style.position = "relative";
2917+ panel.style.overflow = "hidden";
2918+ panel.style.zIndex = "0";
2919+ if(wikifier) {
2920+ var styles = config.formatterHelpers.inlineCssHelper(wikifier);
2921+ config.formatterHelpers.applyCssHelper(panel,styles);
2922+ }
2923+ params = paramString.parseParams("color");
2924+ var locolors = [], hicolors = [];
2925+ var t;
2926+ for(t=2; t<params.length; t++) {
2927+ var c = params[t].value;
2928+ if(params[t].name == "snap") {
2929+ hicolors[hicolors.length-1] = c;
2930+ } else {
2931+ locolors.push(c);
2932+ hicolors.push(c);
2933+ }
2934+ }
2935+ drawGradient(panel,params[1].value != "vert",locolors,hicolors);
2936+ if(wikifier)
2937+ wikifier.subWikify(panel,">>");
2938+ if(document.all) {
2939+ panel.style.height = "100%";
2940+ panel.style.width = "100%";
2941+ }
2942+};
2943+
2944+config.macros.message.handler = function(place,macroName,params)
2945+{
2946+ if(params[0]) {
2947+ var names = params[0].split(".");
2948+ var lookupMessage = function(root,nameIndex) {
2949+ if(root[names[nameIndex]]) {
2950+ if(nameIndex < names.length-1)
2951+ return (lookupMessage(root[names[nameIndex]],nameIndex+1));
2952+ else
2953+ return root[names[nameIndex]];
2954+ } else
2955+ return null;
2956+ };
2957+ var m = lookupMessage(config,0);
2958+ if(m == null)
2959+ m = lookupMessage(window,0);
2960+ createTiddlyText(place,m.toString().format(params.splice(1)));
2961+ }
2962+};
2963+
2964+
2965+config.macros.view.depth = 0;
2966+config.macros.view.values = [];
2967+config.macros.view.views = {
2968+ text: function(value,place,params,wikifier,paramString,tiddler) {
2969+ highlightify(value,place,highlightHack,tiddler);
2970+ },
2971+ link: function(value,place,params,wikifier,paramString,tiddler) {
2972+ createTiddlyLink(place,value,true);
2973+ },
2974+ wikified: function(value,place,params,wikifier,paramString,tiddler) {
2975+ if(config.macros.view.depth>50)
2976+ return;
2977+ if(config.macros.view.depth>0) {
2978+ if (value==config.macros.view.values[config.macros.view.depth-1]) {
2979+ return;
2980+ }
2981+ }
2982+ config.macros.view.values[config.macros.view.depth] = value;
2983+ config.macros.view.depth++;
2984+ if(params[2])
2985+ value=params[2].unescapeLineBreaks().format([value]);
2986+ wikify(value,place,highlightHack,tiddler);
2987+ config.macros.view.depth--;
2988+ config.macros.view.values[config.macros.view.depth] = null;
2989+ },
2990+ date: function(value,place,params,wikifier,paramString,tiddler) {
2991+ value = Date.convertFromYYYYMMDDHHMM(value);
2992+ createTiddlyText(place,value.formatString(params[2] || config.views.wikified.dateFormat));
2993+ }
2994+};
2995+
2996+config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler)
2997+{
2998+ if((tiddler instanceof Tiddler) && params[0]) {
2999+ var value = store.getValue(tiddler,params[0]);
3000+ if(value) {
3001+ var type = params[1] || config.macros.view.defaultView;
3002+ var handler = config.macros.view.views[type];
3003+ if(handler)
3004+ handler(value,place,params,wikifier,paramString,tiddler);
3005+ }
3006+ }
3007+};
3008+
3009+config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler)
3010+{
3011+ var field = params[0];
3012+ var rows = params[1] || 0;
3013+ var defVal = params[2] || '';
3014+ if((tiddler instanceof Tiddler) && field) {
3015+ story.setDirty(tiddler.title,true);
3016+ var e,v;
3017+ if(field != "text" && !rows) {
3018+ e = createTiddlyElement(null,"input",null,null,null,{
3019+ type: "text", edit: field, size: "40", autocomplete: "off"
3020+ });
3021+ e.value = store.getValue(tiddler,field) || defVal;
3022+ place.appendChild(e);
3023+ } else {
3024+ var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix");
3025+ var wrapper2 = createTiddlyElement(wrapper1,"div");
3026+ e = createTiddlyElement(wrapper2,"textarea");
3027+ e.value = v = store.getValue(tiddler,field) || defVal;
3028+ rows = rows || 10;
3029+ var lines = v.match(/\n/mg);
3030+ var maxLines = Math.max(parseInt(config.options.txtMaxEditRows,10),5);
3031+ if(lines != null && lines.length > rows)
3032+ rows = lines.length + 5;
3033+ rows = Math.min(rows,maxLines);
3034+ e.setAttribute("rows",rows);
3035+ e.setAttribute("edit",field);
3036+ place.appendChild(wrapper1);
3037+ }
3038+ if(tiddler.isReadOnly()) {
3039+ e.setAttribute("readOnly","readOnly");
3040+ jQuery(e).addClass("readOnly");
3041+ }
3042+ return e;
3043+ }
3044+};
3045+
3046+config.macros.tagChooser.onClick = function(ev)
3047+{
3048+ var e = ev || window.event;
3049+ var lingo = config.views.editor.tagChooser;
3050+ var popup = Popup.create(this);
3051+ var tags = store.getTags(this.getAttribute("tags"));
3052+ if(tags.length == 0)
3053+ jQuery("<li/>").text(lingo.popupNone).appendTo(popup);
3054+ var t;
3055+ for(t=0; t<tags.length; t++) {
3056+ var tag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick);
3057+ tag.setAttribute("tag",tags[t][0]);
3058+ tag.setAttribute("tiddler",this.getAttribute("tiddler"));
3059+ }
3060+ Popup.show();
3061+ e.cancelBubble = true;
3062+ if(e.stopPropagation) e.stopPropagation();
3063+ return false;
3064+};
3065+
3066+config.macros.tagChooser.onTagClick = function(ev)
3067+{
3068+ var e = ev || window.event;
3069+ if(e.metaKey || e.ctrlKey) stopEvent(e); //# keep popup open on CTRL-click
3070+ var tag = this.getAttribute("tag");
3071+ var title = this.getAttribute("tiddler");
3072+ if(!readOnly)
3073+ story.setTiddlerTag(title,tag,0);
3074+ return false;
3075+};
3076+
3077+config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler)
3078+{
3079+ if(tiddler instanceof Tiddler) {
3080+ var lingo = config.views.editor.tagChooser;
3081+ var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick);
3082+ btn.setAttribute("tiddler",tiddler.title);
3083+ btn.setAttribute("tags",params[0]);
3084+ }
3085+};
3086+
3087+config.macros.refreshDisplay.handler = function(place)
3088+{
3089+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
3090+};
3091+
3092+config.macros.refreshDisplay.onClick = function(e)
3093+{
3094+ refreshAll();
3095+ return false;
3096+};
3097+
3098+config.macros.annotations.handler = function(place,macroName,params,wikifier,paramString,tiddler)
3099+{
3100+ var title = tiddler ? tiddler.title : null;
3101+ var a = title ? config.annotations[title] : null;
3102+ if(!tiddler || !title || !a)
3103+ return;
3104+ var text = a.format([title]);
3105+ wikify(text,createTiddlyElement(place,"div",null,"annotation"),null,tiddler);
3106+};
3107+//--
3108+//-- NewTiddler and NewJournal macros
3109+//--
3110+
3111+config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal)
3112+{
3113+ var tags = [];
3114+ var t;
3115+ for(t=1; t<params.length; t++) {
3116+ if((params[t].name == "anon" && t != 1) || (params[t].name == "tag"))
3117+ tags.push(params[t].value);
3118+ }
3119+ label = getParam(params,"label",label);
3120+ prompt = getParam(params,"prompt",prompt);
3121+ accessKey = getParam(params,"accessKey",accessKey);
3122+ newFocus = getParam(params,"focus",newFocus);
3123+ var customFields = getParam(params,"fields","");
3124+ if(!customFields && !store.isShadowTiddler(title))
3125+ customFields = String.encodeHashMap(config.defaultCustomFields);
3126+ var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey);
3127+ btn.setAttribute("newTitle",title);
3128+ btn.setAttribute("isJournal",isJournal ? "true" : "false");
3129+ if(tags.length > 0)
3130+ btn.setAttribute("params",tags.join("|"));
3131+ btn.setAttribute("newFocus",newFocus);
3132+ btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE));
3133+ if(customFields !== "")
3134+ btn.setAttribute("customFields",customFields);
3135+ var text = getParam(params,"text");
3136+ if(text !== undefined)
3137+ btn.setAttribute("newText",text);
3138+ return btn;
3139+};
3140+
3141+config.macros.newTiddler.onClickNewTiddler = function()
3142+{
3143+ var title = this.getAttribute("newTitle");
3144+ if(this.getAttribute("isJournal") == "true") {
3145+ title = new Date().formatString(title.trim());
3146+ }
3147+ var params = this.getAttribute("params");
3148+ var tags = params ? params.split("|") : [];
3149+ var focus = this.getAttribute("newFocus");
3150+ var template = this.getAttribute("newTemplate");
3151+ var customFields = this.getAttribute("customFields");
3152+ if(!customFields && !store.isShadowTiddler(title))
3153+ customFields = String.encodeHashMap(config.defaultCustomFields);
3154+ story.displayTiddler(null,title,template,false,null,null);
3155+ var tiddlerElem = story.getTiddler(title);
3156+ if(customFields)
3157+ story.addCustomFields(tiddlerElem,customFields);
3158+ var text = this.getAttribute("newText");
3159+ if(typeof text == "string" && story.getTiddlerField(title,"text"))
3160+ story.getTiddlerField(title,"text").value = text.format([title]);
3161+ var t;
3162+ for(t=0;t<tags.length;t++)
3163+ story.setTiddlerTag(title,tags[t],+1);
3164+ story.focusTiddler(title,focus);
3165+ return false;
3166+};
3167+
3168+config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString)
3169+{
3170+ if(!readOnly) {
3171+ params = paramString.parseParams("anon",null,true,false,false);
3172+ var title = params[1] && params[1].name == "anon" ? params[1].value : this.title;
3173+ title = getParam(params,"title",title);
3174+ this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false);
3175+ }
3176+};
3177+
3178+config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString)
3179+{
3180+ if(!readOnly) {
3181+ params = paramString.parseParams("anon",null,true,false,false);
3182+ var title = params[1] && params[1].name == "anon" ? params[1].value : config.macros.timeline.dateFormat;
3183+ title = getParam(params,"title",title);
3184+ config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true);
3185+ }
3186+};
3187+
3188+//--
3189+//-- Search macro
3190+//--
3191+
3192+config.macros.search.handler = function(place,macroName,params,wikifier,paramString,tiddler)
3193+{
3194+ params = paramString.parseParams("anon",null,false,false,false);
3195+ createTiddlyButton(place,this.label,this.prompt,this.onClick,"searchButton");
3196+ var txt = createTiddlyElement(null,"input",null,"txtOptionInput searchField");
3197+ txt.value = getParam(params,"anon","");
3198+ if(config.browser.isSafari) {
3199+ txt.setAttribute("type","search");
3200+ txt.setAttribute("results","5");
3201+ } else {
3202+ txt.setAttribute("type","text");
3203+ }
3204+ place.appendChild(txt);
3205+ txt.onkeyup = this.onKeyPress;
3206+ txt.onfocus = this.onFocus;
3207+ txt.setAttribute("size",this.sizeTextbox);
3208+ txt.setAttribute("accessKey",getParam(params,"accesskey",this.accessKey));
3209+ txt.setAttribute("autocomplete","off");
3210+ txt.setAttribute("lastSearchText","");
3211+ txt.setAttribute("placeholder",getParam(params,"placeholder",this.placeholder));
3212+};
3213+
3214+// Global because there's only ever one outstanding incremental search timer
3215+config.macros.search.timeout = null;
3216+
3217+config.macros.search.doSearch = function(txt)
3218+{
3219+ if(txt.value.length > 0) {
3220+ story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);
3221+ txt.setAttribute("lastSearchText",txt.value);
3222+ }
3223+};
3224+
3225+config.macros.search.onClick = function(e)
3226+{
3227+ config.macros.search.doSearch(this.nextSibling);
3228+ return false;
3229+};
3230+
3231+config.macros.search.onKeyPress = function(ev)
3232+{
3233+ var me = config.macros.search;
3234+ var e = ev || window.event;
3235+ switch(e.keyCode) {
3236+ case 9: // Tab
3237+ return;
3238+ case 13: // Ctrl-Enter
3239+ case 10: // Ctrl-Enter on IE PC
3240+ me.doSearch(this);
3241+ break;
3242+ case 27: // Escape
3243+ this.value = "";
3244+ clearMessage();
3245+ break;
3246+ }
3247+ if(config.options.chkIncrementalSearch) {
3248+ if(this.value.length > 2) {
3249+ if(this.value != this.getAttribute("lastSearchText")) {
3250+ if(me.timeout) {
3251+ clearTimeout(me.timeout);
3252+ }
3253+ var txt = this;
3254+ me.timeout = setTimeout(function() {me.doSearch(txt);},500);
3255+ }
3256+ } else {
3257+ if(me.timeout) {
3258+ clearTimeout(me.timeout);
3259+ }
3260+ }
3261+ }
3262+};
3263+
3264+config.macros.search.onFocus = function(e)
3265+{
3266+ this.select();
3267+};
3268+
3269+//--
3270+//-- Tabs macro
3271+//--
3272+
3273+config.macros.tabs.handler = function(place,macroName,params)
3274+{
3275+ var cookie = params[0];
3276+ var numTabs = (params.length-1)/3;
3277+ var wrapper = createTiddlyElement(null,"div",null,"tabsetWrapper " + cookie);
3278+ var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
3279+ tabset.setAttribute("cookie",cookie);
3280+ var validTab = false;
3281+ var t;
3282+ for(t=0; t<numTabs; t++) {
3283+ var label = params[t*3+1];
3284+ var prompt = params[t*3+2];
3285+ var content = params[t*3+3];
3286+ var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
3287+ createTiddlyElement(tab,"span",null,null," ",{style:"font-size:0pt;line-height:0px"});
3288+ tab.setAttribute("tab",label);
3289+ tab.setAttribute("content",content);
3290+ tab.title = prompt;
3291+ if(config.options[cookie] == label)
3292+ validTab = true;
3293+ }
3294+ if(!validTab)
3295+ config.options[cookie] = params[1];
3296+ place.appendChild(wrapper);
3297+ this.switchTab(tabset,config.options[cookie]);
3298+};
3299+
3300+config.macros.tabs.onClickTab = function(e)
3301+{
3302+ config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
3303+ return false;
3304+};
3305+
3306+config.macros.tabs.switchTab = function(tabset,tab)
3307+{
3308+ var cookie = tabset.getAttribute("cookie");
3309+ var theTab = null;
3310+ var nodes = tabset.childNodes;
3311+ var t;
3312+ for(t=0; t<nodes.length; t++) {
3313+ if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab) {
3314+ theTab = nodes[t];
3315+ theTab.className = "tab tabSelected";
3316+ } else {
3317+ nodes[t].className = "tab tabUnselected";
3318+ }
3319+ }
3320+ if(theTab) {
3321+ if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
3322+ jQuery(tabset.nextSibling).remove();
3323+ var tabContent = createTiddlyElement(null,"div",null,"tabContents");
3324+ tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
3325+ var contentTitle = theTab.getAttribute("content");
3326+ wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
3327+ if(cookie) {
3328+ config.options[cookie] = tab;
3329+ saveOption(cookie);
3330+ }
3331+ }
3332+};
3333+
3334+//--
3335+//-- Tiddler toolbar
3336+//--
3337+
3338+// Create a toolbar command button
3339+config.macros.toolbar.createCommand = function(place,commandName,tiddler,className)
3340+{
3341+ if(typeof commandName != "string") {
3342+ var c = null;
3343+ var t;
3344+ for(t in config.commands) {
3345+ if(config.commands[t] == commandName)
3346+ c = t;
3347+ }
3348+ commandName = c;
3349+ }
3350+ if((tiddler instanceof Tiddler) && (typeof commandName == "string")) {
3351+ var command = config.commands[commandName];
3352+ if(command.isEnabled ? command.isEnabled(tiddler) : this.isCommandEnabled(command,tiddler)) {
3353+ var text = command.getText ? command.getText(tiddler) : this.getCommandText(command,tiddler);
3354+ var tooltip = command.getTooltip ? command.getTooltip(tiddler) : this.getCommandTooltip(command,tiddler);
3355+ var cmd = command.type == "popup" ? this.onClickPopup : this.onClickCommand;
3356+ var btn = createTiddlyButton(null,text,tooltip,cmd);
3357+ btn.setAttribute("commandName",commandName);
3358+ btn.setAttribute("tiddler",tiddler.title);
3359+ jQuery(btn).addClass("command_" + commandName);
3360+ if(className)
3361+ jQuery(btn).addClass(className);
3362+ place.appendChild(btn);
3363+ }
3364+ }
3365+};
3366+
3367+config.macros.toolbar.isCommandEnabled = function(command,tiddler)
3368+{
3369+ var title = tiddler.title;
3370+ var ro = tiddler.isReadOnly();
3371+ var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title);
3372+ return (!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow);
3373+};
3374+
3375+config.macros.toolbar.getCommandText = function(command,tiddler)
3376+{
3377+ return (tiddler.isReadOnly() && command.readOnlyText) || command.text;
3378+};
3379+
3380+config.macros.toolbar.getCommandTooltip = function(command,tiddler)
3381+{
3382+ return (tiddler.isReadOnly() && command.readOnlyTooltip) || command.tooltip;
3383+};
3384+
3385+config.macros.toolbar.onClickCommand = function(ev)
3386+{
3387+ var e = ev || window.event;
3388+ e.cancelBubble = true;
3389+ if(e.stopPropagation) e.stopPropagation();
3390+ var command = config.commands[this.getAttribute("commandName")];
3391+ return command.handler(e,this,this.getAttribute("tiddler"));
3392+};
3393+
3394+config.macros.toolbar.onClickPopup = function(ev)
3395+{
3396+ var e = ev || window.event;
3397+ e.cancelBubble = true;
3398+ if(e.stopPropagation) e.stopPropagation();
3399+ var popup = Popup.create(this);
3400+ var command = config.commands[this.getAttribute("commandName")];
3401+ var title = this.getAttribute("tiddler");
3402+ popup.setAttribute("tiddler",title);
3403+ command.handlePopup(popup,title);
3404+ Popup.show();
3405+ return false;
3406+};
3407+
3408+// Invoke the first command encountered from a given place that is tagged with a specified class
3409+config.macros.toolbar.invokeCommand = function(place,className,event)
3410+{
3411+ var children = place.getElementsByTagName("a");
3412+ var t;
3413+ for(t=0; t<children.length; t++) {
3414+ var c = children[t];
3415+ if(jQuery(c).hasClass(className) && c.getAttribute && c.getAttribute("commandName")) {
3416+ if(c.onclick instanceof Function)
3417+ c.onclick.call(c,event);
3418+ break;
3419+ }
3420+ }
3421+};
3422+
3423+config.macros.toolbar.onClickMore = function(ev)
3424+{
3425+ var e = this.nextSibling;
3426+ e.style.display = "inline";
3427+ this.style.display = "none";
3428+ return false;
3429+};
3430+
3431+config.macros.toolbar.onClickLess = function(ev)
3432+{
3433+ var e = this.parentNode;
3434+ var m = e.previousSibling;
3435+ e.style.display = "none";
3436+ m.style.display = "inline";
3437+ return false;
3438+};
3439+
3440+config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler)
3441+{
3442+ var t;
3443+ for(t=0; t<params.length; t++) {
3444+ var btn;
3445+ var c = params[t];
3446+ switch(c) {
3447+ case "!":
3448+ createTiddlyText(place,this.separator);
3449+ break;
3450+ case "*":
3451+ createTiddlyElement(place,"br");
3452+ break;
3453+ case "<":
3454+ btn = createTiddlyButton(place,this.lessLabel,this.lessPrompt,config.macros.toolbar.onClickLess);
3455+ jQuery(btn).addClass("lessCommand");
3456+ break;
3457+ case ">":
3458+ btn = createTiddlyButton(place,this.moreLabel,this.morePrompt,config.macros.toolbar.onClickMore);
3459+ jQuery(btn).addClass("moreCommand");
3460+ var e = createTiddlyElement(place,"span",null,"moreCommand");
3461+ e.style.display = "none";
3462+ place = e;
3463+ break;
3464+ default:
3465+ var className = "";
3466+ switch(c.substr(0,1)) {
3467+ case "+":
3468+ className = "defaultCommand";
3469+ c = c.substr(1);
3470+ break;
3471+ case "-":
3472+ className = "cancelCommand";
3473+ c = c.substr(1);
3474+ break;
3475+ }
3476+ if(config.commands[c]) {
3477+ this.createCommand(place,c,tiddler,className);
3478+ } else {
3479+ this.customCommand(place,c,wikifier,tiddler);
3480+ }
3481+ break;
3482+ }
3483+ }
3484+};
3485+
3486+// Overrideable function to extend toolbar handler
3487+config.macros.toolbar.customCommand = function(place,command,wikifier,tiddler)
3488+{
3489+};
3490+
3491+//--
3492+//-- Menu and toolbar commands
3493+//--
3494+
3495+config.commands.closeTiddler.handler = function(event,src,title)
3496+{
3497+ if(story.isDirty(title) && !readOnly) {
3498+ if(!confirm(config.commands.cancelTiddler.warning.format([title])))
3499+ return false;
3500+ }
3501+ story.setDirty(title,false);
3502+ story.closeTiddler(title,true);
3503+ return false;
3504+};
3505+
3506+config.commands.closeOthers.handler = function(event,src,title)
3507+{
3508+ story.closeAllTiddlers(title);
3509+ return false;
3510+};
3511+
3512+config.commands.editTiddler.handler = function(event,src,title)
3513+{
3514+ clearMessage();
3515+ var tiddlerElem = story.getTiddler(title);
3516+ var fields = tiddlerElem.getAttribute("tiddlyFields");
3517+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,fields);
3518+ var e = story.getTiddlerField(title,config.options.txtEditorFocus||"text");
3519+ if(e) {
3520+ setCaretPosition(e,0);
3521+ }
3522+ return false;
3523+};
3524+
3525+config.commands.saveTiddler.handler = function(event,src,title)
3526+{
3527+ var newTitle = story.saveTiddler(title,event.shiftKey);
3528+ if(newTitle)
3529+ story.displayTiddler(null,newTitle);
3530+ return false;
3531+};
3532+
3533+config.commands.cancelTiddler.handler = function(event,src,title)
3534+{
3535+ if(story.hasChanges(title) && !readOnly) {
3536+ if(!confirm(this.warning.format([title])))
3537+ return false;
3538+ }
3539+ story.setDirty(title,false);
3540+ story.displayTiddler(null,title);
3541+ return false;
3542+};
3543+
3544+config.commands.deleteTiddler.handler = function(event,src,title)
3545+{
3546+ var deleteIt = true;
3547+ if(config.options.chkConfirmDelete)
3548+ deleteIt = confirm(this.warning.format([title]));
3549+ if(deleteIt) {
3550+ store.removeTiddler(title);
3551+ story.closeTiddler(title,true);
3552+ autoSaveChanges();
3553+ }
3554+ return false;
3555+};
3556+
3557+config.commands.permalink.handler = function(event,src,title)
3558+{
3559+ var t = encodeURIComponent(String.encodeTiddlyLink(title));
3560+ if(window.location.hash != t)
3561+ window.location.hash = t;
3562+ return false;
3563+};
3564+
3565+config.commands.references.handlePopup = function(popup,title)
3566+{
3567+ var references = store.getReferringTiddlers(title);
3568+ var c = false;
3569+ var r;
3570+ for(r=0; r<references.length; r++) {
3571+ if(references[r].title != title && !references[r].isTagged("excludeLists")) {
3572+ createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true);
3573+ c = true;
3574+ }
3575+ }
3576+ if(!c)
3577+ createTiddlyElement(popup,"li",null,"disabled",this.popupNone);
3578+};
3579+
3580+config.commands.jump.handlePopup = function(popup,title)
3581+{
3582+ story.forEachTiddler(function(title,element) {
3583+ createTiddlyLink(createTiddlyElement(popup,"li"),title,true,null,false,null,true);
3584+ });
3585+};
3586+
3587+config.commands.fields.handlePopup = function(popup,title)
3588+{
3589+ var tiddler = store.fetchTiddler(title);
3590+ if(!tiddler)
3591+ return;
3592+ var items = [];
3593+ store.forEachField(tiddler,function(tiddler,fieldName,value){items.push({field:fieldName,value:value});},true);
3594+ items.sort(function(a,b) {return a.field < b.field ? -1 : (a.field == b.field ? 0 : +1);});
3595+ if(items.length > 0)
3596+ ListView.create(popup,items,this.listViewTemplate);
3597+ else
3598+ createTiddlyElement(popup,"div",null,null,this.emptyText);
3599+};
3600+
3601+//--
3602+//-- Tiddler() object
3603+//--
3604+
3605+function Tiddler(title)
3606+{
3607+ this.title = title;
3608+ this.text = "";
3609+ this.creator = null;
3610+ this.modifier = null;
3611+ this.created = new Date();
3612+ this.modified = this.created;
3613+ this.links = [];
3614+ this.linksUpdated = false;
3615+ this.tags = [];
3616+ this.fields = {};
3617+ return this;
3618+}
3619+
3620+Tiddler.prototype.getLinks = function()
3621+{
3622+ if(this.linksUpdated==false)
3623+ this.changed();
3624+ return this.links;
3625+};
3626+
3627+// Returns the fields that are inherited in string field:"value" field2:"value2" format
3628+Tiddler.prototype.getInheritedFields = function()
3629+{
3630+ var f = {};
3631+ var i;
3632+ for(i in this.fields) {
3633+ if(i=="server.host" || i=="server.workspace" || i=="wikiformat"|| i=="server.type") {
3634+ f[i] = this.fields[i];
3635+ }
3636+ }
3637+ return String.encodeHashMap(f);
3638+};
3639+
3640+// Increment the changeCount of a tiddler
3641+Tiddler.prototype.incChangeCount = function()
3642+{
3643+ var c = this.fields['changecount'];
3644+ c = c ? parseInt(c,10) : 0;
3645+ this.fields['changecount'] = String(c+1);
3646+};
3647+
3648+// Clear the changeCount of a tiddler
3649+Tiddler.prototype.clearChangeCount = function()
3650+{
3651+ if(this.fields['changecount']) {
3652+ delete this.fields['changecount'];
3653+ }
3654+};
3655+
3656+Tiddler.prototype.doNotSave = function()
3657+{
3658+ return this.fields['doNotSave'];
3659+};
3660+
3661+// Returns true if the tiddler has been updated since the tiddler was created or downloaded
3662+Tiddler.prototype.isTouched = function()
3663+{
3664+ var changecount = this.fields.changecount || 0;
3665+ return changecount > 0;
3666+};
3667+
3668+// Change the text and other attributes of a tiddler
3669+Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields,creator)
3670+{
3671+ this.assign(title,text,modifier,modified,tags,created,fields,creator);
3672+ this.changed();
3673+ return this;
3674+};
3675+
3676+// Change the text and other attributes of a tiddler without triggered a tiddler.changed() call
3677+Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields,creator)
3678+{
3679+ if(title != undefined)
3680+ this.title = title;
3681+ if(text != undefined)
3682+ this.text = text;
3683+ if(modifier != undefined)
3684+ this.modifier = modifier;
3685+ if(modified != undefined)
3686+ this.modified = modified;
3687+ if(creator != undefined)
3688+ this.creator = creator;
3689+ if(created != undefined)
3690+ this.created = created;
3691+ if(fields != undefined)
3692+ this.fields = fields;
3693+ if(tags != undefined)
3694+ this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
3695+ else if(this.tags == undefined)
3696+ this.tags = [];
3697+ return this;
3698+};
3699+
3700+// Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
3701+Tiddler.prototype.getTags = function()
3702+{
3703+ return String.encodeTiddlyLinkList(this.tags);
3704+};
3705+
3706+// Test if a tiddler carries a tag
3707+Tiddler.prototype.isTagged = function(tag)
3708+{
3709+ return this.tags.indexOf(tag) != -1;
3710+};
3711+
3712+// Static method to convert "\n" to newlines, "\s" to "\"
3713+Tiddler.unescapeLineBreaks = function(text)
3714+{
3715+ return text ? text.unescapeLineBreaks() : "";
3716+};
3717+
3718+// Convert newlines to "\n", "\" to "\s"
3719+Tiddler.prototype.escapeLineBreaks = function()
3720+{
3721+ return this.text.escapeLineBreaks();
3722+};
3723+
3724+// Updates the secondary information (like links[] array) after a change to a tiddler
3725+Tiddler.prototype.changed = function()
3726+{
3727+ this.links = [];
3728+ var text = this.text;
3729+ // remove 'quoted' text before scanning tiddler source
3730+ text = text.replace(/\/%((?:.|\n)*?)%\//g,"").
3731+ replace(/\{{3}((?:.|\n)*?)\}{3}/g,"").
3732+ replace(/"""((?:.|\n)*?)"""/g,"").
3733+ replace(/<nowiki\>((?:.|\n)*?)<\/nowiki\>/g,"").
3734+ replace(/<html\>((?:.|\n)*?)<\/html\>/g,"").
3735+ replace(/<script((?:.|\n)*?)<\/script\>/g,"");
3736+ var t = this.autoLinkWikiWords() ? 0 : 1;
3737+ var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp;
3738+ tiddlerLinkRegExp.lastIndex = 0;
3739+ var formatMatch = tiddlerLinkRegExp.exec(text);
3740+ while(formatMatch) {
3741+ var lastIndex = tiddlerLinkRegExp.lastIndex;
3742+ if(t==0 && formatMatch[1] && formatMatch[1] != this.title) {
3743+ // wikiWordLink
3744+ if(formatMatch.index > 0) {
3745+ var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg");
3746+ preRegExp.lastIndex = formatMatch.index-1;
3747+ var preMatch = preRegExp.exec(text);
3748+ if(preMatch.index != formatMatch.index-1)
3749+ this.links.pushUnique(formatMatch[1]);
3750+ } else {
3751+ this.links.pushUnique(formatMatch[1]);
3752+ }
3753+ }
3754+ else if(formatMatch[2-t] && !config.formatterHelpers.isExternalLink(formatMatch[3-t])) // titledBrackettedLink
3755+ this.links.pushUnique(formatMatch[3-t]);
3756+ else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink
3757+ this.links.pushUnique(formatMatch[4-t]);
3758+ tiddlerLinkRegExp.lastIndex = lastIndex;
3759+ formatMatch = tiddlerLinkRegExp.exec(text);
3760+ }
3761+ this.linksUpdated = true;
3762+};
3763+
3764+Tiddler.prototype.getSubtitle = function()
3765+{
3766+ var modifier = this.modifier;
3767+ if(!modifier)
3768+ modifier = config.messages.subtitleUnknown || "";
3769+ var modified = this.modified;
3770+ if(modified)
3771+ modified = modified.toLocaleString();
3772+ else
3773+ modified = config.messages.subtitleUnknown || "";
3774+ var f = config.messages.tiddlerLinkTooltip || "%0 - %1, %2";
3775+ return f.format([this.title,modifier,modified]);
3776+};
3777+
3778+Tiddler.prototype.isReadOnly = function()
3779+{
3780+ return readOnly;
3781+};
3782+
3783+Tiddler.prototype.autoLinkWikiWords = function()
3784+{
3785+ return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing"));
3786+};
3787+
3788+Tiddler.prototype.getServerType = function()
3789+{
3790+ var serverType = null;
3791+ if(this.fields['server.type'])
3792+ serverType = this.fields['server.type'];
3793+ if(!serverType)
3794+ serverType = this.fields['wikiformat'];
3795+ if(serverType && !config.adaptors[serverType])
3796+ serverType = null;
3797+ return serverType;
3798+};
3799+
3800+Tiddler.prototype.getAdaptor = function()
3801+{
3802+ var serverType = this.getServerType();
3803+ return serverType ? new config.adaptors[serverType]() : null;
3804+};
3805+
3806+//--
3807+//-- TiddlyWiki instance contains TiddlerS
3808+//--
3809+
3810+function TiddlyWiki(params)
3811+{
3812+ var tiddlers = {}; // Hashmap by name of tiddlers
3813+ if(params && params.config) {
3814+ this.config = config;
3815+ }
3816+ this.tiddlersUpdated = false;
3817+ this.namedNotifications = []; // Array of {name:,notify:} of notification functions
3818+ this.notificationLevel = 0;
3819+ this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
3820+ this.clear = function() {
3821+ tiddlers = {};
3822+ this.setDirty(false);
3823+ };
3824+ this.fetchTiddler = function(title) {
3825+ var t = tiddlers[title];
3826+ return t instanceof Tiddler ? t : null;
3827+ };
3828+ this.deleteTiddler = function(title) {
3829+ delete this.slices[title];
3830+ delete tiddlers[title];
3831+ };
3832+ this.addTiddler = function(tiddler) {
3833+ delete this.slices[tiddler.title];
3834+ tiddlers[tiddler.title] = tiddler;
3835+ };
3836+ this.forEachTiddler = function(callback) {
3837+ var t;
3838+ for(t in tiddlers) {
3839+ var tiddler = tiddlers[t];
3840+ if(tiddler instanceof Tiddler)
3841+ callback.call(this,t,tiddler);
3842+ }
3843+ };
3844+}
3845+
3846+TiddlyWiki.prototype.setDirty = function(dirty)
3847+{
3848+ this.dirty = dirty;
3849+};
3850+
3851+TiddlyWiki.prototype.isDirty = function()
3852+{
3853+ return this.dirty;
3854+};
3855+
3856+TiddlyWiki.prototype.tiddlerExists = function(title)
3857+{
3858+ var t = this.fetchTiddler(title);
3859+ return t != undefined;
3860+};
3861+
3862+TiddlyWiki.prototype.isShadowTiddler = function(title)
3863+{
3864+ return config.shadowTiddlers[title] === undefined ? false : true;
3865+};
3866+
3867+TiddlyWiki.prototype.isAvailable = function(title) {
3868+ if (!title)
3869+ return false;
3870+ var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
3871+ if(s!=-1)
3872+ title = title.substr(0,s);
3873+ return this.tiddlerExists(title) || this.isShadowTiddler(title);
3874+};
3875+
3876+TiddlyWiki.prototype.createTiddler = function(title)
3877+{
3878+ var tiddler = this.fetchTiddler(title);
3879+ if(!tiddler) {
3880+ tiddler = new Tiddler(title);
3881+ this.addTiddler(tiddler);
3882+ this.setDirty(true);
3883+ }
3884+ return tiddler;
3885+};
3886+
3887+TiddlyWiki.prototype.getTiddler = function(title)
3888+{
3889+ var t = this.fetchTiddler(title);
3890+ if(t != undefined)
3891+ return t;
3892+ else
3893+ return null;
3894+};
3895+
3896+TiddlyWiki.prototype.getShadowTiddlerText = function(title)
3897+{
3898+ if(typeof config.shadowTiddlers[title] == "string")
3899+ return config.shadowTiddlers[title];
3900+ else
3901+ return "";
3902+};
3903+
3904+// Retrieve tiddler contents
3905+TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
3906+{
3907+ if(!title)
3908+ return defaultText;
3909+ var pos = title.indexOf(config.textPrimitives.sectionSeparator);
3910+ var section = null;
3911+ if(pos != -1) {
3912+ section = title.substr(pos + config.textPrimitives.sectionSeparator.length);
3913+ title = title.substr(0,pos);
3914+ }
3915+ pos = title.indexOf(config.textPrimitives.sliceSeparator);
3916+ if(pos != -1) {
3917+ var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
3918+ if(slice)
3919+ return slice;
3920+ }
3921+ var tiddler = this.fetchTiddler(title);
3922+ var text = tiddler ? tiddler.text : null;
3923+ if(!tiddler && this.isShadowTiddler(title)) {
3924+ text = this.getShadowTiddlerText(title);
3925+ }
3926+ if(text) {
3927+ if(!section)
3928+ return text;
3929+ var re = new RegExp("(^!{1,6}[ \t]*" + section.escapeRegExp() + "[ \t]*\n)","mg");
3930+ re.lastIndex = 0;
3931+ var match = re.exec(text);
3932+ if(match) {
3933+ var t = text.substr(match.index+match[1].length);
3934+ var re2 = /^!/mg;
3935+ re2.lastIndex = 0;
3936+ match = re2.exec(t); //# search for the next heading
3937+ if(match)
3938+ t = t.substr(0,match.index-1);//# don't include final \n
3939+ return t;
3940+ }
3941+ return defaultText;
3942+ }
3943+ if(defaultText != undefined)
3944+ return defaultText;
3945+ return null;
3946+};
3947+
3948+TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth)
3949+{
3950+ var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
3951+ var text = this.getTiddlerText(title,null);
3952+ if(text == null)
3953+ return defaultText;
3954+ var textOut = [];
3955+ var match,lastPos = 0;
3956+ do {
3957+ match = bracketRegExp.exec(text);
3958+ if(match) {
3959+ textOut.push(text.substr(lastPos,match.index-lastPos));
3960+ if(match[1]) {
3961+ if(depth <= 0)
3962+ textOut.push(match[1]);
3963+ else
3964+ textOut.push(this.getRecursiveTiddlerText(match[1],"",depth-1));
3965+ }
3966+ lastPos = match.index + match[0].length;
3967+ } else {
3968+ textOut.push(text.substr(lastPos));
3969+ }
3970+ } while(match);
3971+ return textOut.join("");
3972+};
3973+
3974+//TiddlyWiki.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1[\t\x20]*([^\n]+)[\t\x20]*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|[\t\x20]*([^\n]+)[\t\x20]*\|$)/gm;
3975+TiddlyWiki.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1[\t\x20]*([^\n]*)[\t\x20]*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|[\t\x20]*([^\|\n]*)[\t\x20]*\|$)/gm;
3976+// @internal
3977+TiddlyWiki.prototype.calcAllSlices = function(title)
3978+{
3979+ var slices = {};
3980+ var text = this.getTiddlerText(title,"");
3981+ this.slicesRE.lastIndex = 0;
3982+ var m = this.slicesRE.exec(text);
3983+ while(m) {
3984+ if(m[2])
3985+ slices[m[2]] = m[3];
3986+ else
3987+ slices[m[5]] = m[6];
3988+ m = this.slicesRE.exec(text);
3989+ }
3990+ return slices;
3991+};
3992+
3993+// Returns the slice of text of the given name
3994+TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName)
3995+{
3996+ var slices = this.slices[title];
3997+ if(!slices) {
3998+ slices = this.calcAllSlices(title);
3999+ this.slices[title] = slices;
4000+ }
4001+ return slices[sliceName];
4002+};
4003+
4004+// Build an hashmap of the specified named slices of a tiddler
4005+TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames)
4006+{
4007+ var t,r = {};
4008+ for(t=0; t<sliceNames.length; t++) {
4009+ var slice = this.getTiddlerSlice(title,sliceNames[t]);
4010+ if(slice)
4011+ r[sliceNames[t]] = slice;
4012+ }
4013+ return r;
4014+};
4015+
4016+TiddlyWiki.prototype.suspendNotifications = function()
4017+{
4018+ this.notificationLevel--;
4019+};
4020+
4021+TiddlyWiki.prototype.resumeNotifications = function()
4022+{
4023+ this.notificationLevel++;
4024+};
4025+
4026+// Invoke the notification handlers for a particular tiddler
4027+TiddlyWiki.prototype.notify = function(title,doBlanket)
4028+{
4029+ if(!this.notificationLevel) {
4030+ var t;
4031+ for(t=0; t<this.namedNotifications.length; t++) {
4032+ var n = this.namedNotifications[t];
4033+ if((n.name == null && doBlanket) || (n.name == title))
4034+ n.notify(title);
4035+ }
4036+ }
4037+};
4038+
4039+// Invoke the notification handlers for all tiddlers
4040+TiddlyWiki.prototype.notifyAll = function()
4041+{
4042+ if(!this.notificationLevel) {
4043+ var t;
4044+ for(t=0; t<this.namedNotifications.length; t++) {
4045+ var n = this.namedNotifications[t];
4046+ if(n.name)
4047+ n.notify(n.name);
4048+ }
4049+ }
4050+};
4051+
4052+// Add a notification handler to a tiddler
4053+TiddlyWiki.prototype.addNotification = function(title,fn)
4054+{
4055+ var i;
4056+ for(i=0; i<this.namedNotifications.length; i++) {
4057+ if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
4058+ return this;
4059+ }
4060+ this.namedNotifications.push({name: title, notify: fn});
4061+ return this;
4062+};
4063+
4064+TiddlyWiki.prototype.removeTiddler = function(title)
4065+{
4066+ var tiddler = this.fetchTiddler(title);
4067+ if(tiddler) {
4068+ this.deleteTiddler(title);
4069+ this.notify(title,true);
4070+ this.setDirty(true);
4071+ }
4072+};
4073+
4074+// Reset the sync status of a freshly synced tiddler
4075+TiddlyWiki.prototype.resetTiddler = function(title)
4076+{
4077+ var tiddler = this.fetchTiddler(title);
4078+ if(tiddler) {
4079+ tiddler.clearChangeCount();
4080+ this.notify(title,true);
4081+ this.setDirty(true);
4082+ }
4083+};
4084+
4085+TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag)
4086+{
4087+ var tiddler = this.fetchTiddler(title);
4088+ if(tiddler) {
4089+ var t = tiddler.tags.indexOf(tag);
4090+ if(t != -1)
4091+ tiddler.tags.splice(t,1);
4092+ if(status)
4093+ tiddler.tags.push(tag);
4094+ tiddler.changed();
4095+ tiddler.incChangeCount();
4096+ this.notify(title,true);
4097+ this.setDirty(true);
4098+ }
4099+};
4100+
4101+TiddlyWiki.prototype.addTiddlerFields = function(title,fields)
4102+{
4103+ var tiddler = this.fetchTiddler(title);
4104+ if(!tiddler)
4105+ return;
4106+ merge(tiddler.fields,fields);
4107+ tiddler.changed();
4108+ tiddler.incChangeCount();
4109+ this.notify(title,true);
4110+ this.setDirty(true);
4111+};
4112+
4113+// Store tiddler in TiddlyWiki instance
4114+TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created,creator)
4115+{
4116+ var tiddler;
4117+ if(title instanceof Tiddler) {
4118+ tiddler = title;
4119+ tiddler.fields = merge(merge({},tiddler.fields),config.defaultCustomFields,true);
4120+ title = tiddler.title;
4121+ newTitle = title;
4122+ } else {
4123+ tiddler = this.fetchTiddler(title);
4124+ if(tiddler) {
4125+ created = created || tiddler.created; // Preserve created date
4126+ creator = creator || tiddler.creator;
4127+ this.deleteTiddler(title);
4128+ } else {
4129+ created = created || modified;
4130+ tiddler = new Tiddler();
4131+ }
4132+ fields = merge(merge({},fields),config.defaultCustomFields,true);
4133+ tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields,creator);
4134+ }
4135+ this.addTiddler(tiddler);
4136+ if(clearChangeCount)
4137+ tiddler.clearChangeCount();
4138+ else
4139+ tiddler.incChangeCount();
4140+ if(title != newTitle)
4141+ this.notify(title,true);
4142+ this.notify(newTitle,true);
4143+ this.setDirty(true);
4144+ return tiddler;
4145+};
4146+
4147+TiddlyWiki.prototype.incChangeCount = function(title)
4148+{
4149+ var tiddler = this.fetchTiddler(title);
4150+ if(tiddler)
4151+ tiddler.incChangeCount();
4152+};
4153+
4154+TiddlyWiki.prototype.getLoader = function()
4155+{
4156+ if(!this.loader)
4157+ this.loader = new TW21Loader();
4158+ return this.loader;
4159+};
4160+
4161+TiddlyWiki.prototype.getSaver = function()
4162+{
4163+ if(!this.saver)
4164+ this.saver = new TW21Saver();
4165+ return this.saver;
4166+};
4167+
4168+// Return all tiddlers formatted as an HTML string
4169+TiddlyWiki.prototype.allTiddlersAsHtml = function()
4170+{
4171+ return this.getSaver().externalize(store);
4172+};
4173+
4174+// Load contents of a TiddlyWiki from an HTML DIV
4175+TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate)
4176+{
4177+ this.idPrefix = idPrefix;
4178+ var storeElem = (typeof src == "string") ? document.getElementById(src) : src;
4179+ if(!storeElem)
4180+ return;
4181+ var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes);
4182+ this.setDirty(false);
4183+ if(!noUpdate) {
4184+ var i;
4185+ for(i = 0;i<tiddlers.length; i++)
4186+ tiddlers[i].changed();
4187+ }
4188+ jQuery(document).trigger("loadTiddlers");
4189+};
4190+
4191+// Load contents of a TiddlyWiki from a string
4192+// Returns null if there's an error
4193+TiddlyWiki.prototype.importTiddlyWiki = function(text)
4194+{
4195+ var posDiv = locateStoreArea(text);
4196+ if(!posDiv)
4197+ return null;
4198+ var content = "<" + "html><" + "body>" + text.substring(posDiv[0],posDiv[1] + endSaveArea.length) + "<" + "/body><" + "/html>";
4199+ // Create the iframe
4200+ var iframe = document.createElement("iframe");
4201+ iframe.style.display = "none";
4202+ document.body.appendChild(iframe);
4203+ var doc = iframe.document;
4204+ if(iframe.contentDocument)
4205+ doc = iframe.contentDocument; // For NS6
4206+ else if(iframe.contentWindow)
4207+ doc = iframe.contentWindow.document; // For IE5.5 and IE6
4208+ // Put the content in the iframe
4209+ doc.open();
4210+ doc.writeln(content);
4211+ doc.close();
4212+ // Load the content into a TiddlyWiki() object
4213+ var storeArea = doc.getElementById("storeArea");
4214+ this.loadFromDiv(storeArea,"store");
4215+ // Get rid of the iframe
4216+ iframe.parentNode.removeChild(iframe);
4217+ return this;
4218+};
4219+
4220+TiddlyWiki.prototype.updateTiddlers = function()
4221+{
4222+ this.tiddlersUpdated = true;
4223+ this.forEachTiddler(function(title,tiddler) {
4224+ tiddler.changed();
4225+ });
4226+};
4227+
4228+// Return an array of tiddlers matching a search regular expression
4229+TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag,match)
4230+{
4231+ var candidates = this.reverseLookup("tags",excludeTag,!!match);
4232+ var t,results = [];
4233+ for(t=0; t<candidates.length; t++) {
4234+ if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
4235+ results.push(candidates[t]);
4236+ }
4237+ if(!sortField)
4238+ sortField = "title";
4239+ results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
4240+ return results;
4241+};
4242+
4243+// Returns a list of all tags in use
4244+// excludeTag - if present, excludes tags that are themselves tagged with excludeTag
4245+// Returns an array of arrays where [tag][0] is the name of the tag and [tag][1] is the number of occurances
4246+TiddlyWiki.prototype.getTags = function(excludeTag)
4247+{
4248+ var results = [];
4249+ this.forEachTiddler(function(title,tiddler) {
4250+ var g,c;
4251+ for(g=0; g<tiddler.tags.length; g++) {
4252+ var tag = tiddler.tags[g];
4253+ var n = true;
4254+ for(c=0; c<results.length; c++) {
4255+ if(results[c][0] == tag) {
4256+ n = false;
4257+ results[c][1]++;
4258+ }
4259+ }
4260+ if(n && excludeTag) {
4261+ var t = this.fetchTiddler(tag);
4262+ if(t && t.isTagged(excludeTag))
4263+ n = false;
4264+ }
4265+ if(n)
4266+ results.push([tag,1]);
4267+ }
4268+ });
4269+ results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
4270+ return results;
4271+};
4272+
4273+// Return an array of the tiddlers that are tagged with a given tag
4274+TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
4275+{
4276+ return this.reverseLookup("tags",tag,true,sortField);
4277+};
4278+
4279+TiddlyWiki.prototype.getValueTiddlers = function(field,value,sortField)
4280+{
4281+ return this.reverseLookup(field,value,true,sortField);
4282+};
4283+
4284+// Return an array of the tiddlers that link to a given tiddler
4285+TiddlyWiki.prototype.getReferringTiddlers = function(title,unusedParameter,sortField)
4286+{
4287+ if(!this.tiddlersUpdated)
4288+ this.updateTiddlers();
4289+ return this.reverseLookup("links",title,true,sortField);
4290+};
4291+
4292+// Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
4293+// lookupMatch == true to match tiddlers, false to exclude tiddlers
4294+TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
4295+{
4296+ var results = [];
4297+ this.forEachTiddler(function(title,tiddler) {
4298+ var f = !lookupMatch;
4299+ var values;
4300+ if(["links", "tags"].contains(lookupField)) {
4301+ values = tiddler[lookupField];
4302+ } else {
4303+ var accessor = TiddlyWiki.standardFieldAccess[lookupField];
4304+ if(accessor) {
4305+ values = [ accessor.get(tiddler) ];
4306+ } else {
4307+ values = tiddler.fields[lookupField] ? [tiddler.fields[lookupField]] : [];
4308+ }
4309+ }
4310+ var lookup;
4311+ for(lookup=0; lookup<values.length; lookup++) {
4312+ if(values[lookup] == lookupValue)
4313+ f = lookupMatch;
4314+ }
4315+ if(f)
4316+ results.push(tiddler);
4317+ });
4318+ if(!sortField)
4319+ sortField = "title";
4320+ return this.sortTiddlers(results,sortField);
4321+};
4322+
4323+// Return the tiddlers as a sorted array
4324+TiddlyWiki.prototype.getTiddlers = function(field,excludeTag)
4325+{
4326+ var results = [];
4327+ this.forEachTiddler(function(title,tiddler) {
4328+ if(excludeTag == undefined || !tiddler.isTagged(excludeTag))
4329+ results.push(tiddler);
4330+ });
4331+ if(field)
4332+ results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);});
4333+ return results;
4334+};
4335+
4336+// Return array of names of tiddlers that are referred to but not defined
4337+TiddlyWiki.prototype.getMissingLinks = function()
4338+{
4339+ if(!this.tiddlersUpdated)
4340+ this.updateTiddlers();
4341+ var results = [];
4342+ this.forEachTiddler(function (title,tiddler) {
4343+ if(tiddler.isTagged("excludeMissing") || tiddler.isTagged("systemConfig"))
4344+ return;
4345+ var n;
4346+ for(n=0; n<tiddler.links.length;n++) {
4347+ var link = tiddler.links[n];
4348+ if(this.getTiddlerText(link,null) == null && !this.isShadowTiddler(link) && !config.macros[link])
4349+ results.pushUnique(link);
4350+ }
4351+ });
4352+ results.sort();
4353+ return results;
4354+};
4355+
4356+// Return an array of names of tiddlers that are defined but not referred to
4357+TiddlyWiki.prototype.getOrphans = function()
4358+{
4359+ var results = [];
4360+ this.forEachTiddler(function (title,tiddler) {
4361+ if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists"))
4362+ results.push(title);
4363+ });
4364+ results.sort();
4365+ return results;
4366+};
4367+
4368+// Return an array of names of all the shadow tiddlers
4369+TiddlyWiki.prototype.getShadowed = function()
4370+{
4371+ var t,results = [];
4372+ for(t in config.shadowTiddlers) {
4373+ if(this.isShadowTiddler(t))
4374+ results.push(t);
4375+ }
4376+ results.sort();
4377+ return results;
4378+};
4379+
4380+// Return an array of tiddlers that have been touched since they were downloaded or created
4381+TiddlyWiki.prototype.getTouched = function()
4382+{
4383+ var results = [];
4384+ this.forEachTiddler(function(title,tiddler) {
4385+ if(tiddler.isTouched())
4386+ results.push(tiddler);
4387+ });
4388+ results.sort();
4389+ return results;
4390+};
4391+
4392+// Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist
4393+TiddlyWiki.prototype.resolveTiddler = function(tiddler)
4394+{
4395+ var t = (typeof tiddler == "string") ? this.getTiddler(tiddler) : tiddler;
4396+ return t instanceof Tiddler ? t : null;
4397+};
4398+
4399+// Sort a list of tiddlers
4400+TiddlyWiki.prototype.sortTiddlers = function(tiddlers,field)
4401+{
4402+ var asc = +1;
4403+ switch(field.substr(0,1)) {
4404+ case "-":
4405+ asc = -1;
4406+ field = field.substr(1);
4407+ break;
4408+ case "+":
4409+ field = field.substr(1);
4410+ break;
4411+ }
4412+ if(TiddlyWiki.standardFieldAccess[field]) {
4413+ if(field=="title") {
4414+ tiddlers.sort(function(a,b) {return a[field].toLowerCase() < b[field].toLowerCase() ? -asc : (a[field].toLowerCase() == b[field].toLowerCase() ? 0 : asc);});
4415+ } else {
4416+ tiddlers.sort(function(a,b) {return a[field] < b[field] ? -asc : (a[field] == b[field] ? 0 : asc);});
4417+ }
4418+ } else {
4419+ tiddlers.sort(function(a,b) {return a.fields[field] < b.fields[field] ? -asc : (a.fields[field] == b.fields[field] ? 0 : +asc);});
4420+ }
4421+ return tiddlers;
4422+};
4423+
4424+//--
4425+//-- Filter a list of tiddlers
4426+//--
4427+
4428+config.filters = {
4429+ tiddler: function(results,match) {
4430+ var title = match[1]||match[4];
4431+ var tiddler = this.fetchTiddler(title);
4432+ if(tiddler) {
4433+ results.pushUnique(tiddler);
4434+ } else if(this.isShadowTiddler(title)) {
4435+ tiddler = new Tiddler();
4436+ tiddler.set(title,this.getTiddlerText(title));
4437+ results.pushUnique(tiddler);
4438+ } else {
4439+ results.pushUnique(new Tiddler(title));
4440+ }
4441+ return results;
4442+ },
4443+ tag: function(results,match) {
4444+ var m,matched = this.getTaggedTiddlers(match[3]);
4445+ for(m=0; m<matched.length; m++) {
4446+ results.pushUnique(matched[m]);
4447+ }
4448+ return results;
4449+ },
4450+ sort: function(results,match) {
4451+ return this.sortTiddlers(results,match[3]);
4452+ },
4453+ limit: function(results,match) {
4454+ return results.slice(0,parseInt(match[3],10));
4455+ },
4456+ field: function(results,match) {
4457+ var m,matched = this.getValueTiddlers(match[2],match[3]);
4458+ for (m = 0; m < matched.length; m++) {
4459+ results.pushUnique(matched[m]);
4460+ }
4461+ return results;
4462+ }
4463+};
4464+
4465+// Filter a list of tiddlers
4466+TiddlyWiki.prototype.filterTiddlers = function(filter)
4467+{
4468+ var re = /([^\s\[\]]+)|(?:\[([ \w\.\-]+)\[([^\]]+)\]\])|(?:\[\[([^\]]+)\]\])/mg;
4469+
4470+ var results = [];
4471+ if(filter) {
4472+ var match = re.exec(filter);
4473+ while(match) {
4474+ var handler = (match[1]||match[4])?'tiddler':config.filters[match[2]]?match[2]:'field';
4475+ results = config.filters[handler].call(this,results,match);
4476+ match = re.exec(filter);
4477+ }
4478+ }
4479+ return results;
4480+};
4481+// Returns true if path is a valid field name (path),
4482+// i.e. a sequence of identifiers, separated by "."
4483+TiddlyWiki.isValidFieldName = function(name)
4484+{
4485+ var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name);
4486+ return match && (match[0] == name);
4487+};
4488+
4489+// Throws an exception when name is not a valid field name.
4490+TiddlyWiki.checkFieldName = function(name)
4491+{
4492+ if(!TiddlyWiki.isValidFieldName(name))
4493+ throw config.messages.invalidFieldName.format([name]);
4494+};
4495+
4496+function StringFieldAccess(n,readOnly)
4497+{
4498+ this.set = readOnly ?
4499+ function(t,v) {if(v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);} :
4500+ function(t,v) {if(v != t[n]) {t[n] = v; return true;}};
4501+ this.get = function(t) {return t[n];};
4502+}
4503+
4504+function DateFieldAccess(n)
4505+{
4506+ this.set = function(t,v) {
4507+ var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v);
4508+ if(d != t[n]) {
4509+ t[n] = d; return true;
4510+ }
4511+ };
4512+ this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();};
4513+}
4514+
4515+function LinksFieldAccess(n)
4516+{
4517+ this.set = function(t,v) {
4518+ var s = (typeof v == "string") ? v.readBracketedList() : v;
4519+ if(s.toString() != t[n].toString()) {
4520+ t[n] = s; return true;
4521+ }
4522+ };
4523+ this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);};
4524+}
4525+
4526+TiddlyWiki.standardFieldAccess = {
4527+ // The set functions return true when setting the data has changed the value.
4528+ "title": new StringFieldAccess("title",true),
4529+ // Handle the "tiddler" field name as the title
4530+ "tiddler": new StringFieldAccess("title",true),
4531+ "text": new StringFieldAccess("text"),
4532+ "modifier": new StringFieldAccess("modifier"),
4533+ "modified": new DateFieldAccess("modified"),
4534+ "creator": new StringFieldAccess("creator"),
4535+ "created": new DateFieldAccess("created"),
4536+ "tags": new LinksFieldAccess("tags")
4537+};
4538+
4539+TiddlyWiki.isStandardField = function(name)
4540+{
4541+ return TiddlyWiki.standardFieldAccess[name] != undefined;
4542+};
4543+
4544+// Sets the value of the given field of the tiddler to the value.
4545+// Setting an ExtendedField's value to null or undefined removes the field.
4546+// Setting a namespace to undefined removes all fields of that namespace.
4547+// The fieldName is case-insensitive.
4548+// All values will be converted to a string value.
4549+TiddlyWiki.prototype.setValue = function(tiddler,fieldName,value)
4550+{
4551+ TiddlyWiki.checkFieldName(fieldName);
4552+ var t = this.resolveTiddler(tiddler);
4553+ if(!t)
4554+ return;
4555+ fieldName = fieldName.toLowerCase();
4556+ var isRemove = (value === undefined) || (value === null);
4557+ var accessor = TiddlyWiki.standardFieldAccess[fieldName];
4558+ if(accessor) {
4559+ if(isRemove)
4560+ // don't remove StandardFields
4561+ return;
4562+ var h = TiddlyWiki.standardFieldAccess[fieldName];
4563+ if(!h.set(t,value))
4564+ return;
4565+ } else {
4566+ var oldValue = t.fields[fieldName];
4567+ if(isRemove) {
4568+ if(oldValue !== undefined) {
4569+ // deletes a single field
4570+ delete t.fields[fieldName];
4571+ } else {
4572+ // no concrete value is defined for the fieldName
4573+ // so we guess this is a namespace path.
4574+ // delete all fields in a namespace
4575+ var re = new RegExp("^"+fieldName+"\\.");
4576+ var dirty = false;
4577+ var n;
4578+ for(n in t.fields) {
4579+ if(n.match(re)) {
4580+ delete t.fields[n];
4581+ dirty = true;
4582+ }
4583+ }
4584+ if(!dirty)
4585+ return;
4586+ }
4587+ } else {
4588+ // the "normal" set case. value is defined (not null/undefined)
4589+ // For convenience provide a nicer conversion Date->String
4590+ value = value instanceof Date ? value.convertToYYYYMMDDHHMMSSMMM() : String(value);
4591+ if(oldValue == value)
4592+ return;
4593+ t.fields[fieldName] = value;
4594+ }
4595+ }
4596+ // When we are here the tiddler/store really was changed.
4597+ this.notify(t.title,true);
4598+ if(!fieldName.match(/^temp\./))
4599+ this.setDirty(true);
4600+};
4601+
4602+// Returns the value of the given field of the tiddler.
4603+// The fieldName is case-insensitive.
4604+// Will only return String values (or undefined).
4605+TiddlyWiki.prototype.getValue = function(tiddler,fieldName)
4606+{
4607+ var t = this.resolveTiddler(tiddler);
4608+ if(!t)
4609+ return undefined;
4610+ if(fieldName.indexOf(config.textPrimitives.sectionSeparator) === 0 || fieldName.indexOf(config.textPrimitives.sliceSeparator) === 0) {
4611+ var sliceType = fieldName.substr(0, 2);
4612+ var sliceName = fieldName.substring(2);
4613+ return store.getTiddlerText("%0%1%2".format(t.title,sliceType,sliceName));
4614+ } else {
4615+ fieldName = fieldName.toLowerCase();
4616+ var accessor = TiddlyWiki.standardFieldAccess[fieldName];
4617+ if(accessor) {
4618+ return accessor.get(t);
4619+ }
4620+ }
4621+ return t.fields[fieldName];
4622+};
4623+
4624+// Calls the callback function for every field in the tiddler.
4625+// When callback function returns a non-false value the iteration stops
4626+// and that value is returned.
4627+// The order of the fields is not defined.
4628+// @param callback a function(tiddler,fieldName,value).
4629+TiddlyWiki.prototype.forEachField = function(tiddler,callback,onlyExtendedFields)
4630+{
4631+ var t = this.resolveTiddler(tiddler);
4632+ if(!t)
4633+ return undefined;
4634+ var n,result;
4635+ for(n in t.fields) {
4636+ result = callback(t,n,t.fields[n]);
4637+ if(result)
4638+ return result;
4639+ }
4640+ if(onlyExtendedFields)
4641+ return undefined;
4642+ for(n in TiddlyWiki.standardFieldAccess) {
4643+ if(n != "tiddler") {
4644+ // even though the "title" field can also be referenced through the name "tiddler"
4645+ // we only visit this field once.
4646+ result = callback(t,n,TiddlyWiki.standardFieldAccess[n].get(t));
4647+ if(result)
4648+ return result;
4649+ }
4650+ }
4651+ return undefined;
4652+};
4653+
4654+//--
4655+//-- Story functions
4656+//--
4657+
4658+function Story(containerId,idPrefix)
4659+{
4660+ this.container = containerId;
4661+ this.idPrefix = idPrefix;
4662+ this.highlightRegExp = null;
4663+ this.tiddlerId = function(title) {
4664+ title = title.replace(/_/g, "__").replace(/ /g, "_");
4665+ var id = this.idPrefix + title;
4666+ return id==this.container ? this.idPrefix + "_" + title : id;
4667+ };
4668+ this.containerId = function() {
4669+ return this.container;
4670+ };
4671+}
4672+
4673+Story.prototype.getTiddler = function(title)
4674+{
4675+ return document.getElementById(this.tiddlerId(title));
4676+};
4677+
4678+Story.prototype.getContainer = function()
4679+{
4680+ return document.getElementById(this.containerId());
4681+};
4682+
4683+Story.prototype.forEachTiddler = function(fn)
4684+{
4685+ var place = this.getContainer();
4686+ if(!place)
4687+ return;
4688+ var e = place.firstChild;
4689+ while(e) {
4690+ var n = e.nextSibling;
4691+ var title = e.getAttribute("tiddler");
4692+ if(title) {
4693+ fn.call(this,title,e);
4694+ }
4695+ e = n;
4696+ }
4697+};
4698+
4699+Story.prototype.displayDefaultTiddlers = function()
4700+{
4701+ this.displayTiddlers(null,store.filterTiddlers(store.getTiddlerText("DefaultTiddlers")));
4702+};
4703+
4704+Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,unused,customFields,toggle)
4705+{
4706+ var t;
4707+ for(t = titles.length-1;t>=0;t--)
4708+ this.displayTiddler(srcElement,titles[t],template,animate,unused,customFields);
4709+};
4710+
4711+Story.prototype.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle,animationSrc)
4712+{
4713+ var title = (tiddler instanceof Tiddler) ? tiddler.title : tiddler;
4714+ var tiddlerElem = this.getTiddler(title);
4715+ if(tiddlerElem) {
4716+ if(toggle) {
4717+ if(tiddlerElem.getAttribute("dirty") != "true")
4718+ this.closeTiddler(title,true);
4719+ } else {
4720+ this.refreshTiddler(title,template,false,customFields);
4721+ }
4722+ } else {
4723+ var place = this.getContainer();
4724+ var before = this.positionTiddler(srcElement);
4725+ tiddlerElem = this.createTiddler(place,before,title,template,customFields);
4726+ }
4727+ if(animationSrc && typeof animationSrc !== "string") {
4728+ srcElement = animationSrc;
4729+ }
4730+ if(srcElement && typeof srcElement !== "string") {
4731+ if(config.options.chkAnimate && (animate == undefined || animate == true) && anim && typeof Zoomer == "function" && typeof Scroller == "function")
4732+ anim.startAnimating(new Zoomer(title,srcElement,tiddlerElem),new Scroller(tiddlerElem));
4733+ else
4734+ window.scrollTo(0,ensureVisible(tiddlerElem));
4735+ }
4736+ return tiddlerElem;
4737+};
4738+
4739+Story.prototype.positionTiddler = function(srcElement)
4740+{
4741+ var place = this.getContainer();
4742+ var before = null;
4743+ if(typeof srcElement == "string") {
4744+ switch(srcElement) {
4745+ case "top":
4746+ before = place.firstChild;
4747+ break;
4748+ case "bottom":
4749+ before = null;
4750+ break;
4751+ }
4752+ } else {
4753+ var after = this.findContainingTiddler(srcElement);
4754+ if(after == null) {
4755+ before = place.firstChild;
4756+ } else if(after.nextSibling) {
4757+ before = after.nextSibling;
4758+ if(before.nodeType != 1)
4759+ before = null;
4760+ }
4761+ }
4762+ return before;
4763+};
4764+
4765+Story.prototype.createTiddler = function(place,before,title,template,customFields)
4766+{
4767+ var tiddlerElem = createTiddlyElement(null,"div",this.tiddlerId(title),"tiddler");
4768+ tiddlerElem.setAttribute("refresh","tiddler");
4769+ if(customFields)
4770+ tiddlerElem.setAttribute("tiddlyFields",customFields);
4771+ place.insertBefore(tiddlerElem,before);
4772+ var defaultText = null;
4773+ if(!store.tiddlerExists(title) && !store.isShadowTiddler(title))
4774+ defaultText = this.loadMissingTiddler(title,customFields);
4775+ this.refreshTiddler(title,template,false,customFields,defaultText);
4776+ return tiddlerElem;
4777+};
4778+
4779+Story.prototype.loadMissingTiddler = function(title,fields,callback)
4780+{
4781+ var getTiddlerCallback = function(context)
4782+ {
4783+ if(context.status) {
4784+ var t = context.tiddler;
4785+ if(!t.created)
4786+ t.created = new Date();
4787+ if(!t.modified)
4788+ t.modified = t.created;
4789+ var dirty = store.isDirty();
4790+ context.tiddler = store.saveTiddler(t.title,t.title,t.text,t.modifier,t.modified,t.tags,t.fields,true,t.created,t.creator);
4791+ if(!window.allowSave())
4792+ store.setDirty(dirty);
4793+ autoSaveChanges();
4794+ } else {
4795+ story.refreshTiddler(context.title,null,true);
4796+ }
4797+ context.adaptor.close();
4798+ if(callback) {
4799+ callback(context);
4800+ }
4801+ };
4802+ var tiddler = new Tiddler(title);
4803+ tiddler.fields = typeof fields == "string" ? fields.decodeHashMap() : fields||{};
4804+ var context = {serverType:tiddler.getServerType()};
4805+ if(!context.serverType)
4806+ return "";
4807+ context.host = tiddler.fields['server.host'];
4808+ context.workspace = tiddler.fields['server.workspace'];
4809+ var adaptor = new config.adaptors[context.serverType]();
4810+ adaptor.getTiddler(title,context,null,getTiddlerCallback);
4811+ return config.messages.loadingMissingTiddler.format([title,context.serverType,context.host,context.workspace]);
4812+};
4813+
4814+Story.prototype.chooseTemplateForTiddler = function(title,template)
4815+{
4816+ if(!template)
4817+ template = DEFAULT_VIEW_TEMPLATE;
4818+ if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE)
4819+ template = config.tiddlerTemplates[template];
4820+ return template;
4821+};
4822+
4823+Story.prototype.getTemplateForTiddler = function(title,template,tiddler)
4824+{
4825+ return store.getRecursiveTiddlerText(template,null,10);
4826+};
4827+
4828+Story.prototype.refreshTiddler = function(title,template,force,customFields,defaultText)
4829+{
4830+ var tiddlerElem = this.getTiddler(title);
4831+ if(tiddlerElem) {
4832+ if(tiddlerElem.getAttribute("dirty") == "true" && !force)
4833+ return tiddlerElem;
4834+ template = this.chooseTemplateForTiddler(title,template);
4835+ var currTemplate = tiddlerElem.getAttribute("template");
4836+ if((template != currTemplate) || force) {
4837+ var tiddler = store.getTiddler(title);
4838+ if(!tiddler) {
4839+ tiddler = new Tiddler();
4840+ if(store.isShadowTiddler(title)) {
4841+ var tags = [];
4842+ tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,tags,version.date);
4843+ } else {
4844+ var text = template=="EditTemplate" ?
4845+ config.views.editor.defaultText.format([title]) :
4846+ config.views.wikified.defaultText.format([title]);
4847+ text = defaultText || text;
4848+ var fields = customFields ? customFields.decodeHashMap() : null;
4849+ tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date,fields);
4850+ }
4851+ }
4852+ tiddlerElem.setAttribute("tags",tiddler.tags.join(" "));
4853+ tiddlerElem.setAttribute("tiddler",title);
4854+ tiddlerElem.setAttribute("template",template);
4855+ tiddlerElem.onmouseover = this.onTiddlerMouseOver;
4856+ tiddlerElem.onmouseout = this.onTiddlerMouseOut;
4857+ tiddlerElem.ondblclick = this.onTiddlerDblClick;
4858+ tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress;
4859+ tiddlerElem.innerHTML = this.getTemplateForTiddler(title,template,tiddler);
4860+ applyHtmlMacros(tiddlerElem,tiddler);
4861+ if(store.getTaggedTiddlers(title).length > 0)
4862+ jQuery(tiddlerElem).addClass("isTag");
4863+ else
4864+ jQuery(tiddlerElem).removeClass("isTag");
4865+ if(store.tiddlerExists(title)) {
4866+ jQuery(tiddlerElem).removeClass("shadow");
4867+ jQuery(tiddlerElem).removeClass("missing");
4868+ } else {
4869+ jQuery(tiddlerElem).addClass(store.isShadowTiddler(title) ? "shadow" : "missing");
4870+ }
4871+ if(customFields)
4872+ this.addCustomFields(tiddlerElem,customFields);
4873+ }
4874+ }
4875+ return tiddlerElem;
4876+};
4877+
4878+Story.prototype.addCustomFields = function(place,customFields)
4879+{
4880+ var fields = customFields.decodeHashMap();
4881+ var w = createTiddlyElement(place,"div",null,"customFields");
4882+ w.style.display = "none";
4883+ var t;
4884+ for(t in fields) {
4885+ var e = document.createElement("input");
4886+ e.setAttribute("type","text");
4887+ e.setAttribute("value",fields[t]);
4888+ w.appendChild(e);
4889+ e.setAttribute("edit",t);
4890+ }
4891+};
4892+
4893+Story.prototype.refreshAllTiddlers = function(force)
4894+{
4895+ var e = this.getContainer().firstChild;
4896+ while(e) {
4897+ var template = e.getAttribute("template");
4898+ if(template && e.getAttribute("dirty") != "true") {
4899+ this.refreshTiddler(e.getAttribute("tiddler"),force ? null : template,true);
4900+ }
4901+ e = e.nextSibling;
4902+ }
4903+};
4904+
4905+Story.prototype.onTiddlerMouseOver = function(e)
4906+{
4907+ jQuery(this).addClass("selected");
4908+};
4909+
4910+Story.prototype.onTiddlerMouseOut = function(e)
4911+{
4912+ jQuery(this).removeClass("selected");
4913+};
4914+
4915+Story.prototype.onTiddlerDblClick = function(ev)
4916+{
4917+ var e = ev || window.event;
4918+ var target = resolveTarget(e);
4919+ if(target && target.nodeName.toLowerCase() != "input" && target.nodeName.toLowerCase() != "textarea") {
4920+ if(document.selection && document.selection.empty)
4921+ document.selection.empty();
4922+ config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
4923+ e.cancelBubble = true;
4924+ if(e.stopPropagation) e.stopPropagation();
4925+ return true;
4926+ }
4927+ return false;
4928+};
4929+
4930+Story.prototype.onTiddlerKeyPress = function(ev)
4931+{
4932+ var e = ev || window.event;
4933+ clearMessage();
4934+ var consume = false;
4935+ var title = this.getAttribute("tiddler");
4936+ var target = resolveTarget(e);
4937+ switch(e.keyCode) {
4938+ case 9: // Tab
4939+ var ed = story.getTiddlerField(title,"text");
4940+ if(target.tagName.toLowerCase() == "input" && ed.value==config.views.editor.defaultText.format([title])) {
4941+ // moving from input field and editor still contains default text, so select it
4942+ ed.focus();
4943+ ed.select();
4944+ consume = true;
4945+ }
4946+ if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea") {
4947+ replaceSelection(target,String.fromCharCode(9));
4948+ consume = true;
4949+ }
4950+ if(config.isOpera) {
4951+ target.onblur = function() {
4952+ this.focus();
4953+ this.onblur = null;
4954+ };
4955+ }
4956+ break;
4957+ case 13: // Ctrl-Enter
4958+ case 10: // Ctrl-Enter on IE PC
4959+ case 77: // Ctrl-Enter is "M" on some platforms
4960+ if(e.ctrlKey) {
4961+ blurElement(this);
4962+ config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
4963+ consume = true;
4964+ }
4965+ break;
4966+ case 27: // Escape
4967+ blurElement(this);
4968+ config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
4969+ consume = true;
4970+ break;
4971+ }
4972+ e.cancelBubble = consume;
4973+ if(consume) {
4974+ if(e.stopPropagation) e.stopPropagation(); // Stop Propagation
4975+ e.returnValue = true; // Cancel The Event in IE
4976+ if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz
4977+ }
4978+ return !consume;
4979+};
4980+
4981+Story.prototype.getTiddlerField = function(title,field)
4982+{
4983+ var tiddlerElem = this.getTiddler(title);
4984+ var e = null;
4985+ if(tiddlerElem) {
4986+ var t,children = tiddlerElem.getElementsByTagName("*");
4987+ for(t=0; t<children.length; t++) {
4988+ var c = children[t];
4989+ if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
4990+ if(!e)
4991+ e = c;
4992+ if(c.getAttribute("edit") == field)
4993+ e = c;
4994+ }
4995+ }
4996+ }
4997+ return e;
4998+};
4999+
5000+Story.prototype.focusTiddler = function(title,field)
5001+{
5002+ var e = this.getTiddlerField(title,field);
5003+ if(e) {
5004+ e.focus();
5005+ e.select();
5006+ }
5007+};
5008+
5009+Story.prototype.blurTiddler = function(title)
5010+{
5011+ var tiddlerElem = this.getTiddler(title);
5012+ if(tiddlerElem && tiddlerElem.focus && tiddlerElem.blur) {
5013+ tiddlerElem.focus();
5014+ tiddlerElem.blur();
5015+ }
5016+};
5017+
5018+Story.prototype.setTiddlerField = function(title,tag,mode,field)
5019+{
5020+ var c = this.getTiddlerField(title,field);
5021+ var tags = c.value.readBracketedList();
5022+ tags.setItem(tag,mode);
5023+ c.value = String.encodeTiddlyLinkList(tags);
5024+};
5025+
5026+Story.prototype.setTiddlerTag = function(title,tag,mode)
5027+{
5028+ this.setTiddlerField(title,tag,mode,"tags");
5029+};
5030+
5031+Story.prototype.closeTiddler = function(title,animate,unused)
5032+{
5033+ var tiddlerElem = this.getTiddler(title);
5034+ if(tiddlerElem) {
5035+ clearMessage();
5036+ this.scrubTiddler(tiddlerElem);
5037+ if(config.options.chkAnimate && animate && anim && typeof Slider == "function")
5038+ anim.startAnimating(new Slider(tiddlerElem,false,null,"all"));
5039+ else {
5040+ jQuery(tiddlerElem).remove();
5041+ }
5042+ }
5043+};
5044+
5045+Story.prototype.scrubTiddler = function(tiddlerElem)
5046+{
5047+ tiddlerElem.id = null;
5048+};
5049+
5050+Story.prototype.setDirty = function(title,dirty)
5051+{
5052+ var tiddlerElem = this.getTiddler(title);
5053+ if(tiddlerElem)
5054+ tiddlerElem.setAttribute("dirty",dirty ? "true" : "false");
5055+};
5056+
5057+Story.prototype.isDirty = function(title)
5058+{
5059+ var tiddlerElem = this.getTiddler(title);
5060+ if(tiddlerElem)
5061+ return tiddlerElem.getAttribute("dirty") == "true";
5062+ return null;
5063+};
5064+
5065+Story.prototype.areAnyDirty = function()
5066+{
5067+ var r = false;
5068+ this.forEachTiddler(function(title,element) {
5069+ if(this.isDirty(title))
5070+ r = true;
5071+ });
5072+ return r;
5073+};
5074+
5075+Story.prototype.closeAllTiddlers = function(exclude)
5076+{
5077+ clearMessage();
5078+ this.forEachTiddler(function(title,element) {
5079+ if((title != exclude) && element.getAttribute("dirty") != "true")
5080+ this.closeTiddler(title);
5081+ });
5082+ window.scrollTo(0,ensureVisible(this.container));
5083+};
5084+
5085+Story.prototype.isEmpty = function()
5086+{
5087+ var place = this.getContainer();
5088+ return place && place.firstChild == null;
5089+};
5090+
5091+Story.prototype.search = function(text,useCaseSensitive,useRegExp)
5092+{
5093+ this.closeAllTiddlers();
5094+ highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img");
5095+ var matches = store.search(highlightHack,"title","excludeSearch");
5096+ this.displayTiddlers(null,matches);
5097+ highlightHack = null;
5098+ var q = useRegExp ? "/" : "'";
5099+ if(matches.length > 0)
5100+ displayMessage(config.macros.search.successMsg.format([matches.length.toString(),q + text + q]));
5101+ else
5102+ displayMessage(config.macros.search.failureMsg.format([q + text + q]));
5103+};
5104+
5105+Story.prototype.findContainingTiddler = function(e)
5106+{
5107+ while(e && !jQuery(e).hasClass("tiddler")) {
5108+ e = jQuery(e).hasClass("popup") && Popup.stack[0] ? Popup.stack[0].root : e.parentNode;
5109+ }
5110+ return e;
5111+};
5112+
5113+Story.prototype.gatherSaveFields = function(e,fields)
5114+{
5115+ if(e && e.getAttribute) {
5116+ var f = e.getAttribute("edit");
5117+ if(f)
5118+ fields[f] = e.value.replace(/\r/mg,"");
5119+ if(e.hasChildNodes()) {
5120+ var t,c = e.childNodes;
5121+ for(t=0; t<c.length; t++)
5122+ this.gatherSaveFields(c[t],fields);
5123+ }
5124+ }
5125+};
5126+
5127+Story.prototype.hasChanges = function(title)
5128+{
5129+ var e = this.getTiddler(title);
5130+ if(e) {
5131+ var fields = {};
5132+ this.gatherSaveFields(e,fields);
5133+ if(store.fetchTiddler(title)) {
5134+ var n;
5135+ for(n in fields) {
5136+ if(store.getValue(title,n) != fields[n]) //# tiddler changed
5137+ return true;
5138+ }
5139+ } else {
5140+ if(store.isShadowTiddler(title) && store.getShadowTiddlerText(title) == fields.text) { //# not checking for title or tags
5141+ return false;
5142+ } else { //# changed shadow or new tiddler
5143+ return true;
5144+ }
5145+ }
5146+ }
5147+ return false;
5148+};
5149+
5150+Story.prototype.saveTiddler = function(title,minorUpdate)
5151+{
5152+ var tiddlerElem = this.getTiddler(title);
5153+ if(tiddlerElem) {
5154+ var fields = {};
5155+ this.gatherSaveFields(tiddlerElem,fields);
5156+ var newTitle = fields.title || title;
5157+ if(!store.tiddlerExists(newTitle)) {
5158+ newTitle = newTitle.trim();
5159+ var creator = config.options.txtUserName;
5160+ }
5161+ if(store.tiddlerExists(newTitle) && newTitle != title) {
5162+ if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
5163+ return null;
5164+ title = newTitle;
5165+ }
5166+ if(newTitle != title)
5167+ this.closeTiddler(newTitle,false);
5168+ tiddlerElem.id = this.tiddlerId(newTitle);
5169+ tiddlerElem.setAttribute("tiddler",newTitle);
5170+ tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE);
5171+ tiddlerElem.setAttribute("dirty","false");
5172+ if(config.options.chkForceMinorUpdate)
5173+ minorUpdate = !minorUpdate;
5174+ if(!store.tiddlerExists(newTitle))
5175+ minorUpdate = false;
5176+ var newDate = new Date();
5177+ if(store.tiddlerExists(title)) {
5178+ var t = store.fetchTiddler(title);
5179+ var extendedFields = t.fields;
5180+ creator = t.creator;
5181+ } else {
5182+ extendedFields = merge({},config.defaultCustomFields);
5183+ }
5184+ var n;
5185+ for(n in fields) {
5186+ if(!TiddlyWiki.isStandardField(n))
5187+ extendedFields[n] = fields[n];
5188+ }
5189+ var tiddler = store.saveTiddler(title,newTitle,fields.text,minorUpdate ? undefined : config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags,extendedFields,null,null,creator);
5190+ autoSaveChanges(null,[tiddler]);
5191+ return newTitle;
5192+ }
5193+ return null;
5194+};
5195+
5196+Story.prototype.permaView = function()
5197+{
5198+ var links = [];
5199+ this.forEachTiddler(function(title,element) {
5200+ links.push(String.encodeTiddlyLink(title));
5201+ });
5202+ var t = encodeURIComponent(links.join(" "));
5203+ if(t == "")
5204+ t = "#";
5205+ if(window.location.hash != t)
5206+ window.location.hash = t;
5207+};
5208+
5209+Story.prototype.switchTheme = function(theme)
5210+{
5211+ if(safeMode)
5212+ return;
5213+
5214+ var getSlice = function(theme,slice) {
5215+ var r;
5216+ if(readOnly)
5217+ r = store.getTiddlerSlice(theme,slice+"ReadOnly") || store.getTiddlerSlice(theme,"Web"+slice);
5218+ r = r || store.getTiddlerSlice(theme,slice);
5219+ if(r && r.indexOf(config.textPrimitives.sectionSeparator)==0)
5220+ r = theme + r;
5221+ return store.isAvailable(r) ? r : slice;
5222+ };
5223+
5224+ var replaceNotification = function(i,name,theme,slice) {
5225+ var newName = getSlice(theme,slice);
5226+ if(name!=newName && store.namedNotifications[i].name==name) {
5227+ store.namedNotifications[i].name = newName;
5228+ return newName;
5229+ }
5230+ return name;
5231+ };
5232+
5233+ var pt = config.refresherData.pageTemplate;
5234+ var vi = DEFAULT_VIEW_TEMPLATE;
5235+ var vt = config.tiddlerTemplates[vi];
5236+ var ei = DEFAULT_EDIT_TEMPLATE;
5237+ var et = config.tiddlerTemplates[ei];
5238+
5239+ var i;
5240+ for(i=0; i<config.notifyTiddlers.length; i++) {
5241+ var name = config.notifyTiddlers[i].name;
5242+ switch(name) {
5243+ case "PageTemplate":
5244+ config.refresherData.pageTemplate = replaceNotification(i,config.refresherData.pageTemplate,theme,name);
5245+ break;
5246+ case "StyleSheet":
5247+ removeStyleSheet(config.refresherData.styleSheet);
5248+ config.refresherData.styleSheet = replaceNotification(i,config.refresherData.styleSheet,theme,name);
5249+ break;
5250+ case "ColorPalette":
5251+ config.refresherData.colorPalette = replaceNotification(i,config.refresherData.colorPalette,theme,name);
5252+ break;
5253+ default:
5254+ break;
5255+ }
5256+ }
5257+ config.tiddlerTemplates[vi] = getSlice(theme,"ViewTemplate");
5258+ config.tiddlerTemplates[ei] = getSlice(theme,"EditTemplate");
5259+ if(!startingUp) {
5260+ if(config.refresherData.pageTemplate!=pt || config.tiddlerTemplates[vi]!=vt || config.tiddlerTemplates[ei]!=et) {
5261+ refreshAll();
5262+ this.refreshAllTiddlers(true);
5263+ } else {
5264+ setStylesheet(store.getRecursiveTiddlerText(config.refresherData.styleSheet,"",10),config.refreshers.styleSheet);
5265+ }
5266+ config.options.txtTheme = theme;
5267+ saveOption("txtTheme");
5268+ }
5269+};
5270+
5271+//--
5272+//-- Backstage
5273+//--
5274+// Backstage tasks
5275+config.tasks.save.action = saveChanges;
5276+
5277+var backstage = {
5278+ area: null,
5279+ toolbar: null,
5280+ button: null,
5281+ showButton: null,
5282+ hideButton: null,
5283+ cloak: null,
5284+ panel: null,
5285+ panelBody: null,
5286+ panelFooter: null,
5287+ currTabName: null,
5288+ currTabElem: null,
5289+ content: null,
5290+
5291+ init: function() {
5292+ var cmb = config.messages.backstage;
5293+ this.area = document.getElementById("backstageArea");
5294+ this.toolbar = jQuery("#backstageToolbar").empty()[0];
5295+ this.button = jQuery("#backstageButton").empty()[0];
5296+ this.button.style.display = "block";
5297+ var t = cmb.open.text + " " + glyph("bentArrowLeft");
5298+ this.showButton = createTiddlyButton(this.button,t,cmb.open.tooltip,
5299+ function(e) {backstage.show(); return false;},null,"backstageShow");
5300+ t = glyph("bentArrowRight") + " " + cmb.close.text;
5301+ this.hideButton = createTiddlyButton(this.button,t,cmb.close.tooltip,
5302+ function(e) {backstage.hide(); return false;},null,"backstageHide");
5303+ this.cloak = document.getElementById("backstageCloak");
5304+ this.panel = document.getElementById("backstagePanel");
5305+ this.panelFooter = createTiddlyElement(this.panel,"div",null,"backstagePanelFooter");
5306+ this.panelBody = createTiddlyElement(this.panel,"div",null,"backstagePanelBody");
5307+ this.cloak.onmousedown = function(e) {backstage.switchTab(null);};
5308+ createTiddlyText(this.toolbar,cmb.prompt);
5309+ for(t=0; t<config.backstageTasks.length; t++) {
5310+ var taskName = config.backstageTasks[t];
5311+ var task = config.tasks[taskName];
5312+ var handler = task.action ? this.onClickCommand : this.onClickTab;
5313+ var text = task.text + (task.action ? "" : glyph("downTriangle"));
5314+ var btn = createTiddlyButton(this.toolbar,text,task.tooltip,handler,"backstageTab");
5315+ jQuery(btn).addClass(task.action ? "backstageAction" : "backstageTask");
5316+ btn.setAttribute("task", taskName);
5317+ }
5318+ this.content = document.getElementById("contentWrapper");
5319+ if(config.options.chkBackstage)
5320+ this.show();
5321+ else
5322+ this.hide();
5323+ },
5324+
5325+ isVisible: function() {
5326+ return this.area ? this.area.style.display == "block" : false;
5327+ },
5328+
5329+ show: function() {
5330+ this.area.style.display = "block";
5331+ if(anim && config.options.chkAnimate) {
5332+ backstage.toolbar.style.left = findWindowWidth() + "px";
5333+ var p = [{style: "left", start: findWindowWidth(), end: 0, template: "%0px"}];
5334+ anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p));
5335+ } else {
5336+ backstage.area.style.left = "0px";
5337+ }
5338+ jQuery(this.showButton).hide();
5339+ jQuery(this.hideButton).show();
5340+ config.options.chkBackstage = true;
5341+ saveOption("chkBackstage");
5342+ jQuery(this.content).addClass("backstageVisible");
5343+ },
5344+
5345+ hide: function() {
5346+ if(this.currTabElem) {
5347+ this.switchTab(null);
5348+ } else {
5349+ backstage.toolbar.style.left = "0px";
5350+ if(anim && config.options.chkAnimate) {
5351+ var p = [{style: "left", start: 0, end: findWindowWidth(), template: "%0px"}];
5352+ var c = function(element,properties) {backstage.area.style.display = "none";};
5353+ anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p,c));
5354+ } else {
5355+ this.area.style.display = "none";
5356+ }
5357+ this.showButton.style.display = "block";
5358+ this.hideButton.style.display = "none";
5359+ config.options.chkBackstage = false;
5360+ saveOption("chkBackstage");
5361+ jQuery(this.content).removeClass("backstageVisible");
5362+ }
5363+ },
5364+
5365+ onClickCommand: function(e) {
5366+ var task = config.tasks[this.getAttribute("task")];
5367+ if(task.action) {
5368+ backstage.switchTab(null);
5369+ task.action();
5370+ }
5371+ return false;
5372+ },
5373+
5374+ onClickTab: function(e) {
5375+ backstage.switchTab(this.getAttribute("task"));
5376+ return false;
5377+ },
5378+
5379+ // Switch to a given tab, or none if null is passed
5380+ switchTab: function(tabName) {
5381+ var tabElem = null;
5382+ var e = this.toolbar.firstChild;
5383+ while(e) {
5384+ if(e.getAttribute && e.getAttribute("task") == tabName)
5385+ tabElem = e;
5386+ e = e.nextSibling;
5387+ }
5388+ if(tabName == backstage.currTabName) {
5389+ backstage.hidePanel();
5390+ return;
5391+ }
5392+ if(backstage.currTabElem) {
5393+ jQuery(this.currTabElem).removeClass("backstageSelTab");
5394+ }
5395+ if(tabElem && tabName) {
5396+ backstage.preparePanel();
5397+ jQuery(tabElem).addClass("backstageSelTab");
5398+ var task = config.tasks[tabName];
5399+ wikify(task.content,backstage.panelBody,null,null);
5400+ backstage.showPanel();
5401+ } else if(backstage.currTabElem) {
5402+ backstage.hidePanel();
5403+ }
5404+ backstage.currTabName = tabName;
5405+ backstage.currTabElem = tabElem;
5406+ },
5407+
5408+ isPanelVisible: function() {
5409+ return backstage.panel ? backstage.panel.style.display == "block" : false;
5410+ },
5411+
5412+ preparePanel: function() {
5413+ backstage.cloak.style.height = findDocHeight() + "px";
5414+ backstage.cloak.style.display = "block";
5415+ jQuery(backstage.panelBody).empty();
5416+ return backstage.panelBody;
5417+ },
5418+
5419+ showPanel: function() {
5420+ backstage.panel.style.display = "block";
5421+ if(anim && config.options.chkAnimate) {
5422+ backstage.panel.style.top = (-backstage.panel.offsetHeight) + "px";
5423+ var p = [{style: "top", start: -backstage.panel.offsetHeight, end: 0, template: "%0px"}];
5424+ anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p),new Scroller(backstage.panel,false));
5425+ } else {
5426+ backstage.panel.style.top = "0px";
5427+ }
5428+ return backstage.panelBody;
5429+ },
5430+
5431+ hidePanel: function() {
5432+ if(backstage.currTabElem)
5433+ jQuery(backstage.currTabElem).removeClass("backstageSelTab");
5434+ backstage.currTabElem = null;
5435+ backstage.currTabName = null;
5436+ if(anim && config.options.chkAnimate) {
5437+ var p = [
5438+ {style: "top", start: 0, end: -(backstage.panel.offsetHeight), template: "%0px"},
5439+ {style: "display", atEnd: "none"}
5440+ ];
5441+ var c = function(element,properties) {backstage.cloak.style.display = "none";};
5442+ anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p,c));
5443+ } else {
5444+ jQuery([backstage.panel,backstage.cloak]).hide();
5445+ }
5446+ }
5447+};
5448+
5449+config.macros.backstage = {};
5450+
5451+config.macros.backstage.handler = function(place,macroName,params)
5452+{
5453+ var backstageTask = config.tasks[params[0]];
5454+ if(backstageTask)
5455+ createTiddlyButton(place,backstageTask.text,backstageTask.tooltip,function(e) {backstage.switchTab(params[0]); return false;});
5456+};
5457+
5458+//--
5459+//-- ImportTiddlers macro
5460+//--
5461+
5462+config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
5463+{
5464+ if(readOnly) {
5465+ createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning);
5466+ return;
5467+ }
5468+ var w = new Wizard();
5469+ w.createWizard(place,this.wizardTitle);
5470+ this.restart(w);
5471+};
5472+
5473+config.macros.importTiddlers.onCancel = function(e)
5474+{
5475+ var wizard = new Wizard(this);
5476+ wizard.clear();
5477+ config.macros.importTiddlers.restart(wizard);
5478+ return false;
5479+};
5480+
5481+config.macros.importTiddlers.onClose = function(e)
5482+{
5483+ backstage.hidePanel();
5484+ return false;
5485+};
5486+
5487+config.macros.importTiddlers.restart = function(wizard)
5488+{
5489+ var me = config.macros.importTiddlers;
5490+ wizard.addStep(this.step1Title,this.step1Html);
5491+ var t,s = wizard.getElement("selTypes");
5492+ for(t in config.adaptors) {
5493+ var e = createTiddlyElement(s,"option",null,null,config.adaptors[t].serverLabel || t);
5494+ e.value = t;
5495+ }
5496+ if(config.defaultAdaptor)
5497+ s.value = config.defaultAdaptor;
5498+ s = wizard.getElement("selFeeds");
5499+ var feeds = this.getFeeds();
5500+ for(t in feeds) {
5501+ e = createTiddlyElement(s,"option",null,null,t);
5502+ e.value = t;
5503+ }
5504+ wizard.setValue("feeds",feeds);
5505+ s.onchange = me.onFeedChange;
5506+ var fileInput = wizard.getElement("txtBrowse");
5507+ fileInput.onchange = me.onBrowseChange;
5508+ fileInput.onkeyup = me.onBrowseChange;
5509+ wizard.setButtons([{caption: this.openLabel, tooltip: this.openPrompt, onClick: me.onOpen}]);
5510+ wizard.formElem.action = "javascript:;";
5511+ wizard.formElem.onsubmit = function() {
5512+ if(!this.txtPath || this.txtPath.value.length) //# check for manually entered path in first step
5513+ this.lastChild.firstChild.onclick();
5514+ };
5515+};
5516+
5517+config.macros.importTiddlers.getFeeds = function()
5518+{
5519+ var feeds = {};
5520+ var t,tagged = store.getTaggedTiddlers("systemServer","title");
5521+ for(t=0; t<tagged.length; t++) {
5522+ var title = tagged[t].title;
5523+ var serverType = store.getTiddlerSlice(title,"Type");
5524+ if(!serverType)
5525+ serverType = "file";
5526+ feeds[title] = {title: title,
5527+ url: store.getTiddlerSlice(title,"URL"),
5528+ workspace: store.getTiddlerSlice(title,"Workspace"),
5529+ workspaceList: store.getTiddlerSlice(title,"WorkspaceList"),
5530+ tiddlerFilter: store.getTiddlerSlice(title,"TiddlerFilter"),
5531+ serverType: serverType,
5532+ description: store.getTiddlerSlice(title,"Description")};
5533+ }
5534+ return feeds;
5535+};
5536+
5537+config.macros.importTiddlers.onFeedChange = function(e)
5538+{
5539+ var wizard = new Wizard(this);
5540+ var selTypes = wizard.getElement("selTypes");
5541+ var fileInput = wizard.getElement("txtPath");
5542+ var feeds = wizard.getValue("feeds");
5543+ var f = feeds[this.value];
5544+ if(f) {
5545+ selTypes.value = f.serverType;
5546+ fileInput.value = f.url;
5547+ wizard.setValue("feedName",f.serverType);
5548+ wizard.setValue("feedHost",f.url);
5549+ wizard.setValue("feedWorkspace",f.workspace);
5550+ wizard.setValue("feedWorkspaceList",f.workspaceList);
5551+ wizard.setValue("feedTiddlerFilter",f.tiddlerFilter);
5552+ }
5553+ return false;
5554+};
5555+
5556+config.macros.importTiddlers.onBrowseChange = function(e)
5557+{
5558+ var wizard = new Wizard(this);
5559+ var file = this.value;
5560+ file = file.replace(/^C:\\fakepath\\/i,''); // remove fakepath (chrome/opera/safari)
5561+ if(this.files && this.files[0]) {
5562+ try {
5563+ netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
5564+ file = this.files[0].fileName; // REQUIRES PRIVILEGES.. NULL otherwise
5565+ } catch (ex) {
5566+ // non-priv fallback: combine filename with path to current document
5567+ var path=getLocalPath(document.location.href);
5568+ var slashpos=path.lastIndexOf('/'); if (slashpos==-1) slashpos=path.lastIndexOf('\\');
5569+ if (slashpos!=-1) path=path.substr(0,slashpos+1); // remove filename, leave trailing slash
5570+ file=path+file;
5571+ }
5572+ }
5573+ var fileInput = wizard.getElement("txtPath");
5574+ fileInput.value = config.macros.importTiddlers.getURLFromLocalPath(file);
5575+ var serverType = wizard.getElement("selTypes");
5576+ serverType.value = "file";
5577+ return true;
5578+};
5579+
5580+config.macros.importTiddlers.getURLFromLocalPath = function(v)
5581+{
5582+ if(!v || !v.length)
5583+ return v;
5584+ v = v.replace(/\\/g,"/"); // use "/" for cross-platform consistency
5585+ var u;
5586+ var t = v.split(":");
5587+ var p = t[1] || t[0]; // remove drive letter (if any)
5588+ if(t[1] && (t[0] == "http" || t[0] == "https" || t[0] == "file")) {
5589+ u = v;
5590+ } else if(p.substr(0,1)=="/") {
5591+ u = document.location.protocol + "//" + document.location.hostname + (t[1] ? "/" : "") + v;
5592+ } else {
5593+ var c = document.location.href.replace(/\\/g,"/");
5594+ var pos = c.lastIndexOf("/");
5595+ if(pos!=-1)
5596+ c = c.substr(0,pos); // remove filename
5597+ u = c + "/" + p;
5598+ }
5599+ return u;
5600+};
5601+
5602+config.macros.importTiddlers.onOpen = function(e)
5603+{
5604+ var me = config.macros.importTiddlers;
5605+ var wizard = new Wizard(this);
5606+ var fileInput = wizard.getElement("txtPath");
5607+ var url = fileInput.value;
5608+ var serverType = wizard.getElement("selTypes").value || config.defaultAdaptor;
5609+ var adaptor = new config.adaptors[serverType]();
5610+ wizard.setValue("adaptor",adaptor);
5611+ wizard.setValue("serverType",serverType);
5612+ wizard.setValue("host",url);
5613+ adaptor.openHost(url,null,wizard,me.onOpenHost);
5614+ wizard.setButtons([{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}],me.statusOpenHost);
5615+ return false;
5616+};
5617+
5618+config.macros.importTiddlers.onOpenHost = function(context,wizard)
5619+{
5620+ var me = config.macros.importTiddlers;
5621+ var adaptor = wizard.getValue("adaptor");
5622+ if(context.status !== true)
5623+ displayMessage("Error in importTiddlers.onOpenHost: " + context.statusText);
5624+ adaptor.getWorkspaceList(context,wizard,me.onGetWorkspaceList);
5625+ wizard.setButtons([{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}],me.statusGetWorkspaceList);
5626+};
5627+
5628+config.macros.importTiddlers.onGetWorkspaceList = function(context,wizard)
5629+{
5630+ var me = config.macros.importTiddlers;
5631+ if(context.status !== true)
5632+ displayMessage("Error in importTiddlers.onGetWorkspaceList: " + context.statusText);
5633+ wizard.setValue("context",context);
5634+ var workspace = wizard.getValue("feedWorkspace");
5635+ if(!workspace && context.workspaces.length==1)
5636+ workspace = context.workspaces[0].title;
5637+ if(workspace) {
5638+ context.adaptor.openWorkspace(workspace,context,wizard,me.onOpenWorkspace);
5639+ wizard.setValue("workspace",workspace);
5640+ wizard.setButtons([{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}],me.statusOpenWorkspace);
5641+ return;
5642+ }
5643+ wizard.addStep(me.step2Title,me.step2Html);
5644+ var t,s = wizard.getElement("selWorkspace");
5645+ s.onchange = me.onWorkspaceChange;
5646+ for(t=0; t<context.workspaces.length; t++) {
5647+ var e = createTiddlyElement(s,"option",null,null,context.workspaces[t].title);
5648+ e.value = context.workspaces[t].title;
5649+ }
5650+ var workspaceList = wizard.getValue("feedWorkspaceList");
5651+ if(workspaceList) {
5652+ var n,list = workspaceList.parseParams("workspace",null,false,true);
5653+ for(n=1; n<list.length; n++) {
5654+ if(context.workspaces.findByField("title",list[n].value) == null) {
5655+ e = createTiddlyElement(s,"option",null,null,list[n].value);
5656+ e.value = list[n].value;
5657+ }
5658+ }
5659+ }
5660+ if(workspace) {
5661+ t = wizard.getElement("txtWorkspace");
5662+ t.value = workspace;
5663+ }
5664+ wizard.setButtons([{caption: me.openLabel, tooltip: me.openPrompt, onClick: me.onChooseWorkspace}]);
5665+};
5666+
5667+config.macros.importTiddlers.onWorkspaceChange = function(e)
5668+{
5669+ var wizard = new Wizard(this);
5670+ var t = wizard.getElement("txtWorkspace");
5671+ t.value = this.value;
5672+ this.selectedIndex = 0;
5673+ return false;
5674+};
5675+
5676+config.macros.importTiddlers.onChooseWorkspace = function(e)
5677+{
5678+ var me = config.macros.importTiddlers;
5679+ var wizard = new Wizard(this);
5680+ var adaptor = wizard.getValue("adaptor");
5681+ var workspace = wizard.getElement("txtWorkspace").value;
5682+ wizard.setValue("workspace",workspace);
5683+ var context = wizard.getValue("context");
5684+ adaptor.openWorkspace(workspace,context,wizard,me.onOpenWorkspace);
5685+ wizard.setButtons([{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}],me.statusOpenWorkspace);
5686+ return false;
5687+};
5688+
5689+config.macros.importTiddlers.onOpenWorkspace = function(context,wizard)
5690+{
5691+ var me = config.macros.importTiddlers;
5692+ if(context.status !== true)
5693+ displayMessage("Error in importTiddlers.onOpenWorkspace: " + context.statusText);
5694+ var adaptor = wizard.getValue("adaptor");
5695+ var browse=wizard.getElement("txtBrowse");
5696+ if (browse.files) context.file=browse.files[0]; // for HTML5 FileReader
5697+ adaptor.getTiddlerList(context,wizard,me.onGetTiddlerList,wizard.getValue("feedTiddlerFilter"));
5698+ wizard.setButtons([{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}],me.statusGetTiddlerList);
5699+};
5700+
5701+config.macros.importTiddlers.onGetTiddlerList = function(context,wizard)
5702+{
5703+ var me = config.macros.importTiddlers;
5704+ if(context.status !== true) {
5705+ var error = context.statusText||me.errorGettingTiddlerList;
5706+ if(context.host.indexOf("file://") === 0) {
5707+ error = me.errorGettingTiddlerListFile;
5708+ } else {
5709+ error = context.xhr && context.xhr.status == 404 ? me.errorGettingTiddlerListHttp404 :
5710+ me.errorGettingTiddlerListHttp;
5711+ }
5712+ wizard.setButtons([{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}],"");
5713+ jQuery("span.status", wizard.footerEl).html(error); // so error message can be html
5714+ return;
5715+ }
5716+ // Extract data for the listview
5717+ var listedTiddlers = [];
5718+ if(context.tiddlers) {
5719+ var n;
5720+ for(n=0; n<context.tiddlers.length; n++) {
5721+ var tiddler = context.tiddlers[n];
5722+ listedTiddlers.push({
5723+ title: tiddler.title,
5724+ modified: tiddler.modified,
5725+ modifier: tiddler.modifier,
5726+ text: tiddler.text ? wikifyPlainText(tiddler.text,100) : "",
5727+ tags: tiddler.tags,
5728+ size: tiddler.text ? tiddler.text.length : 0,
5729+ tiddler: tiddler
5730+ });
5731+ }
5732+ }
5733+ listedTiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
5734+ // Display the listview
5735+ wizard.addStep(me.step3Title,me.step3Html);
5736+ var markList = wizard.getElement("markList");
5737+ var listWrapper = document.createElement("div");
5738+ markList.parentNode.insertBefore(listWrapper,markList);
5739+ var listView = ListView.create(listWrapper,listedTiddlers,me.listViewTemplate);
5740+ wizard.setValue("listView",listView);
5741+ wizard.setValue("context",context);
5742+ var txtSaveTiddler = wizard.getElement("txtSaveTiddler");
5743+ txtSaveTiddler.value = me.generateSystemServerName(wizard);
5744+ wizard.setButtons([
5745+ {caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel},
5746+ {caption: me.importLabel, tooltip: me.importPrompt, onClick: me.doImport}
5747+ ]);
5748+};
5749+
5750+config.macros.importTiddlers.generateSystemServerName = function(wizard)
5751+{
5752+ var serverType = wizard.getValue("serverType");
5753+ var host = wizard.getValue("host");
5754+ var workspace = wizard.getValue("workspace");
5755+ var pattern = config.macros.importTiddlers[workspace ? "systemServerNamePattern" : "systemServerNamePatternNoWorkspace"];
5756+ return pattern.format([serverType,host,workspace]);
5757+};
5758+
5759+config.macros.importTiddlers.saveServerTiddler = function(wizard)
5760+{
5761+ var me = config.macros.importTiddlers;
5762+ var txtSaveTiddler = wizard.getElement("txtSaveTiddler").value;
5763+ if(store.tiddlerExists(txtSaveTiddler)) {
5764+ if(!confirm(me.confirmOverwriteSaveTiddler.format([txtSaveTiddler])))
5765+ return;
5766+ store.suspendNotifications();
5767+ store.removeTiddler(txtSaveTiddler);
5768+ store.resumeNotifications();
5769+ }
5770+ var serverType = wizard.getValue("serverType");
5771+ var host = wizard.getValue("host");
5772+ var workspace = wizard.getValue("workspace");
5773+ var text = me.serverSaveTemplate.format([serverType,host,workspace]);
5774+ store.saveTiddler(txtSaveTiddler,txtSaveTiddler,text,me.serverSaveModifier,new Date(),["systemServer"]);
5775+};
5776+
5777+config.macros.importTiddlers.doImport = function(e)
5778+{
5779+ var me = config.macros.importTiddlers;
5780+ var wizard = new Wizard(this);
5781+ if(wizard.getElement("chkSave").checked)
5782+ me.saveServerTiddler(wizard);
5783+ var chkSync = wizard.getElement("chkSync").checked;
5784+ wizard.setValue("sync",chkSync);
5785+ var listView = wizard.getValue("listView");
5786+ var rowNames = ListView.getSelectedRows(listView);
5787+ var adaptor = wizard.getValue("adaptor");
5788+ var overwrite = [];
5789+ var t;
5790+ for(t=0; t<rowNames.length; t++) {
5791+ if(store.tiddlerExists(rowNames[t]))
5792+ overwrite.push(rowNames[t]);
5793+ }
5794+ if(overwrite.length > 0) {
5795+ if(!confirm(me.confirmOverwriteText.format([overwrite.join(", ")])))
5796+ return false;
5797+ }
5798+ wizard.addStep(me.step4Title.format([rowNames.length]),me.step4Html);
5799+ for(t=0; t<rowNames.length; t++) {
5800+ var link = document.createElement("div");
5801+ createTiddlyLink(link,rowNames[t],true);
5802+ var place = wizard.getElement("markReport");
5803+ place.parentNode.insertBefore(link,place);
5804+ }
5805+ wizard.setValue("remainingImports",rowNames.length);
5806+ wizard.setButtons([
5807+ {caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}
5808+ ],me.statusDoingImport);
5809+ var wizardContext = wizard.getValue("context");
5810+ var tiddlers = wizardContext ? wizardContext.tiddlers : [];
5811+ for(t=0; t<rowNames.length; t++) {
5812+ var context = {
5813+ allowSynchronous:true,
5814+ tiddler:tiddlers[tiddlers.findByField("title",rowNames[t])]
5815+ };
5816+ adaptor.getTiddler(rowNames[t],context,wizard,me.onGetTiddler);
5817+ }
5818+ return false;
5819+};
5820+
5821+config.macros.importTiddlers.onGetTiddler = function(context,wizard)
5822+{
5823+ var me = config.macros.importTiddlers;
5824+ if(!context.status)
5825+ displayMessage("Error in importTiddlers.onGetTiddler: " + context.statusText);
5826+ var tiddler = context.tiddler;
5827+ store.suspendNotifications();
5828+ store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
5829+ if(!wizard.getValue("sync")) {
5830+ store.setValue(tiddler.title,'server',null);
5831+ }
5832+ store.resumeNotifications();
5833+ if(!context.isSynchronous)
5834+ store.notify(tiddler.title,true);
5835+ var remainingImports = wizard.getValue("remainingImports")-1;
5836+ wizard.setValue("remainingImports",remainingImports);
5837+ if(remainingImports == 0) {
5838+ if(context.isSynchronous) {
5839+ store.notifyAll();
5840+ refreshDisplay();
5841+ }
5842+ wizard.setButtons([
5843+ {caption: me.doneLabel, tooltip: me.donePrompt, onClick: me.onClose}
5844+ ],me.statusDoneImport);
5845+ autoSaveChanges();
5846+ }
5847+};
5848+
5849+//--
5850+//-- Upgrade macro
5851+//--
5852+
5853+config.macros.upgrade.handler = function(place)
5854+{
5855+ var w = new Wizard();
5856+ w.createWizard(place,this.wizardTitle);
5857+ w.addStep(this.step1Title,this.step1Html.format([this.source,this.source]));
5858+ w.setButtons([{caption: this.upgradeLabel, tooltip: this.upgradePrompt, onClick: this.onClickUpgrade}]);
5859+};
5860+
5861+config.macros.upgrade.onClickUpgrade = function(e)
5862+{
5863+ var me = config.macros.upgrade;
5864+ var w = new Wizard(this);
5865+ if(!window.allowSave()) {
5866+ alert(me.errorCantUpgrade);
5867+ return false;
5868+ }
5869+ if(story.areAnyDirty() || store.isDirty()) {
5870+ alert(me.errorNotSaved);
5871+ return false;
5872+ }
5873+ var localPath = getLocalPath(document.location.toString());
5874+ var backupPath = getBackupPath(localPath,me.backupExtension);
5875+ w.setValue("backupPath",backupPath);
5876+ w.setButtons([],me.statusPreparingBackup);
5877+ var original = loadOriginal(localPath);
5878+ w.setButtons([],me.statusSavingBackup);
5879+ var backup = copyFile(backupPath,localPath);
5880+ if(!backup)
5881+ backup = saveFile(backupPath,original);
5882+ if(!backup) {
5883+ w.setButtons([],me.errorSavingBackup);
5884+ alert(me.errorSavingBackup);
5885+ return false;
5886+ }
5887+ w.setButtons([],me.statusLoadingCore);
5888+ var options = {
5889+ type:"GET",
5890+ url:me.source,
5891+ processData:false,
5892+ success:function(data,textStatus,jqXHR) {
5893+ me.onLoadCore(true,w,jqXHR.responseText,me.source,jqXHR);
5894+ },
5895+ error:function(jqXHR,textStatus,errorThrown) {
5896+ me.onLoadCore(false,w,null,me.source,jqXHR);
5897+ }
5898+ };
5899+ ajaxReq(options);
5900+ return false;
5901+};
5902+
5903+config.macros.upgrade.onLoadCore = function(status,params,responseText,url,xhr)
5904+{
5905+ var me = config.macros.upgrade;
5906+ var w = params;
5907+ var errMsg;
5908+ if(!status)
5909+ errMsg = me.errorLoadingCore;
5910+ var newVer = me.extractVersion(responseText);
5911+ if(!newVer)
5912+ errMsg = me.errorCoreFormat;
5913+ if(errMsg) {
5914+ w.setButtons([],errMsg);
5915+ alert(errMsg);
5916+ return;
5917+ }
5918+ var onStartUpgrade = function(e) {
5919+ w.setButtons([],me.statusSavingCore);
5920+ var localPath = getLocalPath(document.location.toString());
5921+ saveFile(localPath,responseText);
5922+ w.setButtons([],me.statusReloadingCore);
5923+ var backupPath = w.getValue("backupPath");
5924+ var newLoc = document.location.toString() + "?time=" + new Date().convertToYYYYMMDDHHMM() + "#upgrade:[[" + encodeURI(backupPath) + "]]";
5925+ window.setTimeout(function () {window.location = newLoc;},10);
5926+ };
5927+ var step2 = [me.step2Html_downgrade,me.step2Html_restore,me.step2Html_upgrade][compareVersions(version,newVer) + 1];
5928+ w.addStep(me.step2Title,step2.format([formatVersion(newVer),formatVersion(version)]));
5929+ w.setButtons([{caption: me.startLabel, tooltip: me.startPrompt, onClick: onStartUpgrade},{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}]);
5930+};
5931+
5932+config.macros.upgrade.onCancel = function(e)
5933+{
5934+ var me = config.macros.upgrade;
5935+ var w = new Wizard(this);
5936+ w.addStep(me.step3Title,me.step3Html);
5937+ w.setButtons([]);
5938+ return false;
5939+};
5940+
5941+config.macros.upgrade.extractVersion = function(upgradeFile)
5942+{
5943+ var re = /^var version = \{title: "([^"]+)", major: (\d+), minor: (\d+), revision: (\d+)(, beta: (\d+)){0,1}, date: new Date\("([^"]+)"\)/mg;
5944+ var m = re.exec(upgradeFile);
5945+ return m ? {title: m[1], major: m[2], minor: m[3], revision: m[4], beta: m[6], date: new Date(m[7])} : null;
5946+};
5947+
5948+function upgradeFrom(path)
5949+{
5950+ var importStore = new TiddlyWiki();
5951+ var tw = loadFile(path);
5952+ if(window.netscape !== undefined)
5953+ tw = convertUTF8ToUnicode(tw);
5954+ importStore.importTiddlyWiki(tw);
5955+ importStore.forEachTiddler(function(title,tiddler) {
5956+ if(!store.getTiddler(title)) {
5957+ store.addTiddler(tiddler);
5958+ }
5959+ });
5960+ refreshDisplay();
5961+ saveChanges(); //# To create appropriate Markup* sections
5962+ alert(config.messages.upgradeDone.format([formatVersion()]));
5963+ window.location = window.location.toString().substr(0,window.location.toString().lastIndexOf("?"));
5964+}
5965+
5966+//--
5967+//-- Manager UI for groups of tiddlers
5968+//--
5969+
5970+config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString)
5971+{
5972+ var wizard = new Wizard();
5973+ wizard.createWizard(place,this.wizardTitle);
5974+ wizard.addStep(this.step1Title,this.step1Html);
5975+ var markList = wizard.getElement("markList");
5976+ var listWrapper = document.createElement("div");
5977+ markList.parentNode.insertBefore(listWrapper,markList);
5978+ listWrapper.setAttribute("refresh","macro");
5979+ listWrapper.setAttribute("macroName","plugins");
5980+ listWrapper.setAttribute("params",paramString);
5981+ this.refresh(listWrapper,paramString);
5982+};
5983+
5984+config.macros.plugins.refresh = function(listWrapper,params)
5985+{
5986+ var me = config.macros.plugins;
5987+ var wizard = new Wizard(listWrapper);
5988+ var selectedRows = [];
5989+ ListView.forEachSelector(listWrapper,function(e,rowName) {
5990+ if(e.checked)
5991+ selectedRows.push(e.getAttribute("rowName"));
5992+ });
5993+ jQuery(listWrapper).empty();
5994+ params = params.parseParams("anon");
5995+ var plugins = installedPlugins.slice(0);
5996+ var t,tiddler,p;
5997+ var configTiddlers = store.getTaggedTiddlers("systemConfig");
5998+ for(t=0; t<configTiddlers.length; t++) {
5999+ tiddler = configTiddlers[t];
6000+ if(plugins.findByField("title",tiddler.title) == null) {
6001+ p = getPluginInfo(tiddler);
6002+ p.executed = false;
6003+ p.log.splice(0,0,this.skippedText);
6004+ plugins.push(p);
6005+ }
6006+ }
6007+ for(t=0; t<plugins.length; t++) {
6008+ p = plugins[t];
6009+ p.size = p.tiddler.text ? p.tiddler.text.length : 0;
6010+ p.forced = p.tiddler.isTagged("systemConfigForce");
6011+ p.disabled = p.tiddler.isTagged("systemConfigDisable");
6012+ p.Selected = selectedRows.indexOf(plugins[t].title) != -1;
6013+ }
6014+ if(plugins.length == 0) {
6015+ createTiddlyElement(listWrapper,"em",null,null,this.noPluginText);
6016+ wizard.setButtons([]);
6017+ } else {
6018+ var template = readOnly ? this.listViewTemplateReadOnly : this.listViewTemplate;
6019+ var listView = ListView.create(listWrapper,plugins,template,this.onSelectCommand);
6020+ wizard.setValue("listView",listView);
6021+ if(!readOnly) {
6022+ wizard.setButtons([
6023+ {caption: me.removeLabel, tooltip: me.removePrompt, onClick: me.doRemoveTag},
6024+ {caption: me.deleteLabel, tooltip: me.deletePrompt, onClick: me.doDelete}
6025+ ]);
6026+ }
6027+ }
6028+};
6029+
6030+config.macros.plugins.doRemoveTag = function(e)
6031+{
6032+ var wizard = new Wizard(this);
6033+ var listView = wizard.getValue("listView");
6034+ var rowNames = ListView.getSelectedRows(listView);
6035+ if(rowNames.length == 0) {
6036+ alert(config.messages.nothingSelected);
6037+ } else {
6038+ var t;
6039+ for(t=0; t<rowNames.length; t++) {
6040+ store.setTiddlerTag(rowNames[t],false,"systemConfig");
6041+ }
6042+ autoSaveChanges();
6043+ }
6044+};
6045+
6046+config.macros.plugins.doDelete = function(e)
6047+{
6048+ var wizard = new Wizard(this);
6049+ var listView = wizard.getValue("listView");
6050+ var rowNames = ListView.getSelectedRows(listView);
6051+ if(rowNames.length == 0) {
6052+ alert(config.messages.nothingSelected);
6053+ } else {
6054+ if(confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")]))) {
6055+ var t;
6056+ for(t=0; t<rowNames.length; t++) {
6057+ store.removeTiddler(rowNames[t]);
6058+ story.closeTiddler(rowNames[t],true);
6059+ }
6060+ }
6061+ autoSaveChanges();
6062+ }
6063+};
6064+
6065+//--
6066+//-- Message area
6067+//--
6068+
6069+function getMessageDiv()
6070+{
6071+ var msgArea = document.getElementById("messageArea");
6072+ if(!msgArea)
6073+ return null;
6074+ if(!msgArea.hasChildNodes())
6075+ createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"),
6076+ config.messages.messageClose.text,
6077+ config.messages.messageClose.tooltip,
6078+ clearMessage);
6079+ msgArea.style.display = "block";
6080+ return createTiddlyElement(msgArea,"div");
6081+}
6082+
6083+function displayMessage(text,linkText)
6084+{
6085+ var e = getMessageDiv();
6086+ if(!e) {
6087+ alert(text);
6088+ return;
6089+ }
6090+ if(linkText) {
6091+ var link = createTiddlyElement(e,"a",null,null,text);
6092+ link.href = linkText;
6093+ link.target = "_blank";
6094+ } else {
6095+ e.appendChild(document.createTextNode(text));
6096+ }
6097+}
6098+
6099+function clearMessage()
6100+{
6101+ var msgArea = document.getElementById("messageArea");
6102+ if(msgArea) {
6103+ jQuery(msgArea).empty();
6104+ msgArea.style.display = "none";
6105+ }
6106+ return false;
6107+}
6108+
6109+//--
6110+//-- Refresh mechanism
6111+//--
6112+
6113+config.notifyTiddlers = [
6114+ {name: "SystemSettings", notify: onSystemSettingsChange},
6115+ {name: "StyleSheetLayout", notify: refreshStyles},
6116+ {name: "StyleSheetColors", notify: refreshStyles},
6117+ {name: "StyleSheet", notify: refreshStyles},
6118+ {name: "StyleSheetPrint", notify: refreshStyles},
6119+ {name: "PageTemplate", notify: refreshPageTemplate},
6120+ {name: "SiteTitle", notify: refreshPageTitle},
6121+ {name: "SiteSubtitle", notify: refreshPageTitle},
6122+ {name: "WindowTitle", notify: refreshPageTitle},
6123+ {name: "ColorPalette", notify: refreshColorPalette},
6124+ {name: null, notify: refreshDisplay}
6125+];
6126+
6127+config.refreshers = {
6128+ link: function(e,changeList)
6129+ {
6130+ var title = e.getAttribute("tiddlyLink");
6131+ refreshTiddlyLink(e,title);
6132+ return true;
6133+ },
6134+
6135+ tiddler: function(e,changeList)
6136+ {
6137+ var title = e.getAttribute("tiddler");
6138+ var template = e.getAttribute("template");
6139+ if(changeList && (changeList.indexOf && changeList.indexOf(title) != -1) && !story.isDirty(title))
6140+ story.refreshTiddler(title,template,true);
6141+ else
6142+ refreshElements(e,changeList);
6143+ return true;
6144+ },
6145+
6146+ content: function(e,changeList)
6147+ {
6148+ var title = e.getAttribute("tiddler");
6149+ var force = e.getAttribute("force");
6150+ var args = e.getAttribute("args");
6151+ if(force != null || changeList == null || (changeList.indexOf && changeList.indexOf(title) != -1)) {
6152+ jQuery(e).empty();
6153+ config.macros.tiddler.transclude(e,title,args);
6154+ return true;
6155+ } else
6156+ return false;
6157+ },
6158+
6159+ macro: function(e,changeList)
6160+ {
6161+ var macro = e.getAttribute("macroName");
6162+ var params = e.getAttribute("params");
6163+ if(macro)
6164+ macro = config.macros[macro];
6165+ if(macro && macro.refresh)
6166+ macro.refresh(e,params);
6167+ return true;
6168+ }
6169+};
6170+
6171+config.refresherData = {
6172+ styleSheet: "StyleSheet",
6173+ defaultStyleSheet: "StyleSheet",
6174+ pageTemplate: "PageTemplate",
6175+ defaultPageTemplate: "PageTemplate",
6176+ colorPalette: "ColorPalette",
6177+ defaultColorPalette: "ColorPalette"
6178+};
6179+
6180+function refreshElements(root,changeList)
6181+{
6182+ var c,nodes = root.childNodes;
6183+ for(c=0; c<nodes.length; c++) {
6184+ var e = nodes[c], type = null;
6185+ if(e.getAttribute && (e.tagName ? e.tagName != "IFRAME" : true))
6186+ type = e.getAttribute("refresh");
6187+ var refresher = config.refreshers[type];
6188+ var refreshed = false;
6189+ if(refresher != undefined)
6190+ refreshed = refresher(e,changeList);
6191+ if(e.hasChildNodes() && !refreshed)
6192+ refreshElements(e,changeList);
6193+ }
6194+}
6195+
6196+function applyHtmlMacros(root,tiddler)
6197+{
6198+ var e = root.firstChild;
6199+ while(e) {
6200+ var nextChild = e.nextSibling;
6201+ if(e.getAttribute) {
6202+ var macro = e.getAttribute("macro");
6203+ if(macro) {
6204+ e.removeAttribute("macro");
6205+ var params = "";
6206+ var p = macro.indexOf(" ");
6207+ if(p != -1) {
6208+ params = macro.substr(p+1);
6209+ macro = macro.substr(0,p);
6210+ }
6211+ invokeMacro(e,macro,params,null,tiddler);
6212+ }
6213+ }
6214+ if(e.hasChildNodes())
6215+ applyHtmlMacros(e,tiddler);
6216+ e = nextChild;
6217+ }
6218+}
6219+
6220+function refreshPageTemplate(title)
6221+{
6222+ var stash = jQuery("<div/>").appendTo("body").hide()[0];
6223+ var display = story.getContainer();
6224+ var nodes,t;
6225+ if(display) {
6226+ nodes = display.childNodes;
6227+ for(t=nodes.length-1; t>=0; t--)
6228+ stash.appendChild(nodes[t]);
6229+ }
6230+ var wrapper = document.getElementById("contentWrapper");
6231+
6232+ if(!title || !store.isAvailable(title))
6233+ title = config.refresherData.pageTemplate;
6234+ if(!store.isAvailable(title))
6235+ title = config.refresherData.defaultPageTemplate; //# this one is always avaialable
6236+ wrapper.innerHTML = store.getRecursiveTiddlerText(title,null,10);
6237+ applyHtmlMacros(wrapper);
6238+ refreshElements(wrapper);
6239+ display = story.getContainer();
6240+ jQuery(display).empty();
6241+ if(!display)
6242+ display = createTiddlyElement(wrapper,"div",story.containerId());
6243+ nodes = stash.childNodes;
6244+ for(t=nodes.length-1; t>=0; t--)
6245+ display.appendChild(nodes[t]);
6246+ jQuery(stash).remove();
6247+}
6248+
6249+function refreshDisplay(hint)
6250+{
6251+ if(typeof hint == "string")
6252+ hint = [hint];
6253+ var e = document.getElementById("contentWrapper");
6254+ refreshElements(e,hint);
6255+ if(backstage.isPanelVisible()) {
6256+ e = document.getElementById("backstage");
6257+ refreshElements(e,hint);
6258+ }
6259+}
6260+
6261+function refreshPageTitle()
6262+{
6263+ document.title = getPageTitle();
6264+}
6265+
6266+function getPageTitle()
6267+{
6268+ return wikifyPlainText(store.getTiddlerText("WindowTitle",""),null,tiddler);
6269+}
6270+
6271+function refreshStyles(title,doc)
6272+{
6273+ setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title,doc || document);
6274+}
6275+
6276+function refreshColorPalette(title)
6277+{
6278+ if(!startingUp)
6279+ refreshAll();
6280+}
6281+
6282+function refreshAll()
6283+{
6284+ refreshPageTemplate();
6285+ refreshDisplay();
6286+ refreshStyles("StyleSheetLayout");
6287+ refreshStyles("StyleSheetColors");
6288+ refreshStyles(config.refresherData.styleSheet);
6289+ refreshStyles("StyleSheetPrint");
6290+}
6291+
6292+//--
6293+//-- Option handling
6294+//--
6295+
6296+config.optionHandlers = {
6297+ 'txt': {
6298+ get: function(name) {return encodeCookie(config.options[name].toString());},
6299+ set: function(name,value) {config.options[name] = decodeCookie(value);}
6300+ },
6301+ 'chk': {
6302+ get: function(name) {return config.options[name] ? 'true' : 'false';},
6303+ set: function(name,value) {config.options[name] = value == 'true';}
6304+ }
6305+};
6306+
6307+function setOption(name,value)
6308+{
6309+ var optType = name.substr(0,3);
6310+ if(config.optionHandlers[optType] && config.optionHandlers[optType].set)
6311+ config.optionHandlers[optType].set(name,value);
6312+}
6313+
6314+// Gets the value of an option as a string. Most code should just read from config.options.* directly
6315+function getOption(name)
6316+{
6317+ var optType = name.substr(0,3);
6318+ return config.optionHandlers[optType] && config.optionHandlers[optType].get ? config.optionHandlers[optType].get(name) : null;
6319+}
6320+
6321+function loadOptions()
6322+{
6323+ if(safeMode)
6324+ return;
6325+ loadCookies();
6326+ loadSystemSettings();
6327+}
6328+// @Deprecated; retained for backwards compatibility
6329+var loadOptionsCookie = loadOptions;
6330+
6331+function getCookies()
6332+{
6333+ var cookieList = document.cookie.split(';');
6334+ var i,cookies = {};
6335+ for(i=0; i<cookieList.length; i++) {
6336+ var p = cookieList[i].indexOf('=');
6337+ if(p != -1) {
6338+ var name = cookieList[i].substr(0,p).trim();
6339+ var value = cookieList[i].substr(p+1).trim();
6340+ cookies[name] = value;
6341+ }
6342+ }
6343+ return cookies;
6344+}
6345+
6346+function loadCookies()
6347+{
6348+ var i,cookies = getCookies();
6349+ if(cookies['TiddlyWiki']) {
6350+ cookies = cookies['TiddlyWiki'].decodeHashMap();
6351+ }
6352+ for(i in cookies) {
6353+ if(config.optionsSource[i] != 'setting') {
6354+ setOption(i,cookies[i]);
6355+ }
6356+ }
6357+}
6358+
6359+function loadSystemSettings()
6360+{
6361+ var key,settings = store.calcAllSlices('SystemSettings');
6362+ config.optionsSource = {};
6363+ for(key in settings) {
6364+ setOption(key,settings[key]);
6365+ config.optionsSource[key] = 'setting';
6366+ }
6367+}
6368+
6369+function onSystemSettingsChange()
6370+{
6371+ if(!startingUp) {
6372+ loadSystemSettings();
6373+ }
6374+}
6375+
6376+function saveOption(name)
6377+{
6378+ if(safeMode)
6379+ return;
6380+ if(name.match(/[()\s]/g, '_')) {
6381+ alert(config.messages.invalidCookie.format([name]));
6382+ return;
6383+ }
6384+ saveCookie(name);
6385+ if(config.optionsSource[name] == 'setting') {
6386+ saveSystemSetting(name,true);
6387+ }
6388+}
6389+// @Deprecated; retained for backwards compatibility
6390+var saveOptionCookie = saveOption;
6391+
6392+function removeCookie(name)
6393+{
6394+ document.cookie = name + '=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;';
6395+}
6396+
6397+function saveCookie(name)
6398+{
6399+ var key,cookies = {};
6400+ for(key in config.options) {
6401+ var value = getOption(key);
6402+ value = value == null ? 'false' : value;
6403+ cookies[key] = value;
6404+ }
6405+ document.cookie = 'TiddlyWiki=' + String.encodeHashMap(cookies) + '; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/';
6406+ cookies = getCookies();
6407+ var c;
6408+ for(c in cookies) {
6409+ var optType = c.substr(0,3);
6410+ if(config.optionHandlers[optType])
6411+ removeCookie(c);
6412+ }
6413+}
6414+
6415+var systemSettingSave;
6416+function commitSystemSettings(storeWasDirty)
6417+{
6418+ if(systemSettingSave) {
6419+ window.clearTimeout(systemSettingSave);
6420+ }
6421+ systemSettingSave = window.setTimeout(function() {
6422+ var tiddler = store.getTiddler('SystemSettings');
6423+ autoSaveChanges(null,[tiddler]);
6424+ }, 1000);
6425+}
6426+
6427+function saveSystemSetting(name,saveFile)
6428+{
6429+ var title = 'SystemSettings';
6430+ var slice = store.getTiddlerSlice(title,name);
6431+ if(readOnly || slice === getOption(name)) {
6432+ return; //# don't save if read-only or the option hasn't changed
6433+ }
6434+ var slices = store.calcAllSlices(title);
6435+ var key;
6436+ for(key in config.optionsSource) {
6437+ var value = getOption(key) || '';
6438+ if(slices[key] !== value) {
6439+ slices[key] = value;
6440+ }
6441+ }
6442+ var text = [];
6443+ for(key in slices) {
6444+ text.push('%0: %1'.format([key,slices[key]]));
6445+ }
6446+ text = text.sort().join('\n');
6447+ var storeWasDirty = store.isDirty();
6448+ var tiddler = store.getTiddler(title);
6449+ if(tiddler) {
6450+ tiddler.text = text;
6451+ tiddler = store.saveTiddler(tiddler);
6452+ } else {
6453+ tiddler = store.saveTiddler(title,title,text,'System',new Date(),['excludeLists'],config.defaultCustomFields);
6454+ }
6455+ if(saveFile) {
6456+ commitSystemSettings(storeWasDirty);
6457+ }
6458+}
6459+
6460+function encodeCookie(s)
6461+{
6462+ return escape(convertUnicodeToHtmlEntities(s));
6463+}
6464+
6465+function decodeCookie(s)
6466+{
6467+ s = unescape(s);
6468+ var re = /&#[0-9]{1,5};/g;
6469+ return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,'')));});
6470+}
6471+
6472+config.macros.option.genericCreate = function(place,type,opt,className,desc)
6473+{
6474+ var typeInfo = config.macros.option.types[type];
6475+ var c = document.createElement(typeInfo.elementType);
6476+ if(typeInfo.typeValue)
6477+ c.setAttribute('type',typeInfo.typeValue);
6478+ c[typeInfo.eventName] = typeInfo.onChange;
6479+ c.setAttribute('option',opt);
6480+ c.className = className || typeInfo.className;
6481+ if(config.optionsDesc[opt])
6482+ c.setAttribute('title',config.optionsDesc[opt]);
6483+ place.appendChild(c);
6484+ if(desc != 'no')
6485+ createTiddlyText(place,config.optionsDesc[opt] || opt);
6486+ c[typeInfo.valueField] = config.options[opt];
6487+ return c;
6488+};
6489+
6490+config.macros.option.genericOnChange = function(e)
6491+{
6492+ var opt = this.getAttribute('option');
6493+ if(opt) {
6494+ var optType = opt.substr(0,3);
6495+ var handler = config.macros.option.types[optType];
6496+ if(handler.elementType && handler.valueField)
6497+ config.macros.option.propagateOption(opt,handler.valueField,this[handler.valueField],handler.elementType,this);
6498+ }
6499+ return true;
6500+};
6501+
6502+config.macros.option.types = {
6503+ 'txt': {
6504+ elementType: 'input',
6505+ valueField: 'value',
6506+ eventName: 'onchange',
6507+ className: 'txtOptionInput',
6508+ create: config.macros.option.genericCreate,
6509+ onChange: config.macros.option.genericOnChange
6510+ },
6511+ 'chk': {
6512+ elementType: 'input',
6513+ valueField: 'checked',
6514+ eventName: 'onclick',
6515+ className: 'chkOptionInput',
6516+ typeValue: 'checkbox',
6517+ create: config.macros.option.genericCreate,
6518+ onChange: config.macros.option.genericOnChange
6519+ }
6520+};
6521+
6522+config.macros.option.propagateOption = function(opt,valueField,value,elementType,elem)
6523+{
6524+ config.options[opt] = value;
6525+ saveOption(opt);
6526+ var t,nodes = document.getElementsByTagName(elementType);
6527+ for(t=0; t<nodes.length; t++) {
6528+ var optNode = nodes[t].getAttribute('option');
6529+ if(opt == optNode && nodes[t]!=elem)
6530+ nodes[t][valueField] = value;
6531+ }
6532+};
6533+
6534+config.macros.option.handler = function(place,macroName,params,wikifier,paramString)
6535+{
6536+ params = paramString.parseParams('anon',null,true,false,false);
6537+ var opt = (params[1] && params[1].name == 'anon') ? params[1].value : getParam(params,'name',null);
6538+ var className = (params[2] && params[2].name == 'anon') ? params[2].value : getParam(params,'class',null);
6539+ var desc = getParam(params,'desc','no');
6540+ var type = opt.substr(0,3);
6541+ var h = config.macros.option.types[type];
6542+ if(h && h.create)
6543+ h.create(place,type,opt,className,desc);
6544+};
6545+
6546+config.macros.options.handler = function(place,macroName,params,wikifier,paramString)
6547+{
6548+ params = paramString.parseParams('anon',null,true,false,false);
6549+ var showUnknown = getParam(params,'showUnknown','no');
6550+ var wizard = new Wizard();
6551+ wizard.createWizard(place,this.wizardTitle);
6552+ wizard.addStep(this.step1Title,this.step1Html);
6553+ var markList = wizard.getElement('markList');
6554+ var chkUnknown = wizard.getElement('chkUnknown');
6555+ chkUnknown.checked = showUnknown == 'yes';
6556+ chkUnknown.onchange = this.onChangeUnknown;
6557+ var listWrapper = document.createElement('div');
6558+ markList.parentNode.insertBefore(listWrapper,markList);
6559+ wizard.setValue('listWrapper',listWrapper);
6560+ this.refreshOptions(listWrapper,showUnknown == 'yes');
6561+};
6562+
6563+config.macros.options.refreshOptions = function(listWrapper,showUnknown)
6564+{
6565+ var n,opts = [];
6566+ for(n in config.options) {
6567+ var opt = {};
6568+ opt.option = '';
6569+ opt.name = n;
6570+ opt.lowlight = !config.optionsDesc[n];
6571+ opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
6572+ if(!opt.lowlight || showUnknown)
6573+ opts.push(opt);
6574+ }
6575+ 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);});
6576+ ListView.create(listWrapper,opts,this.listViewTemplate);
6577+ for(n=0; n<opts.length; n++) {
6578+ var type = opts[n].name.substr(0,3);
6579+ var h = config.macros.option.types[type];
6580+ if(h && h.create) {
6581+ h.create(opts[n].colElements['option'],type,opts[n].name,null,'no');
6582+ }
6583+ }
6584+};
6585+
6586+config.macros.options.onChangeUnknown = function(e)
6587+{
6588+ var wizard = new Wizard(this);
6589+ var listWrapper = wizard.getValue('listWrapper');
6590+ jQuery(listWrapper).empty();
6591+ config.macros.options.refreshOptions(listWrapper,this.checked);
6592+ return false;
6593+};
6594+
6595+//--
6596+//-- Saving
6597+//--
6598+
6599+var saveUsingSafari = false;
6600+
6601+var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it
6602+var startSaveAreaRE = /<((div)|(DIV)) ((id)|(ID))=["']?storeArea['"]?>/; // Used for IE6
6603+var endSaveArea = '</d' + 'iv>';
6604+var endSaveAreaCaps = '</D' + 'IV>';
6605+
6606+// If there are unsaved changes, force the user to confirm before exitting
6607+function confirmExit()
6608+{
6609+ hadConfirmExit = true;
6610+ if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty()))
6611+ return config.messages.confirmExit;
6612+}
6613+
6614+// Give the user a chance to save changes before exitting
6615+function checkUnsavedChanges()
6616+{
6617+ if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false) {
6618+ if(confirm(config.messages.unsavedChangesWarning))
6619+ saveChanges();
6620+ }
6621+}
6622+
6623+function updateLanguageAttribute(s)
6624+{
6625+ if(config.locale) {
6626+ var mRE = /(<html(?:.*?)?)(?: xml:lang\="([a-z]+)")?(?: lang\="([a-z]+)")?>/;
6627+ var m = mRE.exec(s);
6628+ if(m) {
6629+ var t = m[1];
6630+ if(m[2])
6631+ t += ' xml:lang="' + config.locale + '"';
6632+ if(m[3])
6633+ t += ' lang="' + config.locale + '"';
6634+ t += ">";
6635+ s = s.substr(0,m.index) + t + s.substr(m.index+m[0].length);
6636+ }
6637+ }
6638+ return s;
6639+}
6640+
6641+function updateMarkupBlock(s,blockName,tiddlerName)
6642+{
6643+ return s.replaceChunk(
6644+ "<!--%0-START-->".format([blockName]),
6645+ "<!--%0-END-->".format([blockName]),
6646+ "\n" + convertUnicodeToFileFormat(store.getRecursiveTiddlerText(tiddlerName,"")) + "\n");
6647+}
6648+
6649+function updateOriginal(original,posDiv,localPath)
6650+{
6651+ if(!posDiv)
6652+ posDiv = locateStoreArea(original);
6653+ if(!posDiv) {
6654+ alert(config.messages.invalidFileError.format([localPath]));
6655+ return null;
6656+ }
6657+ var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
6658+ convertUnicodeToFileFormat(store.allTiddlersAsHtml()) + "\n" +
6659+ original.substr(posDiv[1]);
6660+ var newSiteTitle = convertUnicodeToFileFormat(getPageTitle()).htmlEncode();
6661+ revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
6662+ revised = updateLanguageAttribute(revised);
6663+ revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
6664+ revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
6665+ revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
6666+ revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
6667+ return revised;
6668+}
6669+
6670+function locateStoreArea(original)
6671+{
6672+ // Locate the storeArea divs
6673+ if(!original)
6674+ return null;
6675+ var posOpeningDiv = original.search(startSaveAreaRE);
6676+ var limitClosingDiv = original.indexOf("<"+"!--POST-STOREAREA--"+">");
6677+ if(limitClosingDiv == -1)
6678+ limitClosingDiv = original.indexOf("<"+"!--POST-BODY-START--"+">");
6679+ var start = limitClosingDiv == -1 ? original.length : limitClosingDiv;
6680+ var posClosingDiv = original.lastIndexOf(endSaveArea,start);
6681+ if(posClosingDiv == -1)
6682+ posClosingDiv = original.lastIndexOf(endSaveAreaCaps,start);
6683+ return (posOpeningDiv != -1 && posClosingDiv != -1) ? [posOpeningDiv,posClosingDiv] : null;
6684+}
6685+
6686+function autoSaveChanges(onlyIfDirty,tiddlers)
6687+{
6688+ if(config.options.chkAutoSave)
6689+ saveChanges(onlyIfDirty,tiddlers);
6690+}
6691+
6692+function loadOriginal(localPath)
6693+{
6694+ var content=loadFile(localPath);
6695+ if (!content) content=window.originalHTML||recreateOriginal();
6696+ return content;
6697+}
6698+
6699+function recreateOriginal()
6700+{
6701+ // construct doctype
6702+ var content = "<!DOCTYPE ";
6703+ var t=document.doctype;
6704+ if (!t)
6705+ content+="html"
6706+ else {
6707+ content+=t.name;
6708+ if (t.publicId) content+=' PUBLIC "'+t.publicId+'"';
6709+ else if (t.systemId) content+=' SYSTEM "'+t.systemId+'"';
6710+ }
6711+ content+=' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"';
6712+ content+='>\n';
6713+
6714+ // append current document content
6715+ content+=document.documentElement.outerHTML;
6716+
6717+ content=content.replace(/<div id="saveTest">savetest<\/div>/,'<div id="saveTest"></div>');
6718+ content=content.replace(/script><applet [^\>]*><\/applet>/g,'script>');
6719+ content=content.replace(/><head>/,'>\n<head>');
6720+ content=content.replace(/\n\n<\/body><\/html>$/,'</body>\n</html>\n');
6721+ content=content.replace(/(<(meta) [^\>]*[^\/])>/g,'$1 />');
6722+ content=content.replace(/<noscript>[^\<]*<\/noscript>/,
6723+ function(m){return m.replace(/&lt;/g,'<').replace(/&gt;/g,'>');});
6724+ content=content.replace(/<div id="copyright">[^\<]*<\/div>/,
6725+ function(m){return m.replace(/\xA9/g,'&copy;');});
6726+
6727+ return content;
6728+}
6729+
6730+// Save this tiddlywiki with the pending changes
6731+function saveChanges(onlyIfDirty,tiddlers)
6732+{
6733+ if(onlyIfDirty && !store.isDirty())
6734+ return;
6735+ clearMessage();
6736+ var t0 = new Date();
6737+ var msg = config.messages;
6738+ var originalPath = document.location.toString();
6739+ if(!window.allowSave()) {
6740+ alert(msg.notFileUrlError);
6741+ if(store.tiddlerExists(msg.saveInstructions))
6742+ story.displayTiddler(null,msg.saveInstructions);
6743+ return;
6744+ }
6745+ var localPath = getLocalPath(originalPath);
6746+ var original = loadOriginal(localPath);
6747+ if(original == null) {
6748+ alert(msg.cantSaveError);
6749+ if(store.tiddlerExists(msg.saveInstructions))
6750+ story.displayTiddler(null,msg.saveInstructions);
6751+ return;
6752+ }
6753+ var posDiv = locateStoreArea(original);
6754+ if(!posDiv) {
6755+ alert(msg.invalidFileError.format([localPath]));
6756+ return;
6757+ }
6758+ var co=config.options; //# abbreviation
6759+ config.saveByDownload=false;
6760+ config.saveByManualDownload=false;
6761+ saveMain(localPath,original,posDiv);
6762+ if (!config.saveByDownload && !config.saveByManualDownload) {
6763+ if(co.chkSaveBackups)
6764+ saveBackup(localPath,original);
6765+ if(co.chkSaveEmptyTemplate)
6766+ saveEmpty(localPath,original,posDiv);
6767+ if(co.chkGenerateAnRssFeed && saveRss instanceof Function)
6768+ saveRss(localPath);
6769+ }
6770+ if(co.chkDisplayInstrumentation)
6771+ displayMessage("saveChanges " + (new Date()-t0) + " ms");
6772+}
6773+
6774+
6775+function saveMain(localPath,original,posDiv)
6776+{
6777+ var save;
6778+ try {
6779+ var revised = updateOriginal(original,posDiv,localPath);
6780+ save = saveFile(localPath,revised);
6781+ } catch (ex) {
6782+ showException(ex);
6783+ }
6784+ if(save) {
6785+ if (!config.saveByManualDownload) {
6786+ if (config.saveByDownload) { //# set by HTML5DownloadSaveFile()
6787+ var link = getDataURI(revised);
6788+ var msg = config.messages.mainDownload;
6789+ } else {
6790+ var link = "file://" + localPath;
6791+ var msg = config.messages.mainSaved;
6792+ }
6793+ displayMessage(msg,link);
6794+ }
6795+ store.setDirty(false);
6796+ } else {
6797+ alert(config.messages.mainFailed);
6798+ }
6799+}
6800+
6801+function saveBackup(localPath,original)
6802+{
6803+ var backupPath = getBackupPath(localPath);
6804+ var backup = copyFile(backupPath,localPath);
6805+ if(!backup)
6806+ backup = saveFile(backupPath,original);
6807+ if(backup)
6808+ displayMessage(config.messages.backupSaved,"file://" + backupPath);
6809+ else
6810+ alert(config.messages.backupFailed);
6811+}
6812+
6813+function saveEmpty(localPath,original,posDiv)
6814+{
6815+ var emptyPath,p;
6816+ if((p = localPath.lastIndexOf("/")) != -1)
6817+ emptyPath = localPath.substr(0,p) + "/";
6818+ else if((p = localPath.lastIndexOf("\\")) != -1)
6819+ emptyPath = localPath.substr(0,p) + "\\";
6820+ else
6821+ emptyPath = localPath + ".";
6822+ emptyPath += "empty.html";
6823+ var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]);
6824+ var emptySave = saveFile(emptyPath,empty);
6825+ if(emptySave)
6826+ displayMessage(config.messages.emptySaved,"file://" + emptyPath);
6827+ else
6828+ alert(config.messages.emptyFailed);
6829+}
6830+
6831+// Translate URL to local path [Preemption]
6832+window.getLocalPath = window.getLocalPath || function(origPath)
6833+{
6834+ var originalPath = convertUriToUTF8(origPath,config.options.txtFileSystemCharSet);
6835+ // Remove any location or query part of the URL
6836+ var argPos = originalPath.indexOf("?");
6837+ if(argPos != -1)
6838+ originalPath = originalPath.substr(0,argPos);
6839+ var hashPos = originalPath.indexOf("#");
6840+ if(hashPos != -1)
6841+ originalPath = originalPath.substr(0,hashPos);
6842+ // Convert file://localhost/ to file:///
6843+ if(originalPath.indexOf("file://localhost/") == 0)
6844+ originalPath = "file://" + originalPath.substr(16);
6845+ // Convert to a native file format
6846+ var localPath;
6847+ if(originalPath.charAt(9) == ":") // pc local file
6848+ localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
6849+ else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
6850+ localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
6851+ else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
6852+ localPath = unescape(originalPath.substr(7));
6853+ else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
6854+ localPath = unescape(originalPath.substr(5));
6855+ else // pc network file
6856+ localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
6857+ return localPath;
6858+}
6859+
6860+function getBackupPath(localPath,title,extension)
6861+{
6862+ var slash = "\\";
6863+ var dirPathPos = localPath.lastIndexOf("\\");
6864+ if(dirPathPos == -1) {
6865+ dirPathPos = localPath.lastIndexOf("/");
6866+ slash = "/";
6867+ }
6868+ var backupFolder = config.options.txtBackupFolder;
6869+ if(!backupFolder || backupFolder == "")
6870+ backupFolder = ".";
6871+ var backupPath = localPath.substr(0,dirPathPos) + slash + backupFolder + localPath.substr(dirPathPos);
6872+ backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + ".";
6873+ if(title)
6874+ backupPath += title.replace(/[\\\/\*\?\":<> ]/g,"_") + ".";
6875+ backupPath += (new Date()).convertToYYYYMMDDHHMMSSMMM() + "." + (extension || "html");
6876+ return backupPath;
6877+}
6878+
6879+//--
6880+//-- RSS Saving
6881+//--
6882+
6883+function saveRss(localPath)
6884+{
6885+ var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
6886+ if(saveFile(rssPath,convertUnicodeToFileFormat(generateRss())))
6887+ displayMessage(config.messages.rssSaved,"file://" + rssPath);
6888+ else
6889+ alert(config.messages.rssFailed);
6890+}
6891+
6892+tiddlerToRssItem = function(tiddler,uri)
6893+{
6894+ var s = "<title" + ">" + tiddler.title.htmlEncode() + "</title" + ">\n";
6895+ s += "<description>" + wikifyStatic(tiddler.text,null,tiddler).htmlEncode() + "</description>\n";
6896+ var i;
6897+ for(i=0; i<tiddler.tags.length; i++)
6898+ s += "<category>" + tiddler.tags[i] + "</category>\n";
6899+ s += "<link>" + uri + "#" + encodeURIComponent(String.encodeTiddlyLink(tiddler.title)) + "</link>\n";
6900+ s +="<pubDate>" + tiddler.modified.toGMTString() + "</pubDate>\n";
6901+ return s;
6902+};
6903+
6904+function generateRss()
6905+{
6906+ var s = [];
6907+ var d = new Date();
6908+ var u = store.getTiddlerText("SiteUrl");
6909+ // Assemble the header
6910+ s.push("<" + "?xml version=\"1.0\"?" + ">");
6911+ s.push("<rss version=\"2.0\">");
6912+ s.push("<channel>");
6913+ s.push("<title" + ">" + wikifyPlainText(store.getTiddlerText("SiteTitle",""),null,tiddler).htmlEncode() + "</title" + ">");
6914+ if(u)
6915+ s.push("<link>" + u.htmlEncode() + "</link>");
6916+ s.push("<description>" + wikifyPlainText(store.getTiddlerText("SiteSubtitle",""),null,tiddler).htmlEncode() + "</description>");
6917+ s.push("<language>" + config.locale + "</language>");
6918+ s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
6919+ s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
6920+ s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
6921+ s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
6922+ s.push("<generator>TiddlyWiki " + formatVersion() + "</generator>");
6923+ // The body
6924+ var tiddlers = store.getTiddlers("modified","excludeLists");
6925+ var i,n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
6926+ for(i=tiddlers.length-1; i>=n; i--) {
6927+ s.push("<item>\n" + tiddlerToRssItem(tiddlers[i],u) + "\n</item>");
6928+ }
6929+ // And footer
6930+ s.push("</channel>");
6931+ s.push("</rss>");
6932+ // Save it all
6933+ return s.join("\n");
6934+}
6935+
6936+//--
6937+//-- Filesystem code
6938+//--
6939+
6940+// Copy a file in filesystem [Preemption]
6941+window.copyFile = window.copyFile || function(dest,source)
6942+{
6943+ return config.browser.isIE ? ieCopyFile(dest,source) : false;
6944+}
6945+
6946+
6947+// Save a file in filesystem [Preemption]
6948+window.saveFile = window.saveFile || function(fileUrl,content)
6949+{
6950+ var r = mozillaSaveFile(fileUrl,content);
6951+ if(!r)
6952+ r = ieSaveFile(fileUrl,content);
6953+ if(!r)
6954+ r = javaSaveFile(fileUrl,content);
6955+ if(!r)
6956+ r = HTML5DownloadSaveFile(fileUrl,content);
6957+ if(!r)
6958+ r = manualSaveFile(fileUrl,content);
6959+ return r;
6960+}
6961+
6962+// Load a file from filesystem [Preemption]
6963+window.loadFile = window.loadFile || function(fileUrl)
6964+{
6965+ var r = mozillaLoadFile(fileUrl);
6966+ if((r == null) || (r == false))
6967+ r = ieLoadFile(fileUrl);
6968+ if((r == null) || (r == false))
6969+ r = javaLoadFile(fileUrl);
6970+ return r;
6971+}
6972+
6973+function ieCreatePath(path)
6974+{
6975+ try {
6976+ var fso = new ActiveXObject("Scripting.FileSystemObject");
6977+ } catch(ex) {
6978+ return null;
6979+ }
6980+
6981+ var pos = path.lastIndexOf("\\");
6982+ if(pos==-1)
6983+ pos = path.lastIndexOf("/");
6984+ if(pos!=-1)
6985+ path = path.substring(0,pos+1);
6986+
6987+ var scan = [path];
6988+ var parent = fso.GetParentFolderName(path);
6989+ while(parent && !fso.FolderExists(parent)) {
6990+ scan.push(parent);
6991+ parent = fso.GetParentFolderName(parent);
6992+ }
6993+
6994+ for(i=scan.length-1;i>=0;i--) {
6995+ if(!fso.FolderExists(scan[i])) {
6996+ fso.CreateFolder(scan[i]);
6997+ }
6998+ }
6999+ return true;
7000+}
7001+
7002+// Returns null if it can't do it, false if there's an error, true if it saved OK
7003+function ieSaveFile(filePath,content)
7004+{
7005+ ieCreatePath(filePath);
7006+ try {
7007+ var fso = new ActiveXObject("Scripting.FileSystemObject");
7008+ } catch(ex) {
7009+ return null;
7010+ }
7011+ var file = fso.OpenTextFile(filePath,2,-1,0);
7012+ file.Write(content);
7013+ file.Close();
7014+ return true;
7015+}
7016+
7017+// Returns null if it can't do it, false if there's an error, or a string of the content if successful
7018+function ieLoadFile(filePath)
7019+{
7020+ try {
7021+ var fso = new ActiveXObject("Scripting.FileSystemObject");
7022+ var file = fso.OpenTextFile(filePath,1);
7023+ var content = file.ReadAll();
7024+ file.Close();
7025+ } catch(ex) {
7026+ return null;
7027+ }
7028+ return content;
7029+}
7030+
7031+function ieCopyFile(dest,source)
7032+{
7033+ ieCreatePath(dest);
7034+ try {
7035+ var fso = new ActiveXObject("Scripting.FileSystemObject");
7036+ fso.GetFile(source).Copy(dest);
7037+ } catch(ex) {
7038+ return false;
7039+ }
7040+ return true;
7041+}
7042+
7043+// Returns null if it can't do it, false if there's an error, true if it saved OK
7044+function mozillaSaveFile(filePath,content)
7045+{
7046+ if(window.Components) {
7047+ try {
7048+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7049+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
7050+ file.initWithPath(filePath);
7051+ if(!file.exists())
7052+ file.create(0,0x01B4);// 0x01B4 = 0664
7053+ var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
7054+ out.init(file,0x22,0x04,null);
7055+ out.write(content,content.length);
7056+ out.flush();
7057+ out.close();
7058+ return true;
7059+ } catch(ex) {
7060+ return false;
7061+ }
7062+ }
7063+ return null;
7064+}
7065+
7066+// Returns null if it can't do it, false if there's an error, or a string of the content if successful
7067+function mozillaLoadFile(filePath)
7068+{
7069+ if(window.Components) {
7070+ try {
7071+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7072+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
7073+ file.initWithPath(filePath);
7074+ if(!file.exists())
7075+ return null;
7076+ var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
7077+ inputStream.init(file,0x01,0x04,null);
7078+ var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
7079+ sInputStream.init(inputStream);
7080+ var contents = sInputStream.read(sInputStream.available());
7081+ sInputStream.close();
7082+ inputStream.close();
7083+ return contents;
7084+ } catch(ex) {
7085+ return false;
7086+ }
7087+ }
7088+ return null;
7089+}
7090+
7091+function javaUrlToFilename(url)
7092+{
7093+ var f = "//localhost";
7094+ if(url.indexOf(f) == 0)
7095+ return url.substring(f.length);
7096+ var i = url.indexOf(":");
7097+ return i > 0 ? url.substring(i-1) : url;
7098+}
7099+
7100+/*
7101+ *
7102+ * in between when the applet has been started
7103+ * and the user has given permission to run the applet
7104+ * we get an applet object, but it doesn't have the methods
7105+ * we expect yet.
7106+ *
7107+ */
7108+var LOG_TIDDLYSAVER = true;
7109+function logTiddlySaverException(msg, ex) {
7110+ var applet = document.applets['TiddlySaver'];
7111+ console.log(msg + ": " + ex);
7112+ if (LOG_TIDDLYSAVER && applet) {
7113+ try {
7114+ console.log(msg + ": " + applet.getLastErrorMsg());
7115+ console.log(msg + ": " + applet.getLastErrorStackTrace());
7116+ } catch (ex) {}
7117+ }
7118+}
7119+
7120+function javaDebugInformation () {
7121+ var applet = document.applets['TiddlySaver'];
7122+ var what = [
7123+ ["Java Version", applet.getJavaVersion],
7124+ ["Last Exception", applet.getLastErrorMessage],
7125+ ["Last Exception Stack Trace", applet.getLastErrorStackTrace],
7126+ ["System Properties", applet.getSystemProperties] ];
7127+
7128+ function formatItem (description, method) {
7129+ try {
7130+ result = String(method.call(applet));
7131+ } catch (ex) {
7132+ result = String(ex)
7133+ }
7134+ return description + ": " + result
7135+ }
7136+
7137+ return jQuery.map(what, function (item) { return formatItem.apply(this, item) })
7138+ .join('\n\n')
7139+}
7140+
7141+function javaSaveFile(filePath,content)
7142+{
7143+ var applet = document.applets['TiddlySaver'];
7144+ try {
7145+ if (applet && filePath)
7146+ return applet.saveFile(javaUrlToFilename(filePath), "UTF-8", content);
7147+ } catch(ex) {
7148+ logTiddlySaverException("javaSaveFile", ex);
7149+ }
7150+ // is this next block working anywhere ? -- grmble
7151+ try {
7152+ var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath)));
7153+ s.print(content);
7154+ s.close();
7155+ } catch(ex2) {
7156+ return null;
7157+ }
7158+ return true;
7159+}
7160+
7161+function javaLoadFile(filePath)
7162+{
7163+ var applet = document.applets['TiddlySaver'];
7164+ try {
7165+ if (applet && filePath) {
7166+ var ret = applet.loadFile(javaUrlToFilename(filePath),"UTF-8");
7167+ if(!ret)
7168+ return null;
7169+ return String(ret);
7170+ }
7171+ } catch(ex) {
7172+ logTiddlySaverException("javaLoadFile", ex);
7173+ }
7174+ // is this next block working anywhere ? -- grmble
7175+ var content = [];
7176+ try {
7177+ var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath)));
7178+ var line;
7179+ while((line = r.readLine()) != null)
7180+ content.push(String(line));
7181+ r.close();
7182+ } catch(ex2) {
7183+ return null;
7184+ }
7185+ return content.join("\n");
7186+}
7187+
7188+function HTML5DownloadSaveFile(filePath,content)
7189+{
7190+ if(document.createElement("a").download !== undefined) {
7191+ config.saveByDownload=true;
7192+ var slashpos=filePath.lastIndexOf("/");
7193+ if (slashpos==-1) slashpos=filePath.lastIndexOf("\\");
7194+ var filename=filePath.substr(slashpos+1);
7195+ var uri = getDataURI(content);
7196+ var link = document.createElement("a");
7197+ link.setAttribute("target","_blank");
7198+ link.setAttribute("href",uri);
7199+ link.setAttribute("download",filename);
7200+ document.body.appendChild(link); link.click(); document.body.removeChild(link);
7201+ return true;
7202+ }
7203+ return null;
7204+}
7205+
7206+// Returns null if it can't do it, false if there's an error, true if it saved OK
7207+function manualSaveFile(filePath,content)
7208+{
7209+ // FALLBACK for showing a link to data: URI
7210+ config.saveByManualDownload=true;
7211+ var slashpos=filePath.lastIndexOf("/");
7212+ if (slashpos==-1) slashpos=filePath.lastIndexOf("\\");
7213+ var filename=filePath.substr(slashpos+1);
7214+ var uri = getDataURI(content);
7215+ displayMessage(config.messages.mainDownloadManual,uri);
7216+ return true;
7217+}
7218+
7219+// construct data URI (using base64 encoding to preserve multi-byte encodings)
7220+function getDataURI(data) {
7221+ if (config.browser.isIE)
7222+ return "data:text/html,"+encodeURIComponent(data);
7223+ else
7224+ return "data:text/html;base64,"+encodeBase64(data);
7225+}
7226+
7227+function encodeBase64(data) {
7228+ if (!data) return "";
7229+ var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
7230+ var out = "";
7231+ var chr1,chr2,chr3="";
7232+ var enc1,enc2,enc3,enc4="";
7233+ for (var count=0,i=0; i<data.length; ) {
7234+ chr1=data.charCodeAt(i++);
7235+ chr2=data.charCodeAt(i++);
7236+ chr3=data.charCodeAt(i++);
7237+ enc1=chr1 >> 2;
7238+ enc2=((chr1 & 3) << 4) | (chr2 >> 4);
7239+ enc3=((chr2 & 15) << 2) | (chr3 >> 6);
7240+ enc4=chr3 & 63;
7241+ if (isNaN(chr2)) enc3=enc4=64;
7242+ else if (isNaN(chr3)) enc4=64;
7243+ out+=keyStr.charAt(enc1)+keyStr.charAt(enc2)+keyStr.charAt(enc3)+keyStr.charAt(enc4);
7244+ chr1=chr2=chr3=enc1=enc2=enc3=enc4="";
7245+ }
7246+ return out;
7247+}//--
7248+//-- Filesystem utilities
7249+//--
7250+
7251+function convertUTF8ToUnicode(u)
7252+{
7253+ return config.browser.isOpera || !window.netscape ? manualConvertUTF8ToUnicode(u) : mozConvertUTF8ToUnicode(u);
7254+}
7255+
7256+
7257+function manualConvertUTF8ToUnicode(utf)
7258+{
7259+ var uni = utf;
7260+ var src = 0;
7261+ var dst = 0;
7262+ var b1, b2, b3;
7263+ var c;
7264+ while(src < utf.length) {
7265+ b1 = utf.charCodeAt(src++);
7266+ if(b1 < 0x80) {
7267+ dst++;
7268+ } else if(b1 < 0xE0) {
7269+ b2 = utf.charCodeAt(src++);
7270+ c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F));
7271+ uni = uni.substring(0,dst++).concat(c,utf.substr(src));
7272+ } else {
7273+ b2 = utf.charCodeAt(src++);
7274+ b3 = utf.charCodeAt(src++);
7275+ c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F));
7276+ uni = uni.substring(0,dst++).concat(c,utf.substr(src));
7277+ }
7278+ }
7279+ return uni;
7280+}
7281+
7282+function mozConvertUTF8ToUnicode(u)
7283+{
7284+ try {
7285+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7286+ var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
7287+ converter.charset = "UTF-8";
7288+ } catch(ex) {
7289+ return manualConvertUTF8ToUnicode(u);
7290+ } // fallback
7291+ var s = converter.ConvertToUnicode(u);
7292+ var fin = converter.Finish();
7293+ return fin.length > 0 ? s+fin : s;
7294+}
7295+
7296+function convertUnicodeToFileFormat(s)
7297+{
7298+ return config.browser.isOpera || !window.netscape ? (config.browser.isIE ? convertUnicodeToHtmlEntities(s) : s) : mozConvertUnicodeToUTF8(s);
7299+}
7300+
7301+function convertUnicodeToHtmlEntities(s)
7302+{
7303+ var re = /[^\u0000-\u007F]/g;
7304+ return s.replace(re,function($0) {return "&#" + $0.charCodeAt(0).toString() + ";";});
7305+}
7306+
7307+function convertUnicodeToUTF8(s)
7308+{
7309+// return convertUnicodeToFileFormat to allow plugin migration
7310+ return convertUnicodeToFileFormat(s);
7311+}
7312+
7313+function manualConvertUnicodeToUTF8(s)
7314+{
7315+ return unescape(encodeURIComponent(s));
7316+}
7317+
7318+function mozConvertUnicodeToUTF8(s)
7319+{
7320+ try {
7321+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7322+ var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
7323+ converter.charset = "UTF-8";
7324+ } catch(ex) {
7325+ return manualConvertUnicodeToUTF8(s);
7326+ } // fallback
7327+ var u = converter.ConvertFromUnicode(s);
7328+ var fin = converter.Finish();
7329+ return fin.length > 0 ? u + fin : u;
7330+}
7331+
7332+function convertUriToUTF8(uri,charSet)
7333+{
7334+ if(window.netscape == undefined || charSet == undefined || charSet == "")
7335+ return uri;
7336+ try {
7337+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7338+ var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService);
7339+ } catch(ex) {
7340+ return uri;
7341+ }
7342+ return converter.convertURISpecToUTF8(uri,charSet);
7343+}
7344+//--
7345+//-- Server adaptor base class
7346+//--
7347+
7348+function AdaptorBase()
7349+{
7350+ this.host = null;
7351+ this.store = null;
7352+ return this;
7353+}
7354+
7355+AdaptorBase.prototype.close = function()
7356+{
7357+ return true;
7358+};
7359+
7360+AdaptorBase.prototype.fullHostName = function(host)
7361+{
7362+ if(!host)
7363+ return '';
7364+ host = host.trim();
7365+ if(!host.match(/:\/\//))
7366+ host = 'http://' + host;
7367+ if(host.substr(host.length-1) == '/')
7368+ host = host.substr(0,host.length-1);
7369+ return host;
7370+};
7371+
7372+AdaptorBase.minHostName = function(host)
7373+{
7374+ return host;
7375+};
7376+
7377+AdaptorBase.prototype.setContext = function(context,userParams,callback)
7378+{
7379+ if(!context) context = {};
7380+ context.userParams = userParams;
7381+ if(callback) context.callback = callback;
7382+ context.adaptor = this;
7383+ if(!context.host)
7384+ context.host = this.host;
7385+ context.host = this.fullHostName(context.host);
7386+ if(!context.workspace)
7387+ context.workspace = this.workspace;
7388+ return context;
7389+};
7390+
7391+// Open the specified host
7392+AdaptorBase.prototype.openHost = function(host,context,userParams,callback)
7393+{
7394+ this.host = host;
7395+ context = this.setContext(context,userParams,callback);
7396+ context.status = true;
7397+ if(callback)
7398+ window.setTimeout(function() {context.callback(context,userParams);},10);
7399+ return true;
7400+};
7401+
7402+// Open the specified workspace
7403+AdaptorBase.prototype.openWorkspace = function(workspace,context,userParams,callback)
7404+{
7405+ this.workspace = workspace;
7406+ context = this.setContext(context,userParams,callback);
7407+ context.status = true;
7408+ if(callback)
7409+ window.setTimeout(function() {callback(context,userParams);},10);
7410+ return true;
7411+};
7412+
7413+//--
7414+//-- Server adaptor for talking to static TiddlyWiki files
7415+//--
7416+
7417+function FileAdaptor()
7418+{
7419+}
7420+
7421+FileAdaptor.prototype = new AdaptorBase();
7422+
7423+FileAdaptor.serverType = 'file';
7424+FileAdaptor.serverLabel = 'TiddlyWiki';
7425+
7426+FileAdaptor.loadTiddlyWikiSuccess = function(context,jqXHR)
7427+{
7428+ context.status = true;
7429+ context.adaptor.store = new TiddlyWiki();
7430+ if(!context.adaptor.store.importTiddlyWiki(jqXHR.responseText)) {
7431+ context.statusText = config.messages.invalidFileError.format([context.host]);
7432+ context.status = false;
7433+ }
7434+ context.complete(context,context.userParams);
7435+};
7436+
7437+FileAdaptor.loadTiddlyWikiError = function(context,jqXHR)
7438+{
7439+ context.status = false;
7440+ context.statusText = jqXHR.message;
7441+ context.complete(context,context.userParams);
7442+};
7443+
7444+// Get the list of workspaces on a given server
7445+FileAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
7446+{
7447+ context = this.setContext(context,userParams,callback);
7448+ context.workspaces = [{title:"(default)"}];
7449+ context.status = true;
7450+ if(callback)
7451+ window.setTimeout(function() {callback(context,userParams);},10);
7452+ return true;
7453+};
7454+
7455+// Gets the list of tiddlers within a given workspace
7456+FileAdaptor.prototype.getTiddlerList = function(context,userParams,callback,filter)
7457+{
7458+ context = this.setContext(context,userParams,callback);
7459+ if(!context.filter)
7460+ context.filter = filter;
7461+ context.complete = FileAdaptor.getTiddlerListComplete;
7462+ if(this.store) {
7463+ return context.complete(context,context.userParams);
7464+ }
7465+ var options = {
7466+ type:"GET",
7467+ url:context.host,
7468+ file:context.file, // for HTML5 FileReader
7469+ processData:false,
7470+ success:function(data,textStatus,jqXHR) {
7471+ FileAdaptor.loadTiddlyWikiSuccess(context,jqXHR);
7472+ },
7473+ error:function(jqXHR,textStatus,errorThrown) {
7474+ context.xhr = jqXHR;
7475+ FileAdaptor.loadTiddlyWikiError(context,jqXHR);
7476+ }
7477+ };
7478+ return ajaxReq(options);
7479+};
7480+
7481+FileAdaptor.getTiddlerListComplete = function(context,userParams)
7482+{
7483+ if(context.status) {
7484+ if(context.filter) {
7485+ context.tiddlers = context.adaptor.store.filterTiddlers(context.filter);
7486+ } else {
7487+ context.tiddlers = [];
7488+ context.adaptor.store.forEachTiddler(function(title,tiddler) {context.tiddlers.push(tiddler);});
7489+ }
7490+ var i;
7491+ for(i=0; i<context.tiddlers.length; i++) {
7492+ context.tiddlers[i].fields['server.type'] = FileAdaptor.serverType;
7493+ context.tiddlers[i].fields['server.host'] = AdaptorBase.minHostName(context.host);
7494+ context.tiddlers[i].fields['server.page.revision'] = context.tiddlers[i].modified.convertToYYYYMMDDHHMM();
7495+ }
7496+ context.status = true;
7497+ }
7498+ if(context.callback) {
7499+ window.setTimeout(function() {context.callback(context,userParams);},10);
7500+ }
7501+ return true;
7502+};
7503+
7504+FileAdaptor.prototype.generateTiddlerInfo = function(tiddler)
7505+{
7506+ var info = {};
7507+ info.uri = tiddler.fields['server.host'] + "#" + tiddler.title;
7508+ return info;
7509+};
7510+
7511+// Retrieve a tiddler from a given workspace on a given server
7512+FileAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
7513+{
7514+ context = this.setContext(context,userParams,callback);
7515+ context.title = title;
7516+ context.complete = FileAdaptor.getTiddlerComplete;
7517+ if(context.adaptor.store) {
7518+ return context.complete(context,context.userParams);
7519+ }
7520+ var options = {
7521+ type:"GET",
7522+ url:context.host,
7523+ processData:false,
7524+ success:function(data,textStatus,jqXHR) {
7525+ FileAdaptor.loadTiddlyWikiSuccess(context,jqXHR);
7526+ },
7527+ error:function(jqXHR,textStatus,errorThrown) {
7528+ FileAdaptor.loadTiddlyWikiError(context,jqXHR);
7529+ }
7530+ };
7531+ return ajaxReq(options);
7532+};
7533+
7534+FileAdaptor.getTiddlerComplete = function(context,userParams)
7535+{
7536+ var t = context.adaptor.store.fetchTiddler(context.title);
7537+ if(t) {
7538+ t.fields['server.type'] = FileAdaptor.serverType;
7539+ t.fields['server.host'] = AdaptorBase.minHostName(context.host);
7540+ t.fields['server.page.revision'] = t.modified.convertToYYYYMMDDHHMM();
7541+ context.tiddler = t;
7542+ context.status = true;
7543+ } else { //# tiddler does not exist in document
7544+ context.status = false;
7545+ }
7546+ if(context.allowSynchronous) {
7547+ context.isSynchronous = true;
7548+ context.callback(context,userParams);
7549+ } else {
7550+ window.setTimeout(function() {context.callback(context,userParams);},10);
7551+ }
7552+ return true;
7553+};
7554+
7555+FileAdaptor.prototype.close = function()
7556+{
7557+ this.store = null;
7558+};
7559+
7560+config.adaptors[FileAdaptor.serverType] = FileAdaptor;
7561+
7562+config.defaultAdaptor = FileAdaptor.serverType;
7563+
7564+//--
7565+//-- HTTP request code
7566+//--
7567+
7568+function ajaxReq(args)
7569+{
7570+ if (args.file || args.url.startsWith("file")) // LOCAL FILE
7571+ return localAjax(args);
7572+ return jQuery.ajax(args);
7573+}
7574+
7575+function localAjax(args)
7576+{
7577+ var success=function(data)
7578+ { args.success(data,"success",{ responseText:data }); }
7579+ var failure=function(who)
7580+ { args.error({ message:who+": cannot read local file" },"error",0); }
7581+
7582+ if (args.file) try { // HTML5 FileReader (Chrome, FF20+, Safari, etc.)
7583+ var reader=new FileReader();
7584+ reader.onload=function(e) { success(e.target.result); }
7585+ reader.onerror=function(e) { failure("FileReader"); }
7586+ reader.readAsText(args.file);
7587+ return true;
7588+ } catch (ex) { ; }
7589+
7590+ try { // local file I/O (IE, FF with TiddlyFox, Chrome/Safari with TiddlySaver, etc.)
7591+ var data=loadFile(getLocalPath(args.url));
7592+ if (data) success(data);
7593+ else failure("loadFile");
7594+ return true;
7595+ } catch (ex) { ; }
7596+
7597+ return true;
7598+}
7599+
7600+function httpReq(type,url,callback,params,headers,data,contentType,username,password,allowCache)
7601+{
7602+ var httpSuccess = function(xhr) {
7603+ try {
7604+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
7605+ return (!xhr.status && location.protocol === "file:") ||
7606+ (xhr.status >= 200 && xhr.status < 300) ||
7607+ xhr.status === 304 || xhr.status === 1223;
7608+ } catch(e) {}
7609+ return false;
7610+ };
7611+
7612+ var options = {
7613+ type:type,
7614+ url:url,
7615+ processData:false,
7616+ data:data,
7617+ cache:!!allowCache,
7618+ beforeSend: function(xhr) {
7619+ var i;
7620+ for(i in headers)
7621+ xhr.setRequestHeader(i,headers[i]);
7622+ }
7623+ };
7624+
7625+ if(callback) {
7626+ options.complete = function(xhr,textStatus) {
7627+ if(httpSuccess(xhr))
7628+ callback(true,params,xhr.responseText,url,xhr);
7629+ else
7630+ callback(false,params,null,url,xhr);
7631+ };
7632+ }
7633+ if(contentType)
7634+ options.contentType = contentType;
7635+ if(username)
7636+ options.username = username;
7637+ if(password)
7638+ options.password = password;
7639+ try {
7640+ if(window.Components && window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1)
7641+ window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
7642+ } catch (ex) {
7643+ }
7644+ return jQuery.ajax(options);
7645+}
7646+//--
7647+//-- TiddlyWiki-specific utility functions
7648+//--
7649+
7650+// Returns TiddlyWiki version string
7651+function formatVersion(v)
7652+{
7653+ v = v || version;
7654+ return v.major + "." + v.minor + "." + v.revision +
7655+ (v.alpha ? " (alpha " + v.alpha + ")" : "") +
7656+ (v.beta ? " (beta " + v.beta + ")" : "");
7657+}
7658+
7659+function compareVersions(v1,v2)
7660+{
7661+ var x1,x2,i,a = ["major","minor","revision"];
7662+ for(i = 0; i<a.length; i++) {
7663+ x1 = v1[a[i]] || 0;
7664+ x2 = v2[a[i]] || 0;
7665+ if(x1<x2)
7666+ return 1;
7667+ if(x1>x2)
7668+ return -1;
7669+ }
7670+ x1 = v1.beta || 9999;
7671+ x2 = v2.beta || 9999;
7672+ if(x1<x2)
7673+ return 1;
7674+ return x1 > x2 ? -1 : 0;
7675+}
7676+
7677+function merge(dst,src,preserveExisting)
7678+{
7679+ var i;
7680+ for(i in src) {
7681+ if(!preserveExisting || dst[i] === undefined)
7682+ dst[i] = src[i];
7683+ }
7684+ return dst;
7685+}
7686+
7687+// Resolve the target object of an event
7688+function resolveTarget(e)
7689+{
7690+ var obj;
7691+ if(e.target)
7692+ obj = e.target;
7693+ else if(e.srcElement)
7694+ obj = e.srcElement;
7695+ if(obj.nodeType == 3) // defeat Safari bug
7696+ obj = obj.parentNode;
7697+ return obj;
7698+}
7699+
7700+// Returns a string containing the description of an exception, optionally prepended by a message
7701+function exceptionText(e,message)
7702+{
7703+ var s = e.description || e.toString();
7704+ return message ? "%0:\n%1".format([message,s]) : s;
7705+}
7706+
7707+// Displays an alert of an exception description with optional message
7708+function showException(e,message)
7709+{
7710+ alert(exceptionText(e,message));
7711+}
7712+
7713+function alertAndThrow(m)
7714+{
7715+ alert(m);
7716+ throw(m);
7717+}
7718+
7719+function glyph(name)
7720+{
7721+ var g = config.glyphs;
7722+ var b = g.currBrowser;
7723+ if(b == null) {
7724+ b = 0;
7725+ while(b < g.browsers.length-1 && !g.browsers[b]())
7726+ b++;
7727+ g.currBrowser = b;
7728+ }
7729+ if(!g.codes[name])
7730+ return "";
7731+ return g.codes[name][b];
7732+}
7733+
7734+function createTiddlyText(parent,text)
7735+{
7736+ return parent.appendChild(document.createTextNode(text));
7737+}
7738+
7739+function createTiddlyCheckbox(parent,caption,checked,onChange)
7740+{
7741+ var cb = document.createElement("input");
7742+ cb.setAttribute("type","checkbox");
7743+ cb.onclick = onChange;
7744+ parent.appendChild(cb);
7745+ cb.checked = checked;
7746+ cb.className = "chkOptionInput";
7747+ if(caption)
7748+ wikify(caption,parent);
7749+ return cb;
7750+}
7751+
7752+function createTiddlyElement(parent,element,id,className,text,attribs)
7753+{
7754+ var n,e = document.createElement(element);
7755+ if(className != null)
7756+ e.className = className;
7757+ if(id != null)
7758+ e.setAttribute("id",id);
7759+ if(text != null)
7760+ e.appendChild(document.createTextNode(text));
7761+ if(attribs) {
7762+ for(n in attribs) {
7763+ e.setAttribute(n,attribs[n]);
7764+ }
7765+ }
7766+ if(parent != null)
7767+ parent.appendChild(e);
7768+ return e;
7769+}
7770+
7771+function createTiddlyButton(parent,text,tooltip,action,className,id,accessKey,attribs)
7772+{
7773+ var i,btn = document.createElement("a");
7774+ btn.setAttribute("href","javascript:;");
7775+ if(action) {
7776+ btn.onclick = action;
7777+ }
7778+ if(tooltip)
7779+ btn.setAttribute("title",tooltip);
7780+ if(text)
7781+ btn.appendChild(document.createTextNode(text));
7782+ btn.className = className || "button";
7783+ if(id)
7784+ btn.id = id;
7785+ if(attribs) {
7786+ for(i in attribs) {
7787+ btn.setAttribute(i,attribs[i]);
7788+ }
7789+ }
7790+ if(parent)
7791+ parent.appendChild(btn);
7792+ if(accessKey)
7793+ btn.setAttribute("accessKey",accessKey);
7794+ return btn;
7795+}
7796+
7797+function createExternalLink(place,url,label)
7798+{
7799+ var link = document.createElement("a");
7800+ link.className = "externalLink";
7801+ link.href = url;
7802+ var f = config.messages.externalLinkTooltip;
7803+ link.title = f ? f.format([url]) : url;
7804+ if(config.options.chkOpenInNewWindow)
7805+ link.target = "_blank";
7806+ place.appendChild(link);
7807+ if(label)
7808+ createTiddlyText(link, label);
7809+ return link;
7810+}
7811+
7812+function getTiddlyLinkInfo(title,currClasses)
7813+{
7814+ var classes = currClasses ? currClasses.split(" ") : [];
7815+ classes.pushUnique("tiddlyLink");
7816+ var tiddler = store.fetchTiddler(title);
7817+ var subTitle;
7818+ if(tiddler) {
7819+ subTitle = tiddler.getSubtitle();
7820+ classes.pushUnique("tiddlyLinkExisting");
7821+ classes.remove("tiddlyLinkNonExisting");
7822+ classes.remove("shadow");
7823+ } else {
7824+ var f;
7825+ classes.remove("tiddlyLinkExisting");
7826+ classes.pushUnique("tiddlyLinkNonExisting");
7827+ if(store.isShadowTiddler(title)) {
7828+ f = config.messages.shadowedTiddlerToolTip;
7829+ classes.pushUnique("shadow");
7830+ } else {
7831+ f = config.messages.undefinedTiddlerToolTip;
7832+ classes.remove("shadow");
7833+ }
7834+ subTitle = f ? f.format([title]) : "";
7835+ }
7836+ if(typeof config.annotations[title]=="string")
7837+ subTitle = config.annotations[title];
7838+ return {classes: classes.join(" "),subTitle: subTitle};
7839+}
7840+
7841+// Event handler for clicking on a tiddly link
7842+function onClickTiddlerLink(ev)
7843+{
7844+ var e = ev || window.event;
7845+ var target = resolveTarget(e);
7846+ var link = target;
7847+ var title = null;
7848+ var fields = null;
7849+ var noToggle = null;
7850+ do {
7851+ title = link.getAttribute("tiddlyLink");
7852+ fields = link.getAttribute("tiddlyFields");
7853+ noToggle = link.getAttribute("noToggle");
7854+ link = link.parentNode;
7855+ } while(title == null && link != null);
7856+ if(!store.isShadowTiddler(title)) {
7857+ var f = fields ? fields.decodeHashMap() : {};
7858+ fields = String.encodeHashMap(merge(f,config.defaultCustomFields,true));
7859+ }
7860+ if(title) {
7861+ var toggling = e.metaKey || e.ctrlKey;
7862+ if(config.options.chkToggleLinks)
7863+ toggling = !toggling;
7864+ if(noToggle)
7865+ toggling = false;
7866+ if(store.getTiddler(title))
7867+ fields = null;
7868+ story.displayTiddler(target,title,null,true,null,fields,toggling);
7869+ }
7870+ clearMessage();
7871+ return false;
7872+}
7873+
7874+function createTiddlyLink(place,title,includeText,className,isStatic,linkedFromTiddler,noToggle)
7875+{
7876+ var title = jQuery.trim(title);
7877+ var text = includeText ? title : null;
7878+ var i = getTiddlyLinkInfo(title,className);
7879+ var btn = isStatic ? createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" + title) : createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
7880+ if(isStatic)
7881+ btn.className += ' ' + className;
7882+ btn.setAttribute("refresh","link");
7883+ btn.setAttribute("tiddlyLink",title);
7884+ if(noToggle)
7885+ btn.setAttribute("noToggle","true");
7886+ if(linkedFromTiddler) {
7887+ var fields = linkedFromTiddler.getInheritedFields();
7888+ if(fields)
7889+ btn.setAttribute("tiddlyFields",fields);
7890+ }
7891+ return btn;
7892+}
7893+
7894+function refreshTiddlyLink(e,title)
7895+{
7896+ var i = getTiddlyLinkInfo(title,e.className);
7897+ e.className = i.classes;
7898+ e.title = i.subTitle;
7899+}
7900+
7901+function createTiddlyDropDown(place,onchange,options,defaultValue)
7902+{
7903+ var sel = createTiddlyElement(place,"select");
7904+ sel.onchange = onchange;
7905+ var t;
7906+ for(t=0; t<options.length; t++) {
7907+ var e = createTiddlyElement(sel,"option",null,null,options[t].caption);
7908+ e.value = options[t].name;
7909+ if(options[t].name == defaultValue)
7910+ e.selected = true;
7911+ }
7912+ return sel;
7913+}
7914+
7915+//--
7916+//-- TiddlyWiki-specific popup utility functions
7917+//--
7918+
7919+// Event handler for 'open all' on a tiddler popup
7920+function onClickTagOpenAll(ev)
7921+{
7922+ var tiddlers = store.getTaggedTiddlers(this.getAttribute("tag"));
7923+ var sortby = this.getAttribute("sortby");
7924+ if(sortby&&sortby.length) {
7925+ store.sortTiddlers(tiddlers,sortby);
7926+ }
7927+ story.displayTiddlers(this,tiddlers);
7928+ return false;
7929+}
7930+
7931+// Event handler for clicking on a tiddler tag
7932+function onClickTag(ev)
7933+{
7934+ var e = ev || window.event;
7935+ var popup = Popup.create(this);
7936+ jQuery(popup).addClass("taggedTiddlerList");
7937+ var tag = this.getAttribute("tag");
7938+ var title = this.getAttribute("tiddler");
7939+ if(popup && tag) {
7940+ var tagged = tag.indexOf("[")==-1 ? store.getTaggedTiddlers(tag) : store.filterTiddlers(tag);
7941+ var sortby = this.getAttribute("sortby");
7942+ if(sortby&&sortby.length) {
7943+ store.sortTiddlers(tagged,sortby);
7944+ }
7945+ var titles = [];
7946+ var r;
7947+ for(r=0;r<tagged.length;r++) {
7948+ if(tagged[r].title != title)
7949+ titles.push(tagged[r].title);
7950+ }
7951+ var lingo = config.views.wikified.tag;
7952+ if(titles.length > 0) {
7953+ var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);
7954+ openAll.setAttribute("tag",tag);
7955+ openAll.setAttribute("sortby",sortby);
7956+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
7957+ for(r=0; r<titles.length; r++) {
7958+ createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);
7959+ }
7960+ } else {
7961+ createTiddlyElement(popup,"li",null,"disabled",lingo.popupNone.format([tag]));
7962+ }
7963+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
7964+ var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);
7965+ createTiddlyText(h,lingo.openTag.format([tag]));
7966+ }
7967+ Popup.show();
7968+ e.cancelBubble = true;
7969+ if(e.stopPropagation) e.stopPropagation();
7970+ return false;
7971+}
7972+
7973+// Create a button for a tag with a popup listing all the tiddlers that it tags
7974+function createTagButton(place,tag,excludeTiddler,title,tooltip)
7975+{
7976+ var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag);
7977+ btn.setAttribute("tag",tag);
7978+ if(excludeTiddler)
7979+ btn.setAttribute("tiddler",excludeTiddler);
7980+ return btn;
7981+}
7982+
7983+function onClickTiddlyPopup(ev)
7984+{
7985+ var e = ev || window.event;
7986+ var tiddler = this.tiddler;
7987+ if(tiddler.text) {
7988+ var popup = Popup.create(this,"div","popupTiddler");
7989+ wikify(tiddler.text,popup,null,tiddler);
7990+ Popup.show();
7991+ }
7992+ if(e) e.cancelBubble = true;
7993+ if(e && e.stopPropagation) e.stopPropagation();
7994+ return false;
7995+}
7996+
7997+function createTiddlyPopup(place,caption,tooltip,tiddler)
7998+{
7999+ if(tiddler.text) {
8000+ createTiddlyLink(place,caption,true);
8001+ var btn = createTiddlyButton(place,glyph("downArrow"),tooltip,onClickTiddlyPopup,"tiddlerPopupButton");
8002+ btn.tiddler = tiddler;
8003+ } else {
8004+ createTiddlyText(place,caption);
8005+ }
8006+}
8007+
8008+function onClickError(ev)
8009+{
8010+ var e = ev || window.event;
8011+ var popup = Popup.create(this);
8012+ var lines = this.getAttribute("errorText").split("\n");
8013+ var t;
8014+ for(t=0; t<lines.length; t++)
8015+ createTiddlyElement(popup,"li",null,null,lines[t]);
8016+ Popup.show();
8017+ e.cancelBubble = true;
8018+ if(e.stopPropagation) e.stopPropagation();
8019+ return false;
8020+}
8021+
8022+function createTiddlyError(place,title,text)
8023+{
8024+ var btn = createTiddlyButton(place,title,null,onClickError,"errorButton");
8025+ if(text) btn.setAttribute("errorText",text);
8026+}
8027+//-
8028+//- Animation engine
8029+//-
8030+
8031+function Animator()
8032+{
8033+ this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
8034+ this.timerID = 0; // ID of the timer used for animating
8035+ this.animations = []; // List of animations in progress
8036+ return this;
8037+}
8038+
8039+// Start animation engine
8040+Animator.prototype.startAnimating = function() //# Variable number of arguments
8041+{
8042+ var t;
8043+ for(t=0; t<arguments.length; t++)
8044+ this.animations.push(arguments[t]);
8045+ if(this.running == 0) {
8046+ var me = this;
8047+ this.timerID = window.setInterval(function() {me.doAnimate(me);},10);
8048+ }
8049+ this.running += arguments.length;
8050+};
8051+
8052+// Perform an animation engine tick, calling each of the known animation modules
8053+Animator.prototype.doAnimate = function(me)
8054+{
8055+ var a = 0;
8056+ while(a < me.animations.length) {
8057+ var animation = me.animations[a];
8058+ if(animation.tick()) {
8059+ a++;
8060+ } else {
8061+ me.animations.splice(a,1);
8062+ if(--me.running == 0)
8063+ window.clearInterval(me.timerID);
8064+ }
8065+ }
8066+};
8067+
8068+Animator.slowInSlowOut = function(progress)
8069+{
8070+ return(1-((Math.cos(progress * Math.PI)+1)/2));
8071+};
8072+
8073+//--
8074+//-- Morpher animation
8075+//--
8076+
8077+// Animate a set of properties of an element
8078+function Morpher(element,duration,properties,callback)
8079+{
8080+ this.element = element;
8081+ this.duration = duration;
8082+ this.properties = properties;
8083+ this.startTime = new Date();
8084+ this.endTime = Number(this.startTime) + duration;
8085+ this.callback = callback;
8086+ this.tick();
8087+ return this;
8088+}
8089+
8090+Morpher.prototype.assignStyle = function(element,style,value)
8091+{
8092+ switch(style) {
8093+ case "-tw-vertScroll":
8094+ window.scrollTo(findScrollX(),value);
8095+ break;
8096+ case "-tw-horizScroll":
8097+ window.scrollTo(value,findScrollY());
8098+ break;
8099+ default:
8100+ element.style[style] = value;
8101+ break;
8102+ }
8103+};
8104+
8105+Morpher.prototype.stop = function()
8106+{
8107+ var t;
8108+ for(t=0; t<this.properties.length; t++) {
8109+ var p = this.properties[t];
8110+ if(p.atEnd !== undefined) {
8111+ this.assignStyle(this.element,p.style,p.atEnd);
8112+ }
8113+ }
8114+ if(this.callback)
8115+ this.callback(this.element,this.properties);
8116+};
8117+
8118+Morpher.prototype.tick = function()
8119+{
8120+ var currTime = Number(new Date());
8121+ var t,progress = Animator.slowInSlowOut(Math.min(1,(currTime-this.startTime)/this.duration));
8122+ for(t=0; t<this.properties.length; t++) {
8123+ var p = this.properties[t];
8124+ if(p.start !== undefined && p.end !== undefined) {
8125+ var template = p.template || "%0";
8126+ switch(p.format) {
8127+ case undefined:
8128+ case "style":
8129+ var v = p.start + (p.end-p.start) * progress;
8130+ this.assignStyle(this.element,p.style,template.format([v]));
8131+ break;
8132+ case "color":
8133+ break;
8134+ }
8135+ }
8136+ }
8137+ if(currTime >= this.endTime) {
8138+ this.stop();
8139+ return false;
8140+ }
8141+ return true;
8142+};
8143+
8144+//--
8145+//-- Zoomer animation
8146+//--
8147+
8148+function Zoomer(text,startElement,targetElement,unused)
8149+{
8150+ var e = createTiddlyElement(document.body,"div",null,"zoomer");
8151+ createTiddlyElement(e,"div",null,null,text);
8152+ var winWidth = findWindowWidth();
8153+ var winHeight = findWindowHeight();
8154+ var p = [
8155+ {style: 'left', start: findPosX(startElement), end: findPosX(targetElement), template: '%0px'},
8156+ {style: 'top', start: findPosY(startElement), end: findPosY(targetElement), template: '%0px'},
8157+ {style: 'width', start: Math.min(startElement.scrollWidth,winWidth), end: Math.min(targetElement.scrollWidth,winWidth), template: '%0px', atEnd: 'auto'},
8158+ {style: 'height', start: Math.min(startElement.scrollHeight,winHeight), end: Math.min(targetElement.scrollHeight,winHeight), template: '%0px', atEnd: 'auto'},
8159+ {style: 'fontSize', start: 8, end: 24, template: '%0pt'}
8160+ ];
8161+ var c = function(element,properties) {jQuery(element).remove();};
8162+ return new Morpher(e,config.animDuration,p,c);
8163+}
8164+
8165+//--
8166+//-- Scroller animation
8167+//--
8168+
8169+function Scroller(targetElement)
8170+{
8171+ var p = [{style: '-tw-vertScroll', start: findScrollY(), end: ensureVisible(targetElement)}];
8172+ return new Morpher(targetElement,config.animDuration,p);
8173+}
8174+
8175+//--
8176+//-- Slider animation
8177+//--
8178+
8179+// deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element]
8180+function Slider(element,opening,unused,deleteMode)
8181+{
8182+ element.style.overflow = 'hidden';
8183+ if(opening)
8184+ element.style.height = '0px'; // Resolves a Firefox flashing bug
8185+ element.style.display = 'block';
8186+ var height = element.scrollHeight;
8187+ var p = [];
8188+ var c = null;
8189+ if(opening) {
8190+ p.push({style: 'height', start: 0, end: height, template: '%0px', atEnd: 'auto'});
8191+ p.push({style: 'opacity', start: 0, end: 1, template: '%0'});
8192+ p.push({style: 'filter', start: 0, end: 100, template: 'alpha(opacity:%0)'});
8193+ } else {
8194+ p.push({style: 'height', start: height, end: 0, template: '%0px'});
8195+ p.push({style: 'display', atEnd: 'none'});
8196+ p.push({style: 'opacity', start: 1, end: 0, template: '%0'});
8197+ p.push({style: 'filter', start: 100, end: 0, template: 'alpha(opacity:%0)'});
8198+ switch(deleteMode) {
8199+ case "all":
8200+ c = function(element,properties) {jQuery(element).remove();};
8201+ break;
8202+ case "children":
8203+ c = function(element,properties) {jQuery(element).empty();};
8204+ break;
8205+ }
8206+ }
8207+ return new Morpher(element,config.animDuration,p,c);
8208+}
8209+
8210+//--
8211+//-- Popup menu
8212+//--
8213+
8214+var Popup = {
8215+ stack: [] // Array of objects with members root: and popup:
8216+ };
8217+
8218+Popup.create = function(root,elem,className)
8219+{
8220+ var stackPosition = this.find(root,"popup");
8221+ Popup.remove(stackPosition+1);
8222+ var popup = createTiddlyElement(document.body,elem || "ol","popup",className || "popup");
8223+ popup.stackPosition = stackPosition;
8224+ Popup.stack.push({root: root, popup: popup});
8225+ return popup;
8226+};
8227+
8228+Popup.onDocumentClick = function(ev)
8229+{
8230+ var e = ev || window.event;
8231+ if(e.eventPhase == undefined)
8232+ Popup.remove();
8233+ else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET)
8234+ Popup.remove();
8235+ return true;
8236+};
8237+
8238+Popup.show = function(valign,halign,offset)
8239+{
8240+ var curr = Popup.stack[Popup.stack.length-1];
8241+ this.place(curr.root,curr.popup,valign,halign,offset);
8242+ jQuery(curr.root).addClass("highlight");
8243+ if(config.options.chkAnimate && anim && typeof Scroller == "function")
8244+ anim.startAnimating(new Scroller(curr.popup));
8245+ else
8246+ window.scrollTo(0,ensureVisible(curr.popup));
8247+};
8248+
8249+Popup.place = function(root,popup,valign,halign,offset)
8250+{
8251+ if(!offset)
8252+ offset = {x:0,y:0};
8253+ if(popup.stackPosition >= 0 && !valign && !halign) {
8254+ offset.x = offset.x + root.offsetWidth;
8255+ } else {
8256+ offset.x = (halign == "right") ? offset.x + root.offsetWidth : offset.x;
8257+ offset.y = (valign == "top") ? offset.y : offset.y + root.offsetHeight;
8258+ }
8259+ var rootLeft = findPosX(root);
8260+ var rootTop = findPosY(root);
8261+ var popupLeft = rootLeft + offset.x;
8262+ var popupTop = rootTop + offset.y;
8263+ var winWidth = findWindowWidth();
8264+ if(popup.offsetWidth > winWidth*0.75)
8265+ popup.style.width = winWidth*0.75 + "px";
8266+ var popupWidth = popup.offsetWidth;
8267+ var scrollWidth = winWidth - document.body.offsetWidth;
8268+ if(popupLeft + popupWidth > winWidth - scrollWidth - 1) {
8269+ if(halign == "right")
8270+ popupLeft = popupLeft - root.offsetWidth - popupWidth;
8271+ else
8272+ popupLeft = winWidth - popupWidth - scrollWidth - 1;
8273+ }
8274+ popup.style.left = popupLeft + "px";
8275+ popup.style.top = popupTop + "px";
8276+ popup.style.display = "block";
8277+};
8278+
8279+Popup.find = function(e)
8280+{
8281+ var t,pos = -1;
8282+ for(t=this.stack.length-1; t>=0; t--) {
8283+ if(isDescendant(e,this.stack[t].popup))
8284+ pos = t;
8285+ }
8286+ return pos;
8287+};
8288+
8289+Popup.remove = function(pos)
8290+{
8291+ if(!pos) pos = 0;
8292+ if(Popup.stack.length > pos) {
8293+ Popup.removeFrom(pos);
8294+ }
8295+};
8296+
8297+Popup.removeFrom = function(from)
8298+{
8299+ var t;
8300+ for(t=Popup.stack.length-1; t>=from; t--) {
8301+ var p = Popup.stack[t];
8302+ jQuery(p.root).removeClass("highlight");
8303+ jQuery(p.popup).remove();
8304+ }
8305+ Popup.stack = Popup.stack.slice(0,from);
8306+};
8307+
8308+//--
8309+//-- Wizard support
8310+//--
8311+
8312+function Wizard(elem)
8313+{
8314+ if(elem) {
8315+ this.formElem = findRelated(elem,"wizard","className");
8316+ this.bodyElem = findRelated(this.formElem.firstChild,"wizardBody","className","nextSibling");
8317+ this.footElem = findRelated(this.formElem.firstChild,"wizardFooter","className","nextSibling");
8318+ } else {
8319+ this.formElem = null;
8320+ this.bodyElem = null;
8321+ this.footElem = null;
8322+ }
8323+}
8324+
8325+Wizard.prototype.setValue = function(name,value)
8326+{
8327+ jQuery(this.formElem).data(name, value);
8328+};
8329+
8330+Wizard.prototype.getValue = function(name)
8331+{
8332+ return this.formElem ? jQuery(this.formElem).data(name) : null;
8333+};
8334+
8335+Wizard.prototype.createWizard = function(place,title)
8336+{
8337+ this.formElem = createTiddlyElement(place,"form",null,"wizard");
8338+ createTiddlyElement(this.formElem,"h1",null,null,title);
8339+ this.bodyElem = createTiddlyElement(this.formElem,"div",null,"wizardBody");
8340+ this.footElem = createTiddlyElement(this.formElem,"div",null,"wizardFooter");
8341+ return this.formElem;
8342+};
8343+
8344+Wizard.prototype.clear = function()
8345+{
8346+ jQuery(this.bodyElem).empty();
8347+};
8348+
8349+Wizard.prototype.setButtons = function(buttonInfo,status)
8350+{
8351+ jQuery(this.footElem).empty();
8352+ var t;
8353+ for(t=0; t<buttonInfo.length; t++) {
8354+ createTiddlyButton(this.footElem,buttonInfo[t].caption,buttonInfo[t].tooltip,buttonInfo[t].onClick);
8355+ insertSpacer(this.footElem);
8356+ }
8357+ if(typeof status == "string") {
8358+ createTiddlyElement(this.footElem,"span",null,"status",status);
8359+ }
8360+};
8361+
8362+Wizard.prototype.addStep = function(stepTitle,html)
8363+{
8364+ jQuery(this.bodyElem).empty();
8365+ var w = createTiddlyElement(this.bodyElem,"div");
8366+ createTiddlyElement(w,"h2",null,null,stepTitle);
8367+ var step = createTiddlyElement(w,"div",null,"wizardStep");
8368+ step.innerHTML = html;
8369+ applyHtmlMacros(step,tiddler);
8370+};
8371+
8372+Wizard.prototype.getElement = function(name)
8373+{
8374+ return this.formElem.elements[name];
8375+};
8376+
8377+//--
8378+//-- ListView gadget
8379+//--
8380+
8381+var ListView = {};
8382+
8383+// Create a listview
8384+ListView.create = function(place,listObject,listTemplate,callback,className)
8385+{
8386+ var table = createTiddlyElement(place,"table",null,className || "listView twtable");
8387+ var thead = createTiddlyElement(table,"thead");
8388+ var t,r = createTiddlyElement(thead,"tr");
8389+ for(t=0; t<listTemplate.columns.length; t++) {
8390+ var columnTemplate = listTemplate.columns[t];
8391+ var c = createTiddlyElement(r,"th");
8392+ var colType = ListView.columnTypes[columnTemplate.type];
8393+ if(colType && colType.createHeader) {
8394+ colType.createHeader(c,columnTemplate,t);
8395+ if(columnTemplate.className)
8396+ jQuery(c).addClass(columnTemplate.className);
8397+ }
8398+ }
8399+ var rc,tbody = createTiddlyElement(table,"tbody");
8400+ for(rc=0; rc<listObject.length; rc++) {
8401+ var rowObject = listObject[rc];
8402+ r = createTiddlyElement(tbody,"tr");
8403+ for(c=0; c<listTemplate.rowClasses.length; c++) {
8404+ if(rowObject[listTemplate.rowClasses[c].field])
8405+ jQuery(r).addClass(listTemplate.rowClasses[c].className);
8406+ }
8407+ rowObject.rowElement = r;
8408+ rowObject.colElements = {};
8409+ var cc;
8410+ for(cc=0; cc<listTemplate.columns.length; cc++) {
8411+ c = createTiddlyElement(r,"td");
8412+ columnTemplate = listTemplate.columns[cc];
8413+ var field = columnTemplate.field;
8414+ colType = ListView.columnTypes[columnTemplate.type];
8415+ if(colType && colType.createItem) {
8416+ colType.createItem(c,rowObject,field,columnTemplate,cc,rc);
8417+ if(columnTemplate.className)
8418+ jQuery(c).addClass(columnTemplate.className);
8419+ }
8420+ rowObject.colElements[field] = c;
8421+ }
8422+ }
8423+ if(callback && listTemplate.actions)
8424+ createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions);
8425+ if(callback && listTemplate.buttons) {
8426+ for(t=0; t<listTemplate.buttons.length; t++) {
8427+ var a = listTemplate.buttons[t];
8428+ if(a && a.name != "")
8429+ createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection));
8430+ }
8431+ }
8432+ return table;
8433+};
8434+
8435+ListView.getCommandHandler = function(callback,name,allowEmptySelection)
8436+{
8437+ return function(e) {
8438+ var view = findRelated(this,"TABLE",null,"previousSibling");
8439+ var tiddlers = [];
8440+ ListView.forEachSelector(view,function(e,rowName) {
8441+ if(e.checked)
8442+ tiddlers.push(rowName);
8443+ });
8444+ if(tiddlers.length == 0 && !allowEmptySelection) {
8445+ alert(config.messages.nothingSelected);
8446+ } else {
8447+ if(this.nodeName.toLowerCase() == "select") {
8448+ callback(view,this.value,tiddlers);
8449+ this.selectedIndex = 0;
8450+ } else {
8451+ callback(view,name,tiddlers);
8452+ }
8453+ }
8454+ };
8455+};
8456+
8457+// Invoke a callback for each selector checkbox in the listview
8458+ListView.forEachSelector = function(view,callback)
8459+{
8460+ var checkboxes = view.getElementsByTagName("input");
8461+ var t,hadOne = false;
8462+ for(t=0; t<checkboxes.length; t++) {
8463+ var cb = checkboxes[t];
8464+ if(cb.getAttribute("type") == "checkbox") {
8465+ var rn = cb.getAttribute("rowName");
8466+ if(rn) {
8467+ callback(cb,rn);
8468+ hadOne = true;
8469+ }
8470+ }
8471+ }
8472+ return hadOne;
8473+};
8474+
8475+ListView.getSelectedRows = function(view)
8476+{
8477+ var rowNames = [];
8478+ ListView.forEachSelector(view,function(e,rowName) {
8479+ if(e.checked)
8480+ rowNames.push(rowName);
8481+ });
8482+ return rowNames;
8483+};
8484+
8485+ListView.columnTypes = {};
8486+
8487+ListView.columnTypes.String = {
8488+ createHeader: function(place,columnTemplate,col)
8489+ {
8490+ createTiddlyText(place,columnTemplate.title);
8491+ },
8492+ createItem: function(place,listObject,field,columnTemplate,col,row)
8493+ {
8494+ var v = listObject[field];
8495+ if(v != undefined)
8496+ createTiddlyText(place,v);
8497+ }
8498+};
8499+
8500+ListView.columnTypes.WikiText = {
8501+ createHeader: ListView.columnTypes.String.createHeader,
8502+ createItem: function(place,listObject,field,columnTemplate,col,row)
8503+ {
8504+ var v = listObject[field];
8505+ if(v != undefined)
8506+ wikify(v,place,null,null);
8507+ }
8508+};
8509+
8510+ListView.columnTypes.Tiddler = {
8511+ createHeader: ListView.columnTypes.String.createHeader,
8512+ createItem: function(place,listObject,field,columnTemplate,col,row)
8513+ {
8514+ var v = listObject[field];
8515+ if(v != undefined && v.title)
8516+ createTiddlyPopup(place,v.title,config.messages.listView.tiddlerTooltip,v);
8517+ }
8518+};
8519+
8520+ListView.columnTypes.Size = {
8521+ createHeader: ListView.columnTypes.String.createHeader,
8522+ createItem: function(place,listObject,field,columnTemplate,col,row)
8523+ {
8524+ var msg = config.messages.sizeTemplates;
8525+ var v = listObject[field];
8526+ if(v != undefined) {
8527+ var t = 0;
8528+ while(t<msg.length-1 && v<msg[t].unit)
8529+ t++;
8530+ createTiddlyText(place,msg[t].template.format([Math.round(v/msg[t].unit)]));
8531+ }
8532+ }
8533+};
8534+
8535+ListView.columnTypes.Link = {
8536+ createHeader: ListView.columnTypes.String.createHeader,
8537+ createItem: function(place,listObject,field,columnTemplate,col,row)
8538+ {
8539+ var v = listObject[field];
8540+ var c = columnTemplate.text;
8541+ if(v != undefined)
8542+ createExternalLink(place,v,c || v);
8543+ }
8544+};
8545+
8546+ListView.columnTypes.Date = {
8547+ createHeader: ListView.columnTypes.String.createHeader,
8548+ createItem: function(place,listObject,field,columnTemplate,col,row)
8549+ {
8550+ var v = listObject[field];
8551+ if(v != undefined)
8552+ createTiddlyText(place,v.formatString(columnTemplate.dateFormat));
8553+ }
8554+};
8555+
8556+ListView.columnTypes.StringList = {
8557+ createHeader: ListView.columnTypes.String.createHeader,
8558+ createItem: function(place,listObject,field,columnTemplate,col,row)
8559+ {
8560+ var v = listObject[field];
8561+ if(v != undefined) {
8562+ var t;
8563+ for(t=0; t<v.length; t++) {
8564+ createTiddlyText(place,v[t]);
8565+ createTiddlyElement(place,"br");
8566+ }
8567+ }
8568+ }
8569+};
8570+
8571+ListView.columnTypes.Selector = {
8572+ createHeader: function(place,columnTemplate,col)
8573+ {
8574+ createTiddlyCheckbox(place,null,false,this.onHeaderChange);
8575+ },
8576+ createItem: function(place,listObject,field,columnTemplate,col,row)
8577+ {
8578+ var e = createTiddlyCheckbox(place,null,listObject[field],null);
8579+ e.setAttribute("rowName",listObject[columnTemplate.rowName]);
8580+ },
8581+ onHeaderChange: function(e)
8582+ {
8583+ var state = this.checked;
8584+ var view = findRelated(this,"TABLE");
8585+ if(!view)
8586+ return;
8587+ ListView.forEachSelector(view,function(e,rowName) {
8588+ e.checked = state;
8589+ });
8590+ }
8591+};
8592+
8593+ListView.columnTypes.Tags = {
8594+ createHeader: ListView.columnTypes.String.createHeader,
8595+ createItem: function(place,listObject,field,columnTemplate,col,row)
8596+ {
8597+ var tags = listObject[field];
8598+ createTiddlyText(place,String.encodeTiddlyLinkList(tags));
8599+ }
8600+};
8601+
8602+ListView.columnTypes.Boolean = {
8603+ createHeader: ListView.columnTypes.String.createHeader,
8604+ createItem: function(place,listObject,field,columnTemplate,col,row)
8605+ {
8606+ if(listObject[field] == true)
8607+ createTiddlyText(place,columnTemplate.trueText);
8608+ if(listObject[field] == false)
8609+ createTiddlyText(place,columnTemplate.falseText);
8610+ }
8611+};
8612+
8613+ListView.columnTypes.TagCheckbox = {
8614+ createHeader: ListView.columnTypes.String.createHeader,
8615+ createItem: function(place,listObject,field,columnTemplate,col,row)
8616+ {
8617+ var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange);
8618+ e.setAttribute("tiddler",listObject.title);
8619+ e.setAttribute("tag",columnTemplate.tag);
8620+ },
8621+ onChange : function(e)
8622+ {
8623+ var tag = this.getAttribute("tag");
8624+ var tiddler = this.getAttribute("tiddler");
8625+ store.setTiddlerTag(tiddler,this.checked,tag);
8626+ }
8627+};
8628+
8629+ListView.columnTypes.TiddlerLink = {
8630+ createHeader: ListView.columnTypes.String.createHeader,
8631+ createItem: function(place,listObject,field,columnTemplate,col,row)
8632+ {
8633+ var v = listObject[field];
8634+ if(v != undefined) {
8635+ var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null);
8636+ createTiddlyText(link,listObject[field]);
8637+ }
8638+ }
8639+};
8640+
8641+//--
8642+//-- Augmented methods for the JavaScript Array() object
8643+//--
8644+
8645+// Add indexOf function if browser does not support it
8646+if(!Array.indexOf) {
8647+Array.prototype.indexOf = function(item,from)
8648+{
8649+ if(!from)
8650+ from = 0;
8651+ var i;
8652+ for(i=from; i<this.length; i++) {
8653+ if(this[i] === item)
8654+ return i;
8655+ }
8656+ return -1;
8657+};}
8658+
8659+// Find an entry in a given field of the members of an array
8660+Array.prototype.findByField = function(field,value)
8661+{
8662+ var t;
8663+ for(t=0; t<this.length; t++) {
8664+ if(this[t][field] === value)
8665+ return t;
8666+ }
8667+ return null;
8668+};
8669+
8670+// Return whether an entry exists in an array
8671+Array.prototype.contains = function(item)
8672+{
8673+ return this.indexOf(item) != -1;
8674+};
8675+
8676+// Adds, removes or toggles a particular value within an array
8677+// value - value to add
8678+// mode - +1 to add value, -1 to remove value, 0 to toggle it
8679+Array.prototype.setItem = function(value,mode)
8680+{
8681+ var p = this.indexOf(value);
8682+ if(mode == 0)
8683+ mode = (p == -1) ? +1 : -1;
8684+ if(mode == +1) {
8685+ if(p == -1)
8686+ this.push(value);
8687+ } else if(mode == -1) {
8688+ if(p != -1)
8689+ this.splice(p,1);
8690+ }
8691+};
8692+
8693+// Return whether one of a list of values exists in an array
8694+Array.prototype.containsAny = function(items)
8695+{
8696+ var i;
8697+ for(i=0; i<items.length; i++) {
8698+ if(this.indexOf(items[i]) != -1)
8699+ return true;
8700+ }
8701+ return false;
8702+};
8703+
8704+// Return whether all of a list of values exists in an array
8705+Array.prototype.containsAll = function(items)
8706+{
8707+ var i;
8708+ for(i = 0; i<items.length; i++) {
8709+ if(this.indexOf(items[i]) == -1)
8710+ return false;
8711+ }
8712+ return true;
8713+};
8714+
8715+// 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
8716+Array.prototype.pushUnique = function(item,unique)
8717+{
8718+ if(unique === false) {
8719+ this.push(item);
8720+ } else {
8721+ if(this.indexOf(item) == -1)
8722+ this.push(item);
8723+ }
8724+};
8725+
8726+Array.prototype.remove = function(item)
8727+{
8728+ var p = this.indexOf(item);
8729+ if(p != -1)
8730+ this.splice(p,1);
8731+};
8732+
8733+if(!Array.prototype.map) {
8734+Array.prototype.map = function(fn,thisObj)
8735+{
8736+ var scope = thisObj || window;
8737+ var i,j,a = [];
8738+ for(i=0, j=this.length; i < j; ++i) {
8739+ a.push(fn.call(scope,this[i],i,this));
8740+ }
8741+ return a;
8742+};}
8743+
8744+//--
8745+//-- Augmented methods for the JavaScript String() object
8746+//--
8747+
8748+// Get characters from the right end of a string
8749+String.prototype.right = function(n)
8750+{
8751+ return n < this.length ? this.slice(this.length-n) : this;
8752+};
8753+
8754+// Trim whitespace from both ends of a string
8755+String.prototype.trim = function()
8756+{
8757+ return this.replace(/^\s*|\s*$/g,"");
8758+};
8759+
8760+// Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor")
8761+String.prototype.unDash = function()
8762+{
8763+ var t,s = this.split("-");
8764+ if(s.length > 1) {
8765+ for(t=1; t<s.length; t++)
8766+ s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1);
8767+ }
8768+ return s.join("");
8769+};
8770+
8771+// Substitute substrings from an array into a format string that includes '%1'-type specifiers
8772+String.prototype.format = function(s)
8773+{
8774+ var substrings = s && s.constructor == Array ? s : arguments;
8775+ var subRegExp = /(?:%(\d+))/mg;
8776+ var currPos = 0;
8777+ var match,r = [];
8778+ do {
8779+ match = subRegExp.exec(this);
8780+ if(match && match[1]) {
8781+ if(match.index > currPos)
8782+ r.push(this.substring(currPos,match.index));
8783+ r.push(substrings[parseInt(match[1],10)]);
8784+ currPos = subRegExp.lastIndex;
8785+ }
8786+ } while(match);
8787+ if(currPos < this.length)
8788+ r.push(this.substring(currPos,this.length));
8789+ return r.join("");
8790+};
8791+
8792+// Escape any special RegExp characters with that character preceded by a backslash
8793+String.prototype.escapeRegExp = function()
8794+{
8795+ var s = "\\^$*+?()=!|,{}[].";
8796+ var t,c = this;
8797+ for(t=0; t<s.length; t++)
8798+ c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1));
8799+ return c;
8800+};
8801+
8802+// Convert "\" to "\s", newlines to "\n" (and remove carriage returns)
8803+String.prototype.escapeLineBreaks = function()
8804+{
8805+ return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,"");
8806+};
8807+
8808+// Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns)
8809+String.prototype.unescapeLineBreaks = function()
8810+{
8811+ return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,"");
8812+};
8813+
8814+// Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;"
8815+String.prototype.htmlEncode = function()
8816+{
8817+ return this.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;");
8818+};
8819+
8820+// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
8821+String.prototype.htmlDecode = function()
8822+{
8823+ return this.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&");
8824+};
8825+
8826+// Parse a space-separated string of name:value parameters
8827+// The result is an array of objects:
8828+// result[0] = object with a member for each parameter name, value of that member being an array of values
8829+// result[1..n] = one object for each parameter, with 'name' and 'value' members
8830+String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults)
8831+{
8832+ var parseToken = function(match,p) {
8833+ var n;
8834+ if(match[p]) // Double quoted
8835+ n = match[p];
8836+ else if(match[p+1]) // Single quoted
8837+ n = match[p+1];
8838+ else if(match[p+2]) // Double-square-bracket quoted
8839+ n = match[p+2];
8840+ else if(match[p+3]) // Double-brace quoted
8841+ try {
8842+ n = match[p+3];
8843+ if(allowEval && config.evaluateMacroParameters != "none") {
8844+ if(config.evaluateMacroParameters == "restricted") {
8845+ if(window.restrictedEval) {
8846+ n = window.restrictedEval(n);
8847+ }
8848+ } else {
8849+ n = window.eval(n);
8850+ }
8851+ }
8852+ } catch(ex) {
8853+ throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(ex);
8854+ }
8855+ else if(match[p+4]) // Unquoted
8856+ n = match[p+4];
8857+ else if(match[p+5]) // empty quote
8858+ n = "";
8859+ return n;
8860+ };
8861+ var r = [{}];
8862+ var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
8863+ var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
8864+ var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
8865+ var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
8866+ var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
8867+ var emptyQuote = "((?:\"\")|(?:''))";
8868+ var skipSpace = "(?:\\s*)";
8869+ var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
8870+ var re = noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
8871+ var match;
8872+ do {
8873+ match = re.exec(this);
8874+ if(match) {
8875+ var n = parseToken(match,1);
8876+ if(noNames) {
8877+ r.push({name:"",value:n});
8878+ } else {
8879+ var v = parseToken(match,8);
8880+ if(v == null && defaultName) {
8881+ v = n;
8882+ n = defaultName;
8883+ } else if(v == null && defaultValue) {
8884+ v = defaultValue;
8885+ }
8886+ r.push({name:n,value:v});
8887+ if(cascadeDefaults) {
8888+ defaultName = n;
8889+ defaultValue = v;
8890+ }
8891+ }
8892+ }
8893+ } while(match);
8894+ // Summarise parameters into first element
8895+ var t;
8896+ for(t=1; t<r.length; t++) {
8897+ if(r[0][r[t].name])
8898+ r[0][r[t].name].push(r[t].value);
8899+ else
8900+ r[0][r[t].name] = [r[t].value];
8901+ }
8902+ return r;
8903+};
8904+
8905+// Process a string list of macro parameters into an array. Parameters can be quoted with "", '',
8906+// [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in
8907+// an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name.
8908+String.prototype.readMacroParams = function(notAllowEval)
8909+{
8910+ var p = this.parseParams("list",null,!notAllowEval,true);
8911+ var t,n = [];
8912+ for(t=1; t<p.length; t++)
8913+ n.push(p[t].value);
8914+ return n;
8915+};
8916+
8917+// Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]]
8918+String.prototype.readBracketedList = function(unique)
8919+{
8920+ var p = this.parseParams("list",null,false,true);
8921+ var t,n = [];
8922+ for(t=1; t<p.length; t++) {
8923+ if(p[t].value)
8924+ n.pushUnique(p[t].value,unique);
8925+ }
8926+ return n;
8927+};
8928+
8929+// Returns array with start and end index of chunk between given start and end marker, or undefined.
8930+String.prototype.getChunkRange = function(start,end)
8931+{
8932+ var s = this.indexOf(start);
8933+ if(s != -1) {
8934+ s += start.length;
8935+ var e = this.indexOf(end,s);
8936+ if(e != -1)
8937+ return [s,e];
8938+ }
8939+};
8940+
8941+// Replace a chunk of a string given start and end markers
8942+String.prototype.replaceChunk = function(start,end,sub)
8943+{
8944+ var r = this.getChunkRange(start,end);
8945+ return r ? this.substring(0,r[0]) + sub + this.substring(r[1]) : this;
8946+};
8947+
8948+// Returns a chunk of a string between start and end markers, or undefined
8949+String.prototype.getChunk = function(start,end)
8950+{
8951+ var r = this.getChunkRange(start,end);
8952+ if(r)
8953+ return this.substring(r[0],r[1]);
8954+};
8955+
8956+
8957+// Static method to bracket a string with double square brackets if it contains a space
8958+String.encodeTiddlyLink = function(title)
8959+{
8960+ return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
8961+};
8962+
8963+// Static method to encodeTiddlyLink for every item in an array and join them with spaces
8964+String.encodeTiddlyLinkList = function(list)
8965+{
8966+ if(list) {
8967+ var t,results = [];
8968+ for(t=0; t<list.length; t++)
8969+ results.push(String.encodeTiddlyLink(list[t]));
8970+ return results.join(" ");
8971+ } else {
8972+ return "";
8973+ }
8974+};
8975+
8976+// Convert a string as a sequence of name:"value" pairs into a hashmap
8977+String.prototype.decodeHashMap = function()
8978+{
8979+ var fields = this.parseParams("anon","",false);
8980+ var t,r = {};
8981+ for(t=1; t<fields.length; t++)
8982+ r[fields[t].name] = fields[t].value;
8983+ return r;
8984+};
8985+
8986+// Static method to encode a hashmap into a name:"value"... string
8987+String.encodeHashMap = function(hashmap)
8988+{
8989+ var t,r = [];
8990+ for(t in hashmap)
8991+ r.push(t + ':"' + hashmap[t] + '"');
8992+ return r.join(" ");
8993+};
8994+
8995+// Static method to left-pad a string with 0s to a certain width
8996+String.zeroPad = function(n,d)
8997+{
8998+ var s = n.toString();
8999+ if(s.length < d)
9000+ s = "000000000000000000000000000".substr(0,d-s.length) + s;
9001+ return s;
9002+};
9003+
9004+String.prototype.startsWith = function(prefix)
9005+{
9006+ return !prefix || this.substring(0,prefix.length) == prefix;
9007+};
9008+
9009+// Returns the first value of the given named parameter.
9010+function getParam(params,name,defaultValue)
9011+{
9012+ if(!params)
9013+ return defaultValue;
9014+ var p = params[0][name];
9015+ return p ? p[0] : defaultValue;
9016+}
9017+
9018+// Returns the first value of the given boolean named parameter.
9019+function getFlag(params,name,defaultValue)
9020+{
9021+ return !!getParam(params,name,defaultValue);
9022+}
9023+
9024+//--
9025+//-- Augmented methods for the JavaScript Date() object
9026+//--
9027+
9028+// Substitute date components into a string
9029+Date.prototype.formatString = function(template)
9030+{
9031+ var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
9032+ t = t.replace(/hh12/g,this.getHours12());
9033+ t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2));
9034+ t = t.replace(/hh/g,this.getHours());
9035+ t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]);
9036+ t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
9037+ t = t.replace(/mm/g,this.getMinutes());
9038+ t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
9039+ t = t.replace(/ss/g,this.getSeconds());
9040+ t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase());
9041+ t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase());
9042+ t = t.replace(/wYYYY/g,this.getYearForWeekNo());
9043+ t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
9044+ t = t.replace(/YYYY/g,this.getFullYear());
9045+ t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
9046+ t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]);
9047+ t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
9048+ t = t.replace(/MM/g,this.getMonth()+1);
9049+ t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
9050+ t = t.replace(/WW/g,this.getWeek());
9051+ t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]);
9052+ t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]);
9053+ t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2));
9054+ t = t.replace(/DDth/g,this.getDate()+this.daySuffix());
9055+ t = t.replace(/DD/g,this.getDate());
9056+ var tz = this.getTimezoneOffset();
9057+ var atz = Math.abs(tz);
9058+ t = t.replace(/TZD/g,(tz < 0 ? '+' : '-') + String.zeroPad(Math.floor(atz / 60),2) + ':' + String.zeroPad(atz % 60,2));
9059+ t = t.replace(/\\/g,"");
9060+ return t;
9061+};
9062+
9063+Date.prototype.getWeek = function()
9064+{
9065+ var dt = new Date(this.getTime());
9066+ var d = dt.getDay();
9067+ if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
9068+ dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo
9069+ var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);
9070+ return Math.floor(n/7)+1;
9071+};
9072+
9073+Date.prototype.getYearForWeekNo = function()
9074+{
9075+ var dt = new Date(this.getTime());
9076+ var d = dt.getDay();
9077+ if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
9078+ dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week
9079+ return dt.getFullYear();
9080+};
9081+
9082+Date.prototype.getHours12 = function()
9083+{
9084+ var h = this.getHours();
9085+ return h > 12 ? h-12 : ( h > 0 ? h : 12 );
9086+};
9087+
9088+Date.prototype.getAmPm = function()
9089+{
9090+ return this.getHours() >= 12 ? config.messages.dates.pm : config.messages.dates.am;
9091+};
9092+
9093+Date.prototype.daySuffix = function()
9094+{
9095+ return config.messages.dates.daySuffixes[this.getDate()-1];
9096+};
9097+
9098+// Convert a date to local YYYYMMDDHHMM string format
9099+Date.prototype.convertToLocalYYYYMMDDHHMM = function()
9100+{
9101+ return this.getFullYear() + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2);
9102+};
9103+
9104+// Convert a date to UTC YYYYMMDDHHMM string format
9105+Date.prototype.convertToYYYYMMDDHHMM = function()
9106+{
9107+ return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2);
9108+};
9109+
9110+// Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
9111+Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
9112+{
9113+ 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(),3) +"0";
9114+};
9115+
9116+// Static method to create a date from a UTC YYYYMMDDHHMM format string
9117+Date.convertFromYYYYMMDDHHMM = function(d)
9118+{
9119+ d = d?d.replace(/[^0-9]/g, ""):"";
9120+ return Date.convertFromYYYYMMDDHHMMSSMMM(d.substr(0,12));
9121+};
9122+
9123+// Static method to create a date from a UTC YYYYMMDDHHMMSS format string
9124+Date.convertFromYYYYMMDDHHMMSS = function(d)
9125+{
9126+ d = d?d.replace(/[^0-9]/g, ""):"";
9127+ return Date.convertFromYYYYMMDDHHMMSSMMM(d.substr(0,14));
9128+};
9129+
9130+// Static method to create a date from a UTC YYYYMMDDHHMMSSMMM format string
9131+Date.convertFromYYYYMMDDHHMMSSMMM = function(d)
9132+{
9133+ d = d ? d.replace(/[^0-9]/g, "") : "";
9134+ return new Date(Date.UTC(parseInt(d.substr(0,4),10),
9135+ parseInt(d.substr(4,2),10)-1,
9136+ parseInt(d.substr(6,2),10),
9137+ parseInt(d.substr(8,2)||"00",10),
9138+ parseInt(d.substr(10,2)||"00",10),
9139+ parseInt(d.substr(12,2)||"00",10),
9140+ parseInt(d.substr(14,3)||"000",10)));
9141+};
9142+
9143+//--
9144+//-- RGB colour object
9145+//--
9146+
9147+// Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values
9148+function RGB(r,g,b)
9149+{
9150+ this.r = 0;
9151+ this.g = 0;
9152+ this.b = 0;
9153+ if(typeof r == "string") {
9154+ if(r.substr(0,1) == "#") {
9155+ if(r.length == 7) {
9156+ this.r = parseInt(r.substr(1,2),16)/255;
9157+ this.g = parseInt(r.substr(3,2),16)/255;
9158+ this.b = parseInt(r.substr(5,2),16)/255;
9159+ } else {
9160+ this.r = parseInt(r.substr(1,1),16)/15;
9161+ this.g = parseInt(r.substr(2,1),16)/15;
9162+ this.b = parseInt(r.substr(3,1),16)/15;
9163+ }
9164+ } else {
9165+ var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/;
9166+ var c = r.match(rgbPattern);
9167+ if(c) {
9168+ this.r = parseInt(c[1],10)/255;
9169+ this.g = parseInt(c[2],10)/255;
9170+ this.b = parseInt(c[3],10)/255;
9171+ }
9172+ }
9173+ } else {
9174+ this.r = r;
9175+ this.g = g;
9176+ this.b = b;
9177+ }
9178+ return this;
9179+}
9180+
9181+// Mixes this colour with another in a specified proportion
9182+// c = other colour to mix
9183+// f = 0..1 where 0 is this colour and 1 is the new colour
9184+// Returns an RGB object
9185+RGB.prototype.mix = function(c,f)
9186+{
9187+ return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f);
9188+};
9189+
9190+// Return an rgb colour as a #rrggbb format hex string
9191+RGB.prototype.toString = function()
9192+{
9193+ var clamp = function(x,min,max) {
9194+ return x < min ? min : (x > max ? max : x);
9195+ };
9196+ return "#" +
9197+ ("0" + Math.floor(clamp(this.r,0,1) * 255).toString(16)).right(2) +
9198+ ("0" + Math.floor(clamp(this.g,0,1) * 255).toString(16)).right(2) +
9199+ ("0" + Math.floor(clamp(this.b,0,1) * 255).toString(16)).right(2);
9200+};
9201+
9202+//--
9203+//-- DOM utilities - many derived from www.quirksmode.org
9204+//--
9205+
9206+function drawGradient(place,horiz,locolors,hicolors)
9207+{
9208+ if(!hicolors)
9209+ hicolors = locolors;
9210+ var t;
9211+ for(t=0; t<= 100; t+=2) {
9212+ var bar = document.createElement("div");
9213+ place.appendChild(bar);
9214+ bar.style.position = "absolute";
9215+ bar.style.left = horiz ? t + "%" : 0;
9216+ bar.style.top = horiz ? 0 : t + "%";
9217+ bar.style.width = horiz ? (101-t) + "%" : "100%";
9218+ bar.style.height = horiz ? "100%" : (101-t) + "%";
9219+ bar.style.zIndex = -1;
9220+ var p = t/100*(locolors.length-1);
9221+ var hc = hicolors[Math.floor(p)];
9222+ if(typeof hc == "string")
9223+ hc = new RGB(hc);
9224+ var lc = locolors[Math.ceil(p)];
9225+ if(typeof lc == "string")
9226+ lc = new RGB(lc);
9227+ bar.style.backgroundColor = hc.mix(lc,p-Math.floor(p)).toString();
9228+ }
9229+}
9230+
9231+function addEvent(obj,type,fn)
9232+{
9233+ if(obj.attachEvent) {
9234+ obj["e"+type+fn] = fn;
9235+ obj[type+fn] = function(){obj["e"+type+fn](window.event);};
9236+ obj.attachEvent("on"+type,obj[type+fn]);
9237+ } else {
9238+ obj.addEventListener(type,fn,false);
9239+ }
9240+}
9241+
9242+function removeEvent(obj,type,fn)
9243+{
9244+ if(obj.detachEvent) {
9245+ obj.detachEvent("on"+type,obj[type+fn]);
9246+ obj[type+fn] = null;
9247+ } else {
9248+ obj.removeEventListener(type,fn,false);
9249+ }
9250+}
9251+
9252+// Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode)
9253+function findRelated(e,value,name,relative)
9254+{
9255+ name = name || "tagName";
9256+ relative = relative || "parentNode";
9257+ if(name == "className") {
9258+ while(e && !jQuery(e).hasClass(value)) {
9259+ e = e[relative];
9260+ }
9261+ } else {
9262+ while(e && e[name] != value) {
9263+ e = e[relative];
9264+ }
9265+ }
9266+ return e;
9267+}
9268+
9269+// Get the scroll position for window.scrollTo necessary to scroll a given element into view
9270+function ensureVisible(e)
9271+{
9272+ var posTop = findPosY(e);
9273+ var posBot = posTop + e.offsetHeight;
9274+ var winTop = findScrollY();
9275+ var winHeight = findWindowHeight();
9276+ var winBot = winTop + winHeight;
9277+ if(posTop < winTop) {
9278+ return posTop;
9279+ } else if(posBot > winBot) {
9280+ if(e.offsetHeight < winHeight)
9281+ return posTop - (winHeight - e.offsetHeight);
9282+ else
9283+ return posTop;
9284+ } else {
9285+ return winTop;
9286+ }
9287+}
9288+
9289+// Get the current width of the display window
9290+function findWindowWidth()
9291+{
9292+ return window.innerWidth || document.documentElement.clientWidth;
9293+}
9294+
9295+// Get the current height of the display window
9296+function findWindowHeight()
9297+{
9298+ return window.innerHeight || document.documentElement.clientHeight;
9299+}
9300+
9301+// Get the current height of the document
9302+function findDocHeight() {
9303+ var D = document;
9304+ return Math.max(
9305+ Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
9306+ Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
9307+ Math.max(D.body.clientHeight, D.documentElement.clientHeight)
9308+ );
9309+}
9310+
9311+// Get the current horizontal page scroll position
9312+function findScrollX()
9313+{
9314+ return window.scrollX || document.documentElement.scrollLeft;
9315+}
9316+
9317+// Get the current vertical page scroll position
9318+function findScrollY()
9319+{
9320+ return window.scrollY || document.documentElement.scrollTop;
9321+}
9322+
9323+function findPosX(obj)
9324+{
9325+ var curleft = 0;
9326+ while(obj.offsetParent) {
9327+ curleft += obj.offsetLeft;
9328+ obj = obj.offsetParent;
9329+ }
9330+ return curleft;
9331+}
9332+
9333+function findPosY(obj)
9334+{
9335+ var curtop = 0;
9336+ while(obj.offsetParent) {
9337+ curtop += obj.offsetTop;
9338+ obj = obj.offsetParent;
9339+ }
9340+ return curtop;
9341+}
9342+
9343+// Blur a particular element
9344+function blurElement(e)
9345+{
9346+ if(e && e.focus && e.blur) {
9347+ e.focus();
9348+ e.blur();
9349+ }
9350+}
9351+
9352+// Create a non-breaking space
9353+function insertSpacer(place)
9354+{
9355+ var e = document.createTextNode(String.fromCharCode(160));
9356+ if(place)
9357+ place.appendChild(e);
9358+ return e;
9359+}
9360+
9361+// Replace the current selection of a textarea or text input and scroll it into view
9362+function replaceSelection(e,text)
9363+{
9364+ if(e.setSelectionRange) {
9365+ var oldpos = e.selectionStart;
9366+ var isRange = e.selectionEnd > e.selectionStart;
9367+ e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionEnd);
9368+ e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + text.length);
9369+ var linecount = e.value.split("\n").length;
9370+ var thisline = e.value.substr(0,e.selectionStart).split("\n").length-1;
9371+ e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / linecount);
9372+ } else if(document.selection) {
9373+ var range = document.selection.createRange();
9374+ if(range.parentElement() == e) {
9375+ var isCollapsed = range.text == "";
9376+ range.text = text;
9377+ if(!isCollapsed) {
9378+ range.moveStart("character", -text.length);
9379+ range.select();
9380+ }
9381+ }
9382+ }
9383+}
9384+
9385+// Set the caret position in a text area
9386+function setCaretPosition(e,pos)
9387+{
9388+ if(e.selectionStart || e.selectionStart == '0') {
9389+ e.selectionStart = pos;
9390+ e.selectionEnd = pos;
9391+ e.focus();
9392+ } else if(document.selection) {
9393+ // IE support
9394+ e.focus ();
9395+ var sel = document.selection.createRange();
9396+ sel.moveStart('character', -e.value.length);
9397+ sel.moveStart('character',pos);
9398+ sel.moveEnd('character',0);
9399+ sel.select();
9400+ }
9401+}
9402+
9403+// Returns the text of the given (text) node, possibly merging subsequent text nodes
9404+function getNodeText(e)
9405+{
9406+ var t = "";
9407+ while(e && e.nodeName == "#text") {
9408+ t += e.nodeValue;
9409+ e = e.nextSibling;
9410+ }
9411+ return t;
9412+}
9413+
9414+// Returns true if the element e has a given ancestor element
9415+function isDescendant(e,ancestor)
9416+{
9417+ while(e) {
9418+ if(e === ancestor)
9419+ return true;
9420+ e = e.parentNode;
9421+ }
9422+ return false;
9423+}
9424+
9425+
9426+// deprecate the following...
9427+
9428+// Prevent an event from bubbling
9429+function stopEvent(e)
9430+{
9431+ var ev = e || window.event;
9432+ ev.cancelBubble = true;
9433+ if(ev.stopPropagation) ev.stopPropagation();
9434+ return false;
9435+}
9436+
9437+// Remove any event handlers or non-primitve custom attributes
9438+function scrubNode(e)
9439+{
9440+ if(!config.browser.isIE)
9441+ return;
9442+ var att = e.attributes;
9443+ if(att) {
9444+ var t;
9445+ for(t=0; t<att.length; t++) {
9446+ var n = att[t].name;
9447+ if(n !== "style" && (typeof e[n] === "function" || (typeof e[n] === "object" && e[n] != null))) {
9448+ try {
9449+ e[n] = null;
9450+ } catch(ex) {
9451+ }
9452+ }
9453+ }
9454+ }
9455+ var c = e.firstChild;
9456+ while(c) {
9457+ scrubNode(c);
9458+ c = c.nextSibling;
9459+ }
9460+}
9461+
9462+function setStylesheet(s,id,doc)
9463+{
9464+ jQuery.twStylesheet(s,{id:id,doc:doc});
9465+}
9466+
9467+function removeStyleSheet(id)
9468+{
9469+ jQuery.twStylesheet.remove({id:id});
9470+}
9471+
9472+//--
9473+//-- LoaderBase and SaverBase
9474+//--
9475+
9476+function LoaderBase() {}
9477+
9478+LoaderBase.prototype.loadTiddler = function(store,node,tiddlers)
9479+{
9480+ var title = this.getTitle(store,node);
9481+ if(safeMode && store.isShadowTiddler(title))
9482+ return;
9483+ if(title) {
9484+ var tiddler = store.createTiddler(title);
9485+ this.internalizeTiddler(store,tiddler,title,node);
9486+ tiddlers.push(tiddler);
9487+ }
9488+};
9489+
9490+LoaderBase.prototype.loadTiddlers = function(store,nodes)
9491+{
9492+ var t,tiddlers = [];
9493+ for(t = 0; t < nodes.length; t++) {
9494+ try {
9495+ this.loadTiddler(store,nodes[t],tiddlers);
9496+ } catch(ex) {
9497+ showException(ex,config.messages.tiddlerLoadError.format([this.getTitle(store,nodes[t])]));
9498+ }
9499+ }
9500+ return tiddlers;
9501+};
9502+
9503+function SaverBase() {}
9504+
9505+SaverBase.prototype.externalize = function(store)
9506+{
9507+ var results = [];
9508+ var t,tiddlers = store.getTiddlers("title");
9509+ for(t = 0; t < tiddlers.length; t++) {
9510+ if(!tiddlers[t].doNotSave())
9511+ results.push(this.externalizeTiddler(store, tiddlers[t]));
9512+ }
9513+ return results.join("\n");
9514+};
9515+
9516+//--
9517+//-- TW21Loader (inherits from LoaderBase)
9518+//--
9519+
9520+function TW21Loader() {}
9521+
9522+TW21Loader.prototype = new LoaderBase();
9523+
9524+TW21Loader.prototype.getTitle = function(store,node)
9525+{
9526+ var title = null;
9527+ if(node.getAttribute) {
9528+ title = node.getAttribute("title");
9529+ if(!title)
9530+ title = node.getAttribute("tiddler");
9531+ }
9532+ if(!title && node.id) {
9533+ var lenPrefix = store.idPrefix.length;
9534+ if(node.id.substr(0,lenPrefix) == store.idPrefix)
9535+ title = node.id.substr(lenPrefix);
9536+ }
9537+ return title;
9538+};
9539+
9540+TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node)
9541+{
9542+ var e = node.firstChild;
9543+ var text = null;
9544+ if(node.getAttribute("tiddler")) {
9545+ text = getNodeText(e).unescapeLineBreaks();
9546+ } else {
9547+ while(e.nodeName!="PRE" && e.nodeName!="pre") {
9548+ e = e.nextSibling;
9549+ }
9550+ text = e.innerHTML.replace(/\r/mg,"").htmlDecode();
9551+ }
9552+ var creator = node.getAttribute("creator");
9553+ var modifier = node.getAttribute("modifier");
9554+ var c = node.getAttribute("created");
9555+ var m = node.getAttribute("modified");
9556+ var created = c ? Date.convertFromYYYYMMDDHHMMSS(c) : version.date;
9557+ var modified = m ? Date.convertFromYYYYMMDDHHMMSS(m) : created;
9558+ var tags = node.getAttribute("tags");
9559+ var fields = {};
9560+ var i,attrs = node.attributes;
9561+ for(i = attrs.length-1; i >= 0; i--) {
9562+ var name = attrs[i].name;
9563+ if(attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
9564+ fields[name] = attrs[i].value.unescapeLineBreaks();
9565+ }
9566+ }
9567+ tiddler.assign(title,text,modifier,modified,tags,created,fields,creator);
9568+ return tiddler;
9569+};
9570+
9571+//--
9572+//-- TW21Saver (inherits from SaverBase)
9573+//--
9574+
9575+function TW21Saver() {}
9576+
9577+TW21Saver.prototype = new SaverBase();
9578+
9579+TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
9580+{
9581+ try {
9582+ var extendedAttributes = "";
9583+ var usePre = config.options.chkUsePreForStorage;
9584+ store.forEachField(tiddler,
9585+ function(tiddler,fieldName,value) {
9586+ // don't store stuff from the temp namespace
9587+ if(typeof value != "string")
9588+ value = "";
9589+ if(!fieldName.match(/^temp\./))
9590+ extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
9591+ },true);
9592+ var created = tiddler.created;
9593+ var modified = tiddler.modified;
9594+ var attributes = tiddler.creator ? ' creator="' + tiddler.creator.htmlEncode() + '"' : "";
9595+ attributes += tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
9596+ attributes += (usePre && created == version.date) ? "" :' created="' + created.convertToYYYYMMDDHHMM() + '"';
9597+ attributes += (usePre && modified == created) ? "" : ' modified="' + modified.convertToYYYYMMDDHHMM() +'"';
9598+ var tags = tiddler.getTags();
9599+ if(!usePre || tags)
9600+ attributes += ' tags="' + tags.htmlEncode() + '"';
9601+ return ('<div %0="%1"%2%3>%4</'+'div>').format([
9602+ usePre ? "title" : "tiddler",
9603+ tiddler.title.htmlEncode(),
9604+ attributes,
9605+ extendedAttributes,
9606+ usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode()
9607+ ]);
9608+ } catch (ex) {
9609+ throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
9610+ }
9611+};
9612+
9613+
9614+
9615+//]]>
9616+</script>
9617+
9618+<script id="jsdeprecatedArea" type="text/javascript">
9619+//<![CDATA[
9620+//--
9621+//-- Deprecated Crypto functions and associated conversion routines.
9622+//-- Use the jQuery.encoding functions directly instead.
9623+//--
9624+
9625+// Crypto 'namespace'
9626+function Crypto() {}
9627+
9628+// Convert a string to an array of big-endian 32-bit words
9629+Crypto.strToBe32s = function(str)
9630+{
9631+ return jQuery.encoding.strToBe32s(str);
9632+};
9633+
9634+// Convert an array of big-endian 32-bit words to a string
9635+Crypto.be32sToStr = function(be)
9636+{
9637+ return jQuery.encoding.be32sToStr(be);
9638+};
9639+
9640+// Convert an array of big-endian 32-bit words to a hex string
9641+Crypto.be32sToHex = function(be)
9642+{
9643+ return jQuery.encoding.be32sToHex(be);
9644+};
9645+
9646+// Return, in hex, the SHA-1 hash of a string
9647+Crypto.hexSha1Str = function(str)
9648+{
9649+ return jQuery.encoding.digests.hexSha1Str(str);
9650+};
9651+
9652+// Return the SHA-1 hash of a string
9653+Crypto.sha1Str = function(str)
9654+{
9655+ return jQuery.encoding.digests.sha1Str(str);
9656+};
9657+
9658+// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
9659+Crypto.sha1 = function(x,blen)
9660+{
9661+ return jQuery.encoding.digests.sha1(x,blen);
9662+};
9663+
9664+//--
9665+//-- Deprecated code
9666+//--
9667+
9668+// @Deprecated: Use createElementAndWikify and this.termRegExp instead
9669+config.formatterHelpers.charFormatHelper = function(w)
9670+{
9671+ w.subWikify(createTiddlyElement(w.output,this.element),this.terminator);
9672+};
9673+
9674+// @Deprecated: Use enclosedTextHelper and this.lookaheadRegExp instead
9675+config.formatterHelpers.monospacedByLineHelper = function(w)
9676+{
9677+ var lookaheadRegExp = new RegExp(this.lookahead,"mg");
9678+ lookaheadRegExp.lastIndex = w.matchStart;
9679+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
9680+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
9681+ var text = lookaheadMatch[1];
9682+ if(config.browser.isIE)
9683+ text = text.replace(/\n/g,"\r");
9684+ createTiddlyElement(w.output,"pre",null,null,text);
9685+ w.nextMatch = lookaheadRegExp.lastIndex;
9686+ }
9687+};
9688+
9689+// @Deprecated: Use <br> or <br /> instead of <<br>>
9690+config.macros.br = {};
9691+config.macros.br.handler = function(place)
9692+{
9693+ createTiddlyElement(place,"br");
9694+};
9695+
9696+// Find an entry in an array. Returns the array index or null
9697+// @Deprecated: Use indexOf instead
9698+Array.prototype.find = function(item)
9699+{
9700+ var i = this.indexOf(item);
9701+ return i == -1 ? null : i;
9702+};
9703+
9704+// Load a tiddler from an HTML DIV. The caller should make sure to later call Tiddler.changed()
9705+// @Deprecated: Use store.getLoader().internalizeTiddler instead
9706+Tiddler.prototype.loadFromDiv = function(divRef,title)
9707+{
9708+ return store.getLoader().internalizeTiddler(store,this,title,divRef);
9709+};
9710+
9711+// Format the text for storage in an HTML DIV
9712+// @Deprecated Use store.getSaver().externalizeTiddler instead.
9713+Tiddler.prototype.saveToDiv = function()
9714+{
9715+ return store.getSaver().externalizeTiddler(store,this);
9716+};
9717+
9718+// @Deprecated: Use store.allTiddlersAsHtml() instead
9719+function allTiddlersAsHtml()
9720+{
9721+ return store.allTiddlersAsHtml();
9722+}
9723+
9724+// @Deprecated: Use refreshPageTemplate instead
9725+function applyPageTemplate(title)
9726+{
9727+ refreshPageTemplate(title);
9728+}
9729+
9730+// @Deprecated: Use story.displayTiddlers instead
9731+function displayTiddlers(srcElement,titles,template,unused1,unused2,animate,unused3)
9732+{
9733+ story.displayTiddlers(srcElement,titles,template,animate);
9734+}
9735+
9736+// @Deprecated: Use story.displayTiddler instead
9737+function displayTiddler(srcElement,title,template,unused1,unused2,animate,unused3)
9738+{
9739+ story.displayTiddler(srcElement,title,template,animate);
9740+}
9741+
9742+// @Deprecated: Use functions on right hand side directly instead
9743+var createTiddlerPopup = Popup.create;
9744+var scrollToTiddlerPopup = Popup.show;
9745+var hideTiddlerPopup = Popup.remove;
9746+
9747+// @Deprecated: Use right hand side directly instead
9748+var regexpBackSlashEn = new RegExp("\\\\n","mg");
9749+var regexpBackSlash = new RegExp("\\\\","mg");
9750+var regexpBackSlashEss = new RegExp("\\\\s","mg");
9751+var regexpNewLine = new RegExp("\n","mg");
9752+var regexpCarriageReturn = new RegExp("\r","mg");
9753+
9754+//--
9755+//-- Deprecated FileAdaptor functions
9756+//--
9757+
9758+FileAdaptor.loadTiddlyWikiCallback = function(status,context,responseText,url,xhr)
9759+{
9760+ context.status = status;
9761+ if(!status) {
9762+ context.statusText = "Error reading file";
9763+ } else {
9764+ context.adaptor.store = new TiddlyWiki();
9765+ if(!context.adaptor.store.importTiddlyWiki(responseText)) {
9766+ context.statusText = config.messages.invalidFileError.format([url]);
9767+ context.status = false;
9768+ }
9769+ }
9770+ context.complete(context,context.userParams);
9771+};
9772+
9773+//--
9774+//-- Deprecated HTTP request code
9775+//-- Use the jQuery ajax functions directly instead
9776+//--
9777+
9778+function loadRemoteFile(url,callback,params)
9779+{
9780+ return httpReq("GET",url,callback,params);
9781+}
9782+
9783+function doHttp(type,url,data,contentType,username,password,callback,params,headers,allowCache)
9784+{
9785+ return httpReq(type,url,callback,params,headers,data,contentType,username,password,allowCache);
9786+}
9787+
9788+//--
9789+//-- Deprecated String functions
9790+//--
9791+
9792+// @Deprecated: no direct replacement, since not used in core code
9793+String.prototype.toJSONString = function()
9794+{
9795+ // Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org
9796+ var m = {
9797+ '\b': '\\b',
9798+ '\f': '\\f',
9799+ '\n': '\\n',
9800+ '\r': '\\r',
9801+ '\t': '\\t',
9802+ '"' : '\\"',
9803+ '\\': '\\\\'
9804+ };
9805+ var replaceFn = function(a,b) {
9806+ var c = m[b];
9807+ if(c)
9808+ return c;
9809+ c = b.charCodeAt();
9810+ return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
9811+ };
9812+ if(/["\\\x00-\x1f]/.test(this))
9813+ return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"';
9814+ return '"' + this + '"';
9815+};
9816+
9817+//--
9818+//-- Deprecated Tiddler code
9819+//--
9820+
9821+// @Deprecated: Use tiddlerToRssItem(tiddler,uri) instead
9822+Tiddler.prototype.toRssItem = function(uri)
9823+{
9824+ return tiddlerToRssItem(this,uri);
9825+};
9826+
9827+// @Deprecated: Use "<item>\n" + tiddlerToRssItem(tiddler,uri) + "\n</item>" instead
9828+Tiddler.prototype.saveToRss = function(uri)
9829+{
9830+ return "<item>\n" + tiddlerToRssItem(this,uri) + "\n</item>";
9831+};
9832+
9833+// @Deprecated: Use jQuery.encoding.digests.hexSha1Str instead
9834+Tiddler.prototype.generateFingerprint = function()
9835+{
9836+ return "0x" + Crypto.hexSha1Str(this.text);
9837+};
9838+
9839+//--
9840+//-- Deprecated Number functions
9841+//--
9842+
9843+// @Deprecated: no direct replacement, since not used in core code
9844+// Clamp a number to a range
9845+Number.prototype.clamp = function(min,max)
9846+{
9847+ var c = this;
9848+ if(c < min)
9849+ c = min;
9850+ if(c > max)
9851+ c = max;
9852+ return Number(c);
9853+};
9854+
9855+//--
9856+//-- Deprecated utility functions
9857+//-- Use the jQuery functions directly instead
9858+//--
9859+
9860+// Remove all children of a node
9861+function removeChildren(e)
9862+{
9863+ jQuery(e).empty();
9864+}
9865+
9866+// Remove a node and all it's children
9867+function removeNode(e)
9868+{
9869+ jQuery(e).remove();
9870+}
9871+
9872+// Return the content of an element as plain text with no formatting
9873+function getPlainText(e)
9874+{
9875+ return jQuery(e).text();
9876+}
9877+
9878+function addClass(e,className)
9879+{
9880+ jQuery(e).addClass(className);
9881+}
9882+
9883+function removeClass(e,className)
9884+{
9885+ jQuery(e).removeClass(className);
9886+}
9887+
9888+function hasClass(e,className)
9889+{
9890+ return jQuery(e).hasClass(className);
9891+}
9892+
9893+//--
9894+//-- Deprecated Wikifier code
9895+//--
9896+
9897+function wikifyPlain(title,theStore,limit)
9898+{
9899+ if(!theStore)
9900+ theStore = store;
9901+ if(theStore.tiddlerExists(title) || theStore.isShadowTiddler(title)) {
9902+ return wikifyPlainText(theStore.getTiddlerText(title),limit,tiddler);
9903+ } else {
9904+ return "";
9905+ }
9906+}
9907+
9908+
9909+//]]>
9910+</script>
9911+<script id="jslibArea" type="text/javascript">
9912+//<![CDATA[
9913+/*! jQuery v1.8.3 jquery.com | jquery.org/license */
9914+(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r<i;r++)v.event.add(t,n,u[n][r])}o.data&&(o.data=v.extend({},o.data))}function Ot(e,t){var n;if(t.nodeType!==1)return;t.clearAttributes&&t.clearAttributes(),t.mergeAttributes&&t.mergeAttributes(e),n=t.nodeName.toLowerCase(),n==="object"?(t.parentNode&&(t.outerHTML=e.outerHTML),v.support.html5Clone&&e.innerHTML&&!v.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):n==="input"&&Et.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):n==="option"?t.selected=e.defaultSelected:n==="input"||n==="textarea"?t.defaultValue=e.defaultValue:n==="script"&&t.text!==e.text&&(t.text=e.text),t.removeAttribute(v.expando)}function Mt(e){return typeof e.getElementsByTagName!="undefined"?e.getElementsByTagName("*"):typeof e.querySelectorAll!="undefined"?e.querySelectorAll("*"):[]}function _t(e){Et.test(e.type)&&(e.defaultChecked=e.checked)}function Qt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Jt.length;while(i--){t=Jt[i]+n;if(t in e)return t}return r}function Gt(e,t){return e=t||e,v.css(e,"display")==="none"||!v.contains(e.ownerDocument,e)}function Yt(e,t){var n,r,i=[],s=0,o=e.length;for(;s<o;s++){n=e[s];if(!n.style)continue;i[s]=v._data(n,"olddisplay"),t?(!i[s]&&n.style.display==="none"&&(n.style.display=""),n.style.display===""&&Gt(n)&&(i[s]=v._data(n,"olddisplay",nn(n.nodeName)))):(r=Dt(n,"display"),!i[s]&&r!=="none"&&v._data(n,"olddisplay",r))}for(s=0;s<o;s++){n=e[s];if(!n.style)continue;if(!t||n.style.display==="none"||n.style.display==="")n.style.display=t?i[s]||"":"none"}return e}function Zt(e,t,n){var r=Rt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function en(e,t,n,r){var i=n===(r?"border":"content")?4:t==="width"?1:0,s=0;for(;i<4;i+=2)n==="margin"&&(s+=v.css(e,n+$t[i],!0)),r?(n==="content"&&(s-=parseFloat(Dt(e,"padding"+$t[i]))||0),n!=="margin"&&(s-=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0)):(s+=parseFloat(Dt(e,"padding"+$t[i]))||0,n!=="padding"&&(s+=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0));return s}function tn(e,t,n){var r=t==="width"?e.offsetWidth:e.offsetHeight,i=!0,s=v.support.boxSizing&&v.css(e,"boxSizing")==="border-box";if(r<=0||r==null){r=Dt(e,t);if(r<0||r==null)r=e.style[t];if(Ut.test(r))return r;i=s&&(v.support.boxSizingReliable||r===e.style[t]),r=parseFloat(r)||0}return r+en(e,t,n||(s?"border":"content"),i)+"px"}function nn(e){if(Wt[e])return Wt[e];var t=v("<"+e+">").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write("<!doctype html><html><body>"),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u<a;u++)r=o[u],s=/^\+/.test(r),s&&(r=r.substr(1)||"*"),i=e[r]=e[r]||[],i[s?"unshift":"push"](n)}}function kn(e,n,r,i,s,o){s=s||n.dataTypes[0],o=o||{},o[s]=!0;var u,a=e[s],f=0,l=a?a.length:0,c=e===Sn;for(;f<l&&(c||!u);f++)u=a[f](n,r,i),typeof u=="string"&&(!c||o[u]?u=t:(n.dataTypes.unshift(u),u=kn(e,n,r,i,u,o)));return(c||!u)&&!o["*"]&&(u=kn(e,n,r,i,"*",o)),u}function Ln(e,n){var r,i,s=v.ajaxSettings.flatOptions||{};for(r in n)n[r]!==t&&((s[r]?e:i||(i={}))[r]=n[r]);i&&v.extend(!0,e,i)}function An(e,n,r){var i,s,o,u,a=e.contents,f=e.dataTypes,l=e.responseFields;for(s in l)s in r&&(n[l[s]]=r[s]);while(f[0]==="*")f.shift(),i===t&&(i=e.mimeType||n.getResponseHeader("content-type"));if(i)for(s in a)if(a[s]&&a[s].test(i)){f.unshift(s);break}if(f[0]in r)o=f[0];else{for(s in r){if(!f[0]||e.converters[s+" "+f[0]]){o=s;break}u||(u=s)}o=o||u}if(o)return o!==f[0]&&f.unshift(o),r[o]}function On(e,t){var n,r,i,s,o=e.dataTypes.slice(),u=o[0],a={},f=0;e.dataFilter&&(t=e.dataFilter(t,e.dataType));if(o[1])for(n in e.converters)a[n.toLowerCase()]=e.converters[n];for(;i=o[++f];)if(i!=="*"){if(u!=="*"&&u!==i){n=a[u+" "+i]||a["* "+i];if(!n)for(r in a){s=r.split(" ");if(s[1]===i){n=a[u+" "+s[0]]||a["* "+s[0]];if(n){n===!0?n=a[r]:a[r]!==!0&&(i=s[0],o.splice(f--,0,i));break}}}if(n!==!0)if(n&&e["throws"])t=n(t);else try{t=n(t)}catch(l){return{state:"parsererror",error:n?l:"No conversion from "+u+" to "+i}}}u=i}return{state:"success",data:t}}function Fn(){try{return new e.XMLHttpRequest}catch(t){}}function In(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function $n(){return setTimeout(function(){qn=t},0),qn=v.now()}function Jn(e,t){v.each(t,function(t,n){var r=(Vn[t]||[]).concat(Vn["*"]),i=0,s=r.length;for(;i<s;i++)if(r[i].call(e,t,n))return})}function Kn(e,t,n){var r,i=0,s=0,o=Xn.length,u=v.Deferred().always(function(){delete a.elem}),a=function(){var t=qn||$n(),n=Math.max(0,f.startTime+f.duration-t),r=n/f.duration||0,i=1-r,s=0,o=f.tweens.length;for(;s<o;s++)f.tweens[s].run(i);return u.notifyWith(e,[f,i,n]),i<1&&o?n:(u.resolveWith(e,[f]),!1)},f=u.promise({elem:e,props:v.extend({},t),opts:v.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:qn||$n(),duration:n.duration,tweens:[],createTween:function(t,n,r){var i=v.Tween(e,f.opts,t,n,f.opts.specialEasing[t]||f.opts.easing);return f.tweens.push(i),i},stop:function(t){var n=0,r=t?f.tweens.length:0;for(;n<r;n++)f.tweens[n].run(1);return t?u.resolveWith(e,[f,t]):u.rejectWith(e,[f,t]),this}}),l=f.props;Qn(l,f.opts.specialEasing);for(;i<o;i++){r=Xn[i].call(f,e,l,f.opts);if(r)return r}return Jn(f,l),v.isFunction(f.opts.start)&&f.opts.start.call(e,f),v.fx.timer(v.extend(a,{anim:f,queue:f.opts.queue,elem:e})),f.progress(f.opts.progress).done(f.opts.done,f.opts.complete).fail(f.opts.fail).always(f.opts.always)}function Qn(e,t){var n,r,i,s,o;for(n in e){r=v.camelCase(n),i=t[r],s=e[n],v.isArray(s)&&(i=s[1],s=e[n]=s[0]),n!==r&&(e[r]=s,delete e[n]),o=v.cssHooks[r];if(o&&"expand"in o){s=o.expand(s),delete e[r];for(n in s)n in e||(e[n]=s[n],t[n]=i)}else t[r]=i}}function Gn(e,t,n){var r,i,s,o,u,a,f,l,c,h=this,p=e.style,d={},m=[],g=e.nodeType&&Gt(e);n.queue||(l=v._queueHooks(e,"fx"),l.unqueued==null&&(l.unqueued=0,c=l.empty.fire,l.empty.fire=function(){l.unqueued||c()}),l.unqueued++,h.always(function(){h.always(function(){l.unqueued--,v.queue(e,"fx").length||l.empty.fire()})})),e.nodeType===1&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],v.css(e,"display")==="inline"&&v.css(e,"float")==="none"&&(!v.support.inlineBlockNeedsLayout||nn(e.nodeName)==="inline"?p.display="inline-block":p.zoom=1)),n.overflow&&(p.overflow="hidden",v.support.shrinkWrapBlocks||h.done(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t){s=t[r];if(Un.exec(s)){delete t[r],a=a||s==="toggle";if(s===(g?"hide":"show"))continue;m.push(r)}}o=m.length;if(o){u=v._data(e,"fxshow")||v._data(e,"fxshow",{}),"hidden"in u&&(g=u.hidden),a&&(u.hidden=!g),g?v(e).show():h.done(function(){v(e).hide()}),h.done(function(){var t;v.removeData(e,"fxshow",!0);for(t in d)v.style(e,t,d[t])});for(r=0;r<o;r++)i=m[r],f=h.createTween(i,g?u[i]:0),d[i]=u[i]||v.style(e,i),i in u||(u[i]=f.start,g&&(f.end=f.start,f.start=i==="width"||i==="height"?1:0))}}function Yn(e,t,n,r,i){return new Yn.prototype.init(e,t,n,r,i)}function Zn(e,t){var n,r={height:e},i=0;t=t?1:0;for(;i<4;i+=2-t)n=$t[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function tr(e){return v.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:!1}var n,r,i=e.document,s=e.location,o=e.navigator,u=e.jQuery,a=e.$,f=Array.prototype.push,l=Array.prototype.slice,c=Array.prototype.indexOf,h=Object.prototype.toString,p=Object.prototype.hasOwnProperty,d=String.prototype.trim,v=function(e,t){return new v.fn.init(e,t,n)},m=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,g=/\S/,y=/\s+/,b=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,w=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a<f;a++)if((e=arguments[a])!=null)for(n in e){r=u[n],i=e[n];if(u===i)continue;l&&i&&(v.isPlainObject(i)||(s=v.isArray(i)))?(s?(s=!1,o=r&&v.isArray(r)?r:[]):o=r&&v.isPlainObject(r)?r:{},u[n]=v.extend(l,o,i)):i!==t&&(u[n]=i)}return u},v.extend({noConflict:function(t){return e.$===v&&(e.$=a),t&&e.jQuery===v&&(e.jQuery=u),v},isReady:!1,readyWait:1,holdReady:function(e){e?v.readyWait++:v.ready(!0)},ready:function(e){if(e===!0?--v.readyWait:v.isReady)return;if(!i.body)return setTimeout(v.ready,1);v.isReady=!0;if(e!==!0&&--v.readyWait>0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s<o;)if(n.apply(e[s++],r)===!1)break}else if(u){for(i in e)if(n.call(e[i],i,e[i])===!1)break}else for(;s<o;)if(n.call(e[s],s,e[s++])===!1)break;return e},trim:d&&!d.call("\ufeff\u00a0")?function(e){return e==null?"":d.call(e)}:function(e){return e==null?"":(e+"").replace(b,"")},makeArray:function(e,t){var n,r=t||[];return e!=null&&(n=v.type(e),e.length==null||n==="string"||n==="function"||n==="regexp"||v.isWindow(e)?f.call(r,e):v.merge(r,e)),r},inArray:function(e,t,n){var r;if(t){if(c)return c.call(t,e,n);r=t.length,n=n?n<0?Math.max(0,r+n):n:0;for(;n<r;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,s=0;if(typeof r=="number")for(;s<r;s++)e[i++]=n[s];else while(n[s]!==t)e[i++]=n[s++];return e.length=i,e},grep:function(e,t,n){var r,i=[],s=0,o=e.length;n=!!n;for(;s<o;s++)r=!!t(e[s],s),n!==r&&i.push(e[s]);return i},map:function(e,n,r){var i,s,o=[],u=0,a=e.length,f=e instanceof v||a!==t&&typeof a=="number"&&(a>0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u<a;u++)i=n(e[u],u,r),i!=null&&(o[o.length]=i);else for(s in e)i=n(e[s],s,r),i!=null&&(o[o.length]=i);return o.concat.apply([],o)},guid:1,proxy:function(e,n){var r,i,s;return typeof n=="string"&&(r=e[n],n=e,e=r),v.isFunction(e)?(i=l.call(arguments,2),s=function(){return e.apply(n,i.concat(l.call(arguments)))},s.guid=e.guid=e.guid||v.guid++,s):t},access:function(e,n,r,i,s,o,u){var a,f=r==null,l=0,c=e.length;if(r&&typeof r=="object"){for(l in r)v.access(e,n,l,r[l],1,o,i);s=1}else if(i!==t){a=u===t&&v.isFunction(i),f&&(a?(a=n,n=function(e,t,n){return a.call(v(e),n)}):(n.call(e,i),n=null));if(n)for(;l<c;l++)n(e[l],r,a?i.call(e[l],l,n(e[l],r)):i,u);s=1}return s?e:f?n.call(e):c?n(e[0],r):o},now:function(){return(new Date).getTime()}}),v.ready.promise=function(t){if(!r){r=v.Deferred();if(i.readyState==="complete")setTimeout(v.ready,1);else if(i.addEventListener)i.addEventListener("DOMContentLoaded",A,!1),e.addEventListener("load",v.ready,!1);else{i.attachEvent("onreadystatechange",A),e.attachEvent("onload",v.ready);var n=!1;try{n=e.frameElement==null&&i.documentElement}catch(s){}n&&n.doScroll&&function o(){if(!v.isReady){try{n.doScroll("left")}catch(e){return setTimeout(o,50)}v.ready()}}()}}return r.promise(t)},v.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(e,t){O["[object "+t+"]"]=t.toLowerCase()}),n=v(i);var M={};v.Callbacks=function(e){e=typeof e=="string"?M[e]||_(e):v.extend({},e);var n,r,i,s,o,u,a=[],f=!e.once&&[],l=function(t){n=e.memory&&t,r=!0,u=s||0,s=0,o=a.length,i=!0;for(;a&&u<o;u++)if(a[u].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}i=!1,a&&(f?f.length&&l(f.shift()):n?a=[]:c.disable())},c={add:function(){if(a){var t=a.length;(function r(t){v.each(t,function(t,n){var i=v.type(n);i==="function"?(!e.unique||!c.has(n))&&a.push(n):n&&n.length&&i!=="string"&&r(n)})})(arguments),i?o=a.length:n&&(s=t,l(n))}return this},remove:function(){return a&&v.each(arguments,function(e,t){var n;while((n=v.inArray(t,a,n))>-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t<r;t++)n[t]&&v.isFunction(n[t].promise)?n[t].promise().done(o(t,f,n)).fail(s.reject).progress(o(t,a,u)):--i}return i||s.resolveWith(f,n),s.promise()}}),v.support=function(){var t,n,r,s,o,u,a,f,l,c,h,p=i.createElement("div");p.setAttribute("className","t"),p.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="<table><tr><td></td><td>t</td></tr></table>",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="<div></div>",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i<s;i++)delete r[t[i]];if(!(n?B:v.isEmptyObject)(r))return}}if(!n){delete u[a].data;if(!B(u[a]))return}o?v.cleanData([e],!0):v.support.deleteExpando||u!=u.window?delete u[a]:u[a]=null},_data:function(e,t,n){return v.data(e,t,n,!0)},acceptData:function(e){var t=e.nodeName&&v.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),v.fn.extend({data:function(e,n){var r,i,s,o,u,a=this[0],f=0,l=null;if(e===t){if(this.length){l=v.data(a);if(a.nodeType===1&&!v._data(a,"parsedAttrs")){s=a.attributes;for(u=s.length;f<u;f++)o=s[f].name,o.indexOf("data-")||(o=v.camelCase(o.substring(5)),H(a,o,l[o]));v._data(a,"parsedAttrs",!0)}}return l}return typeof e=="object"?this.each(function(){v.data(this,e)}):(r=e.split(".",2),r[1]=r[1]?"."+r[1]:"",i=r[1]+"!",v.access(this,function(n){if(n===t)return l=this.triggerHandler("getData"+i,[r[0]]),l===t&&a&&(l=v.data(a,e),l=H(a,e,l)),l===t&&r[1]?this.data(r[0]):l;r[1]=n,this.each(function(){var t=v(this);t.triggerHandler("setData"+i,r),v.data(this,e,n),t.triggerHandler("changeData"+i,r)})},null,n,arguments.length>1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length<r?v.queue(this[0],e):n===t?this:this.each(function(){var t=v.queue(this,e,n);v._queueHooks(this,e),e==="fx"&&t[0]!=="inprogress"&&v.dequeue(this,e)})},dequeue:function(e){return this.each(function(){v.dequeue(this,e)})},delay:function(e,t){return e=v.fx?v.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,s=v.Deferred(),o=this,u=this.length,a=function(){--i||s.resolveWith(o,[o])};typeof e!="string"&&(n=e,e=t),e=e||"fx";while(u--)r=v._data(o[u],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(a));return a(),s.promise(n)}});var j,F,I,q=/[\t\r\n]/g,R=/\r/g,U=/^(?:button|input)$/i,z=/^(?:button|input|object|select|textarea)$/i,W=/^a(?:rea|)$/i,X=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,V=v.support.getSetAttribute;v.fn.extend({attr:function(e,t){return v.access(this,v.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n<r;n++){i=this[n];if(i.nodeType===1)if(!i.className&&t.length===1)i.className=e;else{s=" "+i.className+" ";for(o=0,u=t.length;o<u;o++)s.indexOf(" "+t[o]+" ")<0&&(s+=t[o]+" ");i.className=v.trim(s)}}}return this},removeClass:function(e){var n,r,i,s,o,u,a;if(v.isFunction(e))return this.each(function(t){v(this).removeClass(e.call(this,t,this.className))});if(e&&typeof e=="string"||e===t){n=(e||"").split(y);for(u=0,a=this.length;u<a;u++){i=this[u];if(i.nodeType===1&&i.className){r=(" "+i.className+" ").replace(q," ");for(s=0,o=n.length;s<o;s++)while(r.indexOf(" "+n[s]+" ")>=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n<r;n++)if(this[n].nodeType===1&&(" "+this[n].className+" ").replace(q," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a<u;a++){n=r[a];if((n.selected||a===i)&&(v.support.optDisabled?!n.disabled:n.getAttribute("disabled")===null)&&(!n.parentNode.disabled||!v.nodeName(n.parentNode,"optgroup"))){t=v(n).val();if(s)return t;o.push(t)}}return o},set:function(e,t){var n=v.makeArray(t);return v(e).find("option").each(function(){this.selected=v.inArray(v(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o<r.length;o++)i=r[o],i&&(n=v.propFix[i]||i,s=X.test(i),s||v.attr(e,i,""),e.removeAttribute(V?i:n),s&&n in e&&(e[n]=!1))}},attrHooks:{type:{set:function(e,t){if(U.test(e.nodeName)&&e.parentNode)v.error("type property can't be changed");else if(!v.support.radioValue&&t==="radio"&&v.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}},value:{get:function(e,t){return j&&v.nodeName(e,"button")?j.get(e,t):t in e?e.value:null},set:function(e,t,n){if(j&&v.nodeName(e,"button"))return j.set(e,t,n);e.value=t}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,s,o,u=e.nodeType;if(!e||u===3||u===8||u===2)return;return o=u!==1||!v.isXMLDoc(e),o&&(n=v.propFix[n]||n,s=v.propHooks[n]),r!==t?s&&"set"in s&&(i=s.set(e,r,n))!==t?i:e[n]=r:s&&"get"in s&&(i=s.get(e,n))!==null?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):z.test(e.nodeName)||W.test(e.nodeName)&&e.href?0:t}}}}),F={get:function(e,n){var r,i=v.prop(e,n);return i===!0||typeof i!="boolean"&&(r=e.getAttributeNode(n))&&r.nodeValue!==!1?n.toLowerCase():t},set:function(e,t,n){var r;return t===!1?v.removeAttr(e,n):(r=v.propFix[n]||n,r in e&&(e[r]=!0),e.setAttribute(n,n.toLowerCase())),n}},V||(I={name:!0,id:!0,coords:!0},j=v.valHooks.button={get:function(e,n){var r;return r=e.getAttributeNode(n),r&&(I[n]?r.value!=="":r.specified)?r.value:t},set:function(e,t,n){var r=e.getAttributeNode(n);return r||(r=i.createAttribute(n),e.setAttributeNode(r)),r.value=t+""}},v.each(["width","height"],function(e,t){v.attrHooks[t]=v.extend(v.attrHooks[t],{set:function(e,n){if(n==="")return e.setAttribute(t,"auto"),n}})}),v.attrHooks.contenteditable={get:j.get,set:function(e,t,n){t===""&&(t="false"),j.set(e,t,n)}}),v.support.hrefNormalized||v.each(["href","src","width","height"],function(e,n){v.attrHooks[n]=v.extend(v.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return r===null?t:r}})}),v.support.style||(v.attrHooks.style={get:function(e){return e.style.cssText.toLowerCase()||t},set:function(e,t){return e.style.cssText=t+""}}),v.support.optSelected||(v.propHooks.selected=v.extend(v.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),v.support.enctype||(v.propFix.enctype="encoding"),v.support.checkOn||v.each(["radio","checkbox"],function(){v.valHooks[this]={get:function(e){return e.getAttribute("value")===null?"on":e.value}}}),v.each(["radio","checkbox"],function(){v.valHooks[this]=v.extend(v.valHooks[this],{set:function(e,t){if(v.isArray(t))return e.checked=v.inArray(v(e).val(),t)>=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f<n.length;f++){l=J.exec(n[f])||[],c=l[1],h=(l[2]||"").split(".").sort(),g=v.event.special[c]||{},c=(s?g.delegateType:g.bindType)||c,g=v.event.special[c]||{},p=v.extend({type:c,origType:l[1],data:i,handler:r,guid:r.guid,selector:s,needsContext:s&&v.expr.match.needsContext.test(s),namespace:h.join(".")},d),m=a[c];if(!m){m=a[c]=[],m.delegateCount=0;if(!g.setup||g.setup.call(e,i,h,u)===!1)e.addEventListener?e.addEventListener(c,u,!1):e.attachEvent&&e.attachEvent("on"+c,u)}g.add&&(g.add.call(e,p),p.handler.guid||(p.handler.guid=r.guid)),s?m.splice(m.delegateCount++,0,p):m.push(p),v.event.global[c]=!0}e=null},global:{},remove:function(e,t,n,r,i){var s,o,u,a,f,l,c,h,p,d,m,g=v.hasData(e)&&v._data(e);if(!g||!(h=g.events))return;t=v.trim(Z(t||"")).split(" ");for(s=0;s<t.length;s++){o=J.exec(t[s])||[],u=a=o[1],f=o[2];if(!u){for(u in h)v.event.remove(e,u+t[s],n,r,!0);continue}p=v.event.special[u]||{},u=(r?p.delegateType:p.bindType)||u,d=h[u]||[],l=d.length,f=f?new RegExp("(^|\\.)"+f.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(c=0;c<d.length;c++)m=d[c],(i||a===m.origType)&&(!n||n.guid===m.guid)&&(!f||f.test(m.namespace))&&(!r||r===m.selector||r==="**"&&m.selector)&&(d.splice(c--,1),m.selector&&d.delegateCount--,p.remove&&p.remove.call(e,m));d.length===0&&l!==d.length&&((!p.teardown||p.teardown.call(e,f,g.handle)===!1)&&v.removeEvent(e,u,g.handle),delete h[u])}v.isEmptyObject(h)&&(delete g.handle,v.removeData(e,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(n,r,s,o){if(!s||s.nodeType!==3&&s.nodeType!==8){var u,a,f,l,c,h,p,d,m,g,y=n.type||n,b=[];if(Y.test(y+v.event.triggered))return;y.indexOf("!")>=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f<m.length&&!n.isPropagationStopped();f++)l=m[f][0],n.type=m[f][1],d=(v._data(l,"events")||{})[n.type]&&v._data(l,"handle"),d&&d.apply(l,r),d=h&&l[h],d&&v.acceptData(l)&&d.apply&&d.apply(l,r)===!1&&n.preventDefault();return n.type=y,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(s.ownerDocument,r)===!1)&&(y!=="click"||!v.nodeName(s,"a"))&&v.acceptData(s)&&h&&s[y]&&(y!=="focus"&&y!=="blur"||n.target.offsetWidth!==0)&&!v.isWindow(s)&&(c=s[h],c&&(s[h]=null),v.event.triggered=y,s[y](),v.event.triggered=t,c&&(s[h]=c)),n.result}return},dispatch:function(n){n=v.event.fix(n||e.event);var r,i,s,o,u,a,f,c,h,p,d=(v._data(this,"events")||{})[n.type]||[],m=d.delegateCount,g=l.call(arguments),y=!n.exclusive&&!n.namespace,b=v.event.special[n.type]||{},w=[];g[0]=n,n.delegateTarget=this;if(b.preDispatch&&b.preDispatch.call(this,n)===!1)return;if(m&&(!n.button||n.type!=="click"))for(s=n.target;s!=this;s=s.parentNode||this)if(s.disabled!==!0||n.type!=="click"){u={},f=[];for(r=0;r<m;r++)c=d[r],h=c.selector,u[h]===t&&(u[h]=c.needsContext?v(h,this).index(s)>=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r<w.length&&!n.isPropagationStopped();r++){a=w[r],n.currentTarget=a.elem;for(i=0;i<a.matches.length&&!n.isImmediatePropagationStopped();i++){c=a.matches[i];if(y||!n.namespace&&!c.namespace||n.namespace_re&&n.namespace_re.test(c.namespace))n.data=c.data,n.handleObj=c,o=((v.event.special[c.origType]||{}).handle||c.handler).apply(a.elem,g),o!==t&&(n.result=o,o===!1&&(n.preventDefault(),n.stopPropagation()))}}return b.postDispatch&&b.postDispatch.call(this,n),n.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return e.which==null&&(e.which=t.charCode!=null?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,s,o,u=n.button,a=n.fromElement;return e.pageX==null&&n.clientX!=null&&(r=e.target.ownerDocument||i,s=r.documentElement,o=r.body,e.pageX=n.clientX+(s&&s.scrollLeft||o&&o.scrollLeft||0)-(s&&s.clientLeft||o&&o.clientLeft||0),e.pageY=n.clientY+(s&&s.scrollTop||o&&o.scrollTop||0)-(s&&s.clientTop||o&&o.clientTop||0)),!e.relatedTarget&&a&&(e.relatedTarget=a===e.target?n.toElement:a),!e.which&&u!==t&&(e.which=u&1?1:u&2?3:u&4?2:0),e}},fix:function(e){if(e[v.expando])return e;var t,n,r=e,s=v.event.fixHooks[e.type]||{},o=s.props?this.props.concat(s.props):this.props;e=v.Event(r);for(t=o.length;t;)n=o[--t],e[n]=r[n];return e.target||(e.target=r.srcElement||i),e.target.nodeType===3&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,r):e},special:{load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(e,t,n){v.isWindow(this)&&(this.onbeforeunload=n)},teardown:function(e,t){this.onbeforeunload===t&&(this.onbeforeunload=null)}}},simulate:function(e,t,n,r){var i=v.extend(new v.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?v.event.trigger(i,null,t):v.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},v.event.handle=v.event.dispatch,v.removeEvent=i.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]=="undefined"&&(e[r]=null),e.detachEvent(r,n))},v.Event=function(e,t){if(!(this instanceof v.Event))return new v.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?tt:et):this.type=e,t&&v.extend(this,t),this.timeStamp=e&&e.timeStamp||v.now(),this[v.expando]=!0},v.Event.prototype={preventDefault:function(){this.isDefaultPrevented=tt;var e=this.originalEvent;if(!e)return;e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=tt;var e=this.originalEvent;if(!e)return;e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=tt,this.stopPropagation()},isDefaultPrevented:et,isPropagationStopped:et,isImmediatePropagationStopped:et},v.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){v.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,s=e.handleObj,o=s.selector;if(!i||i!==r&&!v.contains(r,i))e.type=s.origType,n=s.handler.apply(this,arguments),e.type=t;return n}}}),v.support.submitBubbles||(v.event.special.submit={setup:function(){if(v.nodeName(this,"form"))return!1;v.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=v.nodeName(n,"input")||v.nodeName(n,"button")?n.form:t;r&&!v._data(r,"_submit_attached")&&(v.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),v._data(r,"_submit_attached",!0))})},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&v.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){if(v.nodeName(this,"form"))return!1;v.event.remove(this,"._submit")}}),v.support.changeBubbles||(v.event.special.change={setup:function(){if($.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")v.event.add(this,"propertychange._change",function(e){e.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),v.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),v.event.simulate("change",this,e,!0)});return!1}v.event.add(this,"beforeactivate._change",function(e){var t=e.target;$.test(t.nodeName)&&!v._data(t,"_change_attached")&&(v.event.add(t,"change._change",function(e){this.parentNode&&!e.isSimulated&&!e.isTrigger&&v.event.simulate("change",this.parentNode,e,!0)}),v._data(t,"_change_attached",!0))})},handle:function(e){var t=e.target;if(this!==t||e.isSimulated||e.isTrigger||t.type!=="radio"&&t.type!=="checkbox")return e.handleObj.handler.apply(this,arguments)},teardown:function(){return v.event.remove(this,"._change"),!$.test(this.nodeName)}}),v.support.focusinBubbles||v.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){v.event.simulate(t,e.target,v.event.fix(e),!0)};v.event.special[t]={setup:function(){n++===0&&i.addEventListener(e,r,!0)},teardown:function(){--n===0&&i.removeEventListener(e,r,!0)}}}),v.fn.extend({on:function(e,n,r,i,s){var o,u;if(typeof e=="object"){typeof n!="string"&&(r=r||n,n=t);for(u in e)this.on(u,n,r,e[u],s);return this}r==null&&i==null?(i=n,r=n=t):i==null&&(typeof n=="string"?(i=r,r=t):(i=r,r=n,n=t));if(i===!1)i=et;else if(!i)return this;return s===1&&(o=i,i=function(e){return v().off(e),o.apply(this,arguments)},i.guid=o.guid||(o.guid=v.guid++)),this.each(function(){v.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,s;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,v(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if(typeof e=="object"){for(s in e)this.off(s,n,e[s]);return this}if(n===!1||typeof n=="function")r=n,n=t;return r===!1&&(r=et),this.each(function(){v.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},live:function(e,t,n){return v(this.context).on(e,this.selector,t,n),this},die:function(e,t){return v(this.context).off(e,this.selector||"**",t),this},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return arguments.length===1?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){v.event.trigger(e,t,this)})},triggerHandler:function(e,t){if(this[0])return v.event.trigger(e,t,this[0],!0)},toggle:function(e){var t=arguments,n=e.guid||v.guid++,r=0,i=function(n){var i=(v._data(this,"lastToggle"+e.guid)||0)%r;return v._data(this,"lastToggle"+e.guid,i+1),n.preventDefault(),t[i].apply(this,arguments)||!1};i.guid=n;while(r<t.length)t[r++].guid=n;return this.click(i)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),v.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){v.fn[t]=function(e,n){return n==null&&(n=e,e=null),arguments.length>0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u<a;u++)if(s=e[u])if(!n||n(s,r,i))o.push(s),f&&t.push(u);return o}function ct(e,t,n,r,i,s){return r&&!r[d]&&(r=ct(r)),i&&!i[d]&&(i=ct(i,s)),N(function(s,o,u,a){var f,l,c,h=[],p=[],d=o.length,v=s||dt(t||"*",u.nodeType?[u]:u,[]),m=e&&(s||!t)?lt(v,h,e,u,a):v,g=n?i||(s?e:d||r)?[]:o:m;n&&n(m,g,u,a);if(r){f=lt(g,p),r(f,[],u,a),l=f.length;while(l--)if(c=f[l])g[p[l]]=!(m[p[l]]=c)}if(s){if(i||e){if(i){f=[],l=g.length;while(l--)(c=g[l])&&f.push(m[l]=c);i(null,g=[],f,a)}l=g.length;while(l--)(c=g[l])&&(f=i?T.call(s,c):h[l])>-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a<s;a++)if(n=i.relative[e[a].type])h=[at(ft(h),n)];else{n=i.filter[e[a].type].apply(null,e[a].matches);if(n[d]){r=++a;for(;r<s;r++)if(i.relative[e[r].type])break;return ct(a>1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a<r&&ht(e.slice(a,r)),r<s&&ht(e=e.slice(r)),r<s&&e.join(""))}h.push(n)}return ft(h)}function pt(e,t){var r=t.length>0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r<i;r++)nt(e,t[r],n);return n}function vt(e,t,n,r,s){var o,u,f,l,c,h=ut(e),p=h.length;if(!r&&h.length===1){u=h[0]=h[0].slice(0);if(u.length>2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;t<n;t++)if(this[t]===e)return t;return-1},N=function(e,t){return e[d]=t==null||t,e},C=function(){var e={},t=[];return N(function(n,r){return t.push(n)>i.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="<a name='"+d+"'></a><div name='"+d+"'></div>",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:st(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:st(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},f=y.compareDocumentPosition?function(e,t){return e===t?(l=!0,0):(!e.compareDocumentPosition||!t.compareDocumentPosition?e.compareDocumentPosition:e.compareDocumentPosition(t)&4)?-1:1}:function(e,t){if(e===t)return l=!0,0;if(e.sourceIndex&&t.sourceIndex)return e.sourceIndex-t.sourceIndex;var n,r,i=[],s=[],o=e.parentNode,u=t.parentNode,a=o;if(o===u)return ot(e,t);if(!o)return-1;if(!u)return 1;while(a)i.unshift(a),a=a.parentNode;a=u;while(a)s.unshift(a),a=a.parentNode;n=i.length,r=s.length;for(var f=0;f<n&&f<r;f++)if(i[f]!==s[f])return ot(i[f],s[f]);return f===n?ot(e,s[f],-1):ot(i[f],t,1)},[0,0].sort(f),h=!l,nt.uniqueSort=function(e){var t,n=[],r=1,i=0;l=h,e.sort(f);if(l){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e},nt.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},a=nt.compile=function(e,t){var n,r=[],i=[],s=A[d][e+" "];if(!s){t||(t=ut(e)),n=t.length;while(n--)s=ht(t[n]),s[d]?r.push(s):i.push(s);s=A(e,pt(i,r))}return s},g.querySelectorAll&&function(){var e,t=vt,n=/'|\\/g,r=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,i=[":focus"],s=[":active"],u=y.matchesSelector||y.mozMatchesSelector||y.webkitMatchesSelector||y.oMatchesSelector||y.msMatchesSelector;K(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="<p test=''></p>",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="<input type='hidden'/>",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t<n;t++)if(v.contains(u[t],this))return!0});o=this.pushStack("","find",e);for(t=0,n=this.length;t<n;t++){r=o.length,v.find(e,this[t],o);if(t>0)for(i=r;i<o.length;i++)for(s=0;s<r;s++)if(o[s]===o[i]){o.splice(i--,1);break}}return o},has:function(e){var t,n=v(e,this),r=n.length;return this.filter(function(){for(t=0;t<r;t++)if(v.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1),"not",e)},filter:function(e){return this.pushStack(ft(this,e,!0),"filter",e)},is:function(e){return!!e&&(typeof e=="string"?st.test(e)?v(e,this.context).index(this[0])>=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r<i;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&n.nodeType!==11){if(o?o.index(n)>-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/<tbody/i,gt=/<|&#?\w+;/,yt=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,wt=new RegExp("<(?:"+ct+")[\\s/>]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,Nt={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X<div>","</div>"]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1></$2>");try{for(;r<i;r++)n=this[r]||{},n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),n.innerHTML=e);n=0}catch(s){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){return ut(this[0])?this.length?this.pushStack(v(v.isFunction(e)?e():e),"replaceWith",e):this:v.isFunction(e)?this.each(function(t){var n=v(this),r=n.html();n.replaceWith(e.call(this,t,r))}):(typeof e!="string"&&(e=v(e).detach()),this.each(function(){var t=this.nextSibling,n=this.parentNode;v(this).remove(),t?v(t).before(e):v(n).append(e)}))},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=[].concat.apply([],e);var i,s,o,u,a=0,f=e[0],l=[],c=this.length;if(!v.support.checkClone&&c>1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a<c;a++)r.call(n&&v.nodeName(this[a],"table")?Lt(this[a],"tbody"):this[a],a===u?o:v.clone(o,!0,!0))}o=s=null,l.length&&v.each(l,function(e,t){t.src?v.ajax?v.ajax({url:t.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):v.error("no ajax"):v.globalEval((t.text||t.textContent||t.innerHTML||"").replace(Tt,"")),t.parentNode&&t.parentNode.removeChild(t)})}return this}}),v.buildFragment=function(e,n,r){var s,o,u,a=e[0];return n=n||i,n=!n.nodeType&&n[0]||n,n=n.ownerDocument||n,e.length===1&&typeof a=="string"&&a.length<512&&n===i&&a.charAt(0)==="<"&&!bt.test(a)&&(v.support.checkClone||!St.test(a))&&(v.support.html5Clone||!wt.test(a))&&(o=!0,s=v.fragments[a],u=s!==t),s||(s=n.createDocumentFragment(),v.clean(e,n,s,r),o&&(v.fragments[a]=u&&s)),{fragment:s,cacheable:o}},v.fragments={},v.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){v.fn[e]=function(n){var r,i=0,s=[],o=v(n),u=o.length,a=this.length===1&&this[0].parentNode;if((a==null||a&&a.nodeType===11&&a.childNodes.length===1)&&u===1)return o[t](this[0]),this;for(;i<u;i++)r=(i>0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1></$2>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]==="<table>"&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("<div>").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r<i;r++)n=e[r],Vn[n]=Vn[n]||[],Vn[n].unshift(t)},prefilter:function(e,t){t?Xn.unshift(e):Xn.push(e)}}),v.Tween=Yn,Yn.prototype={constructor:Yn,init:function(e,t,n,r,i,s){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=s||(v.cssNumber[n]?"":"px")},cur:function(){var e=Yn.propHooks[this.prop];return e&&e.get?e.get(this):Yn.propHooks._default.get(this)},run:function(e){var t,n=Yn.propHooks[this.prop];return this.options.duration?this.pos=t=v.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Yn.propHooks._default.set(this),this}},Yn.prototype.init.prototype=Yn.prototype,Yn.propHooks={_default:{get:function(e){var t;return e.elem[e.prop]==null||!!e.elem.style&&e.elem.style[e.prop]!=null?(t=v.css(e.elem,e.prop,!1,""),!t||t==="auto"?0:t):e.elem[e.prop]},set:function(e){v.fx.step[e.prop]?v.fx.step[e.prop](e):e.elem.style&&(e.elem.style[v.cssProps[e.prop]]!=null||v.cssHooks[e.prop])?v.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Yn.propHooks.scrollTop=Yn.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},v.each(["toggle","show","hide"],function(e,t){var n=v.fn[t];v.fn[t]=function(r,i,s){return r==null||typeof r=="boolean"||!e&&v.isFunction(r)&&v.isFunction(i)?n.apply(this,arguments):this.animate(Zn(t,!0),r,i,s)}}),v.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Gt).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=v.isEmptyObject(e),s=v.speed(t,n,r),o=function(){var t=Kn(this,v.extend({},e),s);i&&t.stop(!0)};return i||s.queue===!1?this.each(o):this.queue(s.queue,o)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return typeof e!="string"&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=e!=null&&e+"queueHooks",s=v.timers,o=v._data(this);if(n)o[n]&&o[n].stop&&i(o[n]);else for(n in o)o[n]&&o[n].stop&&Wn.test(n)&&i(o[n]);for(n=s.length;n--;)s[n].elem===this&&(e==null||s[n].queue===e)&&(s[n].anim.stop(r),t=!1,s.splice(n,1));(t||!r)&&v.dequeue(this,e)})}}),v.each({slideDown:Zn("show"),slideUp:Zn("hide"),slideToggle:Zn("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){v.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),v.speed=function(e,t,n){var r=e&&typeof e=="object"?v.extend({},e):{complete:n||!n&&t||v.isFunction(e)&&e,duration:e,easing:n&&t||t&&!v.isFunction(t)&&t};r.duration=v.fx.off?0:typeof r.duration=="number"?r.duration:r.duration in v.fx.speeds?v.fx.speeds[r.duration]:v.fx.speeds._default;if(r.queue==null||r.queue===!0)r.queue="fx";return r.old=r.complete,r.complete=function(){v.isFunction(r.old)&&r.old.call(this),r.queue&&v.dequeue(this,r.queue)},r},v.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},v.timers=[],v.fx=Yn.prototype.init,v.fx.tick=function(){var e,n=v.timers,r=0;qn=v.now();for(;r<n.length;r++)e=n[r],!e()&&n[r]===e&&n.splice(r--,1);n.length||v.fx.stop(),qn=t},v.fx.timer=function(e){e()&&v.timers.push(e)&&!Rn&&(Rn=setInterval(v.fx.tick,v.fx.interval))},v.fx.interval=13,v.fx.stop=function(){clearInterval(Rn),Rn=null},v.fx.speeds={slow:600,fast:200,_default:400},v.fx.step={},v.expr&&v.expr.filters&&(v.expr.filters.animated=function(e){return v.grep(v.timers,function(t){return e===t.elem}).length});var er=/^(?:body|html)$/i;v.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){v.offset.setOffset(this,e,t)});var n,r,i,s,o,u,a,f={top:0,left:0},l=this[0],c=l&&l.ownerDocument;if(!c)return;return(r=c.body)===l?v.offset.bodyOffset(l):(n=c.documentElement,v.contains(n,l)?(typeof l.getBoundingClientRect!="undefined"&&(f=l.getBoundingClientRect()),i=tr(c),s=n.clientTop||r.clientTop||0,o=n.clientLeft||r.clientLeft||0,u=i.pageYOffset||n.scrollTop,a=i.pageXOffset||n.scrollLeft,{top:f.top+u-s,left:f.left+a-o}):f)},v.offset={bodyOffset:function(e){var t=e.offsetTop,n=e.offsetLeft;return v.support.doesNotIncludeMarginInBodyOffset&&(t+=parseFloat(v.css(e,"marginTop"))||0,n+=parseFloat(v.css(e,"marginLeft"))||0),{top:t,left:n}},setOffset:function(e,t,n){var r=v.css(e,"position");r==="static"&&(e.style.position="relative");var i=v(e),s=i.offset(),o=v.css(e,"top"),u=v.css(e,"left"),a=(r==="absolute"||r==="fixed")&&v.inArray("auto",[o,u])>-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window);
9915+//]]>
9916+</script>
9917+<script id="jqueryArea" type="text/javascript">
9918+//<![CDATA[
9919+/*
9920+jQuery.encoding.digests.sha1.js
9921+
9922+SHA-1 digest and associated utility functions
9923+
9924+Copyright (c) UnaMesa Association 2009
9925+
9926+Dual licensed under the MIT and GPL licenses:
9927+ http://www.opensource.org/licenses/mit-license.php
9928+ http://www.gnu.org/licenses/gpl.html
9929+*/
9930+
9931+(function($) {
9932+
9933+if(!$.encoding)
9934+ $.encoding = {};
9935+ $.extend($.encoding,{
9936+ strToBe32s: function(str) {
9937+ // Convert a string to an array of big-endian 32-bit words
9938+ var be=[];
9939+ var len=Math.floor(str.length/4);
9940+ var i, j;
9941+ for(i=0, j=0; i<len; i++, j+=4) {
9942+ be[i]=((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
9943+ }
9944+ while(j<str.length) {
9945+ be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
9946+ j++;
9947+ }
9948+ return be;
9949+ },
9950+ be32sToStr: function(be) {
9951+ // Convert an array of big-endian 32-bit words to a string
9952+ var str='';
9953+ for(var i=0;i<be.length*32;i+=8) {
9954+ str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
9955+ }
9956+ return str;
9957+ },
9958+ be32sToHex: function(be) {
9959+ // Convert an array of big-endian 32-bit words to a hex string
9960+ var hex='0123456789ABCDEF';
9961+ var str='';
9962+ for(var i=0;i<be.length*4;i++) {
9963+ str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
9964+ }
9965+ return str;
9966+ }
9967+ });
9968+})(jQuery);
9969+
9970+
9971+(function($) {
9972+
9973+if(!$.encoding.digests)
9974+ $.encoding.digests = {};
9975+ $.extend($.encoding.digests,{
9976+ hexSha1Str: function(str) {
9977+ // Return, in hex, the SHA-1 hash of a string
9978+ return $.encoding.be32sToHex($.encoding.digests.sha1Str(str));
9979+ },
9980+ sha1Str: function(str) {
9981+ // Return the SHA-1 hash of a string
9982+ return sha1($.encoding.strToBe32s(str),str.length);
9983+ },
9984+ sha1: function(x,blen) {
9985+ // Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
9986+ return sha1($.encoding.strToBe32s(str),str.length);
9987+ }
9988+ });
9989+
9990+ // Private functions.
9991+ function sha1(x,blen) {
9992+ // Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
9993+ function add32(a,b) {
9994+ // Add 32-bit integers, wrapping at 32 bits
9995+ // Uses 16-bit operations internally to work around bugs in some JavaScript interpreters.
9996+ var lsw=(a&0xFFFF)+(b&0xFFFF);
9997+ var msw=(a>>16)+(b>>16)+(lsw>>16);
9998+ return (msw<<16)|(lsw&0xFFFF);
9999+ }
10000+ function AA(a,b,c,d,e) {
10001+ // Cryptographic round helper function. Add five 32-bit integers, wrapping at 32 bits, second parameter is rotated left 5 bits before the addition
10002+ // Uses 16-bit operations internally to work around bugs in some JavaScript interpreters.
10003+ b=(b>>>27)|(b<<5);
10004+ var lsw=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
10005+ var msw=(a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
10006+ return (msw<<16)|(lsw&0xFFFF);
10007+ }
10008+ function RR(w,j) {
10009+ // Cryptographic round helper function.
10010+ var n=w[j-3]^w[j-8]^w[j-14]^w[j-16];
10011+ return (n>>>31)|(n<<1);
10012+ }
10013+
10014+ var len=blen*8;
10015+ x[len>>5] |= 0x80 << (24-len%32);
10016+ x[((len+64>>9)<<4)+15]=len;
10017+ var w=new Array(80);
10018+
10019+ var k1=0x5A827999;
10020+ var k2=0x6ED9EBA1;
10021+ var k3=0x8F1BBCDC;
10022+ var k4=0xCA62C1D6;
10023+
10024+ var h0=0x67452301;
10025+ var h1=0xEFCDAB89;
10026+ var h2=0x98BADCFE;
10027+ var h3=0x10325476;
10028+ var h4=0xC3D2E1F0;
10029+
10030+ for(var i=0;i<x.length;i+=16) {
10031+ var j=0;
10032+ var t;
10033+ var a=h0;
10034+ var b=h1;
10035+ var c=h2;
10036+ var d=h3;
10037+ var e=h4;
10038+ while(j<16) {
10039+ w[j]=x[i+j];
10040+ t=AA(e,a,d^(b&(c^d)),w[j],k1);
10041+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
10042+ }
10043+ while(j<20) {
10044+ w[j]=RR(w,j);
10045+ t=AA(e,a,d^(b&(c^d)),w[j],k1);
10046+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
10047+ }
10048+ while(j<40) {
10049+ w[j]=RR(w,j);
10050+ t=AA(e,a,b^c^d,w[j],k2);
10051+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
10052+ }
10053+ while(j<60) {
10054+ w[j]=RR(w,j);
10055+ t=AA(e,a,(b&c)|(d&(b|c)),w[j],k3);
10056+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
10057+ }
10058+ while(j<80) {
10059+ w[j]=RR(w,j);
10060+ t=AA(e,a,b^c^d,w[j],k4);
10061+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
10062+ }
10063+ h0=add32(h0,a);
10064+ h1=add32(h1,b);
10065+ h2=add32(h2,c);
10066+ h3=add32(h3,d);
10067+ h4=add32(h4,e);
10068+ }
10069+ return [h0,h1,h2,h3,h4];
10070+ }
10071+})(jQuery);
10072+/*
10073+jQuery.twStylesheet.js
10074+
10075+jQuery plugin to dynamically insert CSS rules into a document
10076+
10077+Usage:
10078+ jQuery.twStylesheet applies style definitions
10079+ jQuery.twStylesheet.remove neutralizes style definitions
10080+
10081+Copyright (c) UnaMesa Association 2009
10082+
10083+Triple licensed under the BSD, MIT and GPL licenses:
10084+ http://www.opensource.org/licenses/bsd-license.php
10085+ http://www.opensource.org/licenses/mit-license.php
10086+ http://www.gnu.org/licenses/gpl.html
10087+*/
10088+
10089+(function($) {
10090+
10091+var defaultId = "customStyleSheet"; // XXX: rename to dynamicStyleSheet?
10092+
10093+// Add or replace a style sheet
10094+// css argument is a string of CSS rule sets
10095+// options.id is an optional name identifying the style sheet
10096+// options.doc is an optional document reference
10097+// N.B.: Uses DOM methods instead of jQuery to ensure cross-browser comaptibility.
10098+$.twStylesheet = function(css, options) {
10099+ options = options || {};
10100+ var id = options.id || defaultId;
10101+ var doc = options.doc || document;
10102+ var el = doc.getElementById(id);
10103+ if(doc.createStyleSheet) { // IE-specific handling
10104+ if(el) {
10105+ el.parentNode.removeChild(el);
10106+ }
10107+ doc.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd",
10108+ '&nbsp;<style id="' + id + '" type="text/css">' + css + '</style>'); // fails without &nbsp;
10109+ } else { // modern browsers
10110+ if(el) {
10111+ el.replaceChild(doc.createTextNode(css), el.firstChild);
10112+ } else {
10113+ el = doc.createElement("style");
10114+ el.type = "text/css";
10115+ el.id = id;
10116+ el.appendChild(doc.createTextNode(css));
10117+ doc.getElementsByTagName("head")[0].appendChild(el);
10118+ }
10119+ }
10120+};
10121+
10122+// Remove existing style sheet
10123+// options.id is an optional name identifying the style sheet
10124+// options.doc is an optional document reference
10125+$.twStylesheet.remove = function(options) {
10126+ options = options || {};
10127+ var id = options.id || defaultId;
10128+ var doc = options.doc || document;
10129+ var el = doc.getElementById(id);
10130+ if(el) {
10131+ el.parentNode.removeChild(el);
10132+ }
10133+};
10134+
10135+})(jQuery);
10136+
10137+//]]>
10138+</script>
10139+<script type="text/javascript">
10140+//<![CDATA[
10141+if(useJavaSaver)
10142+ document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>");
10143+//]]>
10144+</script>
10145+<!--POST-SCRIPT-START-->
10146+
10147+<!--POST-SCRIPT-END-->
10148+</body>
10149+</html>