Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Anderson <tony_anderson@usa.net>2009-06-09 08:50:15 (GMT)
committer Tony Anderson <tony_anderson@usa.net>2009-06-09 08:50:15 (GMT)
commit720985fc29dd3b0c9340d80ae2f0839b2d969897 (patch)
treedd847a20a00e0a44e3134abb287daa471336e7bc
add content
-rwxr-xr-xactivity/activity.info8
-rwxr-xr-xactivity/mimetypes.xml7
-rwxr-xr-xactivity/permissions.info1
-rwxr-xr-xactivity/showntell-activity.svg431
-rw-r--r--empty.html9426
-rwxr-xr-xhtmlview.py27
-rwxr-xr-xhulahop_test.py22
-rwxr-xr-xicons/Fileclose-2.0.svg124
-rwxr-xr-xicons/Filenew.svg151
-rwxr-xr-xicons/Icon-move.svg77
-rwxr-xr-xicons/Icon-remove.svg117
-rwxr-xr-xicons/activity-journal.svg31
-rwxr-xr-xicons/black-button.svg88
-rwxr-xr-xicons/blue-button.svg84
-rwxr-xr-xicons/choose.svg191
-rwxr-xr-xicons/done.svg263
-rwxr-xr-xicons/green-button.svg84
-rwxr-xr-xicons/locked.svg24
-rwxr-xr-xicons/media-flash-sd-mmc.svg9
-rwxr-xr-xicons/media-flash-usb.svg9
-rw-r--r--icons/new-slideshow.svg462
-rwxr-xr-xicons/new.svg214
-rwxr-xr-xicons/red-button.svg84
-rwxr-xr-xicons/slideshow.svg431
-rwxr-xr-xicons/text.svg68
-rwxr-xr-xicons/tool-brush.svg16
-rwxr-xr-xicons/tool-eraser.svg18
-rwxr-xr-xicons/tool-pencil.svg21
-rwxr-xr-xicons/unlocked.svg23
-rwxr-xr-xink.py61
-rw-r--r--listview.py103
-rwxr-xr-xmanifest27
-rwxr-xr-xnews1
-rwxr-xr-xpath.py971
-rwxr-xr-xreadme192
-rwxr-xr-xresources/new.cpxobin0 -> 14997 bytes
-rw-r--r--resources/splash.svg205
-rwxr-xr-xsetup.py12
-rwxr-xr-xshared.py387
-rwxr-xr-xsharedslides.py176
-rwxr-xr-xshowntell.py204
-rwxr-xr-xsidebar.py179
-rwxr-xr-xsliderenderer.py145
-rwxr-xr-xslideshow.py594
-rwxr-xr-xslideviewer.py315
-rwxr-xr-xtextarea.py172
-rwxr-xr-xtoolbars.py464
-rw-r--r--tw/simple.html7
-rw-r--r--tw/slides.html9428
-rwxr-xr-xutils.py32
50 files changed, 26186 insertions, 0 deletions
diff --git a/activity/activity.info b/activity/activity.info
new file mode 100755
index 0000000..5458bc7
--- /dev/null
+++ b/activity/activity.info
@@ -0,0 +1,8 @@
+[Activity]
+name = ShowNTell
+service_name = org.laptop.showntell
+class = showntell.ShowNTell
+icon = showntell-activity
+activity_version = 1
+show_launcher = yes
+mime_types = application/x-classroompresenter; application/zip
diff --git a/activity/mimetypes.xml b/activity/mimetypes.xml
new file mode 100755
index 0000000..cf49d84
--- /dev/null
+++ b/activity/mimetypes.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/x-classroompresenter">
+ <comment>Classroom Presenter Slide Deck</comment>
+ <glob pattern="*.cpxo"/>
+ </mime-type>
+</mime-info>
diff --git a/activity/permissions.info b/activity/permissions.info
new file mode 100755
index 0000000..585d713
--- /dev/null
+++ b/activity/permissions.info
@@ -0,0 +1 @@
+constant-uid
diff --git a/activity/showntell-activity.svg b/activity/showntell-activity.svg
new file mode 100755
index 0000000..d57facb
--- /dev/null
+++ b/activity/showntell-activity.svg
@@ -0,0 +1,431 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ enable-background="new 0 0 55 55"
+ height="55px"
+ id="svg2972"
+ version="1.1"
+ viewBox="0 0 55 55"
+ width="55px"
+ x="0px"
+ xml:space="preserve"
+ y="0px"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="new-showntell-activity.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata2729"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs2727"><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2399"><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
+ offset="0"
+ id="stop2401" /><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
+ offset="1"
+ id="stop2403" /></linearGradient><linearGradient
+ id="linearGradient2371"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2373" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0.484536;"
+ offset="1"
+ id="stop2375" /></linearGradient><linearGradient
+ id="linearGradient2407"><stop
+ style="stop-color: rgb(213, 213, 213); stop-opacity: 1;"
+ offset="0"
+ id="stop2409" /><stop
+ style="stop-color: rgb(116, 116, 116); stop-opacity: 1;"
+ offset="1"
+ id="stop2411" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2355"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2357" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
+ offset="1"
+ id="stop2359" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2337"><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
+ offset="0"
+ id="stop2339" /><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
+ offset="1"
+ id="stop2341" /></linearGradient><linearGradient
+ id="linearGradient2345"><stop
+ style="stop-color: rgb(213, 213, 213); stop-opacity: 1;"
+ offset="0"
+ id="stop2347" /><stop
+ style="stop-color: rgb(160, 160, 160); stop-opacity: 1;"
+ offset="1"
+ id="stop2349" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2252"><stop
+ style="stop-color: rgb(198, 198, 198); stop-opacity: 1;"
+ offset="0"
+ id="stop2254" /><stop
+ style="stop-color: rgb(198, 198, 198); stop-opacity: 0;"
+ offset="1"
+ id="stop2256" /></linearGradient><linearGradient
+ id="linearGradient2232"><stop
+ style="stop-color: rgb(176, 176, 176); stop-opacity: 1;"
+ offset="0"
+ id="stop2234" /><stop
+ style="stop-color: rgb(116, 116, 116); stop-opacity: 1;"
+ offset="1"
+ id="stop2236" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2242"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2244" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
+ offset="1"
+ id="stop2246" /></linearGradient><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 27.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="55 : 27.5 : 1"
+ inkscape:persp3d-origin="27.5 : 18.333333 : 1"
+ id="perspective2731" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2242"
+ id="radialGradient3194"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.425856,0,23.5399)"
+ cx="25.1875"
+ cy="41"
+ fx="25.1875"
+ fy="41"
+ r="16.4375" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2232"
+ id="radialGradient3196"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.52514,0,22.0217)"
+ cx="15.4375"
+ cy="42.090427"
+ fx="15.4375"
+ fy="42.090427"
+ r="11.1875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2252"
+ id="linearGradient3198"
+ gradientUnits="userSpaceOnUse"
+ x1="41.25"
+ y1="36.689548"
+ x2="48.25"
+ y2="35.689548" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2345"
+ id="radialGradient3200"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.49192,-8.44511e-2,-5.87441e-2,3.98672,-9.6468,-20.2759)"
+ cx="19.557497"
+ cy="6.644074"
+ fx="19.557497"
+ fy="6.644074"
+ r="10.98921" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2337"
+ id="radialGradient3202"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.53075,0,0,4.4512431,-28.91508,-14.647051)"
+ cx="20.275276"
+ cy="5.7119732"
+ fx="20.275276"
+ fy="5.7119732"
+ r="12.494026" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3204"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3206"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3208"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3210"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2407"
+ id="radialGradient3212"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.435326,0,0,0.435326,18.9166,12.4934)"
+ cx="33.499996"
+ cy="20.538168"
+ fx="33.499996"
+ fy="20.538168"
+ r="2.2697367" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3214"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3216"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-4.5961941,-0.3535534)"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3218"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3220"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3222"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3224"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2399"
+ id="linearGradient3226"
+ gradientUnits="userSpaceOnUse"
+ x1="16.4375"
+ y1="49.110714"
+ x2="17.402376"
+ y2="43.420425" /></defs><sodipodi:namedview
+ inkscape:window-height="726"
+ inkscape:window-width="645"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="8.9818182"
+ inkscape:cx="27.5"
+ inkscape:cy="27.68773"
+ inkscape:window-x="449"
+ inkscape:window-y="25"
+ inkscape:current-layer="svg2972" />
+<g
+ id="g2709">
+ <g
+ id="g2711">
+ <path
+ d="M11.908,34.521c-0.516,0.1-1.012-0.219-1.108-0.712L7.72,17.94c-0.095-0.493,0.245-0.975,0.761-1.075 l21.5-4.173c0.515-0.1,1.013,0.219,1.106,0.713l1.029,5.306l0.049-0.044l5.024,1.097l-1.608-8.618 c-0.294-1.503-1.748-2.485-3.251-2.192L5.121,14.235c-1.503,0.292-2.485,1.747-2.193,3.249l3.697,19.048 c0.292,1.503,1.746,2.484,3.249,2.193l4.623-0.945l1.016-3.959L11.908,34.521z"
+ fill="#666666"
+ id="path2713" />
+ </g>
+</g>
+<path
+ d="M34.167,29.272c0.097,0.493-0.245,0.977-0.761,1.074l-21.497,4.174 c-0.517,0.1-1.014-0.219-1.109-0.712L7.72,17.94c-0.095-0.493,0.245-0.975,0.762-1.075l21.499-4.173 c0.515-0.1,1.013,0.219,1.106,0.713L34.167,29.272z"
+ fill="#ffffff"
+ id="path3554_1_" />
+<g
+ id="g2716">
+ <g
+ id="g2718">
+ <path
+ d="M49.668,23.2l-4.624-0.954l-2.055,2.779l3.032,0.669c0.515,0.113,0.843,0.603,0.734,1.096l-3.485,15.783 c-0.107,0.491-0.613,0.798-1.125,0.684l-21.385-4.723c-0.513-0.112-0.841-0.603-0.733-1.094l3.485-15.784 c0.109-0.491,0.613-0.798,1.127-0.684l11.574,2.556l2.365-2.785L22.602,17.22c-1.495-0.33-2.975,0.615-3.304,2.11l-4.185,18.944 c-0.331,1.496,0.614,2.977,2.109,3.307l27.064,5.977c1.495,0.33,2.973-0.612,3.304-2.108l4.188-18.946 C52.106,25.009,51.163,23.53,49.668,23.2z"
+ fill="#666666"
+ id="path2720" />
+ </g>
+</g>
+<path
+ d="M43.271,42.573c-0.107,0.491-0.613,0.798-1.125,0.684l-21.385-4.723 c-0.513-0.112-0.84-0.603-0.733-1.094l3.485-15.784c0.109-0.491,0.613-0.798,1.127-0.684l21.382,4.722 c0.515,0.113,0.843,0.603,0.734,1.096L43.271,42.573z"
+ fill="#ffffff"
+ id="path3560_1_" />
+<path
+ d="M53.008,10.631c0-0.045-0.002-0.093-0.009-0.141c-0.069-0.589-0.562-1.31-1.28-1.878 c-0.721-0.569-1.536-0.878-2.127-0.81c-0.257,0.032-0.461,0.142-0.602,0.304l-0.016-0.009L38.568,21.872l-0.047,0.046l-0.006,0.01 c-0.016,0.018-0.019,0.043-0.031,0.063l-1.351,1.663c0,0,0.078,0.061,0.158,0.125l-0.164-0.114l-0.025,0.033 c-0.061,0.074-0.097,0.168-0.124,0.267c-0.011,0.012-0.026,0.015-0.032,0.029l-0.848,2.01l2.546,2.037l1.987-1.281 c0.014-0.006,0.011-0.022,0.021-0.033c0.052-0.04,0.111-0.074,0.152-0.124c0.004-0.007,0.024-0.037,0.028-0.039l1.389-1.733 l0.022-0.021l-0.005-0.002l0.016-0.017l0.005,0.002l10.518-13.57c0.021-0.019,0.045-0.027,0.062-0.048 c0.022-0.027,0.031-0.064,0.047-0.094l0.013-0.012l-0.002-0.002C52.963,10.939,53.008,10.798,53.008,10.631z"
+ fill="#666666"
+ id="path3562" />
+<path
+ d="M33.625,31.123c0,0-6.7,4.055-7.934,2.555 c-1.235-1.498,0.353-2.995,1.146-2.995s3.791,2.291,1.675,4.585c-2.117,2.291-3.617,1.764-3.617,1.764"
+ fill="none"
+ id="path3564"
+ stroke="#666666"
+ stroke-width="1.009" />
+<path
+ d="M34.438,30.019c-0.032,0.083-0.012,0.176,0.057,0.232c0.067,0.058,0.164,0.064,0.238,0.016 l2.879-1.851l-1.869-1.497L34.438,30.019z"
+ fill="#666666"
+ id="path3566" />
+<g
+ inkscape:groupmode="layer"
+ id="layer1"
+ inkscape:label="microphone" /><g
+ id="g3105"
+ transform="matrix(0.5232537,0,0,0.4950076,4.3255858,4.694013)"><path
+ transform="matrix(1.10646,0,0,1.04464,-2.68156,-2.51786)"
+ d="M 41.625,41 A 16.4375,7 0 1 1 8.75,41 A 16.4375,7 0 1 1 41.625,41 z"
+ sodipodi:ry="7"
+ sodipodi:rx="16.4375"
+ sodipodi:cy="41"
+ sodipodi:cx="25.1875"
+ id="path2240"
+ style="opacity:0.49431799;fill:url(#radialGradient3194);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ transform="translate(8.75,-7)"
+ d="M 27.625,46.375 A 11.1875,5.875 0 1 1 5.25,46.375 A 11.1875,5.875 0 1 1 27.625,46.375 z"
+ sodipodi:ry="5.875"
+ sodipodi:rx="11.1875"
+ sodipodi:cy="46.375"
+ sodipodi:cx="16.4375"
+ id="path2222"
+ style="opacity:1;fill:url(#radialGradient3196);fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ sodipodi:type="arc"
+ style="opacity:1;fill:#424242;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="path2260"
+ sodipodi:cx="33.5"
+ sodipodi:cy="22.125"
+ sodipodi:rx="1.875"
+ sodipodi:ry="1.875"
+ d="M 35.375,22.125 A 1.875,1.875 0 1 1 31.625,22.125 A 1.875,1.875 0 1 1 35.375,22.125 z"
+ transform="matrix(2.06667,0,0,1.26667,-43.9833,9.475)" /><path
+ sodipodi:nodetypes="cszzc"
+ id="path2250"
+ d="M 20.25,31.375 C 20.25,31.375 20.985875,34.77724 23.25,34.5 C 29.375,33.75 28.721362,34.010493 33.125,35.375 C 37.5625,36.75 35.21875,38.96875 39.75,39.375 C 44.28125,39.78125 43.875,35.75 47.75,35.5"
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3198);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><rect
+ transform="matrix(0.970732,0.240164,-0.264014,0.964519,0,0)"
+ ry="6.6936979"
+ rx="6.6936979"
+ y="-4.0142608"
+ x="16.028919"
+ height="30.692028"
+ width="22.136791"
+ id="rect1343"
+ style="opacity:1;fill:url(#radialGradient3200);fill-opacity:1;fill-rule:evenodd;stroke:#7c7c7c;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><rect
+ style="opacity:0.30681799;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect2353"
+ width="19.862064"
+ height="28.524395"
+ x="17.210075"
+ y="-3.006144"
+ rx="5.4198565"
+ ry="5.4198565"
+ transform="matrix(0.970732,0.240164,-0.264014,0.964519,0,0)" /><path
+ sodipodi:nodetypes="cccsccsssssssssssssssssssssssscccsccssssssssssssssssssssssssssssssccccsccssssssssssssssssssssssssssssssccccccccssssssssscccsssssssssssssssssssssssssccccssccccsccssssssssssssssssssssssssssscccsssssssssssssssssssssssccccssccccsccssssssssssssssssssssssssssscccssssssssssssssssssssssssscccccssssssssssssssssssssssscccccssssssssssssssssssssssssccc"
+ id="rect2302"
+ d="M 22.21507,2.1586646 C 19.993982,2.8419631 18.064553,6.11263 17.43382,10.579833 L 12.59007,45.173267 C 15.447016,47.895386 19.22768,46.082026 22.80882,46.082026 C 23.298828,46.082026 23.796888,46.07907 24.27757,46.021442 C 23.342429,45.580269 21.96507,44.930931 21.96507,44.930931 C 21.745207,44.815494 21.543886,44.668833 21.40257,44.44626 C 21.397838,44.438383 21.375909,44.39376 21.37132,44.385676 C 21.357994,44.360785 21.324385,44.295981 21.30882,44.264508 C 21.303164,44.253775 21.283185,44.214717 21.27757,44.203924 C 21.269347,44.17318 21.252624,44.106823 21.24632,44.082756 C 21.236648,44.035572 21.221593,43.943297 21.21507,43.901004 C 21.215266,43.894996 21.215009,43.845726 21.21507,43.84042 C 21.209239,43.819517 21.189444,43.740465 21.18382,43.719252 C 21.183891,43.707349 21.183867,43.666419 21.18382,43.658668 C 21.18405,43.624034 21.183787,43.559844 21.18382,43.537501 C 21.183714,43.525781 21.183503,43.483954 21.18382,43.476917 C 21.183711,43.470779 21.183831,43.421712 21.18382,43.416333 C 21.19194,43.346104 21.208482,43.235098 21.21507,43.173997 C 21.220328,43.154096 21.240474,43.074649 21.24632,43.052829 C 21.246321,43.047286 21.246583,42.998208 21.24632,42.992245 C 21.253935,42.94461 21.268644,42.853675 21.27757,42.810493 C 21.285643,42.77858 21.303721,42.708776 21.30882,42.689325 C 21.333585,42.601792 21.372075,42.461188 21.40257,42.386406 C 21.40899,42.373833 21.429561,42.334084 21.43382,42.325822 C 21.445069,42.315137 21.486035,42.274931 21.49632,42.265238 C 21.524876,42.231985 21.585658,42.172766 21.62132,42.14407 C 21.632197,42.144368 21.672839,42.143459 21.68382,42.14407 C 21.683639,42.140685 21.683766,42.097088 21.68382,42.083486 C 21.690832,42.083373 21.713299,42.083086 21.71507,42.083486 C 21.889903,42.020149 22.111554,42.070233 22.34007,42.14407 L 28.27757,44.809763 C 29.467865,44.245328 30.604797,43.471628 31.68382,42.568157 C 31.531417,42.401171 31.366355,42.295101 31.21507,42.204654 C 31.177701,42.183677 31.127179,42.159215 31.09007,42.14407 C 31.09007,42.14407 22.87132,38.266697 22.87132,38.266697 C 22.651457,38.15126 22.427107,38.004598 22.27757,37.782026 C 22.272566,37.774149 22.251168,37.729526 22.24632,37.721442 C 22.2418,37.712927 22.21942,37.669595 22.21507,37.660858 C 22.210895,37.651893 22.187815,37.609471 22.18382,37.600274 C 22.178403,37.579671 22.157552,37.500265 22.15257,37.479106 C 22.146868,37.468439 22.126971,37.429254 22.12132,37.418522 C 22.121633,37.412336 22.121228,37.363289 22.12132,37.357938 C 22.11559,37.336837 22.095572,37.258158 22.09007,37.23677 C 22.090241,37.230762 22.090012,37.181492 22.09007,37.176186 C 22.090039,37.155283 22.089851,37.076231 22.09007,37.055018 C 22.089341,37.013278 22.088401,36.917953 22.09007,36.873266 C 22.090112,36.866413 22.090209,36.820365 22.09007,36.812682 C 22.089362,36.787466 22.089223,36.712956 22.09007,36.691515 C 22.089926,36.684857 22.090092,36.636417 22.09007,36.630931 C 22.095814,36.609316 22.11599,36.52989 22.12132,36.509763 C 22.130109,36.455805 22.142957,36.377263 22.15257,36.328011 C 22.157874,36.307389 22.178287,36.227637 22.18382,36.206843 C 22.200943,36.136412 22.228197,36.025446 22.24632,35.964507 C 22.26074,35.92387 22.2912,35.828179 22.30882,35.782755 C 22.313398,35.773306 22.335401,35.731208 22.34007,35.722171 C 22.346487,35.709599 22.367062,35.66985 22.37132,35.661587 C 22.382613,35.650901 22.423566,35.610697 22.43382,35.601003 C 22.449712,35.584996 22.483754,35.552265 22.49632,35.54042 C 22.504834,35.533035 22.542255,35.495766 22.55882,35.479836 C 22.561977,35.480309 22.587322,35.479698 22.59007,35.479836 C 22.59435,35.471614 22.614803,35.431737 22.62132,35.419252 C 22.6241,35.419364 22.649316,35.418932 22.65257,35.419252 C 22.659723,35.405642 22.682489,35.362064 22.68382,35.358668 C 22.687075,35.358978 22.71229,35.358555 22.71507,35.358668 C 22.721429,35.358908 22.743317,35.358902 22.74632,35.358668 C 22.890468,35.347433 23.068342,35.422328 23.24632,35.479836 L 31.55882,39.23604 C 32.178205,39.571146 32.746139,40.416303 33.18382,41.235311 C 33.697582,40.705559 34.175099,40.082033 34.65257,39.478376 C 34.506925,39.100336 33.322125,36.183604 32.24632,35.54042 C 32.208951,35.519443 32.158429,35.494981 32.12132,35.479836 C 32.12132,35.479836 23.90257,31.602463 23.90257,31.602463 C 23.682707,31.487026 23.458357,31.340364 23.30882,31.117791 C 23.303816,31.109915 23.282418,31.065292 23.27757,31.057207 C 23.27305,31.048693 23.25067,31.005361 23.24632,30.996624 C 23.242145,30.987659 23.219065,30.945237 23.21507,30.93604 C 23.209653,30.915437 23.188802,30.836031 23.18382,30.814872 C 23.178118,30.804205 23.158221,30.76502 23.15257,30.754288 C 23.152883,30.748101 23.152478,30.699055 23.15257,30.693704 C 23.14684,30.672603 23.126822,30.593923 23.12132,30.572536 C 23.121491,30.566528 23.121262,30.517258 23.12132,30.511952 C 23.121289,30.491049 23.121101,30.411997 23.12132,30.390784 C 23.120591,30.349044 23.119651,30.253719 23.12132,30.209032 C 23.121362,30.202179 23.121459,30.156131 23.12132,30.148448 C 23.120612,30.123232 23.120473,30.048722 23.12132,30.02728 C 23.121176,30.020623 23.121342,29.972183 23.12132,29.966696 C 23.127064,29.945082 23.14724,29.865656 23.15257,29.845529 C 23.161359,29.791571 23.174207,29.713029 23.18382,29.663777 C 23.189124,29.643155 23.209537,29.563403 23.21507,29.542609 C 23.232193,29.472178 23.259447,29.361212 23.27757,29.300273 C 23.29199,29.259636 23.32245,29.163945 23.34007,29.118521 C 23.344648,29.109072 23.366651,29.066973 23.37132,29.057937 C 23.377737,29.045365 23.398312,29.005618 23.40257,28.997353 C 23.413863,28.986667 23.454816,28.946463 23.46507,28.936769 C 23.480962,28.920762 23.515004,28.888031 23.52757,28.876185 C 23.53306,28.865081 23.553307,28.826621 23.55882,28.815601 C 23.569749,28.815935 23.610299,28.81495 23.62132,28.815601 C 23.6256,28.807379 23.646053,28.767503 23.65257,28.755018 C 23.65535,28.75513 23.680566,28.7547 23.68382,28.755018 C 23.690973,28.741406 23.713739,28.697832 23.71507,28.694434 C 23.718325,28.694744 23.74354,28.694321 23.74632,28.694434 C 23.752679,28.694674 23.774567,28.694666 23.77757,28.694434 C 23.921718,28.683199 24.099592,28.758094 24.27757,28.815601 L 32.59007,32.571806 C 33.93382,33.298814 35.05882,36.449179 35.05882,36.449179 L 34.65257,39.478376 C 34.836737,39.245538 35.03664,39.055256 35.21507,38.811953 L 37.80882,20.333849 C 38.650231,14.374487 36.848446,8.4177135 33.77757,6.9447964 L 24.49632,2.4615843 C 23.89654,2.1739052 23.303073,2.0788021 22.71507,2.1586646 C 22.711521,2.1591465 22.689905,2.1588162 22.68382,2.1586646 C 22.670924,2.1581704 22.633771,2.1598311 22.62132,2.1586646 C 22.615045,2.1582414 22.596501,2.1587092 22.59007,2.1586646 C 22.587023,2.1585444 22.56543,2.1587202 22.55882,2.1586646 C 22.52881,2.1602937 22.46376,2.1562625 22.43382,2.1586646 C 22.424556,2.159398 22.387525,2.159132 22.37132,2.1586646 C 22.367493,2.1585649 22.344175,2.1582138 22.34007,2.1586646 C 22.329452,2.1583154 22.28818,2.1589327 22.27757,2.1586646 C 22.266941,2.1582984 22.22569,2.1589509 22.21507,2.1586646 z M 17.71507,12.276184 L 22.62132,14.154286 C 22.81175,14.267881 23.01278,14.435772 23.15257,14.699542 C 23.1571,14.708551 23.179426,14.750896 23.18382,14.760126 C 23.188075,14.769579 23.21096,14.81103 23.21507,14.82071 C 23.22041,14.841238 23.241337,14.920817 23.24632,14.941878 C 23.251999,14.95252 23.271934,14.991758 23.27757,15.002462 C 23.287659,15.050182 23.301098,15.140858 23.30882,15.184213 C 23.31759,15.23957 23.333658,15.357843 23.34007,15.426549 C 23.339992,15.438417 23.340018,15.479387 23.34007,15.487133 C 23.339819,15.521508 23.340108,15.585519 23.34007,15.608301 C 23.340424,15.663284 23.342068,15.7929 23.34007,15.850637 C 23.340213,15.857291 23.340053,15.905738 23.34007,15.911221 C 23.334346,15.932761 23.314288,16.011386 23.30882,16.032389 C 23.301582,16.085713 23.286162,16.165159 23.27757,16.214141 C 23.277854,16.220106 23.277536,16.26914 23.27757,16.274724 C 23.271906,16.296984 23.25173,16.376333 23.24632,16.395892 C 23.239195,16.423912 23.222717,16.490827 23.21507,16.51706 C 23.209477,16.527695 23.189444,16.567118 23.18382,16.577644 C 23.178558,16.599151 23.157949,16.677728 23.15257,16.698812 C 23.148028,16.709363 23.125972,16.749256 23.12132,16.759396 C 23.11656,16.76913 23.094935,16.810648 23.09007,16.81998 C 23.085103,16.828916 23.063887,16.87202 23.05882,16.880564 C 23.048199,16.890925 23.007148,16.931636 22.99632,16.941148 C 22.990819,16.952148 22.970592,16.990822 22.96507,17.001732 C 22.944002,17.018636 22.893058,17.048529 22.87132,17.062316 C 22.847095,17.079175 22.802773,17.111202 22.77757,17.1229 C 22.612332,17.190858 22.424054,17.160765 22.24632,17.062316 L 17.30882,15.002462 L 17.71507,12.276184 z M 25.52757,15.365965 C 25.530825,15.366276 25.55604,15.365853 25.55882,15.365965 C 25.565179,15.366205 25.587067,15.366199 25.59007,15.365965 C 25.734218,15.35473 25.912092,15.429626 26.09007,15.487133 L 34.40257,19.243338 C 35.74632,19.970345 36.62132,22.636039 36.62132,22.636039 L 36.27757,25.604652 C 36.131925,25.226612 35.134625,22.855136 34.05882,22.211951 C 34.021451,22.190975 33.970929,22.166514 33.93382,22.151367 C 33.93382,22.151367 25.71507,18.273995 25.71507,18.273995 C 25.495207,18.158558 25.270857,18.011896 25.12132,17.789323 C 25.116316,17.781446 25.094918,17.736824 25.09007,17.728739 C 25.08555,17.720225 25.06317,17.676892 25.05882,17.668155 C 25.054645,17.659191 25.031565,17.616768 25.02757,17.607571 C 25.022153,17.586969 25.001302,17.507562 24.99632,17.486403 C 24.990618,17.475737 24.970721,17.436551 24.96507,17.425819 C 24.965383,17.419634 24.964978,17.370585 24.96507,17.365236 C 24.95934,17.344134 24.939322,17.265454 24.93382,17.244068 C 24.933991,17.23806 24.933762,17.188791 24.93382,17.183484 C 24.933789,17.16258 24.933601,17.083529 24.93382,17.062316 C 24.933091,17.020577 24.932151,16.92525 24.93382,16.880564 C 24.933862,16.87371 24.933959,16.827663 24.93382,16.81998 C 24.933112,16.794763 24.932973,16.720254 24.93382,16.698812 C 24.933676,16.692154 24.933842,16.643715 24.93382,16.638228 C 24.939564,16.616614 24.95974,16.537187 24.96507,16.51706 C 24.973859,16.463103 24.986707,16.384561 24.99632,16.335308 C 25.001624,16.314686 25.022037,16.234936 25.02757,16.214141 C 25.044693,16.14371 25.071947,16.032743 25.09007,15.971805 C 25.10449,15.931168 25.13495,15.835477 25.15257,15.790053 C 25.157148,15.780603 25.179151,15.738506 25.18382,15.729469 C 25.190237,15.716896 25.210812,15.677149 25.21507,15.668885 C 25.226363,15.658199 25.267316,15.617994 25.27757,15.608301 C 25.293462,15.592294 25.327504,15.559564 25.34007,15.547717 C 25.34556,15.536613 25.365807,15.498153 25.37132,15.487133 C 25.382249,15.487466 25.422799,15.486481 25.43382,15.487133 C 25.4381,15.478911 25.458553,15.439035 25.46507,15.426549 C 25.46785,15.426662 25.493066,15.42623 25.49632,15.426549 C 25.503473,15.412939 25.526239,15.369363 25.52757,15.365965 z M 16.80882,18.81925 L 21.71507,20.697353 C 21.9055,20.810948 22.10653,20.978838 22.24632,21.242608 C 22.25085,21.251617 22.273176,21.293962 22.27757,21.303192 C 22.281825,21.312645 22.30471,21.354096 22.30882,21.363776 C 22.31416,21.384305 22.335087,21.463884 22.34007,21.484944 C 22.345749,21.495585 22.365684,21.534824 22.37132,21.545528 C 22.37114,21.548597 22.371262,21.592399 22.37132,21.606112 C 22.376977,21.627185 22.397108,21.705946 22.40257,21.72728 C 22.409586,21.771565 22.427062,21.856925 22.43382,21.909032 C 22.433993,21.915743 22.433781,21.961855 22.43382,21.969615 C 22.433391,22.004207 22.433491,22.068444 22.43382,22.090783 C 22.433744,22.136348 22.436183,22.22426 22.43382,22.272535 C 22.428563,22.354532 22.414777,22.485525 22.40257,22.575455 C 22.402657,22.580618 22.402259,22.630657 22.40257,22.636039 C 22.389865,22.694275 22.354068,22.824375 22.34007,22.878375 C 22.333214,22.907302 22.316209,22.97242 22.30882,22.999543 C 22.303517,23.020895 22.282998,23.099794 22.27757,23.12071 C 22.271991,23.131398 22.251928,23.170713 22.24632,23.181294 C 22.210891,23.269026 22.16339,23.361433 22.12132,23.42363 C 22.115809,23.434586 22.095603,23.473352 22.09007,23.484214 C 22.074217,23.500137 22.040551,23.532239 22.02757,23.544798 C 22.018802,23.552646 21.981593,23.589516 21.96507,23.605382 C 21.961925,23.604876 21.936564,23.605529 21.93382,23.605382 C 21.922911,23.616495 21.882288,23.655171 21.87132,23.665966 C 21.706082,23.733925 21.517804,23.70383 21.34007,23.605382 L 16.40257,21.545528 L 16.80882,18.81925 z M 24.62132,22.030199 C 24.624575,22.03051 24.64979,22.030087 24.65257,22.030199 C 24.658929,22.03044 24.680817,22.030434 24.68382,22.030199 C 24.827968,22.018965 25.005842,22.09386 25.18382,22.151367 L 33.49632,25.907572 C 34.84007,26.634579 35.59007,29.118521 35.59007,29.118521 L 35.27757,31.905383 C 35.131925,31.527343 34.228375,29.51937 33.15257,28.876185 C 33.115201,28.855209 33.064679,28.830746 33.02757,28.815601 C 33.02757,28.815601 24.80882,24.938229 24.80882,24.938229 C 24.588957,24.822792 24.364607,24.67613 24.21507,24.453557 C 24.210066,24.44568 24.188668,24.401058 24.18382,24.392973 C 24.1793,24.384459 24.15692,24.341127 24.15257,24.332389 C 24.148395,24.323425 24.125315,24.281003 24.12132,24.271805 C 24.115903,24.251203 24.095052,24.171796 24.09007,24.150638 C 24.084368,24.139971 24.064471,24.100786 24.05882,24.090054 C 24.059133,24.083867 24.058728,24.03482 24.05882,24.02947 C 24.05309,24.008369 24.033072,23.929687 24.02757,23.908302 C 24.027741,23.902294 24.027512,23.853024 24.02757,23.847718 C 24.027539,23.826815 24.027351,23.747763 24.02757,23.72655 C 24.026841,23.68481 24.025901,23.589485 24.02757,23.544798 C 24.027612,23.537945 24.027709,23.491897 24.02757,23.484214 C 24.026862,23.458998 24.026723,23.384488 24.02757,23.363046 C 24.027426,23.356389 24.027592,23.307949 24.02757,23.302462 C 24.033314,23.280848 24.05349,23.201422 24.05882,23.181294 C 24.067609,23.127337 24.080457,23.048795 24.09007,22.999543 C 24.095374,22.978921 24.115787,22.899169 24.12132,22.878375 C 24.138443,22.807944 24.165697,22.696978 24.18382,22.636039 C 24.19824,22.595402 24.2287,22.49971 24.24632,22.454287 C 24.250898,22.444838 24.272901,22.402739 24.27757,22.393703 C 24.283987,22.381131 24.304562,22.341384 24.30882,22.333119 C 24.320113,22.322433 24.361066,22.282229 24.37132,22.272535 C 24.387212,22.256527 24.421254,22.223799 24.43382,22.211951 C 24.442334,22.204567 24.479755,22.167297 24.49632,22.151367 C 24.499477,22.15184 24.524822,22.15123 24.52757,22.151367 C 24.53185,22.143145 24.552303,22.103269 24.55882,22.090783 C 24.5616,22.090896 24.586816,22.090465 24.59007,22.090783 C 24.597223,22.077174 24.619989,22.033598 24.62132,22.030199 z M 15.87132,25.362316 L 20.77757,27.301003 C 20.916425,27.383831 21.062201,27.51338 21.18382,27.664506 C 21.194868,27.674737 21.235393,27.714612 21.24632,27.72509 C 21.251851,27.735875 21.272073,27.774824 21.27757,27.785674 C 21.282892,27.794757 21.303647,27.8369 21.30882,27.846258 C 21.321992,27.871568 21.355511,27.936043 21.37132,27.967426 C 21.376966,27.978114 21.396964,28.017262 21.40257,28.02801 C 21.40239,28.034683 21.402626,28.083077 21.40257,28.088594 C 21.408105,28.11002 21.428262,28.1896 21.43382,28.209762 C 21.439547,28.220339 21.459391,28.259704 21.46507,28.270346 C 21.476102,28.332281 21.490569,28.443946 21.49632,28.512682 C 21.49635,28.533468 21.496523,28.612776 21.49632,28.63385 C 21.496978,28.678531 21.497906,28.768239 21.49632,28.815601 C 21.496404,28.821825 21.496321,28.870751 21.49632,28.876185 C 21.488511,28.947075 21.472138,29.060566 21.46507,29.118521 C 21.4653,29.124591 21.465044,29.173756 21.46507,29.179105 C 21.450883,29.240205 21.416414,29.36568 21.40257,29.421441 C 21.394497,29.453078 21.376582,29.521502 21.37132,29.542609 C 21.365935,29.563074 21.34822,29.632543 21.34007,29.663777 C 21.334926,29.685211 21.313984,29.765067 21.30882,29.784945 C 21.283564,29.842107 21.241673,29.921839 21.21507,29.966696 C 21.209548,29.977605 21.189366,30.016466 21.18382,30.02728 C 21.178309,30.038236 21.158103,30.077002 21.15257,30.087864 C 21.136717,30.103787 21.103051,30.135889 21.09007,30.148448 C 21.081302,30.156296 21.044093,30.193166 21.02757,30.209032 C 21.024425,30.208526 20.999064,30.20918 20.99632,30.209032 C 20.816986,30.312271 20.600812,30.318841 20.40257,30.209032 L 15.46507,28.02801 L 15.87132,25.362316 z M 14.99632,31.844799 L 19.90257,33.904653 C 20.124738,34.037182 20.357682,34.28482 20.49632,34.63166 C 20.501966,34.642348 20.521964,34.681496 20.52757,34.692244 C 20.535744,34.722817 20.552148,34.787858 20.55882,34.813412 C 20.568703,34.861428 20.583054,34.950879 20.59007,34.995164 C 20.595838,35.016096 20.615766,35.095125 20.62132,35.116332 C 20.621319,35.137155 20.621549,35.216393 20.62132,35.2375 C 20.621261,35.249343 20.621256,35.290352 20.62132,35.298084 C 20.621251,35.33224 20.621732,35.396022 20.62132,35.419252 C 20.621391,35.42549 20.621332,35.474388 20.62132,35.479836 C 20.621481,35.485778 20.621296,35.5351 20.62132,35.54042 C 20.617818,35.563312 20.594899,35.636732 20.59007,35.661587 C 20.588742,35.668974 20.591084,35.715636 20.59007,35.722171 C 20.590357,35.727516 20.590016,35.777612 20.59007,35.782755 C 20.581625,35.844968 20.568846,35.960998 20.55882,36.025091 C 20.527306,36.178951 20.478107,36.339513 20.43382,36.449179 C 20.429278,36.459729 20.407222,36.499623 20.40257,36.509763 C 20.39781,36.519497 20.376185,36.561014 20.37132,36.570347 C 20.366353,36.579282 20.345137,36.622387 20.34007,36.630931 C 20.334548,36.64184 20.314366,36.680701 20.30882,36.691515 C 20.298226,36.702005 20.257109,36.742436 20.24632,36.752098 C 20.240829,36.763141 20.220581,36.801727 20.21507,36.812682 C 20.19029,36.831532 20.142745,36.859668 20.12132,36.873266 C 20.110411,36.87302 20.069788,36.873831 20.05882,36.873266 C 19.893582,36.941225 19.705304,36.911131 19.52757,36.812682 L 14.59007,34.571076 L 14.99632,31.844799 z M 14.02757,38.387865 L 18.93382,40.447719 C 19.12425,40.561315 19.32528,40.729205 19.46507,40.992975 C 19.4696,41.001984 19.491926,41.044329 19.49632,41.053559 C 19.500575,41.063012 19.52346,41.104463 19.52757,41.114143 C 19.53291,41.134671 19.553837,41.214251 19.55882,41.235311 C 19.564499,41.245952 19.584434,41.285191 19.59007,41.295894 C 19.600159,41.343615 19.613598,41.434291 19.62132,41.477646 C 19.63009,41.533002 19.646158,41.651275 19.65257,41.719982 C 19.653091,41.730717 19.652466,41.765074 19.65257,41.780566 C 19.652319,41.814941 19.652608,41.878952 19.65257,41.901734 C 19.652924,41.956717 19.654568,42.086334 19.65257,42.14407 C 19.651575,42.151161 19.653861,42.197044 19.65257,42.204654 C 19.647845,42.228885 19.625022,42.303738 19.62132,42.325822 C 19.614082,42.379147 19.598662,42.458593 19.59007,42.507573 C 19.582172,42.549191 19.568118,42.642227 19.55882,42.689325 C 19.551695,42.717345 19.535217,42.784261 19.52757,42.810493 C 19.521977,42.821129 19.501944,42.86055 19.49632,42.871077 C 19.491058,42.892585 19.470449,42.971162 19.46507,42.992245 C 19.460528,43.002795 19.438472,43.04269 19.43382,43.052829 C 19.42906,43.062563 19.407435,43.10408 19.40257,43.113413 C 19.397603,43.122348 19.376387,43.165453 19.37132,43.173997 C 19.360699,43.184357 19.319648,43.22507 19.30882,43.234581 C 19.303319,43.245581 19.283092,43.284256 19.27757,43.295165 C 19.256502,43.312068 19.205558,43.341963 19.18382,43.355749 C 19.159595,43.372607 19.115273,43.404635 19.09007,43.416333 C 18.924832,43.484291 18.736554,43.454197 18.55882,43.355749 L 13.62132,41.114143 L 14.02757,38.387865 z"
+ style="opacity:0.44318201;fill:url(#radialGradient3202);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><g
+ id="g2937"><path
+ style="opacity:1;fill:url(#linearGradient3204);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 22.28125,15.84375 L 30.59375,17.78125 C 31.9375,18.15625 33.0625,19.78125 33.0625,19.78125 L 32.65625,21.375 C 32.65625,21.375 31.3125,19.53125 30.125,19.28125 C 30.125,19.28125 21.90625,17.28125 21.90625,17.28125 C 21.421036,17.149843 20.971366,16.960466 21.15625,16.375 C 21.34375,15.78125 21.71875,15.75 22.28125,15.84375 z"
+ id="path2284"
+ sodipodi:nodetypes="cccccczc" /></g><path
+ sodipodi:nodetypes="ccccccccccsccc"
+ id="path1345"
+ d="M 31.5,19 L 31.375,34.375 L 31.375,34.40625 L 31.375,34.4375 C 31.462702,35.84074 30.279231,37.074596 29.125,36.84375 L 18.65625,34.6875 C 18.1875,34.5625 16.9375,34.0625 17.34375,32.625 L 15.40625,32.125 C 14.727493,34.561693 16.65625,36.28125 18.09375,36.59375 L 28.75,38.78125 C 31.324613,39.296173 33.497942,36.947282 33.375,34.375 C 33.37399,34.353864 33.376323,34.333663 33.375,34.3125 L 33.5,19 L 31.5,19 z"
+ style="opacity:1;fill:#747474;fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3206);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 21.25,19.28125 L 29.5625,21.21875 C 30.90625,21.59375 32.03125,23.21875 32.03125,23.21875 L 31.625,24.8125 C 31.625,24.8125 30.28125,22.96875 29.09375,22.71875 C 29.09375,22.71875 20.875,20.71875 20.875,20.71875 C 20.389786,20.587343 19.940116,20.397966 20.125,19.8125 C 20.3125,19.21875 20.6875,19.1875 21.25,19.28125 z"
+ id="path2286"
+ sodipodi:nodetypes="cccccczc" /><path
+ sodipodi:nodetypes="cccccczc"
+ id="path2280"
+ d="M 24.09375,8.9687499 L 32.40625,10.90625 C 33.75,11.28125 34.46875,12.40625 34.46875,12.40625 L 34.0625,14 C 34.0625,14 33.125,12.65625 31.9375,12.40625 C 31.9375,12.40625 23.71875,10.40625 23.71875,10.40625 C 23.233536,10.274843 22.783866,10.085466 22.96875,9.4999999 C 23.15625,8.9062499 23.53125,8.8749999 24.09375,8.9687499 z"
+ style="opacity:1;fill:url(#linearGradient3208);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3210);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 23.1875,12.40625 L 31.5,14.34375 C 32.84375,14.71875 33.5625,15.90625 33.5625,15.90625 L 33.125,17.40625 C 33.125,17.40625 32.21875,16.09375 31.03125,15.84375 C 31.03125,15.84375 22.8125,13.84375 22.8125,13.84375 C 22.327286,13.712343 21.877616,13.522966 22.0625,12.9375 C 22.25,12.34375 22.625,12.3125 23.1875,12.40625 z"
+ id="path2282"
+ sodipodi:nodetypes="cccccczc" /><path
+ transform="matrix(1.26667,0,0,1.26667,-10.3083,-8.15)"
+ d="M 35.375,22.125 A 1.875,1.875 0 1 1 31.625,22.125 A 1.875,1.875 0 1 1 35.375,22.125 z"
+ sodipodi:ry="1.875"
+ sodipodi:rx="1.875"
+ sodipodi:cy="22.125"
+ sodipodi:cx="33.5"
+ id="path2220"
+ style="opacity:1;fill:url(#radialGradient3212);fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:0.789473;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ sodipodi:nodetypes="cccccczc"
+ id="path2288"
+ d="M 20.34375,22.71875 L 28.65625,24.65625 C 30,25.03125 31.125,26.65625 31.125,26.65625 L 30.71875,28.25 C 30.71875,28.25 29.375,26.40625 28.1875,26.15625 C 28.1875,26.15625 19.96875,24.15625 19.96875,24.15625 C 19.483536,24.024843 19.096366,23.835466 19.21875,23.25 C 19.342601,22.657518 19.78125,22.625 20.34375,22.71875 z"
+ style="opacity:1;fill:url(#linearGradient3214);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2292"
+ d="M 11.966306,22.990197 L 7.0288059,21.833947 L 7.4350559,20.427697 L 12.341306,21.490197 C 12.747556,21.615197 13.185056,21.865197 13.028806,22.458947 C 12.874388,23.045734 12.403806,23.115197 11.966306,22.990197 z"
+ style="opacity:1;fill:url(#linearGradient3216);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3218);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 17.53125,19.976562 L 12.59375,18.820312 L 13,17.414062 L 17.90625,18.476562 C 18.3125,18.601562 18.75,18.851562 18.59375,19.445312 C 18.439332,20.0321 17.96875,20.101562 17.53125,19.976562 z"
+ id="path2294"
+ sodipodi:nodetypes="cccczc" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2296"
+ d="M 18.40625,16.546875 L 13.46875,15.453125 L 13.875,14.046875 L 18.78125,15.046875 C 19.1875,15.171875 19.625,15.421875 19.46875,16.015625 C 19.314332,16.602412 18.84375,16.671875 18.40625,16.546875 z"
+ style="opacity:1;fill:url(#linearGradient3220);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3222);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 19.34375,13.148438 L 14.40625,12.085938 L 14.8125,10.679688 L 19.71875,11.648438 C 20.125,11.773438 20.5625,12.023438 20.40625,12.617188 C 20.251832,13.203974 19.78125,13.273438 19.34375,13.148438 z"
+ id="path2298"
+ sodipodi:nodetypes="cccczc" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2300"
+ d="M 20.25,9.78125 L 15.3125,8.71875 L 15.71875,7.3125 L 20.625,8.28125 C 21.03125,8.40625 21.46875,8.65625 21.3125,9.25 C 21.158082,9.836787 20.6875,9.90625 20.25,9.78125 z"
+ style="opacity:1;fill:url(#linearGradient3224);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:type="arc"
+ style="opacity:0.29545504;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3226);stroke-width:1.16238999;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="path2389"
+ sodipodi:cx="16.4375"
+ sodipodi:cy="46.375"
+ sodipodi:rx="11.1875"
+ sodipodi:ry="5.875"
+ d="M 27.625,46.375 A 11.1875,5.875 0 1 1 5.25,46.375 A 11.1875,5.875 0 1 1 27.625,46.375 z"
+ transform="matrix(0.916296,0,0,0.807726,10.1259,1.91671)" /></g></svg> \ No newline at end of file
diff --git a/empty.html b/empty.html
new file mode 100644
index 0000000..18e00a5
--- /dev/null
+++ b/empty.html
@@ -0,0 +1,9426 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<script id="versionArea" type="text/javascript">
+//<![CDATA[
+var version = {title: "TiddlyWiki", major: 2, minor: 5, revision: 0, date: new Date("Mar 9, 2009"), extensions: {}};
+//]]>
+</script>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<meta name="copyright" content="
+TiddlyWiki created by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
+
+Copyright (c) UnaMesa Association 2004-2009
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+Neither the name of the UnaMesa Association nor the names of its contributors may be
+used to endorse or promote products derived from this software without specific
+prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+" />
+<script id="jsheadArea" type="text/javascript">
+//<![CDATA[
+/*
+ * jQuery JavaScript Library v1.3.2
+ * http://jquery.com/
+ *
+ * Copyright (c) 2009 John Resig
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
+ * Revision: 6246
+ */
+(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
+/*
+ * Sizzle CSS Selector Engine - v0.9.3
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML=' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();
+//]]>
+</script>
+<!--PRE-HEAD-START-->
+<!--{{{-->
+<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
+<!--}}}-->
+<!--PRE-HEAD-END-->
+<title>
+
+</title>
+<style id="styleArea" type="text/css">
+#saveTest {display:none;}
+#messageArea {display:none;}
+#copyright {display:none;}
+#storeArea {display:none;}
+#storeArea div {padding:0.5em; margin:1em 0em 0em 0em; border-color:#fff #666 #444 #ddd; border-style:solid; border-width:2px; overflow:auto;}
+#shadowArea {display:none;}
+#javascriptWarning {width:100%; text-align:center; font-weight:bold; background-color:#dd1100; color:#fff; padding:1em 0em;}
+</style>
+<!--POST-HEAD-START-->
+<!--POST-HEAD-END-->
+</head>
+<body onload="main();" onunload="if(window.checkUnsavedChanges) checkUnsavedChanges(); if(window.scrubNodes) scrubNodes(document.body);">
+<!--PRE-BODY-START-->
+<!--PRE-BODY-END-->
+<div id="copyright">
+Welcome to TiddlyWiki created by Jeremy Ruston, Copyright &copy; 2007 UnaMesa Association
+</div>
+<noscript>
+<div id="javascriptWarning">
+This page requires JavaScript to function properly.<br /><br />If you are using Microsoft Internet Explorer you may need to click on the yellow bar above and select 'Allow Blocked Content'. You must then click 'Yes' on the following security warning.
+</div>
+</noscript>
+<div id="saveTest"></div>
+<div id="backstageCloak"></div>
+<div id="backstageButton"></div>
+<div id="backstageArea"><div id="backstageToolbar"></div></div>
+<div id="backstage">
+ <div id="backstagePanel"></div>
+</div>
+<div id="contentWrapper"></div>
+<div id="contentStash"></div>
+<div id="shadowArea">
+<div title="MarkupPreHead">
+<pre>&lt;!--{{{--&gt;
+&lt;link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' /&gt;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="ColorPalette">
+<pre>Background: #fff
+Foreground: #000
+PrimaryPale: #8cf
+PrimaryLight: #18f
+PrimaryMid: #04b
+PrimaryDark: #014
+SecondaryPale: #ffc
+SecondaryLight: #fe8
+SecondaryMid: #db4
+SecondaryDark: #841
+TertiaryPale: #eee
+TertiaryLight: #ccc
+TertiaryMid: #999
+TertiaryDark: #666
+Error: #f88</pre>
+</div>
+<div title="StyleSheetColors">
+<pre>/*{{{*/
+body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
+
+a {color:[[ColorPalette::PrimaryMid]];}
+a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
+a img {border:0;}
+
+h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
+h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
+h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}
+
+.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
+.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
+.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}
+
+.header {background:[[ColorPalette::PrimaryMid]];}
+.headerShadow {color:[[ColorPalette::Foreground]];}
+.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
+.headerForeground {color:[[ColorPalette::Background]];}
+.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}
+
+.tabSelected{color:[[ColorPalette::PrimaryDark]];
+ background:[[ColorPalette::TertiaryPale]];
+ border-left:1px solid [[ColorPalette::TertiaryLight]];
+ border-top:1px solid [[ColorPalette::TertiaryLight]];
+ border-right:1px solid [[ColorPalette::TertiaryLight]];
+}
+.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
+.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
+.tabContents .button {border:0;}
+
+#sidebar {}
+#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
+#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
+#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
+#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
+#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}
+
+.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
+.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
+.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
+.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
+ border:1px solid [[ColorPalette::PrimaryMid]];}
+.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
+.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
+.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
+.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
+ border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
+.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
+.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
+ border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
+
+.wizard .notChanged {background:transparent;}
+.wizard .changedLocally {background:#80ff80;}
+.wizard .changedServer {background:#8080ff;}
+.wizard .changedBoth {background:#ff8080;}
+.wizard .notFound {background:#ffff80;}
+.wizard .putToServer {background:#ff80ff;}
+.wizard .gotFromServer {background:#80ffff;}
+
+#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
+#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}
+
+.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}
+
+.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
+.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
+.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
+.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
+.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
+.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
+.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
+.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
+
+.tiddler .defaultCommand {font-weight:bold;}
+
+.shadow .title {color:[[ColorPalette::TertiaryDark]];}
+
+.title {color:[[ColorPalette::SecondaryDark]];}
+.subtitle {color:[[ColorPalette::TertiaryDark]];}
+
+.toolbar {color:[[ColorPalette::PrimaryMid]];}
+.toolbar a {color:[[ColorPalette::TertiaryLight]];}
+.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
+.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}
+
+.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
+.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
+.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
+.tagging .button, .tagged .button {border:none;}
+
+.footer {color:[[ColorPalette::TertiaryLight]];}
+.selected .footer {color:[[ColorPalette::TertiaryMid]];}
+
+.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
+.sparktick {background:[[ColorPalette::PrimaryDark]];}
+
+.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
+.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
+.lowlight {background:[[ColorPalette::TertiaryLight]];}
+
+.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}
+
+.imageLink, #displayArea .imageLink {background:transparent;}
+
+.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}
+
+.viewer .listTitle {list-style-type:none; margin-left:-2em;}
+.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
+.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}
+
+.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
+.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
+.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}
+
+.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
+.viewer code {color:[[ColorPalette::SecondaryDark]];}
+.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}
+
+.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}
+
+.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
+.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
+.editorFooter {color:[[ColorPalette::TertiaryMid]];}
+
+#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
+#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
+#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
+#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
+#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
+#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
+#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
+.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
+.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
+#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
+/*}}}*/</pre>
+</div>
+<div title="StyleSheetLayout">
+<pre>/*{{{*/
+* html .tiddler {height:1%;}
+
+body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}
+
+h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
+h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
+h4,h5,h6 {margin-top:1em;}
+h1 {font-size:1.35em;}
+h2 {font-size:1.25em;}
+h3 {font-size:1.1em;}
+h4 {font-size:1em;}
+h5 {font-size:.9em;}
+
+hr {height:1px;}
+
+a {text-decoration:none;}
+
+dt {font-weight:bold;}
+
+ol {list-style-type:decimal;}
+ol ol {list-style-type:lower-alpha;}
+ol ol ol {list-style-type:lower-roman;}
+ol ol ol ol {list-style-type:decimal;}
+ol ol ol ol ol {list-style-type:lower-alpha;}
+ol ol ol ol ol ol {list-style-type:lower-roman;}
+ol ol ol ol ol ol ol {list-style-type:decimal;}
+
+.txtOptionInput {width:11em;}
+
+#contentWrapper .chkOptionInput {border:0;}
+
+.externalLink {text-decoration:underline;}
+
+.indent {margin-left:3em;}
+.outdent {margin-left:3em; text-indent:-3em;}
+code.escaped {white-space:nowrap;}
+
+.tiddlyLinkExisting {font-weight:bold;}
+.tiddlyLinkNonExisting {font-style:italic;}
+
+/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
+a.tiddlyLinkNonExisting.shadow {font-weight:bold;}
+
+#mainMenu .tiddlyLinkExisting,
+ #mainMenu .tiddlyLinkNonExisting,
+ #sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
+#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}
+
+.header {position:relative;}
+.header a:hover {background:transparent;}
+.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
+.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}
+
+.siteTitle {font-size:3em;}
+.siteSubtitle {font-size:1.2em;}
+
+#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}
+
+#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
+#sidebarOptions {padding-top:0.3em;}
+#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
+#sidebarOptions input {margin:0.4em 0.5em;}
+#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
+#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
+#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
+#sidebarTabs .tabContents {width:15em; overflow:hidden;}
+
+.wizard {padding:0.1em 1em 0em 2em;}
+.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
+.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
+.wizardStep {padding:1em 1em 1em 1em;}
+.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
+.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
+.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
+.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}
+
+#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
+.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
+#messageArea a {text-decoration:underline;}
+
+.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
+.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}
+
+.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
+.popup .popupMessage {padding:0.4em;}
+.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
+.popup li.disabled {padding:0.4em;}
+.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
+.listBreak {font-size:1px; line-height:1px;}
+.listBreak div {margin:2px 0;}
+
+.tabset {padding:1em 0em 0em 0.5em;}
+.tab {margin:0em 0em 0em 0.25em; padding:2px;}
+.tabContents {padding:0.5em;}
+.tabContents ul, .tabContents ol {margin:0; padding:0;}
+.txtMainTab .tabContents li {list-style:none;}
+.tabContents li.listLink { margin-left:.75em;}
+
+#contentWrapper {display:block;}
+#splashScreen {display:none;}
+
+#displayArea {margin:1em 17em 0em 14em;}
+
+.toolbar {text-align:right; font-size:.9em;}
+
+.tiddler {padding:1em 1em 0em 1em;}
+
+.missing .viewer,.missing .title {font-style:italic;}
+
+.title {font-size:1.6em; font-weight:bold;}
+
+.missing .subtitle {display:none;}
+.subtitle {font-size:1.1em;}
+
+.tiddler .button {padding:0.2em 0.4em;}
+
+.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
+.isTag .tagging {display:block;}
+.tagged {margin:0.5em; float:right;}
+.tagging, .tagged {font-size:0.9em; padding:0.25em;}
+.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
+.tagClear {clear:both;}
+
+.footer {font-size:.9em;}
+.footer li {display:inline;}
+
+.annotation {padding:0.5em; margin:0.5em;}
+
+* html .viewer pre {width:99%; padding:0 0 1em 0;}
+.viewer {line-height:1.4em; padding-top:0.5em;}
+.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
+.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
+.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}
+
+.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
+.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
+table.listView {font-size:0.85em; margin:0.8em 1.0em;}
+table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}
+
+.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
+.viewer code {font-size:1.2em; line-height:1.4em;}
+
+.editor {font-size:1.1em;}
+.editor input, .editor textarea {display:block; width:100%; font:inherit;}
+.editorFooter {padding:0.25em 0em; font-size:.9em;}
+.editorFooter .button {padding-top:0px; padding-bottom:0px;}
+
+.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}
+
+.sparkline {line-height:1em;}
+.sparktick {outline:0;}
+
+.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
+.zoomer div {padding:1em;}
+
+* html #backstage {width:99%;}
+* html #backstageArea {width:99%;}
+#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
+#backstageToolbar {position:relative;}
+#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
+#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
+#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
+#backstage {position:relative; width:100%; z-index:50;}
+#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
+.backstagePanelFooter {padding-top:0.2em; float:right;}
+.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
+#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}
+
+.whenBackstage {display:none;}
+.backstageVisible .whenBackstage {display:block;}
+/*}}}*/</pre>
+</div>
+<div title="StyleSheetLocale">
+<pre>/***
+StyleSheet for use when a translation requires any css style changes.
+This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
+***/
+/*{{{*/
+body {font-size:0.8em;}
+#sidebarOptions {font-size:1.05em;}
+#sidebarOptions a {font-style:normal;}
+#sidebarOptions .sliderPanel {font-size:0.95em;}
+.subtitle {font-size:0.8em;}
+.viewer table.listView {font-size:0.95em;}
+/*}}}*/</pre>
+</div>
+<div title="StyleSheetPrint">
+<pre>/*{{{*/
+@media print {
+#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
+#displayArea {margin: 1em 1em 0em 1em;}
+/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
+noscript {display:none;}
+}
+/*}}}*/</pre>
+</div>
+<div title="PageTemplate">
+<pre>&lt;!--{{{--&gt;
+&lt;div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'&gt;
+&lt;div class='headerShadow'&gt;
+&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
+&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
+&lt;/div&gt;
+&lt;div class='headerForeground'&gt;
+&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
+&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+&lt;div id='mainMenu' refresh='content' tiddler='MainMenu'&gt;&lt;/div&gt;
+&lt;div id='sidebar'&gt;
+&lt;div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'&gt;&lt;/div&gt;
+&lt;div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div id='displayArea'&gt;
+&lt;div id='messageArea'&gt;&lt;/div&gt;
+&lt;div id='tiddlerDisplay'&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="ViewTemplate">
+<pre>&lt;!--{{{--&gt;
+&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'&gt;&lt;/div&gt;
+&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
+&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;
+&lt;div class='tagging' macro='tagging'&gt;&lt;/div&gt;
+&lt;div class='tagged' macro='tags'&gt;&lt;/div&gt;
+&lt;div class='viewer' macro='view text wikified'&gt;&lt;/div&gt;
+&lt;div class='tagClear'&gt;&lt;/div&gt;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="EditTemplate">
+<pre>&lt;!--{{{--&gt;
+&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'&gt;&lt;/div&gt;
+&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
+&lt;div class='editor' macro='edit title'&gt;&lt;/div&gt;
+&lt;div macro='annotations'&gt;&lt;/div&gt;
+&lt;div class='editor' macro='edit text'&gt;&lt;/div&gt;
+&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;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="GettingStarted">
+<pre>To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
+* SiteTitle &amp; SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
+* MainMenu: The menu (usually on the left)
+* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
+You'll also need to enter your username for signing your edits: &lt;&lt;option txtUserName&gt;&gt;</pre>
+</div>
+<div title="OptionsPanel">
+<pre>These InterfaceOptions for customising TiddlyWiki are saved in your browser
+
+Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)
+
+&lt;&lt;option txtUserName&gt;&gt;
+&lt;&lt;option chkSaveBackups&gt;&gt; SaveBackups
+&lt;&lt;option chkAutoSave&gt;&gt; AutoSave
+&lt;&lt;option chkRegExpSearch&gt;&gt; RegExpSearch
+&lt;&lt;option chkCaseSensitiveSearch&gt;&gt; CaseSensitiveSearch
+&lt;&lt;option chkAnimate&gt;&gt; EnableAnimations
+
+----
+Also see [[AdvancedOptions]]</pre>
+</div>
+<div title="ImportTiddlers">
+<pre>&lt;&lt;importTiddlers&gt;&gt;</pre>
+</div>
+</div>
+<!--POST-SHADOWAREA-->
+<div id="storeArea">
+</div>
+<!--POST-STOREAREA-->
+<!--POST-BODY-START-->
+<!--POST-BODY-END-->
+<script id="jsArea" type="text/javascript">
+//<![CDATA[
+//
+// Please note:
+//
+// * This code is designed to be readable but for compactness it only includes brief comments. You can see fuller comments
+// in the project Subversion repository at http://svn.tiddlywiki.org/Trunk/core/
+//
+// * You should never need to modify this source code directly. TiddlyWiki is carefully designed to allow deep customisation
+// without changing the core code. Please consult the development group at http://groups.google.com/group/TiddlyWikiDev
+//
+
+//--
+//-- Configuration repository
+//--
+
+// Miscellaneous options
+var config = {
+ numRssItems: 20, // Number of items in the RSS feed
+ animDuration: 400, // Duration of UI animations in milliseconds
+ cascadeFast: 20, // Speed for cascade animations (higher == slower)
+ cascadeSlow: 60, // Speed for EasterEgg cascade animations
+ cascadeDepth: 5, // Depth of cascade animation
+ locale: "en" // W3C language tag
+};
+
+// Hashmap of alternative parsers for the wikifier
+config.parsers = {};
+
+// Adaptors
+config.adaptors = {};
+config.defaultAdaptor = null;
+
+// Backstage tasks
+config.tasks = {};
+
+// Annotations
+config.annotations = {};
+
+// Custom fields to be automatically added to new tiddlers
+config.defaultCustomFields = {};
+
+// Messages
+config.messages = {
+ messageClose: {},
+ dates: {},
+ tiddlerPopup: {}
+};
+
+// Options that can be set in the options panel and/or cookies
+config.options = {
+ chkRegExpSearch: false,
+ chkCaseSensitiveSearch: false,
+ chkIncrementalSearch: true,
+ chkAnimate: true,
+ chkSaveBackups: true,
+ chkAutoSave: false,
+ chkGenerateAnRssFeed: false,
+ chkSaveEmptyTemplate: false,
+ chkOpenInNewWindow: true,
+ chkToggleLinks: false,
+ chkHttpReadOnly: true,
+ chkForceMinorUpdate: false,
+ chkConfirmDelete: true,
+ chkInsertTabs: false,
+ chkUsePreForStorage: true, // Whether to use <pre> format for storage
+ chkDisplayInstrumentation: false,
+ txtBackupFolder: "",
+ txtEditorFocus: "text",
+ txtMainTab: "tabTimeline",
+ txtMoreTab: "moreTabAll",
+ txtMaxEditRows: "30",
+ txtFileSystemCharSet: "UTF-8",
+ txtTheme: ""
+ };
+config.optionsDesc = {};
+
+// Default tiddler templates
+var DEFAULT_VIEW_TEMPLATE = 1;
+var DEFAULT_EDIT_TEMPLATE = 2;
+config.tiddlerTemplates = {
+ 1: "ViewTemplate",
+ 2: "EditTemplate"
+};
+
+// More messages (rather a legacy layout that should not really be like this)
+config.views = {
+ wikified: {
+ tag: {}
+ },
+ editor: {
+ tagChooser: {}
+ }
+};
+
+// Backstage tasks
+config.backstageTasks = ["save","sync","importTask","tweak","upgrade","plugins"];
+
+// Extensions
+config.extensions = {};
+
+// Macros; each has a 'handler' member that is inserted later
+config.macros = {
+ today: {},
+ version: {},
+ search: {sizeTextbox: 15},
+ tiddler: {},
+ tag: {},
+ tags: {},
+ tagging: {},
+ timeline: {},
+ allTags: {},
+ list: {
+ all: {},
+ missing: {},
+ orphans: {},
+ shadowed: {},
+ touched: {},
+ filter: {}
+ },
+ closeAll: {},
+ permaview: {},
+ saveChanges: {},
+ slider: {},
+ option: {},
+ options: {},
+ newTiddler: {},
+ newJournal: {},
+ tabs: {},
+ gradient: {},
+ message: {},
+ view: {defaultView: "text"},
+ edit: {},
+ tagChooser: {},
+ toolbar: {},
+ plugins: {},
+ refreshDisplay: {},
+ importTiddlers: {},
+ upgrade: {
+ source: "http://www.tiddlywiki.com/upgrade/",
+ backupExtension: "pre.core.upgrade"
+ },
+ sync: {},
+ annotations: {}
+};
+
+// Commands supported by the toolbar macro
+config.commands = {
+ closeTiddler: {},
+ closeOthers: {},
+ editTiddler: {},
+ saveTiddler: {hideReadOnly: true},
+ cancelTiddler: {},
+ deleteTiddler: {hideReadOnly: true},
+ permalink: {},
+ references: {type: "popup"},
+ jump: {type: "popup"},
+ syncing: {type: "popup"},
+ fields: {type: "popup"}
+};
+
+// Browser detection... In a very few places, there's nothing else for it but to know what browser we're using.
+config.userAgent = navigator.userAgent.toLowerCase();
+config.browser = {
+ isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1,
+ isGecko: config.userAgent.indexOf("gecko") != -1,
+ ieVersion: /MSIE (\d.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0"
+ isSafari: config.userAgent.indexOf("applewebkit") != -1,
+ isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")),
+ firefoxDate: /gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD"
+ isOpera: config.userAgent.indexOf("opera") != -1,
+ isLinux: config.userAgent.indexOf("linux") != -1,
+ isUnix: config.userAgent.indexOf("x11") != -1,
+ isMac: config.userAgent.indexOf("mac") != -1,
+ isWindows: config.userAgent.indexOf("win") != -1
+};
+
+// Basic regular expressions
+config.textPrimitives = {
+ upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]",
+ lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]",
+ anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]",
+ anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]"
+};
+if(config.browser.isBadSafari) {
+ config.textPrimitives = {
+ upperLetter: "[A-Z\u00c0-\u00de]",
+ lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]",
+ anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]",
+ anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]"
+ };
+}
+config.textPrimitives.sliceSeparator = "::";
+config.textPrimitives.sectionSeparator = "##";
+config.textPrimitives.urlPattern = "(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
+config.textPrimitives.unWikiLink = "~";
+config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" +
+ config.textPrimitives.lowerLetter + "+" +
+ config.textPrimitives.upperLetter +
+ config.textPrimitives.anyLetter + "*)|(?:" +
+ config.textPrimitives.upperLetter + "{2,}" +
+ config.textPrimitives.lowerLetter + "+))";
+
+config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)";
+config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg");
+
+config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]";
+config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
+config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" +
+ config.textPrimitives.brackettedLink + ")|(?:" +
+ config.textPrimitives.urlPattern + ")","mg");
+config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" +
+ config.textPrimitives.titledBrackettedLink + ")|(?:" +
+ config.textPrimitives.brackettedLink + ")|(?:" +
+ config.textPrimitives.urlPattern + ")","mg");
+
+config.glyphs = {
+ browsers: [
+ function() {return config.browser.isIE;},
+ function() {return true;}
+ ],
+ currBrowser: null,
+ codes: {
+ downTriangle: ["\u25BC","\u25BE"],
+ downArrow: ["\u2193","\u2193"],
+ bentArrowLeft: ["\u2190","\u21A9"],
+ bentArrowRight: ["\u2192","\u21AA"]
+ }
+};
+
+//--
+//-- Shadow tiddlers
+//--
+
+config.shadowTiddlers = {
+ StyleSheet: "",
+ MarkupPreHead: "",
+ MarkupPostHead: "",
+ MarkupPreBody: "",
+ MarkupPostBody: "",
+ TabTimeline: '<<timeline>>',
+ TabAll: '<<list all>>',
+ TabTags: '<<allTags excludeLists>>',
+ TabMoreMissing: '<<list missing>>',
+ TabMoreOrphans: '<<list orphans>>',
+ TabMoreShadowed: '<<list shadowed>>',
+ AdvancedOptions: '<<options>>',
+ PluginManager: '<<plugins>>',
+ ToolbarCommands: '|~ViewToolbar|closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|\n|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|'
+};
+
+//--
+//-- Translateable strings
+//--
+
+// Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone
+
+merge(config.options,{
+ txtUserName: "YourName"});
+
+merge(config.tasks,{
+ save: {text: "save", tooltip: "Save your changes to this TiddlyWiki", action: saveChanges},
+ sync: {text: "sync", tooltip: "Synchronise changes with other TiddlyWiki files and servers", content: '<<sync>>'},
+ importTask: {text: "import", tooltip: "Import tiddlers and plugins from other TiddlyWiki files and servers", content: '<<importTiddlers>>'},
+ tweak: {text: "tweak", tooltip: "Tweak the appearance and behaviour of TiddlyWiki", content: '<<options>>'},
+ upgrade: {text: "upgrade", tooltip: "Upgrade TiddlyWiki core code", content: '<<upgrade>>'},
+ plugins: {text: "plugins", tooltip: "Manage installed plugins", content: '<<plugins>>'}
+});
+
+// Options that can be set in the options panel and/or cookies
+merge(config.optionsDesc,{
+ txtUserName: "Username for signing your edits",
+ chkRegExpSearch: "Enable regular expressions for searches",
+ chkCaseSensitiveSearch: "Case-sensitive searching",
+ chkIncrementalSearch: "Incremental key-by-key searching",
+ chkAnimate: "Enable animations",
+ chkSaveBackups: "Keep backup file when saving changes",
+ chkAutoSave: "Automatically save changes",
+ chkGenerateAnRssFeed: "Generate an RSS feed when saving changes",
+ chkSaveEmptyTemplate: "Generate an empty template when saving changes",
+ chkOpenInNewWindow: "Open external links in a new window",
+ chkToggleLinks: "Clicking on links to open tiddlers causes them to close",
+ chkHttpReadOnly: "Hide editing features when viewed over HTTP",
+ chkForceMinorUpdate: "Don't update modifier username and date when editing tiddlers",
+ chkConfirmDelete: "Require confirmation before deleting tiddlers",
+ chkInsertTabs: "Use the tab key to insert tab characters instead of moving between fields",
+ txtBackupFolder: "Name of folder to use for backups",
+ txtMaxEditRows: "Maximum number of rows in edit boxes",
+ txtFileSystemCharSet: "Default character set for saving changes (Firefox/Mozilla only)"});
+
+merge(config.messages,{
+ customConfigError: "Problems were encountered loading plugins. See PluginManager for details",
+ pluginError: "Error: %0",
+ pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag",
+ pluginForced: "Executed because forced via 'systemConfigForce' tag",
+ pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki",
+ nothingSelected: "Nothing is selected. You must select one or more items first",
+ savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#Download for details",
+ subtitleUnknown: "(unknown)",
+ undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
+ shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value",
+ tiddlerLinkTooltip: "%0 - %1, %2",
+ externalLinkTooltip: "External link to %0",
+ noTags: "There are no tagged tiddlers",
+ notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
+ cantSaveError: "It's not possible to save changes. Possible reasons include:\n- your browser doesn't support saving (Firefox, Internet Explorer, Safari and Opera all work if properly configured)\n- the pathname to your TiddlyWiki file contains illegal characters\n- the TiddlyWiki HTML file has been moved or renamed",
+ invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
+ backupSaved: "Backup saved",
+ backupFailed: "Failed to save backup file",
+ rssSaved: "RSS feed saved",
+ rssFailed: "Failed to save RSS feed file",
+ emptySaved: "Empty template saved",
+ emptyFailed: "Failed to save empty template file",
+ mainSaved: "Main TiddlyWiki file saved",
+ mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
+ macroError: "Error in macro <<\%0>>",
+ macroErrorDetails: "Error while executing macro <<\%0>>:\n%1",
+ missingMacro: "No such macro",
+ overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
+ unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
+ confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------",
+ saveInstructions: "SaveChanges",
+ unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'",
+ tiddlerSaveError: "Error when saving tiddler '%0'",
+ tiddlerLoadError: "Error when loading tiddler '%0'",
+ wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.",
+ invalidFieldName: "Invalid field name %0",
+ fieldCannotBeChanged: "Field '%0' cannot be changed",
+ loadingMissingTiddler: "Attempting to retrieve the tiddler '%0' from the '%1' server at:\n\n'%2' in the workspace '%3'",
+ upgradeDone: "The upgrade to version %0 is now complete\n\nClick 'OK' to reload the newly upgraded TiddlyWiki"});
+
+merge(config.messages.messageClose,{
+ text: "close",
+ tooltip: "close this message area"});
+
+config.messages.backstage = {
+ open: {text: "backstage", tooltip: "Open the backstage area to perform authoring and editing tasks"},
+ close: {text: "close", tooltip: "Close the backstage area"},
+ prompt: "backstage: ",
+ decal: {
+ edit: {text: "edit", tooltip: "Edit the tiddler '%0'"}
+ }
+};
+
+config.messages.listView = {
+ tiddlerTooltip: "Click for the full text of this tiddler",
+ previewUnavailable: "(preview not available)"
+};
+
+config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
+config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
+config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+// suffixes for dates, eg "1st","2nd","3rd"..."30th","31st"
+config.messages.dates.daySuffixes = ["st","nd","rd","th","th","th","th","th","th","th",
+ "th","th","th","th","th","th","th","th","th","th",
+ "st","nd","rd","th","th","th","th","th","th","th",
+ "st"];
+config.messages.dates.am = "am";
+config.messages.dates.pm = "pm";
+
+merge(config.messages.tiddlerPopup,{
+ });
+
+merge(config.views.wikified.tag,{
+ labelNoTags: "no tags",
+ labelTags: "tags: ",
+ openTag: "Open tag '%0'",
+ tooltip: "Show tiddlers tagged with '%0'",
+ openAllText: "Open all",
+ openAllTooltip: "Open all of these tiddlers",
+ popupNone: "No other tiddlers tagged with '%0'"});
+
+merge(config.views.wikified,{
+ defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it",
+ defaultModifier: "(missing)",
+ shadowModifier: "(built-in shadow tiddler)",
+ dateFormat: "DD MMM YYYY",
+ createdPrompt: "created"});
+
+merge(config.views.editor,{
+ tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
+ defaultText: "Type the text for '%0'"});
+
+merge(config.views.editor.tagChooser,{
+ text: "tags",
+ tooltip: "Choose existing tags to add to this tiddler",
+ popupNone: "There are no tags defined",
+ tagTooltip: "Add the tag '%0'"});
+
+merge(config.messages,{
+ sizeTemplates:
+ [
+ {unit: 1024*1024*1024, template: "%0\u00a0GB"},
+ {unit: 1024*1024, template: "%0\u00a0MB"},
+ {unit: 1024, template: "%0\u00a0KB"},
+ {unit: 1, template: "%0\u00a0B"}
+ ]});
+
+merge(config.macros.search,{
+ label: "search",
+ prompt: "Search this TiddlyWiki",
+ accessKey: "F",
+ successMsg: "%0 tiddlers found matching %1",
+ failureMsg: "No tiddlers found matching %0"});
+
+merge(config.macros.tagging,{
+ label: "tagging: ",
+ labelNotTag: "not tagging",
+ tooltip: "List of tiddlers tagged with '%0'"});
+
+merge(config.macros.timeline,{
+ dateFormat: "DD MMM YYYY"});
+
+merge(config.macros.allTags,{
+ tooltip: "Show tiddlers tagged with '%0'",
+ noTags: "There are no tagged tiddlers"});
+
+config.macros.list.all.prompt = "All tiddlers in alphabetical order";
+config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined";
+config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers";
+config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents";
+config.macros.list.touched.prompt = "Tiddlers that have been modified locally";
+
+merge(config.macros.closeAll,{
+ label: "close all",
+ prompt: "Close all displayed tiddlers (except any that are being edited)"});
+
+merge(config.macros.permaview,{
+ label: "permaview",
+ prompt: "Link to an URL that retrieves all the currently displayed tiddlers"});
+
+merge(config.macros.saveChanges,{
+ label: "save changes",
+ prompt: "Save all tiddlers to create a new TiddlyWiki",
+ accessKey: "S"});
+
+merge(config.macros.newTiddler,{
+ label: "new tiddler",
+ prompt: "Create a new tiddler",
+ title: "New Tiddler",
+ accessKey: "N"});
+
+merge(config.macros.newJournal,{
+ label: "new journal",
+ prompt: "Create a new tiddler from the current date and time",
+ accessKey: "J"});
+
+merge(config.macros.options,{
+ wizardTitle: "Tweak advanced options",
+ step1Title: "These options are saved in cookies in your browser",
+ step1Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='false' name='chkUnknown'>Show unknown options</input>",
+ unknownDescription: "//(unknown)//",
+ listViewTemplate: {
+ columns: [
+ {name: 'Option', field: 'option', title: "Option", type: 'String'},
+ {name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
+ {name: 'Name', field: 'name', title: "Name", type: 'String'}
+ ],
+ rowClasses: [
+ {className: 'lowlight', field: 'lowlight'}
+ ]}
+ });
+
+merge(config.macros.plugins,{
+ wizardTitle: "Manage plugins",
+ step1Title: "Currently loaded plugins",
+ step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
+ skippedText: "(This plugin has not been executed because it was added since startup)",
+ noPluginText: "There are no plugins installed",
+ confirmDeleteText: "Are you sure you want to delete these plugins:\n\n%0",
+ removeLabel: "remove systemConfig tag",
+ removePrompt: "Remove systemConfig tag",
+ deleteLabel: "delete",
+ deletePrompt: "Delete these tiddlers forever",
+ listViewTemplate: {
+ columns: [
+ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
+ {name: 'Description', field: 'desc', title: "Description", type: 'String'},
+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
+ {name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'},
+ {name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'},
+ {name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
+ {name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'},
+ {name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
+ {name: 'Log', field: 'log', title: "Log", type: 'StringList'}
+ ],
+ rowClasses: [
+ {className: 'error', field: 'error'},
+ {className: 'warning', field: 'warning'}
+ ]}
+ });
+
+merge(config.macros.toolbar,{
+ moreLabel: "more",
+ morePrompt: "Reveal further commands"
+ });
+
+merge(config.macros.refreshDisplay,{
+ label: "refresh",
+ prompt: "Redraw the entire TiddlyWiki display"
+ });
+
+merge(config.macros.importTiddlers,{
+ readOnlyWarning: "You cannot import into a read-only TiddlyWiki file. Try opening it from a file:// URL",
+ wizardTitle: "Import tiddlers from another file or server",
+ step1Title: "Step 1: Locate the server or TiddlyWiki file",
+ step1Html: "Specify the type of the server: <select name='selTypes'><option value=''>Choose...</option></select><br>Enter the URL or pathname here: <input type='text' size=50 name='txtPath'><br>...or browse for a file: <input type='file' size=50 name='txtBrowse'><br><hr>...or select a pre-defined feed: <select name='selFeeds'><option value=''>Choose...</option></select>",
+ openLabel: "open",
+ openPrompt: "Open the connection to this file or server",
+ openError: "There were problems fetching the tiddlywiki file",
+ statusOpenHost: "Opening the host",
+ statusGetWorkspaceList: "Getting the list of available workspaces",
+ step2Title: "Step 2: Choose the workspace",
+ step2Html: "Enter a workspace name: <input type='text' size=50 name='txtWorkspace'><br>...or select a workspace: <select name='selWorkspace'><option value=''>Choose...</option></select>",
+ cancelLabel: "cancel",
+ cancelPrompt: "Cancel this import",
+ statusOpenWorkspace: "Opening the workspace",
+ statusGetTiddlerList: "Getting the list of available tiddlers",
+ errorGettingTiddlerList: "Error getting list of tiddlers, click Cancel to try again",
+ step3Title: "Step 3: Choose the tiddlers to import",
+ step3Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='true' name='chkSync'>Keep these tiddlers linked to this server so that you can synchronise subsequent changes</input><br><input type='checkbox' name='chkSave'>Save the details of this server in a 'systemServer' tiddler called:</input> <input type='text' size=25 name='txtSaveTiddler'>",
+ importLabel: "import",
+ importPrompt: "Import these tiddlers",
+ confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0",
+ step4Title: "Step 4: Importing %0 tiddler(s)",
+ step4Html: "<input type='hidden' name='markReport'></input>", // DO NOT TRANSLATE
+ doneLabel: "done",
+ donePrompt: "Close this wizard",
+ statusDoingImport: "Importing tiddlers",
+ statusDoneImport: "All tiddlers imported",
+ systemServerNamePattern: "%2 on %1",
+ systemServerNamePatternNoWorkspace: "%1",
+ confirmOverwriteSaveTiddler: "The tiddler '%0' already exists. Click 'OK' to overwrite it with the details of this server, or 'Cancel' to leave it unchanged",
+ serverSaveTemplate: "|''Type:''|%0|\n|''URL:''|%1|\n|''Workspace:''|%2|\n\nThis tiddler was automatically created to record the details of this server",
+ serverSaveModifier: "(System)",
+ listViewTemplate: {
+ columns: [
+ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
+ {name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
+ ],
+ rowClasses: [
+ ]}
+ });
+
+merge(config.macros.upgrade,{
+ wizardTitle: "Upgrade TiddlyWiki core code",
+ step1Title: "Update or repair this TiddlyWiki to the latest release",
+ step1Html: "You are about to upgrade to the latest release of the TiddlyWiki core code (from <a href='%0' class='externalLink' target='_blank'>%1</a>). Your content will be preserved across the upgrade.<br><br>Note that core upgrades have been known to interfere with older plugins. If you run into problems with the upgraded file, see <a href='http://www.tiddlywiki.org/wiki/CoreUpgrades' class='externalLink' target='_blank'>http://www.tiddlywiki.org/wiki/CoreUpgrades</a>",
+ errorCantUpgrade: "Unable to upgrade this TiddlyWiki. You can only perform upgrades on TiddlyWiki files stored locally",
+ errorNotSaved: "You must save changes before you can perform an upgrade",
+ step2Title: "Confirm the upgrade details",
+ step2Html_downgrade: "You are about to downgrade to TiddlyWiki version %0 from %1.<br><br>Downgrading to an earlier version of the core code is not recommended",
+ step2Html_restore: "This TiddlyWiki appears to be already using the latest version of the core code (%0).<br><br>You can continue to upgrade anyway to ensure that the core code hasn't been corrupted or damaged",
+ step2Html_upgrade: "You are about to upgrade to TiddlyWiki version %0 from %1",
+ upgradeLabel: "upgrade",
+ upgradePrompt: "Prepare for the upgrade process",
+ statusPreparingBackup: "Preparing backup",
+ statusSavingBackup: "Saving backup file",
+ errorSavingBackup: "There was a problem saving the backup file",
+ statusLoadingCore: "Loading core code",
+ errorLoadingCore: "Error loading the core code",
+ errorCoreFormat: "Error with the new core code",
+ statusSavingCore: "Saving the new core code",
+ statusReloadingCore: "Reloading the new core code",
+ startLabel: "start",
+ startPrompt: "Start the upgrade process",
+ cancelLabel: "cancel",
+ cancelPrompt: "Cancel the upgrade process",
+ step3Title: "Upgrade cancelled",
+ step3Html: "You have cancelled the upgrade process"
+ });
+
+merge(config.macros.sync,{
+ listViewTemplate: {
+ columns: [
+ {name: 'Selected', field: 'selected', rowName: 'title', type: 'Selector'},
+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
+ {name: 'Server Type', field: 'serverType', title: "Server type", type: 'String'},
+ {name: 'Server Host', field: 'serverHost', title: "Server host", type: 'String'},
+ {name: 'Server Workspace', field: 'serverWorkspace', title: "Server workspace", type: 'String'},
+ {name: 'Status', field: 'status', title: "Synchronisation status", type: 'String'},
+ {name: 'Server URL', field: 'serverUrl', title: "Server URL", text: "View", type: 'Link'}
+ ],
+ rowClasses: [
+ ],
+ buttons: [
+ {caption: "Sync these tiddlers", name: 'sync'}
+ ]},
+ wizardTitle: "Synchronize with external servers and files",
+ step1Title: "Choose the tiddlers you want to synchronize",
+ step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
+ syncLabel: "sync",
+ syncPrompt: "Sync these tiddlers",
+ hasChanged: "Changed while unplugged",
+ hasNotChanged: "Unchanged while unplugged",
+ syncStatusList: {
+ none: {text: "...", display:null, className:'notChanged'},
+ changedServer: {text: "Changed on server", display:null, className:'changedServer'},
+ changedLocally: {text: "Changed while unplugged", display:null, className:'changedLocally'},
+ changedBoth: {text: "Changed while unplugged and on server", display:null, className:'changedBoth'},
+ notFound: {text: "Not found on server", display:null, className:'notFound'},
+ putToServer: {text: "Saved update on server", display:null, className:'putToServer'},
+ gotFromServer: {text: "Retrieved update from server", display:null, className:'gotFromServer'}
+ }
+ });
+
+merge(config.macros.annotations,{
+ });
+
+merge(config.commands.closeTiddler,{
+ text: "close",
+ tooltip: "Close this tiddler"});
+
+merge(config.commands.closeOthers,{
+ text: "close others",
+ tooltip: "Close all other tiddlers"});
+
+merge(config.commands.editTiddler,{
+ text: "edit",
+ tooltip: "Edit this tiddler",
+ readOnlyText: "view",
+ readOnlyTooltip: "View the source of this tiddler"});
+
+merge(config.commands.saveTiddler,{
+ text: "done",
+ tooltip: "Save changes to this tiddler"});
+
+merge(config.commands.cancelTiddler,{
+ text: "cancel",
+ tooltip: "Undo changes to this tiddler",
+ warning: "Are you sure you want to abandon your changes to '%0'?",
+ readOnlyText: "done",
+ readOnlyTooltip: "View this tiddler normally"});
+
+merge(config.commands.deleteTiddler,{
+ text: "delete",
+ tooltip: "Delete this tiddler",
+ warning: "Are you sure you want to delete '%0'?"});
+
+merge(config.commands.permalink,{
+ text: "permalink",
+ tooltip: "Permalink for this tiddler"});
+
+merge(config.commands.references,{
+ text: "references",
+ tooltip: "Show tiddlers that link to this one",
+ popupNone: "No references"});
+
+merge(config.commands.jump,{
+ text: "jump",
+ tooltip: "Jump to another open tiddler"});
+
+merge(config.commands.syncing,{
+ text: "syncing",
+ tooltip: "Control synchronisation of this tiddler with a server or external file",
+ currentlySyncing: "<div>Currently syncing via <span class='popupHighlight'>'%0'</span> to:</"+"div><div>host: <span class='popupHighlight'>%1</span></"+"div><div>workspace: <span class='popupHighlight'>%2</span></"+"div>", // Note escaping of closing <div> tag
+ notCurrentlySyncing: "Not currently syncing",
+ captionUnSync: "Stop synchronising this tiddler",
+ chooseServer: "Synchronise this tiddler with another server:",
+ currServerMarker: "\u25cf ",
+ notCurrServerMarker: " "});
+
+merge(config.commands.fields,{
+ text: "fields",
+ tooltip: "Show the extended fields of this tiddler",
+ emptyText: "There are no extended fields for this tiddler",
+ listViewTemplate: {
+ columns: [
+ {name: 'Field', field: 'field', title: "Field", type: 'String'},
+ {name: 'Value', field: 'value', title: "Value", type: 'String'}
+ ],
+ rowClasses: [
+ ],
+ buttons: [
+ ]}});
+
+merge(config.shadowTiddlers,{
+ DefaultTiddlers: "[[GettingStarted]]",
+ MainMenu: "[[GettingStarted]]",
+ SiteTitle: "My TiddlyWiki",
+ SiteSubtitle: "a reusable non-linear personal web notebook",
+ SiteUrl: "http://www.tiddlywiki.com/",
+ SideBarOptions: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options \u00bb" "Change TiddlyWiki advanced options">>',
+ SideBarTabs: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>',
+ TabMore: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>'
+ });
+
+merge(config.annotations,{
+ AdvancedOptions: "This shadow tiddler provides access to several advanced options",
+ ColorPalette: "These values in this shadow tiddler determine the colour scheme of the ~TiddlyWiki user interface",
+ DefaultTiddlers: "The tiddlers listed in this shadow tiddler will be automatically displayed when ~TiddlyWiki starts up",
+ EditTemplate: "The HTML template in this shadow tiddler determines how tiddlers look while they are being edited",
+ GettingStarted: "This shadow tiddler provides basic usage instructions",
+ ImportTiddlers: "This shadow tiddler provides access to importing tiddlers",
+ MainMenu: "This shadow tiddler is used as the contents of the main menu in the left-hand column of the screen",
+ MarkupPreHead: "This tiddler is inserted at the top of the <head> section of the TiddlyWiki HTML file",
+ MarkupPostHead: "This tiddler is inserted at the bottom of the <head> section of the TiddlyWiki HTML file",
+ MarkupPreBody: "This tiddler is inserted at the top of the <body> section of the TiddlyWiki HTML file",
+ MarkupPostBody: "This tiddler is inserted at the end of the <body> section of the TiddlyWiki HTML file immediately after the script block",
+ OptionsPanel: "This shadow tiddler is used as the contents of the options panel slider in the right-hand sidebar",
+ PageTemplate: "The HTML template in this shadow tiddler determines the overall ~TiddlyWiki layout",
+ PluginManager: "This shadow tiddler provides access to the plugin manager",
+ SideBarOptions: "This shadow tiddler is used as the contents of the option panel in the right-hand sidebar",
+ SideBarTabs: "This shadow tiddler is used as the contents of the tabs panel in the right-hand sidebar",
+ SiteSubtitle: "This shadow tiddler is used as the second part of the page title",
+ SiteTitle: "This shadow tiddler is used as the first part of the page title",
+ SiteUrl: "This shadow tiddler should be set to the full target URL for publication",
+ StyleSheetColors: "This shadow tiddler contains CSS definitions related to the color of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler",
+ StyleSheet: "This tiddler can contain custom CSS definitions",
+ StyleSheetLayout: "This shadow tiddler contains CSS definitions related to the layout of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler",
+ StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale",
+ StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing",
+ TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar",
+ TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar",
+ TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar",
+ TabMoreOrphans: "This shadow tiddler contains the contents of the 'Orphans' tab in the right-hand sidebar",
+ TabMoreShadowed: "This shadow tiddler contains the contents of the 'Shadowed' tab in the right-hand sidebar",
+ TabTags: "This shadow tiddler contains the contents of the 'Tags' tab in the right-hand sidebar",
+ TabTimeline: "This shadow tiddler contains the contents of the 'Timeline' tab in the right-hand sidebar",
+ ToolbarCommands: "This shadow tiddler determines which commands are shown in tiddler toolbars",
+ ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look"
+ });
+
+//--
+//-- Main
+//--
+
+var params = null; // Command line parameters
+var store = null; // TiddlyWiki storage
+var story = null; // Main story
+var formatter = null; // Default formatters for the wikifier
+var anim = typeof Animator == "function" ? new Animator() : null; // Animation engine
+var readOnly = false; // Whether we're in readonly mode
+var highlightHack = null; // Embarrassing hack department...
+var hadConfirmExit = false; // Don't warn more than once
+var safeMode = false; // Disable all plugins and cookies
+var showBackstage; // Whether to include the backstage area
+var installedPlugins = []; // Information filled in when plugins are executed
+var startingUp = false; // Whether we're in the process of starting up
+var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins()
+
+// Whether to use the JavaSaver applet
+var useJavaSaver = (config.browser.isSafari || config.browser.isOpera) && (document.location.toString().substr(0,4) != "http");
+
+// Starting up
+function main()
+{
+ var t10,t9,t8,t7,t6,t5,t4,t3,t2,t1,t0 = new Date();
+ startingUp = true;
+ jQuery.noConflict();
+ window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();};
+ params = getParameters();
+ if(params)
+ params = params.parseParams("open",null,false);
+ store = new TiddlyWiki();
+ invokeParamifier(params,"oninit");
+ story = new Story("tiddlerDisplay","tiddler");
+ addEvent(document,"click",Popup.onDocumentClick);
+ saveTest();
+ loadOptionsCookie();
+ for(var s=0; s<config.notifyTiddlers.length; s++)
+ store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify);
+ t1 = new Date();
+ loadShadowTiddlers();
+ t2 = new Date();
+ store.loadFromDiv("storeArea","store",true);
+ t3 = new Date();
+ invokeParamifier(params,"onload");
+ t4 = new Date();
+ readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;
+ var pluginProblem = loadPlugins();
+ t5 = new Date();
+ formatter = new Formatter(config.formatters);
+ invokeParamifier(params,"onconfig");
+ story.switchTheme(config.options.txtTheme);
+ showBackstage = !readOnly;
+ t6 = new Date();
+ for(var m in config.macros) {
+ if(config.macros[m].init)
+ config.macros[m].init();
+ }
+ t7 = new Date();
+ store.notifyAll();
+ t8 = new Date();
+ restart();
+ refreshDisplay();
+ t9 = new Date();
+ if(pluginProblem) {
+ story.displayTiddler(null,"PluginManager");
+ displayMessage(config.messages.customConfigError);
+ }
+ if(showBackstage)
+ backstage.init();
+ t10 = new Date();
+ if(config.options.chkDisplayInstrumentation) {
+ displayMessage("LoadShadows " + (t2-t1) + " ms");
+ displayMessage("LoadFromDiv " + (t3-t2) + " ms");
+ displayMessage("LoadPlugins " + (t5-t4) + " ms");
+ displayMessage("Macro init " + (t7-t6) + " ms");
+ displayMessage("Notify " + (t8-t7) + " ms");
+ displayMessage("Restart " + (t9-t8) + " ms");
+ displayMessage("Total: " + (t10-t0) + " ms");
+ }
+ startingUp = false;
+}
+
+// Restarting
+function restart()
+{
+ invokeParamifier(params,"onstart");
+ if(story.isEmpty()) {
+ story.displayDefaultTiddlers();
+ }
+ window.scrollTo(0,0);
+}
+
+function saveTest()
+{
+ var s = document.getElementById("saveTest");
+ if(s.hasChildNodes())
+ alert(config.messages.savedSnapshotError);
+ s.appendChild(document.createTextNode("savetest"));
+}
+
+function loadShadowTiddlers()
+{
+ var shadows = new TiddlyWiki();
+ shadows.loadFromDiv("shadowArea","shadows",true);
+ shadows.forEachTiddler(function(title,tiddler){config.shadowTiddlers[title] = tiddler.text;});
+ delete shadows;
+}
+
+function loadPlugins()
+{
+ if(safeMode)
+ return false;
+ var tiddlers = store.getTaggedTiddlers("systemConfig");
+ var toLoad = [];
+ var nLoaded = 0;
+ var map = {};
+ var nPlugins = tiddlers.length;
+ installedPlugins = [];
+ for(var i=0; i<nPlugins; i++) {
+ var p = getPluginInfo(tiddlers[i]);
+ installedPlugins[i] = p;
+ var n = p.Name;
+ if(n)
+ map[n] = p;
+ n = p.Source;
+ if(n)
+ map[n] = p;
+ }
+ var visit = function(p) {
+ if(!p || p.done)
+ return;
+ p.done = 1;
+ var reqs = p.Requires;
+ if(reqs) {
+ reqs = reqs.readBracketedList();
+ for(var i=0; i<reqs.length; i++)
+ visit(map[reqs[i]]);
+ }
+ toLoad.push(p);
+ };
+ for(i=0; i<nPlugins; i++)
+ visit(installedPlugins[i]);
+ for(i=0; i<toLoad.length; i++) {
+ p = toLoad[i];
+ pluginInfo = p;
+ tiddler = p.tiddler;
+ if(isPluginExecutable(p)) {
+ if(isPluginEnabled(p)) {
+ p.executed = true;
+ var startTime = new Date();
+ try {
+ if(tiddler.text)
+ window.eval(tiddler.text);
+ nLoaded++;
+ } catch(ex) {
+ p.log.push(config.messages.pluginError.format([exceptionText(ex)]));
+ p.error = true;
+ }
+ pluginInfo.startupTime = String((new Date()) - startTime) + "ms";
+ } else {
+ nPlugins--;
+ }
+ } else {
+ p.warning = true;
+ }
+ }
+ return nLoaded != nPlugins;
+}
+
+function getPluginInfo(tiddler)
+{
+ var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","Requires","CoreVersion","Date","Source","Author","License","Browsers"]);
+ p.tiddler = tiddler;
+ p.title = tiddler.title;
+ p.log = [];
+ return p;
+}
+
+// Check that a particular plugin is valid for execution
+function isPluginExecutable(plugin)
+{
+ if(plugin.tiddler.isTagged("systemConfigForce")) {
+ plugin.log.push(config.messages.pluginForced);
+ return true;
+ }
+ if(plugin["CoreVersion"]) {
+ var coreVersion = plugin["CoreVersion"].split(".");
+ var w = parseInt(coreVersion[0],10) - version.major;
+ if(w == 0 && coreVersion[1])
+ w = parseInt(coreVersion[1],10) - version.minor;
+ if(w == 0 && coreVersion[2])
+ w = parseInt(coreVersion[2],10) - version.revision;
+ if(w > 0) {
+ plugin.log.push(config.messages.pluginVersionError);
+ return false;
+ }
+ }
+ return true;
+}
+
+function isPluginEnabled(plugin)
+{
+ if(plugin.tiddler.isTagged("systemConfigDisable")) {
+ plugin.log.push(config.messages.pluginDisabled);
+ return false;
+ }
+ return true;
+}
+
+function invokeMacro(place,macro,params,wikifier,tiddler)
+{
+ try {
+ var m = config.macros[macro];
+ if(m && m.handler) {
+ var tiddlerElem = story.findContainingTiddler(place);
+ window.tiddler = tiddlerElem ? store.getTiddler(tiddlerElem.getAttribute("tiddler")) : null;
+ window.place = place;
+ m.handler(place,macro,params.readMacroParams(),wikifier,params,tiddler);
+ } else {
+ createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro]));
+ }
+ } catch(ex) {
+ createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()]));
+ }
+}
+
+//--
+//-- Paramifiers
+//--
+
+function getParameters()
+{
+ var p = null;
+ if(window.location.hash) {
+ p = decodeURIComponent(window.location.hash.substr(1));
+ if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111")
+ p = convertUTF8ToUnicode(p);
+ }
+ return p;
+}
+
+function invokeParamifier(params,handler)
+{
+ if(!params || params.length == undefined || params.length <= 1)
+ return;
+ for(var i=1; i<params.length; i++) {
+ var p = config.paramifiers[params[i].name];
+ if(p && p[handler] instanceof Function)
+ p[handler](params[i].value);
+ else {
+ var h = config.optionHandlers[params[i].name.substr(0,3)];
+ if(h && h.set instanceof Function)
+ h.set(params[i].name,params[i].value);
+ }
+ }
+}
+
+config.paramifiers = {};
+
+config.paramifiers.start = {
+ oninit: function(v) {
+ safeMode = v.toLowerCase() == "safe";
+ }
+};
+
+config.paramifiers.open = {
+ onstart: function(v) {
+ if(!readOnly || store.tiddlerExists(v) || store.isShadowTiddler(v))
+ story.displayTiddler("bottom",v,null,false,null);
+ }
+};
+
+config.paramifiers.story = {
+ onstart: function(v) {
+ var list = store.getTiddlerText(v,"").parseParams("open",null,false);
+ invokeParamifier(list,"onstart");
+ }
+};
+
+config.paramifiers.search = {
+ onstart: function(v) {
+ story.search(v,false,false);
+ }
+};
+
+config.paramifiers.searchRegExp = {
+ onstart: function(v) {
+ story.prototype.search(v,false,true);
+ }
+};
+
+config.paramifiers.tag = {
+ onstart: function(v) {
+ story.displayTiddlers(null,store.filterTiddlers("[tag["+v+"]]"),null,false,null);
+ }
+};
+
+config.paramifiers.newTiddler = {
+ onstart: function(v) {
+ if(!readOnly) {
+ story.displayTiddler(null,v,DEFAULT_EDIT_TEMPLATE);
+ story.focusTiddler(v,"text");
+ }
+ }
+};
+
+config.paramifiers.newJournal = {
+ onstart: function(v) {
+ if(!readOnly) {
+ var now = new Date();
+ var title = now.formatString(v.trim());
+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
+ story.focusTiddler(title,"text");
+ }
+ }
+};
+
+config.paramifiers.readOnly = {
+ onconfig: function(v) {
+ var p = v.toLowerCase();
+ readOnly = p == "yes" ? true : (p == "no" ? false : readOnly);
+ }
+};
+
+config.paramifiers.theme = {
+ onconfig: function(v) {
+ story.switchTheme(v);
+ }
+};
+
+config.paramifiers.upgrade = {
+ onstart: function(v) {
+ upgradeFrom(v);
+ }
+};
+
+config.paramifiers.recent= {
+ onstart: function(v) {
+ var titles=[];
+ var tiddlers=store.getTiddlers("modified","excludeLists").reverse();
+ for(var i=0; i<v && i<tiddlers.length; i++)
+ titles.push(tiddlers[i].title);
+ story.displayTiddlers(null,titles);
+ }
+};
+
+config.paramifiers.filter = {
+ onstart: function(v) {
+ story.displayTiddlers(null,store.filterTiddlers(v),null,false);
+ }
+};
+
+//--
+//-- Formatter helpers
+//--
+
+function Formatter(formatters)
+{
+ this.formatters = [];
+ var pattern = [];
+ for(var n=0; n<formatters.length; n++) {
+ pattern.push("(" + formatters[n].match + ")");
+ this.formatters.push(formatters[n]);
+ }
+ this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
+}
+
+config.formatterHelpers = {
+
+ createElementAndWikify: function(w)
+ {
+ w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
+ },
+
+ inlineCssHelper: function(w)
+ {
+ var styles = [];
+ config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
+ var s,v;
+ if(lookaheadMatch[1]) {
+ s = lookaheadMatch[1].unDash();
+ v = lookaheadMatch[2];
+ } else {
+ s = lookaheadMatch[3].unDash();
+ v = lookaheadMatch[4];
+ }
+ if(s=="bgcolor")
+ s = "backgroundColor";
+ styles.push({style: s, value: v});
+ w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
+ config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
+ lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
+ }
+ return styles;
+ },
+
+ applyCssHelper: function(e,styles)
+ {
+ for(var t=0; t< styles.length; t++) {
+ try {
+ e.style[styles[t].style] = styles[t].value;
+ } catch (ex) {
+ }
+ }
+ },
+
+ enclosedTextHelper: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ var text = lookaheadMatch[1];
+ if(config.browser.isIE)
+ text = text.replace(/\n/g,"\r");
+ createTiddlyElement(w.output,this.element,null,null,text);
+ w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
+ }
+ },
+
+ isExternalLink: function(link)
+ {
+ if(store.tiddlerExists(link) || store.isShadowTiddler(link)) {
+ return false;
+ }
+ var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
+ if(urlRegExp.exec(link)) {
+ return true;
+ }
+ if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) {
+ return true;
+ }
+ return false;
+ }
+
+};
+
+//--
+//-- Standard formatters
+//--
+
+config.formatters = [
+{
+ name: "table",
+ match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
+ lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
+ rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
+ cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
+ cellTermRegExp: /((?:\x20*)\|)/mg,
+ rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
+ handler: function(w)
+ {
+ var table = createTiddlyElement(w.output,"table",null,"twtable");
+ var prevColumns = [];
+ var currRowType = null;
+ var rowContainer;
+ var rowCount = 0;
+ w.nextMatch = w.matchStart;
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
+ var nextRowType = lookaheadMatch[2];
+ if(nextRowType == "k") {
+ table.className = lookaheadMatch[1];
+ w.nextMatch += lookaheadMatch[0].length+1;
+ } else {
+ if(nextRowType != currRowType) {
+ rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]);
+ currRowType = nextRowType;
+ }
+ if(currRowType == "c") {
+ // Caption
+ w.nextMatch++;
+ if(rowContainer != table.firstChild)
+ table.insertBefore(rowContainer,table.firstChild);
+ rowContainer.setAttribute("align",rowCount == 0?"top":"bottom");
+ w.subWikifyTerm(rowContainer,this.rowTermRegExp);
+ } else {
+ var theRow = createTiddlyElement(rowContainer,"tr",null,(rowCount&1)?"oddRow":"evenRow");
+ theRow.onmouseover = function() {addClass(this,"hoverRow");};
+ theRow.onmouseout = function() {removeClass(this,"hoverRow");};
+ this.rowHandler(w,theRow,prevColumns);
+ rowCount++;
+ }
+ }
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ }
+ },
+ rowHandler: function(w,e,prevColumns)
+ {
+ var col = 0;
+ var colSpanCount = 1;
+ var prevCell = null;
+ this.cellRegExp.lastIndex = w.nextMatch;
+ var cellMatch = this.cellRegExp.exec(w.source);
+ while(cellMatch && cellMatch.index == w.nextMatch) {
+ if(cellMatch[1] == "~") {
+ // Rowspan
+ var last = prevColumns[col];
+ if(last) {
+ last.rowSpanCount++;
+ last.element.setAttribute("rowspan",last.rowSpanCount);
+ last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE
+ last.element.valign = "center";
+ }
+ w.nextMatch = this.cellRegExp.lastIndex-1;
+ } else if(cellMatch[1] == ">") {
+ // Colspan
+ colSpanCount++;
+ w.nextMatch = this.cellRegExp.lastIndex-1;
+ } else if(cellMatch[2]) {
+ // End of row
+ if(prevCell && colSpanCount > 1) {
+ prevCell.setAttribute("colspan",colSpanCount);
+ prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE
+ }
+ w.nextMatch = this.cellRegExp.lastIndex;
+ break;
+ } else {
+ // Cell
+ w.nextMatch++;
+ var styles = config.formatterHelpers.inlineCssHelper(w);
+ var spaceLeft = false;
+ var chr = w.source.substr(w.nextMatch,1);
+ while(chr == " ") {
+ spaceLeft = true;
+ w.nextMatch++;
+ chr = w.source.substr(w.nextMatch,1);
+ }
+ var cell;
+ if(chr == "!") {
+ cell = createTiddlyElement(e,"th");
+ w.nextMatch++;
+ } else {
+ cell = createTiddlyElement(e,"td");
+ }
+ prevCell = cell;
+ prevColumns[col] = {rowSpanCount:1,element:cell};
+ if(colSpanCount > 1) {
+ cell.setAttribute("colspan",colSpanCount);
+ cell.setAttribute("colSpan",colSpanCount); // Needed for IE
+ colSpanCount = 1;
+ }
+ config.formatterHelpers.applyCssHelper(cell,styles);
+ w.subWikifyTerm(cell,this.cellTermRegExp);
+ if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
+ cell.align = spaceLeft ? "center" : "left";
+ else if(spaceLeft)
+ cell.align = "right";
+ w.nextMatch--;
+ }
+ col++;
+ this.cellRegExp.lastIndex = w.nextMatch;
+ cellMatch = this.cellRegExp.exec(w.source);
+ }
+ }
+},
+
+{
+ name: "heading",
+ match: "^!{1,6}",
+ termRegExp: /(\n)/mg,
+ handler: function(w)
+ {
+ w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp);
+ }
+},
+
+{
+ name: "list",
+ match: "^(?:[\\*#;:]+)",
+ lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
+ termRegExp: /(\n)/mg,
+ handler: function(w)
+ {
+ var stack = [w.output];
+ var currLevel = 0, currType = null;
+ var listLevel, listType, itemType, baseType;
+ w.nextMatch = w.matchStart;
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
+ if(lookaheadMatch[1]) {
+ listType = "ul";
+ itemType = "li";
+ } else if(lookaheadMatch[2]) {
+ listType = "ol";
+ itemType = "li";
+ } else if(lookaheadMatch[3]) {
+ listType = "dl";
+ itemType = "dt";
+ } else if(lookaheadMatch[4]) {
+ listType = "dl";
+ itemType = "dd";
+ }
+ if(!baseType)
+ baseType = listType;
+ listLevel = lookaheadMatch[0].length;
+ w.nextMatch += lookaheadMatch[0].length;
+ var t;
+ if(listLevel > currLevel) {
+ for(t=currLevel; t<listLevel; t++) {
+ var target = (currLevel == 0) ? stack[stack.length-1] : stack[stack.length-1].lastChild;
+ stack.push(createTiddlyElement(target,listType));
+ }
+ } else if(listType!=baseType && listLevel==1) {
+ w.nextMatch -= lookaheadMatch[0].length;
+ return;
+ } else if(listLevel < currLevel) {
+ for(t=currLevel; t>listLevel; t--)
+ stack.pop();
+ } else if(listLevel == currLevel && listType != currType) {
+ stack.pop();
+ stack.push(createTiddlyElement(stack[stack.length-1].lastChild,listType));
+ }
+ currLevel = listLevel;
+ currType = listType;
+ var e = createTiddlyElement(stack[stack.length-1],itemType);
+ w.subWikifyTerm(e,this.termRegExp);
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ }
+ }
+},
+
+{
+ name: "quoteByBlock",
+ match: "^<<<\\n",
+ termRegExp: /(^<<<(\n|$))/mg,
+ element: "blockquote",
+ handler: config.formatterHelpers.createElementAndWikify
+},
+
+{
+ name: "quoteByLine",
+ match: "^>+",
+ lookaheadRegExp: /^>+/mg,
+ termRegExp: /(\n)/mg,
+ element: "blockquote",
+ handler: function(w)
+ {
+ var stack = [w.output];
+ var currLevel = 0;
+ var newLevel = w.matchLength;
+ var t;
+ do {
+ if(newLevel > currLevel) {
+ for(t=currLevel; t<newLevel; t++)
+ stack.push(createTiddlyElement(stack[stack.length-1],this.element));
+ } else if(newLevel < currLevel) {
+ for(t=currLevel; t>newLevel; t--)
+ stack.pop();
+ }
+ currLevel = newLevel;
+ w.subWikifyTerm(stack[stack.length-1],this.termRegExp);
+ createTiddlyElement(stack[stack.length-1],"br");
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
+ if(matched) {
+ newLevel = lookaheadMatch[0].length;
+ w.nextMatch += lookaheadMatch[0].length;
+ }
+ } while(matched);
+ }
+},
+
+{
+ name: "rule",
+ match: "^----+$\\n?|<hr ?/?>\\n?",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"hr");
+ }
+},
+
+{
+ name: "monospacedByLine",
+ match: "^(?:/\\*\\{\\{\\{\\*/|\\{\\{\\{|//\\{\\{\\{|<!--\\{\\{\\{-->)\\n",
+ element: "pre",
+ handler: function(w)
+ {
+ switch(w.matchText) {
+ case "/*{{{*/\n": // CSS
+ this.lookaheadRegExp = /\/\*\{\{\{\*\/\n*((?:^[^\n]*\n)+?)(\n*^\/\*\}\}\}\*\/$\n?)/mg;
+ break;
+ case "{{{\n": // monospaced block
+ this.lookaheadRegExp = /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/mg;
+ break;
+ case "//{{{\n": // plugin
+ this.lookaheadRegExp = /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\/\/\}\}\}$\n?)/mg;
+ break;
+ case "<!--{{{-->\n": //template
+ this.lookaheadRegExp = /<!--\{\{\{-->\n*((?:^[^\n]*\n)+?)(\n*^<!--\}\}\}-->$\n?)/mg;
+ break;
+ default:
+ break;
+ }
+ config.formatterHelpers.enclosedTextHelper.call(this,w);
+ }
+},
+
+{
+ name: "wikifyComment",
+ match: "^(?:/\\*\\*\\*|<!---)\\n",
+ handler: function(w)
+ {
+ var termRegExp = (w.matchText == "/***\n") ? (/(^\*\*\*\/\n)/mg) : (/(^--->\n)/mg);
+ w.subWikifyTerm(w.output,termRegExp);
+ }
+},
+
+{
+ name: "macro",
+ match: "<<",
+ lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) {
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
+ }
+ }
+},
+
+{
+ name: "prettyLink",
+ match: "\\[\\[",
+ lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ var e;
+ var text = lookaheadMatch[1];
+ if(lookaheadMatch[3]) {
+ // Pretty bracketted link
+ var link = lookaheadMatch[3];
+ e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link)) ?
+ createExternalLink(w.output,link) : createTiddlyLink(w.output,decodeURIComponent(link),false,null,w.isStatic,w.tiddler);
+ } else {
+ // Simple bracketted link
+ e = createTiddlyLink(w.output,decodeURIComponent(text),false,null,w.isStatic,w.tiddler);
+ }
+ createTiddlyText(e,text);
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "wikiLink",
+ match: config.textPrimitives.unWikiLink+"?"+config.textPrimitives.wikiLink,
+ handler: function(w)
+ {
+ if(w.matchText.substr(0,1) == config.textPrimitives.unWikiLink) {
+ w.outputText(w.output,w.matchStart+1,w.nextMatch);
+ return;
+ }
+ if(w.matchStart > 0) {
+ var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg");
+ preRegExp.lastIndex = w.matchStart-1;
+ var preMatch = preRegExp.exec(w.source);
+ if(preMatch.index == w.matchStart-1) {
+ w.outputText(w.output,w.matchStart,w.nextMatch);
+ return;
+ }
+ }
+ if(w.autoLinkWikiWords || store.isShadowTiddler(w.matchText)) {
+ var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic,w.tiddler);
+ w.outputText(link,w.matchStart,w.nextMatch);
+ } else {
+ w.outputText(w.output,w.matchStart,w.nextMatch);
+ }
+ }
+},
+
+{
+ name: "urlLink",
+ match: config.textPrimitives.urlPattern,
+ handler: function(w)
+ {
+ w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
+ }
+},
+
+{
+ name: "image",
+ match: "\\[[<>]?[Ii][Mm][Gg]\\[",
+ lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ var e = w.output;
+ if(lookaheadMatch[5]) {
+ var link = lookaheadMatch[5];
+ e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
+ addClass(e,"imageLink");
+ }
+ var img = createTiddlyElement(e,"img");
+ if(lookaheadMatch[1])
+ img.align = "left";
+ else if(lookaheadMatch[2])
+ img.align = "right";
+ if(lookaheadMatch[3]) {
+ img.title = lookaheadMatch[3];
+ img.setAttribute("alt",lookaheadMatch[3]);
+ }
+ img.src = lookaheadMatch[4];
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "html",
+ match: "<[Hh][Tt][Mm][Ll]>",
+ lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1];
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "commentByBlock",
+ match: "/%",
+ lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+},
+
+{
+ name: "characterFormat",
+ match: "''|//|__|\\^\\^|~~|--(?!\\s|$)|\\{\\{\\{",
+ handler: function(w)
+ {
+ switch(w.matchText) {
+ case "''":
+ w.subWikifyTerm(w.output.appendChild(document.createElement("strong")),/('')/mg);
+ break;
+ case "//":
+ w.subWikifyTerm(createTiddlyElement(w.output,"em"),/(\/\/)/mg);
+ break;
+ case "__":
+ w.subWikifyTerm(createTiddlyElement(w.output,"u"),/(__)/mg);
+ break;
+ case "^^":
+ w.subWikifyTerm(createTiddlyElement(w.output,"sup"),/(\^\^)/mg);
+ break;
+ case "~~":
+ w.subWikifyTerm(createTiddlyElement(w.output,"sub"),/(~~)/mg);
+ break;
+ case "--":
+ w.subWikifyTerm(createTiddlyElement(w.output,"strike"),/(--)/mg);
+ break;
+ case "{{{":
+ var lookaheadRegExp = /\{\{\{((?:.|\n)*?)\}\}\}/mg;
+ lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]);
+ w.nextMatch = lookaheadRegExp.lastIndex;
+ }
+ break;
+ }
+ }
+},
+
+{
+ name: "customFormat",
+ match: "@@|\\{\\{",
+ handler: function(w)
+ {
+ switch(w.matchText) {
+ case "@@":
+ var e = createTiddlyElement(w.output,"span");
+ var styles = config.formatterHelpers.inlineCssHelper(w);
+ if(styles.length == 0)
+ e.className = "marked";
+ else
+ config.formatterHelpers.applyCssHelper(e,styles);
+ w.subWikifyTerm(e,/(@@)/mg);
+ break;
+ case "{{":
+ var lookaheadRegExp = /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg;
+ lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch) {
+ w.nextMatch = lookaheadRegExp.lastIndex;
+ e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]);
+ w.subWikifyTerm(e,/(\}\}\})/mg);
+ }
+ break;
+ }
+ }
+},
+
+{
+ name: "mdash",
+ match: "--",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"span").innerHTML = "&mdash;";
+ }
+},
+
+{
+ name: "lineBreak",
+ match: "\\n|<br ?/?>",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"br");
+ }
+},
+
+{
+ name: "rawText",
+ match: "\\\"{3}|<nowiki>",
+ lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]);
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "htmlEntitiesEncoding",
+ match: "(?:(?:&#?[a-zA-Z0-9]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9a-fA-F]|1D[c-fC-F][0-9a-fA-F]|20[d-fD-F][0-9a-fA-F]|FE2[0-9a-fA-F])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[a-zA-Z0-9]{2,8};)",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"span").innerHTML = w.matchText;
+ }
+}
+
+];
+
+//--
+//-- Wikifier
+//--
+
+function getParser(tiddler,format)
+{
+ if(tiddler) {
+ if(!format)
+ format = tiddler.fields["wikiformat"];
+ var i;
+ if(format) {
+ for(i in config.parsers) {
+ if(format == config.parsers[i].format)
+ return config.parsers[i];
+ }
+ } else {
+ for(i in config.parsers) {
+ if(tiddler.isTagged(config.parsers[i].formatTag))
+ return config.parsers[i];
+ }
+ }
+ }
+ return formatter;
+}
+
+function wikify(source,output,highlightRegExp,tiddler)
+{
+ if(source) {
+ var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
+ var t0 = new Date();
+ wikifier.subWikify(output);
+ if(tiddler && config.options.chkDisplayInstrumentation)
+ displayMessage("wikify:" +tiddler.title+ " in " + (new Date()-t0) + " ms");
+ }
+}
+
+function wikifyStatic(source,highlightRegExp,tiddler,format)
+{
+ var e = createTiddlyElement(document.body,"pre");
+ e.style.display = "none";
+ var html = "";
+ if(source && source != "") {
+ if(!tiddler)
+ tiddler = new Tiddler("temp");
+ var wikifier = new Wikifier(source,getParser(tiddler,format),highlightRegExp,tiddler);
+ wikifier.isStatic = true;
+ wikifier.subWikify(e);
+ html = e.innerHTML;
+ removeNode(e);
+ }
+ return html;
+}
+
+function wikifyPlain(title,theStore,limit)
+{
+ if(!theStore)
+ theStore = store;
+ if(theStore.tiddlerExists(title) || theStore.isShadowTiddler(title)) {
+ return wikifyPlainText(theStore.getTiddlerText(title),limit,tiddler);
+ } else {
+ return "";
+ }
+}
+
+function wikifyPlainText(text,limit,tiddler)
+{
+ if(limit > 0)
+ text = text.substr(0,limit);
+ var wikifier = new Wikifier(text,formatter,null,tiddler);
+ return wikifier.wikifyPlain();
+}
+
+function highlightify(source,output,highlightRegExp,tiddler)
+{
+ if(source) {
+ var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
+ wikifier.outputText(output,0,source.length);
+ }
+}
+
+function Wikifier(source,formatter,highlightRegExp,tiddler)
+{
+ this.source = source;
+ this.output = null;
+ this.formatter = formatter;
+ this.nextMatch = 0;
+ this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true;
+ this.highlightRegExp = highlightRegExp;
+ this.highlightMatch = null;
+ this.isStatic = false;
+ if(highlightRegExp) {
+ highlightRegExp.lastIndex = 0;
+ this.highlightMatch = highlightRegExp.exec(source);
+ }
+ this.tiddler = tiddler;
+}
+
+Wikifier.prototype.wikifyPlain = function()
+{
+ var e = createTiddlyElement(document.body,"div");
+ e.style.display = "none";
+ this.subWikify(e);
+ var text = getPlainText(e);
+ removeNode(e);
+ return text;
+};
+
+Wikifier.prototype.subWikify = function(output,terminator)
+{
+ try {
+ if(terminator)
+ this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
+ else
+ this.subWikifyUnterm(output);
+ } catch(ex) {
+ showException(ex);
+ }
+};
+
+Wikifier.prototype.subWikifyUnterm = function(output)
+{
+ var oldOutput = this.output;
+ this.output = output;
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
+ while(formatterMatch) {
+ // Output any text before the match
+ if(formatterMatch.index > this.nextMatch)
+ this.outputText(this.output,this.nextMatch,formatterMatch.index);
+ // Set the match parameters for the handler
+ this.matchStart = formatterMatch.index;
+ this.matchLength = formatterMatch[0].length;
+ this.matchText = formatterMatch[0];
+ this.nextMatch = this.formatter.formatterRegExp.lastIndex;
+ for(var t=1; t<formatterMatch.length; t++) {
+ if(formatterMatch[t]) {
+ this.formatter.formatters[t-1].handler(this);
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ break;
+ }
+ }
+ formatterMatch = this.formatter.formatterRegExp.exec(this.source);
+ }
+ if(this.nextMatch < this.source.length) {
+ this.outputText(this.output,this.nextMatch,this.source.length);
+ this.nextMatch = this.source.length;
+ }
+ this.output = oldOutput;
+};
+
+Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
+{
+ var oldOutput = this.output;
+ this.output = output;
+ terminatorRegExp.lastIndex = this.nextMatch;
+ var terminatorMatch = terminatorRegExp.exec(this.source);
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
+ while(terminatorMatch || formatterMatch) {
+ if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) {
+ if(terminatorMatch.index > this.nextMatch)
+ this.outputText(this.output,this.nextMatch,terminatorMatch.index);
+ this.matchText = terminatorMatch[1];
+ this.matchLength = terminatorMatch[1].length;
+ this.matchStart = terminatorMatch.index;
+ this.nextMatch = this.matchStart + this.matchLength;
+ this.output = oldOutput;
+ return;
+ }
+ if(formatterMatch.index > this.nextMatch)
+ this.outputText(this.output,this.nextMatch,formatterMatch.index);
+ this.matchStart = formatterMatch.index;
+ this.matchLength = formatterMatch[0].length;
+ this.matchText = formatterMatch[0];
+ this.nextMatch = this.formatter.formatterRegExp.lastIndex;
+ for(var t=1; t<formatterMatch.length; t++) {
+ if(formatterMatch[t]) {
+ this.formatter.formatters[t-1].handler(this);
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ break;
+ }
+ }
+ terminatorRegExp.lastIndex = this.nextMatch;
+ terminatorMatch = terminatorRegExp.exec(this.source);
+ formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
+ }
+ if(this.nextMatch < this.source.length) {
+ this.outputText(this.output,this.nextMatch,this.source.length);
+ this.nextMatch = this.source.length;
+ }
+ this.output = oldOutput;
+};
+
+Wikifier.prototype.outputText = function(place,startPos,endPos)
+{
+ while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) {
+ if(this.highlightMatch.index > startPos) {
+ createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
+ startPos = this.highlightMatch.index;
+ }
+ var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
+ var theHighlight = createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
+ startPos = highlightEnd;
+ if(startPos >= this.highlightRegExp.lastIndex)
+ this.highlightMatch = this.highlightRegExp.exec(this.source);
+ }
+ if(startPos < endPos) {
+ createTiddlyText(place,this.source.substring(startPos,endPos));
+ }
+};
+
+//--
+//-- Macro definitions
+//--
+
+config.macros.today.handler = function(place,macroName,params)
+{
+ var now = new Date();
+ var text = params[0] ? now.formatString(params[0].trim()) : now.toLocaleString();
+ createTiddlyElement(place,"span",null,null,text);
+};
+
+config.macros.version.handler = function(place)
+{
+ createTiddlyElement(place,"span",null,null,formatVersion());
+};
+
+config.macros.list.handler = function(place,macroName,params)
+{
+ var type = params[0] || "all";
+ var list = document.createElement("ul");
+ place.appendChild(list);
+ if(this[type].prompt)
+ createTiddlyElement(list,"li",null,"listTitle",this[type].prompt);
+ var results;
+ if(this[type].handler)
+ results = this[type].handler(params);
+ for(var t = 0; t < results.length; t++) {
+ var li = document.createElement("li");
+ list.appendChild(li);
+ createTiddlyLink(li,typeof results[t] == "string" ? results[t] : results[t].title,true);
+ }
+};
+
+config.macros.list.all.handler = function(params)
+{
+ return store.reverseLookup("tags","excludeLists",false,"title");
+};
+
+config.macros.list.missing.handler = function(params)
+{
+ return store.getMissingLinks();
+};
+
+config.macros.list.orphans.handler = function(params)
+{
+ return store.getOrphans();
+};
+
+config.macros.list.shadowed.handler = function(params)
+{
+ return store.getShadowed();
+};
+
+config.macros.list.touched.handler = function(params)
+{
+ return store.getTouched();
+};
+
+config.macros.list.filter.handler = function(params)
+{
+ var filter = params[1];
+ var results = [];
+ if(filter) {
+ var tiddlers = store.filterTiddlers(filter);
+ for(var t=0; t<tiddlers.length; t++)
+ results.push(tiddlers[t].title);
+ }
+ return results;
+};
+
+config.macros.allTags.handler = function(place,macroName,params)
+{
+ var tags = store.getTags(params[0]);
+ var ul = createTiddlyElement(place,"ul");
+ if(tags.length == 0)
+ createTiddlyElement(ul,"li",null,"listTitle",this.noTags);
+ for(var t=0; t<tags.length; t++) {
+ var title = tags[t][0];
+ var info = getTiddlyLinkInfo(title);
+ var li = createTiddlyElement(ul,"li");
+ var btn = createTiddlyButton(li,title + " (" + tags[t][1] + ")",this.tooltip.format([title]),onClickTag,info.classes);
+ btn.setAttribute("tag",title);
+ btn.setAttribute("refresh","link");
+ btn.setAttribute("tiddlyLink",title);
+ }
+};
+
+config.macros.timeline.handler = function(place,macroName,params)
+{
+ var field = params[0] || "modified";
+ var tiddlers = store.reverseLookup("tags","excludeLists",false,field);
+ var lastDay = "";
+ var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1])) : 0;
+ var dateFormat = params[2] || this.dateFormat;
+ for(var t=tiddlers.length-1; t>=last; t--) {
+ var tiddler = tiddlers[t];
+ var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);
+ if(theDay != lastDay) {
+ var ul = document.createElement("ul");
+ place.appendChild(ul);
+ createTiddlyElement(ul,"li",null,"listTitle",tiddler[field].formatString(dateFormat));
+ lastDay = theDay;
+ }
+ createTiddlyElement(ul,"li",null,"listLink").appendChild(createTiddlyLink(place,tiddler.title,true));
+ }
+};
+
+config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ params = paramString.parseParams("name",null,true,false,true);
+ var names = params[0]["name"];
+ var tiddlerName = names[0];
+ var className = names[1] || null;
+ var args = params[0]["with"];
+ var wrapper = createTiddlyElement(place,"span",null,className);
+ if(!args) {
+ wrapper.setAttribute("refresh","content");
+ wrapper.setAttribute("tiddler",tiddlerName);
+ }
+ var text = store.getTiddlerText(tiddlerName);
+ if(text) {
+ var stack = config.macros.tiddler.tiddlerStack;
+ if(stack.indexOf(tiddlerName) !== -1)
+ return;
+ stack.push(tiddlerName);
+ try {
+ var n = args ? Math.min(args.length,9) : 0;
+ for(var i=0; i<n; i++) {
+ var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
+ text = text.replace(placeholderRE,args[i]);
+ }
+ config.macros.tiddler.renderText(wrapper,text,tiddlerName,params);
+ } finally {
+ stack.pop();
+ }
+ }
+};
+
+config.macros.tiddler.renderText = function(place,text,tiddlerName,params)
+{
+ wikify(text,place,null,store.getTiddler(tiddlerName));
+};
+
+config.macros.tiddler.tiddlerStack = [];
+
+config.macros.tag.handler = function(place,macroName,params)
+{
+ createTagButton(place,params[0],null,params[1],params[2]);
+};
+
+config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var ul = createTiddlyElement(place,"ul");
+ var title = getParam(params,"anon","");
+ if(title && store.tiddlerExists(title))
+ tiddler = store.getTiddler(title);
+ var sep = getParam(params,"sep"," ");
+ var lingo = config.views.wikified.tag;
+ var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags;
+ createTiddlyElement(ul,"li",null,"listTitle",prompt.format([tiddler.title]));
+ for(var t=0; t<tiddler.tags.length; t++) {
+ createTagButton(createTiddlyElement(ul,"li"),tiddler.tags[t],tiddler.title);
+ if(t<tiddler.tags.length-1)
+ createTiddlyText(ul,sep);
+ }
+};
+
+config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var ul = createTiddlyElement(place,"ul");
+ var title = getParam(params,"anon","");
+ if(title == "" && tiddler instanceof Tiddler)
+ title = tiddler.title;
+ var sep = getParam(params,"sep"," ");
+ ul.setAttribute("title",this.tooltip.format([title]));
+ var tagged = store.getTaggedTiddlers(title);
+ var prompt = tagged.length == 0 ? this.labelNotTag : this.label;
+ createTiddlyElement(ul,"li",null,"listTitle",prompt.format([title,tagged.length]));
+ for(var t=0; t<tagged.length; t++) {
+ createTiddlyLink(createTiddlyElement(ul,"li"),tagged[t].title,true);
+ if(t<tagged.length-1)
+ createTiddlyText(ul,sep);
+ }
+};
+
+config.macros.closeAll.handler = function(place)
+{
+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
+};
+
+config.macros.closeAll.onClick = function(e)
+{
+ story.closeAllTiddlers();
+ return false;
+};
+
+config.macros.permaview.handler = function(place)
+{
+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
+};
+
+config.macros.permaview.onClick = function(e)
+{
+ story.permaView();
+ return false;
+};
+
+config.macros.saveChanges.handler = function(place,macroName,params)
+{
+ if(!readOnly)
+ createTiddlyButton(place,params[0] || this.label,params[1] || this.prompt,this.onClick,null,null,this.accessKey);
+};
+
+config.macros.saveChanges.onClick = function(e)
+{
+ saveChanges();
+ return false;
+};
+
+config.macros.slider.onClickSlider = function(ev)
+{
+ var e = ev || window.event;
+ var n = this.nextSibling;
+ var cookie = n.getAttribute("cookie");
+ var isOpen = n.style.display != "none";
+ if(config.options.chkAnimate && anim && typeof Slider == "function")
+ anim.startAnimating(new Slider(n,!isOpen,null,"none"));
+ else
+ n.style.display = isOpen ? "none" : "block";
+ config.options[cookie] = !isOpen;
+ saveOptionCookie(cookie);
+ return false;
+};
+
+config.macros.slider.createSlider = function(place,cookie,title,tooltip)
+{
+ var c = cookie || "";
+ var btn = createTiddlyButton(place,title,tooltip,this.onClickSlider);
+ var panel = createTiddlyElement(null,"div",null,"sliderPanel");
+ panel.setAttribute("cookie",c);
+ panel.style.display = config.options[c] ? "block" : "none";
+ place.appendChild(panel);
+ return panel;
+};
+
+config.macros.slider.handler = function(place,macroName,params)
+{
+ var panel = this.createSlider(place,params[0],params[2],params[3]);
+ var text = store.getTiddlerText(params[1]);
+ panel.setAttribute("refresh","content");
+ panel.setAttribute("tiddler",params[1]);
+ if(text)
+ wikify(text,panel,null,store.getTiddler(params[1]));
+};
+
+// <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >>
+config.macros.gradient.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ var panel = wikifier ? createTiddlyElement(place,"div",null,"gradient") : place;
+ panel.style.position = "relative";
+ panel.style.overflow = "hidden";
+ panel.style.zIndex = "0";
+ if(wikifier) {
+ var styles = config.formatterHelpers.inlineCssHelper(wikifier);
+ config.formatterHelpers.applyCssHelper(panel,styles);
+ }
+ params = paramString.parseParams("color");
+ var locolors = [], hicolors = [];
+ for(var t=2; t<params.length; t++) {
+ var c = params[t].value;
+ if(params[t].name == "snap") {
+ hicolors[hicolors.length-1] = c;
+ } else {
+ locolors.push(c);
+ hicolors.push(c);
+ }
+ }
+ drawGradient(panel,params[1].value != "vert",locolors,hicolors);
+ if(wikifier)
+ wikifier.subWikify(panel,">>");
+ if(document.all) {
+ panel.style.height = "100%";
+ panel.style.width = "100%";
+ }
+};
+
+config.macros.message.handler = function(place,macroName,params)
+{
+ if(params[0]) {
+ var names = params[0].split(".");
+ var lookupMessage = function(root,nameIndex) {
+ if(names[nameIndex] in root) {
+ if(nameIndex < names.length-1)
+ return (lookupMessage(root[names[nameIndex]],nameIndex+1));
+ else
+ return root[names[nameIndex]];
+ } else
+ return null;
+ };
+ var m = lookupMessage(config,0);
+ if(m == null)
+ m = lookupMessage(window,0);
+ createTiddlyText(place,m.toString().format(params.splice(1)));
+ }
+};
+
+
+config.macros.view.views = {
+ text: function(value,place,params,wikifier,paramString,tiddler) {
+ highlightify(value,place,highlightHack,tiddler);
+ },
+ link: function(value,place,params,wikifier,paramString,tiddler) {
+ createTiddlyLink(place,value,true);
+ },
+ wikified: function(value,place,params,wikifier,paramString,tiddler) {
+ if(params[2])
+ value=params[2].unescapeLineBreaks().format([value]);
+ wikify(value,place,highlightHack,tiddler);
+ },
+ date: function(value,place,params,wikifier,paramString,tiddler) {
+ value = Date.convertFromYYYYMMDDHHMM(value);
+ createTiddlyText(place,value.formatString(params[2] ? params[2] : config.views.wikified.dateFormat));
+ }
+};
+
+config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if((tiddler instanceof Tiddler) && params[0]) {
+ var value = store.getValue(tiddler,params[0]);
+ if(value) {
+ var type = params[1] || config.macros.view.defaultView;
+ var handler = config.macros.view.views[type];
+ if(handler)
+ handler(value,place,params,wikifier,paramString,tiddler);
+ }
+ }
+};
+
+config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ var field = params[0];
+ var rows = params[1] || 0;
+ var defVal = params[2] || '';
+ if((tiddler instanceof Tiddler) && field) {
+ story.setDirty(tiddler.title,true);
+ var e,v;
+ if(field != "text" && !rows) {
+ e = createTiddlyElement(null,"input");
+ if(tiddler.isReadOnly())
+ e.setAttribute("readOnly","readOnly");
+ e.setAttribute("edit",field);
+ e.setAttribute("type","text");
+ e.value = store.getValue(tiddler,field) || defVal;
+ e.setAttribute("size","40");
+ e.setAttribute("autocomplete","off");
+ place.appendChild(e);
+ } else {
+ var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix");
+ var wrapper2 = createTiddlyElement(wrapper1,"div");
+ e = createTiddlyElement(wrapper2,"textarea");
+ if(tiddler.isReadOnly())
+ e.setAttribute("readOnly","readOnly");
+ e.value = v = store.getValue(tiddler,field) || defVal;
+ rows = rows || 10;
+ var lines = v.match(/\n/mg);
+ var maxLines = Math.max(parseInt(config.options.txtMaxEditRows),5);
+ if(lines != null && lines.length > rows)
+ rows = lines.length + 5;
+ rows = Math.min(rows,maxLines);
+ e.setAttribute("rows",rows);
+ e.setAttribute("edit",field);
+ place.appendChild(wrapper1);
+ }
+ return e;
+ }
+};
+
+config.macros.tagChooser.onClick = function(ev)
+{
+ var e = ev || window.event;
+ var lingo = config.views.editor.tagChooser;
+ var popup = Popup.create(this);
+ var tags = store.getTags(this.getAttribute("tags"));
+ if(tags.length == 0)
+ createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone);
+ for(var t=0; t<tags.length; t++) {
+ var tag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick);
+ tag.setAttribute("tag",tags[t][0]);
+ tag.setAttribute("tiddler",this.getAttribute("tiddler"));
+ }
+ Popup.show();
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return false;
+};
+
+config.macros.tagChooser.onTagClick = function(ev)
+{
+ var e = ev || window.event;
+ if(e.metaKey || e.ctrlKey) stopEvent(e); //# keep popup open on CTRL-click
+ var tag = this.getAttribute("tag");
+ var title = this.getAttribute("tiddler");
+ if(!readOnly)
+ story.setTiddlerTag(title,tag,0);
+ return false;
+};
+
+config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if(tiddler instanceof Tiddler) {
+ var lingo = config.views.editor.tagChooser;
+ var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick);
+ btn.setAttribute("tiddler",tiddler.title);
+ btn.setAttribute("tags",params[0]);
+ }
+};
+
+config.macros.refreshDisplay.handler = function(place)
+{
+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
+};
+
+config.macros.refreshDisplay.onClick = function(e)
+{
+ refreshAll();
+ return false;
+};
+
+config.macros.annotations.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ var title = tiddler ? tiddler.title : null;
+ var a = title ? config.annotations[title] : null;
+ if(!tiddler || !title || !a)
+ return;
+ var text = a.format([title]);
+ wikify(text,createTiddlyElement(place,"div",null,"annotation"),null,tiddler);
+};
+
+//--
+//-- NewTiddler and NewJournal macros
+//--
+
+config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal)
+{
+ var tags = [];
+ for(var t=1; t<params.length; t++) {
+ if((params[t].name == "anon" && t != 1) || (params[t].name == "tag"))
+ tags.push(params[t].value);
+ }
+ label = getParam(params,"label",label);
+ prompt = getParam(params,"prompt",prompt);
+ accessKey = getParam(params,"accessKey",accessKey);
+ newFocus = getParam(params,"focus",newFocus);
+ var customFields = getParam(params,"fields","");
+ if(!customFields && !store.isShadowTiddler(title))
+ customFields = String.encodeHashMap(config.defaultCustomFields);
+ var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey);
+ btn.setAttribute("newTitle",title);
+ btn.setAttribute("isJournal",isJournal ? "true" : "false");
+ if(tags.length > 0)
+ btn.setAttribute("params",tags.join("|"));
+ btn.setAttribute("newFocus",newFocus);
+ btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE));
+ if(customFields !== "")
+ btn.setAttribute("customFields",customFields);
+ var text = getParam(params,"text");
+ if(text !== undefined)
+ btn.setAttribute("newText",text);
+ return btn;
+};
+
+config.macros.newTiddler.onClickNewTiddler = function()
+{
+ var title = this.getAttribute("newTitle");
+ if(this.getAttribute("isJournal") == "true") {
+ title = new Date().formatString(title.trim());
+ }
+ var params = this.getAttribute("params");
+ var tags = params ? params.split("|") : [];
+ var focus = this.getAttribute("newFocus");
+ var template = this.getAttribute("newTemplate");
+ var customFields = this.getAttribute("customFields");
+ if(!customFields && !store.isShadowTiddler(title))
+ customFields = String.encodeHashMap(config.defaultCustomFields);
+ story.displayTiddler(null,title,template,false,null,null);
+ var tiddlerElem = story.getTiddler(title);
+ if(customFields)
+ story.addCustomFields(tiddlerElem,customFields);
+ var text = this.getAttribute("newText");
+ if(typeof text == "string" && story.getTiddlerField(title,"text"))
+ story.getTiddlerField(title,"text").value = text.format([title]);
+ for(var t=0;t<tags.length;t++)
+ story.setTiddlerTag(title,tags[t],+1);
+ story.focusTiddler(title,focus);
+ return false;
+};
+
+config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString)
+{
+ if(!readOnly) {
+ params = paramString.parseParams("anon",null,true,false,false);
+ var title = params[1] && params[1].name == "anon" ? params[1].value : this.title;
+ title = getParam(params,"title",title);
+ this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false);
+ }
+};
+
+config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString)
+{
+ if(!readOnly) {
+ params = paramString.parseParams("anon",null,true,false,false);
+ var title = params[1] && params[1].name == "anon" ? params[1].value : config.macros.timeline.dateFormat;
+ title = getParam(params,"title",title);
+ config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true);
+ }
+};
+
+//--
+//-- Search macro
+//--
+
+config.macros.search.handler = function(place,macroName,params)
+{
+ var searchTimeout = null;
+ var btn = createTiddlyButton(place,this.label,this.prompt,this.onClick,"searchButton");
+ var txt = createTiddlyElement(null,"input",null,"txtOptionInput searchField");
+ if(params[0])
+ txt.value = params[0];
+ if(config.browser.isSafari) {
+ txt.setAttribute("type","search");
+ txt.setAttribute("results","5");
+ } else {
+ txt.setAttribute("type","text");
+ }
+ place.appendChild(txt);
+ txt.onkeyup = this.onKeyPress;
+ txt.onfocus = this.onFocus;
+ txt.setAttribute("size",this.sizeTextbox);
+ txt.setAttribute("accessKey",this.accessKey);
+ txt.setAttribute("autocomplete","off");
+ txt.setAttribute("lastSearchText","");
+};
+
+// Global because there's only ever one outstanding incremental search timer
+config.macros.search.timeout = null;
+
+config.macros.search.doSearch = function(txt)
+{
+ if(txt.value.length > 0) {
+ story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);
+ txt.setAttribute("lastSearchText",txt.value);
+ }
+};
+
+config.macros.search.onClick = function(e)
+{
+ config.macros.search.doSearch(this.nextSibling);
+ return false;
+};
+
+config.macros.search.onKeyPress = function(ev)
+{
+ var e = ev || window.event;
+ switch(e.keyCode) {
+ case 13: // Ctrl-Enter
+ case 10: // Ctrl-Enter on IE PC
+ config.macros.search.doSearch(this);
+ break;
+ case 27: // Escape
+ this.value = "";
+ clearMessage();
+ break;
+ }
+ if(config.options.chkIncrementalSearch) {
+ if(this.value.length > 2) {
+ if(this.value != this.getAttribute("lastSearchText")) {
+ if(config.macros.search.timeout)
+ clearTimeout(config.macros.search.timeout);
+ var txt = this;
+ config.macros.search.timeout = setTimeout(function() {config.macros.search.doSearch(txt);},500);
+ }
+ } else {
+ if(config.macros.search.timeout)
+ clearTimeout(config.macros.search.timeout);
+ }
+ }
+};
+
+config.macros.search.onFocus = function(e)
+{
+ this.select();
+};
+
+//--
+//-- Tabs macro
+//--
+
+config.macros.tabs.handler = function(place,macroName,params)
+{
+ var cookie = params[0];
+ var numTabs = (params.length-1)/3;
+ var wrapper = createTiddlyElement(null,"div",null,"tabsetWrapper " + cookie);
+ var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
+ tabset.setAttribute("cookie",cookie);
+ var validTab = false;
+ for(var t=0; t<numTabs; t++) {
+ var label = params[t*3+1];
+ var prompt = params[t*3+2];
+ var content = params[t*3+3];
+ var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
+ tab.setAttribute("tab",label);
+ tab.setAttribute("content",content);
+ tab.title = prompt;
+ if(config.options[cookie] == label)
+ validTab = true;
+ }
+ if(!validTab)
+ config.options[cookie] = params[1];
+ place.appendChild(wrapper);
+ this.switchTab(tabset,config.options[cookie]);
+};
+
+config.macros.tabs.onClickTab = function(e)
+{
+ config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
+ return false;
+};
+
+config.macros.tabs.switchTab = function(tabset,tab)
+{
+ var cookie = tabset.getAttribute("cookie");
+ var theTab = null;
+ var nodes = tabset.childNodes;
+ for(var t=0; t<nodes.length; t++) {
+ if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab) {
+ theTab = nodes[t];
+ theTab.className = "tab tabSelected";
+ } else {
+ nodes[t].className = "tab tabUnselected";
+ }
+ }
+ if(theTab) {
+ if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
+ removeNode(tabset.nextSibling);
+ var tabContent = createTiddlyElement(null,"div",null,"tabContents");
+ tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
+ var contentTitle = theTab.getAttribute("content");
+ wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
+ if(cookie) {
+ config.options[cookie] = tab;
+ saveOptionCookie(cookie);
+ }
+ }
+};
+
+//--
+//-- Tiddler toolbar
+//--
+
+// Create a toolbar command button
+config.macros.toolbar.createCommand = function(place,commandName,tiddler,className)
+{
+ if(typeof commandName != "string") {
+ var c = null;
+ for(var t in config.commands) {
+ if(config.commands[t] == commandName)
+ c = t;
+ }
+ commandName = c;
+ }
+ if((tiddler instanceof Tiddler) && (typeof commandName == "string")) {
+ var command = config.commands[commandName];
+ if(command.isEnabled ? command.isEnabled(tiddler) : this.isCommandEnabled(command,tiddler)) {
+ var text = command.getText ? command.getText(tiddler) : this.getCommandText(command,tiddler);
+ var tooltip = command.getTooltip ? command.getTooltip(tiddler) : this.getCommandTooltip(command,tiddler);
+ var cmd;
+ switch(command.type) {
+ case "popup":
+ cmd = this.onClickPopup;
+ break;
+ case "command":
+ default:
+ cmd = this.onClickCommand;
+ break;
+ }
+ var btn = createTiddlyButton(null,text,tooltip,cmd);
+ btn.setAttribute("commandName",commandName);
+ btn.setAttribute("tiddler",tiddler.title);
+ if(className)
+ addClass(btn,className);
+ place.appendChild(btn);
+ }
+ }
+};
+
+config.macros.toolbar.isCommandEnabled = function(command,tiddler)
+{
+ var title = tiddler.title;
+ var ro = tiddler.isReadOnly();
+ var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title);
+ return (!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow);
+};
+
+config.macros.toolbar.getCommandText = function(command,tiddler)
+{
+ return tiddler.isReadOnly() && command.readOnlyText || command.text;
+};
+
+config.macros.toolbar.getCommandTooltip = function(command,tiddler)
+{
+ return tiddler.isReadOnly() && command.readOnlyTooltip || command.tooltip;
+};
+
+config.macros.toolbar.onClickCommand = function(ev)
+{
+ var e = ev || window.event;
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ var command = config.commands[this.getAttribute("commandName")];
+ return command.handler(e,this,this.getAttribute("tiddler"));
+};
+
+config.macros.toolbar.onClickPopup = function(ev)
+{
+ var e = ev || window.event;
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ var popup = Popup.create(this);
+ var command = config.commands[this.getAttribute("commandName")];
+ var title = this.getAttribute("tiddler");
+ var tiddler = store.fetchTiddler(title);
+ popup.setAttribute("tiddler",title);
+ command.handlePopup(popup,title);
+ Popup.show();
+ return false;
+};
+
+// Invoke the first command encountered from a given place that is tagged with a specified class
+config.macros.toolbar.invokeCommand = function(place,className,event)
+{
+ var children = place.getElementsByTagName("a");
+ for(var t=0; t<children.length; t++) {
+ var c = children[t];
+ if(hasClass(c,className) && c.getAttribute && c.getAttribute("commandName")) {
+ if(c.onclick instanceof Function)
+ c.onclick.call(c,event);
+ break;
+ }
+ }
+};
+
+config.macros.toolbar.onClickMore = function(ev)
+{
+ var e = this.nextSibling;
+ e.style.display = "inline";
+ removeNode(this);
+ return false;
+};
+
+config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ for(var t=0; t<params.length; t++) {
+ var c = params[t];
+ switch(c) {
+ case '>':
+ var btn = createTiddlyButton(place,this.moreLabel,this.morePrompt,config.macros.toolbar.onClickMore);
+ addClass(btn,"moreCommand");
+ var e = createTiddlyElement(place,"span",null,"moreCommand");
+ e.style.display = "none";
+ place = e;
+ break;
+ default:
+ var className = "";
+ switch(c.substr(0,1)) {
+ case "+":
+ className = "defaultCommand";
+ c = c.substr(1);
+ break;
+ case "-":
+ className = "cancelCommand";
+ c = c.substr(1);
+ break;
+ }
+ if(c in config.commands)
+ this.createCommand(place,c,tiddler,className);
+ break;
+ }
+ }
+};
+
+//--
+//-- Menu and toolbar commands
+//--
+
+config.commands.closeTiddler.handler = function(event,src,title)
+{
+ if(story.isDirty(title) && !readOnly) {
+ if(!confirm(config.commands.cancelTiddler.warning.format([title])))
+ return false;
+ }
+ story.setDirty(title,false);
+ story.closeTiddler(title,true);
+ return false;
+};
+
+config.commands.closeOthers.handler = function(event,src,title)
+{
+ story.closeAllTiddlers(title);
+ return false;
+};
+
+config.commands.editTiddler.handler = function(event,src,title)
+{
+ clearMessage();
+ var tiddlerElem = story.getTiddler(title);
+ var fields = tiddlerElem.getAttribute("tiddlyFields");
+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,fields);
+ story.focusTiddler(title,config.options.txtEditorFocus||"text");
+ return false;
+};
+
+config.commands.saveTiddler.handler = function(event,src,title)
+{
+ var newTitle = story.saveTiddler(title,event.shiftKey);
+ if(newTitle)
+ story.displayTiddler(null,newTitle);
+ return false;
+};
+
+config.commands.cancelTiddler.handler = function(event,src,title)
+{
+ if(story.hasChanges(title) && !readOnly) {
+ if(!confirm(this.warning.format([title])))
+ return false;
+ }
+ story.setDirty(title,false);
+ story.displayTiddler(null,title);
+ return false;
+};
+
+config.commands.deleteTiddler.handler = function(event,src,title)
+{
+ var deleteIt = true;
+ if(config.options.chkConfirmDelete)
+ deleteIt = confirm(this.warning.format([title]));
+ if(deleteIt) {
+ store.removeTiddler(title);
+ story.closeTiddler(title,true);
+ autoSaveChanges();
+ }
+ return false;
+};
+
+config.commands.permalink.handler = function(event,src,title)
+{
+ var t = encodeURIComponent(String.encodeTiddlyLink(title));
+ if(window.location.hash != t)
+ window.location.hash = t;
+ return false;
+};
+
+config.commands.references.handlePopup = function(popup,title)
+{
+ var references = store.getReferringTiddlers(title);
+ var c = false;
+ for(var r=0; r<references.length; r++) {
+ if(references[r].title != title && !references[r].isTagged("excludeLists")) {
+ createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true);
+ c = true;
+ }
+ }
+ if(!c)
+ createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),this.popupNone);
+};
+
+config.commands.jump.handlePopup = function(popup,title)
+{
+ story.forEachTiddler(function(title,element) {
+ createTiddlyLink(createTiddlyElement(popup,"li"),title,true,null,false,null,true);
+ });
+};
+
+config.commands.syncing.handlePopup = function(popup,title)
+{
+ var tiddler = store.fetchTiddler(title);
+ if(!tiddler)
+ return;
+ var serverType = tiddler.getServerType();
+ var serverHost = tiddler.fields['server.host'];
+ var serverWorkspace = tiddler.fields['server.workspace'];
+ if(!serverWorkspace)
+ serverWorkspace = "";
+ if(serverType) {
+ var e = createTiddlyElement(popup,"li",null,"popupMessage");
+ e.innerHTML = config.commands.syncing.currentlySyncing.format([serverType,serverHost,serverWorkspace]);
+ } else {
+ createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.notCurrentlySyncing);
+ }
+ if(serverType) {
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ var btn = createTiddlyButton(createTiddlyElement(popup,"li"),this.captionUnSync,null,config.commands.syncing.onChooseServer);
+ btn.setAttribute("tiddler",title);
+ btn.setAttribute("server.type","");
+ }
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.chooseServer);
+ var feeds = store.getTaggedTiddlers("systemServer","title");
+ for(var t=0; t<feeds.length; t++) {
+ var f = feeds[t];
+ var feedServerType = store.getTiddlerSlice(f.title,"Type");
+ if(!feedServerType)
+ feedServerType = "file";
+ var feedServerHost = store.getTiddlerSlice(f.title,"URL");
+ if(!feedServerHost)
+ feedServerHost = "";
+ var feedServerWorkspace = store.getTiddlerSlice(f.title,"Workspace");
+ if(!feedServerWorkspace)
+ feedServerWorkspace = "";
+ var caption = f.title;
+ if(serverType == feedServerType && serverHost == feedServerHost && serverWorkspace == feedServerWorkspace) {
+ caption = config.commands.syncing.currServerMarker + caption;
+ } else {
+ caption = config.commands.syncing.notCurrServerMarker + caption;
+ }
+ btn = createTiddlyButton(createTiddlyElement(popup,"li"),caption,null,config.commands.syncing.onChooseServer);
+ btn.setAttribute("tiddler",title);
+ btn.setAttribute("server.type",feedServerType);
+ btn.setAttribute("server.host",feedServerHost);
+ btn.setAttribute("server.workspace",feedServerWorkspace);
+ }
+};
+
+config.commands.syncing.onChooseServer = function(e)
+{
+ var tiddler = this.getAttribute("tiddler");
+ var serverType = this.getAttribute("server.type");
+ if(serverType) {
+ store.addTiddlerFields(tiddler,{
+ "server.type": serverType,
+ "server.host": this.getAttribute("server.host"),
+ "server.workspace": this.getAttribute("server.workspace")
+ });
+ } else {
+ store.setValue(tiddler,"server",null);
+ }
+ return false;
+};
+
+config.commands.fields.handlePopup = function(popup,title)
+{
+ var tiddler = store.fetchTiddler(title);
+ if(!tiddler)
+ return;
+ var items = [];
+ store.forEachField(tiddler,function(tiddler,fieldName,value){items.push({field:fieldName,value:value});},true);
+ items.sort(function(a,b) {return a.field < b.field ? -1 : (a.field == b.field ? 0 : +1);});
+ if(items.length > 0)
+ ListView.create(popup,items,this.listViewTemplate);
+ else
+ createTiddlyElement(popup,"div",null,null,this.emptyText);
+};
+
+//--
+//-- Tiddler() object
+//--
+
+function Tiddler(title)
+{
+ this.title = title;
+ this.text = "";
+ this.modifier = null;
+ this.created = new Date();
+ this.modified = this.created;
+ this.links = [];
+ this.linksUpdated = false;
+ this.tags = [];
+ this.fields = {};
+ return this;
+}
+
+Tiddler.prototype.getLinks = function()
+{
+ if(this.linksUpdated==false)
+ this.changed();
+ return this.links;
+};
+
+// Returns the fields that are inherited in string field:"value" field2:"value2" format
+Tiddler.prototype.getInheritedFields = function()
+{
+ var f = {};
+ for(var i in this.fields) {
+ if(i=="server.host" || i=="server.workspace" || i=="wikiformat"|| i=="server.type") {
+ f[i] = this.fields[i];
+ }
+ }
+ return String.encodeHashMap(f);
+};
+
+// Increment the changeCount of a tiddler
+Tiddler.prototype.incChangeCount = function()
+{
+ var c = this.fields['changecount'];
+ c = c ? parseInt(c,10) : 0;
+ this.fields['changecount'] = String(c+1);
+};
+
+// Clear the changeCount of a tiddler
+Tiddler.prototype.clearChangeCount = function()
+{
+ if(this.fields['changecount']) {
+ delete this.fields['changecount'];
+ }
+};
+
+Tiddler.prototype.doNotSave = function()
+{
+ return this.fields['doNotSave'];
+};
+
+// Returns true if the tiddler has been updated since the tiddler was created or downloaded
+Tiddler.prototype.isTouched = function()
+{
+ var changeCount = this.fields['changecount'];
+ if(changeCount === undefined)
+ changeCount = 0;
+ return changeCount > 0;
+};
+
+// Change the text and other attributes of a tiddler
+Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields)
+{
+ this.assign(title,text,modifier,modified,tags,created,fields);
+ this.changed();
+ return this;
+};
+
+// Change the text and other attributes of a tiddler without triggered a tiddler.changed() call
+Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields)
+{
+ if(title != undefined)
+ this.title = title;
+ if(text != undefined)
+ this.text = text;
+ if(modifier != undefined)
+ this.modifier = modifier;
+ if(modified != undefined)
+ this.modified = modified;
+ if(created != undefined)
+ this.created = created;
+ if(fields != undefined)
+ this.fields = fields;
+ if(tags != undefined)
+ this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
+ else if(this.tags == undefined)
+ this.tags = [];
+ return this;
+};
+
+// Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
+Tiddler.prototype.getTags = function()
+{
+ return String.encodeTiddlyLinkList(this.tags);
+};
+
+// Test if a tiddler carries a tag
+Tiddler.prototype.isTagged = function(tag)
+{
+ return this.tags.indexOf(tag) != -1;
+};
+
+// Static method to convert "\n" to newlines, "\s" to "\"
+Tiddler.unescapeLineBreaks = function(text)
+{
+ return text ? text.unescapeLineBreaks() : "";
+};
+
+// Convert newlines to "\n", "\" to "\s"
+Tiddler.prototype.escapeLineBreaks = function()
+{
+ return this.text.escapeLineBreaks();
+};
+
+// Updates the secondary information (like links[] array) after a change to a tiddler
+Tiddler.prototype.changed = function()
+{
+ this.links = [];
+ var text = this.text;
+ // remove 'quoted' text before scanning tiddler source
+ text = text.replace(/\/%((?:.|\n)*?)%\//g,"").
+ replace(/\{{3}((?:.|\n)*?)\}{3}/g,"").
+ replace(/"""((?:.|\n)*?)"""/g,"").
+ replace(/\<nowiki\>((?:.|\n)*?)\<\/nowiki\>/g,"").
+ replace(/\<html\>((?:.|\n)*?)\<\/html\>/g,"").
+ replace(/\<script((?:.|\n)*?)\<\/script\>/g,"");
+ var t = this.autoLinkWikiWords() ? 0 : 1;
+ var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp;
+ tiddlerLinkRegExp.lastIndex = 0;
+ var formatMatch = tiddlerLinkRegExp.exec(text);
+ while(formatMatch) {
+ var lastIndex = tiddlerLinkRegExp.lastIndex;
+ if(t==0 && formatMatch[1] && formatMatch[1] != this.title) {
+ // wikiWordLink
+ if(formatMatch.index > 0) {
+ var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg");
+ preRegExp.lastIndex = formatMatch.index-1;
+ var preMatch = preRegExp.exec(text);
+ if(preMatch.index != formatMatch.index-1)
+ this.links.pushUnique(formatMatch[1]);
+ } else {
+ this.links.pushUnique(formatMatch[1]);
+ }
+ }
+ else if(formatMatch[2-t] && !config.formatterHelpers.isExternalLink(formatMatch[3-t])) // titledBrackettedLink
+ this.links.pushUnique(formatMatch[3-t]);
+ else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink
+ this.links.pushUnique(formatMatch[4-t]);
+ tiddlerLinkRegExp.lastIndex = lastIndex;
+ formatMatch = tiddlerLinkRegExp.exec(text);
+ }
+ this.linksUpdated = true;
+};
+
+Tiddler.prototype.getSubtitle = function()
+{
+ var modifier = this.modifier;
+ if(!modifier)
+ modifier = config.messages.subtitleUnknown;
+ var modified = this.modified;
+ if(modified)
+ modified = modified.toLocaleString();
+ else
+ modified = config.messages.subtitleUnknown;
+ return config.messages.tiddlerLinkTooltip.format([this.title,modifier,modified]);
+};
+
+Tiddler.prototype.isReadOnly = function()
+{
+ return readOnly;
+};
+
+Tiddler.prototype.autoLinkWikiWords = function()
+{
+ return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing"));
+};
+
+Tiddler.prototype.generateFingerprint = function()
+{
+ return "0x" + Crypto.hexSha1Str(this.text);
+};
+
+Tiddler.prototype.getServerType = function()
+{
+ var serverType = null;
+ if(this.fields['server.type'])
+ serverType = this.fields['server.type'];
+ if(!serverType)
+ serverType = this.fields['wikiformat'];
+ if(serverType && !config.adaptors[serverType])
+ serverType = null;
+ return serverType;
+};
+
+Tiddler.prototype.getAdaptor = function()
+{
+ var serverType = this.getServerType();
+ return serverType ? new config.adaptors[serverType]() : null;
+};
+
+//--
+//-- TiddlyWiki() object contains Tiddler()s
+//--
+
+function TiddlyWiki()
+{
+ var tiddlers = {}; // Hashmap by name of tiddlers
+ this.tiddlersUpdated = false;
+ this.namedNotifications = []; // Array of {name:,notify:} of notification functions
+ this.notificationLevel = 0;
+ this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
+ this.clear = function() {
+ tiddlers = {};
+ this.setDirty(false);
+ };
+ this.fetchTiddler = function(title) {
+ var t = tiddlers[title];
+ return t instanceof Tiddler ? t : null;
+ };
+ this.deleteTiddler = function(title) {
+ delete this.slices[title];
+ delete tiddlers[title];
+ };
+ this.addTiddler = function(tiddler) {
+ delete this.slices[tiddler.title];
+ tiddlers[tiddler.title] = tiddler;
+ };
+ this.forEachTiddler = function(callback) {
+ for(var t in tiddlers) {
+ var tiddler = tiddlers[t];
+ if(tiddler instanceof Tiddler)
+ callback.call(this,t,tiddler);
+ }
+ };
+}
+
+TiddlyWiki.prototype.setDirty = function(dirty)
+{
+ this.dirty = dirty;
+};
+
+TiddlyWiki.prototype.isDirty = function()
+{
+ return this.dirty;
+};
+
+TiddlyWiki.prototype.tiddlerExists = function(title)
+{
+ var t = this.fetchTiddler(title);
+ return t != undefined;
+};
+
+TiddlyWiki.prototype.isShadowTiddler = function(title)
+{
+ return config.shadowTiddlers[title] === undefined ? false : true;
+};
+
+TiddlyWiki.prototype.createTiddler = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(!tiddler) {
+ tiddler = new Tiddler(title);
+ this.addTiddler(tiddler);
+ this.setDirty(true);
+ }
+ return tiddler;
+};
+
+TiddlyWiki.prototype.getTiddler = function(title)
+{
+ var t = this.fetchTiddler(title);
+ if(t != undefined)
+ return t;
+ else
+ return null;
+};
+
+TiddlyWiki.prototype.getShadowTiddlerText = function(title)
+{
+ if(typeof config.shadowTiddlers[title] == "string")
+ return config.shadowTiddlers[title];
+ else
+ return "";
+};
+
+TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
+{
+ if(!title)
+ return defaultText;
+ var pos = title.indexOf(config.textPrimitives.sectionSeparator);
+ var section = null;
+ if(pos != -1) {
+ section = title.substr(pos + config.textPrimitives.sectionSeparator.length);
+ title = title.substr(0,pos);
+ }
+ pos = title.indexOf(config.textPrimitives.sliceSeparator);
+ if(pos != -1) {
+ var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
+ if(slice)
+ return slice;
+ }
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ if(!section)
+ return tiddler.text;
+ var re = new RegExp("(^!{1,6}" + section.escapeRegExp() + "[ \t]*\n)","mg");
+ re.lastIndex = 0;
+ var match = re.exec(tiddler.text);
+ if(match) {
+ var t = tiddler.text.substr(match.index+match[1].length);
+ var re2 = /^!/mg;
+ re2.lastIndex = 0;
+ match = re2.exec(t); //# search for the next heading
+ if(match)
+ t = t.substr(0,match.index-1);//# don't include final \n
+ return t;
+ }
+ return defaultText;
+ }
+ if(this.isShadowTiddler(title))
+ return this.getShadowTiddlerText(title);
+ if(defaultText != undefined)
+ return defaultText;
+ return null;
+};
+
+TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth)
+{
+ var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
+ var text = this.getTiddlerText(title,null);
+ if(text == null)
+ return defaultText;
+ var textOut = [];
+ var lastPos = 0;
+ do {
+ var match = bracketRegExp.exec(text);
+ if(match) {
+ textOut.push(text.substr(lastPos,match.index-lastPos));
+ if(match[1]) {
+ if(depth <= 0)
+ textOut.push(match[1]);
+ else
+ textOut.push(this.getRecursiveTiddlerText(match[1],"[[" + match[1] + "]]",depth-1));
+ }
+ lastPos = match.index + match[0].length;
+ } else {
+ textOut.push(text.substr(lastPos));
+ }
+ } while(match);
+ return textOut.join("");
+};
+
+TiddlyWiki.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1[\t\x20]*([^\n]+)[\t\x20]*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|[\t\x20]*([^\n]+)[\t\x20]*\|$)/gm;
+
+// @internal
+TiddlyWiki.prototype.calcAllSlices = function(title)
+{
+ var slices = {};
+ var text = this.getTiddlerText(title,"");
+ this.slicesRE.lastIndex = 0;
+ var m = this.slicesRE.exec(text);
+ while(m) {
+ if(m[2])
+ slices[m[2]] = m[3];
+ else
+ slices[m[5]] = m[6];
+ m = this.slicesRE.exec(text);
+ }
+ return slices;
+};
+
+// Returns the slice of text of the given name
+TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName)
+{
+ var slices = this.slices[title];
+ if(!slices) {
+ slices = this.calcAllSlices(title);
+ this.slices[title] = slices;
+ }
+ return slices[sliceName];
+};
+
+// Build an hashmap of the specified named slices of a tiddler
+TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames)
+{
+ var r = {};
+ for(var t=0; t<sliceNames.length; t++) {
+ var slice = this.getTiddlerSlice(title,sliceNames[t]);
+ if(slice)
+ r[sliceNames[t]] = slice;
+ }
+ return r;
+};
+
+TiddlyWiki.prototype.suspendNotifications = function()
+{
+ this.notificationLevel--;
+};
+
+TiddlyWiki.prototype.resumeNotifications = function()
+{
+ this.notificationLevel++;
+};
+
+// Invoke the notification handlers for a particular tiddler
+TiddlyWiki.prototype.notify = function(title,doBlanket)
+{
+ if(!this.notificationLevel) {
+ for(var t=0; t<this.namedNotifications.length; t++) {
+ var n = this.namedNotifications[t];
+ if((n.name == null && doBlanket) || (n.name == title))
+ n.notify(title);
+ }
+ }
+};
+
+// Invoke the notification handlers for all tiddlers
+TiddlyWiki.prototype.notifyAll = function()
+{
+ if(!this.notificationLevel) {
+ for(var t=0; t<this.namedNotifications.length; t++) {
+ var n = this.namedNotifications[t];
+ if(n.name)
+ n.notify(n.name);
+ }
+ }
+};
+
+// Add a notification handler to a tiddler
+TiddlyWiki.prototype.addNotification = function(title,fn)
+{
+ for(var i=0; i<this.namedNotifications.length; i++) {
+ if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
+ return this;
+ }
+ this.namedNotifications.push({name: title, notify: fn});
+ return this;
+};
+
+TiddlyWiki.prototype.removeTiddler = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ this.deleteTiddler(title);
+ this.notify(title,true);
+ this.setDirty(true);
+ }
+};
+
+// Reset the sync status of a freshly synced tiddler
+TiddlyWiki.prototype.resetTiddler = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ tiddler.clearChangeCount();
+ this.notify(title,true);
+ this.setDirty(true);
+ }
+};
+
+TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ var t = tiddler.tags.indexOf(tag);
+ if(t != -1)
+ tiddler.tags.splice(t,1);
+ if(status)
+ tiddler.tags.push(tag);
+ tiddler.changed();
+ tiddler.incChangeCount();
+ this.notify(title,true);
+ this.setDirty(true);
+ }
+};
+
+TiddlyWiki.prototype.addTiddlerFields = function(title,fields)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(!tiddler)
+ return;
+ merge(tiddler.fields,fields);
+ tiddler.changed();
+ tiddler.incChangeCount();
+ this.notify(title,true);
+ this.setDirty(true);
+};
+
+TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ created = created || tiddler.created; // Preserve created date
+ this.deleteTiddler(title);
+ } else {
+ created = created || modified;
+ tiddler = new Tiddler();
+ }
+ tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields);
+ this.addTiddler(tiddler);
+ if(clearChangeCount)
+ tiddler.clearChangeCount();
+ else
+ tiddler.incChangeCount();
+ if(title != newTitle)
+ this.notify(title,true);
+ this.notify(newTitle,true);
+ this.setDirty(true);
+ return tiddler;
+};
+
+TiddlyWiki.prototype.incChangeCount = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler)
+ tiddler.incChangeCount();
+};
+
+TiddlyWiki.prototype.getLoader = function()
+{
+ if(!this.loader)
+ this.loader = new TW21Loader();
+ return this.loader;
+};
+
+TiddlyWiki.prototype.getSaver = function()
+{
+ if(!this.saver)
+ this.saver = new TW21Saver();
+ return this.saver;
+};
+
+// Return all tiddlers formatted as an HTML string
+TiddlyWiki.prototype.allTiddlersAsHtml = function()
+{
+ return this.getSaver().externalize(store);
+};
+
+// Load contents of a TiddlyWiki from an HTML DIV
+TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate)
+{
+ this.idPrefix = idPrefix;
+ var storeElem = (typeof src == "string") ? document.getElementById(src) : src;
+ if(!storeElem)
+ return;
+ var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes);
+ this.setDirty(false);
+ if(!noUpdate) {
+ for(var i = 0;i<tiddlers.length; i++)
+ tiddlers[i].changed();
+ }
+};
+
+// Load contents of a TiddlyWiki from a string
+// Returns null if there's an error
+TiddlyWiki.prototype.importTiddlyWiki = function(text)
+{
+ var posDiv = locateStoreArea(text);
+ if(!posDiv)
+ return null;
+ var content = "<" + "html><" + "body>" + text.substring(posDiv[0],posDiv[1] + endSaveArea.length) + "<" + "/body><" + "/html>";
+ // Create the iframe
+ var iframe = document.createElement("iframe");
+ iframe.style.display = "none";
+ document.body.appendChild(iframe);
+ var doc = iframe.document;
+ if(iframe.contentDocument)
+ doc = iframe.contentDocument; // For NS6
+ else if(iframe.contentWindow)
+ doc = iframe.contentWindow.document; // For IE5.5 and IE6
+ // Put the content in the iframe
+ doc.open();
+ doc.writeln(content);
+ doc.close();
+ // Load the content into a TiddlyWiki() object
+ var storeArea = doc.getElementById("storeArea");
+ this.loadFromDiv(storeArea,"store");
+ // Get rid of the iframe
+ iframe.parentNode.removeChild(iframe);
+ return this;
+};
+
+TiddlyWiki.prototype.updateTiddlers = function()
+{
+ this.tiddlersUpdated = true;
+ this.forEachTiddler(function(title,tiddler) {
+ tiddler.changed();
+ });
+};
+
+// Return an array of tiddlers matching a search regular expression
+TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag,match)
+{
+ var candidates = this.reverseLookup("tags",excludeTag,!!match);
+ var results = [];
+ for(var t=0; t<candidates.length; t++) {
+ if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
+ results.push(candidates[t]);
+ }
+ if(!sortField)
+ sortField = "title";
+ results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
+ return results;
+};
+
+// Returns a list of all tags in use
+// excludeTag - if present, excludes tags that are themselves tagged with excludeTag
+// Returns an array of arrays where [tag][0] is the name of the tag and [tag][1] is the number of occurances
+TiddlyWiki.prototype.getTags = function(excludeTag)
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ for(var g=0; g<tiddler.tags.length; g++) {
+ var tag = tiddler.tags[g];
+ var n = true;
+ for(var c=0; c<results.length; c++) {
+ if(results[c][0] == tag) {
+ n = false;
+ results[c][1]++;
+ }
+ }
+ if(n && excludeTag) {
+ var t = this.fetchTiddler(tag);
+ if(t && t.isTagged(excludeTag))
+ n = false;
+ }
+ if(n)
+ results.push([tag,1]);
+ }
+ });
+ results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
+ return results;
+};
+
+// Return an array of the tiddlers that are tagged with a given tag
+TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
+{
+ return this.reverseLookup("tags",tag,true,sortField);
+};
+
+// Return an array of the tiddlers that link to a given tiddler
+TiddlyWiki.prototype.getReferringTiddlers = function(title,unusedParameter,sortField)
+{
+ if(!this.tiddlersUpdated)
+ this.updateTiddlers();
+ return this.reverseLookup("links",title,true,sortField);
+};
+
+// Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
+// lookupMatch == true to match tiddlers, false to exclude tiddlers
+TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ var f = !lookupMatch;
+ for(var lookup=0; lookup<tiddler[lookupField].length; lookup++) {
+ if(tiddler[lookupField][lookup] == lookupValue)
+ f = lookupMatch;
+ }
+ if(f)
+ results.push(tiddler);
+ });
+ if(!sortField)
+ sortField = "title";
+ results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
+ return results;
+};
+
+// Return the tiddlers as a sorted array
+TiddlyWiki.prototype.getTiddlers = function(field,excludeTag)
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ if(excludeTag == undefined || !tiddler.isTagged(excludeTag))
+ results.push(tiddler);
+ });
+ if(field)
+ results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);});
+ return results;
+};
+
+// Return array of names of tiddlers that are referred to but not defined
+TiddlyWiki.prototype.getMissingLinks = function(sortField)
+{
+ if(!this.tiddlersUpdated)
+ this.updateTiddlers();
+ var results = [];
+ this.forEachTiddler(function (title,tiddler) {
+ if(tiddler.isTagged("excludeMissing") || tiddler.isTagged("systemConfig"))
+ return;
+ for(var n=0; n<tiddler.links.length;n++) {
+ var link = tiddler.links[n];
+ if(this.fetchTiddler(link) == null && !this.isShadowTiddler(link))
+ results.pushUnique(link);
+ }
+ });
+ results.sort();
+ return results;
+};
+
+// Return an array of names of tiddlers that are defined but not referred to
+TiddlyWiki.prototype.getOrphans = function()
+{
+ var results = [];
+ this.forEachTiddler(function (title,tiddler) {
+ if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists"))
+ results.push(title);
+ });
+ results.sort();
+ return results;
+};
+
+// Return an array of names of all the shadow tiddlers
+TiddlyWiki.prototype.getShadowed = function()
+{
+ var results = [];
+ for(var t in config.shadowTiddlers) {
+ if(this.isShadowTiddler(t))
+ results.push(t);
+ }
+ results.sort();
+ return results;
+};
+
+// Return an array of tiddlers that have been touched since they were downloaded or created
+TiddlyWiki.prototype.getTouched = function()
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ if(tiddler.isTouched())
+ results.push(tiddler);
+ });
+ results.sort();
+ return results;
+};
+
+// Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist
+TiddlyWiki.prototype.resolveTiddler = function(tiddler)
+{
+ var t = (typeof tiddler == 'string') ? this.getTiddler(tiddler) : tiddler;
+ return t instanceof Tiddler ? t : null;
+};
+
+// Filter a list of tiddlers
+TiddlyWiki.prototype.filterTiddlers = function(filter)
+{
+ var results = [];
+ if(filter) {
+ var tiddler;
+ var re = /([^\s\[\]]+)|(?:\[([ \w]+)\[([^\]]+)\]\])|(?:\[\[([^\]]+)\]\])/mg;
+ var match = re.exec(filter);
+ while(match) {
+ if(match[1] || match[4]) {
+ var title = match[1] || match[4];
+ tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ results.pushUnique(tiddler);
+ } else if(this.isShadowTiddler(title)) {
+ tiddler = new Tiddler();
+ tiddler.set(title,this.getTiddlerText(title));
+ results.pushUnique(tiddler);
+ } else {
+ results.pushUnique(new Tiddler(title));
+ }
+ } else if(match[2]) {
+ switch(match[2]) {
+ case "tag":
+ var matched = this.getTaggedTiddlers(match[3]);
+ for(var m = 0; m < matched.length; m++)
+ results.pushUnique(matched[m]);
+ break;
+ case "sort":
+ results = this.sortTiddlers(results,match[3]);
+ break;
+ }
+ }
+ match = re.exec(filter);
+ }
+ }
+ return results;
+};
+
+// Sort a list of tiddlers
+TiddlyWiki.prototype.sortTiddlers = function(tiddlers,field)
+{
+ var asc = +1;
+ switch(field.substr(0,1)) {
+ case "-":
+ asc = -1;
+ // Note: this fall-through is intentional
+ /*jsl:fallthru*/
+ case "+":
+ field = field.substr(1);
+ break;
+ }
+ if(TiddlyWiki.standardFieldAccess[field])
+ tiddlers.sort(function(a,b) {return a[field] < b[field] ? -asc : (a[field] == b[field] ? 0 : asc);});
+ else
+ tiddlers.sort(function(a,b) {return a.fields[field] < b.fields[field] ? -asc : (a.fields[field] == b.fields[field] ? 0 : +asc);});
+ return tiddlers;
+};
+
+// Returns true if path is a valid field name (path),
+// i.e. a sequence of identifiers, separated by '.'
+TiddlyWiki.isValidFieldName = function(name)
+{
+ var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name);
+ return match && (match[0] == name);
+};
+
+// Throws an exception when name is not a valid field name.
+TiddlyWiki.checkFieldName = function(name)
+{
+ if(!TiddlyWiki.isValidFieldName(name))
+ throw config.messages.invalidFieldName.format([name]);
+};
+
+function StringFieldAccess(n,readOnly)
+{
+ this.set = readOnly ?
+ function(t,v) {if(v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);} :
+ function(t,v) {if(v != t[n]) {t[n] = v; return true;}};
+ this.get = function(t) {return t[n];};
+}
+
+function DateFieldAccess(n)
+{
+ this.set = function(t,v) {
+ var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v);
+ if(d != t[n]) {
+ t[n] = d; return true;
+ }
+ };
+ this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();};
+}
+
+function LinksFieldAccess(n)
+{
+ this.set = function(t,v) {
+ var s = (typeof v == "string") ? v.readBracketedList() : v;
+ if(s.toString() != t[n].toString()) {
+ t[n] = s; return true;
+ }
+ };
+ this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);};
+}
+
+TiddlyWiki.standardFieldAccess = {
+ // The set functions return true when setting the data has changed the value.
+ "title": new StringFieldAccess("title",true),
+ // Handle the "tiddler" field name as the title
+ "tiddler": new StringFieldAccess("title",true),
+ "text": new StringFieldAccess("text"),
+ "modifier": new StringFieldAccess("modifier"),
+ "modified": new DateFieldAccess("modified"),
+ "created": new DateFieldAccess("created"),
+ "tags": new LinksFieldAccess("tags")
+};
+
+TiddlyWiki.isStandardField = function(name)
+{
+ return TiddlyWiki.standardFieldAccess[name] != undefined;
+};
+
+// Sets the value of the given field of the tiddler to the value.
+// Setting an ExtendedField's value to null or undefined removes the field.
+// Setting a namespace to undefined removes all fields of that namespace.
+// The fieldName is case-insensitive.
+// All values will be converted to a string value.
+TiddlyWiki.prototype.setValue = function(tiddler,fieldName,value)
+{
+ TiddlyWiki.checkFieldName(fieldName);
+ var t = this.resolveTiddler(tiddler);
+ if(!t)
+ return;
+ fieldName = fieldName.toLowerCase();
+ var isRemove = (value === undefined) || (value === null);
+ var accessor = TiddlyWiki.standardFieldAccess[fieldName];
+ if(accessor) {
+ if(isRemove)
+ // don't remove StandardFields
+ return;
+ var h = TiddlyWiki.standardFieldAccess[fieldName];
+ if(!h.set(t,value))
+ return;
+ } else {
+ var oldValue = t.fields[fieldName];
+ if(isRemove) {
+ if(oldValue !== undefined) {
+ // deletes a single field
+ delete t.fields[fieldName];
+ } else {
+ // no concrete value is defined for the fieldName
+ // so we guess this is a namespace path.
+ // delete all fields in a namespace
+ var re = new RegExp('^'+fieldName+'\\.');
+ var dirty = false;
+ for(var n in t.fields) {
+ if(n.match(re)) {
+ delete t.fields[n];
+ dirty = true;
+ }
+ }
+ if(!dirty)
+ return;
+ }
+ } else {
+ // the "normal" set case. value is defined (not null/undefined)
+ // For convenience provide a nicer conversion Date->String
+ value = value instanceof Date ? value.convertToYYYYMMDDHHMMSSMMM() : String(value);
+ if(oldValue == value)
+ return;
+ t.fields[fieldName] = value;
+ }
+ }
+ // When we are here the tiddler/store really was changed.
+ this.notify(t.title,true);
+ if(!fieldName.match(/^temp\./))
+ this.setDirty(true);
+};
+
+// Returns the value of the given field of the tiddler.
+// The fieldName is case-insensitive.
+// Will only return String values (or undefined).
+TiddlyWiki.prototype.getValue = function(tiddler,fieldName)
+{
+ var t = this.resolveTiddler(tiddler);
+ if(!t)
+ return undefined;
+ fieldName = fieldName.toLowerCase();
+ var accessor = TiddlyWiki.standardFieldAccess[fieldName];
+ if(accessor) {
+ return accessor.get(t);
+ }
+ return t.fields[fieldName];
+};
+
+// Calls the callback function for every field in the tiddler.
+// When callback function returns a non-false value the iteration stops
+// and that value is returned.
+// The order of the fields is not defined.
+// @param callback a function(tiddler,fieldName,value).
+TiddlyWiki.prototype.forEachField = function(tiddler,callback,onlyExtendedFields)
+{
+ var t = this.resolveTiddler(tiddler);
+ if(!t)
+ return undefined;
+ var n,result;
+ for(n in t.fields) {
+ result = callback(t,n,t.fields[n]);
+ if(result)
+ return result;
+ }
+ if(onlyExtendedFields)
+ return undefined;
+ for(n in TiddlyWiki.standardFieldAccess) {
+ if(n == "tiddler")
+ // even though the "title" field can also be referenced through the name "tiddler"
+ // we only visit this field once.
+ continue;
+ result = callback(t,n,TiddlyWiki.standardFieldAccess[n].get(t));
+ if(result)
+ return result;
+ }
+ return undefined;
+};
+
+//--
+//-- Story functions
+//--
+
+function Story(containerId,idPrefix)
+{
+ this.container = containerId;
+ this.idPrefix = idPrefix;
+ this.highlightRegExp = null;
+ this.tiddlerId = function(title) {
+ var id = this.idPrefix + title;
+ return id==this.container ? this.idPrefix + "_" + title : id;
+ };
+ this.containerId = function() {
+ return this.container;
+ };
+}
+
+Story.prototype.getTiddler = function(title)
+{
+ return document.getElementById(this.tiddlerId(title));
+};
+
+Story.prototype.getContainer = function()
+{
+ return document.getElementById(this.containerId());
+};
+
+Story.prototype.forEachTiddler = function(fn)
+{
+ var place = this.getContainer();
+ if(!place)
+ return;
+ var e = place.firstChild;
+ while(e) {
+ var n = e.nextSibling;
+ var title = e.getAttribute("tiddler");
+ fn.call(this,title,e);
+ e = n;
+ }
+};
+
+Story.prototype.displayDefaultTiddlers = function()
+{
+ this.displayTiddlers(null,store.filterTiddlers(store.getTiddlerText("DefaultTiddlers")));
+};
+
+Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,unused,customFields,toggle)
+{
+ for(var t = titles.length-1;t>=0;t--)
+ this.displayTiddler(srcElement,titles[t],template,animate,unused,customFields);
+};
+
+Story.prototype.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle,animationSrc)
+{
+ var title = (tiddler instanceof Tiddler) ? tiddler.title : tiddler;
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ if(toggle)
+ this.closeTiddler(title,true);
+ else
+ this.refreshTiddler(title,template,false,customFields);
+ } else {
+ var place = this.getContainer();
+ var before = this.positionTiddler(srcElement);
+ tiddlerElem = this.createTiddler(place,before,title,template,customFields);
+ }
+ if(animationSrc && typeof animationSrc !== "string") {
+ srcElement = animationSrc;
+ }
+ if(srcElement && typeof srcElement !== "string") {
+ if(config.options.chkAnimate && (animate == undefined || animate == true) && anim && typeof Zoomer == "function" && typeof Scroller == "function")
+ anim.startAnimating(new Zoomer(title,srcElement,tiddlerElem),new Scroller(tiddlerElem));
+ else
+ window.scrollTo(0,ensureVisible(tiddlerElem));
+ }
+};
+
+Story.prototype.positionTiddler = function(srcElement)
+{
+ var place = this.getContainer();
+ var before = null;
+ if(typeof srcElement == "string") {
+ switch(srcElement) {
+ case "top":
+ before = place.firstChild;
+ break;
+ case "bottom":
+ before = null;
+ break;
+ }
+ } else {
+ var after = this.findContainingTiddler(srcElement);
+ if(after == null) {
+ before = place.firstChild;
+ } else if(after.nextSibling) {
+ before = after.nextSibling;
+ if(before.nodeType != 1)
+ before = null;
+ }
+ }
+ return before;
+};
+
+Story.prototype.createTiddler = function(place,before,title,template,customFields)
+{
+ var tiddlerElem = createTiddlyElement(null,"div",this.tiddlerId(title),"tiddler");
+ tiddlerElem.setAttribute("refresh","tiddler");
+ if(customFields)
+ tiddlerElem.setAttribute("tiddlyFields",customFields);
+ place.insertBefore(tiddlerElem,before);
+ var defaultText = null;
+ if(!store.tiddlerExists(title) && !store.isShadowTiddler(title))
+ defaultText = this.loadMissingTiddler(title,customFields,tiddlerElem);
+ this.refreshTiddler(title,template,false,customFields,defaultText);
+ return tiddlerElem;
+};
+
+Story.prototype.loadMissingTiddler = function(title,fields,tiddlerElem)
+{
+ var tiddler = new Tiddler(title);
+ tiddler.fields = typeof fields == "string" ? fields.decodeHashMap() : (fields || {});
+ var serverType = tiddler.getServerType();
+ var host = tiddler.fields['server.host'];
+ var workspace = tiddler.fields['server.workspace'];
+ if(!serverType || !host)
+ return null;
+ var sm = new SyncMachine(serverType,{
+ start: function() {
+ return this.openHost(host,"openWorkspace");
+ },
+ openWorkspace: function() {
+ return this.openWorkspace(workspace,"getTiddler");
+ },
+ getTiddler: function() {
+ return this.getTiddler(title,"onGetTiddler");
+ },
+ onGetTiddler: function(context) {
+ var tiddler = context.tiddler;
+ if(tiddler && tiddler.text) {
+ var downloaded = new Date();
+ if(!tiddler.created)
+ tiddler.created = downloaded;
+ if(!tiddler.modified)
+ tiddler.modified = tiddler.created;
+ store.saveTiddler(tiddler.title,tiddler.title,tiddler.text,tiddler.modifier,tiddler.modified,tiddler.tags,tiddler.fields,true,tiddler.created);
+ autoSaveChanges();
+ }
+ delete this;
+ return true;
+ },
+ error: function(message) {
+ displayMessage("Error loading missing tiddler from %0: %1".format([host,message]));
+ }
+ });
+ sm.go();
+ return config.messages.loadingMissingTiddler.format([title,serverType,host,workspace]);
+};
+
+Story.prototype.chooseTemplateForTiddler = function(title,template)
+{
+ if(!template)
+ template = DEFAULT_VIEW_TEMPLATE;
+ if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE)
+ template = config.tiddlerTemplates[template];
+ return template;
+};
+
+Story.prototype.getTemplateForTiddler = function(title,template,tiddler)
+{
+ return store.getRecursiveTiddlerText(template,null,10);
+};
+
+Story.prototype.refreshTiddler = function(title,template,force,customFields,defaultText)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ if(tiddlerElem.getAttribute("dirty") == "true" && !force)
+ return tiddlerElem;
+ template = this.chooseTemplateForTiddler(title,template);
+ var currTemplate = tiddlerElem.getAttribute("template");
+ if((template != currTemplate) || force) {
+ var tiddler = store.getTiddler(title);
+ if(!tiddler) {
+ tiddler = new Tiddler();
+ if(store.isShadowTiddler(title)) {
+ var tags = [];
+ tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,tags,version.date);
+ } else {
+ var text = template=="EditTemplate" ?
+ config.views.editor.defaultText.format([title]) :
+ config.views.wikified.defaultText.format([title]);
+ text = defaultText || text;
+ var fields = customFields ? customFields.decodeHashMap() : null;
+ tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date,fields);
+ }
+ }
+ tiddlerElem.setAttribute("tags",tiddler.tags.join(" "));
+ tiddlerElem.setAttribute("tiddler",title);
+ tiddlerElem.setAttribute("template",template);
+ tiddlerElem.onmouseover = this.onTiddlerMouseOver;
+ tiddlerElem.onmouseout = this.onTiddlerMouseOut;
+ tiddlerElem.ondblclick = this.onTiddlerDblClick;
+ tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress;
+ tiddlerElem.innerHTML = this.getTemplateForTiddler(title,template,tiddler);
+ applyHtmlMacros(tiddlerElem,tiddler);
+ if(store.getTaggedTiddlers(title).length > 0)
+ addClass(tiddlerElem,"isTag");
+ else
+ removeClass(tiddlerElem,"isTag");
+ if(store.tiddlerExists(title)) {
+ removeClass(tiddlerElem,"shadow");
+ removeClass(tiddlerElem,"missing");
+ } else {
+ addClass(tiddlerElem,store.isShadowTiddler(title) ? "shadow" : "missing");
+ }
+ if(customFields)
+ this.addCustomFields(tiddlerElem,customFields);
+ forceReflow();
+ }
+ }
+ return tiddlerElem;
+};
+
+Story.prototype.addCustomFields = function(place,customFields)
+{
+ var fields = customFields.decodeHashMap();
+ var w = document.createElement("div");
+ w.style.display = "none";
+ place.appendChild(w);
+ for(var t in fields) {
+ var e = document.createElement("input");
+ e.setAttribute("type","text");
+ e.setAttribute("value",fields[t]);
+ w.appendChild(e);
+ e.setAttribute("edit",t);
+ }
+};
+
+Story.prototype.refreshAllTiddlers = function(force)
+{
+ var e = this.getContainer().firstChild;
+ while(e) {
+ var template = e.getAttribute("template");
+ if(template && e.getAttribute("dirty") != "true") {
+ this.refreshTiddler(e.getAttribute("tiddler"),force ? null : template,true);
+ }
+ e = e.nextSibling;
+ }
+};
+
+Story.prototype.onTiddlerMouseOver = function(e)
+{
+ if(window.addClass instanceof Function)
+ addClass(this,"selected");
+};
+
+Story.prototype.onTiddlerMouseOut = function(e)
+{
+ if(window.removeClass instanceof Function)
+ removeClass(this,"selected");
+};
+
+Story.prototype.onTiddlerDblClick = function(ev)
+{
+ var e = ev || window.event;
+ var target = resolveTarget(e);
+ if(target && target.nodeName.toLowerCase() != "input" && target.nodeName.toLowerCase() != "textarea") {
+ if(document.selection && document.selection.empty)
+ document.selection.empty();
+ config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return true;
+ }
+ return false;
+};
+
+Story.prototype.onTiddlerKeyPress = function(ev)
+{
+ var e = ev || window.event;
+ clearMessage();
+ var consume = false;
+ var title = this.getAttribute("tiddler");
+ var target = resolveTarget(e);
+ switch(e.keyCode) {
+ case 9: // Tab
+ if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea") {
+ replaceSelection(target,String.fromCharCode(9));
+ consume = true;
+ }
+ if(config.isOpera) {
+ target.onblur = function() {
+ this.focus();
+ this.onblur = null;
+ };
+ }
+ break;
+ case 13: // Ctrl-Enter
+ case 10: // Ctrl-Enter on IE PC
+ case 77: // Ctrl-Enter is "M" on some platforms
+ if(e.ctrlKey) {
+ blurElement(this);
+ config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
+ consume = true;
+ }
+ break;
+ case 27: // Escape
+ blurElement(this);
+ config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
+ consume = true;
+ break;
+ }
+ e.cancelBubble = consume;
+ if(consume) {
+ if(e.stopPropagation) e.stopPropagation(); // Stop Propagation
+ e.returnValue = true; // Cancel The Event in IE
+ if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz
+ }
+ return !consume;
+};
+
+Story.prototype.getTiddlerField = function(title,field)
+{
+ var tiddlerElem = this.getTiddler(title);
+ var e = null;
+ if(tiddlerElem ) {
+ var children = tiddlerElem.getElementsByTagName("*");
+ for(var t=0; t<children.length; t++) {
+ var c = children[t];
+ if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
+ if(!e)
+ e = c;
+ if(c.getAttribute("edit") == field)
+ e = c;
+ }
+ }
+ }
+ return e;
+};
+
+Story.prototype.focusTiddler = function(title,field)
+{
+ var e = this.getTiddlerField(title,field);
+ if(e) {
+ e.focus();
+ e.select();
+ }
+};
+
+Story.prototype.blurTiddler = function(title)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem && tiddlerElem.focus && tiddlerElem.blur) {
+ tiddlerElem.focus();
+ tiddlerElem.blur();
+ }
+};
+
+Story.prototype.setTiddlerField = function(title,tag,mode,field)
+{
+ var c = this.getTiddlerField(title,field);
+ var tags = c.value.readBracketedList();
+ tags.setItem(tag,mode);
+ c.value = String.encodeTiddlyLinkList(tags);
+};
+
+Story.prototype.setTiddlerTag = function(title,tag,mode)
+{
+ this.setTiddlerField(title,tag,mode,"tags");
+};
+
+Story.prototype.closeTiddler = function(title,animate,unused)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ clearMessage();
+ this.scrubTiddler(tiddlerElem);
+ if(config.options.chkAnimate && animate && anim && typeof Slider == "function")
+ anim.startAnimating(new Slider(tiddlerElem,false,null,"all"));
+ else {
+ removeNode(tiddlerElem);
+ forceReflow();
+ }
+ }
+};
+
+Story.prototype.scrubTiddler = function(tiddlerElem)
+{
+ tiddlerElem.id = null;
+};
+
+Story.prototype.setDirty = function(title,dirty)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem)
+ tiddlerElem.setAttribute("dirty",dirty ? "true" : "false");
+};
+
+Story.prototype.isDirty = function(title)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem)
+ return tiddlerElem.getAttribute("dirty") == "true";
+ return null;
+};
+
+Story.prototype.areAnyDirty = function()
+{
+ var r = false;
+ this.forEachTiddler(function(title,element) {
+ if(this.isDirty(title))
+ r = true;
+ });
+ return r;
+};
+
+Story.prototype.closeAllTiddlers = function(exclude)
+{
+ clearMessage();
+ this.forEachTiddler(function(title,element) {
+ if((title != exclude) && element.getAttribute("dirty") != "true")
+ this.closeTiddler(title);
+ });
+ window.scrollTo(0,ensureVisible(this.container));
+};
+
+Story.prototype.isEmpty = function()
+{
+ var place = this.getContainer();
+ return place && place.firstChild == null;
+};
+
+Story.prototype.search = function(text,useCaseSensitive,useRegExp)
+{
+ this.closeAllTiddlers();
+ highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img");
+ var matches = store.search(highlightHack,"title","excludeSearch");
+ this.displayTiddlers(null,matches);
+ highlightHack = null;
+ var q = useRegExp ? "/" : "'";
+ if(matches.length > 0)
+ displayMessage(config.macros.search.successMsg.format([matches.length.toString(),q + text + q]));
+ else
+ displayMessage(config.macros.search.failureMsg.format([q + text + q]));
+};
+
+Story.prototype.findContainingTiddler = function(e)
+{
+ while(e && !hasClass(e,"tiddler"))
+ e = e.parentNode;
+ return e;
+};
+
+Story.prototype.gatherSaveFields = function(e,fields)
+{
+ if(e && e.getAttribute) {
+ var f = e.getAttribute("edit");
+ if(f)
+ fields[f] = e.value.replace(/\r/mg,"");
+ if(e.hasChildNodes()) {
+ var c = e.childNodes;
+ for(var t=0; t<c.length; t++)
+ this.gatherSaveFields(c[t],fields);
+ }
+ }
+};
+
+Story.prototype.hasChanges = function(title)
+{
+ var e = this.getTiddler(title);
+ if(e) {
+ var fields = {};
+ this.gatherSaveFields(e,fields);
+ var tiddler = store.fetchTiddler(title);
+ if(!tiddler)
+ return false;
+ for(var n in fields) {
+ if(store.getValue(title,n) != fields[n])
+ return true;
+ }
+ }
+ return false;
+};
+
+Story.prototype.saveTiddler = function(title,minorUpdate)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ var fields = {};
+ this.gatherSaveFields(tiddlerElem,fields);
+ var newTitle = fields.title || title;
+ if(!store.tiddlerExists(newTitle))
+ newTitle = newTitle.trim();
+ if(store.tiddlerExists(newTitle) && newTitle != title) {
+ if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
+ return null;
+ }
+ if(newTitle != title)
+ this.closeTiddler(newTitle,false);
+ tiddlerElem.id = this.tiddlerId(newTitle);
+ tiddlerElem.setAttribute("tiddler",newTitle);
+ tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE);
+ tiddlerElem.setAttribute("dirty","false");
+ if(config.options.chkForceMinorUpdate)
+ minorUpdate = !minorUpdate;
+ if(!store.tiddlerExists(newTitle))
+ minorUpdate = false;
+ var newDate = new Date();
+ var extendedFields = store.tiddlerExists(newTitle) ? store.fetchTiddler(newTitle).fields : (newTitle!=title && store.tiddlerExists(title) ? store.fetchTiddler(title).fields : merge({},config.defaultCustomFields));
+ for(var n in fields) {
+ if(!TiddlyWiki.isStandardField(n))
+ extendedFields[n] = fields[n];
+ }
+ var tiddler = store.saveTiddler(title,newTitle,fields.text,minorUpdate ? undefined : config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags,extendedFields);
+ autoSaveChanges(null,[tiddler]);
+ return newTitle;
+ }
+ return null;
+};
+
+Story.prototype.permaView = function()
+{
+ var links = [];
+ this.forEachTiddler(function(title,element) {
+ links.push(String.encodeTiddlyLink(title));
+ });
+ var t = encodeURIComponent(links.join(" "));
+ if(t == "")
+ t = "#";
+ if(window.location.hash != t)
+ window.location.hash = t;
+};
+
+Story.prototype.switchTheme = function(theme)
+{
+ if(safeMode)
+ return;
+
+ var isAvailable = function(title) {
+ var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
+ if(s!=-1)
+ title = title.substr(0,s);
+ return store.tiddlerExists(title) || store.isShadowTiddler(title);
+ };
+
+ var getSlice = function(theme,slice) {
+ var r;
+ if(readOnly)
+ r = store.getTiddlerSlice(theme,slice+"ReadOnly") || store.getTiddlerSlice(theme,"Web"+slice);
+ r = r || store.getTiddlerSlice(theme,slice);
+ if(r && r.indexOf(config.textPrimitives.sectionSeparator)==0)
+ r = theme + r;
+ return isAvailable(r) ? r : slice;
+ };
+
+ var replaceNotification = function(i,name,theme,slice) {
+ var newName = getSlice(theme,slice);
+ if(name!=newName && store.namedNotifications[i].name==name) {
+ store.namedNotifications[i].name = newName;
+ return newName;
+ }
+ return name;
+ };
+
+ var pt = config.refresherData.pageTemplate;
+ var vi = DEFAULT_VIEW_TEMPLATE;
+ var vt = config.tiddlerTemplates[vi];
+ var ei = DEFAULT_EDIT_TEMPLATE;
+ var et = config.tiddlerTemplates[ei];
+
+ for(var i=0; i<config.notifyTiddlers.length; i++) {
+ var name = config.notifyTiddlers[i].name;
+ switch(name) {
+ case "PageTemplate":
+ config.refresherData.pageTemplate = replaceNotification(i,config.refresherData.pageTemplate,theme,name);
+ break;
+ case "StyleSheet":
+ removeStyleSheet(config.refresherData.styleSheet);
+ config.refresherData.styleSheet = replaceNotification(i,config.refresherData.styleSheet,theme,name);
+ break;
+ case "ColorPalette":
+ config.refresherData.colorPalette = replaceNotification(i,config.refresherData.colorPalette,theme,name);
+ break;
+ default:
+ break;
+ }
+ }
+ config.tiddlerTemplates[vi] = getSlice(theme,"ViewTemplate");
+ config.tiddlerTemplates[ei] = getSlice(theme,"EditTemplate");
+ if(!startingUp) {
+ if(config.refresherData.pageTemplate!=pt || config.tiddlerTemplates[vi]!=vt || config.tiddlerTemplates[ei]!=et) {
+ refreshAll();
+ this.refreshAllTiddlers(true);
+ } else {
+ setStylesheet(store.getRecursiveTiddlerText(config.refresherData.styleSheet,"",10),config.refreshers.styleSheet);
+ }
+ config.options.txtTheme = theme;
+ saveOptionCookie("txtTheme");
+ }
+};
+
+//--
+//-- Backstage
+//--
+
+var backstage = {
+ area: null,
+ toolbar: null,
+ button: null,
+ showButton: null,
+ hideButton: null,
+ cloak: null,
+ panel: null,
+ panelBody: null,
+ panelFooter: null,
+ currTabName: null,
+ currTabElem: null,
+ content: null,
+
+ init: function() {
+ var cmb = config.messages.backstage;
+ this.area = document.getElementById("backstageArea");
+ this.toolbar = document.getElementById("backstageToolbar");
+ this.button = document.getElementById("backstageButton");
+ this.button.style.display = "block";
+ var t = cmb.open.text + " " + glyph("bentArrowLeft");
+ this.showButton = createTiddlyButton(this.button,t,cmb.open.tooltip,
+ function(e) {backstage.show(); return false;},null,"backstageShow");
+ t = glyph("bentArrowRight") + " " + cmb.close.text;
+ this.hideButton = createTiddlyButton(this.button,t,cmb.close.tooltip,
+ function(e) {backstage.hide(); return false;},null,"backstageHide");
+ this.cloak = document.getElementById("backstageCloak");
+ this.panel = document.getElementById("backstagePanel");
+ this.panelFooter = createTiddlyElement(this.panel,"div",null,"backstagePanelFooter");
+ this.panelBody = createTiddlyElement(this.panel,"div",null,"backstagePanelBody");
+ this.cloak.onmousedown = function(e) {backstage.switchTab(null);};
+ createTiddlyText(this.toolbar,cmb.prompt);
+ for(t=0; t<config.backstageTasks.length; t++) {
+ var taskName = config.backstageTasks[t];
+ var task = config.tasks[taskName];
+ var handler = task.action ? this.onClickCommand : this.onClickTab;
+ var text = task.text + (task.action ? "" : glyph("downTriangle"));
+ var btn = createTiddlyButton(this.toolbar,text,task.tooltip,handler,"backstageTab");
+ btn.setAttribute("task",taskName);
+ addClass(btn,task.action ? "backstageAction" : "backstageTask");
+ }
+ this.content = document.getElementById("contentWrapper");
+ if(config.options.chkBackstage)
+ this.show();
+ else
+ this.hide();
+ },
+
+ isVisible: function() {
+ return this.area ? this.area.style.display == "block" : false;
+ },
+
+ show: function() {
+ this.area.style.display = "block";
+ if(anim && config.options.chkAnimate) {
+ backstage.toolbar.style.left = findWindowWidth() + "px";
+ var p = [{style: "left", start: findWindowWidth(), end: 0, template: "%0px"}];
+ anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p));
+ } else {
+ backstage.area.style.left = "0px";
+ }
+ this.showButton.style.display = "none";
+ this.hideButton.style.display = "block";
+ config.options.chkBackstage = true;
+ saveOptionCookie("chkBackstage");
+ addClass(this.content,"backstageVisible");
+ },
+
+ hide: function() {
+ if(this.currTabElem) {
+ this.switchTab(null);
+ } else {
+ backstage.toolbar.style.left = "0px";
+ if(anim && config.options.chkAnimate) {
+ var p = [{style: "left", start: 0, end: findWindowWidth(), template: "%0px"}];
+ var c = function(element,properties) {backstage.area.style.display = "none";};
+ anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p,c));
+ } else {
+ this.area.style.display = "none";
+ }
+ this.showButton.style.display = "block";
+ this.hideButton.style.display = "none";
+ config.options.chkBackstage = false;
+ saveOptionCookie("chkBackstage");
+ removeClass(this.content,"backstageVisible");
+ }
+ },
+
+ onClickCommand: function(e) {
+ var task = config.tasks[this.getAttribute("task")];
+ displayMessage(task);
+ if(task.action) {
+ backstage.switchTab(null);
+ task.action();
+ }
+ return false;
+ },
+
+ onClickTab: function(e) {
+ backstage.switchTab(this.getAttribute("task"));
+ return false;
+ },
+
+ // Switch to a given tab, or none if null is passed
+ switchTab: function(tabName) {
+ var tabElem = null;
+ var e = this.toolbar.firstChild;
+ while(e)
+ {
+ if(e.getAttribute && e.getAttribute("task") == tabName)
+ tabElem = e;
+ e = e.nextSibling;
+ }
+ if(tabName == backstage.currTabName)
+ return;
+ if(backstage.currTabElem) {
+ removeClass(this.currTabElem,"backstageSelTab");
+ }
+ if(tabElem && tabName) {
+ backstage.preparePanel();
+ addClass(tabElem,"backstageSelTab");
+ var task = config.tasks[tabName];
+ wikify(task.content,backstage.panelBody,null,null);
+ backstage.showPanel();
+ } else if(backstage.currTabElem) {
+ backstage.hidePanel();
+ }
+ backstage.currTabName = tabName;
+ backstage.currTabElem = tabElem;
+ },
+
+ isPanelVisible: function() {
+ return backstage.panel ? backstage.panel.style.display == "block" : false;
+ },
+
+ preparePanel: function() {
+ backstage.cloak.style.height = findWindowHeight() + "px";
+ backstage.cloak.style.display = "block";
+ removeChildren(backstage.panelBody);
+ return backstage.panelBody;
+ },
+
+ showPanel: function() {
+ backstage.panel.style.display = "block";
+ if(anim && config.options.chkAnimate) {
+ backstage.panel.style.top = (-backstage.panel.offsetHeight) + "px";
+ var p = [{style: "top", start: -backstage.panel.offsetHeight, end: 0, template: "%0px"}];
+ anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p),new Scroller(backstage.panel,false));
+ } else {
+ backstage.panel.style.top = "0px";
+ }
+ return backstage.panelBody;
+ },
+
+ hidePanel: function() {
+ if(backstage.currTabElem)
+ removeClass(backstage.currTabElem,"backstageSelTab");
+ backstage.currTabElem = null;
+ backstage.currTabName = null;
+ if(anim && config.options.chkAnimate) {
+ var p = [
+ {style: "top", start: 0, end: -(backstage.panel.offsetHeight), template: "%0px"},
+ {style: "display", atEnd: "none"}
+ ];
+ var c = function(element,properties) {backstage.cloak.style.display = "none";};
+ anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p,c));
+ } else {
+ backstage.panel.style.display = "none";
+ backstage.cloak.style.display = "none";
+ }
+ }
+};
+
+config.macros.backstage = {};
+
+config.macros.backstage.handler = function(place,macroName,params)
+{
+ var backstageTask = config.tasks[params[0]];
+ if(backstageTask)
+ createTiddlyButton(place,backstageTask.text,backstageTask.tooltip,function(e) {backstage.switchTab(params[0]); return false;});
+};
+
+//--
+//-- ImportTiddlers macro
+//--
+
+config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if(readOnly) {
+ createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning);
+ return;
+ }
+ var w = new Wizard();
+ w.createWizard(place,this.wizardTitle);
+ this.restart(w);
+};
+
+config.macros.importTiddlers.onCancel = function(e)
+{
+ var wizard = new Wizard(this);
+ var place = wizard.clear();
+ config.macros.importTiddlers.restart(wizard);
+ return false;
+};
+
+config.macros.importTiddlers.onClose = function(e)
+{
+ backstage.hidePanel();
+ return false;
+};
+
+config.macros.importTiddlers.restart = function(wizard)
+{
+ wizard.addStep(this.step1Title,this.step1Html);
+ var s = wizard.getElement("selTypes");
+ for(var t in config.adaptors) {
+ var e = createTiddlyElement(s,"option",null,null,config.adaptors[t].serverLabel ? config.adaptors[t].serverLabel : t);
+ e.value = t;
+ }
+ if(config.defaultAdaptor)
+ s.value = config.defaultAdaptor;
+ s = wizard.getElement("selFeeds");
+ var feeds = this.getFeeds();
+ for(t in feeds) {
+ e = createTiddlyElement(s,"option",null,null,t);
+ e.value = t;
+ }
+ wizard.setValue("feeds",feeds);
+ s.onchange = config.macros.importTiddlers.onFeedChange;
+ var fileInput = wizard.getElement("txtBrowse");
+ fileInput.onchange = config.macros.importTiddlers.onBrowseChange;
+ fileInput.onkeyup = config.macros.importTiddlers.onBrowseChange;
+ wizard.setButtons([{caption: this.openLabel, tooltip: this.openPrompt, onClick: config.macros.importTiddlers.onOpen}]);
+ wizard.formElem.action = "javascript:;";
+ wizard.formElem.onsubmit = function() {
+ if(this.txtPath.value.length)
+ this.lastChild.firstChild.onclick();
+ };
+};
+
+config.macros.importTiddlers.getFeeds = function()
+{
+ var feeds = {};
+ var tagged = store.getTaggedTiddlers("systemServer","title");
+ for(var t=0; t<tagged.length; t++) {
+ var title = tagged[t].title;
+ var serverType = store.getTiddlerSlice(title,"Type");
+ if(!serverType)
+ serverType = "file";
+ feeds[title] = {title: title,
+ url: store.getTiddlerSlice(title,"URL"),
+ workspace: store.getTiddlerSlice(title,"Workspace"),
+ workspaceList: store.getTiddlerSlice(title,"WorkspaceList"),
+ tiddlerFilter: store.getTiddlerSlice(title,"TiddlerFilter"),
+ serverType: serverType,
+ description: store.getTiddlerSlice(title,"Description")};
+ }
+ return feeds;
+};
+
+config.macros.importTiddlers.onFeedChange = function(e)
+{
+ var wizard = new Wizard(this);
+ var selTypes = wizard.getElement("selTypes");
+ var fileInput = wizard.getElement("txtPath");
+ var feeds = wizard.getValue("feeds");
+ var f = feeds[this.value];
+ if(f) {
+ selTypes.value = f.serverType;
+ fileInput.value = f.url;
+ wizard.setValue("feedName",f.serverType);
+ wizard.setValue("feedHost",f.url);
+ wizard.setValue("feedWorkspace",f.workspace);
+ wizard.setValue("feedWorkspaceList",f.workspaceList);
+ wizard.setValue("feedTiddlerFilter",f.tiddlerFilter);
+ }
+ return false;
+};
+
+config.macros.importTiddlers.onBrowseChange = function(e)
+{
+ var wizard = new Wizard(this);
+ var fileInput = wizard.getElement("txtPath");
+ fileInput.value = config.macros.importTiddlers.getURLFromLocalPath(this.value);
+ var serverType = wizard.getElement("selTypes");
+ serverType.value = "file";
+ return true;
+};
+
+config.macros.importTiddlers.getURLFromLocalPath = function(v)
+{
+ if(!v||!v.length)
+ return v;
+ v = v.replace(/\\/g,"/"); // use "/" for cross-platform consistency
+ var u;
+ var t = v.split(":");
+ var p = t[1]||t[0]; // remove drive letter (if any)
+ if (t[1] && (t[0]=="http"||t[0]=="https"||t[0]=="file")) {
+ u = v;
+ } else if(p.substr(0,1)=="/") {
+ u = document.location.protocol + "//" + document.location.hostname + (t[1] ? "/" : "") + v;
+ } else {
+ var c = document.location.href.replace(/\\/g,"/");
+ var pos = c.lastIndexOf("/");
+ if (pos!=-1)
+ c = c.substr(0,pos); // remove filename
+ u = c + "/" + p;
+ }
+ return u;
+};
+
+config.macros.importTiddlers.onOpen = function(e)
+{
+ var wizard = new Wizard(this);
+ var fileInput = wizard.getElement("txtPath");
+ var url = fileInput.value;
+ var serverType = wizard.getElement("selTypes").value || config.defaultAdaptor;
+ var adaptor = new config.adaptors[serverType]();
+ wizard.setValue("adaptor",adaptor);
+ wizard.setValue("serverType",serverType);
+ wizard.setValue("host",url);
+ var ret = adaptor.openHost(url,null,wizard,config.macros.importTiddlers.onOpenHost);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenHost);
+ return false;
+};
+
+config.macros.importTiddlers.onOpenHost = function(context,wizard)
+{
+ var adaptor = wizard.getValue("adaptor");
+ if(context.status !== true)
+ displayMessage("Error in importTiddlers.onOpenHost: " + context.statusText);
+ var ret = adaptor.getWorkspaceList(context,wizard,config.macros.importTiddlers.onGetWorkspaceList);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetWorkspaceList);
+};
+
+config.macros.importTiddlers.onGetWorkspaceList = function(context,wizard)
+{
+ if(context.status !== true)
+ displayMessage("Error in importTiddlers.onGetWorkspaceList: " + context.statusText);
+ wizard.setValue("context",context);
+ var workspace = wizard.getValue("feedWorkspace");
+ if(!workspace && context.workspaces.length==1)
+ workspace = context.workspaces[0].title;
+ if(workspace) {
+ var ret = context.adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setValue("workspace",workspace);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
+ return;
+ }
+ wizard.addStep(config.macros.importTiddlers.step2Title,config.macros.importTiddlers.step2Html);
+ var s = wizard.getElement("selWorkspace");
+ s.onchange = config.macros.importTiddlers.onWorkspaceChange;
+ for(var t=0; t<context.workspaces.length; t++) {
+ var e = createTiddlyElement(s,"option",null,null,context.workspaces[t].title);
+ e.value = context.workspaces[t].title;
+ }
+ var workspaceList = wizard.getValue("feedWorkspaceList");
+ if(workspaceList) {
+ var list = workspaceList.parseParams("workspace",null,false,true);
+ for(var n=1; n<list.length; n++) {
+ if(context.workspaces.findByField("title",list[n].value) == null) {
+ e = createTiddlyElement(s,"option",null,null,list[n].value);
+ e.value = list[n].value;
+ }
+ }
+ }
+ if(workspace) {
+ t = wizard.getElement("txtWorkspace");
+ t.value = workspace;
+ }
+ wizard.setButtons([{caption: config.macros.importTiddlers.openLabel, tooltip: config.macros.importTiddlers.openPrompt, onClick: config.macros.importTiddlers.onChooseWorkspace}]);
+};
+
+config.macros.importTiddlers.onWorkspaceChange = function(e)
+{
+ var wizard = new Wizard(this);
+ var t = wizard.getElement("txtWorkspace");
+ t.value = this.value;
+ this.selectedIndex = 0;
+ return false;
+};
+
+config.macros.importTiddlers.onChooseWorkspace = function(e)
+{
+ var wizard = new Wizard(this);
+ var adaptor = wizard.getValue("adaptor");
+ var workspace = wizard.getElement("txtWorkspace").value;
+ wizard.setValue("workspace",workspace);
+ var context = wizard.getValue("context");
+ var ret = adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
+ return false;
+};
+
+config.macros.importTiddlers.onOpenWorkspace = function(context,wizard)
+{
+ if(context.status !== true)
+ displayMessage("Error in importTiddlers.onOpenWorkspace: " + context.statusText);
+ var adaptor = wizard.getValue("adaptor");
+ var ret = adaptor.getTiddlerList(context,wizard,config.macros.importTiddlers.onGetTiddlerList,wizard.getValue("feedTiddlerFilter"));
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetTiddlerList);
+};
+
+config.macros.importTiddlers.onGetTiddlerList = function(context,wizard)
+{
+ if(context.status !== true) {
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.errorGettingTiddlerList);
+ return;
+ }
+ // Extract data for the listview
+ var listedTiddlers = [];
+ if(context.tiddlers) {
+ for(var n=0; n<context.tiddlers.length; n++) {
+ var tiddler = context.tiddlers[n];
+ listedTiddlers.push({
+ title: tiddler.title,
+ modified: tiddler.modified,
+ modifier: tiddler.modifier,
+ text: tiddler.text ? wikifyPlainText(tiddler.text,100) : "",
+ tags: tiddler.tags,
+ size: tiddler.text ? tiddler.text.length : 0,
+ tiddler: tiddler
+ });
+ }
+ }
+ listedTiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
+ // Display the listview
+ wizard.addStep(config.macros.importTiddlers.step3Title,config.macros.importTiddlers.step3Html);
+ var markList = wizard.getElement("markList");
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ var listView = ListView.create(listWrapper,listedTiddlers,config.macros.importTiddlers.listViewTemplate);
+ wizard.setValue("listView",listView);
+ wizard.setValue("context",context);
+ var txtSaveTiddler = wizard.getElement("txtSaveTiddler");
+ txtSaveTiddler.value = config.macros.importTiddlers.generateSystemServerName(wizard);
+ wizard.setButtons([
+ {caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel},
+ {caption: config.macros.importTiddlers.importLabel, tooltip: config.macros.importTiddlers.importPrompt, onClick: config.macros.importTiddlers.doImport}
+ ]);
+};
+
+config.macros.importTiddlers.generateSystemServerName = function(wizard)
+{
+ var serverType = wizard.getValue("serverType");
+ var host = wizard.getValue("host");
+ var workspace = wizard.getValue("workspace");
+ var pattern = config.macros.importTiddlers[workspace ? "systemServerNamePattern" : "systemServerNamePatternNoWorkspace"];
+ return pattern.format([serverType,host,workspace]);
+};
+
+config.macros.importTiddlers.saveServerTiddler = function(wizard)
+{
+ var txtSaveTiddler = wizard.getElement("txtSaveTiddler").value;
+ if(store.tiddlerExists(txtSaveTiddler)) {
+ if(!confirm(config.macros.importTiddlers.confirmOverwriteSaveTiddler.format([txtSaveTiddler])))
+ return;
+ store.suspendNotifications();
+ store.removeTiddler(txtSaveTiddler);
+ store.resumeNotifications();
+ }
+ var serverType = wizard.getValue("serverType");
+ var host = wizard.getValue("host");
+ var workspace = wizard.getValue("workspace");
+ var text = config.macros.importTiddlers.serverSaveTemplate.format([serverType,host,workspace]);
+ store.saveTiddler(txtSaveTiddler,txtSaveTiddler,text,config.macros.importTiddlers.serverSaveModifier,new Date(),["systemServer"]);
+};
+
+config.macros.importTiddlers.doImport = function(e)
+{
+ var wizard = new Wizard(this);
+ if(wizard.getElement("chkSave").checked)
+ config.macros.importTiddlers.saveServerTiddler(wizard);
+ var chkSync = wizard.getElement("chkSync").checked;
+ wizard.setValue("sync",chkSync);
+ var listView = wizard.getValue("listView");
+ var rowNames = ListView.getSelectedRows(listView);
+ var adaptor = wizard.getValue("adaptor");
+ var overwrite = [];
+ var t;
+ for(t=0; t<rowNames.length; t++) {
+ if(store.tiddlerExists(rowNames[t]))
+ overwrite.push(rowNames[t]);
+ }
+ if(overwrite.length > 0) {
+ if(!confirm(config.macros.importTiddlers.confirmOverwriteText.format([overwrite.join(", ")])))
+ return false;
+ }
+ wizard.addStep(config.macros.importTiddlers.step4Title.format([rowNames.length]),config.macros.importTiddlers.step4Html);
+ for(t=0; t<rowNames.length; t++) {
+ var link = document.createElement("div");
+ createTiddlyLink(link,rowNames[t],true);
+ var place = wizard.getElement("markReport");
+ place.parentNode.insertBefore(link,place);
+ }
+ wizard.setValue("remainingImports",rowNames.length);
+ wizard.setButtons([
+ {caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}
+ ],config.macros.importTiddlers.statusDoingImport);
+ var wizardContext = wizard.getValue("context");
+ var tiddlers = wizardContext ? wizardContext.tiddlers : [];
+ for(t=0; t<rowNames.length; t++) {
+ var context = {
+ allowSynchronous:true,
+ tiddler:tiddlers[tiddlers.findByField("title",rowNames[t])]
+ };
+ adaptor.getTiddler(rowNames[t],context,wizard,config.macros.importTiddlers.onGetTiddler);
+ }
+ return false;
+};
+
+config.macros.importTiddlers.onGetTiddler = function(context,wizard)
+{
+ if(!context.status)
+ displayMessage("Error in importTiddlers.onGetTiddler: " + context.statusText);
+ var tiddler = context.tiddler;
+ store.suspendNotifications();
+ store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
+ if(!wizard.getValue("sync")) {
+ store.setValue(tiddler.title,'server',null);
+ }
+ store.resumeNotifications();
+ if(!context.isSynchronous)
+ store.notify(tiddler.title,true);
+ var remainingImports = wizard.getValue("remainingImports")-1;
+ wizard.setValue("remainingImports",remainingImports);
+ if(remainingImports == 0) {
+ if(context.isSynchronous) {
+ store.notifyAll();
+ refreshDisplay();
+ }
+ wizard.setButtons([
+ {caption: config.macros.importTiddlers.doneLabel, tooltip: config.macros.importTiddlers.donePrompt, onClick: config.macros.importTiddlers.onClose}
+ ],config.macros.importTiddlers.statusDoneImport);
+ autoSaveChanges();
+ }
+};
+
+//--
+//-- Upgrade macro
+//--
+
+config.macros.upgrade.handler = function(place)
+{
+ var w = new Wizard();
+ w.createWizard(place,this.wizardTitle);
+ w.addStep(this.step1Title,this.step1Html.format([this.source,this.source]));
+ w.setButtons([{caption: this.upgradeLabel, tooltip: this.upgradePrompt, onClick: this.onClickUpgrade}]);
+};
+
+config.macros.upgrade.onClickUpgrade = function(e)
+{
+ var me = config.macros.upgrade;
+ var w = new Wizard(this);
+ if(window.location.protocol != "file:") {
+ alert(me.errorCantUpgrade);
+ return false;
+ }
+ if(story.areAnyDirty() || store.isDirty()) {
+ alert(me.errorNotSaved);
+ return false;
+ }
+ var localPath = getLocalPath(document.location.toString());
+ var backupPath = getBackupPath(localPath,me.backupExtension);
+ w.setValue("backupPath",backupPath);
+ w.setButtons([],me.statusPreparingBackup);
+ var original = loadOriginal(localPath);
+ w.setButtons([],me.statusSavingBackup);
+ var backup = config.browser.isIE ? ieCopyFile(backupPath,localPath) : saveFile(backupPath,original);
+ if(backup != true) {
+ w.setButtons([],me.errorSavingBackup);
+ alert(me.errorSavingBackup);
+ return false;
+ }
+ w.setButtons([],me.statusLoadingCore);
+ var load = loadRemoteFile(me.source,me.onLoadCore,w);
+ if(typeof load == "string") {
+ w.setButtons([],me.errorLoadingCore);
+ alert(me.errorLoadingCore);
+ return false;
+ }
+ return false;
+};
+
+config.macros.upgrade.onLoadCore = function(status,params,responseText,url,xhr)
+{
+ var me = config.macros.upgrade;
+ var w = params;
+ var errMsg;
+ if(!status)
+ errMsg = me.errorLoadingCore;
+ var newVer = me.extractVersion(responseText);
+ if(!newVer)
+ errMsg = me.errorCoreFormat;
+ if(errMsg) {
+ w.setButtons([],errMsg);
+ alert(errMsg);
+ return;
+ }
+ var onStartUpgrade = function(e) {
+ w.setButtons([],me.statusSavingCore);
+ var localPath = getLocalPath(document.location.toString());
+ saveFile(localPath,responseText);
+ w.setButtons([],me.statusReloadingCore);
+ var backupPath = w.getValue("backupPath");
+ var newLoc = document.location.toString() + '?time=' + new Date().convertToYYYYMMDDHHMM() + '#upgrade:[[' + encodeURI(backupPath) + ']]';
+ window.setTimeout(function () {window.location = newLoc;},10);
+ };
+ var step2 = [me.step2Html_downgrade,me.step2Html_restore,me.step2Html_upgrade][compareVersions(version,newVer) + 1];
+ w.addStep(me.step2Title,step2.format([formatVersion(newVer),formatVersion(version)]));
+ w.setButtons([{caption: me.startLabel, tooltip: me.startPrompt, onClick: onStartUpgrade},{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}]);
+};
+
+config.macros.upgrade.onCancel = function(e)
+{
+ var me = config.macros.upgrade;
+ var w = new Wizard(this);
+ w.addStep(me.step3Title,me.step3Html);
+ w.setButtons([]);
+ return false;
+};
+
+config.macros.upgrade.extractVersion = function(upgradeFile)
+{
+ var re = /^var version = \{title: "([^"]+)", major: (\d+), minor: (\d+), revision: (\d+)(, beta: (\d+)){0,1}, date: new Date\("([^"]+)"\)/mg;
+ var m = re.exec(upgradeFile);
+ return m ? {title: m[1], major: m[2], minor: m[3], revision: m[4], beta: m[6], date: new Date(m[7])} : null;
+};
+
+function upgradeFrom(path)
+{
+ var importStore = new TiddlyWiki();
+ var tw = loadFile(path);
+ if(window.netscape !== undefined)
+ tw = convertUTF8ToUnicode(tw);
+ importStore.importTiddlyWiki(tw);
+ importStore.forEachTiddler(function(title,tiddler) {
+ if(!store.getTiddler(title)) {
+ store.addTiddler(tiddler);
+ }
+ });
+ refreshDisplay();
+ saveChanges(); //# To create appropriate Markup* sections
+ alert(config.messages.upgradeDone.format([formatVersion()]));
+ window.location = window.location.toString().substr(0,window.location.toString().lastIndexOf('?'));
+}
+
+//--
+//-- Sync macro
+//--
+
+// Synchronisation handlers
+config.syncers = {};
+
+// Sync state.
+var currSync = null;
+
+// sync macro
+config.macros.sync.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if(!wikifier.isStatic)
+ this.startSync(place);
+};
+
+config.macros.sync.cancelSync = function()
+{
+ currSync = null;
+};
+
+config.macros.sync.startSync = function(place)
+{
+ if(currSync)
+ config.macros.sync.cancelSync();
+ currSync = {};
+ currSync.syncList = this.getSyncableTiddlers();
+ currSync.syncTasks = this.createSyncTasks(currSync.syncList);
+ this.preProcessSyncableTiddlers(currSync.syncList);
+ var wizard = new Wizard();
+ currSync.wizard = wizard;
+ wizard.createWizard(place,this.wizardTitle);
+ wizard.addStep(this.step1Title,this.step1Html);
+ var markList = wizard.getElement("markList");
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ currSync.listView = ListView.create(listWrapper,currSync.syncList,this.listViewTemplate);
+ this.processSyncableTiddlers(currSync.syncList);
+ wizard.setButtons([{caption: this.syncLabel, tooltip: this.syncPrompt, onClick: this.doSync}]);
+};
+
+config.macros.sync.getSyncableTiddlers = function()
+{
+ var list = [];
+ store.forEachTiddler(function(title,tiddler) {
+ var syncItem = {};
+ syncItem.serverType = tiddler.getServerType();
+ syncItem.serverHost = tiddler.fields['server.host'];
+ if(syncItem.serverType && syncItem.serverHost) {
+ syncItem.serverWorkspace = tiddler.fields['server.workspace'];
+ syncItem.tiddler = tiddler;
+ syncItem.title = tiddler.title;
+ syncItem.isTouched = tiddler.isTouched();
+ syncItem.selected = syncItem.isTouched;
+ syncItem.syncStatus = config.macros.sync.syncStatusList[syncItem.isTouched ? "changedLocally" : "none"];
+ syncItem.status = syncItem.syncStatus.text;
+ list.push(syncItem);
+ }
+ });
+ list.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
+ return list;
+};
+
+config.macros.sync.preProcessSyncableTiddlers = function(syncList)
+{
+ for(var i=0; i<syncList.length; i++) {
+ var si = syncList[i];
+ si.serverUrl = si.syncTask.syncMachine.generateTiddlerInfo(si.tiddler).uri;
+ }
+};
+
+config.macros.sync.processSyncableTiddlers = function(syncList)
+{
+ for(var i=0; i<syncList.length; i++) {
+ var si = syncList[i];
+ if(si.syncStatus.display)
+ si.rowElement.style.display = si.syncStatus.display;
+ if(si.syncStatus.className)
+ si.rowElement.className = si.syncStatus.className;
+ }
+};
+
+config.macros.sync.createSyncTasks = function(syncList)
+{
+ var syncTasks = [];
+ for(var i=0; i<syncList.length; i++) {
+ var si = syncList[i];
+ var r = null;
+ for(var j=0; j<syncTasks.length; j++) {
+ var cst = syncTasks[j];
+ if(si.serverType == cst.serverType && si.serverHost == cst.serverHost && si.serverWorkspace == cst.serverWorkspace)
+ r = cst;
+ }
+ if(r) {
+ si.syncTask = r;
+ r.syncItems.push(si);
+ } else {
+ si.syncTask = this.createSyncTask(si);
+ syncTasks.push(si.syncTask);
+ }
+ }
+ return syncTasks;
+};
+
+config.macros.sync.createSyncTask = function(syncItem)
+{
+ var st = {};
+ st.serverType = syncItem.serverType;
+ st.serverHost = syncItem.serverHost;
+ st.serverWorkspace = syncItem.serverWorkspace;
+ st.syncItems = [syncItem];
+ st.syncMachine = new SyncMachine(st.serverType,{
+ start: function() {
+ return this.openHost(st.serverHost,"openWorkspace");
+ },
+ openWorkspace: function() {
+ return this.openWorkspace(st.serverWorkspace,"getTiddlerList");
+ },
+ getTiddlerList: function() {
+ return this.getTiddlerList("onGetTiddlerList");
+ },
+ onGetTiddlerList: function(context) {
+ var tiddlers = context.tiddlers;
+ for(var i=0; i<st.syncItems.length; i++) {
+ var si = st.syncItems[i];
+ var f = tiddlers.findByField("title",si.title);
+ if(f !== null) {
+ if(tiddlers[f].fields['server.page.revision'] > si.tiddler.fields['server.page.revision']) {
+ si.syncStatus = config.macros.sync.syncStatusList[si.isTouched ? 'changedBoth' : 'changedServer'];
+ }
+ } else {
+ si.syncStatus = config.macros.sync.syncStatusList.notFound;
+ }
+ config.macros.sync.updateSyncStatus(si);
+ }
+ },
+ getTiddler: function(title) {
+ return this.getTiddler(title,"onGetTiddler");
+ },
+ onGetTiddler: function(context) {
+ var tiddler = context.tiddler;
+ var syncItem = st.syncItems.findByField("title",tiddler.title);
+ if(syncItem !== null) {
+ syncItem = st.syncItems[syncItem];
+ store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
+ syncItem.syncStatus = config.macros.sync.syncStatusList.gotFromServer;
+ config.macros.sync.updateSyncStatus(syncItem);
+ }
+ },
+ putTiddler: function(tiddler) {
+ return this.putTiddler(tiddler,"onPutTiddler");
+ },
+ onPutTiddler: function(context) {
+ var title = context.title;
+ var syncItem = st.syncItems.findByField("title",title);
+ if(syncItem !== null) {
+ syncItem = st.syncItems[syncItem];
+ store.resetTiddler(title);
+ if(context.status) {
+ syncItem.syncStatus = config.macros.sync.syncStatusList.putToServer;
+ config.macros.sync.updateSyncStatus(syncItem);
+ }
+ }
+ }
+ });
+ st.syncMachine.go();
+ return st;
+};
+
+config.macros.sync.updateSyncStatus = function(syncItem)
+{
+ var e = syncItem.colElements["status"];
+ removeChildren(e);
+ createTiddlyText(e,syncItem.syncStatus.text);
+ if(syncItem.syncStatus.display)
+ syncItem.rowElement.style.display = syncItem.syncStatus.display;
+ if(syncItem.syncStatus.className)
+ syncItem.rowElement.className = syncItem.syncStatus.className;
+};
+
+config.macros.sync.doSync = function(e)
+{
+ var rowNames = ListView.getSelectedRows(currSync.listView);
+ var sl = config.macros.sync.syncStatusList;
+ for(var i=0; i<currSync.syncList.length; i++) {
+ var si = currSync.syncList[i];
+ if(rowNames.indexOf(si.title) != -1) {
+ var r = true;
+ switch(si.syncStatus) {
+ case sl.changedServer:
+ r = si.syncTask.syncMachine.go("getTiddler",si.title);
+ break;
+ case sl.notFound:
+ case sl.changedLocally:
+ case sl.changedBoth:
+ r = si.syncTask.syncMachine.go("putTiddler",si.tiddler);
+ break;
+ default:
+ break;
+ }
+ if(!r)
+ displayMessage("Error in doSync: " + r);
+ }
+ }
+ return false;
+};
+
+function SyncMachine(serverType,steps)
+{
+ this.serverType = serverType;
+ this.adaptor = new config.adaptors[serverType]();
+ this.steps = steps;
+}
+
+SyncMachine.prototype.go = function(step,context)
+{
+ var r = context ? context.status : null;
+ if(typeof r == "string") {
+ this.invokeError(r);
+ return r;
+ }
+ var h = this.steps[step ? step : "start"];
+ if(!h)
+ return null;
+ r = h.call(this,context);
+ if(typeof r == "string")
+ this.invokeError(r);
+ return r;
+};
+
+SyncMachine.prototype.invokeError = function(message)
+{
+ if(this.steps.error)
+ this.steps.error(message);
+};
+
+SyncMachine.prototype.openHost = function(host,nextStep)
+{
+ var me = this;
+ return me.adaptor.openHost(host,null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.getWorkspaceList = function(nextStep)
+{
+ var me = this;
+ return me.adaptor.getWorkspaceList(null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.openWorkspace = function(workspace,nextStep)
+{
+ var me = this;
+ return me.adaptor.openWorkspace(workspace,null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.getTiddlerList = function(nextStep)
+{
+ var me = this;
+ return me.adaptor.getTiddlerList(null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.generateTiddlerInfo = function(tiddler)
+{
+ return this.adaptor.generateTiddlerInfo(tiddler);
+};
+
+SyncMachine.prototype.getTiddler = function(title,nextStep)
+{
+ var me = this;
+ return me.adaptor.getTiddler(title,null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.putTiddler = function(tiddler,nextStep)
+{
+ var me = this;
+ if(me.adaptor.putTiddler)
+ return me.adaptor.putTiddler(tiddler,null,null,function(context) {me.go(nextStep,context);});
+ return false;
+};
+
+//--
+//-- Manager UI for groups of tiddlers
+//--
+
+config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString)
+{
+ var wizard = new Wizard();
+ wizard.createWizard(place,this.wizardTitle);
+ wizard.addStep(this.step1Title,this.step1Html);
+ var markList = wizard.getElement("markList");
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ listWrapper.setAttribute("refresh","macro");
+ listWrapper.setAttribute("macroName","plugins");
+ listWrapper.setAttribute("params",paramString);
+ this.refresh(listWrapper,paramString);
+};
+
+config.macros.plugins.refresh = function(listWrapper,params)
+{
+ var wizard = new Wizard(listWrapper);
+ var selectedRows = [];
+ ListView.forEachSelector(listWrapper,function(e,rowName) {
+ if(e.checked)
+ selectedRows.push(e.getAttribute("rowName"));
+ });
+ removeChildren(listWrapper);
+ params = params.parseParams("anon");
+ var plugins = installedPlugins.slice(0);
+ var t,tiddler,p;
+ var configTiddlers = store.getTaggedTiddlers("systemConfig");
+ for(t=0; t<configTiddlers.length; t++) {
+ tiddler = configTiddlers[t];
+ if(plugins.findByField("title",tiddler.title) == null) {
+ p = getPluginInfo(tiddler);
+ p.executed = false;
+ p.log.splice(0,0,this.skippedText);
+ plugins.push(p);
+ }
+ }
+ for(t=0; t<plugins.length; t++) {
+ p = plugins[t];
+ p.size = p.tiddler.text ? p.tiddler.text.length : 0;
+ p.forced = p.tiddler.isTagged("systemConfigForce");
+ p.disabled = p.tiddler.isTagged("systemConfigDisable");
+ p.Selected = selectedRows.indexOf(plugins[t].title) != -1;
+ p.desc = store.getTiddlerSlice(p.tiddler.title,"Description");
+ }
+ if(plugins.length == 0) {
+ createTiddlyElement(listWrapper,"em",null,null,this.noPluginText);
+ wizard.setButtons([]);
+ } else {
+ var listView = ListView.create(listWrapper,plugins,this.listViewTemplate,this.onSelectCommand);
+ wizard.setValue("listView",listView);
+ wizard.setButtons([
+ {caption: config.macros.plugins.removeLabel, tooltip: config.macros.plugins.removePrompt, onClick: config.macros.plugins.doRemoveTag},
+ {caption: config.macros.plugins.deleteLabel, tooltip: config.macros.plugins.deletePrompt, onClick: config.macros.plugins.doDelete}
+ ]);
+ }
+};
+
+config.macros.plugins.doRemoveTag = function(e)
+{
+ var wizard = new Wizard(this);
+ var listView = wizard.getValue("listView");
+ var rowNames = ListView.getSelectedRows(listView);
+ if(rowNames.length == 0) {
+ alert(config.messages.nothingSelected);
+ } else {
+ for(var t=0; t<rowNames.length; t++)
+ store.setTiddlerTag(rowNames[t],false,"systemConfig");
+ }
+};
+
+config.macros.plugins.doDelete = function(e)
+{
+ var wizard = new Wizard(this);
+ var listView = wizard.getValue("listView");
+ var rowNames = ListView.getSelectedRows(listView);
+ if(rowNames.length == 0) {
+ alert(config.messages.nothingSelected);
+ } else {
+ if(confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")]))) {
+ for(var t=0; t<rowNames.length; t++) {
+ store.removeTiddler(rowNames[t]);
+ story.closeTiddler(rowNames[t],true);
+ }
+ }
+ }
+};
+
+//--
+//-- Message area
+//--
+
+function getMessageDiv()
+{
+ var msgArea = document.getElementById("messageArea");
+ if(!msgArea)
+ return null;
+ if(!msgArea.hasChildNodes())
+ createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"),
+ config.messages.messageClose.text,
+ config.messages.messageClose.tooltip,
+ clearMessage);
+ msgArea.style.display = "block";
+ return createTiddlyElement(msgArea,"div");
+}
+
+function displayMessage(text,linkText)
+{
+ var e = getMessageDiv();
+ if(!e) {
+ alert(text);
+ return;
+ }
+ if(linkText) {
+ var link = createTiddlyElement(e,"a",null,null,text);
+ link.href = linkText;
+ link.target = "_blank";
+ } else {
+ e.appendChild(document.createTextNode(text));
+ }
+}
+
+function clearMessage()
+{
+ var msgArea = document.getElementById("messageArea");
+ if(msgArea) {
+ removeChildren(msgArea);
+ msgArea.style.display = "none";
+ }
+ return false;
+}
+
+//--
+//-- Refresh mechanism
+//--
+
+config.notifyTiddlers = [
+ {name: "StyleSheetLayout", notify: refreshStyles},
+ {name: "StyleSheetColors", notify: refreshStyles},
+ {name: "StyleSheet", notify: refreshStyles},
+ {name: "StyleSheetPrint", notify: refreshStyles},
+ {name: "PageTemplate", notify: refreshPageTemplate},
+ {name: "SiteTitle", notify: refreshPageTitle},
+ {name: "SiteSubtitle", notify: refreshPageTitle},
+ {name: "ColorPalette", notify: refreshColorPalette},
+ {name: null, notify: refreshDisplay}
+];
+
+config.refreshers = {
+ link: function(e,changeList)
+ {
+ var title = e.getAttribute("tiddlyLink");
+ refreshTiddlyLink(e,title);
+ return true;
+ },
+
+ tiddler: function(e,changeList)
+ {
+ var title = e.getAttribute("tiddler");
+ var template = e.getAttribute("template");
+ if(changeList && changeList.indexOf(title) != -1 && !story.isDirty(title))
+ story.refreshTiddler(title,template,true);
+ else
+ refreshElements(e,changeList);
+ return true;
+ },
+
+ content: function(e,changeList)
+ {
+ var title = e.getAttribute("tiddler");
+ var force = e.getAttribute("force");
+ if(force != null || changeList == null || changeList.indexOf(title) != -1) {
+ removeChildren(e);
+ wikify(store.getTiddlerText(title,""),e,null,store.fetchTiddler(title));
+ return true;
+ } else
+ return false;
+ },
+
+ macro: function(e,changeList)
+ {
+ var macro = e.getAttribute("macroName");
+ var params = e.getAttribute("params");
+ if(macro)
+ macro = config.macros[macro];
+ if(macro && macro.refresh)
+ macro.refresh(e,params);
+ return true;
+ }
+};
+
+config.refresherData = {
+ styleSheet: "StyleSheet",
+ defaultStyleSheet: "StyleSheet",
+ pageTemplate: "PageTemplate",
+ defaultPageTemplate: "PageTemplate",
+ colorPalette: "ColorPalette",
+ defaultColorPalette: "ColorPalette"
+};
+
+function refreshElements(root,changeList)
+{
+ var nodes = root.childNodes;
+ for(var c=0; c<nodes.length; c++) {
+ var e = nodes[c], type = null;
+ if(e.getAttribute && (e.tagName ? e.tagName != "IFRAME" : true))
+ type = e.getAttribute("refresh");
+ var refresher = config.refreshers[type];
+ var refreshed = false;
+ if(refresher != undefined)
+ refreshed = refresher(e,changeList);
+ if(e.hasChildNodes() && !refreshed)
+ refreshElements(e,changeList);
+ }
+}
+
+function applyHtmlMacros(root,tiddler)
+{
+ var e = root.firstChild;
+ while(e) {
+ var nextChild = e.nextSibling;
+ if(e.getAttribute) {
+ var macro = e.getAttribute("macro");
+ if(macro) {
+ e.removeAttribute("macro");
+ var params = "";
+ var p = macro.indexOf(" ");
+ if(p != -1) {
+ params = macro.substr(p+1);
+ macro = macro.substr(0,p);
+ }
+ invokeMacro(e,macro,params,null,tiddler);
+ }
+ }
+ if(e.hasChildNodes())
+ applyHtmlMacros(e,tiddler);
+ e = nextChild;
+ }
+}
+
+function refreshPageTemplate(title)
+{
+ var stash = createTiddlyElement(document.body,"div");
+ stash.style.display = "none";
+ var display = story.getContainer();
+ var nodes,t;
+ if(display) {
+ nodes = display.childNodes;
+ for(t=nodes.length-1; t>=0; t--)
+ stash.appendChild(nodes[t]);
+ }
+ var wrapper = document.getElementById("contentWrapper");
+
+ var isAvailable = function(title) {
+ var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
+ if(s!=-1)
+ title = title.substr(0,s);
+ return store.tiddlerExists(title) || store.isShadowTiddler(title);
+ };
+ if(!title || !isAvailable(title))
+ title = config.refresherData.pageTemplate;
+ if(!isAvailable(title))
+ title = config.refresherData.defaultPageTemplate; //# this one is always avaialable
+ wrapper.innerHTML = store.getRecursiveTiddlerText(title,null,10);
+ applyHtmlMacros(wrapper);
+ refreshElements(wrapper);
+ display = story.getContainer();
+ removeChildren(display);
+ if(!display)
+ display = createTiddlyElement(wrapper,"div",story.containerId());
+ nodes = stash.childNodes;
+ for(t=nodes.length-1; t>=0; t--)
+ display.appendChild(nodes[t]);
+ removeNode(stash);
+}
+
+function refreshDisplay(hint)
+{
+ if(typeof hint == "string")
+ hint = [hint];
+ var e = document.getElementById("contentWrapper");
+ refreshElements(e,hint);
+ if(backstage.isPanelVisible()) {
+ e = document.getElementById("backstage");
+ refreshElements(e,hint);
+ }
+}
+
+function refreshPageTitle()
+{
+ document.title = getPageTitle();
+}
+
+function getPageTitle()
+{
+ var st = wikifyPlain("SiteTitle");
+ var ss = wikifyPlain("SiteSubtitle");
+ return st + ((st == "" || ss == "") ? "" : " - ") + ss;
+}
+
+function refreshStyles(title,doc)
+{
+ setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title,doc || document);
+}
+
+function refreshColorPalette(title)
+{
+ if(!startingUp)
+ refreshAll();
+}
+
+function refreshAll()
+{
+ refreshPageTemplate();
+ refreshDisplay();
+ refreshStyles("StyleSheetLayout");
+ refreshStyles("StyleSheetColors");
+ refreshStyles(config.refresherData.styleSheet);
+ refreshStyles("StyleSheetPrint");
+}
+
+//--
+//-- Options stuff
+//--
+
+config.optionHandlers = {
+ 'txt': {
+ get: function(name) {return encodeCookie(config.options[name].toString());},
+ set: function(name,value) {config.options[name] = decodeCookie(value);}
+ },
+ 'chk': {
+ get: function(name) {return config.options[name] ? "true" : "false";},
+ set: function(name,value) {config.options[name] = value == "true";}
+ }
+};
+
+function loadOptionsCookie()
+{
+ if(safeMode)
+ return;
+ var cookies = document.cookie.split(";");
+ for(var c=0; c<cookies.length; c++) {
+ var p = cookies[c].indexOf("=");
+ if(p != -1) {
+ var name = cookies[c].substr(0,p).trim();
+ var value = cookies[c].substr(p+1).trim();
+ var optType = name.substr(0,3);
+ if(config.optionHandlers[optType] && config.optionHandlers[optType].set)
+ config.optionHandlers[optType].set(name,value);
+ }
+ }
+}
+
+function saveOptionCookie(name)
+{
+ if(safeMode)
+ return;
+ var c = name + "=";
+ var optType = name.substr(0,3);
+ if(config.optionHandlers[optType] && config.optionHandlers[optType].get)
+ c += config.optionHandlers[optType].get(name);
+ c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/";
+ document.cookie = c;
+}
+
+function removeCookie(name)
+{
+ document.cookie = name + "=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;";
+}
+
+function encodeCookie(s)
+{
+ return escape(convertUnicodeToHtmlEntities(s));
+}
+
+function decodeCookie(s)
+{
+ s = unescape(s);
+ var re = /&#[0-9]{1,5};/g;
+ return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));});
+}
+
+
+config.macros.option.genericCreate = function(place,type,opt,className,desc)
+{
+ var typeInfo = config.macros.option.types[type];
+ var c = document.createElement(typeInfo.elementType);
+ if(typeInfo.typeValue)
+ c.setAttribute("type",typeInfo.typeValue);
+ c[typeInfo.eventName] = typeInfo.onChange;
+ c.setAttribute("option",opt);
+ c.className = className || typeInfo.className;
+ if(config.optionsDesc[opt])
+ c.setAttribute("title",config.optionsDesc[opt]);
+ place.appendChild(c);
+ if(desc != "no")
+ createTiddlyText(place,config.optionsDesc[opt] || opt);
+ c[typeInfo.valueField] = config.options[opt];
+ return c;
+};
+
+config.macros.option.genericOnChange = function(e)
+{
+ var opt = this.getAttribute("option");
+ if(opt) {
+ var optType = opt.substr(0,3);
+ var handler = config.macros.option.types[optType];
+ if(handler.elementType && handler.valueField)
+ config.macros.option.propagateOption(opt,handler.valueField,this[handler.valueField],handler.elementType,this);
+ }
+ return true;
+};
+
+config.macros.option.types = {
+ 'txt': {
+ elementType: "input",
+ valueField: "value",
+ eventName: "onchange",
+ className: "txtOptionInput",
+ create: config.macros.option.genericCreate,
+ onChange: config.macros.option.genericOnChange
+ },
+ 'chk': {
+ elementType: "input",
+ valueField: "checked",
+ eventName: "onclick",
+ className: "chkOptionInput",
+ typeValue: "checkbox",
+ create: config.macros.option.genericCreate,
+ onChange: config.macros.option.genericOnChange
+ }
+};
+
+config.macros.option.propagateOption = function(opt,valueField,value,elementType,elem)
+{
+ config.options[opt] = value;
+ saveOptionCookie(opt);
+ var nodes = document.getElementsByTagName(elementType);
+ for(var t=0; t<nodes.length; t++) {
+ var optNode = nodes[t].getAttribute("option");
+ if(opt == optNode && nodes[t]!=elem)
+ nodes[t][valueField] = value;
+ }
+};
+
+config.macros.option.handler = function(place,macroName,params,wikifier,paramString)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var opt = (params[1] && params[1].name == "anon") ? params[1].value : getParam(params,"name",null);
+ var className = (params[2] && params[2].name == "anon") ? params[2].value : getParam(params,"class",null);
+ var desc = getParam(params,"desc","no");
+ var type = opt.substr(0,3);
+ var h = config.macros.option.types[type];
+ if(h && h.create)
+ h.create(place,type,opt,className,desc);
+};
+
+config.macros.options.handler = function(place,macroName,params,wikifier,paramString)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var showUnknown = getParam(params,"showUnknown","no");
+ var wizard = new Wizard();
+ wizard.createWizard(place,this.wizardTitle);
+ wizard.addStep(this.step1Title,this.step1Html);
+ var markList = wizard.getElement("markList");
+ var chkUnknown = wizard.getElement("chkUnknown");
+ chkUnknown.checked = showUnknown == "yes";
+ chkUnknown.onchange = this.onChangeUnknown;
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ wizard.setValue("listWrapper",listWrapper);
+ this.refreshOptions(listWrapper,showUnknown == "yes");
+};
+
+config.macros.options.refreshOptions = function(listWrapper,showUnknown)
+{
+ var opts = [];
+ for(var n in config.options) {
+ var opt = {};
+ opt.option = "";
+ opt.name = n;
+ opt.lowlight = !config.optionsDesc[n];
+ opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
+ if(!opt.lowlight || showUnknown)
+ opts.push(opt);
+ }
+ opts.sort(function(a,b) {return a.name.substr(3) < b.name.substr(3) ? -1 : (a.name.substr(3) == b.name.substr(3) ? 0 : +1);});
+ var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
+ for(n=0; n<opts.length; n++) {
+ var type = opts[n].name.substr(0,3);
+ var h = config.macros.option.types[type];
+ if(h && h.create) {
+ h.create(opts[n].colElements['option'],type,opts[n].name,null,"no");
+ }
+ }
+};
+
+config.macros.options.onChangeUnknown = function(e)
+{
+ var wizard = new Wizard(this);
+ var listWrapper = wizard.getValue("listWrapper");
+ removeChildren(listWrapper);
+ config.macros.options.refreshOptions(listWrapper,this.checked);
+ return false;
+};
+
+//--
+//-- Saving
+//--
+
+var saveUsingSafari = false;
+
+var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it
+var endSaveArea = '</d' + 'iv>';
+
+// If there are unsaved changes, force the user to confirm before exitting
+function confirmExit()
+{
+ hadConfirmExit = true;
+ if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty()))
+ return config.messages.confirmExit;
+}
+
+// Give the user a chance to save changes before exitting
+function checkUnsavedChanges()
+{
+ if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false) {
+ if(confirm(config.messages.unsavedChangesWarning))
+ saveChanges();
+ }
+}
+
+function updateLanguageAttribute(s)
+{
+ if(config.locale) {
+ var mRE = /(<html(?:.*?)?)(?: xml:lang\="([a-z]+)")?(?: lang\="([a-z]+)")?>/;
+ var m = mRE.exec(s);
+ if(m) {
+ var t = m[1];
+ if(m[2])
+ t += ' xml:lang="' + config.locale + '"';
+ if(m[3])
+ t += ' lang="' + config.locale + '"';
+ t += ">";
+ s = s.substr(0,m.index) + t + s.substr(m.index+m[0].length);
+ }
+ }
+ return s;
+}
+
+function updateMarkupBlock(s,blockName,tiddlerName)
+{
+ return s.replaceChunk(
+ "<!--%0-START-->".format([blockName]),
+ "<!--%0-END-->".format([blockName]),
+ "\n" + convertUnicodeToFileFormat(store.getRecursiveTiddlerText(tiddlerName,"")) + "\n");
+}
+
+function updateOriginal(original,posDiv,localPath)
+{
+ if(!posDiv)
+ posDiv = locateStoreArea(original);
+ if(!posDiv) {
+ alert(config.messages.invalidFileError.format([localPath]));
+ return null;
+ }
+ var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
+ convertUnicodeToFileFormat(store.allTiddlersAsHtml()) + "\n" +
+ original.substr(posDiv[1]);
+ var newSiteTitle = convertUnicodeToFileFormat(getPageTitle()).htmlEncode();
+ revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
+ revised = updateLanguageAttribute(revised);
+ revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
+ revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
+ revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
+ revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
+ return revised;
+}
+
+function locateStoreArea(original)
+{
+ // Locate the storeArea div's
+ var posOpeningDiv = original.indexOf(startSaveArea);
+ var limitClosingDiv = original.indexOf("<"+"!--POST-STOREAREA--"+">");
+ if(limitClosingDiv == -1)
+ limitClosingDiv = original.indexOf("<"+"!--POST-BODY-START--"+">");
+ var posClosingDiv = original.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? original.length : limitClosingDiv);
+ return (posOpeningDiv != -1 && posClosingDiv != -1) ? [posOpeningDiv,posClosingDiv] : null;
+}
+
+function autoSaveChanges(onlyIfDirty,tiddlers)
+{
+ if(config.options.chkAutoSave)
+ saveChanges(onlyIfDirty,tiddlers);
+}
+
+function loadOriginal(localPath)
+{
+ return loadFile(localPath);
+}
+
+// Save this tiddlywiki with the pending changes
+function saveChanges(onlyIfDirty,tiddlers)
+{
+ if(onlyIfDirty && !store.isDirty())
+ return;
+ clearMessage();
+ var t0 = new Date();
+ var originalPath = document.location.toString();
+ if(originalPath.substr(0,5) != "file:") {
+ alert(config.messages.notFileUrlError);
+ if(store.tiddlerExists(config.messages.saveInstructions))
+ story.displayTiddler(null,config.messages.saveInstructions);
+ return;
+ }
+ var localPath = getLocalPath(originalPath);
+ var original = loadOriginal(localPath);
+ if(original == null) {
+ alert(config.messages.cantSaveError);
+ if(store.tiddlerExists(config.messages.saveInstructions))
+ story.displayTiddler(null,config.messages.saveInstructions);
+ return;
+ }
+ var posDiv = locateStoreArea(original);
+ if(!posDiv) {
+ alert(config.messages.invalidFileError.format([localPath]));
+ return;
+ }
+ saveMain(localPath,original,posDiv);
+ if(config.options.chkSaveBackups)
+ saveBackup(localPath,original);
+ if(config.options.chkSaveEmptyTemplate)
+ saveEmpty(localPath,original,posDiv);
+ if(config.options.chkGenerateAnRssFeed && saveRss instanceof Function)
+ saveRss(localPath);
+ if(config.options.chkDisplayInstrumentation)
+ displayMessage("saveChanges " + (new Date()-t0) + " ms");
+}
+
+function saveMain(localPath,original,posDiv)
+{
+ var save;
+ try {
+ var revised = updateOriginal(original,posDiv,localPath);
+ save = saveFile(localPath,revised);
+ } catch (ex) {
+ showException(ex);
+ }
+ if(save) {
+ displayMessage(config.messages.mainSaved,"file://" + localPath);
+ store.setDirty(false);
+ } else {
+ alert(config.messages.mainFailed);
+ }
+}
+
+function saveBackup(localPath,original)
+{
+ var backupPath = getBackupPath(localPath);
+ var backup = copyFile(backupPath,localPath);
+ if(!backup)
+ backup = saveFile(backupPath,original);
+ if(backup)
+ displayMessage(config.messages.backupSaved,"file://" + backupPath);
+ else
+ alert(config.messages.backupFailed);
+ displayMessage(config.messages.backupFailed,"failed" + backup + "file://" + backupPath);
+}
+
+function saveEmpty(localPath,original,posDiv)
+{
+ var emptyPath,p;
+ if((p = localPath.lastIndexOf("/")) != -1)
+ emptyPath = localPath.substr(0,p) + "/";
+ else if((p = localPath.lastIndexOf("\\")) != -1)
+ emptyPath = localPath.substr(0,p) + "\\";
+ else
+ emptyPath = localPath + ".";
+ emptyPath += "empty.html";
+ var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]);
+ var emptySave = saveFile(emptyPath,empty);
+ if(emptySave)
+ displayMessage(config.messages.emptySaved,"file://" + emptyPath);
+ else
+ alert(config.messages.emptyFailed);
+}
+
+function getLocalPath(origPath)
+{
+ var originalPath = convertUriToUTF8(origPath,config.options.txtFileSystemCharSet);
+ // Remove any location or query part of the URL
+ var argPos = originalPath.indexOf("?");
+ if(argPos != -1)
+ originalPath = originalPath.substr(0,argPos);
+ var hashPos = originalPath.indexOf("#");
+ if(hashPos != -1)
+ originalPath = originalPath.substr(0,hashPos);
+ // Convert file://localhost/ to file:///
+ if(originalPath.indexOf("file://localhost/") == 0)
+ originalPath = "file://" + originalPath.substr(16);
+ // Convert to a native file format
+ var localPath;
+ if(originalPath.charAt(9) == ":") // pc local file
+ localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
+ else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
+ localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
+ else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
+ localPath = unescape(originalPath.substr(7));
+ else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
+ localPath = unescape(originalPath.substr(5));
+ else // pc network file
+ localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
+ return localPath;
+}
+
+function getBackupPath(localPath,title,extension)
+{
+ var slash = "\\";
+ var dirPathPos = localPath.lastIndexOf("\\");
+ if(dirPathPos == -1) {
+ dirPathPos = localPath.lastIndexOf("/");
+ slash = "/";
+ }
+ var backupFolder = config.options.txtBackupFolder;
+ if(!backupFolder || backupFolder == "")
+ backupFolder = ".";
+ var backupPath = localPath.substr(0,dirPathPos) + slash + backupFolder + localPath.substr(dirPathPos);
+ backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + ".";
+ if(title)
+ backupPath += title.replace(/[\\\/\*\?\":<> ]/g,"_") + ".";
+ backupPath += (new Date()).convertToYYYYMMDDHHMMSSMMM() + "." + (extension || "html");
+ return backupPath;
+}
+
+//--
+//-- RSS Saving
+//--
+
+function saveRss(localPath)
+{
+ var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
+ if(saveFile(rssPath,convertUnicodeToFileFormat(generateRss())))
+ displayMessage(config.messages.rssSaved,"file://" + rssPath);
+ else
+ alert(config.messages.rssFailed);
+}
+
+tiddlerToRssItem = function(tiddler,uri)
+{
+ var s = "<title" + ">" + tiddler.title.htmlEncode() + "</title" + ">\n";
+ s += "<description>" + wikifyStatic(tiddler.text,null,tiddler).htmlEncode() + "</description>\n";
+ for(var i=0; i<tiddler.tags.length; i++)
+ s += "<category>" + tiddler.tags[i] + "</category>\n";
+ s += "<link>" + uri + "#" + encodeURIComponent(String.encodeTiddlyLink(tiddler.title)) + "</link>\n";
+ s +="<pubDate>" + tiddler.modified.toGMTString() + "</pubDate>\n";
+ return s;
+};
+
+function generateRss()
+{
+ var s = [];
+ var d = new Date();
+ var u = store.getTiddlerText("SiteUrl");
+ // Assemble the header
+ s.push("<" + "?xml version=\"1.0\"?" + ">");
+ s.push("<rss version=\"2.0\">");
+ s.push("<channel>");
+ s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">");
+ if(u)
+ s.push("<link>" + u.htmlEncode() + "</link>");
+ s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");
+ s.push("<language>" + config.locale + "</language>");
+ s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
+ s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
+ s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
+ s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
+ s.push("<generator>TiddlyWiki " + formatVersion() + "</generator>");
+ // The body
+ var tiddlers = store.getTiddlers("modified","excludeLists");
+ var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
+ for(var i=tiddlers.length-1; i>=n; i--) {
+ s.push("<item>\n" + tiddlerToRssItem(tiddlers[i],u) + "\n</item>");
+ }
+ // And footer
+ s.push("</channel>");
+ s.push("</rss>");
+ // Save it all
+ return s.join("\n");
+}
+
+//--
+//-- Filesystem code
+//--
+
+function convertUTF8ToUnicode(u)
+{
+ return config.browser.isOpera || !window.netscape ? manualConvertUTF8ToUnicode(u) : mozConvertUTF8ToUnicode(u);
+}
+
+function manualConvertUTF8ToUnicode(utf)
+{
+ var uni = utf;
+ var src = 0;
+ var dst = 0;
+ var b1, b2, b3;
+ var c;
+ while(src < utf.length) {
+ b1 = utf.charCodeAt(src++);
+ if(b1 < 0x80) {
+ dst++;
+ } else if(b1 < 0xE0) {
+ b2 = utf.charCodeAt(src++);
+ c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F));
+ uni = uni.substring(0,dst++).concat(c,utf.substr(src));
+ } else {
+ b2 = utf.charCodeAt(src++);
+ b3 = utf.charCodeAt(src++);
+ c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F));
+ uni = uni.substring(0,dst++).concat(c,utf.substr(src));
+ }
+ }
+ return uni;
+}
+
+function mozConvertUTF8ToUnicode(u)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+ converter.charset = "UTF-8";
+ } catch(ex) {
+ return manualConvertUTF8ToUnicode(u);
+ } // fallback
+ var s = converter.ConvertToUnicode(u);
+ var fin = converter.Finish();
+ return fin.length > 0 ? s+fin : s;
+}
+
+function convertUnicodeToFileFormat(s)
+{
+ return config.browser.isOpera || !window.netscape ? convertUnicodeToHtmlEntities(s) : mozConvertUnicodeToUTF8(s);
+}
+
+function convertUnicodeToHtmlEntities(s)
+{
+ var re = /[^\u0000-\u007F]/g;
+ return s.replace(re,function($0) {return "&#" + $0.charCodeAt(0).toString() + ";";});
+}
+
+function convertUnicodeToUTF8(s)
+{
+// return convertUnicodeToFileFormat to allow plugin migration
+ return convertUnicodeToFileFormat(s);
+}
+
+function manualConvertUnicodeToUTF8(s)
+{
+ return unescape(encodeURIComponent(s));
+}
+
+function mozConvertUnicodeToUTF8(s)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+ converter.charset = "UTF-8";
+ } catch(ex) {
+ return manualConvertUnicodeToUTF8(s);
+ } // fallback
+ var u = converter.ConvertFromUnicode(s);
+ var fin = converter.Finish();
+ return fin.length > 0 ? u + fin : u;
+}
+
+function convertUriToUTF8(uri,charSet)
+{
+ if(window.netscape == undefined || charSet == undefined || charSet == "")
+ return uri;
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService);
+ } catch(ex) {
+ return uri;
+ }
+ return converter.convertURISpecToUTF8(uri,charSet);
+}
+
+function copyFile(dest,source)
+{
+ return config.browser.isIE ? ieCopyFile(dest,source) : false;
+}
+
+function saveFile(fileUrl,content)
+{
+ var r = mozillaSaveFile(fileUrl,content);
+ if(!r)
+ r = ieSaveFile(fileUrl,content);
+ if(!r)
+ r = javaSaveFile(fileUrl,content);
+ return r;
+}
+
+function loadFile(fileUrl)
+{
+ var r = mozillaLoadFile(fileUrl);
+ if((r == null) || (r == false))
+ r = ieLoadFile(fileUrl);
+ if((r == null) || (r == false))
+ r = javaLoadFile(fileUrl);
+ return r;
+}
+
+function ieCreatePath(path)
+{
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ } catch(ex) {
+ return null;
+ }
+
+ var pos = path.lastIndexOf("\\");
+ if(pos==-1)
+ pos = path.lastIndexOf("/");
+ if(pos!=-1)
+ path = path.substring(0,pos+1);
+
+ var scan = [path];
+ var parent = fso.GetParentFolderName(path);
+ while(parent && !fso.FolderExists(parent)) {
+ scan.push(parent);
+ parent = fso.GetParentFolderName(parent);
+ }
+
+ for(i=scan.length-1;i>=0;i--) {
+ if(!fso.FolderExists(scan[i])) {
+ fso.CreateFolder(scan[i]);
+ }
+ }
+ return true;
+}
+
+// Returns null if it can't do it, false if there's an error, true if it saved OK
+function ieSaveFile(filePath,content)
+{
+ ieCreatePath(filePath);
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ } catch(ex) {
+ return null;
+ }
+ var file = fso.OpenTextFile(filePath,2,-1,0);
+ file.Write(content);
+ file.Close();
+ return true;
+}
+
+// Returns null if it can't do it, false if there's an error, or a string of the content if successful
+function ieLoadFile(filePath)
+{
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ var file = fso.OpenTextFile(filePath,1);
+ var content = file.ReadAll();
+ file.Close();
+ } catch(ex) {
+ return null;
+ }
+ return content;
+}
+
+function ieCopyFile(dest,source)
+{
+ ieCreatePath(dest);
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ fso.GetFile(source).Copy(dest);
+ } catch(ex) {
+ return false;
+ }
+ return true;
+}
+
+// Returns null if it can't do it, false if there's an error, true if it saved OK
+function mozillaSaveFile(filePath,content)
+{
+ if(window.Components) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath(filePath);
+ if(!file.exists())
+ file.create(0,0664);
+ var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
+ out.init(file,0x20|0x02,00004,null);
+ out.write(content,content.length);
+ out.flush();
+ out.close();
+ return true;
+ } catch(ex) {
+ return false;
+ }
+ }
+ return null;
+}
+
+// Returns null if it can't do it, false if there's an error, or a string of the content if successful
+function mozillaLoadFile(filePath)
+{
+ if(window.Components) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath(filePath);
+ if(!file.exists())
+ return null;
+ var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
+ inputStream.init(file,0x01,00004,null);
+ var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
+ sInputStream.init(inputStream);
+ var contents = sInputStream.read(sInputStream.available());
+ sInputStream.close();
+ inputStream.close();
+ return contents;
+ } catch(ex) {
+ return false;
+ }
+ }
+ return null;
+}
+
+function javaUrlToFilename(url)
+{
+ var f = "//localhost";
+ if(url.indexOf(f) == 0)
+ return url.substring(f.length);
+ var i = url.indexOf(":");
+ return i > 0 ? url.substring(i-1) : url;
+}
+
+function javaSaveFile(filePath,content)
+{
+ try {
+ if(document.applets["TiddlySaver"])
+ return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content);
+ } catch(ex) {
+ }
+ try {
+ var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath)));
+ s.print(content);
+ s.close();
+ } catch(ex) {
+ return null;
+ }
+ return true;
+}
+
+function javaLoadFile(filePath)
+{
+ try {
+ if(document.applets["TiddlySaver"])
+ return String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8"));
+ } catch(ex) {
+ }
+ var content = [];
+ try {
+ var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath)));
+ var line;
+ while((line = r.readLine()) != null)
+ content.push(new String(line));
+ r.close();
+ } catch(ex) {
+ return null;
+ }
+ return content.join("\n");
+}
+
+//--
+//-- Server adaptor base class
+//--
+
+function AdaptorBase()
+{
+ this.host = null;
+ this.store = null;
+ return this;
+}
+
+AdaptorBase.prototype.close = function()
+{
+ return true;
+};
+
+AdaptorBase.prototype.fullHostName = function(host)
+{
+ if(!host)
+ return '';
+ host = host.trim();
+ if(!host.match(/:\/\//))
+ host = 'http://' + host;
+ if(host.substr(host.length-1) == '/')
+ host = host.substr(0,host.length-1);
+ return host;
+};
+
+AdaptorBase.minHostName = function(host)
+{
+ return host ? host.replace(/^http:\/\//,'').replace(/\/$/,'') : '';
+};
+
+AdaptorBase.prototype.setContext = function(context,userParams,callback)
+{
+ if(!context) context = {};
+ context.userParams = userParams;
+ if(callback) context.callback = callback;
+ context.adaptor = this;
+ if(!context.host)
+ context.host = this.host;
+ context.host = this.fullHostName(context.host);
+ if(!context.workspace)
+ context.workspace = this.workspace;
+ return context;
+};
+
+// Open the specified host
+AdaptorBase.prototype.openHost = function(host,context,userParams,callback)
+{
+ this.host = host;
+ context = this.setContext(context,userParams,callback);
+ context.status = true;
+ if(callback)
+ window.setTimeout(function() {context.callback(context,userParams);},10);
+ return true;
+};
+
+// Open the specified workspace
+AdaptorBase.prototype.openWorkspace = function(workspace,context,userParams,callback)
+{
+ this.workspace = workspace;
+ context = this.setContext(context,userParams,callback);
+ context.status = true;
+ if(callback)
+ window.setTimeout(function() {callback(context,userParams);},10);
+ return true;
+};
+
+//--
+//-- Server adaptor for talking to static TiddlyWiki files
+//--
+
+function FileAdaptor()
+{
+}
+
+FileAdaptor.prototype = new AdaptorBase();
+
+FileAdaptor.serverType = 'file';
+FileAdaptor.serverLabel = 'TiddlyWiki';
+
+FileAdaptor.loadTiddlyWikiCallback = function(status,context,responseText,url,xhr)
+{
+ context.status = status;
+ if(!status) {
+ context.statusText = "Error reading file";
+ } else {
+ context.adaptor.store = new TiddlyWiki();
+ if(!context.adaptor.store.importTiddlyWiki(responseText)) {
+ context.statusText = config.messages.invalidFileError.format([url]);
+ context.status = false;
+ }
+ }
+ context.complete(context,context.userParams);
+};
+
+// Get the list of workspaces on a given server
+FileAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
+{
+ context = this.setContext(context,userParams,callback);
+ context.workspaces = [{title:"(default)"}];
+ context.status = true;
+ if(callback)
+ window.setTimeout(function() {callback(context,userParams);},10);
+ return true;
+};
+
+// Gets the list of tiddlers within a given workspace
+FileAdaptor.prototype.getTiddlerList = function(context,userParams,callback,filter)
+{
+ context = this.setContext(context,userParams,callback);
+ if(!context.filter)
+ context.filter = filter;
+ context.complete = FileAdaptor.getTiddlerListComplete;
+ if(this.store) {
+ var ret = context.complete(context,context.userParams);
+ } else {
+ ret = loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context);
+ if(typeof ret != "string")
+ ret = true;
+ }
+ return ret;
+};
+
+FileAdaptor.getTiddlerListComplete = function(context,userParams)
+{
+ if(context.status) {
+ if(context.filter) {
+ context.tiddlers = context.adaptor.store.filterTiddlers(context.filter);
+ } else {
+ context.tiddlers = [];
+ context.adaptor.store.forEachTiddler(function(title,tiddler) {context.tiddlers.push(tiddler);});
+ }
+ for(var i=0; i<context.tiddlers.length; i++) {
+ context.tiddlers[i].fields['server.type'] = FileAdaptor.serverType;
+ context.tiddlers[i].fields['server.host'] = AdaptorBase.minHostName(context.host);
+ context.tiddlers[i].fields['server.page.revision'] = context.tiddlers[i].modified.convertToYYYYMMDDHHMM();
+ }
+ context.status = true;
+ }
+ if(context.callback) {
+ window.setTimeout(function() {context.callback(context,userParams);},10);
+ }
+ return true;
+};
+
+FileAdaptor.prototype.generateTiddlerInfo = function(tiddler)
+{
+ var info = {};
+ info.uri = tiddler.fields['server.host'] + "#" + tiddler.title;
+ return info;
+};
+
+// Retrieve a tiddler from a given workspace on a given server
+FileAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
+{
+ context = this.setContext(context,userParams,callback);
+ context.title = title;
+ context.complete = FileAdaptor.getTiddlerComplete;
+ return context.adaptor.store ?
+ context.complete(context,context.userParams) :
+ loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context);
+};
+
+FileAdaptor.getTiddlerComplete = function(context,userParams)
+{
+ var t = context.adaptor.store.fetchTiddler(context.title);
+ t.fields['server.type'] = FileAdaptor.serverType;
+ t.fields['server.host'] = AdaptorBase.minHostName(context.host);
+ t.fields['server.page.revision'] = t.modified.convertToYYYYMMDDHHMM();
+ context.tiddler = t;
+ context.status = true;
+ if(context.allowSynchronous) {
+ context.isSynchronous = true;
+ context.callback(context,userParams);
+ } else {
+ window.setTimeout(function() {context.callback(context,userParams);},10);
+ }
+ return true;
+};
+
+FileAdaptor.prototype.close = function()
+{
+ delete this.store;
+ this.store = null;
+};
+
+config.adaptors[FileAdaptor.serverType] = FileAdaptor;
+
+config.defaultAdaptor = FileAdaptor.serverType;
+
+//--
+//-- Remote HTTP requests
+//--
+
+function loadRemoteFile(url,callback,params)
+{
+ return httpReq("GET",url,callback,params);
+}
+
+function httpReq(type,url,callback,params,headers,data,contentType,username,password,allowCache)
+{
+ var x = null;
+ try {
+ x = new XMLHttpRequest(); //# Modern
+ } catch(ex) {
+ try {
+ x = new ActiveXObject("Msxml2.XMLHTTP"); //# IE 6
+ } catch(ex2) {
+ }
+ }
+ if(!x)
+ return "Can't create XMLHttpRequest object";
+ x.onreadystatechange = function() {
+ try {
+ var status = x.status;
+ } catch(ex) {
+ status = false;
+ }
+ if(x.readyState == 4 && callback && (status !== undefined)) {
+ if([0, 200, 201, 204, 207].contains(status))
+ callback(true,params,x.responseText,url,x);
+ else
+ callback(false,params,null,url,x);
+ x.onreadystatechange = function(){};
+ x = null;
+ }
+ };
+ if(window.Components && window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1)
+ window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
+ try {
+ if(!allowCache)
+ url = url + (url.indexOf("?") < 0 ? "?" : "&") + "nocache=" + Math.random();
+ x.open(type,url,true,username,password);
+ if(data)
+ x.setRequestHeader("Content-Type", contentType || "application/x-www-form-urlencoded");
+ if(x.overrideMimeType)
+ x.setRequestHeader("Connection", "close");
+ if(headers) {
+ for(var n in headers)
+ x.setRequestHeader(n,headers[n]);
+ }
+ x.setRequestHeader("X-Requested-With", "TiddlyWiki " + formatVersion());
+ x.send(data);
+ } catch(ex) {
+ return exceptionText(ex);
+ }
+ return x;
+}
+
+// included for compatibility
+function getXMLHttpRequest()
+{
+ try {
+ var x = new XMLHttpRequest(); // Modern
+ } catch(ex) {
+ try {
+ x = new ActiveXObject("Msxml2.XMLHTTP"); // IE 6
+ } catch (ex2) {
+ return null;
+ }
+ }
+ return x;
+}
+
+// included for compatibility
+function doHttp(type,url,data,contentType,username,password,callback,params,headers,allowCache)
+{
+ return httpReq(type,url,callback,params,headers,data,contentType,username,password,allowCache);
+}
+
+//--
+//-- TiddlyWiki-specific utility functions
+//--
+
+function formatVersion(v)
+{
+ v = v || version;
+ return v.major + "." + v.minor + "." + v.revision + (v.beta ? " (beta " + v.beta + ")" : "");
+}
+
+function compareVersions(v1,v2)
+{
+ var a = ["major","minor","revision"];
+ for(var i = 0; i<a.length; i++) {
+ var x1 = v1[a[i]] || 0;
+ var x2 = v2[a[i]] || 0;
+ if(x1<x2)
+ return 1;
+ if(x1>x2)
+ return -1;
+ }
+ x1 = v1.beta || 9999;
+ x2 = v2.beta || 9999;
+ if(x1<x2)
+ return 1;
+ return x1 > x2 ? -1 : 0;
+}
+
+function createTiddlyButton(parent,text,tooltip,action,className,id,accessKey,attribs)
+{
+ var btn = document.createElement("a");
+ if(action) {
+ btn.onclick = action;
+ btn.setAttribute("href","javascript:;");
+ }
+ if(tooltip)
+ btn.setAttribute("title",tooltip);
+ if(text)
+ btn.appendChild(document.createTextNode(text));
+ btn.className = className || "button";
+ if(id)
+ btn.id = id;
+ if(attribs) {
+ for(var i in attribs) {
+ btn.setAttribute(i,attribs[i]);
+ }
+ }
+ if(parent)
+ parent.appendChild(btn);
+ if(accessKey)
+ btn.setAttribute("accessKey",accessKey);
+ return btn;
+}
+
+function createTiddlyLink(place,title,includeText,className,isStatic,linkedFromTiddler,noToggle)
+{
+ var text = includeText ? title : null;
+ var i = getTiddlyLinkInfo(title,className);
+ var btn = isStatic ? createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" + title) : createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
+ if(isStatic)
+ btn.className += ' ' + className;
+ btn.setAttribute("refresh","link");
+ btn.setAttribute("tiddlyLink",title);
+ if(noToggle)
+ btn.setAttribute("noToggle","true");
+ if(linkedFromTiddler) {
+ var fields = linkedFromTiddler.getInheritedFields();
+ if(fields)
+ btn.setAttribute("tiddlyFields",fields);
+ }
+ return btn;
+}
+
+function refreshTiddlyLink(e,title)
+{
+ var i = getTiddlyLinkInfo(title,e.className);
+ e.className = i.classes;
+ e.title = i.subTitle;
+}
+
+function getTiddlyLinkInfo(title,currClasses)
+{
+ var classes = currClasses ? currClasses.split(" ") : [];
+ classes.pushUnique("tiddlyLink");
+ var tiddler = store.fetchTiddler(title);
+ var subTitle;
+ if(tiddler) {
+ subTitle = tiddler.getSubtitle();
+ classes.pushUnique("tiddlyLinkExisting");
+ classes.remove("tiddlyLinkNonExisting");
+ classes.remove("shadow");
+ } else {
+ classes.remove("tiddlyLinkExisting");
+ classes.pushUnique("tiddlyLinkNonExisting");
+ if(store.isShadowTiddler(title)) {
+ subTitle = config.messages.shadowedTiddlerToolTip.format([title]);
+ classes.pushUnique("shadow");
+ } else {
+ subTitle = config.messages.undefinedTiddlerToolTip.format([title]);
+ classes.remove("shadow");
+ }
+ }
+ if(typeof config.annotations[title]=="string")
+ subTitle = config.annotations[title];
+ return {classes: classes.join(" "),subTitle: subTitle};
+}
+
+function createExternalLink(place,url)
+{
+ var link = document.createElement("a");
+ link.className = "externalLink";
+ link.href = url;
+ link.title = config.messages.externalLinkTooltip.format([url]);
+ if(config.options.chkOpenInNewWindow)
+ link.target = "_blank";
+ place.appendChild(link);
+ return link;
+}
+
+// Event handler for clicking on a tiddly link
+function onClickTiddlerLink(ev)
+{
+ var e = ev || window.event;
+ var target = resolveTarget(e);
+ var link = target;
+ var title = null;
+ var fields = null;
+ var noToggle = null;
+ do {
+ title = link.getAttribute("tiddlyLink");
+ fields = link.getAttribute("tiddlyFields");
+ noToggle = link.getAttribute("noToggle");
+ link = link.parentNode;
+ } while(title == null && link != null);
+ if(!store.isShadowTiddler(title)) {
+ var f = fields ? fields.decodeHashMap() : {};
+ fields = String.encodeHashMap(merge(f,config.defaultCustomFields,true));
+ }
+ if(title) {
+ var toggling = e.metaKey || e.ctrlKey;
+ if(config.options.chkToggleLinks)
+ toggling = !toggling;
+ if(noToggle)
+ toggling = false;
+ if(store.getTiddler(title))
+ fields = null;
+ story.displayTiddler(target,title,null,true,null,fields,toggling);
+ }
+ clearMessage();
+ return false;
+}
+
+// Create a button for a tag with a popup listing all the tiddlers that it tags
+function createTagButton(place,tag,excludeTiddler,title,tooltip)
+{
+ var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag);
+ btn.setAttribute("tag",tag);
+ if(excludeTiddler)
+ btn.setAttribute("tiddler",excludeTiddler);
+ return btn;
+}
+
+// Event handler for clicking on a tiddler tag
+function onClickTag(ev)
+{
+ var e = ev || window.event;
+ var popup = Popup.create(this);
+ var tag = this.getAttribute("tag");
+ var title = this.getAttribute("tiddler");
+ if(popup && tag) {
+ var tagged = store.getTaggedTiddlers(tag);
+ var titles = [];
+ var li,r;
+ for(r=0;r<tagged.length;r++) {
+ if(tagged[r].title != title)
+ titles.push(tagged[r].title);
+ }
+ var lingo = config.views.wikified.tag;
+ if(titles.length > 0) {
+ var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);
+ openAll.setAttribute("tag",tag);
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ for(r=0; r<titles.length; r++) {
+ createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);
+ }
+ } else {
+ createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag]));
+ }
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);
+ createTiddlyText(h,lingo.openTag.format([tag]));
+ }
+ Popup.show();
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return false;
+}
+
+// Event handler for 'open all' on a tiddler popup
+function onClickTagOpenAll(ev)
+{
+ var tiddlers = store.getTaggedTiddlers(this.getAttribute("tag"));
+ story.displayTiddlers(this,tiddlers);
+ return false;
+}
+
+function onClickError(ev)
+{
+ var e = ev || window.event;
+ var popup = Popup.create(this);
+ var lines = this.getAttribute("errorText").split("\n");
+ for(var t=0; t<lines.length; t++)
+ createTiddlyElement(popup,"li",null,null,lines[t]);
+ Popup.show();
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return false;
+}
+
+function createTiddlyDropDown(place,onchange,options,defaultValue)
+{
+ var sel = createTiddlyElement(place,"select");
+ sel.onchange = onchange;
+ for(var t=0; t<options.length; t++) {
+ var e = createTiddlyElement(sel,"option",null,null,options[t].caption);
+ e.value = options[t].name;
+ if(options[t].name == defaultValue)
+ e.selected = true;
+ }
+ return sel;
+}
+
+function createTiddlyPopup(place,caption,tooltip,tiddler)
+{
+ if(tiddler.text) {
+ createTiddlyLink(place,caption,true);
+ var btn = createTiddlyButton(place,glyph("downArrow"),tooltip,onClickTiddlyPopup,"tiddlerPopupButton");
+ btn.tiddler = tiddler;
+ } else {
+ createTiddlyText(place,caption);
+ }
+}
+
+function onClickTiddlyPopup(ev)
+{
+ var e = ev || window.event;
+ var tiddler = this.tiddler;
+ if(tiddler.text) {
+ var popup = Popup.create(this,"div","popupTiddler");
+ wikify(tiddler.text,popup,null,tiddler);
+ Popup.show();
+ }
+ if(e) e.cancelBubble = true;
+ if(e && e.stopPropagation) e.stopPropagation();
+ return false;
+}
+
+function createTiddlyError(place,title,text)
+{
+ var btn = createTiddlyButton(place,title,null,onClickError,"errorButton");
+ if(text) btn.setAttribute("errorText",text);
+}
+
+function merge(dst,src,preserveExisting)
+{
+ for(var i in src) {
+ if(!preserveExisting || dst[i] === undefined)
+ dst[i] = src[i];
+ }
+ return dst;
+}
+
+// Returns a string containing the description of an exception, optionally prepended by a message
+function exceptionText(e,message)
+{
+ var s = e.description || e.toString();
+ return message ? "%0:\n%1".format([message,s]) : s;
+}
+
+// Displays an alert of an exception description with optional message
+function showException(e,message)
+{
+ alert(exceptionText(e,message));
+}
+
+function alertAndThrow(m)
+{
+ alert(m);
+ throw(m);
+}
+
+function glyph(name)
+{
+ var g = config.glyphs;
+ var b = g.currBrowser;
+ if(b == null) {
+ b = 0;
+ while(!g.browsers[b]() && b < g.browsers.length-1)
+ b++;
+ g.currBrowser = b;
+ }
+ if(!g.codes[name])
+ return "";
+ return g.codes[name][b];
+}
+
+if(!window.console) {
+ console = {tiddlywiki:true,log:function(message) {displayMessage(message);}};
+}
+
+//-
+//- Animation engine
+//-
+
+function Animator()
+{
+ this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
+ this.timerID = 0; // ID of the timer used for animating
+ this.animations = []; // List of animations in progress
+ return this;
+}
+
+// Start animation engine
+Animator.prototype.startAnimating = function() //# Variable number of arguments
+{
+ for(var t=0; t<arguments.length; t++)
+ this.animations.push(arguments[t]);
+ if(this.running == 0) {
+ var me = this;
+ this.timerID = window.setInterval(function() {me.doAnimate(me);},10);
+ }
+ this.running += arguments.length;
+};
+
+// Perform an animation engine tick, calling each of the known animation modules
+Animator.prototype.doAnimate = function(me)
+{
+ var a = 0;
+ while(a < me.animations.length) {
+ var animation = me.animations[a];
+ if(animation.tick()) {
+ a++;
+ } else {
+ me.animations.splice(a,1);
+ if(--me.running == 0)
+ window.clearInterval(me.timerID);
+ }
+ }
+};
+
+Animator.slowInSlowOut = function(progress)
+{
+ return(1-((Math.cos(progress * Math.PI)+1)/2));
+};
+
+//--
+//-- Morpher animation
+//--
+
+// Animate a set of properties of an element
+function Morpher(element,duration,properties,callback)
+{
+ this.element = element;
+ this.duration = duration;
+ this.properties = properties;
+ this.startTime = new Date();
+ this.endTime = Number(this.startTime) + duration;
+ this.callback = callback;
+ this.tick();
+ return this;
+}
+
+Morpher.prototype.assignStyle = function(element,style,value)
+{
+ switch(style) {
+ case "-tw-vertScroll":
+ window.scrollTo(findScrollX(),value);
+ break;
+ case "-tw-horizScroll":
+ window.scrollTo(value,findScrollY());
+ break;
+ default:
+ element.style[style] = value;
+ break;
+ }
+};
+
+Morpher.prototype.stop = function()
+{
+ for(var t=0; t<this.properties.length; t++) {
+ var p = this.properties[t];
+ if(p.atEnd !== undefined) {
+ this.assignStyle(this.element,p.style,p.atEnd);
+ }
+ }
+ if(this.callback)
+ this.callback(this.element,this.properties);
+};
+
+Morpher.prototype.tick = function()
+{
+ var currTime = Number(new Date());
+ var progress = Animator.slowInSlowOut(Math.min(1,(currTime-this.startTime)/this.duration));
+ for(var t=0; t<this.properties.length; t++) {
+ var p = this.properties[t];
+ if(p.start !== undefined && p.end !== undefined) {
+ var template = p.template || "%0";
+ switch(p.format) {
+ case undefined:
+ case "style":
+ var v = p.start + (p.end-p.start) * progress;
+ this.assignStyle(this.element,p.style,template.format([v]));
+ break;
+ case "color":
+ break;
+ }
+ }
+ }
+ if(currTime >= this.endTime) {
+ this.stop();
+ return false;
+ }
+ return true;
+};
+
+//--
+//-- Zoomer animation
+//--
+
+function Zoomer(text,startElement,targetElement,unused)
+{
+ var e = createTiddlyElement(document.body,"div",null,"zoomer");
+ createTiddlyElement(e,"div",null,null,text);
+ var winWidth = findWindowWidth();
+ var winHeight = findWindowHeight();
+ var p = [
+ {style: 'left', start: findPosX(startElement), end: findPosX(targetElement), template: '%0px'},
+ {style: 'top', start: findPosY(startElement), end: findPosY(targetElement), template: '%0px'},
+ {style: 'width', start: Math.min(startElement.scrollWidth,winWidth), end: Math.min(targetElement.scrollWidth,winWidth), template: '%0px', atEnd: 'auto'},
+ {style: 'height', start: Math.min(startElement.scrollHeight,winHeight), end: Math.min(targetElement.scrollHeight,winHeight), template: '%0px', atEnd: 'auto'},
+ {style: 'fontSize', start: 8, end: 24, template: '%0pt'}
+ ];
+ var c = function(element,properties) {removeNode(element);};
+ return new Morpher(e,config.animDuration,p,c);
+}
+
+//--
+//-- Scroller animation
+//--
+
+function Scroller(targetElement)
+{
+ var p = [{style: '-tw-vertScroll', start: findScrollY(), end: ensureVisible(targetElement)}];
+ return new Morpher(targetElement,config.animDuration,p);
+}
+
+//--
+//-- Slider animation
+//--
+
+// deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element]
+function Slider(element,opening,unused,deleteMode)
+{
+ element.style.overflow = 'hidden';
+ if(opening)
+ element.style.height = '0px'; // Resolves a Firefox flashing bug
+ element.style.display = 'block';
+ var left = findPosX(element);
+ var width = element.scrollWidth;
+ var height = element.scrollHeight;
+ var winWidth = findWindowWidth();
+ var p = [];
+ var c = null;
+ if(opening) {
+ p.push({style: 'height', start: 0, end: height, template: '%0px', atEnd: 'auto'});
+ p.push({style: 'opacity', start: 0, end: 1, template: '%0'});
+ p.push({style: 'filter', start: 0, end: 100, template: 'alpha(opacity:%0)'});
+ } else {
+ p.push({style: 'height', start: height, end: 0, template: '%0px'});
+ p.push({style: 'display', atEnd: 'none'});
+ p.push({style: 'opacity', start: 1, end: 0, template: '%0'});
+ p.push({style: 'filter', start: 100, end: 0, template: 'alpha(opacity:%0)'});
+ switch(deleteMode) {
+ case "all":
+ c = function(element,properties) {removeNode(element);};
+ break;
+ case "children":
+ c = function(element,properties) {removeChildren(element);};
+ break;
+ }
+ }
+ return new Morpher(element,config.animDuration,p,c);
+}
+
+//--
+//-- Popup menu
+//--
+
+var Popup = {
+ stack: [] // Array of objects with members root: and popup:
+ };
+
+Popup.create = function(root,elem,className)
+{
+ var stackPosition = this.find(root,"popup");
+ Popup.remove(stackPosition+1);
+ var popup = createTiddlyElement(document.body,elem || "ol","popup",className || "popup");
+ popup.stackPosition = stackPosition;
+ Popup.stack.push({root: root, popup: popup});
+ return popup;
+};
+
+Popup.onDocumentClick = function(ev)
+{
+ var e = ev || window.event;
+ if(e.eventPhase == undefined)
+ Popup.remove();
+ else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET)
+ Popup.remove();
+ return true;
+};
+
+Popup.show = function(valign,halign,offset)
+{
+ var curr = Popup.stack[Popup.stack.length-1];
+ this.place(curr.root,curr.popup,valign,halign,offset);
+ addClass(curr.root,"highlight");
+ if(config.options.chkAnimate && anim && typeof Scroller == "function")
+ anim.startAnimating(new Scroller(curr.popup));
+ else
+ window.scrollTo(0,ensureVisible(curr.popup));
+};
+
+Popup.place = function(root,popup,valign,halign,offset)
+{
+ if(!offset)
+ var offset = {x:0,y:0};
+ if(popup.stackPosition >= 0 && !valign && !halign) {
+ offset.x = offset.x + root.offsetWidth;
+ } else {
+ offset.x = (halign == 'right') ? offset.x + root.offsetWidth : offset.x;
+ offset.y = (valign == 'top') ? offset.y : offset.y + root.offsetHeight;
+ }
+ var rootLeft = findPosX(root);
+ var rootTop = findPosY(root);
+ var popupLeft = rootLeft + offset.x;
+ var popupTop = rootTop + offset.y;
+ var winWidth = findWindowWidth();
+ if(popup.offsetWidth > winWidth*0.75)
+ popup.style.width = winWidth*0.75 + "px";
+ var popupWidth = popup.offsetWidth;
+ var scrollWidth = winWidth - document.body.offsetWidth;
+ if(popupLeft + popupWidth > winWidth - scrollWidth - 1) {
+ if(halign == 'right')
+ popupLeft = popupLeft - root.offsetWidth - popupWidth;
+ else
+ popupLeft = winWidth - popupWidth - scrollWidth - 1;
+ }
+ popup.style.left = popupLeft + "px";
+ popup.style.top = popupTop + "px";
+ popup.style.display = "block";
+};
+
+Popup.find = function(e)
+{
+ var pos = -1;
+ for (var t=this.stack.length-1; t>=0; t--) {
+ if(isDescendant(e,this.stack[t].popup))
+ pos = t;
+ }
+ return pos;
+};
+
+Popup.remove = function(pos)
+{
+ if(!pos) var pos = 0;
+ if(Popup.stack.length > pos) {
+ Popup.removeFrom(pos);
+ }
+};
+
+Popup.removeFrom = function(from)
+{
+ for(var t=Popup.stack.length-1; t>=from; t--) {
+ var p = Popup.stack[t];
+ removeClass(p.root,"highlight");
+ removeNode(p.popup);
+ }
+ Popup.stack = Popup.stack.slice(0,from);
+};
+
+//--
+//-- Wizard support
+//--
+
+function Wizard(elem)
+{
+ if(elem) {
+ this.formElem = findRelated(elem,"wizard","className");
+ this.bodyElem = findRelated(this.formElem.firstChild,"wizardBody","className","nextSibling");
+ this.footElem = findRelated(this.formElem.firstChild,"wizardFooter","className","nextSibling");
+ } else {
+ this.formElem = null;
+ this.bodyElem = null;
+ this.footElem = null;
+ }
+}
+
+Wizard.prototype.setValue = function(name,value)
+{
+ if(this.formElem)
+ this.formElem[name] = value;
+};
+
+Wizard.prototype.getValue = function(name)
+{
+ return this.formElem ? this.formElem[name] : null;
+};
+
+Wizard.prototype.createWizard = function(place,title)
+{
+ this.formElem = createTiddlyElement(place,"form",null,"wizard");
+ createTiddlyElement(this.formElem,"h1",null,null,title);
+ this.bodyElem = createTiddlyElement(this.formElem,"div",null,"wizardBody");
+ this.footElem = createTiddlyElement(this.formElem,"div",null,"wizardFooter");
+};
+
+Wizard.prototype.clear = function()
+{
+ removeChildren(this.bodyElem);
+};
+
+Wizard.prototype.setButtons = function(buttonInfo,status)
+{
+ removeChildren(this.footElem);
+ for(var t=0; t<buttonInfo.length; t++) {
+ createTiddlyButton(this.footElem,buttonInfo[t].caption,buttonInfo[t].tooltip,buttonInfo[t].onClick);
+ insertSpacer(this.footElem);
+ }
+ if(typeof status == "string") {
+ createTiddlyElement(this.footElem,"span",null,"status",status);
+ }
+};
+
+Wizard.prototype.addStep = function(stepTitle,html)
+{
+ removeChildren(this.bodyElem);
+ var w = createTiddlyElement(this.bodyElem,"div");
+ createTiddlyElement(w,"h2",null,null,stepTitle);
+ var step = createTiddlyElement(w,"div",null,"wizardStep");
+ step.innerHTML = html;
+ applyHtmlMacros(step,tiddler);
+};
+
+Wizard.prototype.getElement = function(name)
+{
+ return this.formElem.elements[name];
+};
+
+//--
+//-- ListView gadget
+//--
+
+var ListView = {};
+
+// Create a listview
+ListView.create = function(place,listObject,listTemplate,callback,className)
+{
+ var table = createTiddlyElement(place,"table",null,className || "listView twtable");
+ var thead = createTiddlyElement(table,"thead");
+ var r = createTiddlyElement(thead,"tr");
+ for(var t=0; t<listTemplate.columns.length; t++) {
+ var columnTemplate = listTemplate.columns[t];
+ var c = createTiddlyElement(r,"th");
+ var colType = ListView.columnTypes[columnTemplate.type];
+ if(colType && colType.createHeader) {
+ colType.createHeader(c,columnTemplate,t);
+ if(columnTemplate.className)
+ addClass(c,columnTemplate.className);
+ }
+ }
+ var tbody = createTiddlyElement(table,"tbody");
+ for(var rc=0; rc<listObject.length; rc++) {
+ var rowObject = listObject[rc];
+ r = createTiddlyElement(tbody,"tr");
+ for(c=0; c<listTemplate.rowClasses.length; c++) {
+ if(rowObject[listTemplate.rowClasses[c].field])
+ addClass(r,listTemplate.rowClasses[c].className);
+ }
+ rowObject.rowElement = r;
+ rowObject.colElements = {};
+ for(var cc=0; cc<listTemplate.columns.length; cc++) {
+ c = createTiddlyElement(r,"td");
+ columnTemplate = listTemplate.columns[cc];
+ var field = columnTemplate.field;
+ colType = ListView.columnTypes[columnTemplate.type];
+ if(colType && colType.createItem) {
+ colType.createItem(c,rowObject,field,columnTemplate,cc,rc);
+ if(columnTemplate.className)
+ addClass(c,columnTemplate.className);
+ }
+ rowObject.colElements[field] = c;
+ }
+ }
+ if(callback && listTemplate.actions)
+ createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions);
+ if(callback && listTemplate.buttons) {
+ for(t=0; t<listTemplate.buttons.length; t++) {
+ var a = listTemplate.buttons[t];
+ if(a && a.name != "")
+ createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection));
+ }
+ }
+ return table;
+};
+
+ListView.getCommandHandler = function(callback,name,allowEmptySelection)
+{
+ return function(e) {
+ var view = findRelated(this,"TABLE",null,"previousSibling");
+ var tiddlers = [];
+ ListView.forEachSelector(view,function(e,rowName) {
+ if(e.checked)
+ tiddlers.push(rowName);
+ });
+ if(tiddlers.length == 0 && !allowEmptySelection) {
+ alert(config.messages.nothingSelected);
+ } else {
+ if(this.nodeName.toLowerCase() == "select") {
+ callback(view,this.value,tiddlers);
+ this.selectedIndex = 0;
+ } else {
+ callback(view,name,tiddlers);
+ }
+ }
+ };
+};
+
+// Invoke a callback for each selector checkbox in the listview
+ListView.forEachSelector = function(view,callback)
+{
+ var checkboxes = view.getElementsByTagName("input");
+ var hadOne = false;
+ for(var t=0; t<checkboxes.length; t++) {
+ var cb = checkboxes[t];
+ if(cb.getAttribute("type") == "checkbox") {
+ var rn = cb.getAttribute("rowName");
+ if(rn) {
+ callback(cb,rn);
+ hadOne = true;
+ }
+ }
+ }
+ return hadOne;
+};
+
+ListView.getSelectedRows = function(view)
+{
+ var rowNames = [];
+ ListView.forEachSelector(view,function(e,rowName) {
+ if(e.checked)
+ rowNames.push(rowName);
+ });
+ return rowNames;
+};
+
+ListView.columnTypes = {};
+
+ListView.columnTypes.String = {
+ createHeader: function(place,columnTemplate,col)
+ {
+ createTiddlyText(place,columnTemplate.title);
+ },
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined)
+ createTiddlyText(place,v);
+ }
+};
+
+ListView.columnTypes.WikiText = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined)
+ wikify(v,place,null,null);
+ }
+};
+
+ListView.columnTypes.Tiddler = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined && v.title)
+ createTiddlyPopup(place,v.title,config.messages.listView.tiddlerTooltip,v);
+ }
+};
+
+ListView.columnTypes.Size = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined) {
+ var t = 0;
+ while(t<config.messages.sizeTemplates.length-1 && v<config.messages.sizeTemplates[t].unit)
+ t++;
+ createTiddlyText(place,config.messages.sizeTemplates[t].template.format([Math.round(v/config.messages.sizeTemplates[t].unit)]));
+ }
+ }
+};
+
+ListView.columnTypes.Link = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ var c = columnTemplate.text;
+ if(v != undefined)
+ createTiddlyText(createExternalLink(place,v),c || v);
+ }
+};
+
+ListView.columnTypes.Date = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined)
+ createTiddlyText(place,v.formatString(columnTemplate.dateFormat));
+ }
+};
+
+ListView.columnTypes.StringList = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined) {
+ for(var t=0; t<v.length; t++) {
+ createTiddlyText(place,v[t]);
+ createTiddlyElement(place,"br");
+ }
+ }
+ }
+};
+
+ListView.columnTypes.Selector = {
+ createHeader: function(place,columnTemplate,col)
+ {
+ createTiddlyCheckbox(place,null,false,this.onHeaderChange);
+ },
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var e = createTiddlyCheckbox(place,null,listObject[field],null);
+ e.setAttribute("rowName",listObject[columnTemplate.rowName]);
+ },
+ onHeaderChange: function(e)
+ {
+ var state = this.checked;
+ var view = findRelated(this,"TABLE");
+ if(!view)
+ return;
+ ListView.forEachSelector(view,function(e,rowName) {
+ e.checked = state;
+ });
+ }
+};
+
+ListView.columnTypes.Tags = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var tags = listObject[field];
+ createTiddlyText(place,String.encodeTiddlyLinkList(tags));
+ }
+};
+
+ListView.columnTypes.Boolean = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ if(listObject[field] == true)
+ createTiddlyText(place,columnTemplate.trueText);
+ if(listObject[field] == false)
+ createTiddlyText(place,columnTemplate.falseText);
+ }
+};
+
+ListView.columnTypes.TagCheckbox = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange);
+ e.setAttribute("tiddler",listObject.title);
+ e.setAttribute("tag",columnTemplate.tag);
+ },
+ onChange : function(e)
+ {
+ var tag = this.getAttribute("tag");
+ var tiddler = this.getAttribute("tiddler");
+ store.setTiddlerTag(tiddler,this.checked,tag);
+ }
+};
+
+ListView.columnTypes.TiddlerLink = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined) {
+ var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null);
+ createTiddlyText(link,listObject[field]);
+ }
+ }
+};
+
+//--
+//-- Augmented methods for the JavaScript Number(), Array(), String() and Date() objects
+//--
+
+// Clamp a number to a range
+Number.prototype.clamp = function(min,max)
+{
+ var c = this;
+ if(c < min)
+ c = min;
+ if(c > max)
+ c = max;
+ return c;
+};
+
+// Add indexOf function if browser does not support it
+if(!Array.indexOf) {
+Array.prototype.indexOf = function(item,from)
+{
+ if(!from)
+ from = 0;
+ for(var i=from; i<this.length; i++) {
+ if(this[i] === item)
+ return i;
+ }
+ return -1;
+};}
+
+// Find an entry in a given field of the members of an array
+Array.prototype.findByField = function(field,value)
+{
+ for(var t=0; t<this.length; t++) {
+ if(this[t][field] == value)
+ return t;
+ }
+ return null;
+};
+
+// Return whether an entry exists in an array
+Array.prototype.contains = function(item)
+{
+ return this.indexOf(item) != -1;
+};
+
+// Adds, removes or toggles a particular value within an array
+// value - value to add
+// mode - +1 to add value, -1 to remove value, 0 to toggle it
+Array.prototype.setItem = function(value,mode)
+{
+ var p = this.indexOf(value);
+ if(mode == 0)
+ mode = (p == -1) ? +1 : -1;
+ if(mode == +1) {
+ if(p == -1)
+ this.push(value);
+ } else if(mode == -1) {
+ if(p != -1)
+ this.splice(p,1);
+ }
+};
+
+// Return whether one of a list of values exists in an array
+Array.prototype.containsAny = function(items)
+{
+ for(var i=0; i<items.length; i++) {
+ if(this.indexOf(items[i]) != -1)
+ return true;
+ }
+ return false;
+};
+
+// Return whether all of a list of values exists in an array
+Array.prototype.containsAll = function(items)
+{
+ for(var i = 0; i<items.length; i++) {
+ if(this.indexOf(items[i]) == -1)
+ return false;
+ }
+ return true;
+};
+
+// Push a new value into an array only if it is not already present in the array. If the optional unique parameter is false, it reverts to a normal push
+Array.prototype.pushUnique = function(item,unique)
+{
+ if(unique === false) {
+ this.push(item);
+ } else {
+ if(this.indexOf(item) == -1)
+ this.push(item);
+ }
+};
+
+Array.prototype.remove = function(item)
+{
+ var p = this.indexOf(item);
+ if(p != -1)
+ this.splice(p,1);
+};
+
+if(!Array.prototype.map) {
+Array.prototype.map = function(fn,thisObj)
+{
+ var scope = thisObj || window;
+ var a = [];
+ for(var i=0, j=this.length; i < j; ++i) {
+ a.push(fn.call(scope,this[i],i,this));
+ }
+ return a;
+};}
+
+// Get characters from the right end of a string
+String.prototype.right = function(n)
+{
+ return n < this.length ? this.slice(this.length-n) : this;
+};
+
+// Trim whitespace from both ends of a string
+String.prototype.trim = function()
+{
+ return this.replace(/^\s*|\s*$/g,"");
+};
+
+// Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor")
+String.prototype.unDash = function()
+{
+ var s = this.split("-");
+ if(s.length > 1) {
+ for(var t=1; t<s.length; t++)
+ s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1);
+ }
+ return s.join("");
+};
+
+// Substitute substrings from an array into a format string that includes '%1'-type specifiers
+String.prototype.format = function(substrings)
+{
+ var subRegExp = /(?:%(\d+))/mg;
+ var currPos = 0;
+ var r = [];
+ do {
+ var match = subRegExp.exec(this);
+ if(match && match[1]) {
+ if(match.index > currPos)
+ r.push(this.substring(currPos,match.index));
+ r.push(substrings[parseInt(match[1])]);
+ currPos = subRegExp.lastIndex;
+ }
+ } while(match);
+ if(currPos < this.length)
+ r.push(this.substring(currPos,this.length));
+ return r.join("");
+};
+
+// Escape any special RegExp characters with that character preceded by a backslash
+String.prototype.escapeRegExp = function()
+{
+ var s = "\\^$*+?()=!|,{}[].";
+ var c = this;
+ for(var t=0; t<s.length; t++)
+ c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1));
+ return c;
+};
+
+// Convert "\" to "\s", newlines to "\n" (and remove carriage returns)
+String.prototype.escapeLineBreaks = function()
+{
+ return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,"");
+};
+
+// Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns)
+String.prototype.unescapeLineBreaks = function()
+{
+ return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,"");
+};
+
+// Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;"
+String.prototype.htmlEncode = function()
+{
+ return this.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;");
+};
+
+// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
+String.prototype.htmlDecode = function()
+{
+ return this.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&");
+};
+
+// Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org
+String.prototype.toJSONString = function()
+{
+ var m = {
+ '\b': '\\b',
+ '\f': '\\f',
+ '\n': '\\n',
+ '\r': '\\r',
+ '\t': '\\t',
+ '"' : '\\"',
+ '\\': '\\\\'
+ };
+ var replaceFn = function(a,b) {
+ var c = m[b];
+ if(c)
+ return c;
+ c = b.charCodeAt();
+ return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
+ };
+ if(/["\\\x00-\x1f]/.test(this))
+ return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"';
+ return '"' + this + '"';
+};
+
+// Parse a space-separated string of name:value parameters
+// The result is an array of objects:
+// result[0] = object with a member for each parameter name, value of that member being an array of values
+// result[1..n] = one object for each parameter, with 'name' and 'value' members
+String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults)
+{
+ var parseToken = function(match,p) {
+ var n;
+ if(match[p]) // Double quoted
+ n = match[p];
+ else if(match[p+1]) // Single quoted
+ n = match[p+1];
+ else if(match[p+2]) // Double-square-bracket quoted
+ n = match[p+2];
+ else if(match[p+3]) // Double-brace quoted
+ try {
+ n = match[p+3];
+ if(allowEval)
+ n = window.eval(n);
+ } catch(ex) {
+ throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(ex);
+ }
+ else if(match[p+4]) // Unquoted
+ n = match[p+4];
+ else if(match[p+5]) // empty quote
+ n = "";
+ return n;
+ };
+ var r = [{}];
+ var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
+ var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
+ var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
+ var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
+ var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
+ var emptyQuote = "((?:\"\")|(?:''))";
+ var skipSpace = "(?:\\s*)";
+ var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
+ var re = noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
+ var params = [];
+ do {
+ var match = re.exec(this);
+ if(match) {
+ var n = parseToken(match,1);
+ if(noNames) {
+ r.push({name:"",value:n});
+ } else {
+ var v = parseToken(match,8);
+ if(v == null && defaultName) {
+ v = n;
+ n = defaultName;
+ } else if(v == null && defaultValue) {
+ v = defaultValue;
+ }
+ r.push({name:n,value:v});
+ if(cascadeDefaults) {
+ defaultName = n;
+ defaultValue = v;
+ }
+ }
+ }
+ } while(match);
+ // Summarise parameters into first element
+ for(var t=1; t<r.length; t++) {
+ if(r[0][r[t].name])
+ r[0][r[t].name].push(r[t].value);
+ else
+ r[0][r[t].name] = [r[t].value];
+ }
+ return r;
+};
+
+// Process a string list of macro parameters into an array. Parameters can be quoted with "", '',
+// [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in
+// an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name.
+String.prototype.readMacroParams = function()
+{
+ var p = this.parseParams("list",null,true,true);
+ var n = [];
+ for(var t=1; t<p.length; t++)
+ n.push(p[t].value);
+ return n;
+};
+
+// Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]]
+String.prototype.readBracketedList = function(unique)
+{
+ var p = this.parseParams("list",null,false,true);
+ var n = [];
+ for(var t=1; t<p.length; t++) {
+ if(p[t].value)
+ n.pushUnique(p[t].value,unique);
+ }
+ return n;
+};
+
+// Returns array with start and end index of chunk between given start and end marker, or undefined.
+String.prototype.getChunkRange = function(start,end)
+{
+ var s = this.indexOf(start);
+ if(s != -1) {
+ s += start.length;
+ var e = this.indexOf(end,s);
+ if(e != -1)
+ return [s,e];
+ }
+};
+
+// Replace a chunk of a string given start and end markers
+String.prototype.replaceChunk = function(start,end,sub)
+{
+ var r = this.getChunkRange(start,end);
+ return r ? this.substring(0,r[0]) + sub + this.substring(r[1]) : this;
+};
+
+// Returns a chunk of a string between start and end markers, or undefined
+String.prototype.getChunk = function(start,end)
+{
+ var r = this.getChunkRange(start,end);
+ if(r)
+ return this.substring(r[0],r[1]);
+};
+
+
+// Static method to bracket a string with double square brackets if it contains a space
+String.encodeTiddlyLink = function(title)
+{
+ return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
+};
+
+// Static method to encodeTiddlyLink for every item in an array and join them with spaces
+String.encodeTiddlyLinkList = function(list)
+{
+ if(list) {
+ var results = [];
+ for(var t=0; t<list.length; t++)
+ results.push(String.encodeTiddlyLink(list[t]));
+ return results.join(" ");
+ } else {
+ return "";
+ }
+};
+
+// Convert a string as a sequence of name:"value" pairs into a hashmap
+String.prototype.decodeHashMap = function()
+{
+ var fields = this.parseParams("anon","",false);
+ var r = {};
+ for(var t=1; t<fields.length; t++)
+ r[fields[t].name] = fields[t].value;
+ return r;
+};
+
+// Static method to encode a hashmap into a name:"value"... string
+String.encodeHashMap = function(hashmap)
+{
+ var r = [];
+ for(var t in hashmap)
+ r.push(t + ':"' + hashmap[t] + '"');
+ return r.join(" ");
+};
+
+// Static method to left-pad a string with 0s to a certain width
+String.zeroPad = function(n,d)
+{
+ var s = n.toString();
+ if(s.length < d)
+ s = "000000000000000000000000000".substr(0,d-s.length) + s;
+ return s;
+};
+
+String.prototype.startsWith = function(prefix)
+{
+ return !prefix || this.substring(0,prefix.length) == prefix;
+};
+
+// Returns the first value of the given named parameter.
+function getParam(params,name,defaultValue)
+{
+ if(!params)
+ return defaultValue;
+ var p = params[0][name];
+ return p ? p[0] : defaultValue;
+}
+
+// Returns the first value of the given boolean named parameter.
+function getFlag(params,name,defaultValue)
+{
+ return !!getParam(params,name,defaultValue);
+}
+
+// Substitute date components into a string
+Date.prototype.formatString = function(template)
+{
+ var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
+ t = t.replace(/hh12/g,this.getHours12());
+ t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2));
+ t = t.replace(/hh/g,this.getHours());
+ t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]);
+ t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
+ t = t.replace(/mm/g,this.getMinutes());
+ t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
+ t = t.replace(/ss/g,this.getSeconds());
+ t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase());
+ t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase());
+ t = t.replace(/wYYYY/g,this.getYearForWeekNo());
+ t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
+ t = t.replace(/YYYY/g,this.getFullYear());
+ t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
+ t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]);
+ t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
+ t = t.replace(/MM/g,this.getMonth()+1);
+ t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
+ t = t.replace(/WW/g,this.getWeek());
+ t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]);
+ t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]);
+ t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2));
+ t = t.replace(/DDth/g,this.getDate()+this.daySuffix());
+ t = t.replace(/DD/g,this.getDate());
+ var tz = this.getTimezoneOffset();
+ var atz = Math.abs(tz);
+ t = t.replace(/TZD/g,(tz < 0 ? '+' : '-') + String.zeroPad(Math.floor(atz / 60),2) + ':' + String.zeroPad(atz % 60,2));
+ t = t.replace(/\\/g,"");
+ return t;
+};
+
+Date.prototype.getWeek = function()
+{
+ var dt = new Date(this.getTime());
+ var d = dt.getDay();
+ if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
+ dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo
+ var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);
+ return Math.floor(n/7)+1;
+};
+
+Date.prototype.getYearForWeekNo = function()
+{
+ var dt = new Date(this.getTime());
+ var d = dt.getDay();
+ if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
+ dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week
+ return dt.getFullYear();
+};
+
+Date.prototype.getHours12 = function()
+{
+ var h = this.getHours();
+ return h > 12 ? h-12 : ( h > 0 ? h : 12 );
+};
+
+Date.prototype.getAmPm = function()
+{
+ return this.getHours() >= 12 ? config.messages.dates.pm : config.messages.dates.am;
+};
+
+Date.prototype.daySuffix = function()
+{
+ return config.messages.dates.daySuffixes[this.getDate()-1];
+};
+
+// Convert a date to local YYYYMMDDHHMM string format
+Date.prototype.convertToLocalYYYYMMDDHHMM = function()
+{
+ return this.getFullYear() + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2);
+};
+
+// Convert a date to UTC YYYYMMDDHHMM string format
+Date.prototype.convertToYYYYMMDDHHMM = function()
+{
+ return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2);
+};
+
+// Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
+Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
+{
+ return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),4);
+};
+
+// Static method to create a date from a UTC YYYYMMDDHHMM format string
+Date.convertFromYYYYMMDDHHMM = function(d)
+{
+ var hh = d.substr(8,2) || "00";
+ var mm = d.substr(10,2) || "00";
+ return new Date(Date.UTC(parseInt(d.substr(0,4),10),
+ parseInt(d.substr(4,2),10)-1,
+ parseInt(d.substr(6,2),10),
+ parseInt(hh,10),
+ parseInt(mm,10),0,0));
+};
+
+//--
+//-- Crypto functions and associated conversion routines
+//--
+
+// Crypto 'namespace'
+function Crypto() {}
+
+// Convert a string to an array of big-endian 32-bit words
+Crypto.strToBe32s = function(str)
+{
+ var be=[];
+ var len=Math.floor(str.length/4);
+ var i, j;
+ for(i=0, j=0; i<len; i++, j+=4) {
+ be[i]=((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
+ }
+ while(j<str.length) {
+ be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
+ j++;
+ }
+ return be;
+};
+
+// Convert an array of big-endian 32-bit words to a string
+Crypto.be32sToStr = function(be)
+{
+ var str='';
+ for(var i=0;i<be.length*32;i+=8) {
+ str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
+ }
+ return str;
+};
+
+// Convert an array of big-endian 32-bit words to a hex string
+Crypto.be32sToHex = function(be)
+{
+ var hex='0123456789ABCDEF';
+ var str='';
+ for(var i=0;i<be.length*4;i++) {
+ str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
+ }
+ return str;
+};
+
+// Return, in hex, the SHA-1 hash of a string
+Crypto.hexSha1Str = function(str)
+{
+ return Crypto.be32sToHex(Crypto.sha1Str(str));
+};
+
+// Return the SHA-1 hash of a string
+Crypto.sha1Str = function(str)
+{
+ return Crypto.sha1(Crypto.strToBe32s(str),str.length);
+};
+
+// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
+Crypto.sha1 = function(x,blen)
+{
+ // Add 32-bit integers, wrapping at 32 bits
+ function add32(a,b)
+ {
+ var lsw=(a&0xFFFF)+(b&0xFFFF);
+ var msw=(a>>16)+(b>>16)+(lsw>>16);
+ return (msw<<16)|(lsw&0xFFFF);
+ }
+ function AA(a,b,c,d,e)
+ {
+ b=(b>>>27)|(b<<5);
+ var lsw=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
+ var msw=(a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
+ return (msw<<16)|(lsw&0xFFFF);
+ }
+ function RR(w,j)
+ {
+ var n=w[j-3]^w[j-8]^w[j-14]^w[j-16];
+ return (n>>>31)|(n<<1);
+ }
+
+ var len=blen*8;
+ x[len>>5] |= 0x80 << (24-len%32);
+ x[((len+64>>9)<<4)+15]=len;
+ var w=new Array(80);
+
+ var k1=0x5A827999;
+ var k2=0x6ED9EBA1;
+ var k3=0x8F1BBCDC;
+ var k4=0xCA62C1D6;
+
+ var h0=0x67452301;
+ var h1=0xEFCDAB89;
+ var h2=0x98BADCFE;
+ var h3=0x10325476;
+ var h4=0xC3D2E1F0;
+
+ for(var i=0;i<x.length;i+=16) {
+ var j=0;
+ var t;
+ var a=h0;
+ var b=h1;
+ var c=h2;
+ var d=h3;
+ var e=h4;
+ while(j<16) {
+ w[j]=x[i+j];
+ t=AA(e,a,d^(b&(c^d)),w[j],k1);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<20) {
+ w[j]=RR(w,j);
+ t=AA(e,a,d^(b&(c^d)),w[j],k1);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<40) {
+ w[j]=RR(w,j);
+ t=AA(e,a,b^c^d,w[j],k2);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<60) {
+ w[j]=RR(w,j);
+ t=AA(e,a,(b&c)|(d&(b|c)),w[j],k3);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<80) {
+ w[j]=RR(w,j);
+ t=AA(e,a,b^c^d,w[j],k4);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ h0=add32(h0,a);
+ h1=add32(h1,b);
+ h2=add32(h2,c);
+ h3=add32(h3,d);
+ h4=add32(h4,e);
+ }
+ return [h0,h1,h2,h3,h4];
+};
+
+//--
+//-- RGB colour object
+//--
+
+// Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values
+function RGB(r,g,b)
+{
+ this.r = 0;
+ this.g = 0;
+ this.b = 0;
+ if(typeof r == "string") {
+ if(r.substr(0,1) == "#") {
+ if(r.length == 7) {
+ this.r = parseInt(r.substr(1,2),16)/255;
+ this.g = parseInt(r.substr(3,2),16)/255;
+ this.b = parseInt(r.substr(5,2),16)/255;
+ } else {
+ this.r = parseInt(r.substr(1,1),16)/15;
+ this.g = parseInt(r.substr(2,1),16)/15;
+ this.b = parseInt(r.substr(3,1),16)/15;
+ }
+ } else {
+ var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/;
+ var c = r.match(rgbPattern);
+ if(c) {
+ this.r = parseInt(c[1],10)/255;
+ this.g = parseInt(c[2],10)/255;
+ this.b = parseInt(c[3],10)/255;
+ }
+ }
+ } else {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ }
+ return this;
+}
+
+// Mixes this colour with another in a specified proportion
+// c = other colour to mix
+// f = 0..1 where 0 is this colour and 1 is the new colour
+// Returns an RGB object
+RGB.prototype.mix = function(c,f)
+{
+ return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f);
+};
+
+// Return an rgb colour as a #rrggbb format hex string
+RGB.prototype.toString = function()
+{
+ return "#" + ("0" + Math.floor(this.r.clamp(0,1) * 255).toString(16)).right(2) +
+ ("0" + Math.floor(this.g.clamp(0,1) * 255).toString(16)).right(2) +
+ ("0" + Math.floor(this.b.clamp(0,1) * 255).toString(16)).right(2);
+};
+
+//--
+//-- DOM utilities - many derived from www.quirksmode.org
+//--
+
+function drawGradient(place,horiz,locolors,hicolors)
+{
+ if(!hicolors)
+ hicolors = locolors;
+ for(var t=0; t<= 100; t+=2) {
+ var bar = document.createElement("div");
+ place.appendChild(bar);
+ bar.style.position = "absolute";
+ bar.style.left = horiz ? t + "%" : 0;
+ bar.style.top = horiz ? 0 : t + "%";
+ bar.style.width = horiz ? (101-t) + "%" : "100%";
+ bar.style.height = horiz ? "100%" : (101-t) + "%";
+ bar.style.zIndex = -1;
+ var p = t/100*(locolors.length-1);
+ var hc = hicolors[Math.floor(p)];
+ if(typeof hc == "string")
+ hc = new RGB(hc);
+ var lc = locolors[Math.ceil(p)];
+ if(typeof lc == "string")
+ lc = new RGB(lc);
+ bar.style.backgroundColor = hc.mix(lc,p-Math.floor(p)).toString();
+ }
+}
+
+function createTiddlyText(parent,text)
+{
+ return parent.appendChild(document.createTextNode(text));
+}
+
+function createTiddlyCheckbox(parent,caption,checked,onChange)
+{
+ var cb = document.createElement("input");
+ cb.setAttribute("type","checkbox");
+ cb.onclick = onChange;
+ parent.appendChild(cb);
+ cb.checked = checked;
+ cb.className = "chkOptionInput";
+ if(caption)
+ wikify(caption,parent);
+ return cb;
+}
+
+function createTiddlyElement(parent,element,id,className,text,attribs)
+{
+ var e = document.createElement(element);
+ if(className != null)
+ e.className = className;
+ if(id != null)
+ e.setAttribute("id",id);
+ if(text != null)
+ e.appendChild(document.createTextNode(text));
+ if(attribs) {
+ for(var n in attribs) {
+ e.setAttribute(n,attribs[n]);
+ }
+ }
+ if(parent != null)
+ parent.appendChild(e);
+ return e;
+}
+
+function addEvent(obj,type,fn)
+{
+ if(obj.attachEvent) {
+ obj['e'+type+fn] = fn;
+ obj[type+fn] = function(){obj['e'+type+fn](window.event);};
+ obj.attachEvent('on'+type,obj[type+fn]);
+ } else {
+ obj.addEventListener(type,fn,false);
+ }
+}
+
+function removeEvent(obj,type,fn)
+{
+ if(obj.detachEvent) {
+ obj.detachEvent('on'+type,obj[type+fn]);
+ obj[type+fn] = null;
+ } else {
+ obj.removeEventListener(type,fn,false);
+ }
+}
+
+function addClass(e,className)
+{
+ var currClass = e.className.split(" ");
+ if(currClass.indexOf(className) == -1)
+ e.className += " " + className;
+}
+
+function removeClass(e,className)
+{
+ var currClass = e.className.split(" ");
+ var i = currClass.indexOf(className);
+ while(i != -1) {
+ currClass.splice(i,1);
+ i = currClass.indexOf(className);
+ }
+ e.className = currClass.join(" ");
+}
+
+function hasClass(e,className)
+{
+ if(e.className && e.className.split(" ").indexOf(className) != -1) {
+ return true;
+ }
+ return false;
+}
+
+// Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode)
+function findRelated(e,value,name,relative)
+{
+ name = name || "tagName";
+ relative = relative || "parentNode";
+ if(name == "className") {
+ while(e && !hasClass(e,value)) {
+ e = e[relative];
+ }
+ } else {
+ while(e && e[name] != value) {
+ e = e[relative];
+ }
+ }
+ return e;
+}
+
+// Resolve the target object of an event
+function resolveTarget(e)
+{
+ var obj;
+ if(e.target)
+ obj = e.target;
+ else if(e.srcElement)
+ obj = e.srcElement;
+ if(obj.nodeType == 3) // defeat Safari bug
+ obj = obj.parentNode;
+ return obj;
+}
+
+// Prevent an event from bubbling
+function stopEvent(e)
+{
+ var ev = e || window.event;
+ ev.cancelBubble = true;
+ if(ev.stopPropagation) ev.stopPropagation();
+ return false;
+}
+
+// Return the content of an element as plain text with no formatting
+function getPlainText(e)
+{
+ var text = "";
+ if(e.innerText)
+ text = e.innerText;
+ else if(e.textContent)
+ text = e.textContent;
+ return text;
+}
+
+// Get the scroll position for window.scrollTo necessary to scroll a given element into view
+function ensureVisible(e)
+{
+ var posTop = findPosY(e);
+ var posBot = posTop + e.offsetHeight;
+ var winTop = findScrollY();
+ var winHeight = findWindowHeight();
+ var winBot = winTop + winHeight;
+ if(posTop < winTop) {
+ return posTop;
+ } else if(posBot > winBot) {
+ if(e.offsetHeight < winHeight)
+ return posTop - (winHeight - e.offsetHeight);
+ else
+ return posTop;
+ } else {
+ return winTop;
+ }
+}
+
+// Get the current width of the display window
+function findWindowWidth()
+{
+ return window.innerWidth || document.documentElement.clientWidth;
+}
+
+// Get the current height of the display window
+function findWindowHeight()
+{
+ return window.innerHeight || document.documentElement.clientHeight;
+}
+
+// Get the current horizontal page scroll position
+function findScrollX()
+{
+ return window.scrollX || document.documentElement.scrollLeft;
+}
+
+// Get the current vertical page scroll position
+function findScrollY()
+{
+ return window.scrollY || document.documentElement.scrollTop;
+}
+
+function findPosX(obj)
+{
+ var curleft = 0;
+ while(obj.offsetParent) {
+ curleft += obj.offsetLeft;
+ obj = obj.offsetParent;
+ }
+ return curleft;
+}
+
+function findPosY(obj)
+{
+ var curtop = 0;
+ while(obj.offsetParent) {
+ curtop += obj.offsetTop;
+ obj = obj.offsetParent;
+ }
+ return curtop;
+}
+
+// Blur a particular element
+function blurElement(e)
+{
+ if(e && e.focus && e.blur) {
+ e.focus();
+ e.blur();
+ }
+}
+
+// Create a non-breaking space
+function insertSpacer(place)
+{
+ var e = document.createTextNode(String.fromCharCode(160));
+ if(place)
+ place.appendChild(e);
+ return e;
+}
+
+// Remove all children of a node
+function removeChildren(e)
+{
+ while(e && e.hasChildNodes())
+ removeNode(e.firstChild);
+}
+
+// Remove a node and all it's children
+function removeNode(e)
+{
+ scrubNode(e);
+ e.parentNode.removeChild(e);
+}
+
+// Remove any event handlers or non-primitve custom attributes
+function scrubNode(e)
+{
+ if(!config.browser.isIE)
+ return;
+ var att = e.attributes;
+ if(att) {
+ for(var t=0; t<att.length; t++) {
+ var n = att[t].name;
+ if(n !== 'style' && (typeof e[n] === 'function' || (typeof e[n] === 'object' && e[n] != null))) {
+ try {
+ e[n] = null;
+ } catch(ex) {
+ }
+ }
+ }
+ }
+ var c = e.firstChild;
+ while(c) {
+ scrubNode(c);
+ c = c.nextSibling;
+ }
+}
+
+// Add a stylesheet, replacing any previous custom stylesheet
+function setStylesheet(s,id,doc)
+{
+ if(!id)
+ id = "customStyleSheet";
+ if(!doc)
+ doc = document;
+ var n = doc.getElementById(id);
+ if(doc.createStyleSheet) {
+ // Test for IE's non-standard createStyleSheet method
+ if(n)
+ n.parentNode.removeChild(n);
+ // This failed without the &nbsp;
+ doc.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd","&nbsp;<style id='" + id + "'>" + s + "</style>");
+ } else {
+ if(n) {
+ n.replaceChild(doc.createTextNode(s),n.firstChild);
+ } else {
+ n = doc.createElement("style");
+ n.type = "text/css";
+ n.id = id;
+ n.appendChild(doc.createTextNode(s));
+ doc.getElementsByTagName("head")[0].appendChild(n);
+ }
+ }
+}
+
+function removeStyleSheet(id)
+{
+ var e = document.getElementById(id);
+ if(e)
+ e.parentNode.removeChild(e);
+}
+
+// Force the browser to do a document reflow when needed to workaround browser bugs
+function forceReflow()
+{
+ if(config.browser.isGecko) {
+ setStylesheet("body {top:0px;margin-top:0px;}","forceReflow");
+ setTimeout(function() {setStylesheet("","forceReflow");},1);
+ }
+}
+
+// Replace the current selection of a textarea or text input and scroll it into view
+function replaceSelection(e,text)
+{
+ if(e.setSelectionRange) {
+ var oldpos = e.selectionStart;
+ var isRange = e.selectionEnd > e.selectionStart;
+ e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionEnd);
+ e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + text.length);
+ var linecount = e.value.split('\n').length;
+ var thisline = e.value.substr(0,e.selectionStart).split('\n').length-1;
+ e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / linecount);
+ } else if(document.selection) {
+ var range = document.selection.createRange();
+ if(range.parentElement() == e) {
+ var isCollapsed = range.text == "";
+ range.text = text;
+ if(!isCollapsed) {
+ range.moveStart('character', -text.length);
+ range.select();
+ }
+ }
+ }
+}
+
+// Returns the text of the given (text) node, possibly merging subsequent text nodes
+function getNodeText(e)
+{
+ var t = "";
+ while(e && e.nodeName == "#text") {
+ t += e.nodeValue;
+ e = e.nextSibling;
+ }
+ return t;
+}
+
+// Returns true if the element e has a given ancestor element
+function isDescendant(e,ancestor)
+{
+ while(e) {
+ if(e === ancestor)
+ return true;
+ e = e.parentNode;
+ }
+ return false;
+}
+
+//--
+//-- LoaderBase and SaverBase
+//--
+
+function LoaderBase() {}
+
+LoaderBase.prototype.loadTiddler = function(store,node,tiddlers)
+{
+ var title = this.getTitle(store,node);
+ if(safeMode && store.isShadowTiddler(title))
+ return;
+ if(title) {
+ var tiddler = store.createTiddler(title);
+ this.internalizeTiddler(store,tiddler,title,node);
+ tiddlers.push(tiddler);
+ }
+};
+
+LoaderBase.prototype.loadTiddlers = function(store,nodes)
+{
+ var tiddlers = [];
+ for(var t = 0; t < nodes.length; t++) {
+ try {
+ this.loadTiddler(store,nodes[t],tiddlers);
+ } catch(ex) {
+ showException(ex,config.messages.tiddlerLoadError.format([this.getTitle(store,nodes[t])]));
+ }
+ }
+ return tiddlers;
+};
+
+function SaverBase() {}
+
+SaverBase.prototype.externalize = function(store)
+{
+ var results = [];
+ var tiddlers = store.getTiddlers("title");
+ for(var t = 0; t < tiddlers.length; t++) {
+ if(!tiddlers[t].doNotSave())
+ results.push(this.externalizeTiddler(store, tiddlers[t]));
+ }
+ return results.join("\n");
+};
+
+//--
+//-- TW21Loader (inherits from LoaderBase)
+//--
+
+function TW21Loader() {}
+
+TW21Loader.prototype = new LoaderBase();
+
+TW21Loader.prototype.getTitle = function(store,node)
+{
+ var title = null;
+ if(node.getAttribute) {
+ title = node.getAttribute("title");
+ if(!title)
+ title = node.getAttribute("tiddler");
+ }
+ if(!title && node.id) {
+ var lenPrefix = store.idPrefix.length;
+ if(node.id.substr(0,lenPrefix) == store.idPrefix)
+ title = node.id.substr(lenPrefix);
+ }
+ return title;
+};
+
+TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node)
+{
+ var e = node.firstChild;
+ var text = null;
+ if(node.getAttribute("tiddler")) {
+ text = getNodeText(e).unescapeLineBreaks();
+ } else {
+ while(e.nodeName!="PRE" && e.nodeName!="pre") {
+ e = e.nextSibling;
+ }
+ text = e.innerHTML.replace(/\r/mg,"").htmlDecode();
+ }
+ var modifier = node.getAttribute("modifier");
+ var c = node.getAttribute("created");
+ var m = node.getAttribute("modified");
+ var created = c ? Date.convertFromYYYYMMDDHHMM(c) : version.date;
+ var modified = m ? Date.convertFromYYYYMMDDHHMM(m) : created;
+ var tags = node.getAttribute("tags");
+ var fields = {};
+ var attrs = node.attributes;
+ for(var i = attrs.length-1; i >= 0; i--) {
+ var name = attrs[i].name;
+ if(attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
+ fields[name] = attrs[i].value.unescapeLineBreaks();
+ }
+ }
+ tiddler.assign(title,text,modifier,modified,tags,created,fields);
+ return tiddler;
+};
+
+//--
+//-- TW21Saver (inherits from SaverBase)
+//--
+
+function TW21Saver() {}
+
+TW21Saver.prototype = new SaverBase();
+
+TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
+{
+ try {
+ var extendedAttributes = "";
+ var usePre = config.options.chkUsePreForStorage;
+ store.forEachField(tiddler,
+ function(tiddler,fieldName,value) {
+ // don't store stuff from the temp namespace
+ if(typeof value != "string")
+ value = "";
+ if(!fieldName.match(/^temp\./))
+ extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
+ },true);
+ var created = tiddler.created;
+ var modified = tiddler.modified;
+ var attributes = tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
+ attributes += (usePre && created == version.date) ? "" :' created="' + created.convertToYYYYMMDDHHMM() + '"';
+ attributes += (usePre && modified == created) ? "" : ' modified="' + modified.convertToYYYYMMDDHHMM() +'"';
+ var tags = tiddler.getTags();
+ if(!usePre || tags)
+ attributes += ' tags="' + tags.htmlEncode() + '"';
+ return ('<div %0="%1"%2%3>%4</'+'div>').format([
+ usePre ? "title" : "tiddler",
+ tiddler.title.htmlEncode(),
+ attributes,
+ extendedAttributes,
+ usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode()
+ ]);
+ } catch (ex) {
+ throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
+ }
+};
+
+//]]>
+</script>
+<script id="jsdeprecatedArea" type="text/javascript">
+//<![CDATA[
+//--
+//-- Deprecated Tiddler code
+//--
+
+// @Deprecated: Use tiddlerToRssItem(tiddler,uri) instead
+Tiddler.prototype.toRssItem = function(uri)
+{
+ return tiddlerToRssItem(this,uri);
+};
+
+// @Deprecated: Use "<item>\n" + tiddlerToRssItem(tiddler,uri) + "\n</item>" instead
+Tiddler.prototype.saveToRss = function(uri)
+{
+ return "<item>\n" + tiddlerToRssItem(this,uri) + "\n</item>";
+};
+
+//]]>
+</script>
+<script id="jqueryArea" type="text/javascript">
+//<![CDATA[
+//]]>
+</script>
+<script type="text/javascript">
+//<![CDATA[
+if(useJavaSaver)
+ document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>");
+//]]>
+</script>
+<!--POST-SCRIPT-START-->
+<!--POST-SCRIPT-END-->
+</body>
+</html>
diff --git a/htmlview.py b/htmlview.py
new file mode 100755
index 0000000..c14a461
--- /dev/null
+++ b/htmlview.py
@@ -0,0 +1,27 @@
+import os
+import gtk
+import hulahop
+from sugar import env
+from sugar.activity import activity
+from path import path
+hulahop.startup(os.path.join(env.get_profile_path(), 'gecko'))
+
+from hulahop.webview import WebView
+
+BUNDLEPATH = path(activity.get_bundle_path()) / 'tw'
+DATAPATH = path(activity.get_activity_root()) / 'data'
+TESTFILE = BUNDLEPATH / 'slides.html'
+WORKFILE = 'file://' + DATAPATH / 'slides.html'
+
+class Htmlview(gtk.VBox):
+ def __init__(self):
+ gtk.VBox.__init__(self)
+ #vbox = gtk.VBox(False, 8)
+ wv = WebView()
+ print 'show', WORKFILE, path(WORKFILE).exists()
+ wv.load_uri(WORKFILE)
+ wv.show()
+ self.pack_start(wv, True, True, 0)
+ #self.add(wv)
+ self.show_all()
+
diff --git a/hulahop_test.py b/hulahop_test.py
new file mode 100755
index 0000000..24a3067
--- /dev/null
+++ b/hulahop_test.py
@@ -0,0 +1,22 @@
+import os
+import hulahop
+from sugar import env
+hulahop.startup(os.path.join(env.get_profile_path(), 'gecko'))
+
+from hulahop.webview import WebView
+
+import gtk
+
+win = gtk.Window(gtk.WINDOW_TOPLEVEL)
+win.set_size_request(800,600)
+win.connect('destroy', gtk.main_quit)
+wv = WebView()
+#wv.load_uri('file:///home/olpc/Activities/ShowNTell.activity/tw/simple.html')
+wv.load_uri('file:///home/olpc/Activities/ShowNTell.activity/tw/slides.html')
+wv.show()
+
+win.add(wv)
+
+win.show()
+gtk.main()
+
diff --git a/icons/Fileclose-2.0.svg b/icons/Fileclose-2.0.svg
new file mode 100755
index 0000000..e06f112
--- /dev/null
+++ b/icons/Fileclose-2.0.svg
@@ -0,0 +1,124 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
+[
+ <!ATTLIST svg
+ xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
+]>
+<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
+<svg
+ xml:space="preserve"
+ width="128pt"
+ height="128pt"
+ viewBox="0 0 507.946 507.946"
+ id="svg49"
+ sodipodi:version="0.27"
+ sodipodi:docname="/mnt/windows/Themes/Work/Blue-Sphere/fileclose-2.0.svg"
+ sodipodi:docbase="/mnt/windows/Themes/Work/Blue-Sphere/"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs
+ id="defs62">
+ <radialGradient
+ id="radialGradient93"
+ cx="218.9404"
+ cy="219.7715"
+ r="150.7063"
+ fx="218.9404"
+ fy="219.7715"
+ gradientUnits="userSpaceOnUse"
+ style="stroke:#000000;stroke-opacity:0.986014;stroke-width:0.981612;">
+ <stop
+ offset="0.000000"
+ style="stop-color:#25a6ca;stop-opacity:1;"
+ id="stop94" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#2ea6b9;stop-opacity:0.843137;"
+ id="stop95" />
+ </radialGradient>
+ <radialGradient
+ id="aigrd1"
+ cx="218.9404"
+ cy="219.7715"
+ r="150.7063"
+ fx="218.9404"
+ fy="219.7715"
+ gradientUnits="userSpaceOnUse"
+ style="stroke:#000000;stroke-opacity:0.986014;stroke-width:0.981612;">
+ <stop
+ offset="0"
+ style="stop-color:#73ffff;stroke:#000000;stroke-opacity:0.986014;stroke-width:0.981612;"
+ id="stop53" />
+ <stop
+ offset="0.2809"
+ style="stop-color:#2EA6B9;stroke:#000000;stroke-opacity:0.986014;stroke-width:0.981612;"
+ id="stop54" />
+ <stop
+ offset="1"
+ style="stop-color:#006b8b;stroke:#000000;stroke-opacity:0.986014;stroke-width:0.981612;"
+ id="stop55" />
+ </radialGradient>
+ <linearGradient
+ xlink:href="#aigrd1"
+ id="linearGradient91"
+ x1="-0.295723"
+ y1="-0.264591"
+ x2="0.622574"
+ y2="0.365762"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(0.996114,0,0,1.0039,0.496124,0.492186)"
+ spreadMethod="pad" />
+ <radialGradient
+ xlink:href="#aigrd1"
+ id="radialGradient92"
+ cx="-8.09344e-05"
+ cy="-7.68867e-05"
+ fx="-8.09344e-05"
+ fy="-7.68867e-05"
+ r="0.789127"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(1.06784,0,0,0.936469,0.342219,0.344712)"
+ spreadMethod="pad" />
+ </defs>
+ <sodipodi:namedview
+ id="base">
+ <sodipodi:guide
+ orientation="vertical"
+ position="66.018929"
+ id="sodipodi:guide127" />
+ <sodipodi:guide
+ orientation="horizontal"
+ position="91.861198"
+ id="sodipodi:guide20" />
+ <sodipodi:guide
+ orientation="horizontal"
+ position="31.293375"
+ id="sodipodi:guide21" />
+ <sodipodi:guide
+ orientation="vertical"
+ position="97.110413"
+ id="sodipodi:guide22" />
+ <sodipodi:guide
+ orientation="vertical"
+ position="34.927444"
+ id="sodipodi:guide23" />
+ </sodipodi:namedview>
+ <path
+ style="font-size:12;stroke:none;stroke-width:0.979268;stroke-opacity:0.986014;fill:#a4c9ee;fill-opacity:0.7;"
+ d="M134.757,263.776c0,66.739,54.298,121.04,121.039,121.04c66.739,0,121.039-54.301,121.039-121.04c0-66.741-54.3-121.039-121.039-121.039c-66.741,0-121.039,54.298-121.039,121.039z"
+ id="path51"
+ transform="matrix(1.89511,0,0,1.91236,-231.458,-247.971)" />
+ <path
+ style="font-size:12;fill:url(#radialGradient92);fill-rule:evenodd;stroke:#1c6671;stroke-width:7.72505;stroke-opacity:0.988235;"
+ d="M356.643,263.366c0,57.027-46.23,103.257-103.256,103.257c-57.027,0-103.256-46.229-103.256-103.257c0-57.027,46.229-103.256,103.256-103.256 c57.025,0,103.256,46.229,103.256,103.256z"
+ id="path56"
+ transform="matrix(2.04451,0,0,2.04451,-264.353,-281.723)" />
+ <path
+ style="font-size:12;opacity:1.0;fill:#ffffff;stroke:#1c6772;stroke-width:7.9101;stroke-opacity:0.988235;fill-opacity:0.7;"
+ d="M 246.07 280.233 L 164.73 280.777 C 151.122 280.863 145.143 265.54 145.421 255.258 C 144.775 247.053 148.852 232.142 164.429 230.994 L 244.216 229.011 L 241.953 153.421 C 241.796 138.289 257.675 128.71 267.404 129.607 C 278.285 128.656 290.708 137.925 291.688 150.233 C 291.688 155.507 293.031 209.592 293.209 230.76 L 369.189 227.788 C 382.351 226.748 395.032 239.215 395.06 249.825 C 395.088 260.706 393.504 274.842 374.095 275.209 L 297.205 277.016 L 299.416 360.521 C 299.502 371.358 285.104 379.184 276.67 378.906 C 268.465 379.552 251.244 376.861 250.096 361.284 L 246.07 280.233 z "
+ id="path124"
+ sodipodi:nodetypes="ccccccccccccccccc"
+ transform="matrix(0.908402,-0.864764,0.864764,0.908402,-204.249,267.198)" />
+</svg>
diff --git a/icons/Filenew.svg b/icons/Filenew.svg
new file mode 100755
index 0000000..ba27ce2
--- /dev/null
+++ b/icons/Filenew.svg
@@ -0,0 +1,151 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
+[
+ <!ATTLIST svg
+ xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
+]>
+<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
+<svg
+ width="128pt"
+ height="128pt"
+ id="svg1"
+ sodipodi:version="0.27"
+ sodipodi:docname="/mnt/windows/themes/Work/Blue-Sphere/filenew.svg"
+ sodipodi:docbase="/mnt/windows/themes/Work/Blue-Sphere/"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs
+ id="defs22">
+ <linearGradient
+ id="linearGradient168">
+ <stop
+ offset="0.000000"
+ style="stop-color:#cdffff;stop-opacity:1;"
+ id="stop169" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#0c5d7d;stop-opacity:0.905882;"
+ id="stop170" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient90">
+ <stop
+ offset="0.000000"
+ style="stop-color:#cdffff;stop-opacity:1;"
+ id="stop91" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#006b97;stop-opacity:0.905882;"
+ id="stop92" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient67">
+ <stop
+ offset="0.000000"
+ style="stop-color:#d7ffff;stop-opacity:0.898039;"
+ id="stop70" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#2ea6b9;stop-opacity:0.952941;"
+ id="stop69" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient57">
+ <stop
+ offset="0.000000"
+ style="stop-color:#ffffff;stop-opacity:1;"
+ id="stop59" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#797979;stop-opacity:1;"
+ id="stop58" />
+ </linearGradient>
+ <defs
+ id="defs4">
+ <radialGradient
+ id="1"
+ cx="869.603027"
+ cy="1973.579956"
+ r="2106.649902"
+ fx="869.603027"
+ fy="1973.579956"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient67" />
+ </defs>
+ <defs
+ id="defs11">
+ <linearGradient
+ id="2"
+ x1="255.848"
+ y1="119.147"
+ x2="375.686"
+ y2="34.1009"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ offset="0"
+ style="stop-color:#ffffff"
+ id="stop13" />
+ <stop
+ offset="1"
+ style="stop-color:#000000"
+ id="stop14" />
+ </linearGradient>
+ </defs>
+ <defs
+ id="defs16">
+ <linearGradient
+ id="3"
+ x1="275.053009"
+ y1="109.384003"
+ x2="356.480988"
+ y2="30.864300"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient57" />
+ </defs>
+ <radialGradient
+ cx="3.03981e-14"
+ cy="1.05578e-10"
+ r="0.773346"
+ fx="3.03981e-14"
+ fy="1.05578e-10"
+ xlink:href="#linearGradient168"
+ id="radialGradient88"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(0.945877,0,0,1.05722,0.264368,0.249996)"
+ spreadMethod="pad" />
+ <linearGradient
+ x1="2.69643"
+ y1="1.14655"
+ x2="3.85147"
+ y2="0.623116"
+ xlink:href="#linearGradient67"
+ id="linearGradient89"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="translate(-2.65767,-0.201241)"
+ spreadMethod="pad" />
+ </defs>
+ <sodipodi:namedview
+ id="base" />
+ <path
+ style="font-size:12;fill:url(#radialGradient88);stroke:#0c5d7d;stroke-opacity:0.99;stroke-width:4.03585;"
+ d="M 35.399 39.1321L 277.219 39.1321L 377.219 137.984L 377.219 548.198L 35.399 548.198L 35.399 39.1321z"
+ id="path9"
+ transform="matrix(0.278752,0,0,0.284891,29.8322,1.63322)" />
+ <path
+ style="font-size:12;fill:#ffffff;fill-opacity:0.699301;stroke:#2ea6b9;stroke-width:8.96855;stroke-opacity:0.82;"
+ d="M 23.9471 20.1241L 265.767 20.1241L 365.767 120.124L 365.767 535.103L 23.9471 535.103L 23.9471 20.1241z"
+ id="path10"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#2);"
+ d="M 276.767 133.124L 365.767 120.124L 265.767 20.1241"
+ id="path15"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#linearGradient89);stroke:#2ea6b9;stroke-width:6.72641;stroke-opacity:0.91;"
+ d="M 265.767 120.124L 365.767 120.124L 265.767 20.1241L 265.767 120.124"
+ id="path20"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+</svg>
diff --git a/icons/Icon-move.svg b/icons/Icon-move.svg
new file mode 100755
index 0000000..a68267d
--- /dev/null
+++ b/icons/Icon-move.svg
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?xml-stylesheet href="icon-move_files/textshadow.css" media="all" type="text/css"?><!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="48px" height="48px" id="svg11300" _moz-textshadow-done="true" _moz-textshadow-init-cue="[]" _moz-textshadow-last-width="0">
+ <defs id="defs3">
+ <linearGradient inkscape:collect="always" id="linearGradient2240">
+ <stop style="stop-color: rgb(153, 176, 11); stop-opacity: 1;" offset="0" id="stop2242"/>
+ <stop style="stop-color: rgb(153, 176, 11); stop-opacity: 0;" offset="1" id="stop2244"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" id="linearGradient2232">
+ <stop style="stop-color: rgb(120, 134, 0); stop-opacity: 1;" offset="0" id="stop2234"/>
+
+ <stop style="stop-color: rgb(120, 134, 0); stop-opacity: 0;" offset="1" id="stop2236"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" id="linearGradient4991">
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 1;" offset="0" id="stop4993"/>
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0;" offset="1" id="stop4995"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" id="linearGradient8662">
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 1;" offset="0" id="stop8664"/>
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 0;" offset="1" id="stop8666"/>
+
+ </linearGradient>
+ <radialGradient inkscape:collect="always" xlink:href="#linearGradient8662" id="radialGradient8668" cx="24.837126" cy="36.421127" fx="24.837126" fy="36.421127" r="15.644737" gradientTransform="matrix(1, 0, 0, 0.536723, -5.82533e-14, 16.8731)" gradientUnits="userSpaceOnUse"/>
+ <linearGradient id="linearGradient2187" inkscape:collect="always">
+ <stop id="stop2189" offset="0" style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"/>
+ <stop id="stop2191" offset="1" style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2187" id="linearGradient1764" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.81347e-16, -1.17193, 1.17193, 1.81347e-16, 1.7828, 54.1011)" x1="17.060806" y1="11.39502" x2="12.624337" y2="12.583769"/>
+ <radialGradient inkscape:collect="always" xlink:href="#linearGradient4991" id="radialGradient4997" cx="16.563837" cy="11.132236" fx="16.563837" fy="11.132236" r="19.0625" gradientTransform="matrix(-0.0129013, 1.6852, 1.71308, 0.0131148, -1.0415, -10.1157)" gradientUnits="userSpaceOnUse"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2232" id="linearGradient2238" x1="33" y1="35.75" x2="31.5" y2="42.5" gradientUnits="userSpaceOnUse"/>
+
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2240" id="linearGradient2246" x1="33" y1="35.75" x2="31.5" y2="42.5" gradientUnits="userSpaceOnUse"/>
+ </defs>
+ <metadata id="metadata4">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"/>
+ <dc:title>Edit Redo</dc:title>
+
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>edit</rdf:li>
+ <rdf:li>redo</rdf:li>
+ <rdf:li>again</rdf:li>
+ <rdf:li>reapply</rdf:li>
+ </rdf:Bag>
+
+ </dc:subject>
+ </cc:Work>
+ <cc:License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/>
+
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer">
+ <path transform="matrix(1.48974, 0, 0, -1.00125, -12.6472, 75.3126)" d="M 40.481863 36.421127 A 15.644737 8.3968935 0 1 1 9.1923885,36.421127 A 15.644737 8.3968935 0 1 1 40.481863 36.421127 z" sodipodi:ry="8.3968935" sodipodi:rx="15.644737" sodipodi:cy="36.421127" sodipodi:cx="24.837126" id="path8660" style="overflow: visible; marker: none; opacity: 0.141176; color: rgb(0, 0, 0); fill: url(#radialGradient8668) rgb(0, 0, 0); fill-opacity: 1; fill-rule: evenodd; stroke: none; stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: inline;" sodipodi:type="arc"/>
+ <path style="overflow: visible; marker: none; opacity: 1; color: rgb(0, 0, 0); fill: url(#linearGradient2246) rgb(0, 0, 0); fill-opacity: 1; fill-rule: nonzero; stroke: url(#linearGradient2238) rgb(0, 0, 0); stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: block;" d="M 38.37476,45.034369 C -1.6510486,46.355509 4.6747954,12.29355 25.49479,12.49765 L 25.49479,3.1222396 L 42.143271,17.708819 L 25.49479,33.006349 C 25.49479,33.006349 25.49479,23.337969 25.49479,23.337969 C 11.43168,22.751999 7.3172614,44.770549 38.37476,45.034369 z " id="path1432" sodipodi:nodetypes="ccccccc"/>
+ <path sodipodi:nodetypes="ccccccc" id="path2177" d="M 16.92492,39.315519 C 5.2018204,33.235892 8.7371274,13.087489 26.5085,13.549959 L 26.5085,5.4508678 C 26.5085,5.4508678 40.556238,17.714589 40.556238,17.714589 L 26.5085,30.658617 C 26.5085,30.658617 26.5085,22.380979 26.5085,22.380979 C 11.66865,22.032709 12.34859,35.138579 16.92492,39.315519 z " style="overflow: visible; marker: none; opacity: 0.698864; color: rgb(0, 0, 0); fill: none; fill-opacity: 1; fill-rule: nonzero; stroke: url(#linearGradient1764) rgb(0, 0, 0); stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: block;"/>
+ <path style="overflow: visible; marker: none; opacity: 0.494318; color: rgb(0, 0, 0); fill: url(#radialGradient4997) rgb(0, 0, 0); fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1; visibility: visible; display: inline;" d="M 26.036989,4.5686095 L 36.723727,14.798241 C 29.786227,14.79824 32.036989,23.735424 25.911989,26.610424 L 25.974489,22.943609 C 10.786989,22.881109 11.661989,38.443609 22.724489,42.693609 C 3.6363414,37.811681 6.2869904,13.381109 25.911989,12.88111 L 26.036989,4.5686095 z " id="path4989" sodipodi:nodetypes="ccccccc"/>
+ </g>
+
+</svg>
diff --git a/icons/Icon-remove.svg b/icons/Icon-remove.svg
new file mode 100755
index 0000000..bb17023
--- /dev/null
+++ b/icons/Icon-remove.svg
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?xml-stylesheet href="List-remove_files/textshadow.css" media="all" type="text/css"?><!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="48px" height="48px" id="svg6431" sodipodi:version="0.32" inkscape:version="0.43+devel" sodipodi:docbase="/home/jimmac/src/cvs/tango-icon-theme/scalable/actions" sodipodi:docname="list-remove.svg" _moz-textshadow-done="true" _moz-textshadow-init-cue="[]" _moz-textshadow-last-width="0">
+ <defs id="defs6433">
+ <linearGradient inkscape:collect="always" id="linearGradient2091">
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 1;" offset="0" id="stop2093"/>
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 0;" offset="1" id="stop2095"/>
+ </linearGradient>
+ <radialGradient inkscape:collect="always" xlink:href="#linearGradient2091" id="radialGradient2097" cx="23.070683" cy="35.127438" fx="23.070683" fy="35.127438" r="10.319340" gradientTransform="matrix(0.914812, 0.0126502, -0.00821502, 0.213562, 2.25391, 27.1889)" gradientUnits="userSpaceOnUse"/>
+ <linearGradient id="linearGradient7916">
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 1;" offset="0" id="stop7918"/>
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0.340206;" offset="1.0000000" id="stop7920"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" id="linearGradient8662">
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 1;" offset="0" id="stop8664"/>
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 0;" offset="1" id="stop8666"/>
+ </linearGradient>
+ <radialGradient inkscape:collect="always" xlink:href="#linearGradient8662" id="radialGradient1503" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1, 0, 0, 0.536723, -1.01899e-13, 16.8731)" cx="24.837126" cy="36.421127" fx="24.837126" fy="36.421127" r="15.644737"/>
+ <linearGradient inkscape:collect="always" id="linearGradient2847">
+ <stop style="stop-color: rgb(52, 101, 164); stop-opacity: 1;" offset="0" id="stop2849"/>
+ <stop style="stop-color: rgb(52, 101, 164); stop-opacity: 0;" offset="1" id="stop2851"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2847" id="linearGradient1488" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-1, 0, 0, -1, -1.24248, 40.0817)" x1="37.128052" y1="29.729605" x2="37.065414" y2="26.194071"/>
+ <linearGradient id="linearGradient2831">
+ <stop style="stop-color: rgb(52, 101, 164); stop-opacity: 1;" offset="0" id="stop2833"/>
+ <stop id="stop2855" offset="0.33333334" style="stop-color: rgb(91, 134, 190); stop-opacity: 1;"/>
+ <stop style="stop-color: rgb(131, 168, 216); stop-opacity: 0;" offset="1" id="stop2835"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2831" id="linearGradient1486" gradientUnits="userSpaceOnUse" gradientTransform="translate(-48.305, -6.0433)" x1="13.478554" y1="10.612206" x2="15.419417" y2="19.115122"/>
+ <linearGradient id="linearGradient2380">
+ <stop style="stop-color: rgb(185, 207, 231); stop-opacity: 1;" offset="0" id="stop2382"/>
+ <stop style="stop-color: rgb(114, 159, 207); stop-opacity: 1;" offset="1" id="stop2384"/>
+ </linearGradient>
+ <linearGradient id="linearGradient2682">
+ <stop style="stop-color: rgb(57, 119, 195); stop-opacity: 1;" offset="0" id="stop2684"/>
+ <stop style="stop-color: rgb(137, 174, 220); stop-opacity: 0;" offset="1" id="stop2686"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2682" id="linearGradient2688" x1="36.713837" y1="31.455952" x2="37.124462" y2="24.842253" gradientUnits="userSpaceOnUse" gradientTransform="translate(-48.7704, -5.76571)"/>
+ <linearGradient inkscape:collect="always" id="linearGradient2690">
+ <stop style="stop-color: rgb(196, 215, 235); stop-opacity: 1;" offset="0" id="stop2692"/>
+ <stop style="stop-color: rgb(196, 215, 235); stop-opacity: 0;" offset="1" id="stop2694"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2690" id="linearGradient2696" x1="32.647972" y1="30.748846" x2="37.124462" y2="24.842253" gradientUnits="userSpaceOnUse" gradientTransform="translate(-48.7704, -5.76571)"/>
+ <linearGradient inkscape:collect="always" id="linearGradient2871">
+ <stop style="stop-color: rgb(52, 101, 164); stop-opacity: 1;" offset="0" id="stop2873"/>
+ <stop style="stop-color: rgb(52, 101, 164); stop-opacity: 1;" offset="1" id="stop2875"/>
+ </linearGradient>
+ <linearGradient id="linearGradient2402">
+ <stop style="stop-color: rgb(114, 159, 207); stop-opacity: 1;" offset="0" id="stop2404"/>
+ <stop style="stop-color: rgb(82, 138, 197); stop-opacity: 1;" offset="1" id="stop2406"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2797" id="linearGradient1493" gradientUnits="userSpaceOnUse" x1="5.9649176" y1="26.048164" x2="52.854097" y2="26.048164"/>
+ <linearGradient inkscape:collect="always" id="linearGradient2797">
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 1;" offset="0" id="stop2799"/>
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0;" offset="1" id="stop2801"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2797" id="linearGradient1491" gradientUnits="userSpaceOnUse" x1="5.9649176" y1="26.048164" x2="52.854097" y2="26.048164"/>
+ <linearGradient inkscape:collect="always" id="linearGradient7179">
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 1;" offset="0" id="stop7181"/>
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0;" offset="1" id="stop7183"/>
+ </linearGradient>
+ <linearGradient id="linearGradient2316">
+ <stop style="stop-color: rgb(0, 0, 0); stop-opacity: 1;" offset="0" id="stop2318"/>
+ <stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0.659794;" offset="1" id="stop2320"/>
+ </linearGradient>
+ <linearGradient id="linearGradient1322">
+ <stop id="stop1324" offset="0.0000000" style="stop-color: rgb(114, 159, 207);"/>
+ <stop id="stop1326" offset="1.0000000" style="stop-color: rgb(81, 135, 214); stop-opacity: 1;"/>
+ </linearGradient>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient1322" id="linearGradient4975" x1="34.892849" y1="36.422989" x2="45.918697" y2="48.547989" gradientUnits="userSpaceOnUse" gradientTransform="translate(-18.0179, -13.5712)"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient7179" id="linearGradient7185" x1="13.435029" y1="13.604306" x2="22.374878" y2="23.554308" gradientUnits="userSpaceOnUse"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient7179" id="linearGradient7189" gradientUnits="userSpaceOnUse" x1="13.435029" y1="13.604306" x2="22.374878" y2="23.554308" gradientTransform="matrix(-1, 0, 0, -1, 47.9393, 50.0247)"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2380" id="linearGradient7180" gradientUnits="userSpaceOnUse" x1="62.513836" y1="36.061237" x2="15.984863" y2="20.60858"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2871" id="linearGradient7182" gradientUnits="userSpaceOnUse" x1="46.834816" y1="45.264122" x2="45.380436" y2="50.939667"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2402" id="linearGradient7184" gradientUnits="userSpaceOnUse" x1="18.935766" y1="23.667896" x2="53.588622" y2="26.649362"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient2871" id="linearGradient7186" gradientUnits="userSpaceOnUse" x1="46.834816" y1="45.264122" x2="45.380436" y2="50.939667"/>
+ <linearGradient inkscape:collect="always" xlink:href="#linearGradient7916" id="linearGradient7922" x1="16.874998" y1="22.851799" x2="27.900846" y2="34.976799" gradientUnits="userSpaceOnUse"/>
+ </defs>
+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="0.10980392" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1" inkscape:cx="38.727739" inkscape:cy="26.974252" inkscape:current-layer="layer1" showgrid="false" inkscape:grid-bbox="true" inkscape:document-units="px" inkscape:window-width="1280" inkscape:window-height="949" inkscape:window-x="380" inkscape:window-y="79" inkscape:showpageshadow="false"/>
+ <metadata id="metadata6436">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:title>Remove</dc:title>
+ <dc:date>2006-01-04</dc:date>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Andreas Nilsson</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:source>http://tango-project.org</dc:source>
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>remove</rdf:li>
+ <rdf:li>delete</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"/>
+ </cc:Work>
+ <cc:License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/>
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer">
+ <path style="font-size: 59.9011px; font-style: normal; font-variant: normal; font-weight: bold; font-stretch: normal; text-align: start; line-height: 125%; text-anchor: start; fill: rgb(117, 161, 208); fill-opacity: 1; stroke: rgb(52, 101, 164); stroke-width: 1px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; font-family: Bitstream Vera Sans;" d="M 27.514356,28.359472 L 39.633445,28.475543 L 39.633445,21.480219 L 27.523285,21.480219 L 20.502546,21.462362 L 8.5441705,21.489147 L 8.5084565,28.457686 L 20.511475,28.475543 L 27.514356,28.359472 z " id="text1314" sodipodi:nodetypes="ccccccccc"/>
+ <path style="font-size: 59.9011px; font-style: normal; font-variant: normal; font-weight: bold; font-stretch: normal; text-align: start; line-height: 125%; text-anchor: start; opacity: 0.408602; fill: url(#linearGradient4975) rgb(0, 0, 0); fill-opacity: 1; stroke: url(#linearGradient7922) rgb(0, 0, 0); stroke-width: 1px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; font-family: Bitstream Vera Sans;" d="M 38.579429,27.484113 L 38.588357,22.475309 L 9.5267863,22.493166 L 9.5000003,27.466256 L 38.579429,27.484113 z " id="path7076" sodipodi:nodetypes="ccccc"/>
+ <path style="fill: rgb(255, 255, 255); fill-opacity: 1; fill-rule: evenodd; stroke: none; stroke-width: 1px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; opacity: 0.311828;" d="M 9.0000000,25.000000 C 9.0000000,26.937500 39.125000,24.062500 39.125000,25.000000 L 39.125000,22.000000 L 9.0000000,22.000000 L 9.0000000,25.000000 z " id="path7914" sodipodi:nodetypes="ccccc"/>
+ <path sodipodi:type="arc" style="opacity: 0.104396; fill: url(#radialGradient2097) rgb(0, 0, 0); fill-opacity: 1; stroke: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0pt; stroke-opacity: 1;" id="path1361" sodipodi:cx="22.958872" sodipodi:cy="34.94062" sodipodi:rx="10.31934" sodipodi:ry="2.320194" d="M 33.278212 34.94062 A 10.31934 2.320194 0 1 1 12.639532,34.94062 A 10.31934 2.320194 0 1 1 33.278212 34.94062 z" transform="matrix(2.32573, 0, 0, 1.293, -29.3961, -8.1782)" inkscape:r_cx="true" inkscape:r_cy="true"/>
+ </g>
+</svg> \ No newline at end of file
diff --git a/icons/activity-journal.svg b/icons/activity-journal.svg
new file mode 100755
index 0000000..8145b48
--- /dev/null
+++ b/icons/activity-journal.svg
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+
+ <!ENTITY stroke_color "#00FF00">
+ <!ENTITY fill_color "#0000FF">
+
+]>
+
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px"
+ height="54.696px" viewBox="0 0 55 54.696" enable-background="new 0 0 55 54.696" xml:space="preserve">
+
+<g id="Icon">
+ <path fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" d="M41.074,24.17v19.639
+ c0,2.407-1.467,4.153-4.154,4.153H8.676V6.733H36.92c2.062,0,4.154,2.066,4.154,4.152v1.073"/>
+
+ <line fill="none" stroke="&stroke_color;" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" x1="17.559" y1="6.848" x2="17.559" y2="47.848"/>
+ <path fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" d="M39.109,26.475
+ L51.988,9.862c0.027-0.027,0.178-0.236,0.178-0.236c0.109-0.193,0.178-0.41,0.178-0.658c0-0.07-0.004-0.143-0.014-0.215
+ c-0.104-0.896-0.848-1.992-1.947-2.857c-1.098-0.863-2.338-1.332-3.232-1.229c-0.389,0.045-0.938,0.447-0.938,0.447L33.504,22.042
+ l-2.479,3.225l-4.121,9.803c-0.049,0.125-0.018,0.268,0.082,0.354c0.105,0.086,0.254,0.098,0.365,0.023l9.285-5.975
+ c0.014-0.014,0.012-0.039,0.029-0.053c0.078-0.061,0.168-0.111,0.229-0.188c0.008-0.012,0.041-0.053,0.047-0.062L39.109,26.475z"/>
+ <path fill="none" stroke="&stroke_color;" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" d="M4.177,14.848
+ c0,0,1.999,0.667,3.999,0.667s4.001-0.667,4.001-0.667"/>
+ <path fill="none" stroke="&stroke_color;" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" d="M4.177,27.848
+ c0,0,1.833,0.667,4.166,0.667s3.834-0.667,3.834-0.667"/>
+ <path fill="none" stroke="&stroke_color;" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round" d="M4.177,40.514
+ c0,0,1.665,0.667,4.332,0.667s3.668-0.667,3.668-0.667"/>
+</g>
+
+</svg>
diff --git a/icons/black-button.svg b/icons/black-button.svg
new file mode 100755
index 0000000..f84b016
--- /dev/null
+++ b/icons/black-button.svg
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="55"
+ height="55"
+ id="svg2389"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="black-button.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs2391">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective2397" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="8.4"
+ inkscape:cx="27.5"
+ inkscape:cy="27.5"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="760"
+ inkscape:window-height="667"
+ inkscape:window-x="110"
+ inkscape:window-y="67" />
+ <metadata
+ id="metadata2394">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2399"
+ sodipodi:cx="27.380953"
+ sodipodi:cy="27.559525"
+ sodipodi:rx="0"
+ sodipodi:ry="0.05952381"
+ d="M 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 z" />
+ <path
+ style="fill:#000000"
+ d="M 27.08663,6.8664607 C 27.297968,6.8401619 27.672968,6.8397298 27.919964,6.8655 C 28.166961,6.8912714 27.994048,6.9127881 27.535714,6.9133167 C 27.077381,6.9138452 26.875293,6.8927595 27.086631,6.8664607 L 27.08663,6.8664607 z"
+ id="path2383" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000"
+ id="path2387"
+ sodipodi:cx="36.607143"
+ sodipodi:cy="14.821428"
+ sodipodi:rx="10.773809"
+ sodipodi:ry="12.202381"
+ d="M 47.380953,14.821428 A 10.773809,12.202381 0 1 1 25.833334,14.821428 A 10.773809,12.202381 0 1 1 47.380953,14.821428 z"
+ transform="matrix(2.0883978,0,0,1.8439024,-48.950278,0.1707317)" />
+ </g>
+</svg>
diff --git a/icons/blue-button.svg b/icons/blue-button.svg
new file mode 100755
index 0000000..451f0a6
--- /dev/null
+++ b/icons/blue-button.svg
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="55"
+ height="55"
+ id="svg2389"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="blue-button.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs2391">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective2397" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="8.4"
+ inkscape:cx="27.5"
+ inkscape:cy="27.5"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="640"
+ inkscape:window-height="667"
+ inkscape:window-x="110"
+ inkscape:window-y="67" />
+ <metadata
+ id="metadata2394">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2399"
+ sodipodi:cx="27.380953"
+ sodipodi:cy="27.559525"
+ sodipodi:rx="0"
+ sodipodi:ry="0.05952381"
+ d="M 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 z" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2401"
+ sodipodi:cx="35"
+ sodipodi:cy="34.82143"
+ sodipodi:rx="15.714286"
+ sodipodi:ry="16.488094"
+ d="M 50.714286,34.82143 A 15.714286,16.488094 0 1 1 19.285714,34.82143 A 15.714286,16.488094 0 1 1 50.714286,34.82143 z"
+ transform="matrix(1.388888,0,0,1.3107093,-21.111081,-17.926485)" />
+ </g>
+</svg>
diff --git a/icons/choose.svg b/icons/choose.svg
new file mode 100755
index 0000000..2fc648e
--- /dev/null
+++ b/icons/choose.svg
@@ -0,0 +1,191 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
+[
+ <!ATTLIST svg
+ xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
+]>
+<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
+<svg
+ width="128pt"
+ height="128pt"
+ id="svg1"
+ sodipodi:version="0.27"
+ sodipodi:docname="/mnt/windows/Themes/Work/Blue-Sphere/documents-2.0.svg"
+ sodipodi:docbase="/mnt/windows/Themes/Work/Blue-Sphere/"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs
+ id="defs22">
+ <linearGradient
+ id="linearGradient1451">
+ <stop
+ offset="0.000000"
+ style="stop-color:#ffffff;stop-opacity:1;"
+ id="stop1453" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#000000;stop-opacity:1;"
+ id="stop1452" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient168">
+ <stop
+ offset="0.000000"
+ style="stop-color:#cdffff;stop-opacity:1;"
+ id="stop169" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#0c5d7d;stop-opacity:0.905882;"
+ id="stop170" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient90">
+ <stop
+ offset="0.000000"
+ style="stop-color:#cdffff;stop-opacity:1;"
+ id="stop91" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#006b97;stop-opacity:0.905882;"
+ id="stop92" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient67">
+ <stop
+ offset="0.000000"
+ style="stop-color:#d7ffff;stop-opacity:0.898039;"
+ id="stop70" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#2ea6b9;stop-opacity:0.952941;"
+ id="stop69" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient57">
+ <stop
+ offset="0.000000"
+ style="stop-color:#ffffff;stop-opacity:1;"
+ id="stop59" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#797979;stop-opacity:1;"
+ id="stop58" />
+ </linearGradient>
+ <defs
+ id="defs4">
+ <radialGradient
+ id="1"
+ cx="869.603027"
+ cy="1973.579956"
+ r="2106.649902"
+ fx="869.603027"
+ fy="1973.579956"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient67" />
+ </defs>
+ <defs
+ id="defs11">
+ <linearGradient
+ id="2"
+ x1="255.848007"
+ y1="119.147003"
+ x2="375.686005"
+ y2="34.100899"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient1451" />
+ </defs>
+ <defs
+ id="defs16">
+ <linearGradient
+ id="3"
+ x1="275.053009"
+ y1="109.384003"
+ x2="356.480988"
+ y2="30.864300"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient57" />
+ </defs>
+ <radialGradient
+ cx="3.03981e-14"
+ cy="1.05578e-10"
+ r="0.773346"
+ fx="3.03981e-14"
+ fy="1.05578e-10"
+ xlink:href="#linearGradient168"
+ id="radialGradient88"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(0.945877,0,0,1.05722,0.264368,0.249996)"
+ spreadMethod="pad" />
+ <linearGradient
+ x1="2.69643"
+ y1="1.14655"
+ x2="3.85147"
+ y2="0.623116"
+ xlink:href="#linearGradient67"
+ id="linearGradient89"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="translate(-2.65767,-0.201241)"
+ spreadMethod="pad" />
+ </defs>
+ <sodipodi:namedview
+ id="base" />
+ <g
+ id="g3506"
+ transform="matrix(0.748077,-0.297958,0.297958,0.748077,-29.854,26.0741)">
+ <path
+ style="font-size:12;fill:url(#radialGradient88);stroke:#0c5d7d;stroke-opacity:0.99;stroke-width:6.65354;"
+ d="M 35.399 39.1321L 277.219 39.1321L 377.219 137.984L 377.219 548.198L 35.399 548.198L 35.399 39.1321z"
+ id="path3507"
+ transform="matrix(0.277275,0,0,0.281917,30.3892,3.26382)" />
+ <path
+ style="font-size:12;fill:#ffffff;fill-opacity:0.699301;stroke:#2ea6b9;stroke-width:13.4528;stroke-opacity:0.82;"
+ d="M 23.9471 20.1241L 265.767 20.1241L 365.767 120.124L 365.767 535.103L 23.9471 535.103L 23.9471 20.1241z"
+ id="path3508"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#linearGradient89);stroke:#2ea6b9;stroke-width:13.4528;stroke-opacity:0.91;stroke-linejoin:round;"
+ d="M 265.767 120.124L 365.767 120.124L 265.767 20.1241L 265.767 120.124"
+ id="path3509"
+ transform="matrix(0.268657,0,0,0.268657,34.0292,6.47529)" />
+ </g>
+ <g
+ id="g3502"
+ transform="matrix(0.758327,-0.150101,0.150101,0.758327,18.5242,28.5251)">
+ <path
+ style="font-size:12;fill:url(#radialGradient88);stroke:#0c5d7d;stroke-opacity:0.99;stroke-width:6.65354;"
+ d="M 35.399 39.1321L 277.219 39.1321L 377.219 137.984L 377.219 548.198L 35.399 548.198L 35.399 39.1321z"
+ id="path3503"
+ transform="matrix(0.277275,0,0,0.281917,30.3892,3.26382)" />
+ <path
+ style="font-size:12;fill:#ffffff;fill-opacity:0.699301;stroke:#2ea6b9;stroke-width:13.4528;stroke-opacity:0.82;"
+ d="M 23.9471 20.1241L 265.767 20.1241L 365.767 120.124L 365.767 535.103L 23.9471 535.103L 23.9471 20.1241z"
+ id="path3504"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#linearGradient89);stroke:#2ea6b9;stroke-width:13.4528;stroke-opacity:0.91;stroke-linejoin:round;"
+ d="M 265.767 120.124L 365.767 120.124L 265.767 20.1241L 265.767 120.124"
+ id="path3505"
+ transform="matrix(0.268657,0,0,0.268657,34.0292,6.47529)" />
+ </g>
+ <g
+ id="g3498"
+ transform="matrix(0.753721,0,0,0.753721,57.4453,40.1596)">
+ <path
+ style="font-size:12;fill:url(#radialGradient88);stroke:#0c5d7d;stroke-opacity:0.99;stroke-width:6.65354;"
+ d="M 35.399 39.1321L 277.219 39.1321L 377.219 137.984L 377.219 548.198L 35.399 548.198L 35.399 39.1321z"
+ id="path9"
+ transform="matrix(0.277275,0,0,0.281917,30.3892,3.26382)" />
+ <path
+ style="font-size:12;fill:#ffffff;fill-opacity:0.699301;stroke:#2ea6b9;stroke-width:13.4528;stroke-opacity:0.82;"
+ d="M 23.9471 20.1241L 265.767 20.1241L 365.767 120.124L 365.767 535.103L 23.9471 535.103L 23.9471 20.1241z"
+ id="path10"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#linearGradient89);stroke:#2ea6b9;stroke-width:13.4528;stroke-opacity:0.91;stroke-linejoin:round;"
+ d="M 265.767 120.124L 365.767 120.124L 265.767 20.1241L 265.767 120.124"
+ id="path20"
+ transform="matrix(0.268657,0,0,0.268657,34.0292,6.47529)" />
+ </g>
+</svg>
diff --git a/icons/done.svg b/icons/done.svg
new file mode 100755
index 0000000..14d3b5d
--- /dev/null
+++ b/icons/done.svg
@@ -0,0 +1,263 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
+<svg
+ width="48pt"
+ height="48pt"
+ viewBox="0 0 256 256"
+ overflow="visible"
+ enable-background="new 0 0 256 256"
+ xml:space="preserve"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
+ xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ id="svg548"
+ sodipodi:version="0.32"
+ sodipodi:docname="/home/cschalle/gnome-themes-extras/Nuvola/icons/scalable/stock/stock_quit.svg"
+ sodipodi:docbase="/home/cschalle/gnome-themes-extras/Nuvola/icons/scalable/stock">
+ <defs
+ id="defs600" />
+ <sodipodi:namedview
+ id="base" />
+ <g
+ id="Layer_1"
+ stroke="#000000">
+ <path
+ fill="none"
+ stroke="none"
+ d="M256,256H0V0h256V256z"
+ id="path550" />
+ </g>
+ <g
+ id="Layer_2"
+ stroke="#000000">
+ <path
+ opacity="0.2"
+ stroke="none"
+ d="M11.285,130.645C11.285,198.111,66.174,253,133.643,253C201.11,253,256,198.111,256,130.645 C256,63.175,201.11,8.286,133.643,8.286C66.174,8.286,11.285,63.175,11.285,130.645z"
+ id="path552" />
+ <g
+ display="none"
+ id="g553">
+ <path
+ display="inline"
+ opacity="0.2"
+ stroke="none"
+ d="M133.429,53.076l8.095,6.894l83.157,70.817l-96.107,81.847 c0,0,0-30.299,0-34.207c-4.186-1.066-77.223-19.684-77.223-19.684v-56.355c0,0,73.011-18.221,77.223-19.272 c0-3.926,0-34.175,0-34.175L133.429,53.076z"
+ id="path554" />
+ <path
+ display="inline"
+ fill="#0066CC"
+ stroke="none"
+ d="M222.918,123.788L121.725,37.611v4.33c0,0,0,29.768,0,32.613 c-2.913,0.727-77.221,19.272-77.221,19.272v59.473c0,0,74.325,18.943,77.221,19.682c0,2.832,0,36.984,0,36.984L222.918,123.788z"
+ id="path555" />
+ <linearGradient
+ id="XMLID_1_"
+ gradientUnits="userSpaceOnUse"
+ x1="54.3604"
+ y1="123.7881"
+ x2="207.7148"
+ y2="123.7881">
+ <stop
+ offset="0"
+ style="stop-color:#3399FF"
+ id="stop557" />
+ <stop
+ offset="1"
+ style="stop-color:#99CCFF"
+ id="stop558" />
+ <a:midPointStop
+ offset="0"
+ style="stop-color:#3399FF"
+ id="midPointStop559" />
+ <a:midPointStop
+ offset="0.5"
+ style="stop-color:#3399FF"
+ id="midPointStop560" />
+ <a:midPointStop
+ offset="1"
+ style="stop-color:#99CCFF"
+ id="midPointStop561" />
+ </linearGradient>
+ <path
+ display="inline"
+ fill="url(#XMLID_1_)"
+ stroke="none"
+ d="M54.36,101.525l77.223-19.273v-23.3l38.065,32.418l38.066,32.417 l-38.066,32.417l-38.065,32.418V165.32L54.36,145.639V101.525z"
+ id="path562" />
+ <linearGradient
+ id="XMLID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="173.751"
+ y1="88.6768"
+ x2="158.657"
+ y2="103.7712">
+ <stop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="stop564" />
+ <stop
+ offset="0.2111"
+ style="stop-color:#FBFDFF"
+ id="stop565" />
+ <stop
+ offset="0.4061"
+ style="stop-color:#F0F8FF"
+ id="stop566" />
+ <stop
+ offset="0.5949"
+ style="stop-color:#DDEEFF"
+ id="stop567" />
+ <stop
+ offset="0.7797"
+ style="stop-color:#C3E1FF"
+ id="stop568" />
+ <stop
+ offset="0.9601"
+ style="stop-color:#A2D0FF"
+ id="stop569" />
+ <stop
+ offset="1"
+ style="stop-color:#99CCFF"
+ id="stop570" />
+ <a:midPointStop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="midPointStop571" />
+ <a:midPointStop
+ offset="0.7232"
+ style="stop-color:#FFFFFF"
+ id="midPointStop572" />
+ <a:midPointStop
+ offset="1"
+ style="stop-color:#99CCFF"
+ id="midPointStop573" />
+ </linearGradient>
+ <path
+ display="inline"
+ opacity="0.7"
+ fill="url(#XMLID_2_)"
+ stroke="none"
+ d="M133.546,69.178c0-1.388,0-2.702,0-3.847 c7.393,6.296,33.21,28.283,33.21,28.283s30.868,26.287,35.433,30.174c-1.435,1.222-8.027,6.836-16.618,14.152 C175.345,107.764,156.768,83.264,133.546,69.178z"
+ id="path574" />
+ </g>
+ <path
+ fill="#660000"
+ stroke="none"
+ d="M6.449,125.798c0,67.467,54.889,122.356,122.357,122.356 c67.468,0,122.357-54.889,122.357-122.356c0-67.469-54.89-122.358-122.357-122.358C61.338,3.44,6.449,58.33,6.449,125.798z"
+ id="path575" />
+ <path
+ fill="#660000"
+ stroke="none"
+ d="M128.807,5.44C62.441,5.44,8.449,59.433,8.449,125.798 c0,66.364,53.992,120.356,120.357,120.356s120.357-53.992,120.357-120.356C249.164,59.433,195.172,5.44,128.807,5.44z"
+ id="path576" />
+ <radialGradient
+ id="XMLID_3_"
+ cx="50.5859"
+ cy="55.0098"
+ r="259.5079"
+ fx="50.5859"
+ fy="55.0098"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ offset="0.0056"
+ style="stop-color:#FF9999"
+ id="stop578" />
+ <stop
+ offset="0.5843"
+ style="stop-color:#FF0000"
+ id="stop579" />
+ <stop
+ offset="1"
+ style="stop-color:#990000"
+ id="stop580" />
+ <a:midPointStop
+ offset="0.0056"
+ style="stop-color:#FF9999"
+ id="midPointStop581" />
+ <a:midPointStop
+ offset="0.5"
+ style="stop-color:#FF9999"
+ id="midPointStop582" />
+ <a:midPointStop
+ offset="0.5843"
+ style="stop-color:#FF0000"
+ id="midPointStop583" />
+ <a:midPointStop
+ offset="0.5"
+ style="stop-color:#FF0000"
+ id="midPointStop584" />
+ <a:midPointStop
+ offset="1"
+ style="stop-color:#990000"
+ id="midPointStop585" />
+ </radialGradient>
+ <path
+ fill="url(#XMLID_3_)"
+ stroke="none"
+ d="M14.449,125.798c0,63.157,51.199,114.356,114.357,114.356 s114.357-51.199,114.357-114.356c0-63.158-51.199-114.358-114.357-114.358S14.449,62.64,14.449,125.798z"
+ id="path586" />
+ <path
+ opacity="0.5"
+ fill="#FFFFFF"
+ stroke="none"
+ d="M17.449,129.813c0-63.158,51.199-114.358,114.357-114.358 c36.628,0,69.23,17.222,90.16,44.007c-20.735-29.068-54.733-48.022-93.16-48.022c-63.158,0-114.357,51.2-114.357,114.358 c0,26.53,9.037,50.946,24.196,70.348C25.301,177.439,17.449,154.543,17.449,129.813z"
+ id="path587" />
+ <linearGradient
+ id="XMLID_4_"
+ gradientUnits="userSpaceOnUse"
+ x1="127.5151"
+ y1="12.998"
+ x2="127.5151"
+ y2="101.9984">
+ <stop
+ offset="0.0056"
+ style="stop-color:#FFFFFF"
+ id="stop589" />
+ <stop
+ offset="1"
+ style="stop-color:#FF5656"
+ id="stop590" />
+ <a:midPointStop
+ offset="0.0056"
+ style="stop-color:#FFFFFF"
+ id="midPointStop591" />
+ <a:midPointStop
+ offset="0.5"
+ style="stop-color:#FFFFFF"
+ id="midPointStop592" />
+ <a:midPointStop
+ offset="1"
+ style="stop-color:#FF5656"
+ id="midPointStop593" />
+ </linearGradient>
+ <path
+ fill="url(#XMLID_4_)"
+ stroke="none"
+ d="M35.672,71.752C57.685,81.768,88.603,88,122.847,88 c39.413,0,74.42-8.256,96.512-21.033c-18.02-31.361-51.86-52.527-90.552-52.527C88.179,14.44,52.903,37.779,35.672,71.752z"
+ id="path594" />
+ <path
+ fill="#660000"
+ stroke="none"
+ d="M161.307,41.489v33.488c16.736,10.741,27.857,29.5,27.857,50.821 c0,33.281-27.076,60.356-60.357,60.356s-60.357-27.075-60.357-60.356c0-21.32,11.122-40.08,27.857-50.821V41.489 c-33.812,13.079-57.857,45.937-57.857,84.309c0,49.823,40.534,90.356,90.357,90.356s90.357-40.533,90.357-90.356 C219.164,87.426,195.119,54.568,161.307,41.489z"
+ id="path595" />
+ <path
+ fill="#FFFFFF"
+ stroke="none"
+ d="M164.307,45.986v27.361c16.799,11.406,27.857,30.661,27.857,52.451 c0,34.935-28.422,63.356-63.357,63.356s-63.357-28.421-63.357-63.356c0-21.791,11.059-41.045,27.857-52.451V45.986 c-30.527,13.632-51.857,44.277-51.857,79.813c0,48.168,39.188,87.356,87.357,87.356s87.357-39.188,87.357-87.356 C216.164,90.263,194.834,59.618,164.307,45.986z"
+ id="path596" />
+ <path
+ fill="#660000"
+ stroke="none"
+ d="M112.307,33c-1.657,0-3,1.246-3,2.783v122.435c0,1.537,1.343,2.782,3,2.782h33 c1.657,0,3-1.245,3-2.782V35.783c0-1.537-1.343-2.783-3-2.783H112.307z"
+ id="path597" />
+ <path
+ fill="#FFFFFF"
+ stroke="none"
+ d="M145.307,158.218h-33V35.783h33V158.218z"
+ id="path598" />
+ </g>
+</svg>
diff --git a/icons/green-button.svg b/icons/green-button.svg
new file mode 100755
index 0000000..404a745
--- /dev/null
+++ b/icons/green-button.svg
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="55"
+ height="55"
+ id="svg2389"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="green-button.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs2391">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective2397" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="8.4"
+ inkscape:cx="27.5"
+ inkscape:cy="27.5"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="640"
+ inkscape:window-height="667"
+ inkscape:window-x="110"
+ inkscape:window-y="67" />
+ <metadata
+ id="metadata2394">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2399"
+ sodipodi:cx="27.380953"
+ sodipodi:cy="27.559525"
+ sodipodi:rx="0"
+ sodipodi:ry="0.05952381"
+ d="M 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 z" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#00ff00;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2401"
+ sodipodi:cx="35"
+ sodipodi:cy="34.82143"
+ sodipodi:rx="15.714286"
+ sodipodi:ry="16.488094"
+ d="M 50.714286,34.82143 A 15.714286,16.488094 0 1 1 19.285714,34.82143 A 15.714286,16.488094 0 1 1 50.714286,34.82143 z"
+ transform="matrix(1.388888,0,0,1.3107093,-21.111081,-17.926485)" />
+ </g>
+</svg>
diff --git a/icons/locked.svg b/icons/locked.svg
new file mode 100755
index 0000000..99c2fd2
--- /dev/null
+++ b/icons/locked.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg version="1.0"
+ id="svg2" xmlns:svg="http://www.w3.org/2000/svg" inkscape:version="0.46" xmlns:dc="http://purl.org/dc/elements/1.1/" sodipodi:version="0.32" sodipodi:docname="locked.svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px" height="55px"
+ viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<defs>
+
+
+ <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" id="perspective10">
+ </inkscape:perspective>
+</defs>
+<sodipodi:namedview inkscape:window-y="6" inkscape:window-x="42" inkscape:window-height="667" inkscape:window-width="774" showgrid="false" inkscape:current-layer="layer1" inkscape:document-units="px" inkscape:cy="27.5" inkscape:cx="27.5" inkscape:zoom="8.4" inkscape:pageshadow="2" inkscape:pageopacity="0.0" objecttolerance="10" guidetolerance="10" gridtolerance="10000" borderopacity="1.0" bordercolor="#666666" pagecolor="#ffffff" id="base">
+ </sodipodi:namedview>
+<rect id="rect2405" x="10" y="25" fill="#FFFFFF" width="35" height="25"/>
+<g>
+ <g>
+ <path fill="#FFFFFF" d="M27.5,2.5C20.597,2.5,15,5.858,15,10v15h5V12.5h0.017C20.012,12.42,20,12.342,20,12.262
+ c0-2.891,3.36-5.238,7.5-5.238c4.141,0,7.5,2.347,7.5,5.238c0,0.081-0.012,0.159-0.018,0.238H35V25h5V10
+ C40,5.858,34.403,2.5,27.5,2.5z"/>
+ </g>
+</g>
+</svg>
diff --git a/icons/media-flash-sd-mmc.svg b/icons/media-flash-sd-mmc.svg
new file mode 100755
index 0000000..b5d37ad
--- /dev/null
+++ b/icons/media-flash-sd-mmc.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#010101">
+ <!ENTITY fill_color "#ffffff">
+]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="media-flash-sd-mmc">
+ <g display="inline">
+ <polygon fill="&fill_color;" points="35.914,3.5 8.913,3.5 8.913,19.251 10.992,19.251 10.992,28.77 8.913,28.77 8.913,51.5 45.836,51.5 45.836,22.051 44.119,22.051 44.119,19.368 45.836,19.368 45.836,13.423 " stroke="&stroke_color;" stroke-width="3.5"/>
+ <path d="M39.571,28.728c0,3.281-2.685,5.965-5.966,5.965H20.68c-3.28,0-5.965-2.684-5.965-5.965V15.733 c0-3.281,2.684-5.965,5.965-5.965h12.925c3.281,0,5.966,2.685,5.966,5.965V28.728z" fill="&stroke_color;"/>
+ </g>
+</g></svg> \ No newline at end of file
diff --git a/icons/media-flash-usb.svg b/icons/media-flash-usb.svg
new file mode 100755
index 0000000..2fd43a1
--- /dev/null
+++ b/icons/media-flash-usb.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#010101">
+ <!ENTITY fill_color "#ffffff">
+]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="media-flash-usb">
+ <g display="inline">
+ <path d="M15.885,16.723c-6.641,0-12.023,5.385-12.023,12.025 c0,6.639,5.383,12.023,12.023,12.023h0.014h27.259V16.723H15.899" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
+ <rect fill="&fill_color;" height="14.182" stroke="&stroke_color;" stroke-width="3.5" width="9.14" x="43.722" y="21.731"/>
+ </g>
+</g></svg> \ No newline at end of file
diff --git a/icons/new-slideshow.svg b/icons/new-slideshow.svg
new file mode 100644
index 0000000..2bda67c
--- /dev/null
+++ b/icons/new-slideshow.svg
@@ -0,0 +1,462 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ enable-background="new 0 0 55 55"
+ height="55px"
+ id="svg2972"
+ version="1.1"
+ viewBox="0 0 55 55"
+ width="55px"
+ x="0px"
+ xml:space="preserve"
+ y="0px"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="new-slideshow.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata2729"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs2727"><linearGradient
+ id="linearGradient96"><stop
+ offset="0.000000"
+ style="stop-color:#fbddb2;stop-opacity:0.992157;"
+ id="stop97" /><stop
+ offset="1.000000"
+ style="stop-color:#efa81a;stop-opacity:0.952941;"
+ id="stop98" /></linearGradient><radialGradient
+ xlink:href="#linearGradient96"
+ id="radialGradient95"
+ cx="3.9486481"
+ cy="21.445167"
+ fx="3.9486481"
+ fy="21.445167"
+ r="28.869786"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.2068054,0,0,0.2375171,41.430177,61.327763)"
+ spreadMethod="pad" /><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2399"><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
+ offset="0"
+ id="stop2401" /><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
+ offset="1"
+ id="stop2403" /></linearGradient><linearGradient
+ id="linearGradient2371"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2373" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0.484536;"
+ offset="1"
+ id="stop2375" /></linearGradient><linearGradient
+ id="linearGradient2407"><stop
+ style="stop-color: rgb(213, 213, 213); stop-opacity: 1;"
+ offset="0"
+ id="stop2409" /><stop
+ style="stop-color: rgb(116, 116, 116); stop-opacity: 1;"
+ offset="1"
+ id="stop2411" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2355"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2357" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
+ offset="1"
+ id="stop2359" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2337"><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
+ offset="0"
+ id="stop2339" /><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
+ offset="1"
+ id="stop2341" /></linearGradient><linearGradient
+ id="linearGradient2345"><stop
+ style="stop-color: rgb(213, 213, 213); stop-opacity: 1;"
+ offset="0"
+ id="stop2347" /><stop
+ style="stop-color: rgb(160, 160, 160); stop-opacity: 1;"
+ offset="1"
+ id="stop2349" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2252"><stop
+ style="stop-color: rgb(198, 198, 198); stop-opacity: 1;"
+ offset="0"
+ id="stop2254" /><stop
+ style="stop-color: rgb(198, 198, 198); stop-opacity: 0;"
+ offset="1"
+ id="stop2256" /></linearGradient><linearGradient
+ id="linearGradient2232"><stop
+ style="stop-color: rgb(176, 176, 176); stop-opacity: 1;"
+ offset="0"
+ id="stop2234" /><stop
+ style="stop-color: rgb(116, 116, 116); stop-opacity: 1;"
+ offset="1"
+ id="stop2236" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2242"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2244" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
+ offset="1"
+ id="stop2246" /></linearGradient><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 27.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="55 : 27.5 : 1"
+ inkscape:persp3d-origin="27.5 : 18.333333 : 1"
+ id="perspective2731" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2242"
+ id="radialGradient3194"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.425856,0,23.5399)"
+ cx="25.1875"
+ cy="41"
+ fx="25.1875"
+ fy="41"
+ r="16.4375" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2232"
+ id="radialGradient3196"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.52514,0,22.0217)"
+ cx="15.4375"
+ cy="42.090427"
+ fx="15.4375"
+ fy="42.090427"
+ r="11.1875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2252"
+ id="linearGradient3198"
+ gradientUnits="userSpaceOnUse"
+ x1="41.25"
+ y1="36.689548"
+ x2="48.25"
+ y2="35.689548" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2345"
+ id="radialGradient3200"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.49192,-8.44511e-2,-5.87441e-2,3.98672,-9.6468,-20.2759)"
+ cx="19.557497"
+ cy="6.644074"
+ fx="19.557497"
+ fy="6.644074"
+ r="10.98921" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2337"
+ id="radialGradient3202"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.53075,0,0,4.4512431,-28.91508,-14.647051)"
+ cx="20.275276"
+ cy="5.7119732"
+ fx="20.275276"
+ fy="5.7119732"
+ r="12.494026" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3204"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3206"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3208"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3210"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2407"
+ id="radialGradient3212"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.435326,0,0,0.435326,18.9166,12.4934)"
+ cx="33.499996"
+ cy="20.538168"
+ fx="33.499996"
+ fy="20.538168"
+ r="2.2697367" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3214"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3216"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-4.5961941,-0.3535534)"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3218"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3220"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3222"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3224"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2399"
+ id="linearGradient3226"
+ gradientUnits="userSpaceOnUse"
+ x1="16.4375"
+ y1="49.110714"
+ x2="17.402376"
+ y2="43.420425" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient96"
+ id="radialGradient2841"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.2068054,0,0,0.2375171,1.6418138e-3,20.50447)"
+ spreadMethod="pad"
+ cx="3.9486481"
+ cy="21.445167"
+ fx="3.9486481"
+ fy="21.445167"
+ r="28.869786" /></defs><sodipodi:namedview
+ inkscape:window-height="726"
+ inkscape:window-width="645"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="8.9818182"
+ inkscape:cx="27.5"
+ inkscape:cy="27.68773"
+ inkscape:window-x="449"
+ inkscape:window-y="25"
+ inkscape:current-layer="svg2972" />
+<g
+ id="g2709">
+ <g
+ id="g2711">
+ <path
+ d="M11.908,34.521c-0.516,0.1-1.012-0.219-1.108-0.712L7.72,17.94c-0.095-0.493,0.245-0.975,0.761-1.075 l21.5-4.173c0.515-0.1,1.013,0.219,1.106,0.713l1.029,5.306l0.049-0.044l5.024,1.097l-1.608-8.618 c-0.294-1.503-1.748-2.485-3.251-2.192L5.121,14.235c-1.503,0.292-2.485,1.747-2.193,3.249l3.697,19.048 c0.292,1.503,1.746,2.484,3.249,2.193l4.623-0.945l1.016-3.959L11.908,34.521z"
+ fill="#666666"
+ id="path2713" />
+ </g>
+</g>
+<path
+ d="M34.167,29.272c0.097,0.493-0.245,0.977-0.761,1.074l-21.497,4.174 c-0.517,0.1-1.014-0.219-1.109-0.712L7.72,17.94c-0.095-0.493,0.245-0.975,0.762-1.075l21.499-4.173 c0.515-0.1,1.013,0.219,1.106,0.713L34.167,29.272z"
+ fill="#ffffff"
+ id="path3554_1_" />
+<g
+ id="g2716">
+ <g
+ id="g2718">
+ <path
+ d="M49.668,23.2l-4.624-0.954l-2.055,2.779l3.032,0.669c0.515,0.113,0.843,0.603,0.734,1.096l-3.485,15.783 c-0.107,0.491-0.613,0.798-1.125,0.684l-21.385-4.723c-0.513-0.112-0.841-0.603-0.733-1.094l3.485-15.784 c0.109-0.491,0.613-0.798,1.127-0.684l11.574,2.556l2.365-2.785L22.602,17.22c-1.495-0.33-2.975,0.615-3.304,2.11l-4.185,18.944 c-0.331,1.496,0.614,2.977,2.109,3.307l27.064,5.977c1.495,0.33,2.973-0.612,3.304-2.108l4.188-18.946 C52.106,25.009,51.163,23.53,49.668,23.2z"
+ fill="#666666"
+ id="path2720" />
+ </g>
+</g>
+<path
+ d="M43.271,42.573c-0.107,0.491-0.613,0.798-1.125,0.684l-21.385-4.723 c-0.513-0.112-0.84-0.603-0.733-1.094l3.485-15.784c0.109-0.491,0.613-0.798,1.127-0.684l21.382,4.722 c0.515,0.113,0.843,0.603,0.734,1.096L43.271,42.573z"
+ fill="#ffffff"
+ id="path3560_1_" />
+<path
+ d="M53.008,10.631c0-0.045-0.002-0.093-0.009-0.141c-0.069-0.589-0.562-1.31-1.28-1.878 c-0.721-0.569-1.536-0.878-2.127-0.81c-0.257,0.032-0.461,0.142-0.602,0.304l-0.016-0.009L38.568,21.872l-0.047,0.046l-0.006,0.01 c-0.016,0.018-0.019,0.043-0.031,0.063l-1.351,1.663c0,0,0.078,0.061,0.158,0.125l-0.164-0.114l-0.025,0.033 c-0.061,0.074-0.097,0.168-0.124,0.267c-0.011,0.012-0.026,0.015-0.032,0.029l-0.848,2.01l2.546,2.037l1.987-1.281 c0.014-0.006,0.011-0.022,0.021-0.033c0.052-0.04,0.111-0.074,0.152-0.124c0.004-0.007,0.024-0.037,0.028-0.039l1.389-1.733 l0.022-0.021l-0.005-0.002l0.016-0.017l0.005,0.002l10.518-13.57c0.021-0.019,0.045-0.027,0.062-0.048 c0.022-0.027,0.031-0.064,0.047-0.094l0.013-0.012l-0.002-0.002C52.963,10.939,53.008,10.798,53.008,10.631z"
+ fill="#666666"
+ id="path3562" />
+<path
+ d="M33.625,31.123c0,0-6.7,4.055-7.934,2.555 c-1.235-1.498,0.353-2.995,1.146-2.995s3.791,2.291,1.675,4.585c-2.117,2.291-3.617,1.764-3.617,1.764"
+ fill="none"
+ id="path3564"
+ stroke="#666666"
+ stroke-width="1.009" />
+<path
+ d="M34.438,30.019c-0.032,0.083-0.012,0.176,0.057,0.232c0.067,0.058,0.164,0.064,0.238,0.016 l2.879-1.851l-1.869-1.497L34.438,30.019z"
+ fill="#666666"
+ id="path3566" />
+<g
+ inkscape:groupmode="layer"
+ id="layer1"
+ inkscape:label="microphone" /><g
+ id="g3105"
+ transform="matrix(0.5232537,0,0,0.4950076,4.3255858,4.694013)"><path
+ transform="matrix(1.10646,0,0,1.04464,-2.68156,-2.51786)"
+ d="M 41.625,41 A 16.4375,7 0 1 1 8.75,41 A 16.4375,7 0 1 1 41.625,41 z"
+ sodipodi:ry="7"
+ sodipodi:rx="16.4375"
+ sodipodi:cy="41"
+ sodipodi:cx="25.1875"
+ id="path2240"
+ style="opacity:0.49431799;fill:url(#radialGradient3194);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ transform="translate(8.75,-7)"
+ d="M 27.625,46.375 A 11.1875,5.875 0 1 1 5.25,46.375 A 11.1875,5.875 0 1 1 27.625,46.375 z"
+ sodipodi:ry="5.875"
+ sodipodi:rx="11.1875"
+ sodipodi:cy="46.375"
+ sodipodi:cx="16.4375"
+ id="path2222"
+ style="opacity:1;fill:url(#radialGradient3196);fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ sodipodi:type="arc"
+ style="opacity:1;fill:#424242;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="path2260"
+ sodipodi:cx="33.5"
+ sodipodi:cy="22.125"
+ sodipodi:rx="1.875"
+ sodipodi:ry="1.875"
+ d="M 35.375,22.125 A 1.875,1.875 0 1 1 31.625,22.125 A 1.875,1.875 0 1 1 35.375,22.125 z"
+ transform="matrix(2.06667,0,0,1.26667,-43.9833,9.475)" /><path
+ sodipodi:nodetypes="cszzc"
+ id="path2250"
+ d="M 20.25,31.375 C 20.25,31.375 20.985875,34.77724 23.25,34.5 C 29.375,33.75 28.721362,34.010493 33.125,35.375 C 37.5625,36.75 35.21875,38.96875 39.75,39.375 C 44.28125,39.78125 43.875,35.75 47.75,35.5"
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3198);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><rect
+ transform="matrix(0.970732,0.240164,-0.264014,0.964519,0,0)"
+ ry="6.6936979"
+ rx="6.6936979"
+ y="-4.0142608"
+ x="16.028919"
+ height="30.692028"
+ width="22.136791"
+ id="rect1343"
+ style="opacity:1;fill:url(#radialGradient3200);fill-opacity:1;fill-rule:evenodd;stroke:#7c7c7c;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><rect
+ style="opacity:0.30681799;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect2353"
+ width="19.862064"
+ height="28.524395"
+ x="17.210075"
+ y="-3.006144"
+ rx="5.4198565"
+ ry="5.4198565"
+ transform="matrix(0.970732,0.240164,-0.264014,0.964519,0,0)" /><path
+ sodipodi:nodetypes="cccsccsssssssssssssssssssssssscccsccssssssssssssssssssssssssssssssccccsccssssssssssssssssssssssssssssssccccccccssssssssscccsssssssssssssssssssssssssccccssccccsccssssssssssssssssssssssssssscccsssssssssssssssssssssssccccssccccsccssssssssssssssssssssssssssscccssssssssssssssssssssssssscccccssssssssssssssssssssssscccccssssssssssssssssssssssssccc"
+ id="rect2302"
+ d="M 22.21507,2.1586646 C 19.993982,2.8419631 18.064553,6.11263 17.43382,10.579833 L 12.59007,45.173267 C 15.447016,47.895386 19.22768,46.082026 22.80882,46.082026 C 23.298828,46.082026 23.796888,46.07907 24.27757,46.021442 C 23.342429,45.580269 21.96507,44.930931 21.96507,44.930931 C 21.745207,44.815494 21.543886,44.668833 21.40257,44.44626 C 21.397838,44.438383 21.375909,44.39376 21.37132,44.385676 C 21.357994,44.360785 21.324385,44.295981 21.30882,44.264508 C 21.303164,44.253775 21.283185,44.214717 21.27757,44.203924 C 21.269347,44.17318 21.252624,44.106823 21.24632,44.082756 C 21.236648,44.035572 21.221593,43.943297 21.21507,43.901004 C 21.215266,43.894996 21.215009,43.845726 21.21507,43.84042 C 21.209239,43.819517 21.189444,43.740465 21.18382,43.719252 C 21.183891,43.707349 21.183867,43.666419 21.18382,43.658668 C 21.18405,43.624034 21.183787,43.559844 21.18382,43.537501 C 21.183714,43.525781 21.183503,43.483954 21.18382,43.476917 C 21.183711,43.470779 21.183831,43.421712 21.18382,43.416333 C 21.19194,43.346104 21.208482,43.235098 21.21507,43.173997 C 21.220328,43.154096 21.240474,43.074649 21.24632,43.052829 C 21.246321,43.047286 21.246583,42.998208 21.24632,42.992245 C 21.253935,42.94461 21.268644,42.853675 21.27757,42.810493 C 21.285643,42.77858 21.303721,42.708776 21.30882,42.689325 C 21.333585,42.601792 21.372075,42.461188 21.40257,42.386406 C 21.40899,42.373833 21.429561,42.334084 21.43382,42.325822 C 21.445069,42.315137 21.486035,42.274931 21.49632,42.265238 C 21.524876,42.231985 21.585658,42.172766 21.62132,42.14407 C 21.632197,42.144368 21.672839,42.143459 21.68382,42.14407 C 21.683639,42.140685 21.683766,42.097088 21.68382,42.083486 C 21.690832,42.083373 21.713299,42.083086 21.71507,42.083486 C 21.889903,42.020149 22.111554,42.070233 22.34007,42.14407 L 28.27757,44.809763 C 29.467865,44.245328 30.604797,43.471628 31.68382,42.568157 C 31.531417,42.401171 31.366355,42.295101 31.21507,42.204654 C 31.177701,42.183677 31.127179,42.159215 31.09007,42.14407 C 31.09007,42.14407 22.87132,38.266697 22.87132,38.266697 C 22.651457,38.15126 22.427107,38.004598 22.27757,37.782026 C 22.272566,37.774149 22.251168,37.729526 22.24632,37.721442 C 22.2418,37.712927 22.21942,37.669595 22.21507,37.660858 C 22.210895,37.651893 22.187815,37.609471 22.18382,37.600274 C 22.178403,37.579671 22.157552,37.500265 22.15257,37.479106 C 22.146868,37.468439 22.126971,37.429254 22.12132,37.418522 C 22.121633,37.412336 22.121228,37.363289 22.12132,37.357938 C 22.11559,37.336837 22.095572,37.258158 22.09007,37.23677 C 22.090241,37.230762 22.090012,37.181492 22.09007,37.176186 C 22.090039,37.155283 22.089851,37.076231 22.09007,37.055018 C 22.089341,37.013278 22.088401,36.917953 22.09007,36.873266 C 22.090112,36.866413 22.090209,36.820365 22.09007,36.812682 C 22.089362,36.787466 22.089223,36.712956 22.09007,36.691515 C 22.089926,36.684857 22.090092,36.636417 22.09007,36.630931 C 22.095814,36.609316 22.11599,36.52989 22.12132,36.509763 C 22.130109,36.455805 22.142957,36.377263 22.15257,36.328011 C 22.157874,36.307389 22.178287,36.227637 22.18382,36.206843 C 22.200943,36.136412 22.228197,36.025446 22.24632,35.964507 C 22.26074,35.92387 22.2912,35.828179 22.30882,35.782755 C 22.313398,35.773306 22.335401,35.731208 22.34007,35.722171 C 22.346487,35.709599 22.367062,35.66985 22.37132,35.661587 C 22.382613,35.650901 22.423566,35.610697 22.43382,35.601003 C 22.449712,35.584996 22.483754,35.552265 22.49632,35.54042 C 22.504834,35.533035 22.542255,35.495766 22.55882,35.479836 C 22.561977,35.480309 22.587322,35.479698 22.59007,35.479836 C 22.59435,35.471614 22.614803,35.431737 22.62132,35.419252 C 22.6241,35.419364 22.649316,35.418932 22.65257,35.419252 C 22.659723,35.405642 22.682489,35.362064 22.68382,35.358668 C 22.687075,35.358978 22.71229,35.358555 22.71507,35.358668 C 22.721429,35.358908 22.743317,35.358902 22.74632,35.358668 C 22.890468,35.347433 23.068342,35.422328 23.24632,35.479836 L 31.55882,39.23604 C 32.178205,39.571146 32.746139,40.416303 33.18382,41.235311 C 33.697582,40.705559 34.175099,40.082033 34.65257,39.478376 C 34.506925,39.100336 33.322125,36.183604 32.24632,35.54042 C 32.208951,35.519443 32.158429,35.494981 32.12132,35.479836 C 32.12132,35.479836 23.90257,31.602463 23.90257,31.602463 C 23.682707,31.487026 23.458357,31.340364 23.30882,31.117791 C 23.303816,31.109915 23.282418,31.065292 23.27757,31.057207 C 23.27305,31.048693 23.25067,31.005361 23.24632,30.996624 C 23.242145,30.987659 23.219065,30.945237 23.21507,30.93604 C 23.209653,30.915437 23.188802,30.836031 23.18382,30.814872 C 23.178118,30.804205 23.158221,30.76502 23.15257,30.754288 C 23.152883,30.748101 23.152478,30.699055 23.15257,30.693704 C 23.14684,30.672603 23.126822,30.593923 23.12132,30.572536 C 23.121491,30.566528 23.121262,30.517258 23.12132,30.511952 C 23.121289,30.491049 23.121101,30.411997 23.12132,30.390784 C 23.120591,30.349044 23.119651,30.253719 23.12132,30.209032 C 23.121362,30.202179 23.121459,30.156131 23.12132,30.148448 C 23.120612,30.123232 23.120473,30.048722 23.12132,30.02728 C 23.121176,30.020623 23.121342,29.972183 23.12132,29.966696 C 23.127064,29.945082 23.14724,29.865656 23.15257,29.845529 C 23.161359,29.791571 23.174207,29.713029 23.18382,29.663777 C 23.189124,29.643155 23.209537,29.563403 23.21507,29.542609 C 23.232193,29.472178 23.259447,29.361212 23.27757,29.300273 C 23.29199,29.259636 23.32245,29.163945 23.34007,29.118521 C 23.344648,29.109072 23.366651,29.066973 23.37132,29.057937 C 23.377737,29.045365 23.398312,29.005618 23.40257,28.997353 C 23.413863,28.986667 23.454816,28.946463 23.46507,28.936769 C 23.480962,28.920762 23.515004,28.888031 23.52757,28.876185 C 23.53306,28.865081 23.553307,28.826621 23.55882,28.815601 C 23.569749,28.815935 23.610299,28.81495 23.62132,28.815601 C 23.6256,28.807379 23.646053,28.767503 23.65257,28.755018 C 23.65535,28.75513 23.680566,28.7547 23.68382,28.755018 C 23.690973,28.741406 23.713739,28.697832 23.71507,28.694434 C 23.718325,28.694744 23.74354,28.694321 23.74632,28.694434 C 23.752679,28.694674 23.774567,28.694666 23.77757,28.694434 C 23.921718,28.683199 24.099592,28.758094 24.27757,28.815601 L 32.59007,32.571806 C 33.93382,33.298814 35.05882,36.449179 35.05882,36.449179 L 34.65257,39.478376 C 34.836737,39.245538 35.03664,39.055256 35.21507,38.811953 L 37.80882,20.333849 C 38.650231,14.374487 36.848446,8.4177135 33.77757,6.9447964 L 24.49632,2.4615843 C 23.89654,2.1739052 23.303073,2.0788021 22.71507,2.1586646 C 22.711521,2.1591465 22.689905,2.1588162 22.68382,2.1586646 C 22.670924,2.1581704 22.633771,2.1598311 22.62132,2.1586646 C 22.615045,2.1582414 22.596501,2.1587092 22.59007,2.1586646 C 22.587023,2.1585444 22.56543,2.1587202 22.55882,2.1586646 C 22.52881,2.1602937 22.46376,2.1562625 22.43382,2.1586646 C 22.424556,2.159398 22.387525,2.159132 22.37132,2.1586646 C 22.367493,2.1585649 22.344175,2.1582138 22.34007,2.1586646 C 22.329452,2.1583154 22.28818,2.1589327 22.27757,2.1586646 C 22.266941,2.1582984 22.22569,2.1589509 22.21507,2.1586646 z M 17.71507,12.276184 L 22.62132,14.154286 C 22.81175,14.267881 23.01278,14.435772 23.15257,14.699542 C 23.1571,14.708551 23.179426,14.750896 23.18382,14.760126 C 23.188075,14.769579 23.21096,14.81103 23.21507,14.82071 C 23.22041,14.841238 23.241337,14.920817 23.24632,14.941878 C 23.251999,14.95252 23.271934,14.991758 23.27757,15.002462 C 23.287659,15.050182 23.301098,15.140858 23.30882,15.184213 C 23.31759,15.23957 23.333658,15.357843 23.34007,15.426549 C 23.339992,15.438417 23.340018,15.479387 23.34007,15.487133 C 23.339819,15.521508 23.340108,15.585519 23.34007,15.608301 C 23.340424,15.663284 23.342068,15.7929 23.34007,15.850637 C 23.340213,15.857291 23.340053,15.905738 23.34007,15.911221 C 23.334346,15.932761 23.314288,16.011386 23.30882,16.032389 C 23.301582,16.085713 23.286162,16.165159 23.27757,16.214141 C 23.277854,16.220106 23.277536,16.26914 23.27757,16.274724 C 23.271906,16.296984 23.25173,16.376333 23.24632,16.395892 C 23.239195,16.423912 23.222717,16.490827 23.21507,16.51706 C 23.209477,16.527695 23.189444,16.567118 23.18382,16.577644 C 23.178558,16.599151 23.157949,16.677728 23.15257,16.698812 C 23.148028,16.709363 23.125972,16.749256 23.12132,16.759396 C 23.11656,16.76913 23.094935,16.810648 23.09007,16.81998 C 23.085103,16.828916 23.063887,16.87202 23.05882,16.880564 C 23.048199,16.890925 23.007148,16.931636 22.99632,16.941148 C 22.990819,16.952148 22.970592,16.990822 22.96507,17.001732 C 22.944002,17.018636 22.893058,17.048529 22.87132,17.062316 C 22.847095,17.079175 22.802773,17.111202 22.77757,17.1229 C 22.612332,17.190858 22.424054,17.160765 22.24632,17.062316 L 17.30882,15.002462 L 17.71507,12.276184 z M 25.52757,15.365965 C 25.530825,15.366276 25.55604,15.365853 25.55882,15.365965 C 25.565179,15.366205 25.587067,15.366199 25.59007,15.365965 C 25.734218,15.35473 25.912092,15.429626 26.09007,15.487133 L 34.40257,19.243338 C 35.74632,19.970345 36.62132,22.636039 36.62132,22.636039 L 36.27757,25.604652 C 36.131925,25.226612 35.134625,22.855136 34.05882,22.211951 C 34.021451,22.190975 33.970929,22.166514 33.93382,22.151367 C 33.93382,22.151367 25.71507,18.273995 25.71507,18.273995 C 25.495207,18.158558 25.270857,18.011896 25.12132,17.789323 C 25.116316,17.781446 25.094918,17.736824 25.09007,17.728739 C 25.08555,17.720225 25.06317,17.676892 25.05882,17.668155 C 25.054645,17.659191 25.031565,17.616768 25.02757,17.607571 C 25.022153,17.586969 25.001302,17.507562 24.99632,17.486403 C 24.990618,17.475737 24.970721,17.436551 24.96507,17.425819 C 24.965383,17.419634 24.964978,17.370585 24.96507,17.365236 C 24.95934,17.344134 24.939322,17.265454 24.93382,17.244068 C 24.933991,17.23806 24.933762,17.188791 24.93382,17.183484 C 24.933789,17.16258 24.933601,17.083529 24.93382,17.062316 C 24.933091,17.020577 24.932151,16.92525 24.93382,16.880564 C 24.933862,16.87371 24.933959,16.827663 24.93382,16.81998 C 24.933112,16.794763 24.932973,16.720254 24.93382,16.698812 C 24.933676,16.692154 24.933842,16.643715 24.93382,16.638228 C 24.939564,16.616614 24.95974,16.537187 24.96507,16.51706 C 24.973859,16.463103 24.986707,16.384561 24.99632,16.335308 C 25.001624,16.314686 25.022037,16.234936 25.02757,16.214141 C 25.044693,16.14371 25.071947,16.032743 25.09007,15.971805 C 25.10449,15.931168 25.13495,15.835477 25.15257,15.790053 C 25.157148,15.780603 25.179151,15.738506 25.18382,15.729469 C 25.190237,15.716896 25.210812,15.677149 25.21507,15.668885 C 25.226363,15.658199 25.267316,15.617994 25.27757,15.608301 C 25.293462,15.592294 25.327504,15.559564 25.34007,15.547717 C 25.34556,15.536613 25.365807,15.498153 25.37132,15.487133 C 25.382249,15.487466 25.422799,15.486481 25.43382,15.487133 C 25.4381,15.478911 25.458553,15.439035 25.46507,15.426549 C 25.46785,15.426662 25.493066,15.42623 25.49632,15.426549 C 25.503473,15.412939 25.526239,15.369363 25.52757,15.365965 z M 16.80882,18.81925 L 21.71507,20.697353 C 21.9055,20.810948 22.10653,20.978838 22.24632,21.242608 C 22.25085,21.251617 22.273176,21.293962 22.27757,21.303192 C 22.281825,21.312645 22.30471,21.354096 22.30882,21.363776 C 22.31416,21.384305 22.335087,21.463884 22.34007,21.484944 C 22.345749,21.495585 22.365684,21.534824 22.37132,21.545528 C 22.37114,21.548597 22.371262,21.592399 22.37132,21.606112 C 22.376977,21.627185 22.397108,21.705946 22.40257,21.72728 C 22.409586,21.771565 22.427062,21.856925 22.43382,21.909032 C 22.433993,21.915743 22.433781,21.961855 22.43382,21.969615 C 22.433391,22.004207 22.433491,22.068444 22.43382,22.090783 C 22.433744,22.136348 22.436183,22.22426 22.43382,22.272535 C 22.428563,22.354532 22.414777,22.485525 22.40257,22.575455 C 22.402657,22.580618 22.402259,22.630657 22.40257,22.636039 C 22.389865,22.694275 22.354068,22.824375 22.34007,22.878375 C 22.333214,22.907302 22.316209,22.97242 22.30882,22.999543 C 22.303517,23.020895 22.282998,23.099794 22.27757,23.12071 C 22.271991,23.131398 22.251928,23.170713 22.24632,23.181294 C 22.210891,23.269026 22.16339,23.361433 22.12132,23.42363 C 22.115809,23.434586 22.095603,23.473352 22.09007,23.484214 C 22.074217,23.500137 22.040551,23.532239 22.02757,23.544798 C 22.018802,23.552646 21.981593,23.589516 21.96507,23.605382 C 21.961925,23.604876 21.936564,23.605529 21.93382,23.605382 C 21.922911,23.616495 21.882288,23.655171 21.87132,23.665966 C 21.706082,23.733925 21.517804,23.70383 21.34007,23.605382 L 16.40257,21.545528 L 16.80882,18.81925 z M 24.62132,22.030199 C 24.624575,22.03051 24.64979,22.030087 24.65257,22.030199 C 24.658929,22.03044 24.680817,22.030434 24.68382,22.030199 C 24.827968,22.018965 25.005842,22.09386 25.18382,22.151367 L 33.49632,25.907572 C 34.84007,26.634579 35.59007,29.118521 35.59007,29.118521 L 35.27757,31.905383 C 35.131925,31.527343 34.228375,29.51937 33.15257,28.876185 C 33.115201,28.855209 33.064679,28.830746 33.02757,28.815601 C 33.02757,28.815601 24.80882,24.938229 24.80882,24.938229 C 24.588957,24.822792 24.364607,24.67613 24.21507,24.453557 C 24.210066,24.44568 24.188668,24.401058 24.18382,24.392973 C 24.1793,24.384459 24.15692,24.341127 24.15257,24.332389 C 24.148395,24.323425 24.125315,24.281003 24.12132,24.271805 C 24.115903,24.251203 24.095052,24.171796 24.09007,24.150638 C 24.084368,24.139971 24.064471,24.100786 24.05882,24.090054 C 24.059133,24.083867 24.058728,24.03482 24.05882,24.02947 C 24.05309,24.008369 24.033072,23.929687 24.02757,23.908302 C 24.027741,23.902294 24.027512,23.853024 24.02757,23.847718 C 24.027539,23.826815 24.027351,23.747763 24.02757,23.72655 C 24.026841,23.68481 24.025901,23.589485 24.02757,23.544798 C 24.027612,23.537945 24.027709,23.491897 24.02757,23.484214 C 24.026862,23.458998 24.026723,23.384488 24.02757,23.363046 C 24.027426,23.356389 24.027592,23.307949 24.02757,23.302462 C 24.033314,23.280848 24.05349,23.201422 24.05882,23.181294 C 24.067609,23.127337 24.080457,23.048795 24.09007,22.999543 C 24.095374,22.978921 24.115787,22.899169 24.12132,22.878375 C 24.138443,22.807944 24.165697,22.696978 24.18382,22.636039 C 24.19824,22.595402 24.2287,22.49971 24.24632,22.454287 C 24.250898,22.444838 24.272901,22.402739 24.27757,22.393703 C 24.283987,22.381131 24.304562,22.341384 24.30882,22.333119 C 24.320113,22.322433 24.361066,22.282229 24.37132,22.272535 C 24.387212,22.256527 24.421254,22.223799 24.43382,22.211951 C 24.442334,22.204567 24.479755,22.167297 24.49632,22.151367 C 24.499477,22.15184 24.524822,22.15123 24.52757,22.151367 C 24.53185,22.143145 24.552303,22.103269 24.55882,22.090783 C 24.5616,22.090896 24.586816,22.090465 24.59007,22.090783 C 24.597223,22.077174 24.619989,22.033598 24.62132,22.030199 z M 15.87132,25.362316 L 20.77757,27.301003 C 20.916425,27.383831 21.062201,27.51338 21.18382,27.664506 C 21.194868,27.674737 21.235393,27.714612 21.24632,27.72509 C 21.251851,27.735875 21.272073,27.774824 21.27757,27.785674 C 21.282892,27.794757 21.303647,27.8369 21.30882,27.846258 C 21.321992,27.871568 21.355511,27.936043 21.37132,27.967426 C 21.376966,27.978114 21.396964,28.017262 21.40257,28.02801 C 21.40239,28.034683 21.402626,28.083077 21.40257,28.088594 C 21.408105,28.11002 21.428262,28.1896 21.43382,28.209762 C 21.439547,28.220339 21.459391,28.259704 21.46507,28.270346 C 21.476102,28.332281 21.490569,28.443946 21.49632,28.512682 C 21.49635,28.533468 21.496523,28.612776 21.49632,28.63385 C 21.496978,28.678531 21.497906,28.768239 21.49632,28.815601 C 21.496404,28.821825 21.496321,28.870751 21.49632,28.876185 C 21.488511,28.947075 21.472138,29.060566 21.46507,29.118521 C 21.4653,29.124591 21.465044,29.173756 21.46507,29.179105 C 21.450883,29.240205 21.416414,29.36568 21.40257,29.421441 C 21.394497,29.453078 21.376582,29.521502 21.37132,29.542609 C 21.365935,29.563074 21.34822,29.632543 21.34007,29.663777 C 21.334926,29.685211 21.313984,29.765067 21.30882,29.784945 C 21.283564,29.842107 21.241673,29.921839 21.21507,29.966696 C 21.209548,29.977605 21.189366,30.016466 21.18382,30.02728 C 21.178309,30.038236 21.158103,30.077002 21.15257,30.087864 C 21.136717,30.103787 21.103051,30.135889 21.09007,30.148448 C 21.081302,30.156296 21.044093,30.193166 21.02757,30.209032 C 21.024425,30.208526 20.999064,30.20918 20.99632,30.209032 C 20.816986,30.312271 20.600812,30.318841 20.40257,30.209032 L 15.46507,28.02801 L 15.87132,25.362316 z M 14.99632,31.844799 L 19.90257,33.904653 C 20.124738,34.037182 20.357682,34.28482 20.49632,34.63166 C 20.501966,34.642348 20.521964,34.681496 20.52757,34.692244 C 20.535744,34.722817 20.552148,34.787858 20.55882,34.813412 C 20.568703,34.861428 20.583054,34.950879 20.59007,34.995164 C 20.595838,35.016096 20.615766,35.095125 20.62132,35.116332 C 20.621319,35.137155 20.621549,35.216393 20.62132,35.2375 C 20.621261,35.249343 20.621256,35.290352 20.62132,35.298084 C 20.621251,35.33224 20.621732,35.396022 20.62132,35.419252 C 20.621391,35.42549 20.621332,35.474388 20.62132,35.479836 C 20.621481,35.485778 20.621296,35.5351 20.62132,35.54042 C 20.617818,35.563312 20.594899,35.636732 20.59007,35.661587 C 20.588742,35.668974 20.591084,35.715636 20.59007,35.722171 C 20.590357,35.727516 20.590016,35.777612 20.59007,35.782755 C 20.581625,35.844968 20.568846,35.960998 20.55882,36.025091 C 20.527306,36.178951 20.478107,36.339513 20.43382,36.449179 C 20.429278,36.459729 20.407222,36.499623 20.40257,36.509763 C 20.39781,36.519497 20.376185,36.561014 20.37132,36.570347 C 20.366353,36.579282 20.345137,36.622387 20.34007,36.630931 C 20.334548,36.64184 20.314366,36.680701 20.30882,36.691515 C 20.298226,36.702005 20.257109,36.742436 20.24632,36.752098 C 20.240829,36.763141 20.220581,36.801727 20.21507,36.812682 C 20.19029,36.831532 20.142745,36.859668 20.12132,36.873266 C 20.110411,36.87302 20.069788,36.873831 20.05882,36.873266 C 19.893582,36.941225 19.705304,36.911131 19.52757,36.812682 L 14.59007,34.571076 L 14.99632,31.844799 z M 14.02757,38.387865 L 18.93382,40.447719 C 19.12425,40.561315 19.32528,40.729205 19.46507,40.992975 C 19.4696,41.001984 19.491926,41.044329 19.49632,41.053559 C 19.500575,41.063012 19.52346,41.104463 19.52757,41.114143 C 19.53291,41.134671 19.553837,41.214251 19.55882,41.235311 C 19.564499,41.245952 19.584434,41.285191 19.59007,41.295894 C 19.600159,41.343615 19.613598,41.434291 19.62132,41.477646 C 19.63009,41.533002 19.646158,41.651275 19.65257,41.719982 C 19.653091,41.730717 19.652466,41.765074 19.65257,41.780566 C 19.652319,41.814941 19.652608,41.878952 19.65257,41.901734 C 19.652924,41.956717 19.654568,42.086334 19.65257,42.14407 C 19.651575,42.151161 19.653861,42.197044 19.65257,42.204654 C 19.647845,42.228885 19.625022,42.303738 19.62132,42.325822 C 19.614082,42.379147 19.598662,42.458593 19.59007,42.507573 C 19.582172,42.549191 19.568118,42.642227 19.55882,42.689325 C 19.551695,42.717345 19.535217,42.784261 19.52757,42.810493 C 19.521977,42.821129 19.501944,42.86055 19.49632,42.871077 C 19.491058,42.892585 19.470449,42.971162 19.46507,42.992245 C 19.460528,43.002795 19.438472,43.04269 19.43382,43.052829 C 19.42906,43.062563 19.407435,43.10408 19.40257,43.113413 C 19.397603,43.122348 19.376387,43.165453 19.37132,43.173997 C 19.360699,43.184357 19.319648,43.22507 19.30882,43.234581 C 19.303319,43.245581 19.283092,43.284256 19.27757,43.295165 C 19.256502,43.312068 19.205558,43.341963 19.18382,43.355749 C 19.159595,43.372607 19.115273,43.404635 19.09007,43.416333 C 18.924832,43.484291 18.736554,43.454197 18.55882,43.355749 L 13.62132,41.114143 L 14.02757,38.387865 z"
+ style="opacity:0.44318201;fill:url(#radialGradient3202);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><g
+ id="g2937"><path
+ style="opacity:1;fill:url(#linearGradient3204);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 22.28125,15.84375 L 30.59375,17.78125 C 31.9375,18.15625 33.0625,19.78125 33.0625,19.78125 L 32.65625,21.375 C 32.65625,21.375 31.3125,19.53125 30.125,19.28125 C 30.125,19.28125 21.90625,17.28125 21.90625,17.28125 C 21.421036,17.149843 20.971366,16.960466 21.15625,16.375 C 21.34375,15.78125 21.71875,15.75 22.28125,15.84375 z"
+ id="path2284"
+ sodipodi:nodetypes="cccccczc" /></g><path
+ sodipodi:nodetypes="ccccccccccsccc"
+ id="path1345"
+ d="M 31.5,19 L 31.375,34.375 L 31.375,34.40625 L 31.375,34.4375 C 31.462702,35.84074 30.279231,37.074596 29.125,36.84375 L 18.65625,34.6875 C 18.1875,34.5625 16.9375,34.0625 17.34375,32.625 L 15.40625,32.125 C 14.727493,34.561693 16.65625,36.28125 18.09375,36.59375 L 28.75,38.78125 C 31.324613,39.296173 33.497942,36.947282 33.375,34.375 C 33.37399,34.353864 33.376323,34.333663 33.375,34.3125 L 33.5,19 L 31.5,19 z"
+ style="opacity:1;fill:#747474;fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3206);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 21.25,19.28125 L 29.5625,21.21875 C 30.90625,21.59375 32.03125,23.21875 32.03125,23.21875 L 31.625,24.8125 C 31.625,24.8125 30.28125,22.96875 29.09375,22.71875 C 29.09375,22.71875 20.875,20.71875 20.875,20.71875 C 20.389786,20.587343 19.940116,20.397966 20.125,19.8125 C 20.3125,19.21875 20.6875,19.1875 21.25,19.28125 z"
+ id="path2286"
+ sodipodi:nodetypes="cccccczc" /><path
+ sodipodi:nodetypes="cccccczc"
+ id="path2280"
+ d="M 24.09375,8.9687499 L 32.40625,10.90625 C 33.75,11.28125 34.46875,12.40625 34.46875,12.40625 L 34.0625,14 C 34.0625,14 33.125,12.65625 31.9375,12.40625 C 31.9375,12.40625 23.71875,10.40625 23.71875,10.40625 C 23.233536,10.274843 22.783866,10.085466 22.96875,9.4999999 C 23.15625,8.9062499 23.53125,8.8749999 24.09375,8.9687499 z"
+ style="opacity:1;fill:url(#linearGradient3208);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3210);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 23.1875,12.40625 L 31.5,14.34375 C 32.84375,14.71875 33.5625,15.90625 33.5625,15.90625 L 33.125,17.40625 C 33.125,17.40625 32.21875,16.09375 31.03125,15.84375 C 31.03125,15.84375 22.8125,13.84375 22.8125,13.84375 C 22.327286,13.712343 21.877616,13.522966 22.0625,12.9375 C 22.25,12.34375 22.625,12.3125 23.1875,12.40625 z"
+ id="path2282"
+ sodipodi:nodetypes="cccccczc" /><path
+ transform="matrix(1.26667,0,0,1.26667,-10.3083,-8.15)"
+ d="M 35.375,22.125 A 1.875,1.875 0 1 1 31.625,22.125 A 1.875,1.875 0 1 1 35.375,22.125 z"
+ sodipodi:ry="1.875"
+ sodipodi:rx="1.875"
+ sodipodi:cy="22.125"
+ sodipodi:cx="33.5"
+ id="path2220"
+ style="opacity:1;fill:url(#radialGradient3212);fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:0.789473;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ sodipodi:nodetypes="cccccczc"
+ id="path2288"
+ d="M 20.34375,22.71875 L 28.65625,24.65625 C 30,25.03125 31.125,26.65625 31.125,26.65625 L 30.71875,28.25 C 30.71875,28.25 29.375,26.40625 28.1875,26.15625 C 28.1875,26.15625 19.96875,24.15625 19.96875,24.15625 C 19.483536,24.024843 19.096366,23.835466 19.21875,23.25 C 19.342601,22.657518 19.78125,22.625 20.34375,22.71875 z"
+ style="opacity:1;fill:url(#linearGradient3214);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2292"
+ d="M 11.966306,22.990197 L 7.0288059,21.833947 L 7.4350559,20.427697 L 12.341306,21.490197 C 12.747556,21.615197 13.185056,21.865197 13.028806,22.458947 C 12.874388,23.045734 12.403806,23.115197 11.966306,22.990197 z"
+ style="opacity:1;fill:url(#linearGradient3216);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3218);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 17.53125,19.976562 L 12.59375,18.820312 L 13,17.414062 L 17.90625,18.476562 C 18.3125,18.601562 18.75,18.851562 18.59375,19.445312 C 18.439332,20.0321 17.96875,20.101562 17.53125,19.976562 z"
+ id="path2294"
+ sodipodi:nodetypes="cccczc" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2296"
+ d="M 18.40625,16.546875 L 13.46875,15.453125 L 13.875,14.046875 L 18.78125,15.046875 C 19.1875,15.171875 19.625,15.421875 19.46875,16.015625 C 19.314332,16.602412 18.84375,16.671875 18.40625,16.546875 z"
+ style="opacity:1;fill:url(#linearGradient3220);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3222);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 19.34375,13.148438 L 14.40625,12.085938 L 14.8125,10.679688 L 19.71875,11.648438 C 20.125,11.773438 20.5625,12.023438 20.40625,12.617188 C 20.251832,13.203974 19.78125,13.273438 19.34375,13.148438 z"
+ id="path2298"
+ sodipodi:nodetypes="cccczc" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2300"
+ d="M 20.25,9.78125 L 15.3125,8.71875 L 15.71875,7.3125 L 20.625,8.28125 C 21.03125,8.40625 21.46875,8.65625 21.3125,9.25 C 21.158082,9.836787 20.6875,9.90625 20.25,9.78125 z"
+ style="opacity:1;fill:url(#linearGradient3224);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:type="arc"
+ style="opacity:0.29545504;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3226);stroke-width:1.16238999;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="path2389"
+ sodipodi:cx="16.4375"
+ sodipodi:cy="46.375"
+ sodipodi:rx="11.1875"
+ sodipodi:ry="5.875"
+ d="M 27.625,46.375 A 11.1875,5.875 0 1 1 5.25,46.375 A 11.1875,5.875 0 1 1 27.625,46.375 z"
+ transform="matrix(0.916296,0,0,0.807726,10.1259,1.91671)" /></g><path
+ style="font-size:12px;fill:url(#radialGradient2841);stroke:#cf5d07;stroke-width:0.69259357;stroke-opacity:0.99215698"
+ d="M 22.832175,48.09749 L 19.006951,41.473963 L 25.133925,37.778654 L 18.351191,36.201424 L 20.408515,28.612743 L 14.641322,33.005969 L 11.423775,25.969182 L 10.050627,33.758994 L 3.4431408,31.396272 L 7.2683028,38.019828 L 1.1413788,41.715137 L 7.9240638,43.292367 L 5.8667588,50.88095 L 11.633953,46.488076 L 14.851478,53.524745 L 16.224648,45.734683 L 22.832175,48.09749 z"
+ id="path64" /></svg> \ No newline at end of file
diff --git a/icons/new.svg b/icons/new.svg
new file mode 100755
index 0000000..f6bc61a
--- /dev/null
+++ b/icons/new.svg
@@ -0,0 +1,214 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"
+[
+ <!ATTLIST svg
+ xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
+]>
+<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
+<svg
+ width="128pt"
+ height="128pt"
+ id="svg1"
+ sodipodi:version="0.27"
+ sodipodi:docname="/mnt/windows/Themes/Work/Blue-Sphere/document_new.svg"
+ sodipodi:docbase="/mnt/windows/Themes/Work/Blue-Sphere/"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs
+ id="defs22">
+ <linearGradient
+ id="linearGradient96">
+ <stop
+ offset="0.000000"
+ style="stop-color:#fbddb2;stop-opacity:0.992157;"
+ id="stop97" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#efa81a;stop-opacity:0.952941;"
+ id="stop98" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient1857">
+ <stop
+ offset="0.000000"
+ style="stop-color:#fbddc7;stop-opacity:0.992157;"
+ id="stop1858" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#efa81a;stop-opacity:0.952941;"
+ id="stop1859" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient168">
+ <stop
+ offset="0.000000"
+ style="stop-color:#cdffff;stop-opacity:1;"
+ id="stop169" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#0c5d7d;stop-opacity:0.905882;"
+ id="stop170" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient90">
+ <stop
+ offset="0.000000"
+ style="stop-color:#cdffff;stop-opacity:1;"
+ id="stop91" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#006b97;stop-opacity:0.905882;"
+ id="stop92" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient67">
+ <stop
+ offset="0.000000"
+ style="stop-color:#d7ffff;stop-opacity:0.898039;"
+ id="stop70" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#2ea6b9;stop-opacity:0.952941;"
+ id="stop69" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient57">
+ <stop
+ offset="0.000000"
+ style="stop-color:#ffffff;stop-opacity:1;"
+ id="stop59" />
+ <stop
+ offset="1.000000"
+ style="stop-color:#797979;stop-opacity:1;"
+ id="stop58" />
+ </linearGradient>
+ <defs
+ id="defs4">
+ <radialGradient
+ id="1"
+ cx="869.603027"
+ cy="1973.579956"
+ r="2106.649902"
+ fx="869.603027"
+ fy="1973.579956"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient67" />
+ </defs>
+ <defs
+ id="defs11">
+ <linearGradient
+ id="2"
+ x1="255.848"
+ y1="119.147"
+ x2="375.686"
+ y2="34.1009"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ offset="0"
+ style="stop-color:#ffffff"
+ id="stop13" />
+ <stop
+ offset="1"
+ style="stop-color:#000000"
+ id="stop14" />
+ </linearGradient>
+ </defs>
+ <defs
+ id="defs16">
+ <linearGradient
+ id="3"
+ x1="275.053009"
+ y1="109.384003"
+ x2="356.480988"
+ y2="30.864300"
+ gradientUnits="userSpaceOnUse"
+ xlink:href="#linearGradient57" />
+ </defs>
+ <radialGradient
+ cx="3.03981e-14"
+ cy="1.05578e-10"
+ r="0.773346"
+ fx="3.03981e-14"
+ fy="1.05578e-10"
+ xlink:href="#linearGradient168"
+ id="radialGradient88"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(0.945877,0,0,1.05722,0.264368,0.249996)"
+ spreadMethod="pad" />
+ <linearGradient
+ x1="2.69643"
+ y1="1.14655"
+ x2="3.85147"
+ y2="0.623116"
+ xlink:href="#linearGradient67"
+ id="linearGradient89"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="translate(-2.65767,-0.201241)"
+ spreadMethod="pad" />
+ <linearGradient
+ xlink:href="#linearGradient1857"
+ id="linearGradient1856"
+ x1="0.0259356"
+ y1="-0.761799"
+ x2="0.0424691"
+ y2="0.752764"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(1.27999,-1.2809,0.380134,0.400852,0.419179,0.455777)"
+ spreadMethod="pad" />
+ <radialGradient
+ xlink:href="#linearGradient1857"
+ id="radialGradient1860"
+ cx="-5.51513e-06"
+ cy="-1.48419e-06"
+ fx="-5.51513e-06"
+ fy="-1.48419e-06"
+ r="0.694199"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(1.6481,-1.64928,0.295229,0.311319,0.00343702,0.809113)"
+ spreadMethod="pad" />
+ <radialGradient
+ xlink:href="#linearGradient96"
+ id="radialGradient95"
+ cx="6.46047e-09"
+ cy="5.68149e-08"
+ fx="6.46047e-09"
+ fy="5.68149e-08"
+ r="0.242318"
+ gradientUnits="objectBoundingBox"
+ gradientTransform="matrix(0.8189,0,0,1.22115,0.417826,0.462637)"
+ spreadMethod="pad" />
+ </defs>
+ <sodipodi:namedview
+ id="base" />
+ <g
+ id="g1760"
+ transform="matrix(0.964572,0,0,0.964572,-9.30589,-0.173276)">
+ <path
+ style="font-size:12;fill:url(#radialGradient88);stroke:#0c5d7d;stroke-opacity:0.99;stroke-width:4.03585;"
+ d="M 35.399 39.1321L 277.219 39.1321L 377.219 137.984L 377.219 548.198L 35.399 548.198L 35.399 39.1321z"
+ id="path1761"
+ transform="matrix(0.278752,0,0,0.284891,29.8322,1.63322)" />
+ <path
+ style="font-size:12;fill:#ffffff;fill-opacity:0.699301;stroke:#2ea6b9;stroke-width:8.96855;stroke-opacity:0.82;"
+ d="M 23.9471 20.1241L 265.767 20.1241L 365.767 120.124L 365.767 535.103L 23.9471 535.103L 23.9471 20.1241z"
+ id="path1762"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#2);"
+ d="M 276.767 133.124L 365.767 120.124L 265.767 20.1241"
+ id="path1763"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ <path
+ style="font-size:12;fill:url(#linearGradient89);stroke:#2ea6b9;stroke-width:6.72641;stroke-opacity:0.91;"
+ d="M 265.767 120.124L 365.767 120.124L 265.767 20.1241L 265.767 120.124"
+ id="path1764"
+ transform="matrix(0.278752,0,0,0.278752,29.8322,3.74844)" />
+ </g>
+ <path
+ style="font-size:12;fill:url(#radialGradient95);stroke:#cf5d07;stroke-opacity:0.992157;stroke-width:3.125;"
+ d="M 110.396 116.173 L 91.8993 88.2864 L 121.526 72.7283 L 88.7284 66.0878 L 98.6765 34.1377 L 70.7895 52.6342 L 55.2312 23.0077 L 48.5914 55.8046 L 16.6412 45.857 L 35.1376 73.7437 L 5.51114 89.3018 L 38.3085 95.9423 L 28.3605 127.892 L 56.2475 109.397 L 71.8057 139.023 L 78.4456 106.225 L 110.396 116.173 z "
+ id="path64"
+ transform="matrix(0.62585,0,0,0.62585,48.4973,53.0247)" />
+</svg>
diff --git a/icons/red-button.svg b/icons/red-button.svg
new file mode 100755
index 0000000..430b09a
--- /dev/null
+++ b/icons/red-button.svg
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="55"
+ height="55"
+ id="svg2389"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="red-button.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs2391">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective2397" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="8.4"
+ inkscape:cx="27.5"
+ inkscape:cy="27.5"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="640"
+ inkscape:window-height="667"
+ inkscape:window-x="110"
+ inkscape:window-y="67" />
+ <metadata
+ id="metadata2394">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2399"
+ sodipodi:cx="27.380953"
+ sodipodi:cy="27.559525"
+ sodipodi:rx="0"
+ sodipodi:ry="0.05952381"
+ d="M 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 A 0,0.05952381 0 1 1 27.380953,27.559525 z" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2401"
+ sodipodi:cx="35"
+ sodipodi:cy="34.82143"
+ sodipodi:rx="15.714286"
+ sodipodi:ry="16.488094"
+ d="M 50.714286,34.82143 A 15.714286,16.488094 0 1 1 19.285714,34.82143 A 15.714286,16.488094 0 1 1 50.714286,34.82143 z"
+ transform="matrix(1.388888,0,0,1.3107093,-21.111081,-17.926485)" />
+ </g>
+</svg>
diff --git a/icons/slideshow.svg b/icons/slideshow.svg
new file mode 100755
index 0000000..d57facb
--- /dev/null
+++ b/icons/slideshow.svg
@@ -0,0 +1,431 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ enable-background="new 0 0 55 55"
+ height="55px"
+ id="svg2972"
+ version="1.1"
+ viewBox="0 0 55 55"
+ width="55px"
+ x="0px"
+ xml:space="preserve"
+ y="0px"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="new-showntell-activity.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata2729"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs2727"><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2399"><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
+ offset="0"
+ id="stop2401" /><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
+ offset="1"
+ id="stop2403" /></linearGradient><linearGradient
+ id="linearGradient2371"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2373" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0.484536;"
+ offset="1"
+ id="stop2375" /></linearGradient><linearGradient
+ id="linearGradient2407"><stop
+ style="stop-color: rgb(213, 213, 213); stop-opacity: 1;"
+ offset="0"
+ id="stop2409" /><stop
+ style="stop-color: rgb(116, 116, 116); stop-opacity: 1;"
+ offset="1"
+ id="stop2411" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2355"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2357" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
+ offset="1"
+ id="stop2359" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2337"><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
+ offset="0"
+ id="stop2339" /><stop
+ style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
+ offset="1"
+ id="stop2341" /></linearGradient><linearGradient
+ id="linearGradient2345"><stop
+ style="stop-color: rgb(213, 213, 213); stop-opacity: 1;"
+ offset="0"
+ id="stop2347" /><stop
+ style="stop-color: rgb(160, 160, 160); stop-opacity: 1;"
+ offset="1"
+ id="stop2349" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2252"><stop
+ style="stop-color: rgb(198, 198, 198); stop-opacity: 1;"
+ offset="0"
+ id="stop2254" /><stop
+ style="stop-color: rgb(198, 198, 198); stop-opacity: 0;"
+ offset="1"
+ id="stop2256" /></linearGradient><linearGradient
+ id="linearGradient2232"><stop
+ style="stop-color: rgb(176, 176, 176); stop-opacity: 1;"
+ offset="0"
+ id="stop2234" /><stop
+ style="stop-color: rgb(116, 116, 116); stop-opacity: 1;"
+ offset="1"
+ id="stop2236" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2242"><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 1;"
+ offset="0"
+ id="stop2244" /><stop
+ style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
+ offset="1"
+ id="stop2246" /></linearGradient><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 27.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="55 : 27.5 : 1"
+ inkscape:persp3d-origin="27.5 : 18.333333 : 1"
+ id="perspective2731" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2242"
+ id="radialGradient3194"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.425856,0,23.5399)"
+ cx="25.1875"
+ cy="41"
+ fx="25.1875"
+ fy="41"
+ r="16.4375" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2232"
+ id="radialGradient3196"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.52514,0,22.0217)"
+ cx="15.4375"
+ cy="42.090427"
+ fx="15.4375"
+ fy="42.090427"
+ r="11.1875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2252"
+ id="linearGradient3198"
+ gradientUnits="userSpaceOnUse"
+ x1="41.25"
+ y1="36.689548"
+ x2="48.25"
+ y2="35.689548" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2345"
+ id="radialGradient3200"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.49192,-8.44511e-2,-5.87441e-2,3.98672,-9.6468,-20.2759)"
+ cx="19.557497"
+ cy="6.644074"
+ fx="19.557497"
+ fy="6.644074"
+ r="10.98921" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2337"
+ id="radialGradient3202"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.53075,0,0,4.4512431,-28.91508,-14.647051)"
+ cx="20.275276"
+ cy="5.7119732"
+ fx="20.275276"
+ fy="5.7119732"
+ r="12.494026" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3204"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3206"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3208"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3210"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2407"
+ id="radialGradient3212"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.435326,0,0,0.435326,18.9166,12.4934)"
+ cx="33.499996"
+ cy="20.538168"
+ fx="33.499996"
+ fy="20.538168"
+ r="2.2697367" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2355"
+ id="linearGradient3214"
+ gradientUnits="userSpaceOnUse"
+ x1="25.160467"
+ y1="15.803662"
+ x2="33.96875"
+ y2="20.4375" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3216"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-4.5961941,-0.3535534)"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3218"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3220"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3222"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2371"
+ id="linearGradient3224"
+ gradientUnits="userSpaceOnUse"
+ x1="18.328718"
+ y1="15.323075"
+ x2="14.40625"
+ y2="14.046875" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2399"
+ id="linearGradient3226"
+ gradientUnits="userSpaceOnUse"
+ x1="16.4375"
+ y1="49.110714"
+ x2="17.402376"
+ y2="43.420425" /></defs><sodipodi:namedview
+ inkscape:window-height="726"
+ inkscape:window-width="645"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="8.9818182"
+ inkscape:cx="27.5"
+ inkscape:cy="27.68773"
+ inkscape:window-x="449"
+ inkscape:window-y="25"
+ inkscape:current-layer="svg2972" />
+<g
+ id="g2709">
+ <g
+ id="g2711">
+ <path
+ d="M11.908,34.521c-0.516,0.1-1.012-0.219-1.108-0.712L7.72,17.94c-0.095-0.493,0.245-0.975,0.761-1.075 l21.5-4.173c0.515-0.1,1.013,0.219,1.106,0.713l1.029,5.306l0.049-0.044l5.024,1.097l-1.608-8.618 c-0.294-1.503-1.748-2.485-3.251-2.192L5.121,14.235c-1.503,0.292-2.485,1.747-2.193,3.249l3.697,19.048 c0.292,1.503,1.746,2.484,3.249,2.193l4.623-0.945l1.016-3.959L11.908,34.521z"
+ fill="#666666"
+ id="path2713" />
+ </g>
+</g>
+<path
+ d="M34.167,29.272c0.097,0.493-0.245,0.977-0.761,1.074l-21.497,4.174 c-0.517,0.1-1.014-0.219-1.109-0.712L7.72,17.94c-0.095-0.493,0.245-0.975,0.762-1.075l21.499-4.173 c0.515-0.1,1.013,0.219,1.106,0.713L34.167,29.272z"
+ fill="#ffffff"
+ id="path3554_1_" />
+<g
+ id="g2716">
+ <g
+ id="g2718">
+ <path
+ d="M49.668,23.2l-4.624-0.954l-2.055,2.779l3.032,0.669c0.515,0.113,0.843,0.603,0.734,1.096l-3.485,15.783 c-0.107,0.491-0.613,0.798-1.125,0.684l-21.385-4.723c-0.513-0.112-0.841-0.603-0.733-1.094l3.485-15.784 c0.109-0.491,0.613-0.798,1.127-0.684l11.574,2.556l2.365-2.785L22.602,17.22c-1.495-0.33-2.975,0.615-3.304,2.11l-4.185,18.944 c-0.331,1.496,0.614,2.977,2.109,3.307l27.064,5.977c1.495,0.33,2.973-0.612,3.304-2.108l4.188-18.946 C52.106,25.009,51.163,23.53,49.668,23.2z"
+ fill="#666666"
+ id="path2720" />
+ </g>
+</g>
+<path
+ d="M43.271,42.573c-0.107,0.491-0.613,0.798-1.125,0.684l-21.385-4.723 c-0.513-0.112-0.84-0.603-0.733-1.094l3.485-15.784c0.109-0.491,0.613-0.798,1.127-0.684l21.382,4.722 c0.515,0.113,0.843,0.603,0.734,1.096L43.271,42.573z"
+ fill="#ffffff"
+ id="path3560_1_" />
+<path
+ d="M53.008,10.631c0-0.045-0.002-0.093-0.009-0.141c-0.069-0.589-0.562-1.31-1.28-1.878 c-0.721-0.569-1.536-0.878-2.127-0.81c-0.257,0.032-0.461,0.142-0.602,0.304l-0.016-0.009L38.568,21.872l-0.047,0.046l-0.006,0.01 c-0.016,0.018-0.019,0.043-0.031,0.063l-1.351,1.663c0,0,0.078,0.061,0.158,0.125l-0.164-0.114l-0.025,0.033 c-0.061,0.074-0.097,0.168-0.124,0.267c-0.011,0.012-0.026,0.015-0.032,0.029l-0.848,2.01l2.546,2.037l1.987-1.281 c0.014-0.006,0.011-0.022,0.021-0.033c0.052-0.04,0.111-0.074,0.152-0.124c0.004-0.007,0.024-0.037,0.028-0.039l1.389-1.733 l0.022-0.021l-0.005-0.002l0.016-0.017l0.005,0.002l10.518-13.57c0.021-0.019,0.045-0.027,0.062-0.048 c0.022-0.027,0.031-0.064,0.047-0.094l0.013-0.012l-0.002-0.002C52.963,10.939,53.008,10.798,53.008,10.631z"
+ fill="#666666"
+ id="path3562" />
+<path
+ d="M33.625,31.123c0,0-6.7,4.055-7.934,2.555 c-1.235-1.498,0.353-2.995,1.146-2.995s3.791,2.291,1.675,4.585c-2.117,2.291-3.617,1.764-3.617,1.764"
+ fill="none"
+ id="path3564"
+ stroke="#666666"
+ stroke-width="1.009" />
+<path
+ d="M34.438,30.019c-0.032,0.083-0.012,0.176,0.057,0.232c0.067,0.058,0.164,0.064,0.238,0.016 l2.879-1.851l-1.869-1.497L34.438,30.019z"
+ fill="#666666"
+ id="path3566" />
+<g
+ inkscape:groupmode="layer"
+ id="layer1"
+ inkscape:label="microphone" /><g
+ id="g3105"
+ transform="matrix(0.5232537,0,0,0.4950076,4.3255858,4.694013)"><path
+ transform="matrix(1.10646,0,0,1.04464,-2.68156,-2.51786)"
+ d="M 41.625,41 A 16.4375,7 0 1 1 8.75,41 A 16.4375,7 0 1 1 41.625,41 z"
+ sodipodi:ry="7"
+ sodipodi:rx="16.4375"
+ sodipodi:cy="41"
+ sodipodi:cx="25.1875"
+ id="path2240"
+ style="opacity:0.49431799;fill:url(#radialGradient3194);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ transform="translate(8.75,-7)"
+ d="M 27.625,46.375 A 11.1875,5.875 0 1 1 5.25,46.375 A 11.1875,5.875 0 1 1 27.625,46.375 z"
+ sodipodi:ry="5.875"
+ sodipodi:rx="11.1875"
+ sodipodi:cy="46.375"
+ sodipodi:cx="16.4375"
+ id="path2222"
+ style="opacity:1;fill:url(#radialGradient3196);fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ sodipodi:type="arc"
+ style="opacity:1;fill:#424242;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="path2260"
+ sodipodi:cx="33.5"
+ sodipodi:cy="22.125"
+ sodipodi:rx="1.875"
+ sodipodi:ry="1.875"
+ d="M 35.375,22.125 A 1.875,1.875 0 1 1 31.625,22.125 A 1.875,1.875 0 1 1 35.375,22.125 z"
+ transform="matrix(2.06667,0,0,1.26667,-43.9833,9.475)" /><path
+ sodipodi:nodetypes="cszzc"
+ id="path2250"
+ d="M 20.25,31.375 C 20.25,31.375 20.985875,34.77724 23.25,34.5 C 29.375,33.75 28.721362,34.010493 33.125,35.375 C 37.5625,36.75 35.21875,38.96875 39.75,39.375 C 44.28125,39.78125 43.875,35.75 47.75,35.5"
+ style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3198);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><rect
+ transform="matrix(0.970732,0.240164,-0.264014,0.964519,0,0)"
+ ry="6.6936979"
+ rx="6.6936979"
+ y="-4.0142608"
+ x="16.028919"
+ height="30.692028"
+ width="22.136791"
+ id="rect1343"
+ style="opacity:1;fill:url(#radialGradient3200);fill-opacity:1;fill-rule:evenodd;stroke:#7c7c7c;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><rect
+ style="opacity:0.30681799;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect2353"
+ width="19.862064"
+ height="28.524395"
+ x="17.210075"
+ y="-3.006144"
+ rx="5.4198565"
+ ry="5.4198565"
+ transform="matrix(0.970732,0.240164,-0.264014,0.964519,0,0)" /><path
+ sodipodi:nodetypes="cccsccsssssssssssssssssssssssscccsccssssssssssssssssssssssssssssssccccsccssssssssssssssssssssssssssssssccccccccssssssssscccsssssssssssssssssssssssssccccssccccsccssssssssssssssssssssssssssscccsssssssssssssssssssssssccccssccccsccssssssssssssssssssssssssssscccssssssssssssssssssssssssscccccssssssssssssssssssssssscccccssssssssssssssssssssssssccc"
+ id="rect2302"
+ d="M 22.21507,2.1586646 C 19.993982,2.8419631 18.064553,6.11263 17.43382,10.579833 L 12.59007,45.173267 C 15.447016,47.895386 19.22768,46.082026 22.80882,46.082026 C 23.298828,46.082026 23.796888,46.07907 24.27757,46.021442 C 23.342429,45.580269 21.96507,44.930931 21.96507,44.930931 C 21.745207,44.815494 21.543886,44.668833 21.40257,44.44626 C 21.397838,44.438383 21.375909,44.39376 21.37132,44.385676 C 21.357994,44.360785 21.324385,44.295981 21.30882,44.264508 C 21.303164,44.253775 21.283185,44.214717 21.27757,44.203924 C 21.269347,44.17318 21.252624,44.106823 21.24632,44.082756 C 21.236648,44.035572 21.221593,43.943297 21.21507,43.901004 C 21.215266,43.894996 21.215009,43.845726 21.21507,43.84042 C 21.209239,43.819517 21.189444,43.740465 21.18382,43.719252 C 21.183891,43.707349 21.183867,43.666419 21.18382,43.658668 C 21.18405,43.624034 21.183787,43.559844 21.18382,43.537501 C 21.183714,43.525781 21.183503,43.483954 21.18382,43.476917 C 21.183711,43.470779 21.183831,43.421712 21.18382,43.416333 C 21.19194,43.346104 21.208482,43.235098 21.21507,43.173997 C 21.220328,43.154096 21.240474,43.074649 21.24632,43.052829 C 21.246321,43.047286 21.246583,42.998208 21.24632,42.992245 C 21.253935,42.94461 21.268644,42.853675 21.27757,42.810493 C 21.285643,42.77858 21.303721,42.708776 21.30882,42.689325 C 21.333585,42.601792 21.372075,42.461188 21.40257,42.386406 C 21.40899,42.373833 21.429561,42.334084 21.43382,42.325822 C 21.445069,42.315137 21.486035,42.274931 21.49632,42.265238 C 21.524876,42.231985 21.585658,42.172766 21.62132,42.14407 C 21.632197,42.144368 21.672839,42.143459 21.68382,42.14407 C 21.683639,42.140685 21.683766,42.097088 21.68382,42.083486 C 21.690832,42.083373 21.713299,42.083086 21.71507,42.083486 C 21.889903,42.020149 22.111554,42.070233 22.34007,42.14407 L 28.27757,44.809763 C 29.467865,44.245328 30.604797,43.471628 31.68382,42.568157 C 31.531417,42.401171 31.366355,42.295101 31.21507,42.204654 C 31.177701,42.183677 31.127179,42.159215 31.09007,42.14407 C 31.09007,42.14407 22.87132,38.266697 22.87132,38.266697 C 22.651457,38.15126 22.427107,38.004598 22.27757,37.782026 C 22.272566,37.774149 22.251168,37.729526 22.24632,37.721442 C 22.2418,37.712927 22.21942,37.669595 22.21507,37.660858 C 22.210895,37.651893 22.187815,37.609471 22.18382,37.600274 C 22.178403,37.579671 22.157552,37.500265 22.15257,37.479106 C 22.146868,37.468439 22.126971,37.429254 22.12132,37.418522 C 22.121633,37.412336 22.121228,37.363289 22.12132,37.357938 C 22.11559,37.336837 22.095572,37.258158 22.09007,37.23677 C 22.090241,37.230762 22.090012,37.181492 22.09007,37.176186 C 22.090039,37.155283 22.089851,37.076231 22.09007,37.055018 C 22.089341,37.013278 22.088401,36.917953 22.09007,36.873266 C 22.090112,36.866413 22.090209,36.820365 22.09007,36.812682 C 22.089362,36.787466 22.089223,36.712956 22.09007,36.691515 C 22.089926,36.684857 22.090092,36.636417 22.09007,36.630931 C 22.095814,36.609316 22.11599,36.52989 22.12132,36.509763 C 22.130109,36.455805 22.142957,36.377263 22.15257,36.328011 C 22.157874,36.307389 22.178287,36.227637 22.18382,36.206843 C 22.200943,36.136412 22.228197,36.025446 22.24632,35.964507 C 22.26074,35.92387 22.2912,35.828179 22.30882,35.782755 C 22.313398,35.773306 22.335401,35.731208 22.34007,35.722171 C 22.346487,35.709599 22.367062,35.66985 22.37132,35.661587 C 22.382613,35.650901 22.423566,35.610697 22.43382,35.601003 C 22.449712,35.584996 22.483754,35.552265 22.49632,35.54042 C 22.504834,35.533035 22.542255,35.495766 22.55882,35.479836 C 22.561977,35.480309 22.587322,35.479698 22.59007,35.479836 C 22.59435,35.471614 22.614803,35.431737 22.62132,35.419252 C 22.6241,35.419364 22.649316,35.418932 22.65257,35.419252 C 22.659723,35.405642 22.682489,35.362064 22.68382,35.358668 C 22.687075,35.358978 22.71229,35.358555 22.71507,35.358668 C 22.721429,35.358908 22.743317,35.358902 22.74632,35.358668 C 22.890468,35.347433 23.068342,35.422328 23.24632,35.479836 L 31.55882,39.23604 C 32.178205,39.571146 32.746139,40.416303 33.18382,41.235311 C 33.697582,40.705559 34.175099,40.082033 34.65257,39.478376 C 34.506925,39.100336 33.322125,36.183604 32.24632,35.54042 C 32.208951,35.519443 32.158429,35.494981 32.12132,35.479836 C 32.12132,35.479836 23.90257,31.602463 23.90257,31.602463 C 23.682707,31.487026 23.458357,31.340364 23.30882,31.117791 C 23.303816,31.109915 23.282418,31.065292 23.27757,31.057207 C 23.27305,31.048693 23.25067,31.005361 23.24632,30.996624 C 23.242145,30.987659 23.219065,30.945237 23.21507,30.93604 C 23.209653,30.915437 23.188802,30.836031 23.18382,30.814872 C 23.178118,30.804205 23.158221,30.76502 23.15257,30.754288 C 23.152883,30.748101 23.152478,30.699055 23.15257,30.693704 C 23.14684,30.672603 23.126822,30.593923 23.12132,30.572536 C 23.121491,30.566528 23.121262,30.517258 23.12132,30.511952 C 23.121289,30.491049 23.121101,30.411997 23.12132,30.390784 C 23.120591,30.349044 23.119651,30.253719 23.12132,30.209032 C 23.121362,30.202179 23.121459,30.156131 23.12132,30.148448 C 23.120612,30.123232 23.120473,30.048722 23.12132,30.02728 C 23.121176,30.020623 23.121342,29.972183 23.12132,29.966696 C 23.127064,29.945082 23.14724,29.865656 23.15257,29.845529 C 23.161359,29.791571 23.174207,29.713029 23.18382,29.663777 C 23.189124,29.643155 23.209537,29.563403 23.21507,29.542609 C 23.232193,29.472178 23.259447,29.361212 23.27757,29.300273 C 23.29199,29.259636 23.32245,29.163945 23.34007,29.118521 C 23.344648,29.109072 23.366651,29.066973 23.37132,29.057937 C 23.377737,29.045365 23.398312,29.005618 23.40257,28.997353 C 23.413863,28.986667 23.454816,28.946463 23.46507,28.936769 C 23.480962,28.920762 23.515004,28.888031 23.52757,28.876185 C 23.53306,28.865081 23.553307,28.826621 23.55882,28.815601 C 23.569749,28.815935 23.610299,28.81495 23.62132,28.815601 C 23.6256,28.807379 23.646053,28.767503 23.65257,28.755018 C 23.65535,28.75513 23.680566,28.7547 23.68382,28.755018 C 23.690973,28.741406 23.713739,28.697832 23.71507,28.694434 C 23.718325,28.694744 23.74354,28.694321 23.74632,28.694434 C 23.752679,28.694674 23.774567,28.694666 23.77757,28.694434 C 23.921718,28.683199 24.099592,28.758094 24.27757,28.815601 L 32.59007,32.571806 C 33.93382,33.298814 35.05882,36.449179 35.05882,36.449179 L 34.65257,39.478376 C 34.836737,39.245538 35.03664,39.055256 35.21507,38.811953 L 37.80882,20.333849 C 38.650231,14.374487 36.848446,8.4177135 33.77757,6.9447964 L 24.49632,2.4615843 C 23.89654,2.1739052 23.303073,2.0788021 22.71507,2.1586646 C 22.711521,2.1591465 22.689905,2.1588162 22.68382,2.1586646 C 22.670924,2.1581704 22.633771,2.1598311 22.62132,2.1586646 C 22.615045,2.1582414 22.596501,2.1587092 22.59007,2.1586646 C 22.587023,2.1585444 22.56543,2.1587202 22.55882,2.1586646 C 22.52881,2.1602937 22.46376,2.1562625 22.43382,2.1586646 C 22.424556,2.159398 22.387525,2.159132 22.37132,2.1586646 C 22.367493,2.1585649 22.344175,2.1582138 22.34007,2.1586646 C 22.329452,2.1583154 22.28818,2.1589327 22.27757,2.1586646 C 22.266941,2.1582984 22.22569,2.1589509 22.21507,2.1586646 z M 17.71507,12.276184 L 22.62132,14.154286 C 22.81175,14.267881 23.01278,14.435772 23.15257,14.699542 C 23.1571,14.708551 23.179426,14.750896 23.18382,14.760126 C 23.188075,14.769579 23.21096,14.81103 23.21507,14.82071 C 23.22041,14.841238 23.241337,14.920817 23.24632,14.941878 C 23.251999,14.95252 23.271934,14.991758 23.27757,15.002462 C 23.287659,15.050182 23.301098,15.140858 23.30882,15.184213 C 23.31759,15.23957 23.333658,15.357843 23.34007,15.426549 C 23.339992,15.438417 23.340018,15.479387 23.34007,15.487133 C 23.339819,15.521508 23.340108,15.585519 23.34007,15.608301 C 23.340424,15.663284 23.342068,15.7929 23.34007,15.850637 C 23.340213,15.857291 23.340053,15.905738 23.34007,15.911221 C 23.334346,15.932761 23.314288,16.011386 23.30882,16.032389 C 23.301582,16.085713 23.286162,16.165159 23.27757,16.214141 C 23.277854,16.220106 23.277536,16.26914 23.27757,16.274724 C 23.271906,16.296984 23.25173,16.376333 23.24632,16.395892 C 23.239195,16.423912 23.222717,16.490827 23.21507,16.51706 C 23.209477,16.527695 23.189444,16.567118 23.18382,16.577644 C 23.178558,16.599151 23.157949,16.677728 23.15257,16.698812 C 23.148028,16.709363 23.125972,16.749256 23.12132,16.759396 C 23.11656,16.76913 23.094935,16.810648 23.09007,16.81998 C 23.085103,16.828916 23.063887,16.87202 23.05882,16.880564 C 23.048199,16.890925 23.007148,16.931636 22.99632,16.941148 C 22.990819,16.952148 22.970592,16.990822 22.96507,17.001732 C 22.944002,17.018636 22.893058,17.048529 22.87132,17.062316 C 22.847095,17.079175 22.802773,17.111202 22.77757,17.1229 C 22.612332,17.190858 22.424054,17.160765 22.24632,17.062316 L 17.30882,15.002462 L 17.71507,12.276184 z M 25.52757,15.365965 C 25.530825,15.366276 25.55604,15.365853 25.55882,15.365965 C 25.565179,15.366205 25.587067,15.366199 25.59007,15.365965 C 25.734218,15.35473 25.912092,15.429626 26.09007,15.487133 L 34.40257,19.243338 C 35.74632,19.970345 36.62132,22.636039 36.62132,22.636039 L 36.27757,25.604652 C 36.131925,25.226612 35.134625,22.855136 34.05882,22.211951 C 34.021451,22.190975 33.970929,22.166514 33.93382,22.151367 C 33.93382,22.151367 25.71507,18.273995 25.71507,18.273995 C 25.495207,18.158558 25.270857,18.011896 25.12132,17.789323 C 25.116316,17.781446 25.094918,17.736824 25.09007,17.728739 C 25.08555,17.720225 25.06317,17.676892 25.05882,17.668155 C 25.054645,17.659191 25.031565,17.616768 25.02757,17.607571 C 25.022153,17.586969 25.001302,17.507562 24.99632,17.486403 C 24.990618,17.475737 24.970721,17.436551 24.96507,17.425819 C 24.965383,17.419634 24.964978,17.370585 24.96507,17.365236 C 24.95934,17.344134 24.939322,17.265454 24.93382,17.244068 C 24.933991,17.23806 24.933762,17.188791 24.93382,17.183484 C 24.933789,17.16258 24.933601,17.083529 24.93382,17.062316 C 24.933091,17.020577 24.932151,16.92525 24.93382,16.880564 C 24.933862,16.87371 24.933959,16.827663 24.93382,16.81998 C 24.933112,16.794763 24.932973,16.720254 24.93382,16.698812 C 24.933676,16.692154 24.933842,16.643715 24.93382,16.638228 C 24.939564,16.616614 24.95974,16.537187 24.96507,16.51706 C 24.973859,16.463103 24.986707,16.384561 24.99632,16.335308 C 25.001624,16.314686 25.022037,16.234936 25.02757,16.214141 C 25.044693,16.14371 25.071947,16.032743 25.09007,15.971805 C 25.10449,15.931168 25.13495,15.835477 25.15257,15.790053 C 25.157148,15.780603 25.179151,15.738506 25.18382,15.729469 C 25.190237,15.716896 25.210812,15.677149 25.21507,15.668885 C 25.226363,15.658199 25.267316,15.617994 25.27757,15.608301 C 25.293462,15.592294 25.327504,15.559564 25.34007,15.547717 C 25.34556,15.536613 25.365807,15.498153 25.37132,15.487133 C 25.382249,15.487466 25.422799,15.486481 25.43382,15.487133 C 25.4381,15.478911 25.458553,15.439035 25.46507,15.426549 C 25.46785,15.426662 25.493066,15.42623 25.49632,15.426549 C 25.503473,15.412939 25.526239,15.369363 25.52757,15.365965 z M 16.80882,18.81925 L 21.71507,20.697353 C 21.9055,20.810948 22.10653,20.978838 22.24632,21.242608 C 22.25085,21.251617 22.273176,21.293962 22.27757,21.303192 C 22.281825,21.312645 22.30471,21.354096 22.30882,21.363776 C 22.31416,21.384305 22.335087,21.463884 22.34007,21.484944 C 22.345749,21.495585 22.365684,21.534824 22.37132,21.545528 C 22.37114,21.548597 22.371262,21.592399 22.37132,21.606112 C 22.376977,21.627185 22.397108,21.705946 22.40257,21.72728 C 22.409586,21.771565 22.427062,21.856925 22.43382,21.909032 C 22.433993,21.915743 22.433781,21.961855 22.43382,21.969615 C 22.433391,22.004207 22.433491,22.068444 22.43382,22.090783 C 22.433744,22.136348 22.436183,22.22426 22.43382,22.272535 C 22.428563,22.354532 22.414777,22.485525 22.40257,22.575455 C 22.402657,22.580618 22.402259,22.630657 22.40257,22.636039 C 22.389865,22.694275 22.354068,22.824375 22.34007,22.878375 C 22.333214,22.907302 22.316209,22.97242 22.30882,22.999543 C 22.303517,23.020895 22.282998,23.099794 22.27757,23.12071 C 22.271991,23.131398 22.251928,23.170713 22.24632,23.181294 C 22.210891,23.269026 22.16339,23.361433 22.12132,23.42363 C 22.115809,23.434586 22.095603,23.473352 22.09007,23.484214 C 22.074217,23.500137 22.040551,23.532239 22.02757,23.544798 C 22.018802,23.552646 21.981593,23.589516 21.96507,23.605382 C 21.961925,23.604876 21.936564,23.605529 21.93382,23.605382 C 21.922911,23.616495 21.882288,23.655171 21.87132,23.665966 C 21.706082,23.733925 21.517804,23.70383 21.34007,23.605382 L 16.40257,21.545528 L 16.80882,18.81925 z M 24.62132,22.030199 C 24.624575,22.03051 24.64979,22.030087 24.65257,22.030199 C 24.658929,22.03044 24.680817,22.030434 24.68382,22.030199 C 24.827968,22.018965 25.005842,22.09386 25.18382,22.151367 L 33.49632,25.907572 C 34.84007,26.634579 35.59007,29.118521 35.59007,29.118521 L 35.27757,31.905383 C 35.131925,31.527343 34.228375,29.51937 33.15257,28.876185 C 33.115201,28.855209 33.064679,28.830746 33.02757,28.815601 C 33.02757,28.815601 24.80882,24.938229 24.80882,24.938229 C 24.588957,24.822792 24.364607,24.67613 24.21507,24.453557 C 24.210066,24.44568 24.188668,24.401058 24.18382,24.392973 C 24.1793,24.384459 24.15692,24.341127 24.15257,24.332389 C 24.148395,24.323425 24.125315,24.281003 24.12132,24.271805 C 24.115903,24.251203 24.095052,24.171796 24.09007,24.150638 C 24.084368,24.139971 24.064471,24.100786 24.05882,24.090054 C 24.059133,24.083867 24.058728,24.03482 24.05882,24.02947 C 24.05309,24.008369 24.033072,23.929687 24.02757,23.908302 C 24.027741,23.902294 24.027512,23.853024 24.02757,23.847718 C 24.027539,23.826815 24.027351,23.747763 24.02757,23.72655 C 24.026841,23.68481 24.025901,23.589485 24.02757,23.544798 C 24.027612,23.537945 24.027709,23.491897 24.02757,23.484214 C 24.026862,23.458998 24.026723,23.384488 24.02757,23.363046 C 24.027426,23.356389 24.027592,23.307949 24.02757,23.302462 C 24.033314,23.280848 24.05349,23.201422 24.05882,23.181294 C 24.067609,23.127337 24.080457,23.048795 24.09007,22.999543 C 24.095374,22.978921 24.115787,22.899169 24.12132,22.878375 C 24.138443,22.807944 24.165697,22.696978 24.18382,22.636039 C 24.19824,22.595402 24.2287,22.49971 24.24632,22.454287 C 24.250898,22.444838 24.272901,22.402739 24.27757,22.393703 C 24.283987,22.381131 24.304562,22.341384 24.30882,22.333119 C 24.320113,22.322433 24.361066,22.282229 24.37132,22.272535 C 24.387212,22.256527 24.421254,22.223799 24.43382,22.211951 C 24.442334,22.204567 24.479755,22.167297 24.49632,22.151367 C 24.499477,22.15184 24.524822,22.15123 24.52757,22.151367 C 24.53185,22.143145 24.552303,22.103269 24.55882,22.090783 C 24.5616,22.090896 24.586816,22.090465 24.59007,22.090783 C 24.597223,22.077174 24.619989,22.033598 24.62132,22.030199 z M 15.87132,25.362316 L 20.77757,27.301003 C 20.916425,27.383831 21.062201,27.51338 21.18382,27.664506 C 21.194868,27.674737 21.235393,27.714612 21.24632,27.72509 C 21.251851,27.735875 21.272073,27.774824 21.27757,27.785674 C 21.282892,27.794757 21.303647,27.8369 21.30882,27.846258 C 21.321992,27.871568 21.355511,27.936043 21.37132,27.967426 C 21.376966,27.978114 21.396964,28.017262 21.40257,28.02801 C 21.40239,28.034683 21.402626,28.083077 21.40257,28.088594 C 21.408105,28.11002 21.428262,28.1896 21.43382,28.209762 C 21.439547,28.220339 21.459391,28.259704 21.46507,28.270346 C 21.476102,28.332281 21.490569,28.443946 21.49632,28.512682 C 21.49635,28.533468 21.496523,28.612776 21.49632,28.63385 C 21.496978,28.678531 21.497906,28.768239 21.49632,28.815601 C 21.496404,28.821825 21.496321,28.870751 21.49632,28.876185 C 21.488511,28.947075 21.472138,29.060566 21.46507,29.118521 C 21.4653,29.124591 21.465044,29.173756 21.46507,29.179105 C 21.450883,29.240205 21.416414,29.36568 21.40257,29.421441 C 21.394497,29.453078 21.376582,29.521502 21.37132,29.542609 C 21.365935,29.563074 21.34822,29.632543 21.34007,29.663777 C 21.334926,29.685211 21.313984,29.765067 21.30882,29.784945 C 21.283564,29.842107 21.241673,29.921839 21.21507,29.966696 C 21.209548,29.977605 21.189366,30.016466 21.18382,30.02728 C 21.178309,30.038236 21.158103,30.077002 21.15257,30.087864 C 21.136717,30.103787 21.103051,30.135889 21.09007,30.148448 C 21.081302,30.156296 21.044093,30.193166 21.02757,30.209032 C 21.024425,30.208526 20.999064,30.20918 20.99632,30.209032 C 20.816986,30.312271 20.600812,30.318841 20.40257,30.209032 L 15.46507,28.02801 L 15.87132,25.362316 z M 14.99632,31.844799 L 19.90257,33.904653 C 20.124738,34.037182 20.357682,34.28482 20.49632,34.63166 C 20.501966,34.642348 20.521964,34.681496 20.52757,34.692244 C 20.535744,34.722817 20.552148,34.787858 20.55882,34.813412 C 20.568703,34.861428 20.583054,34.950879 20.59007,34.995164 C 20.595838,35.016096 20.615766,35.095125 20.62132,35.116332 C 20.621319,35.137155 20.621549,35.216393 20.62132,35.2375 C 20.621261,35.249343 20.621256,35.290352 20.62132,35.298084 C 20.621251,35.33224 20.621732,35.396022 20.62132,35.419252 C 20.621391,35.42549 20.621332,35.474388 20.62132,35.479836 C 20.621481,35.485778 20.621296,35.5351 20.62132,35.54042 C 20.617818,35.563312 20.594899,35.636732 20.59007,35.661587 C 20.588742,35.668974 20.591084,35.715636 20.59007,35.722171 C 20.590357,35.727516 20.590016,35.777612 20.59007,35.782755 C 20.581625,35.844968 20.568846,35.960998 20.55882,36.025091 C 20.527306,36.178951 20.478107,36.339513 20.43382,36.449179 C 20.429278,36.459729 20.407222,36.499623 20.40257,36.509763 C 20.39781,36.519497 20.376185,36.561014 20.37132,36.570347 C 20.366353,36.579282 20.345137,36.622387 20.34007,36.630931 C 20.334548,36.64184 20.314366,36.680701 20.30882,36.691515 C 20.298226,36.702005 20.257109,36.742436 20.24632,36.752098 C 20.240829,36.763141 20.220581,36.801727 20.21507,36.812682 C 20.19029,36.831532 20.142745,36.859668 20.12132,36.873266 C 20.110411,36.87302 20.069788,36.873831 20.05882,36.873266 C 19.893582,36.941225 19.705304,36.911131 19.52757,36.812682 L 14.59007,34.571076 L 14.99632,31.844799 z M 14.02757,38.387865 L 18.93382,40.447719 C 19.12425,40.561315 19.32528,40.729205 19.46507,40.992975 C 19.4696,41.001984 19.491926,41.044329 19.49632,41.053559 C 19.500575,41.063012 19.52346,41.104463 19.52757,41.114143 C 19.53291,41.134671 19.553837,41.214251 19.55882,41.235311 C 19.564499,41.245952 19.584434,41.285191 19.59007,41.295894 C 19.600159,41.343615 19.613598,41.434291 19.62132,41.477646 C 19.63009,41.533002 19.646158,41.651275 19.65257,41.719982 C 19.653091,41.730717 19.652466,41.765074 19.65257,41.780566 C 19.652319,41.814941 19.652608,41.878952 19.65257,41.901734 C 19.652924,41.956717 19.654568,42.086334 19.65257,42.14407 C 19.651575,42.151161 19.653861,42.197044 19.65257,42.204654 C 19.647845,42.228885 19.625022,42.303738 19.62132,42.325822 C 19.614082,42.379147 19.598662,42.458593 19.59007,42.507573 C 19.582172,42.549191 19.568118,42.642227 19.55882,42.689325 C 19.551695,42.717345 19.535217,42.784261 19.52757,42.810493 C 19.521977,42.821129 19.501944,42.86055 19.49632,42.871077 C 19.491058,42.892585 19.470449,42.971162 19.46507,42.992245 C 19.460528,43.002795 19.438472,43.04269 19.43382,43.052829 C 19.42906,43.062563 19.407435,43.10408 19.40257,43.113413 C 19.397603,43.122348 19.376387,43.165453 19.37132,43.173997 C 19.360699,43.184357 19.319648,43.22507 19.30882,43.234581 C 19.303319,43.245581 19.283092,43.284256 19.27757,43.295165 C 19.256502,43.312068 19.205558,43.341963 19.18382,43.355749 C 19.159595,43.372607 19.115273,43.404635 19.09007,43.416333 C 18.924832,43.484291 18.736554,43.454197 18.55882,43.355749 L 13.62132,41.114143 L 14.02757,38.387865 z"
+ style="opacity:0.44318201;fill:url(#radialGradient3202);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.00014997;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><g
+ id="g2937"><path
+ style="opacity:1;fill:url(#linearGradient3204);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 22.28125,15.84375 L 30.59375,17.78125 C 31.9375,18.15625 33.0625,19.78125 33.0625,19.78125 L 32.65625,21.375 C 32.65625,21.375 31.3125,19.53125 30.125,19.28125 C 30.125,19.28125 21.90625,17.28125 21.90625,17.28125 C 21.421036,17.149843 20.971366,16.960466 21.15625,16.375 C 21.34375,15.78125 21.71875,15.75 22.28125,15.84375 z"
+ id="path2284"
+ sodipodi:nodetypes="cccccczc" /></g><path
+ sodipodi:nodetypes="ccccccccccsccc"
+ id="path1345"
+ d="M 31.5,19 L 31.375,34.375 L 31.375,34.40625 L 31.375,34.4375 C 31.462702,35.84074 30.279231,37.074596 29.125,36.84375 L 18.65625,34.6875 C 18.1875,34.5625 16.9375,34.0625 17.34375,32.625 L 15.40625,32.125 C 14.727493,34.561693 16.65625,36.28125 18.09375,36.59375 L 28.75,38.78125 C 31.324613,39.296173 33.497942,36.947282 33.375,34.375 C 33.37399,34.353864 33.376323,34.333663 33.375,34.3125 L 33.5,19 L 31.5,19 z"
+ style="opacity:1;fill:#747474;fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3206);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 21.25,19.28125 L 29.5625,21.21875 C 30.90625,21.59375 32.03125,23.21875 32.03125,23.21875 L 31.625,24.8125 C 31.625,24.8125 30.28125,22.96875 29.09375,22.71875 C 29.09375,22.71875 20.875,20.71875 20.875,20.71875 C 20.389786,20.587343 19.940116,20.397966 20.125,19.8125 C 20.3125,19.21875 20.6875,19.1875 21.25,19.28125 z"
+ id="path2286"
+ sodipodi:nodetypes="cccccczc" /><path
+ sodipodi:nodetypes="cccccczc"
+ id="path2280"
+ d="M 24.09375,8.9687499 L 32.40625,10.90625 C 33.75,11.28125 34.46875,12.40625 34.46875,12.40625 L 34.0625,14 C 34.0625,14 33.125,12.65625 31.9375,12.40625 C 31.9375,12.40625 23.71875,10.40625 23.71875,10.40625 C 23.233536,10.274843 22.783866,10.085466 22.96875,9.4999999 C 23.15625,8.9062499 23.53125,8.8749999 24.09375,8.9687499 z"
+ style="opacity:1;fill:url(#linearGradient3208);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3210);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 23.1875,12.40625 L 31.5,14.34375 C 32.84375,14.71875 33.5625,15.90625 33.5625,15.90625 L 33.125,17.40625 C 33.125,17.40625 32.21875,16.09375 31.03125,15.84375 C 31.03125,15.84375 22.8125,13.84375 22.8125,13.84375 C 22.327286,13.712343 21.877616,13.522966 22.0625,12.9375 C 22.25,12.34375 22.625,12.3125 23.1875,12.40625 z"
+ id="path2282"
+ sodipodi:nodetypes="cccccczc" /><path
+ transform="matrix(1.26667,0,0,1.26667,-10.3083,-8.15)"
+ d="M 35.375,22.125 A 1.875,1.875 0 1 1 31.625,22.125 A 1.875,1.875 0 1 1 35.375,22.125 z"
+ sodipodi:ry="1.875"
+ sodipodi:rx="1.875"
+ sodipodi:cy="22.125"
+ sodipodi:cx="33.5"
+ id="path2220"
+ style="opacity:1;fill:url(#radialGradient3212);fill-opacity:1;fill-rule:evenodd;stroke:#424242;stroke-width:0.789473;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="arc" /><path
+ sodipodi:nodetypes="cccccczc"
+ id="path2288"
+ d="M 20.34375,22.71875 L 28.65625,24.65625 C 30,25.03125 31.125,26.65625 31.125,26.65625 L 30.71875,28.25 C 30.71875,28.25 29.375,26.40625 28.1875,26.15625 C 28.1875,26.15625 19.96875,24.15625 19.96875,24.15625 C 19.483536,24.024843 19.096366,23.835466 19.21875,23.25 C 19.342601,22.657518 19.78125,22.625 20.34375,22.71875 z"
+ style="opacity:1;fill:url(#linearGradient3214);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2292"
+ d="M 11.966306,22.990197 L 7.0288059,21.833947 L 7.4350559,20.427697 L 12.341306,21.490197 C 12.747556,21.615197 13.185056,21.865197 13.028806,22.458947 C 12.874388,23.045734 12.403806,23.115197 11.966306,22.990197 z"
+ style="opacity:1;fill:url(#linearGradient3216);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3218);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 17.53125,19.976562 L 12.59375,18.820312 L 13,17.414062 L 17.90625,18.476562 C 18.3125,18.601562 18.75,18.851562 18.59375,19.445312 C 18.439332,20.0321 17.96875,20.101562 17.53125,19.976562 z"
+ id="path2294"
+ sodipodi:nodetypes="cccczc" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2296"
+ d="M 18.40625,16.546875 L 13.46875,15.453125 L 13.875,14.046875 L 18.78125,15.046875 C 19.1875,15.171875 19.625,15.421875 19.46875,16.015625 C 19.314332,16.602412 18.84375,16.671875 18.40625,16.546875 z"
+ style="opacity:1;fill:url(#linearGradient3220);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:1;fill:url(#linearGradient3222);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 19.34375,13.148438 L 14.40625,12.085938 L 14.8125,10.679688 L 19.71875,11.648438 C 20.125,11.773438 20.5625,12.023438 20.40625,12.617188 C 20.251832,13.203974 19.78125,13.273438 19.34375,13.148438 z"
+ id="path2298"
+ sodipodi:nodetypes="cccczc" /><path
+ sodipodi:nodetypes="cccczc"
+ id="path2300"
+ d="M 20.25,9.78125 L 15.3125,8.71875 L 15.71875,7.3125 L 20.625,8.28125 C 21.03125,8.40625 21.46875,8.65625 21.3125,9.25 C 21.158082,9.836787 20.6875,9.90625 20.25,9.78125 z"
+ style="opacity:1;fill:url(#linearGradient3224);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:type="arc"
+ style="opacity:0.29545504;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3226);stroke-width:1.16238999;stroke-linecap:butt;stroke-linejoin:miter;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="path2389"
+ sodipodi:cx="16.4375"
+ sodipodi:cy="46.375"
+ sodipodi:rx="11.1875"
+ sodipodi:ry="5.875"
+ d="M 27.625,46.375 A 11.1875,5.875 0 1 1 5.25,46.375 A 11.1875,5.875 0 1 1 27.625,46.375 z"
+ transform="matrix(0.916296,0,0,0.807726,10.1259,1.91671)" /></g></svg> \ No newline at end of file
diff --git a/icons/text.svg b/icons/text.svg
new file mode 100755
index 0000000..ddfee40
--- /dev/null
+++ b/icons/text.svg
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ x="0px"
+ y="0px"
+ width="55px"
+ height="55px"
+ viewBox="0 0 55 55"
+ enable-background="new 0 0 55 55"
+ xml:space="preserve"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.45"
+ sodipodi:docname="text.svg"
+ sodipodi:docbase="/home/joy/oficina_sugar/oficina/icons"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ sodipodi:modified="true"><metadata
+ id="metadata12"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs10" /><sodipodi:namedview
+ inkscape:window-height="941"
+ inkscape:window-width="1269"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="6.8909091"
+ inkscape:cx="27.5"
+ inkscape:cy="27.5"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:current-layer="svg2" />
+
+
+
+<rect
+ style="fill:#999999;stroke:#ffffff;stroke-opacity:1"
+ id="rect2175"
+ width="51.952507"
+ height="39.327175"
+ x="1.5963061"
+ y="5.6596308" /><rect
+ style="fill:#ffffff;stroke:#ffffff;stroke-opacity:1"
+ id="rect2161"
+ width="27.282322"
+ height="4.4986806"
+ x="13.496042"
+ y="11.319262" /><rect
+ style="fill:#ffffff;stroke:#ffffff;stroke-width:1.06520391;stroke-opacity:1"
+ id="rect2163"
+ width="4.4334769"
+ height="24.89522"
+ x="25.314924"
+ y="16.866377" /></svg> \ No newline at end of file
diff --git a/icons/tool-brush.svg b/icons/tool-brush.svg
new file mode 100755
index 0000000..e888321
--- /dev/null
+++ b/icons/tool-brush.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px"
+ height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+
+<g id="Brush" >
+ <g display="inline">
+ <path fill="#FFFFFF" d="M26.939,32.777c0,0,9.546-10.04,12.062-13.721c3.697-5.406,5.988-10.829,3.994-11.775
+ c-1.468-0.697-6.469,3.434-9.471,7.896C31.491,18.205,24,30.635,24,30.635L26.939,32.777z"/>
+ <path fill="#FFFFFF" d="M25.613,34.668l-2.971-2.166c0,0-3.054,1.592-4.602,3.862c-1.546,2.284-2.31,6.661-4.752,9.01
+ c-1.465,1.409-0.186,1.085-0.186,1.085s7.907-2.985,9.786-5.477C24.75,38.512,25.613,34.668,25.613,34.668z"/>
+ </g>
+</g>
+
+</svg>
diff --git a/icons/tool-eraser.svg b/icons/tool-eraser.svg
new file mode 100755
index 0000000..41fc143
--- /dev/null
+++ b/icons/tool-eraser.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px"
+ height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+
+<g id="Eraser" >
+ <g display="inline">
+ <path fill="#FFFFFF" d="M15.621,33.853c-1.1,0-1.424-0.691-0.721-1.536l14.249-17.109c0.704-0.845,2.18-1.537,3.28-1.537h7.805
+ c1.1,0,1.424,0.691,0.721,1.537L26.706,32.316c-0.704,0.845-2.18,1.536-3.28,1.536H15.621z"/>
+ <path fill="#FFFFFF" d="M24.709,41.155c-0.166,1.088-1.2,1.978-2.301,1.978h-8.525c-1.1,0-1.865-0.89-1.7-1.978l0.549-3.62
+ c0.165-1.088,1.2-1.978,2.3-1.978h8.525c1.101,0,1.865,0.89,1.701,1.978L24.709,41.155z"/>
+ <path fill="#FFFFFF" d="M40.446,23.333c-0.189,1.083-0.921,2.662-1.625,3.507L27.471,40.467c-0.705,0.846-1.125,0.65-0.936-0.434
+ l0.646-3.688c0.19-1.083,0.921-2.661,1.626-3.506l11.35-13.627c0.705-0.845,1.125-0.65,0.936,0.434L40.446,23.333z"/>
+ </g>
+</g>
+
+</svg>
diff --git a/icons/tool-pencil.svg b/icons/tool-pencil.svg
new file mode 100755
index 0000000..c7a1ef9
--- /dev/null
+++ b/icons/tool-pencil.svg
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px"
+ height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+
+<g id="Pencil" >
+ <g display="inline">
+ <path fill="#FFFFFF" d="M12.727,45.969c-0.053,0.132-0.02,0.281,0.09,0.373s0.264,0.103,0.385,0.025l4.635-2.984l-3.009-2.407
+ L12.727,45.969z M42.967,14.071c0-0.073-0.004-0.15-0.014-0.227c-0.112-0.949-0.903-2.109-2.062-3.025
+ c-1.16-0.915-2.474-1.413-3.424-1.304c-0.414,0.052-0.747,0.228-0.973,0.491l-0.021-0.015L19.716,32.17l-0.073,0.073l-0.011,0.015
+ c-0.026,0.029-0.029,0.069-0.05,0.103l-2.177,2.677c0,0,0.128,0.099,0.256,0.201l-0.002,0.004l-0.009,0.011
+ c-0.128-0.103-0.252-0.197-0.252-0.197l-0.042,0.051c-0.097,0.121-0.155,0.271-0.203,0.429c-0.015,0.019-0.046,0.025-0.057,0.048
+ l-1.361,3.236l4.097,3.278l3.202-2.062c0.019-0.011,0.015-0.037,0.031-0.052c0.083-0.065,0.178-0.121,0.243-0.201
+ c0.008-0.011,0.043-0.059,0.048-0.062l2.237-2.79l0.033-0.033l-0.004-0.004l0.023-0.029l0.006,0.004L42.59,15.02
+ c0.029-0.029,0.071-0.044,0.1-0.077c0.032-0.044,0.049-0.103,0.076-0.15l0.015-0.019l-0.003-0.003
+ C42.895,14.566,42.967,14.339,42.967,14.071z"/>
+ </g>
+</g>
+
+</svg>
diff --git a/icons/unlocked.svg b/icons/unlocked.svg
new file mode 100755
index 0000000..9e47d87
--- /dev/null
+++ b/icons/unlocked.svg
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg version="1.0"
+ id="svg2" xmlns:svg="http://www.w3.org/2000/svg" inkscape:version="0.46" xmlns:dc="http://purl.org/dc/elements/1.1/" sodipodi:version="0.32" sodipodi:docname="unlocked.svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55px" height="55px"
+ viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<defs>
+
+
+ <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" id="perspective10">
+ </inkscape:perspective>
+</defs>
+<sodipodi:namedview inkscape:window-y="6" inkscape:window-x="42" inkscape:window-height="667" inkscape:window-width="774" showgrid="false" inkscape:current-layer="layer1" inkscape:document-units="px" inkscape:cy="27.5" inkscape:cx="27.5" inkscape:zoom="8.4" inkscape:pageshadow="2" inkscape:pageopacity="0.0" objecttolerance="10" guidetolerance="10" gridtolerance="10000" borderopacity="1.0" bordercolor="#666666" pagecolor="#ffffff" id="base">
+ </sodipodi:namedview>
+<rect id="rect2405" x="5" y="25" fill="#FFFFFF" width="35" height="25"/>
+<g>
+ <g>
+ <path fill="#FFFFFF" d="M37.5,2.5C30.597,2.5,25,5.858,25,10v15h5V12.5h0.018C30.012,12.42,30,12.342,30,12.262
+ c0-2.891,3.359-5.238,7.5-5.238S45,9.371,45,12.262c0,0.081-0.012,0.159-0.018,0.238H45V25h5V10C50,5.858,44.403,2.5,37.5,2.5z"/>
+ </g>
+</g>
+</svg>
diff --git a/ink.py b/ink.py
new file mode 100755
index 0000000..544bc78
--- /dev/null
+++ b/ink.py
@@ -0,0 +1,61 @@
+# ink.py
+#
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import random
+import logging
+
+class Path:
+
+ def __init__(self, inkstr=None):
+ self.__logger = logging.getLogger('Path')
+ self.points=[]
+ self.color = (0,0,1.0)
+ self.pen = 4
+ self.uid = random.randint(0, 2147483647)
+ if inkstr:
+ try:
+ i=0
+ parts = inkstr.split('#')
+ if len(parts) > 1:
+ params = parts[i].split(';')
+ self.uid = int(params[0])
+ colorparts = params[1].split(',')
+ self.color = (float(colorparts[0]),float(colorparts[1]),float(colorparts[2]))
+ self.pen = float(params[2])
+ i = i + 1
+ pathstr = parts[i]
+ pointstrs = pathstr.split(';')
+ for pointstr in pointstrs:
+ pparts = pointstr.split(',')
+ if len(pparts) == 2:
+ self.add((int(pparts[0]), int(pparts[1])))
+ except Exception, e:
+ self.__logger.debug('Could not unserialize ink string (old ink?)')
+
+ def add(self, point):
+ self.points.append(point)
+
+ def __str__(self):
+ s = str(self.uid) + ";"
+ s = s + str(self.color[0]) + "," + str(self.color[1]) + "," + str(self.color[2]) + ";"
+ s = s + str(self.pen) + "#"
+ for p in self.points:
+ s = s + str(int(p[0])) + "," + str(int(p[1])) + ";"
+ return s
diff --git a/listview.py b/listview.py
new file mode 100644
index 0000000..bf43040
--- /dev/null
+++ b/listview.py
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+
+# ZetCode PyGTK tutorial
+#
+# This example shows a TreeView widget
+# in a list view mode
+#
+# author: jan bodnar
+# website: zetcode.com
+# last edited: February 2009
+
+import sys, os
+import gtk
+from sugar.datastore import datastore
+from path import path
+
+
+class Listview(gtk.VBox):
+ def __init__(self, activity, deck):
+ self.activity = activity
+ gtk.VBox.__init__(self)
+ vbox = gtk.VBox(False, 8)
+ sw = gtk.ScrolledWindow()
+ sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.pack_start(sw, True, True, 0)
+ treeView = gtk.TreeView()
+ treeView.connect("row-activated", self.on_activated)
+ treeView.set_rules_hint(True)
+ sw.add(treeView)
+ self.create_columns(treeView)
+ self.treeView = treeView
+ self.deck = deck
+ self.add(vbox)
+ self.show_all()
+
+ def create_columns(self, treeView):
+
+ rendererText = gtk.CellRendererText()
+ column = gtk.TreeViewColumn("Title", rendererText, text=0)
+ column.set_sort_column_id(0)
+ treeView.append_column(column)
+ rendererText = gtk.CellRendererText()
+ column = gtk.TreeViewColumn("Mime_type", rendererText, text=1)
+ column.set_sort_column_id(1)
+ treeView.append_column(column)
+ rendererText = gtk.CellRendererText()
+ column = gtk.TreeViewColumn("Date", rendererText, text=2)
+ column.set_sort_column_id(2)
+ treeView.append_column(column)
+
+ def get_treeView(self):
+ return self.treeView
+
+ def set_store(self, mountpoint, pth):
+ print 'set_store', mountpoint, pth
+ store = gtk.ListStore(str, str, str)
+ #get objects from the local datastore
+ ds_objects, num_objects = datastore.find({'mountpoints':[mountpoint], 'mime_type':['image/jpg', 'image/png', 'image/svg']})
+ for f in ds_objects:
+ try:
+ title = f.metadata['title']
+ except:
+ title = ""
+ try:
+ mime_type = f.metadata['mime_type']
+ except:
+ mime_type = 'unknown'
+ try:
+ timestamp = f.metadata['timestamp']
+ except:
+ timestamp = "0"
+ store.append([title, mime_type, timestamp])
+ f.destroy()
+ return store
+
+ def on_activated(self, widget, row, col):
+
+ model = widget.get_model()
+ print 'row', model[row][0], model[row][1], model[row][2]
+ title = model[row][0]
+ mime_type = model[row][1]
+ timestamp = model[row][2]
+ print 'search for', title, mime_type, timestamp
+ if int(timestamp) > 0:
+ ds_objects, num_objects = datastore.find({'title':[title], 'timestamp':[timestamp]})
+ else:
+ ds_objects, num_objects = datastore.find({'title':[title], 'mime_type': [mime_type]})
+ if num_objects > 0:
+ object = ds_objects[0]
+ else:
+ print 'datastore find failed', f
+ fn = object.file_path
+ print 'object filename', path(fn).exists(), fn
+ self.deck.addSlide(fn)
+ self.deck.reload()
+ for object in ds_objects:
+ object.destroy()
+ scrn1, scrn2 = self.activity.get_window()
+ scrn2.hide()
+ scrn1.show()
+
+
diff --git a/manifest b/manifest
new file mode 100755
index 0000000..f58a5b4
--- /dev/null
+++ b/manifest
@@ -0,0 +1,27 @@
+classroompresenter.py
+setup.py
+activity/classroompresenter-activity.svg
+activity/application-x-classroompresenter.svg
+activity/activity.info
+activity/mimetypes.xml
+toolbars.py
+slideshow.py
+slideviewer.py
+sliderenderer.py
+textarea.py
+utils.py
+sidebar.py
+shared.py
+sharedslides.py
+ink.py
+resources/splash.svg
+icons/black-button.svg
+icons/blue-button.svg
+icons/green-button.svg
+icons/locked.svg
+icons/red-button.svg
+icons/text.svg
+icons/tool-brush.svg
+icons/tool-eraser.svg
+icons/tool-pencil.svg
+icons/unlocked.svg
diff --git a/news b/news
new file mode 100755
index 0000000..fbe3682
--- /dev/null
+++ b/news
@@ -0,0 +1 @@
+empty file for now; sugar complains if it's not here
diff --git a/path.py b/path.py
new file mode 100755
index 0000000..01c2c04
--- /dev/null
+++ b/path.py
@@ -0,0 +1,971 @@
+""" path.py - An object representing a path to a file or directory.
+
+Example:
+
+from path import path
+d = path('/home/guido/bin')
+for f in d.files('*.py'):
+ f.chmod(0755)
+
+This module requires Python 2.2 or later.
+
+
+URL: http://www.jorendorff.com/articles/python/path
+Author: Jason Orendorff <jason.orendorff\x40gmail\x2ecom> (and others - see the url!)
+Date: 9 Mar 2007
+"""
+
+
+# TODO
+# - Tree-walking functions don't avoid symlink loops. Matt Harrison
+# sent me a patch for this.
+# - Bug in write_text(). It doesn't support Universal newline mode.
+# - Better error message in listdir() when self isn't a
+# directory. (On Windows, the error message really sucks.)
+# - Make sure everything has a good docstring.
+# - Add methods for regex find and replace.
+# - guess_content_type() method?
+# - Perhaps support arguments to touch().
+
+from __future__ import generators
+
+import sys, warnings, os, fnmatch, glob, shutil, codecs, md5
+
+__version__ = '2.2'
+__all__ = ['path']
+
+# Platform-specific support for path.owner
+if os.name == 'nt':
+ try:
+ import win32security
+ except ImportError:
+ win32security = None
+else:
+ try:
+ import pwd
+ except ImportError:
+ pwd = None
+
+# Pre-2.3 support. Are unicode filenames supported?
+_base = str
+_getcwd = os.getcwd
+try:
+ if os.path.supports_unicode_filenames:
+ _base = unicode
+ _getcwd = os.getcwdu
+except AttributeError:
+ pass
+
+# Pre-2.3 workaround for booleans
+try:
+ True, False
+except NameError:
+ True, False = 1, 0
+
+# Pre-2.3 workaround for basestring.
+try:
+ basestring
+except NameError:
+ basestring = (str, unicode)
+
+# Universal newline support
+_textmode = 'r'
+if hasattr(file, 'newlines'):
+ _textmode = 'U'
+
+
+class TreeWalkWarning(Warning):
+ pass
+
+class path(_base):
+ """ Represents a filesystem path.
+
+ For documentation on individual methods, consult their
+ counterparts in os.path.
+ """
+
+ # --- Special Python methods.
+
+ def __repr__(self):
+ return 'path(%s)' % _base.__repr__(self)
+
+ # Adding a path and a string yields a path.
+ def __add__(self, more):
+ try:
+ resultStr = _base.__add__(self, more)
+ except TypeError: #Python bug
+ resultStr = NotImplemented
+ if resultStr is NotImplemented:
+ return resultStr
+ return self.__class__(resultStr)
+
+ def __radd__(self, other):
+ if isinstance(other, basestring):
+ return self.__class__(other.__add__(self))
+ else:
+ return NotImplemented
+
+ # The / operator joins paths.
+ def __div__(self, rel):
+ """ fp.__div__(rel) == fp / rel == fp.joinpath(rel)
+
+ Join two path components, adding a separator character if
+ needed.
+ """
+ return self.__class__(os.path.join(self, rel))
+
+ # Make the / operator work even when true division is enabled.
+ __truediv__ = __div__
+
+ def getcwd(cls):
+ """ Return the current working directory as a path object. """
+ return cls(_getcwd())
+ getcwd = classmethod(getcwd)
+
+
+ # --- Operations on path strings.
+
+ isabs = os.path.isabs
+ def abspath(self): return self.__class__(os.path.abspath(self))
+ def normcase(self): return self.__class__(os.path.normcase(self))
+ def normpath(self): return self.__class__(os.path.normpath(self))
+ def realpath(self): return self.__class__(os.path.realpath(self))
+ def expanduser(self): return self.__class__(os.path.expanduser(self))
+ def expandvars(self): return self.__class__(os.path.expandvars(self))
+ def dirname(self): return self.__class__(os.path.dirname(self))
+ basename = os.path.basename
+
+ def expand(self):
+ """ Clean up a filename by calling expandvars(),
+ expanduser(), and normpath() on it.
+
+ This is commonly everything needed to clean up a filename
+ read from a configuration file, for example.
+ """
+ return self.expandvars().expanduser().normpath()
+
+ def _get_namebase(self):
+ base, ext = os.path.splitext(self.name)
+ return base
+
+ def _get_ext(self):
+ f, ext = os.path.splitext(_base(self))
+ return ext
+
+ def _get_drive(self):
+ drive, r = os.path.splitdrive(self)
+ return self.__class__(drive)
+
+ parent = property(
+ dirname, None, None,
+ """ This path's parent directory, as a new path object.
+
+ For example, path('/usr/local/lib/libpython.so').parent == path('/usr/local/lib')
+ """)
+
+ name = property(
+ basename, None, None,
+ """ The name of this file or directory without the full path.
+
+ For example, path('/usr/local/lib/libpython.so').name == 'libpython.so'
+ """)
+
+ namebase = property(
+ _get_namebase, None, None,
+ """ The same as path.name, but with one file extension stripped off.
+
+ For example, path('/home/guido/python.tar.gz').name == 'python.tar.gz',
+ but path('/home/guido/python.tar.gz').namebase == 'python.tar'
+ """)
+
+ ext = property(
+ _get_ext, None, None,
+ """ The file extension, for example '.py'. """)
+
+ drive = property(
+ _get_drive, None, None,
+ """ The drive specifier, for example 'C:'.
+ This is always empty on systems that don't use drive specifiers.
+ """)
+
+ def splitpath(self):
+ """ p.splitpath() -> Return (p.parent, p.name). """
+ parent, child = os.path.split(self)
+ return self.__class__(parent), child
+
+ def splitdrive(self):
+ """ p.splitdrive() -> Return (p.drive, <the rest of p>).
+
+ Split the drive specifier from this path. If there is
+ no drive specifier, p.drive is empty, so the return value
+ is simply (path(''), p). This is always the case on Unix.
+ """
+ drive, rel = os.path.splitdrive(self)
+ return self.__class__(drive), rel
+
+ def splitext(self):
+ """ p.splitext() -> Return (p.stripext(), p.ext).
+
+ Split the filename extension from this path and return
+ the two parts. Either part may be empty.
+
+ The extension is everything from '.' to the end of the
+ last path segment. This has the property that if
+ (a, b) == p.splitext(), then a + b == p.
+ """
+ filename, ext = os.path.splitext(self)
+ return self.__class__(filename), ext
+
+ def stripext(self):
+ """ p.stripext() -> Remove one file extension from the path.
+
+ For example, path('/home/guido/python.tar.gz').stripext()
+ returns path('/home/guido/python.tar').
+ """
+ return self.splitext()[0]
+
+ if hasattr(os.path, 'splitunc'):
+ def splitunc(self):
+ unc, rest = os.path.splitunc(self)
+ return self.__class__(unc), rest
+
+ def _get_uncshare(self):
+ unc, r = os.path.splitunc(self)
+ return self.__class__(unc)
+
+ uncshare = property(
+ _get_uncshare, None, None,
+ """ The UNC mount point for this path.
+ This is empty for paths on local drives. """)
+
+ def joinpath(self, *args):
+ """ Join two or more path components, adding a separator
+ character (os.sep) if needed. Returns a new path
+ object.
+ """
+ return self.__class__(os.path.join(self, *args))
+
+ def splitall(self):
+ r""" Return a list of the path components in this path.
+
+ The first item in the list will be a path. Its value will be
+ either os.curdir, os.pardir, empty, or the root directory of
+ this path (for example, '/' or 'C:\\'). The other items in
+ the list will be strings.
+
+ path.path.joinpath(*result) will yield the original path.
+ """
+ parts = []
+ loc = self
+ while loc != os.curdir and loc != os.pardir:
+ prev = loc
+ loc, child = prev.splitpath()
+ if loc == prev:
+ break
+ parts.append(child)
+ parts.append(loc)
+ parts.reverse()
+ return parts
+
+ def relpath(self):
+ """ Return this path as a relative path,
+ based from the current working directory.
+ """
+ cwd = self.__class__(os.getcwd())
+ return cwd.relpathto(self)
+
+ def relpathto(self, dest):
+ """ Return a relative path from self to dest.
+
+ If there is no relative path from self to dest, for example if
+ they reside on different drives in Windows, then this returns
+ dest.abspath().
+ """
+ origin = self.abspath()
+ dest = self.__class__(dest).abspath()
+
+ orig_list = origin.normcase().splitall()
+ # Don't normcase dest! We want to preserve the case.
+ dest_list = dest.splitall()
+
+ if orig_list[0] != os.path.normcase(dest_list[0]):
+ # Can't get here from there.
+ return dest
+
+ # Find the location where the two paths start to differ.
+ i = 0
+ for start_seg, dest_seg in zip(orig_list, dest_list):
+ if start_seg != os.path.normcase(dest_seg):
+ break
+ i += 1
+
+ # Now i is the point where the two paths diverge.
+ # Need a certain number of "os.pardir"s to work up
+ # from the origin to the point of divergence.
+ segments = [os.pardir] * (len(orig_list) - i)
+ # Need to add the diverging part of dest_list.
+ segments += dest_list[i:]
+ if len(segments) == 0:
+ # If they happen to be identical, use os.curdir.
+ relpath = os.curdir
+ else:
+ relpath = os.path.join(*segments)
+ return self.__class__(relpath)
+
+ # --- Listing, searching, walking, and matching
+
+ def listdir(self, pattern=None):
+ """ D.listdir() -> List of items in this directory.
+
+ Use D.files() or D.dirs() instead if you want a listing
+ of just files or just subdirectories.
+
+ The elements of the list are path objects.
+
+ With the optional 'pattern' argument, this only lists
+ items whose names match the given pattern.
+ """
+ names = os.listdir(self)
+ if pattern is not None:
+ names = fnmatch.filter(names, pattern)
+ return [self / child for child in names]
+
+ def dirs(self, pattern=None):
+ """ D.dirs() -> List of this directory's subdirectories.
+
+ The elements of the list are path objects.
+ This does not walk recursively into subdirectories
+ (but see path.walkdirs).
+
+ With the optional 'pattern' argument, this only lists
+ directories whose names match the given pattern. For
+ example, d.dirs('build-*').
+ """
+ return [p for p in self.listdir(pattern) if p.isdir()]
+
+ def files(self, pattern=None):
+ """ D.files() -> List of the files in this directory.
+
+ The elements of the list are path objects.
+ This does not walk into subdirectories (see path.walkfiles).
+
+ With the optional 'pattern' argument, this only lists files
+ whose names match the given pattern. For example,
+ d.files('*.pyc').
+ """
+
+ return [p for p in self.listdir(pattern) if p.isfile()]
+
+ def walk(self, pattern=None, errors='strict'):
+ """ D.walk() -> iterator over files and subdirs, recursively.
+
+ The iterator yields path objects naming each child item of
+ this directory and its descendants. This requires that
+ D.isdir().
+
+ This performs a depth-first traversal of the directory tree.
+ Each directory is returned just before all its children.
+
+ The errors= keyword argument controls behavior when an
+ error occurs. The default is 'strict', which causes an
+ exception. The other allowed values are 'warn', which
+ reports the error via warnings.warn(), and 'ignore'.
+ """
+ if errors not in ('strict', 'warn', 'ignore'):
+ raise ValueError("invalid errors parameter")
+
+ try:
+ childList = self.listdir()
+ except Exception:
+ if errors == 'ignore':
+ return
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to list directory '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ return
+ else:
+ raise
+
+ for child in childList:
+ if pattern is None or child.fnmatch(pattern):
+ yield child
+ try:
+ isdir = child.isdir()
+ except Exception:
+ if errors == 'ignore':
+ isdir = False
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to access '%s': %s"
+ % (child, sys.exc_info()[1]),
+ TreeWalkWarning)
+ isdir = False
+ else:
+ raise
+
+ if isdir:
+ for item in child.walk(pattern, errors):
+ yield item
+
+ def walkdirs(self, pattern=None, errors='strict'):
+ """ D.walkdirs() -> iterator over subdirs, recursively.
+
+ With the optional 'pattern' argument, this yields only
+ directories whose names match the given pattern. For
+ example, mydir.walkdirs('*test') yields only directories
+ with names ending in 'test'.
+
+ The errors= keyword argument controls behavior when an
+ error occurs. The default is 'strict', which causes an
+ exception. The other allowed values are 'warn', which
+ reports the error via warnings.warn(), and 'ignore'.
+ """
+ if errors not in ('strict', 'warn', 'ignore'):
+ raise ValueError("invalid errors parameter")
+
+ try:
+ dirs = self.dirs()
+ except Exception:
+ if errors == 'ignore':
+ return
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to list directory '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ return
+ else:
+ raise
+
+ for child in dirs:
+ if pattern is None or child.fnmatch(pattern):
+ yield child
+ for subsubdir in child.walkdirs(pattern, errors):
+ yield subsubdir
+
+ def walkfiles(self, pattern=None, errors='strict'):
+ """ D.walkfiles() -> iterator over files in D, recursively.
+
+ The optional argument, pattern, limits the results to files
+ with names that match the pattern. For example,
+ mydir.walkfiles('*.tmp') yields only files with the .tmp
+ extension.
+ """
+ if errors not in ('strict', 'warn', 'ignore'):
+ raise ValueError("invalid errors parameter")
+
+ try:
+ childList = self.listdir()
+ except Exception:
+ if errors == 'ignore':
+ return
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to list directory '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ return
+ else:
+ raise
+
+ for child in childList:
+ try:
+ isfile = child.isfile()
+ isdir = not isfile and child.isdir()
+ except:
+ if errors == 'ignore':
+ continue
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to access '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ continue
+ else:
+ raise
+
+ if isfile:
+ if pattern is None or child.fnmatch(pattern):
+ yield child
+ elif isdir:
+ for f in child.walkfiles(pattern, errors):
+ yield f
+
+ def fnmatch(self, pattern):
+ """ Return True if self.name matches the given pattern.
+
+ pattern - A filename pattern with wildcards,
+ for example '*.py'.
+ """
+ return fnmatch.fnmatch(self.name, pattern)
+
+ def glob(self, pattern):
+ """ Return a list of path objects that match the pattern.
+
+ pattern - a path relative to this directory, with wildcards.
+
+ For example, path('/users').glob('*/bin/*') returns a list
+ of all the files users have in their bin directories.
+ """
+ cls = self.__class__
+ return [cls(s) for s in glob.glob(_base(self / pattern))]
+
+
+ # --- Reading or writing an entire file at once.
+
+ def open(self, mode='r'):
+ """ Open this file. Return a file object. """
+ return file(self, mode)
+
+ def bytes(self):
+ """ Open this file, read all bytes, return them as a string. """
+ f = self.open('rb')
+ try:
+ return f.read()
+ finally:
+ f.close()
+
+ def write_bytes(self, bytes, append=False):
+ """ Open this file and write the given bytes to it.
+
+ Default behavior is to overwrite any existing file.
+ Call p.write_bytes(bytes, append=True) to append instead.
+ """
+ if append:
+ mode = 'ab'
+ else:
+ mode = 'wb'
+ f = self.open(mode)
+ try:
+ f.write(bytes)
+ finally:
+ f.close()
+
+ def text(self, encoding=None, errors='strict'):
+ r""" Open this file, read it in, return the content as a string.
+
+ This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r'
+ are automatically translated to '\n'.
+
+ Optional arguments:
+
+ encoding - The Unicode encoding (or character set) of
+ the file. If present, the content of the file is
+ decoded and returned as a unicode object; otherwise
+ it is returned as an 8-bit str.
+ errors - How to handle Unicode errors; see help(str.decode)
+ for the options. Default is 'strict'.
+ """
+ if encoding is None:
+ # 8-bit
+ f = self.open(_textmode)
+ try:
+ return f.read()
+ finally:
+ f.close()
+ else:
+ # Unicode
+ f = codecs.open(self, 'r', encoding, errors)
+ # (Note - Can't use 'U' mode here, since codecs.open
+ # doesn't support 'U' mode, even in Python 2.3.)
+ try:
+ t = f.read()
+ finally:
+ f.close()
+ return (t.replace(u'\r\n', u'\n')
+ .replace(u'\r\x85', u'\n')
+ .replace(u'\r', u'\n')
+ .replace(u'\x85', u'\n')
+ .replace(u'\u2028', u'\n'))
+
+ def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False):
+ r""" Write the given text to this file.
+
+ The default behavior is to overwrite any existing file;
+ to append instead, use the 'append=True' keyword argument.
+
+ There are two differences between path.write_text() and
+ path.write_bytes(): newline handling and Unicode handling.
+ See below.
+
+ Parameters:
+
+ - text - str/unicode - The text to be written.
+
+ - encoding - str - The Unicode encoding that will be used.
+ This is ignored if 'text' isn't a Unicode string.
+
+ - errors - str - How to handle Unicode encoding errors.
+ Default is 'strict'. See help(unicode.encode) for the
+ options. This is ignored if 'text' isn't a Unicode
+ string.
+
+ - linesep - keyword argument - str/unicode - The sequence of
+ characters to be used to mark end-of-line. The default is
+ os.linesep. You can also specify None; this means to
+ leave all newlines as they are in 'text'.
+
+ - append - keyword argument - bool - Specifies what to do if
+ the file already exists (True: append to the end of it;
+ False: overwrite it.) The default is False.
+
+
+ --- Newline handling.
+
+ write_text() converts all standard end-of-line sequences
+ ('\n', '\r', and '\r\n') to your platform's default end-of-line
+ sequence (see os.linesep; on Windows, for example, the
+ end-of-line marker is '\r\n').
+
+ If you don't like your platform's default, you can override it
+ using the 'linesep=' keyword argument. If you specifically want
+ write_text() to preserve the newlines as-is, use 'linesep=None'.
+
+ This applies to Unicode text the same as to 8-bit text, except
+ there are three additional standard Unicode end-of-line sequences:
+ u'\x85', u'\r\x85', and u'\u2028'.
+
+ (This is slightly different from when you open a file for
+ writing with fopen(filename, "w") in C or file(filename, 'w')
+ in Python.)
+
+
+ --- Unicode
+
+ If 'text' isn't Unicode, then apart from newline handling, the
+ bytes are written verbatim to the file. The 'encoding' and
+ 'errors' arguments are not used and must be omitted.
+
+ If 'text' is Unicode, it is first converted to bytes using the
+ specified 'encoding' (or the default encoding if 'encoding'
+ isn't specified). The 'errors' argument applies only to this
+ conversion.
+
+ """
+ if isinstance(text, unicode):
+ if linesep is not None:
+ # Convert all standard end-of-line sequences to
+ # ordinary newline characters.
+ text = (text.replace(u'\r\n', u'\n')
+ .replace(u'\r\x85', u'\n')
+ .replace(u'\r', u'\n')
+ .replace(u'\x85', u'\n')
+ .replace(u'\u2028', u'\n'))
+ text = text.replace(u'\n', linesep)
+ if encoding is None:
+ encoding = sys.getdefaultencoding()
+ bytes = text.encode(encoding, errors)
+ else:
+ # It is an error to specify an encoding if 'text' is
+ # an 8-bit string.
+ assert encoding is None
+
+ if linesep is not None:
+ text = (text.replace('\r\n', '\n')
+ .replace('\r', '\n'))
+ bytes = text.replace('\n', linesep)
+
+ self.write_bytes(bytes, append)
+
+ def lines(self, encoding=None, errors='strict', retain=True):
+ r""" Open this file, read all lines, return them in a list.
+
+ Optional arguments:
+ encoding - The Unicode encoding (or character set) of
+ the file. The default is None, meaning the content
+ of the file is read as 8-bit characters and returned
+ as a list of (non-Unicode) str objects.
+ errors - How to handle Unicode errors; see help(str.decode)
+ for the options. Default is 'strict'
+ retain - If true, retain newline characters; but all newline
+ character combinations ('\r', '\n', '\r\n') are
+ translated to '\n'. If false, newline characters are
+ stripped off. Default is True.
+
+ This uses 'U' mode in Python 2.3 and later.
+ """
+ if encoding is None and retain:
+ f = self.open(_textmode)
+ try:
+ return f.readlines()
+ finally:
+ f.close()
+ else:
+ return self.text(encoding, errors).splitlines(retain)
+
+ def write_lines(self, lines, encoding=None, errors='strict',
+ linesep=os.linesep, append=False):
+ r""" Write the given lines of text to this file.
+
+ By default this overwrites any existing file at this path.
+
+ This puts a platform-specific newline sequence on every line.
+ See 'linesep' below.
+
+ lines - A list of strings.
+
+ encoding - A Unicode encoding to use. This applies only if
+ 'lines' contains any Unicode strings.
+
+ errors - How to handle errors in Unicode encoding. This
+ also applies only to Unicode strings.
+
+ linesep - The desired line-ending. This line-ending is
+ applied to every line. If a line already has any
+ standard line ending ('\r', '\n', '\r\n', u'\x85',
+ u'\r\x85', u'\u2028'), that will be stripped off and
+ this will be used instead. The default is os.linesep,
+ which is platform-dependent ('\r\n' on Windows, '\n' on
+ Unix, etc.) Specify None to write the lines as-is,
+ like file.writelines().
+
+ Use the keyword argument append=True to append lines to the
+ file. The default is to overwrite the file. Warning:
+ When you use this with Unicode data, if the encoding of the
+ existing data in the file is different from the encoding
+ you specify with the encoding= parameter, the result is
+ mixed-encoding data, which can really confuse someone trying
+ to read the file later.
+ """
+ if append:
+ mode = 'ab'
+ else:
+ mode = 'wb'
+ f = self.open(mode)
+ try:
+ for line in lines:
+ isUnicode = isinstance(line, unicode)
+ if linesep is not None:
+ # Strip off any existing line-end and add the
+ # specified linesep string.
+ if isUnicode:
+ if line[-2:] in (u'\r\n', u'\x0d\x85'):
+ line = line[:-2]
+ elif line[-1:] in (u'\r', u'\n',
+ u'\x85', u'\u2028'):
+ line = line[:-1]
+ else:
+ if line[-2:] == '\r\n':
+ line = line[:-2]
+ elif line[-1:] in ('\r', '\n'):
+ line = line[:-1]
+ line += linesep
+ if isUnicode:
+ if encoding is None:
+ encoding = sys.getdefaultencoding()
+ line = line.encode(encoding, errors)
+ f.write(line)
+ finally:
+ f.close()
+
+ def read_md5(self):
+ """ Calculate the md5 hash for this file.
+
+ This reads through the entire file.
+ """
+ f = self.open('rb')
+ try:
+ m = md5.new()
+ while True:
+ d = f.read(8192)
+ if not d:
+ break
+ m.update(d)
+ finally:
+ f.close()
+ return m.digest()
+
+ # --- Methods for querying the filesystem.
+
+ exists = os.path.exists
+ isdir = os.path.isdir
+ isfile = os.path.isfile
+ islink = os.path.islink
+ ismount = os.path.ismount
+
+ if hasattr(os.path, 'samefile'):
+ samefile = os.path.samefile
+
+ getatime = os.path.getatime
+ atime = property(
+ getatime, None, None,
+ """ Last access time of the file. """)
+
+ getmtime = os.path.getmtime
+ mtime = property(
+ getmtime, None, None,
+ """ Last-modified time of the file. """)
+
+ if hasattr(os.path, 'getctime'):
+ getctime = os.path.getctime
+ ctime = property(
+ getctime, None, None,
+ """ Creation time of the file. """)
+
+ getsize = os.path.getsize
+ size = property(
+ getsize, None, None,
+ """ Size of the file, in bytes. """)
+
+ if hasattr(os, 'access'):
+ def access(self, mode):
+ """ Return true if current user has access to this path.
+
+ mode - One of the constants os.F_OK, os.R_OK, os.W_OK, os.X_OK
+ """
+ return os.access(self, mode)
+
+ def stat(self):
+ """ Perform a stat() system call on this path. """
+ return os.stat(self)
+
+ def lstat(self):
+ """ Like path.stat(), but do not follow symbolic links. """
+ return os.lstat(self)
+
+ def get_owner(self):
+ r""" Return the name of the owner of this file or directory.
+
+ This follows symbolic links.
+
+ On Windows, this returns a name of the form ur'DOMAIN\User Name'.
+ On Windows, a group can own a file or directory.
+ """
+ if os.name == 'nt':
+ if win32security is None:
+ raise Exception("path.owner requires win32all to be installed")
+ desc = win32security.GetFileSecurity(
+ self, win32security.OWNER_SECURITY_INFORMATION)
+ sid = desc.GetSecurityDescriptorOwner()
+ account, domain, typecode = win32security.LookupAccountSid(None, sid)
+ return domain + u'\\' + account
+ else:
+ if pwd is None:
+ raise NotImplementedError("path.owner is not implemented on this platform.")
+ st = self.stat()
+ return pwd.getpwuid(st.st_uid).pw_name
+
+ owner = property(
+ get_owner, None, None,
+ """ Name of the owner of this file or directory. """)
+
+ if hasattr(os, 'statvfs'):
+ def statvfs(self):
+ """ Perform a statvfs() system call on this path. """
+ return os.statvfs(self)
+
+ if hasattr(os, 'pathconf'):
+ def pathconf(self, name):
+ return os.pathconf(self, name)
+
+
+ # --- Modifying operations on files and directories
+
+ def utime(self, times):
+ """ Set the access and modified times of this file. """
+ os.utime(self, times)
+
+ def chmod(self, mode):
+ os.chmod(self, mode)
+
+ if hasattr(os, 'chown'):
+ def chown(self, uid, gid):
+ os.chown(self, uid, gid)
+
+ def rename(self, new):
+ os.rename(self, new)
+
+ def renames(self, new):
+ os.renames(self, new)
+
+
+ # --- Create/delete operations on directories
+
+ def mkdir(self, mode=0777):
+ os.mkdir(self, mode)
+
+ def makedirs(self, mode=0777):
+ os.makedirs(self, mode)
+
+ def rmdir(self):
+ os.rmdir(self)
+
+ def removedirs(self):
+ os.removedirs(self)
+
+
+ # --- Modifying operations on files
+
+ def touch(self):
+ """ Set the access/modified times of this file to the current time.
+ Create the file if it does not exist.
+ """
+ fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0666)
+ os.close(fd)
+ os.utime(self, None)
+
+ def remove(self):
+ os.remove(self)
+
+ def unlink(self):
+ os.unlink(self)
+
+
+ # --- Links
+
+ if hasattr(os, 'link'):
+ def link(self, newpath):
+ """ Create a hard link at 'newpath', pointing to this file. """
+ os.link(self, newpath)
+
+ if hasattr(os, 'symlink'):
+ def symlink(self, newlink):
+ """ Create a symbolic link at 'newlink', pointing here. """
+ os.symlink(self, newlink)
+
+ if hasattr(os, 'readlink'):
+ def readlink(self):
+ """ Return the path to which this symbolic link points.
+
+ The result may be an absolute or a relative path.
+ """
+ return self.__class__(os.readlink(self))
+
+ def readlinkabs(self):
+ """ Return the path to which this symbolic link points.
+
+ The result is always an absolute path.
+ """
+ p = self.readlink()
+ if p.isabs():
+ return p
+ else:
+ return (self.parent / p).abspath()
+
+
+ # --- High-level functions from shutil
+
+ copyfile = shutil.copyfile
+ copymode = shutil.copymode
+ copystat = shutil.copystat
+ copy = shutil.copy
+ copy2 = shutil.copy2
+ copytree = shutil.copytree
+ if hasattr(shutil, 'move'):
+ move = shutil.move
+ rmtree = shutil.rmtree
+
+
+ # --- Special stuff from os
+
+ if hasattr(os, 'chroot'):
+ def chroot(self):
+ os.chroot(self)
+
+ if hasattr(os, 'startfile'):
+ def startfile(self):
+ os.startfile(self)
+
+
diff --git a/readme b/readme
new file mode 100755
index 0000000..7cd0899
--- /dev/null
+++ b/readme
@@ -0,0 +1,192 @@
+Note: 1 - record as slideN.wav in Deck_dir
+ 2 - add <clip>slideN.wav</clip> to 'submission'
+ 3 - play slideN.wav
+ 4 - test: record clip for three slides, verify each is playable when slide is selected
+
+
+slideshow.py
+
+class Deck
+ set_locked_mode
+ set_is_initiating
+ getisInitiating
+ set_title
+ get_title
+ reload
+ save
+ rebuild_dom
+ getDeckPath
+ resizeImage
+ addSlide
+ removeSlide
+ moveSlide
+ getSlideLayers
+ getInstructorInk
+ getSelfInkOrSubmission
+ setActiveSubmission
+ getActiveSubmission
+ getSubmissionList
+ addSubmission
+ addInkToSlide
+ clearInk
+ clearInstructorInk
+ removeInstructorPathByUID
+ removeLocalPathByUID
+ doSubmit
+ doBroadcast
+ getSerializedInkSubmission
+ getSlideThumb
+ setSlideThumb
+ setSlideText
+ doNewIndex
+ goToIndex
+ getIndex
+ next
+ previous
+ isAtBeginning
+ isAtEnd
+ getSlideDimensionsFromXML
+ getSlideCount
+
+sharedslides.py
+
+class ReadHTTPRequestHandler
+
+class ReadHTTPServer
+
+class sharedSlides
+
+ getStreamTube
+ handle_download_fail
+ list_tubes_reply_cb
+ list_tubes_error_cb
+ new_tube_cb
+ download_file
+ download_result_cb
+ download_progress_cb
+ download_error_cb
+ share_deck
+
+shared.py
+
+class Shared
+ shared_cb
+ joined_cb
+ shared_setup
+ deck_download_complete_cb
+ student_dl_complete_cb
+ list_tubes_reply_cb
+ list_tubes_error_cb
+ new_tube_cb
+ participant_change_cb
+ Slide_Changed
+ Deck_Download_Complete
+ Lock_Nav
+ Push_Initial_State
+ send_slide_changed_signal
+ slide_changed_cb
+ lock_nav_cb
+ lock_mode_switch
+ lock_nav
+ unlock_nav
+ send_ink_path
+ Add_Ink_Path
+ _get_buddy
+ add_ink_path_cb
+ submit_ink_cb
+ Send_Submission
+ receive_submission_cb
+ bcast_submission_cb
+ Bcast_Submission
+ instr_clear_ink_cb
+ Instructor_Clear_Ink
+ recv_instr_clear_ink_cb
+ instr_remove_ink_cb
+ Instructor_Remove_Ink
+ recv_instr_remove_ink_cb
+ buddy_joined_cb
+ buddy_left_cb
+
+ink.py
+
+class Path
+
+ add
+ __str__
+
+classroompresenter.py
+
+class ClassroomPresenter
+
+ dl_complete_cb
+ do_slideview_mode
+ set_progress_max
+ do_progress_view
+ set_progress
+ read_file
+ write_file
+ get_shared_activity
+
+utils.py
+
+ getFileType
+ copy_file
+ run_dialog
+
+toolbars.py
+
+class NavToolBar
+ activity_shared_cb
+ activity_joined_cb
+ set_lock_button
+ next
+ previous
+ slide_changed
+ num_page_activate
+
+class InkToolBar
+ instructor_state_cb
+ set_cur_pen
+ set_ink_color
+ set_erase
+ set_tool_buttons
+ submit_ink
+ broadcast_ink
+ reenable_submissions
+ undo
+ redo
+ update_buttons
+
+class MakeToolBar
+
+ new
+ choose
+ save
+ done
+
+textarea.py
+
+class TextArea
+
+ update_text
+ text_changed
+ render_text_area
+ clear_text
+ record
+ play
+ stop
+ create_bbox
+
+sidebar.py
+
+class SideBar
+ load_subs
+ sub_sel_changed
+ load_thumbs
+ change_slide
+ moveslide
+ removeslide
+
+
+
+
diff --git a/resources/new.cpxo b/resources/new.cpxo
new file mode 100755
index 0000000..1cefb2d
--- /dev/null
+++ b/resources/new.cpxo
Binary files differ
diff --git a/resources/splash.svg b/resources/splash.svg
new file mode 100644
index 0000000..10b0a14
--- /dev/null
+++ b/resources/splash.svg
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="800"
+ height="600"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="splash.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2471"
+ inkscape:persp3d-origin="27.5 : 18.333333 : 1"
+ inkscape:vp_z="55 : 27.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 27.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="426.63631"
+ inkscape:cy="300"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1108"
+ inkscape:window-height="856"
+ inkscape:window-x="20"
+ inkscape:window-y="20" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <rect
+ style="opacity:1;fill:#000080;stroke:none"
+ id="rect2459"
+ width="689.67639"
+ height="146.07088"
+ x="50.847458"
+ y="404.93066"
+ rx="12.001222"
+ ry="12" />
+ <g
+ id="g2449"
+ transform="matrix(4.527989,0,0,4.527989,32.491418,11.193553)"
+ style="fill:#000080">
+ <g
+ id="g2451"
+ style="fill:#000080">
+ <path
+ style="fill:#000080"
+ d="M 11.908,34.521 C 11.392,34.621 10.896,34.302 10.8,33.809 L 7.72,17.94 C 7.625,17.447 7.965,16.965 8.481,16.865 L 29.981,12.692 C 30.496,12.592 30.994,12.911 31.087,13.405 L 32.116,18.711 L 32.165,18.667 L 37.189,19.764 L 35.581,11.146 C 35.287,9.643 33.833,8.661 32.33,8.954 L 5.121,14.235 C 3.618,14.527 2.636,15.982 2.928,17.484 L 6.625,36.532 C 6.917,38.035 8.371,39.016 9.874,38.725 L 14.497,37.78 L 15.513,33.821 L 11.908,34.521 z"
+ id="path2453" />
+ </g>
+ </g>
+ <path
+ style="fill:#ffffff"
+ id="path3554_1_"
+ d="M 187.19922,143.73685 C 187.63843,145.96915 186.08986,148.16069 183.75342,148.59991 L 86.415239,167.49973 C 84.074269,167.95253 81.823858,166.5081 81.393699,164.2758 L 67.447493,92.42567 C 67.017334,90.193377 68.55685,88.010886 70.897821,87.558087 L 168.24506,68.662789 C 170.57697,68.20999 172.83191,69.654418 173.25301,71.891245 L 187.19922,143.73685 z" />
+ <g
+ id="g2456"
+ transform="matrix(4.527989,0,0,4.527989,32.491418,11.193553)"
+ style="fill:#000080">
+ <g
+ id="g2458"
+ style="fill:#000080">
+ <path
+ style="fill:#000080"
+ d="M 49.668,23.2 L 45.044,22.246 L 42.989,25.025 L 46.021,25.694 C 46.536,25.807 46.864,26.297 46.755,26.79 L 43.27,42.573 C 43.163,43.064 42.657,43.371 42.145,43.257 L 20.76,38.534 C 20.247,38.422 19.919,37.931 20.027,37.44 L 23.512,21.656 C 23.621,21.165 24.125,20.858 24.639,20.972 L 36.213,23.528 L 38.578,20.743 L 22.602,17.22 C 21.107,16.89 19.627,17.835 19.298,19.33 L 15.113,38.274 C 14.782,39.77 15.727,41.251 17.222,41.581 L 44.286,47.558 C 45.781,47.888 47.259,46.946 47.59,45.45 L 51.778,26.504 C 52.106,25.009 51.163,23.53 49.668,23.2 z"
+ id="path2460" />
+ </g>
+ </g>
+ <path
+ style="fill:#ffffff"
+ id="path3560_1_"
+ d="M 228.42203,203.96363 C 227.93754,206.18687 225.64637,207.57696 223.32804,207.06077 L 126.497,185.67508 C 124.17414,185.16795 122.69349,182.9447 123.17798,180.72146 L 138.95802,109.25168 C 139.45157,107.02844 141.73368,105.63835 144.06107,106.15454 L 240.87853,127.5357 C 243.21044,128.04736 244.69562,130.26608 244.20207,132.49838 L 228.42203,203.96363 z" />
+ <path
+ style="fill:#000080"
+ id="path3562"
+ d="M 272.51106,59.330604 C 272.51106,59.126844 272.502,58.909501 272.47031,58.692157 C 272.15788,56.025172 269.92558,52.760492 266.67448,50.188594 C 263.4098,47.612168 259.71949,46.213019 257.04345,46.520923 C 255.87976,46.665818 254.95605,47.163897 254.3176,47.897431 L 254.24515,47.856679 L 207.1269,110.22973 L 206.91408,110.43802 L 206.88691,110.4833 C 206.81447,110.5648 206.80088,110.678 206.74655,110.76856 L 200.62923,118.2986 C 200.62923,118.2986 200.98242,118.57481 201.34466,118.8646 L 200.60207,118.34841 L 200.48887,118.49784 C 200.21266,118.83291 200.04965,119.25854 199.9274,119.70681 C 199.87759,119.76114 199.80967,119.77473 199.7825,119.83812 L 195.94276,128.93938 L 207.47102,138.16289 L 216.46814,132.36254 C 216.53153,132.33537 216.51795,132.26292 216.56323,132.21311 C 216.79868,132.03199 217.06583,131.87804 217.25148,131.65164 C 217.26959,131.61995 217.36015,131.48411 217.37826,131.47505 L 223.66764,123.62805 L 223.76726,123.53296 L 223.74462,123.5239 L 223.81707,123.44693 L 223.83971,123.45598 L 271.46509,62.011173 C 271.56018,61.925141 271.66885,61.888917 271.74583,61.79383 C 271.84544,61.671574 271.8862,61.504038 271.95864,61.368199 L 272.01751,61.313863 L 272.00845,61.304807 C 272.3073,60.725224 272.51106,60.086778 272.51106,59.330604 z" />
+ <path
+ style="fill:none;stroke:#000080;stroke-width:4.56874084;stroke-opacity:1"
+ id="path3564"
+ d="M 184.74505,152.11815 C 184.74505,152.11815 154.40752,170.47915 148.81998,163.68717 C 143.22792,156.90424 150.41836,150.12584 154.00906,150.12584 C 157.59975,150.12584 171.17467,160.49946 161.59344,170.88667 C 152.00769,181.26029 145.2157,178.87404 145.2157,178.87404" />
+ <path
+ style="fill:#000080"
+ id="path3566"
+ d="M 188.4263,147.11925 C 188.28141,147.49508 188.37197,147.91618 188.6844,148.16975 C 188.98777,148.43237 189.42699,148.45954 189.76206,148.2422 L 202.79814,139.86089 L 194.33533,133.08249 L 188.4263,147.11925 z" />
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Serif;-inkscape-font-specification:Bitstream Vera Serif"
+ x="293.53775"
+ y="104.29892"
+ id="text3268"><tspan
+ sodipodi:role="line"
+ id="tspan3270"
+ x="293.53775"
+ y="104.29892"
+ style="font-size:28px">Welcome to</tspan><tspan
+ sodipodi:role="line"
+ x="293.53775"
+ y="151.35254"
+ id="tspan3272"><tspan
+ style="font-weight:bold;-inkscape-font-specification:Bitstream Vera Serif Bold"
+ id="tspan3276"><tspan
+ style="fill:#000080"
+ id="tspan3278">Classroom Presenter </tspan></tspan></tspan><tspan
+ sodipodi:role="line"
+ x="293.53775"
+ y="189.29892"
+ id="tspan3274"
+ style="font-size:28px">for the XO Laptop.</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"
+ x="64.714943"
+ y="435.43915"
+ id="text2447"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan2449"
+ x="64.714943"
+ y="435.43915">This is an empty presentation. Classroom Presenter does not yet</tspan><tspan
+ sodipodi:role="line"
+ x="64.714943"
+ y="460.43915"
+ id="tspan2451">support slide creation on the XO.</tspan><tspan
+ sodipodi:role="line"
+ x="64.714943"
+ y="485.43915"
+ id="tspan2453" /><tspan
+ sodipodi:role="line"
+ x="64.714943"
+ y="510.43915"
+ id="tspan2455">To begin using Classroom Presenter, resume an existing slide</tspan><tspan
+ sodipodi:role="line"
+ x="64.714943"
+ y="535.43915"
+ id="tspan2457">deck from the Journal.</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
+ x="58.24345"
+ y="267.31281"
+ id="text2461"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan2463"
+ x="58.24345"
+ y="267.31281">Classroom Presenter XO version 1.0 Beta 1</tspan><tspan
+ sodipodi:role="line"
+ x="58.24345"
+ y="287.31281"
+ id="tspan2465">University of Washington Computer Science and Engineering</tspan><tspan
+ sodipodi:role="line"
+ x="58.24345"
+ y="307.31281"
+ id="tspan2467">William Burnside, Mathias Klous, Brian Mayton, and Kristofer Plunkett</tspan><tspan
+ sodipodi:role="line"
+ x="58.24345"
+ y="327.31281"
+ id="tspan2469">http://xo.orderedpixels.com/</tspan><tspan
+ sodipodi:role="line"
+ x="58.24345"
+ y="347.31281"
+ id="tspan2471">http://classroompresenter.cs.washington.edu/</tspan></text>
+ </g>
+</svg>
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..77e788c
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+try:
+ from sugar.activity import bundlebuilder
+ bundlebuilder.start("ClassroomPresenter")
+except ImportError:
+ import os
+ #os.system("find ./ | sed 's,^./,ClassroomPresenter.activity/,g' > MANIFEST")
+ os.system('rm ClassroomPresenter.xo')
+ os.chdir('..')
+ os.system('zip -r ClassroomPresenter.xo ClassroomPresenter.activity')
+ os.system('mv ClassroomPresenter.xo ./ClassroomPresenter.activity')
+ os.chdir('ClassroomPresenter.activity')
diff --git a/shared.py b/shared.py
new file mode 100755
index 0000000..19da1c8
--- /dev/null
+++ b/shared.py
@@ -0,0 +1,387 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:nil; -*-
+
+# shared.py
+#
+# Top-level class responsible for making Classroom Presenter a shared activity.
+# Kris Plunkett <kp86@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import logging
+import os
+import gobject
+
+import telepathy
+import telepathy.client
+
+import dbus
+from dbus.service import method, signal
+from dbus.gobject_service import ExportedGObject
+
+from sugar.presence import presenceservice
+from sugar.presence.tubeconn import TubeConnection
+
+import utils
+from sharedslides import SharedSlides
+
+SERVICE = "edu.washington.cs.ClassroomPresenterXO"
+IFACE = SERVICE
+PATH = "/edu/washington/cs/ClassroomPresenterXO"
+
+
+class Shared(ExportedGObject):
+
+ __gsignals__ = {
+ 'navigation-lock-change' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_BOOLEAN,)),
+ 'deck-download-complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ }
+
+ def __init__(self, activity, deck, work_path):
+ gobject.GObject.__init__(self)
+
+ self.__activity = activity
+ self.__deck = deck
+ self.__logger = logging.getLogger('Shared')
+
+ self.__is_initiating = True # defaults to instructor
+ self.__shared_slides = None
+ self.__got_dbus_tube = False
+ self.__locked = False
+ self.__pservice = presenceservice.get_instance()
+ #self.__owner = self.__pservice.get_owner()
+
+ self.__cpxo_path = os.path.join(work_path, 'deck.cpxo')
+
+ self.__activity.connect('shared', self.shared_cb)
+ self.__activity.connect('joined', self.joined_cb)
+
+ def shared_cb(self, activity):
+ """ Called when the activity is shared """
+ self.__logger.debug('The activity has been shared.')
+ self.__is_initiating = True
+ self.__activity.write_file(self.__cpxo_path)
+ self.__deck.set_is_initiating(is_init=True)
+ self.shared_setup()
+
+ def joined_cb(self, activity):
+ """ Called when the activity is joined """
+ self.__logger.debug('Joined another activity.')
+ self.__is_initiating = False
+ self.__deck.set_is_initiating(is_init=False)
+ # for showing slide deck download progress
+ activity.do_progress_view()
+ activity.set_progress(0.0)
+ self.shared_setup()
+
+ def shared_setup(self):
+ """ Called by joined_cb and shared_cb because all of this needs to happen
+ whether we are sharing or joining the activity """
+
+ self.__shared_activity = self.__activity.get_shared_activity()
+
+ if self.__shared_activity is None:
+ self.__logger.error('Failed to share or join activity!')
+ return
+
+ self.__tubes_chan = self.__shared_activity.telepathy_tubes_chan
+ self.__iface = self.__tubes_chan[telepathy.CHANNEL_TYPE_TUBES]
+
+ self.__text_chan = self.__shared_activity.telepathy_text_chan
+ self.__iface_grp = self.__text_chan[telepathy.CHANNEL_INTERFACE_GROUP]
+
+ self.__conn = self.__shared_activity.telepathy_conn
+ self.__my_handle = self.__conn.GetSelfHandle()
+
+ #self.__shared_activity.connect('buddy-joined', self.buddy_joined_cb)
+ #self.__shared_activity.connect('buddy-left', self.buddy_left_cb)
+
+ # takes care of downloading (and then sharing) the slide deck over stream tubes
+ self.__shared_slides = SharedSlides(self.__is_initiating, self.__cpxo_path,
+ self.__shared_activity, self.__activity.read_file)
+ self.__shared_slides.connect('deck-download-complete', self.deck_download_complete_cb)
+
+ # now for the dbus tube
+ self.__iface.connect_to_signal('NewTube', self.new_tube_cb)
+
+ if (self.__is_initiating):
+ self.__logger.debug("We are sharing, making a dbus tube and setting locked nav mode.")
+ self.lock_nav()
+ id = self.__iface.OfferDBusTube(SERVICE, {})
+ else:
+ self.__logger.debug("We are joining, looking for the global dbus tube.")
+ self.__tubes_chan[telepathy.CHANNEL_TYPE_TUBES].ListTubes(
+ reply_handler=self.list_tubes_reply_cb,
+ error_handler=self.list_tubes_error_cb)
+
+
+ """ --- START DBUS TUBE CODE --- """
+
+ def deck_download_complete_cb(self, object):
+ """ Catches the local deck_download_complete signal and sends the appropriate dbus signal """
+ self.__logger.debug("Deck download is complete, sending Deck_Download_Complete dbus signal.")
+ self.Deck_Download_Complete()
+ self.emit('deck-download-complete')
+
+ def student_dl_complete_cb(self, sender):
+ """ Catches the Deck_Download_Complete dbus signal from students, lets us know that they
+ are ready to have initial state information pushed onto them """
+ self.__logger.debug("Got Deck_Download_Complete dbus signal, pushing initial state info to student.")
+ proxy_object = self.__dbus_tube.get_object(sender, PATH)
+ proxy_object.Push_Initial_State(self.__locked, self.__deck.getIndex(),
+ dbus_interface=IFACE)
+
+ def list_tubes_reply_cb(self, tubes):
+ for tube_info in tubes:
+ self.new_tube_cb(*tube_info)
+
+ def list_tubes_error_cb(self, e):
+ self.__logger.error('ListTubes() failed: %s', e)
+
+ def new_tube_cb(self, tube_id, initiator, type, service, params, state):
+ self.__logger.debug('New tube: ID=%d initator=%d type=%d service=%s params=%r state=%d',
+ tube_id, initiator, type, service, params, state)
+ if (not self.__got_dbus_tube and type == telepathy.TUBE_TYPE_DBUS and service == SERVICE):
+ if( state == telepathy.TUBE_STATE_LOCAL_PENDING):
+ self.__iface.AcceptDBusTube(tube_id)
+
+ self.__dbus_tube = TubeConnection(self.__conn, self.__iface, tube_id,
+ group_iface=self.__iface_grp)
+ self.__got_dbus_tube = True
+ self.__logger.debug("Got our dbus tube!")
+
+ # lots of stuff to do once we get our tube
+ if (self.__is_initiating):
+ self.__deck.connect('slide-changed', self.send_slide_changed_signal)
+ self.__deck.connect('local-ink-added', self.send_ink_path)
+ self.__deck.connect('instructor-ink-cleared', self.instr_clear_ink_cb)
+ self.__deck.connect('instructor-ink-removed', self.instr_remove_ink_cb)
+ self.__deck.connect('ink-broadcast', self.bcast_submission_cb)
+ self.__dbus_tube.add_signal_receiver(self.student_dl_complete_cb, 'Deck_Download_Complete',
+ IFACE, path=PATH, sender_keyword='sender')
+ self.__dbus_tube.add_signal_receiver(self.receive_submission_cb,
+ 'Send_Submission', IFACE, path=PATH)
+ else:
+ self.__deck.connect('ink-submitted', self.submit_ink_cb)
+ self.__dbus_tube.add_signal_receiver(self.slide_changed_cb, 'Slide_Changed',
+ IFACE, path=PATH)
+ self.__dbus_tube.add_signal_receiver(self.lock_nav_cb, 'Lock_Nav',
+ IFACE, path=PATH)
+ self.__dbus_tube.add_signal_receiver(self.add_ink_path_cb, 'Add_Ink_Path',
+ IFACE, path=PATH)
+ self.__dbus_tube.add_signal_receiver(self.recv_instr_clear_ink_cb, 'Instructor_Clear_Ink',
+ IFACE, path=PATH)
+ self.__dbus_tube.add_signal_receiver(self.recv_instr_remove_ink_cb, 'Instructor_Remove_Ink',
+ IFACE, path=PATH)
+ self.__dbus_tube.add_signal_receiver(self.receive_submission_cb,
+ 'Bcast_Submission', IFACE, path=PATH)
+
+ #self.__dbus_tube.watch_participants(self.participant_change_cb)
+
+ super(Shared, self).__init__(self.__dbus_tube, PATH)
+
+ def participant_change_cb(self, added, removed):
+ """ Callback on instructor XO for when someone joins or leaves the tube """
+ for handle, bus_name in added:
+ buddy = self._get_buddy(handle)
+ if buddy is not None:
+ if handle != self.__my_handle and self.__is_initiating:
+ self.__logger.debug("New student joined: %s", buddy.props.nick)
+
+ for handle in removed:
+ buddy = self._get_buddy(handle)
+ if buddy is not None:
+ self.__logger.debug('Buddy %s was removed' % buddy.props.nick)
+
+ @signal(dbus_interface=IFACE, signature='u')
+ def Slide_Changed(self, slide_num):
+ """ Signals joiners to move to given slide """
+ self.__logger.debug("Sending the Slide_Changed signal with slide num %d.", slide_num)
+ pass
+
+ @signal(dbus_interface=IFACE, signature='')
+ def Deck_Download_Complete(self):
+ """ Signal from the student informing instructor that the deck download has finished """
+ self.__logger.debug("Sending Deck_Download_Complete signal, ready for initial state info.")
+ pass
+
+ @signal(dbus_interface=IFACE, signature='u')
+ def Lock_Nav(self, lock):
+ """ Signals joiners to lock or unlock navigation """
+ self.__logger.debug("Sending Lock_Nav signal with bool %u", lock)
+ pass
+
+ @method(dbus_interface=IFACE, in_signature='uu', out_signature='')
+ def Push_Initial_State(self, locked, slide_idx):
+ """ Called on student XO to push initial state info """
+ # push current slide index and go to that slide
+ self.__deck.goToIndex(slide_idx, is_local=False)
+
+ # push nav lock information
+ if locked:
+ self.lock_nav()
+ else:
+ self.unlock_nav()
+
+ def send_slide_changed_signal(self, widget):
+ """ Arbitrates the sending of the Slide_Changed signal """
+ self.__logger.debug("Got the slide-changed signal.")
+ if self.__locked:
+ self.__logger.debug("Navigation is locked, sending Slide_Changed to students.")
+ self.Slide_Changed(self.__deck.getIndex())
+
+ def slide_changed_cb(self, slide_idx):
+ """ Called on the joiners when they receive the Slide_Changed signal """
+ self.__logger.debug("Received the Slide_Changed signal and changing to slide %d.",
+ slide_idx)
+
+ self.__deck.goToIndex(slide_idx, is_local=False)
+
+ def lock_nav_cb(self, lock):
+ """ Called on joiners when they receive the Lock_Nav signal """
+ self.__logger.debug("Received the Lock_Nav signal with bool %u", lock)
+ if (lock):
+ self.lock_nav()
+ else:
+ self.unlock_nav()
+
+ def lock_mode_switch(self, widget=None):
+ """ Switches the lock mode from locked to unlocked and vice versa """
+ # first switch our own lock mode
+ if (self.__locked):
+ self.unlock_nav()
+ else:
+ self.lock_nav()
+
+ # if we are instructor, tell student XOs to go into our new lock mode
+ if (self.__is_initiating):
+ self.Lock_Nav(self.__locked)
+
+ def lock_nav(self):
+ self.__logger.debug("Locking navigation.")
+ self.__locked = True
+ # if we are the instructor, force students to jump to our slide
+ if self.__got_dbus_tube and self.__is_initiating:
+ self.Slide_Changed(self.__deck.getIndex())
+ self.__deck.set_locked_mode(locked=True)
+ self.emit('navigation-lock-change', self.__locked)
+
+ def unlock_nav(self):
+ self.__logger.debug("Unlocking navigation.")
+ self.__locked = False
+ self.__deck.set_locked_mode(locked=False)
+ self.emit('navigation-lock-change', self.__locked)
+
+ def send_ink_path(self, widget, inkstr):
+ self.__logger.debug("send_ink_path called")
+ if (self.__is_initiating and self.__got_dbus_tube):
+ self.Add_Ink_Path(self.__deck.getIndex(), inkstr)
+
+ @signal(dbus_interface=IFACE, signature='us')
+ def Add_Ink_Path(self, slide_idx, pathstr):
+ self.__logger.debug("Sending new ink path")
+ pass
+
+ def _get_buddy(self, cs_handle):
+ """Get a Buddy from a channel specific handle."""
+ self.__logger.debug('Trying to find owner of handle %u...', cs_handle)
+ my_csh = self.__iface_grp.GetSelfHandle()
+ self.__logger.debug('My handle in that group is %u', my_csh)
+ if my_csh == cs_handle:
+ handle = self.__conn.GetSelfHandle()
+ self.__logger.debug('CS handle %u belongs to me, %u', cs_handle, handle)
+ elif group.GetGroupFlags() & telepathy.CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES:
+ handle = group.GetHandleOwners([cs_handle])[0]
+ self.__logger.debug('CS handle %u belongs to %u', cs_handle, handle)
+ else:
+ handle = cs_handle
+ self.__logger.debug('non-CS handle %u belongs to itself', handle)
+ # XXX: deal with failure to get the handle owner
+ assert handle != 0
+ return self.__pservice.get_buddy_by_telepathy_handle(
+ self.__conn.service_name, self.__conn.object_path, handle)
+
+ def add_ink_path_cb(self, idx, inkstr):
+ self.__logger.debug("Received new ink path")
+ self.__deck.addInkToSlide(inkstr, islocal=False, n=idx)
+
+ def submit_ink_cb(self, widget, inks, text):
+ if not self.__is_initiating and self.__got_dbus_tube:
+ cur_idx = self.__deck.getIndex()
+ my_csh = self.__iface_grp.GetSelfHandle()
+ buddy = self._get_buddy(my_csh)
+
+ if buddy is not None:
+ sender = buddy.props.nick
+ else:
+ sender = 'Unknown'
+
+ self.__logger.debug("Sending submission: idx '%d', sender '%s'.", cur_idx, sender)
+ self.Send_Submission(sender, cur_idx, inks, text)
+
+ @signal(dbus_interface=IFACE, signature='suss')
+ def Send_Submission(self, sender, slide_idx, inks, text):
+ pass
+
+ def receive_submission_cb(self, sender, slide_idx, inks, text):
+ self.__logger.debug("Received submission from '%s'.", sender)
+ self.__deck.addSubmission(sender, inks, text, slide_idx)
+
+ def bcast_submission_cb(self, widget, whofrom, inks, text):
+ if self.__is_initiating and self.__got_dbus_tube:
+ cur_idx = self.__deck.getIndex()
+ self.Bcast_Submission(whofrom, cur_idx, inks, text)
+
+ @signal(dbus_interface=IFACE, signature='suss')
+ def Bcast_Submission(self, sender, slide_idx, inks, text):
+ pass
+
+ def instr_clear_ink_cb(self, widget, idx):
+ if self.__is_initiating and self.__got_dbus_tube:
+ self.Instructor_Clear_Ink(idx)
+
+ @signal(dbus_interface=IFACE, signature='u')
+ def Instructor_Clear_Ink(self, idx):
+ pass
+
+ def recv_instr_clear_ink_cb(self, idx):
+ self.__deck.clearInstructorInk(idx)
+
+ def instr_remove_ink_cb(self, widget, uid, idx):
+ if self.__is_initiating and self.__got_dbus_tube:
+ self.Instructor_Remove_Ink(uid, idx)
+
+ @signal(dbus_interface=IFACE, signature='uu')
+ def Instructor_Remove_Ink(self, uid, idx):
+ pass
+
+ def recv_instr_remove_ink_cb(self, uid, idx):
+ self.__deck.removeInstructorPathByUID(uid, idx)
+
+
+ """ --- END DBUS TUBE CODE --- """
+
+ # DEPRECATED
+ def buddy_joined_cb(self, activity, buddy):
+ """ Called when a buddy joins the activity """
+ if self.__is_initiating is True:
+ utils.run_dialog("Instructor", buddy.props.nick + " has joined!")
+
+ # DEPRECATED
+ def buddy_left_cb(self, activity, buddy):
+ """ Called when a buddy leaves the activity """
+ if self.__is_initiating is True:
+ utils.run_dialog("Instructor", buddy.props.nick + " has left!")
+
+gobject.type_register(Shared)
diff --git a/sharedslides.py b/sharedslides.py
new file mode 100755
index 0000000..d49c4cd
--- /dev/null
+++ b/sharedslides.py
@@ -0,0 +1,176 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:nil; -*-
+
+# sharedslides.py
+#
+# Class that performs all work relating to the sharing of slide decks and ink.
+# Kris Plunkett <kp86@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import logging
+
+import sys
+import os
+import time
+import random
+import gobject
+
+import telepathy
+import telepathy.client
+
+import dbus
+from dbus.service import method, signal
+from dbus.gobject_service import ExportedGObject
+
+from sugar.presence import presenceservice
+from sugar import network
+from sugar.presence.tubeconn import TubeConnection
+
+SERVICE = "edu.washington.cs.ClassroomPresenterXO"
+IFACE = SERVICE
+PATH = "/edu/washington/cs/ClassroomPresenterXO"
+
+
+# Define a simple HTTP server for sharing data.
+class ReadHTTPRequestHandler(network.ChunkedGlibHTTPRequestHandler):
+ def translate_path(self, path):
+ return self.server._filepath
+
+class ReadHTTPServer(network.GlibTCPServer):
+ def __init__(self, server_address, filepath):
+ self._filepath = filepath
+ network.GlibTCPServer.__init__(self, server_address, ReadHTTPRequestHandler)
+
+
+class SharedSlides(gobject.GObject):
+ """ Handles all sharing of slides and ink """
+
+ __gsignals__ = {
+ 'deck-download-complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ }
+
+ def __init__(self, init, cpxo_path, shared_activity, read_file_cb):
+ gobject.GObject.__init__(self)
+
+ self.__is_initiating = init
+ self.__cpxo_path = cpxo_path
+ self.__shared_activity = shared_activity
+ self.read_file_cb = read_file_cb
+ self.__logger = logging.getLogger('SharedSlides')
+
+ self.__tubes_chan = self.__shared_activity.telepathy_tubes_chan
+ self.__iface = self.__tubes_chan[telepathy.CHANNEL_TYPE_TUBES]
+
+ if (self.__is_initiating):
+ self.__logger.debug('Hello from SharedSlides (sharer).')
+ self.__have_deck = True
+ self.share_deck()
+ else:
+ # find a stream tube to download the slide deck from
+ self.__logger.debug('Hello from SharedSlides (joiner).')
+ self.__iface.connect_to_signal('NewTube', self.new_tube_cb)
+ self.__have_deck = False
+ self.get_stream_tube()
+
+ def get_stream_tube(self):
+ """ Attempts to download the slide deck from an available stream tube """
+ self.__iface.ListTubes(
+ reply_handler=self.list_tubes_reply_cb,
+ error_handler=self.list_tubes_error_cb)
+
+ def handle_download_fail(self):
+ """ If an attempt to download the deck fails, this method takes care of it """
+ self.__logger.error('Download failed! Sleeping five seconds and trying again.')
+ time.sleep(5)
+ self.get_stream_tube()
+
+ def list_tubes_reply_cb(self, tubes):
+ for tube_info in tubes:
+ self.new_tube_cb(*tube_info)
+
+ def list_tubes_error_cb(self, e):
+ self.__logger.error('ListTubes() failed: %s', e)
+ self.handle_download_fail
+
+ def new_tube_cb(self, id, initiator, type, service, params, state):
+ self.__logger.debug('New tube: ID=%d initiator=%d type=%d service=%s params=%r state=%d',
+ id, initiator, type, service, params, state)
+
+ if (not self.__have_deck and
+ type == telepathy.TUBE_TYPE_STREAM and
+ service == SERVICE and
+ state == telepathy.TUBE_STATE_LOCAL_PENDING):
+ addr = self.__iface.AcceptStreamTube(id,
+ telepathy.SOCKET_ADDRESS_TYPE_IPV4,
+ telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0,
+ utf8_strings=True)
+ self.__logger.debug("Got a stream tube!")
+
+ # sanity checks
+ assert isinstance(addr, dbus.Struct)
+ assert len(addr) == 2
+ assert isinstance(addr[0], str)
+ assert isinstance(addr[1], (int, long))
+ assert addr[1] > 0 and addr[1] < 65536
+ ip_addr = addr[0]
+ port = int(addr[1])
+
+ self.__logger.debug("The stream tube is good!")
+ self.download_file(ip_addr, port, id)
+
+ def download_file(self, ip_addr, port, tube_id):
+ """ Performs the actual download of the slide deck """
+ self.__logger.debug("Downloading from ip %s and port %d.", ip_addr, port)
+
+ getter = network.GlibURLDownloader("http://%s:%d/document" % (ip_addr, port))
+ getter.connect("finished", self.download_result_cb, tube_id)
+ getter.connect("progress", self.download_progress_cb, tube_id)
+ getter.connect("error", self.download_error_cb, tube_id)
+ self.__logger.debug("Starting download to %s...", self.__cpxo_path)
+ getter.start(self.__cpxo_path)
+
+ def download_result_cb(self, getter, tempfile, suggested_name, tube_id):
+ """ Called when the file download was successful """
+ self.__logger.debug("Got file %s (%s) from tube %u",
+ tempfile, suggested_name, tube_id)
+ self.emit('deck-download-complete')
+ self.read_file_cb(self.__cpxo_path)
+
+ def download_progress_cb(self, getter, bytes_downloaded, tube_id):
+ tmp = True
+ #self.__logger.debug("Bytes downloaded from tube %u: %u", tube_id, bytes_downloaded)
+
+ def download_error_cb(self, getter, err, tube_id):
+ self.__logger.error('Download failed on tube %u: %s', tube_id, err)
+ self.handle_download_fail()
+
+ def share_deck(self):
+ """ As the instructor XO, or as a student that has completed the deck download
+ share the deck with others in the activity """
+
+ # get a somewhat random port number
+ self.__port = random.randint(1024, 65535)
+ self.__ip_addr = "127.0.0.1"
+
+ self._fileserver = ReadHTTPServer(("", self.__port), self.__cpxo_path)
+ self.__logger.debug('Started an HTTP server on port %d', self.__port)
+
+ self.__iface.OfferStreamTube(SERVICE, {},
+ telepathy.SOCKET_ADDRESS_TYPE_IPV4,
+ (self.__ip_addr, dbus.UInt16(self.__port)),
+ telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0)
+ self.__logger.debug('Made a stream tube.')
+
+gobject.type_register(SharedSlides)
diff --git a/showntell.py b/showntell.py
new file mode 100755
index 0000000..8b37da8
--- /dev/null
+++ b/showntell.py
@@ -0,0 +1,204 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# showntell.py
+#
+# Derived from:
+#
+# Classroom Presenter for the XO Laptop
+# Main class
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from sugar.activity import activity
+from sugar.datastore import datastore
+import logging
+
+import sys, os
+import subprocess
+import gtk
+import zipfile
+
+import slideviewer
+import sidebar
+import sliderenderer
+import slideshow
+import textarea
+import toolbars
+import utils
+import shared
+import time
+import pdb
+
+import listview
+#import htmlview
+
+
+class ShowNTell(activity.Activity):
+
+ def __init__(self, handle):
+ #pdb.set_trace()
+ activity.Activity.__init__(self, handle)
+
+ self.__logger = logging.getLogger('ClassroomPresenter')
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)s %(message)s')
+
+ # Find our instance path
+ self.__work_path = os.path.join(self.get_activity_root(), 'instance')
+ self.__deck_dir = os.path.join(self.__work_path, 'deck')
+ if '-o' not in sys.argv:
+ try:
+ os.mkdir(self.__deck_dir)
+ except Exception, e:
+ self.__logger.debug("Caught exception and continuing: %s", e)
+ print 'deck_dir exists'
+ subprocess.call("rm -rf " + self.__deck_dir + "/*", shell=True)
+
+ self.__rsrc_dir = os.path.join(activity.get_bundle_path(), 'resources')
+ self.__logger.debug("Found deck directory: %s", self.__deck_dir)
+
+ # Copy the splash screen to the working directory
+ utils.copy_file(os.path.join(self.__rsrc_dir, 'splash.svg'),
+ os.path.join(self.__deck_dir, 'splash.svg'))
+
+ # Create a slide deck object
+ self.__deck = slideshow.Deck(self.__deck_dir)
+
+ # Set up activity sharing
+ self.__shared = shared.Shared(self, self.__deck, self.__work_path)
+
+ # Create a renderer for slides
+ self.__renderer = sliderenderer.Renderer(self.__deck)
+
+ # Set up the main canvas
+ self.__slide_view = gtk.HBox()
+ self.set_canvas(self.__slide_view)
+
+ # Set up Main Viewer box
+ self.__main_view_box = gtk.VBox()
+ self.__slide = slideviewer.SlideViewer(self.__deck, self.__renderer)
+ self.__text_area = textarea.TextArea(self.__deck)
+ self.__image_chooser = listview.Listview(self, self.__deck)
+ #self.__html_viewer = htmlview.Htmlview()
+ self.__main_view_box.pack_start(self.__slide, True, True, 5)
+ self.__main_view_box.pack_start(self.__image_chooser, True, True, 5)
+ #self.__main_view_box.pack_start(self.__html_viewer, True, True, 5)
+ self.__main_view_box.pack_start(self.__text_area, False, False, 0)
+
+ # Create our toolbars
+ makeTB = toolbars.MakeToolBar(self, self.__deck)
+ navTB = toolbars.NavToolBar(self, self.__shared, self.__deck)
+ inkTB = toolbars.InkToolBar(self.__slide, self.__deck)
+
+ # Create the standard activity toolbox; add our toolbars
+ toolbox = activity.ActivityToolbox(self)
+ toolbox.add_toolbar("Slideshow", makeTB)
+ toolbox.add_toolbar("Navigation",navTB)
+ toolbox.add_toolbar("Ink", inkTB)
+ self.set_toolbox(toolbox)
+ toolbox.show()
+
+ # Set up the side scrollbar widget
+ self.__side_bar = sidebar.SideBar(self.__deck, self.__renderer)
+ self.__side_bar.set_size_request(225, 100)
+
+ # Set up a separator for the two widgets
+ separator = gtk.VSeparator()
+
+ # Pack widgets into main window
+ self.__slide_view.pack_start(self.__main_view_box, True, True, 0)
+ self.__slide_view.pack_start(separator, False, False, 5)
+ self.__slide_view.pack_start(self.__side_bar, False, False, 0)
+
+ # Show all widgets
+ self.__slide_view.show_all()
+ self.__main_view_box.show()
+ self.__slide.show()
+ self.__text_area.show()
+ self.__image_chooser.hide()
+ #self.__html_viewer.hide()
+ separator.show()
+ self.__side_bar.show_all()
+
+ # Set up the progress view
+ self.__progress_max = 1.0
+ self.__progress_cur = 0.01
+ self.__progress_view = gtk.VBox()
+ self.__progress_lbl = gtk.Label("Loading slide deck...")
+ self.__progress_bar = gtk.ProgressBar()
+ self.__progress_view.pack_start(self.__progress_lbl, True, False, 5)
+ #self.__progress_view.pack_start(self.__progress_bar, False, False, 5)
+ self.__progress_bar.set_fraction(self.__progress_cur / self.__progress_max)
+
+ self.__shared.connect('deck-download-complete', self.dl_complete_cb)
+
+ def dl_complete_cb(self, widget):
+ self.do_slideview_mode()
+
+ def do_slideview_mode(self):
+ self.set_canvas(self.__slide_view)
+ self.__slide_view.show_all()
+
+ def set_progress_max(self, maxval):
+ self.__progress_max = maxval
+ self.__progress_bar.set_fraction(float(self.__progress_cur) / float(self.__progress_max))
+
+ def do_progress_view(self):
+ self.set_canvas(self.__progress_view)
+ self.__progress_view.show_all()
+
+ def set_progress(self, val):
+ self.__progress_cur = val
+ self.__progress_bar.set_fraction(float(self.__progress_cur) / float(self.__progress_max))
+
+ #resume from journal
+ def read_file(self, file_path):
+ self.__logger.debug("read_file " + str(file_path))
+ ftype = utils.getFileType(file_path)
+ z = zipfile.ZipFile(file_path, "r")
+ for i in z.infolist():
+ f = open(os.path.join(self.__deck_dir, i.filename), "wb")
+ f.write(z.read(i.filename))
+ f.close()
+ z.close()
+ self.__deck.set_title(self.metadata['title'])
+ self.__deck.reload()
+ newindex = 0
+ if 'current_index' in self.metadata:
+ newindex = int(self.metadata.get('current_index', '0'))
+ self.__deck.goToIndex(newindex, is_local=False)
+
+ #save state in journal for resume
+ def write_file(self, file_path):
+ self.__logger.debug("write_file " + str(file_path))
+ self.metadata['title'] = self.__deck.get_title()
+ self.metadata['mime_type'] = "application/x-classroompresenter"
+ self.metadata['current_index'] = str(self.__deck.getIndex())
+ self.__deck.save()
+ z = zipfile.ZipFile(file_path, "w")
+ root, dirs, files = os.walk(self.__deck_dir).next()
+ for f in files:
+ z.write(os.path.join(root, f), f)
+ z.close()
+
+ def get_shared_activity(self):
+ return self._shared_activity
+
+ def get_window(self):
+ #return (self.__slide, self.__image_chooser, self.__html_viewer)
+ return (self.__slide, self.__image_chooser)
+
+
diff --git a/sidebar.py b/sidebar.py
new file mode 100755
index 0000000..8fb739a
--- /dev/null
+++ b/sidebar.py
@@ -0,0 +1,179 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# sidebar.py
+#
+# Class to handle thumbnail views of the slide on the side of the main viewer
+#
+# W.Burnside <wburnsid@u.washington.edu>
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import pygtk
+import gtk
+import slideshow
+import slideviewer
+import os
+import logging
+import gobject
+
+from sugar.graphics import style
+
+class SideBar(gtk.Notebook):
+
+ def __init__(self, deck, renderer):
+ gtk.Notebook.__init__(self)
+ self.__logger = logging.getLogger('SideBar')
+ self.__deck = deck
+ self.__renderer = renderer
+ self.__is_instr = True
+
+ self.set_show_border(False)
+ self.set_show_tabs(True)
+ #self.show_tabs = True
+ #self.show_border = True
+
+ self.slide_context_menu = gtk.Menu() # Don't need to show menus
+
+ # Create the menu items
+ move_item = gtk.ImageMenuItem('Move')
+ img = gtk.Image()
+ img.set_from_file('icons/Icon-move.svg')
+ move_item.set_image(img)
+ move_item.connect("activate", self.moveslide)
+
+ remove_item = gtk.ImageMenuItem('remove')
+ img = gtk.Image()
+ img.set_from_file('icons/Icon-remove.svg')
+ remove_item.set_image(img)
+ remove_item.connect("activate", self.removeslide)
+
+ # Add them to the menu
+ self.slide_context_menu.append(move_item)
+ self.slide_context_menu.append(remove_item)
+
+ # We do need to show menu items
+ move_item.show()
+ remove_item.show()
+
+ # Create scrolled window for viewing thumbs or subs
+ # Scrollbar: horizontal if necessary; vertical always
+ self.__viewing_box = gtk.ScrolledWindow()
+ self.__viewing_box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ slide_label = gtk.Label("Slides")
+ event_box = gtk.EventBox()
+ event_box.add(self.__viewing_box)
+
+ self.append_page(event_box, slide_label)
+ #self.append_page(self.__viewing_box, sub_label)
+
+ self.__sublist_store = gtk.ListStore(str, int)
+ self.__sub_col = gtk.TreeViewColumn("Versions of this slide:")
+ self.__sublist = gtk.TreeView(self.__sublist_store)
+ self.__sublist.append_column(self.__sub_col)
+ self.__sublist_cell = gtk.CellRendererText()
+ self.__sub_col.pack_start(self.__sublist_cell, True)
+ self.__sub_col.add_attribute(self.__sublist_cell, 'text', 0)
+
+ sub_label = gtk.Label("Submissions")
+ self.append_page(self.__sublist, sub_label)
+
+ #self.__sublist_store.append(["My Ink", -1])
+
+ self.load_thumbs()
+
+ # show widgets
+ self.show_all()
+
+ self.__deck.connect('deck-changed', self.load_thumbs)
+ self.__deck.connect('update-submissions', self.load_subs)
+ self.__sublist.get_selection().connect('changed', self.sub_sel_changed)
+
+ def load_subs(self, widget=None, def_sub=-1):
+ self.__logger.debug("Loading submission list")
+ self.__sublist_store.clear()
+ sublist = self.__deck.getSubmissionList()
+ self.__sublist_store.append(["My Ink", -1])
+ i = 0
+ for submission in sublist:
+ self.__sublist_store.append([str(submission) + "'s Ink", i])
+ i = i + 1
+ self.__sublist.get_selection().select_path(def_sub+1)
+
+ def sub_sel_changed(self, widget=None):
+ (model, itera) = widget.get_selected()
+ if itera:
+ newindex = model.get_value(itera, 1)
+ self.__logger.debug("Submission selection changed to "+ str(newindex))
+ self.__deck.setActiveSubmission(newindex)
+
+ # Method to load slides into Scrolling side window
+ # The method uses a table to organize the slides
+ def load_thumbs(self, widget=None):
+ for c in self.__viewing_box.get_children():
+ self.__viewing_box.remove(c)
+
+ # create image table for thumbnails
+ self.image_table = gtk.Table(self.__deck.getSlideCount(), 1, False)
+
+ # Loop to show slides
+ for i in range(self.__deck.getSlideCount()):
+ # Create event box for table entry
+ event_box = gtk.EventBox()
+ event_box.set_size_request(209, 160)
+
+ # Add navigation to event boxes
+ event_box.set_above_child(True)
+ event_box.connect('button_press_event', self.change_slide, i)
+
+ # Create viewer for slide and add to box
+ slide = slideviewer.ThumbViewer(self.__deck, self.__renderer, i)
+ event_box.add(slide)
+
+ # Put box in table and show
+ self.image_table.attach(event_box, 0, 1, i, i+1)
+ event_box.show()
+
+ # Show each slide
+ slide.show()
+
+ # show images
+ self.__viewing_box.add_with_viewport(self.image_table)
+ self.image_table.show()
+ self.movemode=False
+
+
+ def change_slide(self, widget, event, n):
+ if event.button == 3:
+ self.selected_slide = n
+ self.slide_context_menu.popup( None, None, None, event.button, event.time)
+ elif self.movemode:
+ self.movemode=False
+ self.__deck.moveSlide(self.moved_slide, n)
+ self.__deck.save()
+ self.__deck.reload()
+ else:
+ self.__deck.goToIndex(n, is_local=True)
+
+ def moveslide(self, params):
+ self.movemode=True
+ self.moved_slide = self.selected_slide
+
+ def removeslide(self, params):
+ self.__deck.removeSlide(self.selected_slide)
+ self.__deck.save()
+ self.__deck.reload()
+
+
diff --git a/sliderenderer.py b/sliderenderer.py
new file mode 100755
index 0000000..9c89e88
--- /dev/null
+++ b/sliderenderer.py
@@ -0,0 +1,145 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# sliderenderer.py
+#
+# Class for rendering slides to a surface
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import cairo
+import rsvg
+import gtk
+import os
+import utils
+import time
+import logging
+
+class Renderer(object):
+ def __init__(self, deck):
+ """Constructs a new SlideRenderer that will render slides from deck"""
+ self.__logger = logging.getLogger('Renderer')
+ self.__logger.setLevel('error')
+ self.__deck = deck
+
+ def getSlideDimensionsFromFirstLayer(self, n=None):
+ """Returns the [width, height] of the first slide layer"""
+ if n is None:
+ n = self.__deck.getIndex()
+ layers = self.__deck.getSlideLayers(n)
+
+ # return some default reasonable value if this is an empty slide
+ if len(layers) == 0:
+ return [640.0, 480.0]
+
+ ftype = utils.getFileType(layers[0])
+
+ # This may be optimizable to avoid having to open the first layer to get its size,
+ # or at least keeping it around to re-use it when the slide is first rendered
+ if ftype == "svg":
+ f = open(layers[0], 'rb')
+ svg_data = f.read()
+ f.close()
+ handle = rsvg.Handle(data=svg_data)
+ a, b, w, h = handle.get_dimension_data()
+ return [w,h]
+ elif ftype == "png":
+ surface = cairo.ImageSurface.create_from_png(layers[0])
+ return [float(surface.get_width()), float(surface.get_height())]
+ elif ftype == "jpg":
+ pbuf = gtk.gdk.pixbuf_new_from_file(layers[0])
+ return [float(pbuf.get_width()), float(pbuf.get_height())]
+ else:
+ return [640.0, 480.0]
+
+ def getSlideDimensions(self, n=None):
+ """Returns the slide dimensions, using the value in the XML file first, if it exists, and then the size of the first layer"""
+ if n is None:
+ n = self.__deck.getIndex()
+ dims = self.__deck.getSlideDimensionsFromXML(n)
+ if dims == False:
+ return self.getSlideDimensionsFromFirstLayer(n)
+ else:
+ w, h = dims
+ return [w, h]
+
+ def renderSlideToSurface(self, surface, n=None):
+ if n is None:
+ n = self.__deck.getIndex()
+
+ timerstart = time.time()
+
+ self.__logger.debug("rendering slide " + str(n))
+ ctx = gtk.gdk.CairoContext(cairo.Context(surface))
+ #ctx = cairo.Context(surface)
+
+ self.__logger.debug("Got context at " + str(time.time() - timerstart))
+
+ # Get the slide dimensions and set up a Cairo transformation matrix
+ srcw, srch = self.getSlideDimensions(n)
+ if srcw > 640:
+ srcw = 640
+ if srch > 480:
+ srch = 480
+ targw = float(surface.get_width())
+ targh = float(surface.get_height())
+ x_scale = targw/srcw
+ y_scale = targh/srch
+ print 'rendering slide', str(n), "w=", targw, srcw, x_scale, "h=", targh, srch, y_scale
+
+ self.__logger.debug("Surface is " + str(targw) + "x" + str(targh))
+
+ scale = x_scale
+ if y_scale < x_scale:
+ scale = y_scale
+
+ if scale < .98 or scale > 1.02:
+ ctx.transform(cairo.Matrix(scale, 0, 0, scale, 0, 0))
+
+ self.__logger.debug("Got transformation matrix at " + str(time.time() - timerstart))
+
+ # Paint the slide background
+ ctx.set_source_rgb(1.0, 1.0, 1.0)
+ ctx.rectangle(0, 0, srcw, srch)
+ ctx.fill()
+
+ self.__logger.debug("Filled background at " + str(time.time() - timerstart))
+
+ # Paint the layers
+ layers = self.__deck.getSlideLayers(n)
+ self.__logger.debug("Got layers at " + str(time.time() - timerstart))
+ for layer in layers:
+ type = utils.getFileType(layer)
+ self.__logger.debug("Drawing layer " + str(layer) +" " + str(scale) + " at " + str(time.time() - timerstart))
+ print 'drawing layer', type, str(layer)
+ if type == "svg":
+ f = open(layer, "rb")
+ svg_data = f.read()
+ f.close()
+ handle = rsvg.Handle(data=svg_data)
+ handle.render_cairo(ctx)
+ elif type == "png":
+ png_surface = cairo.ImageSurface.create_from_png(layer)
+ self.__logger.debug("Got PNG surface at "+ str(time.time() - timerstart))
+ ctx.set_source_surface(png_surface, 0, 0)
+ ctx.rectangle(0, 0, png_surface.get_width(), png_surface.get_height())
+ ctx.fill()
+ elif type == "jpg":
+ jpg_pixbuf = gtk.gdk.pixbuf_new_from_file(layer)
+ self.__logger.debug("Got JPG pixbuf at "+ str(time.time() - timerstart))
+ ctx.set_source_pixbuf(jpg_pixbuf, 0, 0)
+ ctx.rectangle(0, 0, jpg_pixbuf.get_width(), jpg_pixbuf.get_height())
+ ctx.fill()
+ self.__logger.debug("Finished drawing layer at "+ str(time.time() - timerstart))
diff --git a/slideshow.py b/slideshow.py
new file mode 100755
index 0000000..bc878c6
--- /dev/null
+++ b/slideshow.py
@@ -0,0 +1,594 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# slideshow.py
+#
+# Classes to represent a deck of slides, and handle things like file I/O and
+# formats
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+import os
+import gtk
+import xml.dom.minidom
+import gobject
+import logging
+from path import path
+from sugar.activity import activity
+
+class Deck(gobject.GObject):
+
+ __gsignals__ = {
+ 'slide-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ 'slide-redraw' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ 'remove-path' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
+ 'deck-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ 'local-ink-added' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)),
+ 'remote-ink-added' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)),
+ 'instr-state-propagate' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_BOOLEAN,)),
+ 'lock-state-propagate' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_BOOLEAN,)),
+ 'ink-submitted' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING)),
+ 'ink-broadcast' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
+ (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)),
+ 'update-submissions' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
+ 'instructor-ink-cleared' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
+ 'instructor-ink-removed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_INT)),
+ }
+
+ def __init__(self, base="/nfs/show"):
+ gobject.GObject.__init__(self)
+ self.__logger = logging.getLogger('Deck')
+ self.__base = base
+
+ self.__is_initiating = True
+ self.__nav_locked = False
+ self.__active_sub = -1
+ self.__self_text = ""
+ self.__text_tag = None
+
+ # Compute the path to the deck.xml file and read it if it exists;
+ # otherwise we'll create a new XML Document
+ self.__xmlpath = os.path.join(base, "deck.xml")
+ self.reload()
+
+ def set_locked_mode(self, locked):
+ """ Setter method for the navigation lock flag"""
+ self.__logger.debug("Lock state: " +str(locked))
+ self.__nav_locked = locked
+ self.emit('lock-state-propagate', locked)
+
+ def set_is_initiating(self, is_init):
+ """ Setter method for the instructor flag """
+ self.__logger.debug("Instructor state: " +str(is_init))
+ self.__is_initiating = is_init
+ self.emit('instr-state-propagate', is_init)
+
+ def getIsInitiating(self):
+ return self.__is_initiating
+
+ def set_title(self, title):
+ self.__title = title
+
+ def get_title(self):
+ print 'get_title', self.__title
+ if len(self.__title) > 0:
+ return self.__title
+ else:
+ return "no title"
+
+ def reload(self):
+ self.__logger.debug("Reading deck")
+ if os.path.exists(self.__xmlpath):
+ self.__dom = xml.dom.minidom.parse(self.__xmlpath)
+ else:
+ self.__dom = xml.dom.minidom.Document()
+
+ # Look for the root deck element; create it if it's not there
+ decks = self.__dom.getElementsByTagName("deck")
+ if len(decks) > 0:
+ self.__deck = decks[0]
+ nodes = self.__dom.getElementsByTagName("title")
+ if len(nodes) > 0:
+ self.__title = nodes[0].firstChild.data
+ else:
+ self.__deck = self.__dom.createElement("deck")
+ self.__dom.appendChild(self.__deck)
+ self.__title = 'new'
+ title = self.__dom.createElement("title")
+ title.appendChild(self.__dom.createTextNode(self.__title))
+ self.__deck.appendChild(title)
+ splash = self.__dom.createElement("slide")
+ layer = self.__dom.createElement("layer")
+ layer.appendChild(self.__dom.createTextNode("splash.svg"))
+ splash.appendChild(layer)
+ self.__deck.appendChild(splash)
+ print "Deck.__title=", self.__title
+
+ # Get the slides from the show
+ self.__slides = self.__deck.getElementsByTagName("slide")
+ self.__nslides = len(self.__slides)
+ self.__logger.debug(str(self.__nslides) + " slides in show")
+ self.goToIndex(0, is_local=False)
+ self.emit("deck-changed")
+
+ def save(self, path=None):
+ """Writes the XML DOM in memory out to disk"""
+ if not path:
+ path = self.__xmlpath
+ outfile = open(path, "w")
+ self.__dom.writexml(outfile)
+ outfile.close()
+
+ def rebuild_dom(self, title, slides):
+ dom = xml.dom.minidom.Document()
+ deck = dom.createElement("deck")
+ title = dom.createElement("title")
+ title.appendChild(dom.createTextNode("new"))
+ deck.appendChild(title)
+ for slide in slides:
+ deck.appendChild(slide)
+ dom.appendChild(deck)
+ return dom
+
+ def getDeckPath(self):
+ """Returns the path to the folder that stores this slide deck"""
+ return self.__base
+
+ def resizeImage(self, inpath, outpath, w, h):
+ # resize an image
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(inpath, w, h)
+ #scaled_buf = pixbuf.scale.simple(w, h, gtk.gdk.INTERP_BILINEAR)
+ pixbuf.save(outpath, "png")
+
+ def addSlide(self,file_path):
+
+ INSTANCE = path(activity.get_activity_root()) / 'instance'
+ filepath = path(file_path)
+ print 'addSlide file_path', filepath.exists(), filepath
+ filename = filepath.name
+ inpath = INSTANCE / 'deck' / filename
+ print 'inpath', inpath.exists(), inpath
+ path.copy(filepath, inpath)
+ outpath = path(activity.get_activity_root() ) / 'instance' / 'deck' / filename
+ print 'outpath=', outpath.exists(), outpath
+ self.resizeImage(inpath, outpath, 640, 480)
+ print 'outpath=', outpath.exists(), outpath
+
+ print 'get slide dimensions'
+ dims = self.getSlideDimensionsFromXML(0)
+ if dims == False:
+ wf = 640
+ hf = 480
+ else:
+ wf, hf = dims
+ w = str(int(wf))
+ h = str(int(hf))
+ print 'add slide', w, h
+ newslide = self.__dom.createElement("slide")
+ newslide.setAttribute("height", h)
+ newslide.setAttribute("title", "newslide")
+ newslide.setAttribute("width", w)
+ newlayer = self.__dom.createElement("layer")
+ txt = self.__dom.createTextNode(filename)
+ newlayer.appendChild(txt)
+ newslide.appendChild(newlayer)
+ self.__deck.appendChild(newslide)
+ print 'added slide', self.__dom.toxml()
+ self.save()
+
+ def removeSlide(self, n):
+ del self.__slides[n]
+ self.__dom = self.rebuild_dom("modified deck", self.__slides)
+
+ def moveSlide(self, f, t):
+ if f < t:
+ self.__slides.insert(t, self.__slides[f])
+ del self.__slides[f]
+ elif t < f:
+ self.__slides.insert(t, self.__slides[f])
+ del self.__slides[f+1]
+ self.__dom = self.rebuild_dom("modified deck", self.__slides)
+
+ def getSlideLayers(self, n=-1):
+ """Returns a list of the layers that comprise this slide"""
+ if n == -1:
+ n = self.__pos
+ slide = self.__slides[n]
+ self.__layers = slide.getElementsByTagName("layer")
+ layers = []
+ for l in self.__layers:
+ p = os.path.join(self.__base, l.firstChild.nodeValue)
+ layers.append(p)
+ return layers
+
+ def getInstructorInk(self):
+ self.__instructor_ink = []
+ instr = self.__slide.getElementsByTagName("instructor")
+ if len(instr) > 0:
+ self.__instructor_tag = instr[0]
+ pathtags = self.__instructor_tag.getElementsByTagName("path")
+ for pathstr in pathtags:
+ self.__instructor_ink.append(pathstr.firstChild.nodeValue)
+ return self.__instructor_ink
+
+ def getSelfInkOrSubmission(self):
+ if self.__active_sub == -1:
+ return (self.__self_ink, self.__self_text)
+ subtags = self.__slide.getElementsByTagName("submission")
+ if self.__active_sub > -1 and self.__active_sub < len(subtags):
+ active_subtag = subtags[self.__active_sub]
+ text = ""
+ texts = active_subtag.getElementsByTagName("text")
+ if len(texts) > 0:
+ if texts[0].firstChild:
+ text = texts[0].firstChild.nodeValue
+ pathlist = []
+ paths = active_subtag.getElementsByTagName("path")
+ for path in paths:
+ if path.firstChild:
+ pathlist.append(path.firstChild.nodeValue)
+ return (pathlist, text)
+ return None
+
+ def setActiveSubmission(self, sub):
+ self.__active_sub = sub
+ self.emit('slide-redraw')
+
+ def getActiveSubmission(self):
+ return self.__active_sub
+
+ def getSubmissionList(self, n=None):
+ if n is None:
+ n = self.__pos
+ subtags = self.__slide.getElementsByTagName("submission")
+ sublist = []
+ for subtag in subtags:
+ sublist.append(subtag.getAttribute("from"))
+ return sublist
+
+ def addSubmission(self, whofrom, inks, text="", n=None):
+ if n is None:
+ n = self.__pos
+ if n >= 0 and n < self.getSlideCount():
+ slide = self.__slides[n]
+ else:
+ slide = self.__slides[self.__pos]
+ newsub = self.__dom.createElement("submission")
+ newsub.setAttribute("from", whofrom)
+ substrparts = inks.split("$")
+ for part in substrparts:
+ if len(part) > 0:
+ newpath = self.__dom.createElement("path")
+ newpath.appendChild(self.__dom.createTextNode(part))
+ newsub.appendChild(newpath)
+ subtext = self.__dom.createElement("text")
+ subtext.appendChild(self.__dom.createTextNode(text))
+ newsub.appendChild(subtext)
+ subs = slide.getElementsByTagName("submission")
+ for sub in subs:
+ if sub.getAttribute("from") == whofrom:
+ slide.removeChild(sub)
+ slide.appendChild(newsub)
+ subs = slide.getElementsByTagName("submission")
+ if n == self.__pos:
+ self.emit('update-submissions', len(subs) - 1)
+
+ def addInkToSlide(self, pathstr, islocal, n=None):
+ """Adds ink to the current slide, or slide n if given. Instructor ink may be added to any slide;
+ but it only makes sense to add student ink to the current slide (n will be ignored)"""
+ if n is None:
+ slide = self.__slide
+ instr_tag = self.__instructor_tag
+ if instr_tag == None:
+ instr_tag = self.__dom.createElement("instructor")
+ slide.appendChild(instr_tag)
+ self.__instructor_tag = instr_tag
+ else:
+ if n < self.getSlideCount and n >= 0:
+ slide = self.__slides[n]
+ else:
+ slide = self.__slides[self.__pos]
+ instr_tags = slide.getElementsByTagName("instructor")
+ if len(instr_tags) > 0:
+ instr_tag = instr_tags[0]
+ else:
+ instr_tag = self.__dom.createElement("instructor")
+ slide.appendChild(instr_tag)
+ if not islocal or self.__is_initiating:
+ self.__instructor_ink.append(pathstr)
+ path = self.__dom.createElement("path")
+ path.appendChild(self.__dom.createTextNode(pathstr))
+ instr_tag.appendChild(path)
+ else:
+ self.__self_ink.append(pathstr)
+ if not self.__self_ink_tag:
+ self.__self_ink_tag = self.__dom.createElement("self")
+ self.__slide.appendChild(self.__self_ink_tag)
+ path = self.__dom.createElement("path")
+ path.appendChild(self.__dom.createTextNode(pathstr))
+ self.__self_ink_tag.appendChild(path)
+ if islocal:
+ self.emit("local-ink-added", pathstr)
+ else:
+ if n is None or n == self.__pos:
+ self.emit("remote-ink-added", pathstr)
+
+ def clearInk(self, n=None):
+ if n is None:
+ n = self.__pos
+ slide = self.__slides[n]
+ if self.__is_initiating:
+ self.clearInstructorInk(n)
+ self.emit('instructor-ink-cleared', n)
+ self_tags = slide.getElementsByTagName("self")
+ for self_tag in self_tags:
+ slide.removeChild(self_tag)
+ self.__self_ink = []
+ self.__self_ink_tag = None
+
+ def clearInstructorInk(self, n=None):
+ if n is None:
+ n = self.__pos
+ slide = self.__slides[n]
+ instructor_tags = slide.getElementsByTagName("instructor")
+ for instructor_tag in instructor_tags:
+ slide.removeChild(instructor_tag)
+ if n == self.__pos:
+ self.__instructor_ink = []
+ self.__instructor_tag = None
+ self.emit('slide-redraw')
+
+ def removeInstructorPathByUID(self, uid, n=None):
+ if n is None:
+ n = self.__pos
+ needs_redraw = False
+ slide = self.__slides[n]
+ instructor_tags = slide.getElementsByTagName("instructor")
+ if len(instructor_tags) > 0:
+ instructor_tag = instructor_tags[0]
+ else:
+ return
+ path_tags = instructor_tag.getElementsByTagName("path")
+ for path_tag in path_tags:
+ if path_tag.firstChild:
+ pathstr = path_tag.firstChild.nodeValue
+ path_uid = 0
+ try:
+ path_uid = int(pathstr[0:pathstr.find(';')])
+ except Exception, e:
+ pass
+ if path_uid == uid:
+ instructor_tag.removeChild(path_tag)
+ needs_redraw = True
+ if n == self.__pos and needs_redraw:
+ self.emit('remove-path', uid)
+
+ def removeLocalPathByUID(self, uid, n=None):
+ if n is None:
+ n = self.__pos
+ slide = self.__slides[n]
+ if self.__is_initiating:
+ self.emit('instructor_ink_removed', uid, n)
+ tags = slide.getElementsByTagName("instructor")
+ else:
+ tags = slide.getElementsByTagName("self")
+ if len(tags) > 0:
+ tag = tags[0]
+ else:
+ return
+ path_tags = tag.getElementsByTagName("path")
+ for path_tag in path_tags:
+ if path_tag.firstChild:
+ pathstr = path_tag.firstChild.nodeValue
+ path_uid = 0
+ try:
+ path_uid = int(pathstr[0:pathstr.find(';')])
+ except Exception, e:
+ pass
+ if path_uid == uid:
+ tag.removeChild(path_tag)
+
+ def doSubmit(self):
+ inks, text, whofrom = self.getSerializedInkSubmission()
+ self.__logger.debug("Submitting ink: " + str(inks) + " text: " + text)
+ self.emit('ink-submitted', inks, text)
+
+ def doBroadcast(self):
+ inks, text, whofrom = self.getSerializedInkSubmission()
+ self.emit('ink-broadcast', whofrom, inks, text)
+
+ def getSerializedInkSubmission(self):
+ sub = ""
+ text = ""
+ if self.__active_sub == -1:
+ self_tags = self.__slide.getElementsByTagName("self")
+ if len(self_tags) > 0:
+ texts = self_tags[0].getElementsByTagName("text")
+ if len(texts) > 0:
+ if texts[0].firstChild:
+ text = texts[0].firstChild.nodeValue
+ for path in self_tags[0].getElementsByTagName("path"):
+ sub = sub + path.firstChild.nodeValue + "$"
+ return sub, text, "myself"
+ else:
+ sub = ""
+ whofrom = "unknown"
+ subtags = self.__slide.getElementsByTagName("submission")
+ if self.__active_sub > -1 and self.__active_sub < len(subtags):
+ active_subtag = subtags[self.__active_sub]
+ text = ""
+ whofrom = active_subtag.getAttribute("from")
+ texts = active_subtag.getElementsByTagName("text")
+ if len(texts) > 0:
+ if texts[0].firstChild:
+ text = texts[0].firstChild.nodeValue
+ pathlist = []
+ paths = active_subtag.getElementsByTagName("path")
+ for path in paths:
+ if path.firstChild:
+ sub = sub + path.firstChild.nodeValue + "$"
+ return sub, text, whofrom
+
+ def getSlideThumb(self, n=-1):
+ """Returns the full path to the thumbnail for this slide if it is defined; otherwise False"""
+ if n == -1:
+ n = self.__pos
+ slide = self.__slides[n]
+ thumbs = slide.getElementsByTagName("thumb")
+ if len(thumbs) < 1:
+ return False
+ return os.path.join(self.__base, thumbs[0].firstChild.nodeValue)
+
+ def setSlideThumb(self, filename, n=-1):
+ """Sets the thumbnail for this slide to filename (provide a *relative* path!)"""
+ if n == -1:
+ n = self.__pos
+ slide = self.__slides[n]
+ thumbs = slide.getElementsByTagName("thumb")
+ for t in thumbs:
+ slide.removeChild(t)
+ thumb = self.__dom.createElement("thumb")
+ thumb.appendChild(self.__dom.createTextNode(filename))
+ slide.appendChild(thumb)
+
+ def getSlideClip(self, n=-1):
+ """Returns the full path to the audio clip for this slide if it is defined; otherwise False"""
+ if n == -1:
+ n = self.__pos
+ slide = self.__slides[n]
+ clip = slide.getElementsByTagName("clip")
+ if len(clip) < 1:
+ return False
+ return os.path.join(self.__base, clip[0].firstChild.nodeValue)
+
+ def setSlideClip(self, filename, n=-1):
+ """Sets the clip for this slide to filename (provide a *relative* path!)"""
+ if n == -1:
+ n = self.__pos
+ slide = self.__slides[n]
+ clips = slide.getElementsByTagName("clip")
+ for clip in clips:
+ slide.removeChild(clip)
+ thumb = self.__dom.createElement("clip")
+ thumb.appendChild(self.__dom.createTextNode(filename))
+ slide.appendChild(thumb)
+
+ def setSlideText(self, textval):
+ self.__self_text = textval
+ if self.__text_tag:
+ if self.__text_tag.firstChild:
+ self.__text_tag.firstChild.nodeValue = textval
+ else:
+ self.__text_tag.appendChild(self.__dom.createTextNode(textval))
+
+ def doNewIndex(self):
+ """Updates any necessary state associated with moving to a new slide"""
+ self.__slide = self.__slides[self.__pos]
+ self_ink = self.__slide.getElementsByTagName("self")
+ self.__instructor_tag = None
+ self.__self_ink_tag = None
+ self.__instructor_ink = []
+ self.__self_ink = []
+ self.__self_text = ""
+ self.__text_tag = None
+ self.__active_sub = -1
+ if len(self_ink) > 0:
+ self.__self_ink_tag = self_ink[0]
+ texttags = self.__self_ink_tag.getElementsByTagName("text")
+ if len(texttags) > 0:
+ self.__text_tag = texttags[0]
+ else:
+ self.__text_tag = self.__dom.createElement(text)
+ self.__text_tag.appendChild(self.__dom.createTextNode(""))
+ self.__self_ink_tag.appendChild(text)
+ pathtags = self.__self_ink_tag.getElementsByTagName("path")
+ for pathstr in pathtags:
+ self.__self_ink.append(pathstr.firstChild.nodeValue)
+ else:
+ self.__self_ink_tag = self.__dom.createElement("self")
+ self.__slide.appendChild(self.__self_ink_tag)
+ self.__text_tag = self.__dom.createElement("text")
+ self.__text_tag.appendChild(self.__dom.createTextNode(""))
+ self.__self_ink_tag.appendChild(self.__text_tag)
+ if self.__text_tag.firstChild:
+ self.__self_text = self.__text_tag.firstChild.nodeValue
+
+ self.emit("slide-changed")
+ self.emit("update-submissions", self.__active_sub)
+ self.emit("slide-redraw")
+
+ def goToIndex(self, index, is_local):
+ """Jumps to the slide at the given index, if it's valid"""
+ self.__logger.debug("Trying to change slides: locked? %u, instructor? %u, is_local? %u",
+ self.__nav_locked, self.__is_initiating, is_local)
+
+ in_range = index < self.__nslides and index >= 0
+
+ if (self.__is_initiating or not is_local or not self.__nav_locked) and in_range:
+ self.__logger.debug("Changing slide to index: %u", index)
+ self.__pos = index
+ self.doNewIndex()
+ else:
+ self.__pos = index
+ print 'invalid index', index
+
+ def getIndex(self):
+ """Returns the index of the current slide"""
+ return self.__pos
+
+ def next(self):
+ """Moves to the next slide"""
+ self.goToIndex(self.__pos + 1, is_local=True)
+
+ def previous(self):
+ """Moves to the previous slide"""
+ self.goToIndex(self.__pos - 1, is_local=True)
+
+ def isAtBeginning(self):
+ """Returns true if show is on the first slide in the deck"""
+ if self.__nslides < 1:
+ return True
+
+ if self.__pos == 0:
+ return True
+ else:
+ return False
+
+ def isAtEnd(self):
+ """Returns true if the show is at the last slide in the deck"""
+ if self.__nslides < 1:
+ return True
+
+ if self.__pos == self.__nslides - 1:
+ return True
+ else:
+ return False
+
+ def getSlideDimensionsFromXML(self, n=-1):
+ """Returns the dimensions for the slide at index n, if they're specified"""
+ if n == -1:
+ n = self.__pos
+ slide = self.__slides[n]
+ wstring = slide.getAttribute("width")
+ hstring = slide.getAttribute("height")
+ if wstring != '' and hstring != '':
+ return [float(wstring), float(hstring)]
+ return False
+
+ def getSlideCount(self):
+ return self.__nslides
+
+gobject.type_register(Deck)
diff --git a/slideviewer.py b/slideviewer.py
new file mode 100755
index 0000000..5156bbf
--- /dev/null
+++ b/slideviewer.py
@@ -0,0 +1,315 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# slideviewer.py
+#
+# Class for displaying Classroom Presenter SVG slides in a GTK widget
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import cairo
+import rsvg
+import gtk
+import os
+import time
+import ink
+import logging
+import gobject
+
+class SlideViewer(gtk.EventBox):
+ __gsignals__ = {'button_press_event' : 'override',
+ 'button_release_event' : 'override',
+ 'motion_notify_event' : 'override',
+ 'enter_notify_event' : 'override',
+ 'undo-redo-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
+ }
+
+ def __init__(self, deck, renderer):
+ gtk.EventBox.__init__(self)
+ self.__logger = logging.getLogger('SlideViewer')
+ self.__logger.setLevel('error')
+ self.__deck = deck
+ self.__canvas = SlideViewerCanvas(deck, renderer)
+ self.add(self.__canvas)
+ self.__canvas.show()
+ self.__deck.connect("slide-redraw", self.show_current)
+ self.__deck.connect("remote-ink-added", self.remote_ink_added)
+ self.__deck.connect("instr-state-propagate", self.set_is_instructor)
+ self.__deck.connect("remove-path", self.instr_remove_ink)
+ self.__cur_path = None
+ self.__is_instr = True
+
+ # default color-blue and pen-4
+ self.set_pen(4)
+ self.set_color(0.0, 0.0, 1.0)
+
+ def set_is_instructor(self, widget, isInstr):
+ self.__is_instr = isInstr
+ self.__canvas.is_instr = isInstr
+
+ def set_color(self, r, g, b):
+ self.__canvas.cur_color = (r, g, b)
+
+ def get_color(self):
+ return self.__canvas.get_color()
+
+ def set_pen(self, size):
+ self.__canvas.cur_pen = size
+
+ def get_pen(self):
+ return self.__canvas.get_pen()
+
+ def show_current(self, widget):
+ """Handle a slide-redraw event by showing the current slide."""
+ self.show_slide()
+
+ def show_slide(self, n=None):
+ self.__canvas.show_slide(n)
+
+ def remote_ink_added(self, event, inkstr):
+ self.__canvas.add_ink_path(ink.Path(inkstr), ink_from_instr=True)
+ self.__canvas.queue_draw()
+
+ def clear_ink(self):
+ self.__deck.clearInk()
+ if self.__is_instr:
+ self.__canvas.instr_ink = []
+ if self.__deck.getActiveSubmission() == -1:
+ self.__canvas.self_ink = []
+ self.__canvas.queue_draw()
+
+ def instr_remove_ink(self, widget, uid):
+ for path in self.__canvas.instr_ink:
+ if path.uid == uid:
+ self.__canvas.instr_ink.remove(path)
+ self.__canvas.queue_draw()
+
+ def submit_ink(self):
+ self.__logger.debug("Submit clicked")
+ self.__deck.doSubmit()
+
+ def broadcast_ink(self):
+ self.__deck.doBroadcast()
+
+ def can_undo_redo(self):
+ if self.__deck.getActiveSubmission() == -1 or self.__is_instr:
+ if self.__is_instr:
+ return ((len(self.__canvas.instr_ink) > 0), (len(self.__canvas.redo_stack) > 0))
+ else:
+ return ((len(self.__canvas.self_ink) > 0), (len(self.__canvas.redo_stack) > 0))
+ else:
+ return (False, False)
+
+ def undo(self):
+ if self.__is_instr:
+ undo_stack = self.__canvas.instr_ink
+ else:
+ undo_stack = self.__canvas.self_ink
+ if len(undo_stack) > 0:
+ path = undo_stack.pop()
+ self.__deck.removeLocalPathByUID(path.uid)
+ self.__canvas.redo_stack.append(path)
+ self.__canvas.queue_draw()
+ self.emit('undo-redo-changed')
+
+ def redo(self):
+ if len(self.__canvas.redo_stack) > 0:
+ path = self.__canvas.redo_stack.pop()
+ self.__deck.addInkToSlide(str(path), islocal=True)
+ if self.__is_instr:
+ self.__canvas.instr_ink.append(path)
+ else:
+ self.__canvas.self_ink.append(path)
+ self.__canvas.queue_draw()
+ self.emit('undo-redo-changed')
+
+ def do_button_press_event(self, event):
+ if self.__deck.getActiveSubmission() == -1 or self.__is_instr:
+ self.__last_pos = (event.x, event.y)
+ self.__cur_path = ink.Path()
+ self.__cur_path.color = self.__canvas.cur_color
+ self.__cur_path.pen = self.__canvas.cur_pen
+ self.__cur_path.add((event.x, event.y));
+ self.__canvas.add_ink_path(self.__cur_path)
+
+ def do_button_release_event(self, event):
+ if self.__cur_path:
+ self.__cur_path.add((event.x, event.y));
+ self.__deck.addInkToSlide(str(self.__cur_path), islocal=True)
+ self.__cur_path = None
+ self.__canvas.redo_stack = []
+ self.emit('undo-redo-changed')
+
+
+ def do_motion_notify_event(self, event):
+ if self.__cur_path:
+ self.__pos = (event.x, event.y)
+ if(self.has_moved()):
+ self.__canvas.draw_ink_seg_immed(self.__last_pos, self.__pos)
+ self.__cur_path.add((event.x, event.y));
+ self.__last_pos = self.__pos
+
+ def has_moved(self):
+ deltaX = self.__pos[0] - self.__last_pos[0]
+ deltaY = self.__pos[1] - self.__last_pos[1]
+ return (deltaX > 3 or deltaX < -3 or deltaY > 3 or deltaY < -3)
+
+ def do_enter_notify_event(self, event):
+ self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.PENCIL))
+
+class SlideViewerCanvas(gtk.DrawingArea):
+ __gsignals__ = {'expose_event' : 'override',
+ 'configure_event' : 'override',
+ }
+
+ def __init__ (self, deck, renderer):
+ gtk.DrawingArea.__init__ (self)
+ self.__logger = logging.getLogger('SlideViewerCanvas')
+ self.__logger.setLevel('error')
+ self.__surface = None
+ self.__renderer = renderer
+ self.__deck = deck
+ self.instr_ink = []
+ self.self_ink = []
+ self.redo_stack = []
+ self.is_instr = True
+ self.cur_pen = None
+ self.cur_color = None
+
+
+ def show_slide(self, n=None):
+ timerstart = time.time()
+ x, y, width, height = self.allocation
+ self.__surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
+ self.__renderer.renderSlideToSurface(self.__surface, n)
+ self.instr_ink = []
+ self.self_ink = []
+ self.redo_stack = []
+ instr = self.__deck.getInstructorInk()
+ selfink, text = self.__deck.getSelfInkOrSubmission()
+ for path in instr:
+ self.instr_ink.append(ink.Path(path))
+ for path in selfink:
+ self.self_ink.append(ink.Path(path))
+ self.queue_draw()
+ self.__logger.debug("Rendering slide took " + str(time.time() - timerstart) + " seconds")
+
+ def add_ink_path(self, path, ink_from_instr=False):
+ if self.is_instr or ink_from_instr:
+ self.instr_ink.append(path)
+ else:
+ self.self_ink.append(path)
+
+ def draw_ink_seg_immed(self, start, end):
+ self.__context = self.window.cairo_create()
+ self.__context.set_source_rgb(self.cur_color[0], self.cur_color[1], self.cur_color[2])
+ self.__context.set_line_width(self.cur_pen)
+ self.__context.move_to(start[0], start[1])
+ self.__context.line_to(end[0], end[1])
+ self.__context.stroke()
+
+ def do_configure_event(self, event):
+ """Reload the slide when assigned a new height/width"""
+ if self.__renderer:
+ self.show_slide()
+
+ def do_expose_event (self, event):
+ """Draw the slide surface into the DrawingArea"""
+ timerstart = time.time()
+ if self.__surface:
+ # Draw the (cached) slide
+ self.__context = self.window.cairo_create()
+ self.__context.set_source_surface(self.__surface, 0, 0)
+ self.__context.paint()
+ self.draw_ink_paths(self.instr_ink)
+ self.draw_ink_paths(self.self_ink)
+
+ self.__logger.debug("Exposing slide took " + str(time.time() - timerstart) + " seconds")
+
+ def draw_ink_paths(self, paths):
+ for path in paths:
+ self.__context.set_line_width(path.pen)
+ self.__context.set_source_rgb(path.color[0], path.color[1], path.color[2])
+ start = True
+ for point in path.points:
+ if start:
+ self.__context.move_to(point[0], point[1])
+ start = False
+ else:
+ self.__context.line_to(point[0], point[1])
+ self.__context.stroke()
+
+ def get_pen(self):
+ return self.cur_pen
+
+ def get_color(self):
+ return self.cur_color
+
+
+class ThumbViewer(gtk.DrawingArea):
+
+ __gsignals__ = {'expose_event' : 'override',
+ }
+
+ def __init__ (self, deck, renderer, n):
+ gtk.DrawingArea.__init__ (self)
+ self.__logger = logging.getLogger('ThumbViewer')
+ self.__logger.setLevel('error')
+ self.__deck = deck
+ self.__renderer = renderer
+ self.__n = n
+ self.__was_highlighted = False
+ self.__deck.connect('slide-redraw', self.slide_changed)
+
+ # Load thumbnail from the PNG file, if it exists; otherwise draw from scratch
+ timerstart = time.time()
+ thumb = self.__deck.getSlideThumb(n)
+ if thumb and os.path.exists(thumb):
+ self.__surface = cairo.ImageSurface.create_from_png(thumb)
+ else:
+ self.__surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 200, 150)
+ self.__renderer.renderSlideToSurface(self.__surface, n)
+
+ # Cache thumbnail
+ name = "slide" + str(n) + "_thumb.png"
+ thumb = os.path.join(self.__deck.getDeckPath(), name)
+ self.__surface.write_to_png(thumb)
+ self.__deck.setSlideThumb(name, n)
+ self.__logger.debug("Thumbnail loading/drawing took " + str(time.time() - timerstart) + " seconds")
+
+
+ def do_expose_event (self, event):
+ """Redraws the slide thumbnail view"""
+ timerstart = time.time()
+ ctx = self.window.cairo_create()
+ x, y, width, height = self.allocation
+ if self.__n == self.__deck.getIndex():
+ ctx.set_source_rgb(0, 1.0, 0)
+ self.__was_highlighted = True
+ else:
+ ctx.set_source_rgb(0.7, 0.7, 0.7)
+ self.__was_highlighted = False
+ ctx.rectangle(0, 0, width, height)
+ ctx.fill()
+ if self.__surface:
+ ctx.set_source_surface(self.__surface, 0, 0)
+ ctx.rectangle(5, 5, 200, 150)
+ ctx.fill()
+ self.__logger.debug("Exposing slide thumbnail took " + str(time.time() - timerstart) + " seconds")
+
+ def slide_changed(self, widget):
+ """Updates highlighting, if necessary, when current slide changes"""
+ if self.__was_highlighted != (self.__n == self.__deck.getIndex()):
+ self.queue_draw()
diff --git a/textarea.py b/textarea.py
new file mode 100755
index 0000000..260c887
--- /dev/null
+++ b/textarea.py
@@ -0,0 +1,172 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+# textarea.py
+#
+# Class to show, save, submit text entries
+#
+# W.Burnside <wburnsid@u.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+import os, time
+from path import path
+import pygtk
+import gtk
+import logging
+import subprocess
+from sugar.activity import activity
+
+import pygst
+pygst.require("0.10")
+import gst
+
+class TextArea(gtk.HBox):
+
+
+ # Constructor
+ def __init__(self, deck):
+ gtk.HBox.__init__(self)
+
+ self.__logger = logging.getLogger('TextArea')
+ self.__deck = deck
+ self.__text_area = gtk.Entry()
+ self.render_text_area()
+ self.__record=False
+ self.__play=False
+ self.__deck.connect('slide-redraw', self.update_text)
+ self.__text_area.connect('changed', self.text_changed)
+ self.__logger.debug("Constructed")
+
+ """
+ #initialize audio record pipeline
+ player = gst.Pipeline("player")
+ #source = gst.element_factory_make("alsasrc", "alsa-source")
+ source = gst.element_factory_make("filesrc", "file-source")
+ player.add(source)
+ parse = gst.element_factory_make("wavparse", "parser")
+ player.add(parse)
+ convert = gst.element_factory_make("audioconvert", "converter")
+ player.add(convert)
+ enc = gst.element_factory_make("vorbisenc", "vorbis-encoder")
+ player.add(enc)
+ create = gst.element_factory_make("oggmux", "ogg-create")
+ player.add(create)
+ fileout = gst.element_factory_make("filesink", "sink")
+ player.add(fileout)
+ gst.element_link_many(source, parse, convert, enc, create, fileout)
+ self.__player = player
+ self.__source = source
+ self.__fileout = fileout
+ """
+
+ def update_text(self, widget):
+ selfink, text = self.__deck.getSelfInkOrSubmission()
+ self.__text_area.set_text(text)
+ if self.__deck.getActiveSubmission() == -1 and not self.__deck.getIsInitiating():
+ self.__text_area.set_sensitive(True)
+ else:
+ self.__text_area.set_sensitive(False)
+
+ def text_changed(self, entry):
+ if self.__deck.getActiveSubmission() == -1:
+ self.__deck.setSlideText(self.__text_area.get_text())
+
+ def render_text_area(self, widget=None):
+
+ # pack widgets
+ self.pack_start(self.create_bbox(title="Audio Controls"), False, False, 0)
+ self.pack_start(self.__text_area, True, True, 0)
+
+ # show widgets
+ self.__text_area.show()
+ self.show()
+
+ # Clear text in entry box
+ def clear_text(self, widget, event):
+ self.__text_area.set_text("")
+
+ # Start Recording
+ def record(self, params):
+ if self.__record:
+ #we are recording, stop and save clip
+ subprocess.call("killall -q arecord", shell=True)
+ #convert to ogg file
+ pipeline = "filesrc location=/tmp/temp.wav ! wavparse ! audioconvert ! vorbisenc ! oggmux ! filesink location=" + self.__audiofile
+ print 'pipeline', pipeline
+ subprocess.call("gst-launch-0.10 " + pipeline, shell=True)
+ #self.__player.set_state(gst.STATE_PLAYING)
+ #time.sleep(10)
+ #self.__player.set_state(gst.STATE_NULL)
+ self.__record = False
+ self.__deck.setSlideClip(self.__audiofile, n = self.__deck.getIndex())
+ self.__deck.save()
+ self.__deck.reload()
+ #reset mic boost (xo)
+ subprocess.call("amixer cset numid=11 off", shell = True)
+ print 'recording stopped'
+ else:
+ self.__record = True
+ #what is name of clip? If it exists, rm it
+ self.__audiofile = self.__deck.getSlideClip()
+ if path(self.__audiofile).exists():
+ subprocess.call("rm -rf " + str(self.__audiofile), shell=True)
+ else:
+ self.__audiofile = path(self.__deck.getDeckPath()) / 'slide' + str(self.__deck.getIndex()) + '.ogg'
+ #turn on mic boost (xo)
+ print 'turn on mic boost'
+ subprocess.call("amixer cset numid=11 on", shell=True)
+ print 'record clip:', self.__audiofile
+ #self.__fileout.set_property("location", self.__audiofile)
+ #self.__source.set_property("location", "/tmp/temp.wav")
+ #self.__player.set_state(gst.STATE_PLAYING)
+ print 'recording started'
+ subprocess.call("arecord -f cd -d 10 /tmp/temp.wav", shell=True)
+
+ # Play Audio Clip
+ def play(self, params):
+ if self.__play:
+ #we are playing and need to stop
+ subprocess.call("killall -q gst-launch-0.10", shell=True)
+ self.__play = False
+ else:
+ #play clip
+ self.__deck.save()
+ clip = self.__deck.getSlideClip()
+ #clip = "/home/olpc/Activities/ShowNTell.activity/resources/test.ogg"
+ print 'play clip:', clip
+ if clip:
+ self.__play = True
+ subprocess.call("gst-launch-0.10 filesrc location=" + clip + " ! decodebin ! audioconvert ! alsasink", shell = True)
+ self.__play = False
+
+ # Create buttons for audio controls
+ def create_bbox(self, title=None, spacing=0, layout=gtk.BUTTONBOX_SPREAD):
+ frame = gtk.Frame(title)
+ bbox = gtk.HButtonBox()
+ bbox.set_border_width(5)
+ bbox.set_layout(layout)
+ bbox.set_spacing(spacing)
+
+ button = gtk.Button(stock='gtk-media-record')
+ button.connect("clicked", self.record)
+ bbox.pack_start(button, False, False, 0)
+
+ button = gtk.Button(stock='gtk-media-play')
+ button.connect("clicked", self.play)
+ bbox.pack_start(button, False, False, 0)
+
+ frame.add(bbox)
+ return frame
diff --git a/toolbars.py b/toolbars.py
new file mode 100755
index 0000000..b7c2323
--- /dev/null
+++ b/toolbars.py
@@ -0,0 +1,464 @@
+# toolbars.py
+#
+# Classes defining toolbars for Classroom Presenter
+# B. Mayton <bmayton@cs.washington.edu>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from sugar.activity import activity
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.menuitem import MenuItem
+from sugar.graphics.objectchooser import ObjectChooser
+from sugar.datastore import datastore
+
+import gtk
+import gobject
+import pango
+import logging
+import threading
+import os, sys
+import utils
+from path import path
+import slideshow
+import subprocess
+import listview
+
+#import htmlview
+#import hulahop
+from sugar import env
+#hulahop.startup(os.path.join(env.get_profile_path(), 'gecko'))
+
+#from hulahop.webview import WebView
+
+DATASTORE = '/home/olpc/.sugar/default/datastore/store'
+
+class NavToolBar(gtk.Toolbar):
+
+ def __init__(self, activity, shared, deck):
+ gtk.Toolbar.__init__(self)
+
+ self.__deck = deck
+ self.__activity = activity
+ self.__shared = shared
+ self.__logger = logging.getLogger('Navigation Toolbar')
+
+ self.__is_initiating = True
+
+ self.__prevbtn = ToolButton('go-previous')
+ self.__prevbtn.set_tooltip("Previous slide")
+ self.__prevbtn.connect('clicked', self.previous)
+ self.insert(self.__prevbtn, -1)
+ self.__prevbtn.show()
+
+ self.__nextbtn = ToolButton('go-next')
+ self.__nextbtn.set_tooltip("Next slide")
+ self.__nextbtn.connect('clicked', self.next)
+ self.insert(self.__nextbtn, -1)
+ self.__nextbtn.show()
+
+ # page number widget and navigation
+ self.__num_page_item = gtk.ToolItem()
+ self.__num_current_page = 1
+
+ self.__num_page_entry = gtk.Entry()
+ self.__num_page_entry.set_text(str(self.__num_current_page))
+ self.__num_page_entry.set_alignment(1)
+ self.__num_page_entry.connect('activate', self.num_page_activate)
+
+ self.__num_page_entry.set_width_chars(4)
+
+ self.__num_page_item.add(self.__num_page_entry)
+ self.__num_page_entry.show()
+
+ self.insert(self.__num_page_item, -1)
+ self.__num_page_item.show()
+
+
+ # total page number widget
+ self.__total_page_item = gtk.ToolItem()
+ self.__total_page_label = gtk.Label()
+
+ label_attributes = pango.AttrList()
+ label_attributes.insert(pango.AttrSize(14000, 0, -1))
+ label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1))
+ self.__total_page_label.set_attributes(label_attributes)
+
+ self.__total_page_label.set_text(' / ' + str(self.__deck.getSlideCount()))
+ self.__total_page_item.add(self.__total_page_label)
+ self.__total_page_label.show()
+
+ self.insert(self.__total_page_item, -1)
+ self.__total_page_item.show()
+
+ # separator between navigation buttons and lock button
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(False)
+ separator.set_expand(True)
+ self.insert(separator, -1)
+ separator.show()
+
+ # unlocked button
+ self.__unlockBtn = ToolButton('unlocked')
+ self.__unlockBtn.set_tooltip("Student Navigation Unlocked")
+
+ # navigation is unlocked by default, so insert the unlock button
+ self.insert(self.__unlockBtn, 5)
+ self.__unlockBtn.show()
+
+ # locked button
+ self.__lockBtn = ToolButton('locked')
+ self.__lockBtn.set_tooltip("Student Navigation Locked")
+
+ self.__logger.debug("Connecting to navigation locking and activity sharing signals.")
+ self.__activity.connect('shared', self.activity_shared_cb)
+ self.__activity.connect('joined', self.activity_joined_cb)
+ self.__shared.connect('navigation-lock-change', self.set_lock_button)
+
+ # triggers for when slides are changed
+ self.__deck.connect("slide-changed", self.slide_changed)
+ self.__deck.connect("deck-changed", self.slide_changed)
+ self.slide_changed(self.__deck)
+ self.show()
+
+ def activity_shared_cb(self, widget):
+ #Callback for when the activity is shared
+ # bind the lock button click with switching lock mode
+ self.__lockBtn.connect('clicked', self.__shared.lock_mode_switch)
+ self.__unlockBtn.connect('clicked', self.__shared.lock_mode_switch)
+
+ def activity_joined_cb(self, widget):
+ """ Callback for when the activity is joined """
+ self.__is_initiating = False
+
+ def set_lock_button(self, widget, is_locked):
+ self.__logger.debug("Changing lock button, lock mode %u, init %u",
+ is_locked, self.__is_initiating)
+ if is_locked:
+ new_button = self.__lockBtn
+ if not self.__is_initiating:
+ self.__prevbtn.set_sensitive(False)
+ self.__nextbtn.set_sensitive(False)
+ else:
+ new_button = self.__unlockBtn
+ if not self.__is_initiating:
+ self.__prevbtn.set_sensitive(True)
+ self.__nextbtn.set_sensitive(True)
+
+ old = self.get_nth_item(5)
+ self.remove(old)
+ self.insert(new_button, 5)
+ new_button.show()
+ self.queue_draw()
+
+ def next(self, widget):
+ self.__deck.next()
+
+ def previous(self, widget):
+ self.__deck.previous()
+
+ def slide_changed(self, widget):
+ self.__logger.debug("Changing slides!")
+ if self.__deck.isAtBeginning():
+ self.__prevbtn.set_sensitive(False)
+ else:
+ self.__prevbtn.set_sensitive(True)
+ if self.__deck.isAtEnd():
+ self.__nextbtn.set_sensitive(False)
+ else:
+ self.__nextbtn.set_sensitive(True)
+
+ self.__num_current_page = self.__deck.getIndex()
+ self.__num_page_entry.set_text(str(self.__num_current_page + 1))
+ self.__total_page_label.set_text(' / ' + str(self.__deck.getSlideCount()))
+
+ def num_page_activate(self, entry):
+ page_entered = int(entry.get_text())
+
+ if page_entered < 1:
+ page_entered = 1
+ elif self.__deck.getSlideCount() < page_entered:
+ page_entered = self.__deck.getSlideCount()
+
+ self.__deck.goToIndex(page_entered - 1, is_local=True)
+
+
+class InkToolBar(gtk.Toolbar):
+
+ # Constructor
+ def __init__(self, slideviewer, deck):
+
+ gtk.Toolbar.__init__(self)
+
+ self.__slideviewer = slideviewer
+ self.__cur_color = slideviewer.get_color()
+ self.__cur_color_str = "blue"
+ self.__cur_pen = slideviewer.get_pen()
+ self.__deck = deck
+ self.__deck.connect('slide-redraw', self.update_buttons)
+ self.__slideviewer.connect('undo-redo-changed', self.update_buttons)
+ self.__is_instr = False
+
+ # Red Ink
+ self.__red = gtk.RadioToolButton()
+ self.__red.set_icon_name('red-button')
+ self.insert(self.__red, -1)
+ self.__red.show()
+ #self.__red.set_tooltip('Red Ink')
+ self.__red.connect('clicked', self.set_ink_color, 1.0, 0.0, 0.0, "red")
+
+ # Green Ink
+ self.__green = gtk.RadioToolButton(group=self.__red)
+ self.__green.set_icon_name('green-button')
+ self.insert(self.__green, -1)
+ self.__green.show()
+ #self.__green.set_tooltip('Green Ink')
+ self.__green.connect('clicked', self.set_ink_color, 0.0, 1.0, 0.0, "green")
+
+ # Blue Ink
+ self.__blue = gtk.RadioToolButton(group=self.__red)
+ self.__blue.set_icon_name('blue-button')
+ self.insert(self.__blue, -1)
+ self.__blue.show()
+ #self.__blue.set_tooltip('Blue Ink')
+ self.__blue.connect('clicked', self.set_ink_color, 0.0, 0.0, 1.0, "blue")
+
+ # Black Ink
+ self.__black = gtk.RadioToolButton(group=self.__red)
+ self.__black.set_icon_name('black-button')
+ self.insert(self.__black, -1)
+ self.__black.show()
+ #self.__black.set_tooltip('Black Ink')
+ self.__black.connect('clicked', self.set_ink_color, 0.0, 0.0, 0.0, "black")
+
+ # Separate ink from untensils
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(False)
+ self.insert(separator, -1)
+ separator.show()
+
+ # Pencil
+ self.__pencil = gtk.RadioToolButton()
+ self.__pencil.set_icon_name('tool-pencil')
+ self.insert(self.__pencil, -1)
+ self.__pencil.show()
+ #self.__pencil.set_tooltip('Pencil')
+ self.__pencil.connect('clicked', self.set_cur_pen, 4)
+
+ # Brush
+ self.__brush = gtk.RadioToolButton(self.__pencil)
+ self.__brush.set_icon_name('tool-brush')
+ self.insert(self.__brush, -1)
+ self.__brush.show()
+ #self.__brush.set_tooltip('Brush')
+ self.__brush.connect('clicked', self.set_cur_pen, 8)
+
+ # Erase
+ self.__erase = ToolButton('tool-eraser')
+ self.insert(self.__erase, -1)
+ self.__erase.show()
+ self.__erase.set_tooltip('Erase All Ink')
+ self.__erase.connect('clicked', self.set_erase)
+
+ """
+ # Text
+ self.__text = ToolButton('text')
+ self.insert(self.__text, -1)
+ self.__text.show()
+ self.__text.set_tooltip('Text')
+ """
+
+ # Separate tools from text
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(False)
+ self.insert(separator, -1)
+ separator.show()
+
+ # Undo
+ self.__undo = ToolButton('edit-undo')
+ self.insert(self.__undo, -1)
+ self.__undo.show()
+ self.__undo.set_tooltip('Undo')
+ self.__undo.connect('clicked', self.undo)
+
+ # Redo
+ self.__redo = ToolButton('edit-redo')
+ self.insert(self.__redo, -1)
+ self.__redo.show()
+ self.__redo.set_tooltip('Redo')
+ self.__redo.connect('clicked', self.redo)
+
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(False)
+ separator.set_expand(True)
+ self.insert(separator, -1)
+ separator.show()
+
+ self.__submit = ToolButton('dialog-ok') #FIXME (though actually not a terrible icon)
+ self.insert(self.__submit, -1)
+ self.__submit.show()
+ self.__submit.set_tooltip('Broadcast Submission')
+ self.__submit.connect('clicked', self.submit_ink)
+
+ self.__deck.connect('instr_state_propagate', self.instructor_state_cb)
+
+ self.set_tool_buttons()
+ self.show()
+
+ def instructor_state_cb(self, widget, is_instr):
+ self.__is_instr = is_instr
+ if is_instr:
+ self.__submit.set_tooltip('Broadcast Submission')
+ else:
+ self.__submit.set_tooltip('Submit Ink')
+
+
+ def set_cur_pen(self, widget, size):
+ self.__slideviewer.set_pen(size)
+
+ def set_ink_color(self, widget, r, g, b, color):
+ self.__slideviewer.set_color(r, g, b)
+
+
+ def set_erase(self, widget):
+ self.__slideviewer.clear_ink()
+
+ def set_tool_buttons(self):
+ if self.__cur_color == (1.0, 0.0, 0.0):
+ self.__red.set_active(True)
+ elif self.__cur_color == (0.0, 1.0, 0.0):
+ self.__green.set_active(True)
+ elif self.__cur_color == (0.0, 0.0, 1.0):
+ self.__blue.set_active(True)
+ else:
+ self.__black.set_active(True)
+
+ if self.__cur_pen == 2:
+ self.__pencil.set_active(True)
+ elif self.__cur_pen == 5:
+ self.__brush.set_active(True)
+
+
+ def submit_ink(self, widget):
+ if self.__is_instr:
+ self.broadcast_ink()
+ else:
+ self.__submit.set_sensitive(False)
+ self.__timer = threading.Timer(3.0, self.reenable_submissions)
+ self.__timer.start()
+ self.__slideviewer.submit_ink()
+
+ def broadcast_ink(self):
+ self.__slideviewer.broadcast_ink()
+
+ def reenable_submissions(self):
+ self.__submit.set_sensitive(True)
+ self.__submit.queue_draw()
+
+ def undo(self, widget):
+ self.__slideviewer.undo()
+
+ def redo(self, widget):
+ self.__slideviewer.redo()
+
+ def update_buttons(self, widget=None):
+ can_undo, can_redo = self.__slideviewer.can_undo_redo()
+ self.__undo.set_sensitive(can_undo)
+ self.__redo.set_sensitive(can_redo)
+ if self.__is_instr:
+ if self.__deck.getActiveSubmission() == -1:
+ self.__submit.set_sensitive(False)
+ else:
+ self.__submit.set_sensitive(True)
+
+class MakeToolBar(gtk.Toolbar):
+
+ def __init__(self, activity, deck):
+ gtk.Toolbar.__init__(self)
+ self.activity = activity
+ self.deck = deck
+
+ #get mount points
+ ds_mounts = datastore.mounts()
+ pendrive = -1
+ for i in range(0, len(ds_mounts), 1):
+ print 'mount', i, ds_mounts[i]['uri']
+ if ds_mounts[i]['uri'].find('datastore') > 0:
+ journal = i
+ else:
+ pendrive = i
+
+
+ self.__newbtn = ToolButton('new-slideshow')
+ self.__newbtn.set_tooltip("New slideshow")
+ self.__newbtn.connect('clicked', self.new)
+ self.insert(self.__newbtn, -1)
+ self.__newbtn.show()
+
+ self.__openbtn = ToolButton('slideshow')
+ self.__openbtn.set_tooltip("Choose slideshow")
+ self.__openbtn.connect('clicked', self.open)
+ self.insert(self.__openbtn, -1)
+ self.__openbtn.show()
+
+ #self.__htmlbutton = ToolButton('new')
+ #self.__htmlbutton.set_tooltip("test tw")
+ #self.__htmlbutton.connect('clicked', self.showhtml)
+ #self.insert(self.__htmlbutton, -1)
+ #self.__htmlbutton.show()
+
+ self.__journalbtn = ToolButton('activity-journal')
+ self.__journalbtn.set_tooltip("Choose image")
+ self.__journalbtn.connect('clicked', self.chooseimage, ds_mounts[journal]['id'], DATASTORE)
+ self.insert(self.__journalbtn, -1)
+ self.__journalbtn.show()
+
+ #show pendrive button only if pendrive is mounted
+ if pendrive > -1:
+ self.__pendrivebutton = ToolButton('media-flash-usb')
+ self.__pendrivebutton.set_tooltip("Choose image")
+ self.__pendrivebutton.connect('clicked', self.chooseimage, ds_mounts[pendrive]['id'], ds_mounts[pendrive]['title'])
+ self.insert(self.__pendrivebutton, -1)
+ self.__pendrivebutton.show()
+
+ self.show()
+
+ def new(self, widget):
+ print 'New slideshow'
+ #no effect if slideshow is already 'new', e.g. when ShowNTell is opened
+ #directly not by read_file
+ #this needs to be changed to show slideshow with html title slide
+ self.activity.read_file(path(activity.get_bundle_path()) / 'resources' / 'new.cpxo')
+
+ def open(self, widget):
+ print 'Open slideshow'
+ #here we need a listview to show existing cpxo bundles (all sources)
+ #there should be a standard 'open' function for both read_file and open
+
+ def chooseimage(self, widget, source, pth):
+ scrn1, scrn2 = self.activity.get_window()
+ treeview = scrn2.get_treeView()
+ print 'set_store', source, pth
+ treeview.set_model(scrn2.set_store(source, pth))
+ scrn1.hide()
+ scrn2.show()
+
+ def showhtml(self, widget):
+ scrn1, scrn2, scrn3 = self.activity.get_window()
+ scrn1.hide()
+ scrn2.hide()
+ #we need to show blank editable tiddly or web page
+ scrn3.show()
+
+
diff --git a/tw/simple.html b/tw/simple.html
new file mode 100644
index 0000000..55bad01
--- /dev/null
+++ b/tw/simple.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+<title>Simple</title>
+</head>
+<body>
+<h1>Simple test html page</h1>
+</body>
diff --git a/tw/slides.html b/tw/slides.html
new file mode 100644
index 0000000..10f4bb7
--- /dev/null
+++ b/tw/slides.html
@@ -0,0 +1,9428 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<script id="versionArea" type="text/javascript">
+//<![CDATA[
+var version = {title: "TiddlyWiki", major: 2, minor: 5, revision: 0, date: new Date("Mar 9, 2009"), extensions: {}};
+//]]>
+</script>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<meta name="copyright" content="
+TiddlyWiki created by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
+
+Copyright (c) UnaMesa Association 2004-2009
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or other
+materials provided with the distribution.
+
+Neither the name of the UnaMesa Association nor the names of its contributors may be
+used to endorse or promote products derived from this software without specific
+prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+" />
+<script id="jsheadArea" type="text/javascript">
+//<![CDATA[
+/*
+ * jQuery JavaScript Library v1.3.2
+ * http://jquery.com/
+ *
+ * Copyright (c) 2009 John Resig
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
+ * Revision: 6246
+ */
+(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
+/*
+ * Sizzle CSS Selector Engine - v0.9.3
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML=' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();
+//]]>
+</script>
+<!--PRE-HEAD-START-->
+<!--{{{-->
+<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
+<!--}}}-->
+<!--PRE-HEAD-END-->
+<title>
+
+</title>
+<style id="styleArea" type="text/css">
+#saveTest {display:none;}
+#messageArea {display:none;}
+#copyright {display:none;}
+#storeArea {display:none;}
+#storeArea div {padding:0.5em; margin:1em 0em 0em 0em; border-color:#fff #666 #444 #ddd; border-style:solid; border-width:2px; overflow:auto;}
+#shadowArea {display:none;}
+#javascriptWarning {width:100%; text-align:center; font-weight:bold; background-color:#dd1100; color:#fff; padding:1em 0em;}
+</style>
+<!--POST-HEAD-START-->
+<!--POST-HEAD-END-->
+</head>
+<body onload="main();" onunload="if(window.checkUnsavedChanges) checkUnsavedChanges(); if(window.scrubNodes) scrubNodes(document.body);">
+<!--PRE-BODY-START-->
+<!--PRE-BODY-END-->
+<div id="copyright">
+Welcome to TiddlyWiki created by Jeremy Ruston, Copyright &copy; 2007 UnaMesa Association
+</div>
+<noscript>
+<div id="javascriptWarning">
+This page requires JavaScript to function properly.<br /><br />If you are using Microsoft Internet Explorer you may need to click on the yellow bar above and select 'Allow Blocked Content'. You must then click 'Yes' on the following security warning.
+</div>
+</noscript>
+<div id="saveTest"></div>
+<div id="backstageCloak"></div>
+<div id="backstageButton"></div>
+<div id="backstageArea"><div id="backstageToolbar"></div></div>
+<div id="backstage">
+ <div id="backstagePanel"></div>
+</div>
+<div id="contentWrapper"></div>
+<div id="contentStash"></div>
+<div id="shadowArea">
+<div title="MarkupPreHead">
+<pre>&lt;!--{{{--&gt;
+&lt;link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' /&gt;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="ColorPalette">
+<pre>Background: #fff
+Foreground: #000
+PrimaryPale: #8cf
+PrimaryLight: #18f
+PrimaryMid: #04b
+PrimaryDark: #014
+SecondaryPale: #ffc
+SecondaryLight: #fe8
+SecondaryMid: #db4
+SecondaryDark: #841
+TertiaryPale: #eee
+TertiaryLight: #ccc
+TertiaryMid: #999
+TertiaryDark: #666
+Error: #f88</pre>
+</div>
+<div title="StyleSheetColors">
+<pre>/*{{{*/
+body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
+
+a {color:[[ColorPalette::PrimaryMid]];}
+a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
+a img {border:0;}
+
+h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
+h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
+h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}
+
+.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
+.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
+.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}
+
+.header {background:[[ColorPalette::PrimaryMid]];}
+.headerShadow {color:[[ColorPalette::Foreground]];}
+.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
+.headerForeground {color:[[ColorPalette::Background]];}
+.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}
+
+.tabSelected{color:[[ColorPalette::PrimaryDark]];
+ background:[[ColorPalette::TertiaryPale]];
+ border-left:1px solid [[ColorPalette::TertiaryLight]];
+ border-top:1px solid [[ColorPalette::TertiaryLight]];
+ border-right:1px solid [[ColorPalette::TertiaryLight]];
+}
+.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
+.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
+.tabContents .button {border:0;}
+
+#sidebar {}
+#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
+#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
+#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
+#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
+#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}
+
+.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
+.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
+.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
+.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
+ border:1px solid [[ColorPalette::PrimaryMid]];}
+.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
+.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
+.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
+.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
+ border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
+.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
+.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
+ border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
+
+.wizard .notChanged {background:transparent;}
+.wizard .changedLocally {background:#80ff80;}
+.wizard .changedServer {background:#8080ff;}
+.wizard .changedBoth {background:#ff8080;}
+.wizard .notFound {background:#ffff80;}
+.wizard .putToServer {background:#ff80ff;}
+.wizard .gotFromServer {background:#80ffff;}
+
+#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
+#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}
+
+.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}
+
+.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
+.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
+.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
+.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
+.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
+.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
+.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
+.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
+
+.tiddler .defaultCommand {font-weight:bold;}
+
+.shadow .title {color:[[ColorPalette::TertiaryDark]];}
+
+.title {color:[[ColorPalette::SecondaryDark]];}
+.subtitle {color:[[ColorPalette::TertiaryDark]];}
+
+.toolbar {color:[[ColorPalette::PrimaryMid]];}
+.toolbar a {color:[[ColorPalette::TertiaryLight]];}
+.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
+.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}
+
+.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
+.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
+.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
+.tagging .button, .tagged .button {border:none;}
+
+.footer {color:[[ColorPalette::TertiaryLight]];}
+.selected .footer {color:[[ColorPalette::TertiaryMid]];}
+
+.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
+.sparktick {background:[[ColorPalette::PrimaryDark]];}
+
+.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
+.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
+.lowlight {background:[[ColorPalette::TertiaryLight]];}
+
+.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}
+
+.imageLink, #displayArea .imageLink {background:transparent;}
+
+.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}
+
+.viewer .listTitle {list-style-type:none; margin-left:-2em;}
+.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
+.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}
+
+.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
+.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
+.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}
+
+.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
+.viewer code {color:[[ColorPalette::SecondaryDark]];}
+.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}
+
+.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}
+
+.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
+.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
+.editorFooter {color:[[ColorPalette::TertiaryMid]];}
+
+#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
+#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
+#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
+#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
+#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
+#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
+#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
+.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
+.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
+#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
+/*}}}*/</pre>
+</div>
+<div title="StyleSheetLayout">
+<pre>/*{{{*/
+* html .tiddler {height:1%;}
+
+body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}
+
+h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
+h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
+h4,h5,h6 {margin-top:1em;}
+h1 {font-size:1.35em;}
+h2 {font-size:1.25em;}
+h3 {font-size:1.1em;}
+h4 {font-size:1em;}
+h5 {font-size:.9em;}
+
+hr {height:1px;}
+
+a {text-decoration:none;}
+
+dt {font-weight:bold;}
+
+ol {list-style-type:decimal;}
+ol ol {list-style-type:lower-alpha;}
+ol ol ol {list-style-type:lower-roman;}
+ol ol ol ol {list-style-type:decimal;}
+ol ol ol ol ol {list-style-type:lower-alpha;}
+ol ol ol ol ol ol {list-style-type:lower-roman;}
+ol ol ol ol ol ol ol {list-style-type:decimal;}
+
+.txtOptionInput {width:11em;}
+
+#contentWrapper .chkOptionInput {border:0;}
+
+.externalLink {text-decoration:underline;}
+
+.indent {margin-left:3em;}
+.outdent {margin-left:3em; text-indent:-3em;}
+code.escaped {white-space:nowrap;}
+
+.tiddlyLinkExisting {font-weight:bold;}
+.tiddlyLinkNonExisting {font-style:italic;}
+
+/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
+a.tiddlyLinkNonExisting.shadow {font-weight:bold;}
+
+#mainMenu .tiddlyLinkExisting,
+ #mainMenu .tiddlyLinkNonExisting,
+ #sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
+#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}
+
+.header {position:relative;}
+.header a:hover {background:transparent;}
+.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
+.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}
+
+.siteTitle {font-size:3em;}
+.siteSubtitle {font-size:1.2em;}
+
+#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}
+
+#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
+#sidebarOptions {padding-top:0.3em;}
+#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
+#sidebarOptions input {margin:0.4em 0.5em;}
+#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
+#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
+#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
+#sidebarTabs .tabContents {width:15em; overflow:hidden;}
+
+.wizard {padding:0.1em 1em 0em 2em;}
+.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
+.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
+.wizardStep {padding:1em 1em 1em 1em;}
+.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
+.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
+.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
+.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}
+
+#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
+.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
+#messageArea a {text-decoration:underline;}
+
+.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
+.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}
+
+.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
+.popup .popupMessage {padding:0.4em;}
+.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
+.popup li.disabled {padding:0.4em;}
+.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
+.listBreak {font-size:1px; line-height:1px;}
+.listBreak div {margin:2px 0;}
+
+.tabset {padding:1em 0em 0em 0.5em;}
+.tab {margin:0em 0em 0em 0.25em; padding:2px;}
+.tabContents {padding:0.5em;}
+.tabContents ul, .tabContents ol {margin:0; padding:0;}
+.txtMainTab .tabContents li {list-style:none;}
+.tabContents li.listLink { margin-left:.75em;}
+
+#contentWrapper {display:block;}
+#splashScreen {display:none;}
+
+#displayArea {margin:1em 17em 0em 14em;}
+
+.toolbar {text-align:right; font-size:.9em;}
+
+.tiddler {padding:1em 1em 0em 1em;}
+
+.missing .viewer,.missing .title {font-style:italic;}
+
+.title {font-size:1.6em; font-weight:bold;}
+
+.missing .subtitle {display:none;}
+.subtitle {font-size:1.1em;}
+
+.tiddler .button {padding:0.2em 0.4em;}
+
+.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
+.isTag .tagging {display:block;}
+.tagged {margin:0.5em; float:right;}
+.tagging, .tagged {font-size:0.9em; padding:0.25em;}
+.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
+.tagClear {clear:both;}
+
+.footer {font-size:.9em;}
+.footer li {display:inline;}
+
+.annotation {padding:0.5em; margin:0.5em;}
+
+* html .viewer pre {width:99%; padding:0 0 1em 0;}
+.viewer {line-height:1.4em; padding-top:0.5em;}
+.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
+.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
+.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}
+
+.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
+.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
+table.listView {font-size:0.85em; margin:0.8em 1.0em;}
+table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}
+
+.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
+.viewer code {font-size:1.2em; line-height:1.4em;}
+
+.editor {font-size:1.1em;}
+.editor input, .editor textarea {display:block; width:100%; font:inherit;}
+.editorFooter {padding:0.25em 0em; font-size:.9em;}
+.editorFooter .button {padding-top:0px; padding-bottom:0px;}
+
+.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}
+
+.sparkline {line-height:1em;}
+.sparktick {outline:0;}
+
+.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
+.zoomer div {padding:1em;}
+
+* html #backstage {width:99%;}
+* html #backstageArea {width:99%;}
+#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
+#backstageToolbar {position:relative;}
+#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
+#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
+#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
+#backstage {position:relative; width:100%; z-index:50;}
+#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
+.backstagePanelFooter {padding-top:0.2em; float:right;}
+.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
+#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}
+
+.whenBackstage {display:none;}
+.backstageVisible .whenBackstage {display:block;}
+/*}}}*/</pre>
+</div>
+<div title="StyleSheetLocale">
+<pre>/***
+StyleSheet for use when a translation requires any css style changes.
+This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
+***/
+/*{{{*/
+body {font-size:0.8em;}
+#sidebarOptions {font-size:1.05em;}
+#sidebarOptions a {font-style:normal;}
+#sidebarOptions .sliderPanel {font-size:0.95em;}
+.subtitle {font-size:0.8em;}
+.viewer table.listView {font-size:0.95em;}
+/*}}}*/</pre>
+</div>
+<div title="StyleSheetPrint">
+<pre>/*{{{*/
+@media print {
+#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
+#displayArea {margin: 1em 1em 0em 1em;}
+/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
+noscript {display:none;}
+}
+/*}}}*/</pre>
+</div>
+<div title="PageTemplate">
+<pre>&lt;!--{{{--&gt;
+&lt;div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'&gt;
+&lt;div class='headerShadow'&gt;
+&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
+&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
+&lt;/div&gt;
+&lt;div class='headerForeground'&gt;
+&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
+&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
+&lt;/div&gt;
+&lt;/div&gt;
+&lt;div id='mainMenu' refresh='content' tiddler='MainMenu'&gt;&lt;/div&gt;
+&lt;div id='sidebar'&gt;
+&lt;div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'&gt;&lt;/div&gt;
+&lt;div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div id='displayArea'&gt;
+&lt;div id='messageArea'&gt;&lt;/div&gt;
+&lt;div id='tiddlerDisplay'&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="ViewTemplate">
+<pre>&lt;!--{{{--&gt;
+&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'&gt;&lt;/div&gt;
+&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
+&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;
+&lt;div class='tagging' macro='tagging'&gt;&lt;/div&gt;
+&lt;div class='tagged' macro='tags'&gt;&lt;/div&gt;
+&lt;div class='viewer' macro='view text wikified'&gt;&lt;/div&gt;
+&lt;div class='tagClear'&gt;&lt;/div&gt;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="EditTemplate">
+<pre>&lt;!--{{{--&gt;
+&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'&gt;&lt;/div&gt;
+&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
+&lt;div class='editor' macro='edit title'&gt;&lt;/div&gt;
+&lt;div macro='annotations'&gt;&lt;/div&gt;
+&lt;div class='editor' macro='edit text'&gt;&lt;/div&gt;
+&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;
+&lt;!--}}}--&gt;</pre>
+</div>
+<div title="GettingStarted">
+<pre>To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
+* SiteTitle &amp; SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
+* MainMenu: The menu (usually on the left)
+* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
+You'll also need to enter your username for signing your edits: &lt;&lt;option txtUserName&gt;&gt;</pre>
+</div>
+<div title="OptionsPanel">
+<pre>These InterfaceOptions for customising TiddlyWiki are saved in your browser
+
+Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)
+
+&lt;&lt;option txtUserName&gt;&gt;
+&lt;&lt;option chkSaveBackups&gt;&gt; SaveBackups
+&lt;&lt;option chkAutoSave&gt;&gt; AutoSave
+&lt;&lt;option chkRegExpSearch&gt;&gt; RegExpSearch
+&lt;&lt;option chkCaseSensitiveSearch&gt;&gt; CaseSensitiveSearch
+&lt;&lt;option chkAnimate&gt;&gt; EnableAnimations
+
+----
+Also see [[AdvancedOptions]]</pre>
+</div>
+<div title="ImportTiddlers">
+<pre>&lt;&lt;importTiddlers&gt;&gt;</pre>
+</div>
+</div>
+<!--POST-SHADOWAREA-->
+<div id="storeArea">
+</div>
+<!--POST-STOREAREA-->
+<!--POST-BODY-START-->
+<!--POST-BODY-END-->
+<script id="jsArea" type="text/javascript">
+//<![CDATA[
+//
+// Please note:
+//
+// * This code is designed to be readable but for compactness it only includes brief comments. You can see fuller comments
+// in the project Subversion repository at http://svn.tiddlywiki.org/Trunk/core/
+//
+// * You should never need to modify this source code directly. TiddlyWiki is carefully designed to allow deep customisation
+// without changing the core code. Please consult the development group at http://groups.google.com/group/TiddlyWikiDev
+//
+
+//--
+//-- Configuration repository
+//--
+
+// Miscellaneous options
+var config = {
+ numRssItems: 20, // Number of items in the RSS feed
+ animDuration: 400, // Duration of UI animations in milliseconds
+ cascadeFast: 20, // Speed for cascade animations (higher == slower)
+ cascadeSlow: 60, // Speed for EasterEgg cascade animations
+ cascadeDepth: 5, // Depth of cascade animation
+ locale: "en" // W3C language tag
+};
+
+// Hashmap of alternative parsers for the wikifier
+config.parsers = {};
+
+// Adaptors
+config.adaptors = {};
+config.defaultAdaptor = null;
+
+// Backstage tasks
+config.tasks = {};
+
+// Annotations
+config.annotations = {};
+
+// Custom fields to be automatically added to new tiddlers
+config.defaultCustomFields = {};
+
+// Messages
+config.messages = {
+ messageClose: {},
+ dates: {},
+ tiddlerPopup: {}
+};
+
+// Options that can be set in the options panel and/or cookies
+config.options = {
+ chkRegExpSearch: false,
+ chkCaseSensitiveSearch: false,
+ chkIncrementalSearch: true,
+ chkAnimate: true,
+ chkSaveBackups: true,
+ chkAutoSave: false,
+ chkGenerateAnRssFeed: false,
+ chkSaveEmptyTemplate: false,
+ chkOpenInNewWindow: true,
+ chkToggleLinks: false,
+ chkHttpReadOnly: true,
+ chkForceMinorUpdate: false,
+ chkConfirmDelete: true,
+ chkInsertTabs: false,
+ chkUsePreForStorage: true, // Whether to use <pre> format for storage
+ chkDisplayInstrumentation: false,
+ txtBackupFolder: "",
+ txtEditorFocus: "text",
+ txtMainTab: "tabTimeline",
+ txtMoreTab: "moreTabAll",
+ txtMaxEditRows: "30",
+ txtFileSystemCharSet: "UTF-8",
+ txtTheme: ""
+ };
+config.optionsDesc = {};
+
+// Default tiddler templates
+var DEFAULT_VIEW_TEMPLATE = 1;
+var DEFAULT_EDIT_TEMPLATE = 2;
+config.tiddlerTemplates = {
+ 1: "ViewTemplate",
+ 2: "EditTemplate"
+};
+
+// More messages (rather a legacy layout that should not really be like this)
+config.views = {
+ wikified: {
+ tag: {}
+ },
+ editor: {
+ tagChooser: {}
+ }
+};
+
+// Backstage tasks
+config.backstageTasks = ["save","sync","importTask","tweak","upgrade","plugins"];
+
+// Extensions
+config.extensions = {};
+
+// Macros; each has a 'handler' member that is inserted later
+config.macros = {
+ today: {},
+ version: {},
+ search: {sizeTextbox: 15},
+ tiddler: {},
+ tag: {},
+ tags: {},
+ tagging: {},
+ timeline: {},
+ allTags: {},
+ list: {
+ all: {},
+ missing: {},
+ orphans: {},
+ shadowed: {},
+ touched: {},
+ filter: {}
+ },
+ closeAll: {},
+ permaview: {},
+ saveChanges: {},
+ slider: {},
+ option: {},
+ options: {},
+ newTiddler: {},
+ newJournal: {},
+ tabs: {},
+ gradient: {},
+ message: {},
+ view: {defaultView: "text"},
+ edit: {},
+ tagChooser: {},
+ toolbar: {},
+ plugins: {},
+ refreshDisplay: {},
+ importTiddlers: {},
+ upgrade: {
+ source: "http://www.tiddlywiki.com/upgrade/",
+ backupExtension: "pre.core.upgrade"
+ },
+ sync: {},
+ annotations: {}
+};
+
+// Commands supported by the toolbar macro
+config.commands = {
+ closeTiddler: {},
+ closeOthers: {},
+ editTiddler: {},
+ saveTiddler: {hideReadOnly: true},
+ cancelTiddler: {},
+ deleteTiddler: {hideReadOnly: true},
+ permalink: {},
+ references: {type: "popup"},
+ jump: {type: "popup"},
+ syncing: {type: "popup"},
+ fields: {type: "popup"}
+};
+
+// Browser detection... In a very few places, there's nothing else for it but to know what browser we're using.
+config.userAgent = navigator.userAgent.toLowerCase();
+config.browser = {
+ isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1,
+ isGecko: config.userAgent.indexOf("gecko") != -1,
+ ieVersion: /MSIE (\d.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0"
+ isSafari: config.userAgent.indexOf("applewebkit") != -1,
+ isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")),
+ firefoxDate: /gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD"
+ isOpera: config.userAgent.indexOf("opera") != -1,
+ isLinux: config.userAgent.indexOf("linux") != -1,
+ isUnix: config.userAgent.indexOf("x11") != -1,
+ isMac: config.userAgent.indexOf("mac") != -1,
+ isWindows: config.userAgent.indexOf("win") != -1
+};
+
+// Basic regular expressions
+config.textPrimitives = {
+ upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]",
+ lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]",
+ anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]",
+ anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]"
+};
+if(config.browser.isBadSafari) {
+ config.textPrimitives = {
+ upperLetter: "[A-Z\u00c0-\u00de]",
+ lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]",
+ anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]",
+ anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]"
+ };
+}
+config.textPrimitives.sliceSeparator = "::";
+config.textPrimitives.sectionSeparator = "##";
+config.textPrimitives.urlPattern = "(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
+config.textPrimitives.unWikiLink = "~";
+config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" +
+ config.textPrimitives.lowerLetter + "+" +
+ config.textPrimitives.upperLetter +
+ config.textPrimitives.anyLetter + "*)|(?:" +
+ config.textPrimitives.upperLetter + "{2,}" +
+ config.textPrimitives.lowerLetter + "+))";
+
+config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)";
+config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg");
+
+config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]";
+config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
+config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" +
+ config.textPrimitives.brackettedLink + ")|(?:" +
+ config.textPrimitives.urlPattern + ")","mg");
+config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" +
+ config.textPrimitives.titledBrackettedLink + ")|(?:" +
+ config.textPrimitives.brackettedLink + ")|(?:" +
+ config.textPrimitives.urlPattern + ")","mg");
+
+config.glyphs = {
+ browsers: [
+ function() {return config.browser.isIE;},
+ function() {return true;}
+ ],
+ currBrowser: null,
+ codes: {
+ downTriangle: ["\u25BC","\u25BE"],
+ downArrow: ["\u2193","\u2193"],
+ bentArrowLeft: ["\u2190","\u21A9"],
+ bentArrowRight: ["\u2192","\u21AA"]
+ }
+};
+
+//--
+//-- Shadow tiddlers
+//--
+
+config.shadowTiddlers = {
+ StyleSheet: "",
+ MarkupPreHead: "",
+ MarkupPostHead: "",
+ MarkupPreBody: "",
+ MarkupPostBody: "",
+ TabTimeline: '<<timeline>>',
+ TabAll: '<<list all>>',
+ TabTags: '<<allTags excludeLists>>',
+ TabMoreMissing: '<<list missing>>',
+ TabMoreOrphans: '<<list orphans>>',
+ TabMoreShadowed: '<<list shadowed>>',
+ AdvancedOptions: '<<options>>',
+ PluginManager: '<<plugins>>',
+ ToolbarCommands: '|~ViewToolbar|closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|\n|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|'
+};
+
+//--
+//-- Translateable strings
+//--
+
+// Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone
+
+merge(config.options,{
+ txtUserName: "YourName"});
+
+merge(config.tasks,{
+ save: {text: "save", tooltip: "Save your changes to this TiddlyWiki", action: saveChanges},
+ sync: {text: "sync", tooltip: "Synchronise changes with other TiddlyWiki files and servers", content: '<<sync>>'},
+ importTask: {text: "import", tooltip: "Import tiddlers and plugins from other TiddlyWiki files and servers", content: '<<importTiddlers>>'},
+ tweak: {text: "tweak", tooltip: "Tweak the appearance and behaviour of TiddlyWiki", content: '<<options>>'},
+ upgrade: {text: "upgrade", tooltip: "Upgrade TiddlyWiki core code", content: '<<upgrade>>'},
+ plugins: {text: "plugins", tooltip: "Manage installed plugins", content: '<<plugins>>'}
+});
+
+// Options that can be set in the options panel and/or cookies
+merge(config.optionsDesc,{
+ txtUserName: "Username for signing your edits",
+ chkRegExpSearch: "Enable regular expressions for searches",
+ chkCaseSensitiveSearch: "Case-sensitive searching",
+ chkIncrementalSearch: "Incremental key-by-key searching",
+ chkAnimate: "Enable animations",
+ chkSaveBackups: "Keep backup file when saving changes",
+ chkAutoSave: "Automatically save changes",
+ chkGenerateAnRssFeed: "Generate an RSS feed when saving changes",
+ chkSaveEmptyTemplate: "Generate an empty template when saving changes",
+ chkOpenInNewWindow: "Open external links in a new window",
+ chkToggleLinks: "Clicking on links to open tiddlers causes them to close",
+ chkHttpReadOnly: "Hide editing features when viewed over HTTP",
+ chkForceMinorUpdate: "Don't update modifier username and date when editing tiddlers",
+ chkConfirmDelete: "Require confirmation before deleting tiddlers",
+ chkInsertTabs: "Use the tab key to insert tab characters instead of moving between fields",
+ txtBackupFolder: "Name of folder to use for backups",
+ txtMaxEditRows: "Maximum number of rows in edit boxes",
+ txtFileSystemCharSet: "Default character set for saving changes (Firefox/Mozilla only)"});
+
+merge(config.messages,{
+ customConfigError: "Problems were encountered loading plugins. See PluginManager for details",
+ pluginError: "Error: %0",
+ pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag",
+ pluginForced: "Executed because forced via 'systemConfigForce' tag",
+ pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki",
+ nothingSelected: "Nothing is selected. You must select one or more items first",
+ savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#Download for details",
+ subtitleUnknown: "(unknown)",
+ undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
+ shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value",
+ tiddlerLinkTooltip: "%0 - %1, %2",
+ externalLinkTooltip: "External link to %0",
+ noTags: "There are no tagged tiddlers",
+ notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
+ cantSaveError: "It's not possible to save changes. Possible reasons include:\n- your browser doesn't support saving (Firefox, Internet Explorer, Safari and Opera all work if properly configured)\n- the pathname to your TiddlyWiki file contains illegal characters\n- the TiddlyWiki HTML file has been moved or renamed",
+ invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
+ backupSaved: "Backup saved",
+ backupFailed: "Failed to save backup file",
+ rssSaved: "RSS feed saved",
+ rssFailed: "Failed to save RSS feed file",
+ emptySaved: "Empty template saved",
+ emptyFailed: "Failed to save empty template file",
+ mainSaved: "Main TiddlyWiki file saved",
+ mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
+ macroError: "Error in macro <<\%0>>",
+ macroErrorDetails: "Error while executing macro <<\%0>>:\n%1",
+ missingMacro: "No such macro",
+ overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
+ unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
+ confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------",
+ saveInstructions: "SaveChanges",
+ unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'",
+ tiddlerSaveError: "Error when saving tiddler '%0'",
+ tiddlerLoadError: "Error when loading tiddler '%0'",
+ wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.",
+ invalidFieldName: "Invalid field name %0",
+ fieldCannotBeChanged: "Field '%0' cannot be changed",
+ loadingMissingTiddler: "Attempting to retrieve the tiddler '%0' from the '%1' server at:\n\n'%2' in the workspace '%3'",
+ upgradeDone: "The upgrade to version %0 is now complete\n\nClick 'OK' to reload the newly upgraded TiddlyWiki"});
+
+merge(config.messages.messageClose,{
+ text: "close",
+ tooltip: "close this message area"});
+
+config.messages.backstage = {
+ open: {text: "backstage", tooltip: "Open the backstage area to perform authoring and editing tasks"},
+ close: {text: "close", tooltip: "Close the backstage area"},
+ prompt: "backstage: ",
+ decal: {
+ edit: {text: "edit", tooltip: "Edit the tiddler '%0'"}
+ }
+};
+
+config.messages.listView = {
+ tiddlerTooltip: "Click for the full text of this tiddler",
+ previewUnavailable: "(preview not available)"
+};
+
+config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
+config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
+config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+// suffixes for dates, eg "1st","2nd","3rd"..."30th","31st"
+config.messages.dates.daySuffixes = ["st","nd","rd","th","th","th","th","th","th","th",
+ "th","th","th","th","th","th","th","th","th","th",
+ "st","nd","rd","th","th","th","th","th","th","th",
+ "st"];
+config.messages.dates.am = "am";
+config.messages.dates.pm = "pm";
+
+merge(config.messages.tiddlerPopup,{
+ });
+
+merge(config.views.wikified.tag,{
+ labelNoTags: "no tags",
+ labelTags: "tags: ",
+ openTag: "Open tag '%0'",
+ tooltip: "Show tiddlers tagged with '%0'",
+ openAllText: "Open all",
+ openAllTooltip: "Open all of these tiddlers",
+ popupNone: "No other tiddlers tagged with '%0'"});
+
+merge(config.views.wikified,{
+ defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it",
+ defaultModifier: "(missing)",
+ shadowModifier: "(built-in shadow tiddler)",
+ dateFormat: "DD MMM YYYY",
+ createdPrompt: "created"});
+
+merge(config.views.editor,{
+ tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
+ defaultText: "Type the text for '%0'"});
+
+merge(config.views.editor.tagChooser,{
+ text: "tags",
+ tooltip: "Choose existing tags to add to this tiddler",
+ popupNone: "There are no tags defined",
+ tagTooltip: "Add the tag '%0'"});
+
+merge(config.messages,{
+ sizeTemplates:
+ [
+ {unit: 1024*1024*1024, template: "%0\u00a0GB"},
+ {unit: 1024*1024, template: "%0\u00a0MB"},
+ {unit: 1024, template: "%0\u00a0KB"},
+ {unit: 1, template: "%0\u00a0B"}
+ ]});
+
+merge(config.macros.search,{
+ label: "search",
+ prompt: "Search this TiddlyWiki",
+ accessKey: "F",
+ successMsg: "%0 tiddlers found matching %1",
+ failureMsg: "No tiddlers found matching %0"});
+
+merge(config.macros.tagging,{
+ label: "tagging: ",
+ labelNotTag: "not tagging",
+ tooltip: "List of tiddlers tagged with '%0'"});
+
+merge(config.macros.timeline,{
+ dateFormat: "DD MMM YYYY"});
+
+merge(config.macros.allTags,{
+ tooltip: "Show tiddlers tagged with '%0'",
+ noTags: "There are no tagged tiddlers"});
+
+config.macros.list.all.prompt = "All tiddlers in alphabetical order";
+config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined";
+config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers";
+config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents";
+config.macros.list.touched.prompt = "Tiddlers that have been modified locally";
+
+merge(config.macros.closeAll,{
+ label: "close all",
+ prompt: "Close all displayed tiddlers (except any that are being edited)"});
+
+merge(config.macros.permaview,{
+ label: "permaview",
+ prompt: "Link to an URL that retrieves all the currently displayed tiddlers"});
+
+merge(config.macros.saveChanges,{
+ label: "save changes",
+ prompt: "Save all tiddlers to create a new TiddlyWiki",
+ accessKey: "S"});
+
+merge(config.macros.newTiddler,{
+ label: "new tiddler",
+ prompt: "Create a new tiddler",
+ title: "New Tiddler",
+ accessKey: "N"});
+
+merge(config.macros.newJournal,{
+ label: "new journal",
+ prompt: "Create a new tiddler from the current date and time",
+ accessKey: "J"});
+
+merge(config.macros.options,{
+ wizardTitle: "Tweak advanced options",
+ step1Title: "These options are saved in cookies in your browser",
+ step1Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='false' name='chkUnknown'>Show unknown options</input>",
+ unknownDescription: "//(unknown)//",
+ listViewTemplate: {
+ columns: [
+ {name: 'Option', field: 'option', title: "Option", type: 'String'},
+ {name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
+ {name: 'Name', field: 'name', title: "Name", type: 'String'}
+ ],
+ rowClasses: [
+ {className: 'lowlight', field: 'lowlight'}
+ ]}
+ });
+
+merge(config.macros.plugins,{
+ wizardTitle: "Manage plugins",
+ step1Title: "Currently loaded plugins",
+ step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
+ skippedText: "(This plugin has not been executed because it was added since startup)",
+ noPluginText: "There are no plugins installed",
+ confirmDeleteText: "Are you sure you want to delete these plugins:\n\n%0",
+ removeLabel: "remove systemConfig tag",
+ removePrompt: "Remove systemConfig tag",
+ deleteLabel: "delete",
+ deletePrompt: "Delete these tiddlers forever",
+ listViewTemplate: {
+ columns: [
+ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
+ {name: 'Description', field: 'desc', title: "Description", type: 'String'},
+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
+ {name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'},
+ {name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'},
+ {name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
+ {name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'},
+ {name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
+ {name: 'Log', field: 'log', title: "Log", type: 'StringList'}
+ ],
+ rowClasses: [
+ {className: 'error', field: 'error'},
+ {className: 'warning', field: 'warning'}
+ ]}
+ });
+
+merge(config.macros.toolbar,{
+ moreLabel: "more",
+ morePrompt: "Reveal further commands"
+ });
+
+merge(config.macros.refreshDisplay,{
+ label: "refresh",
+ prompt: "Redraw the entire TiddlyWiki display"
+ });
+
+merge(config.macros.importTiddlers,{
+ readOnlyWarning: "You cannot import into a read-only TiddlyWiki file. Try opening it from a file:// URL",
+ wizardTitle: "Import tiddlers from another file or server",
+ step1Title: "Step 1: Locate the server or TiddlyWiki file",
+ step1Html: "Specify the type of the server: <select name='selTypes'><option value=''>Choose...</option></select><br>Enter the URL or pathname here: <input type='text' size=50 name='txtPath'><br>...or browse for a file: <input type='file' size=50 name='txtBrowse'><br><hr>...or select a pre-defined feed: <select name='selFeeds'><option value=''>Choose...</option></select>",
+ openLabel: "open",
+ openPrompt: "Open the connection to this file or server",
+ openError: "There were problems fetching the tiddlywiki file",
+ statusOpenHost: "Opening the host",
+ statusGetWorkspaceList: "Getting the list of available workspaces",
+ step2Title: "Step 2: Choose the workspace",
+ step2Html: "Enter a workspace name: <input type='text' size=50 name='txtWorkspace'><br>...or select a workspace: <select name='selWorkspace'><option value=''>Choose...</option></select>",
+ cancelLabel: "cancel",
+ cancelPrompt: "Cancel this import",
+ statusOpenWorkspace: "Opening the workspace",
+ statusGetTiddlerList: "Getting the list of available tiddlers",
+ errorGettingTiddlerList: "Error getting list of tiddlers, click Cancel to try again",
+ step3Title: "Step 3: Choose the tiddlers to import",
+ step3Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='true' name='chkSync'>Keep these tiddlers linked to this server so that you can synchronise subsequent changes</input><br><input type='checkbox' name='chkSave'>Save the details of this server in a 'systemServer' tiddler called:</input> <input type='text' size=25 name='txtSaveTiddler'>",
+ importLabel: "import",
+ importPrompt: "Import these tiddlers",
+ confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0",
+ step4Title: "Step 4: Importing %0 tiddler(s)",
+ step4Html: "<input type='hidden' name='markReport'></input>", // DO NOT TRANSLATE
+ doneLabel: "done",
+ donePrompt: "Close this wizard",
+ statusDoingImport: "Importing tiddlers",
+ statusDoneImport: "All tiddlers imported",
+ systemServerNamePattern: "%2 on %1",
+ systemServerNamePatternNoWorkspace: "%1",
+ confirmOverwriteSaveTiddler: "The tiddler '%0' already exists. Click 'OK' to overwrite it with the details of this server, or 'Cancel' to leave it unchanged",
+ serverSaveTemplate: "|''Type:''|%0|\n|''URL:''|%1|\n|''Workspace:''|%2|\n\nThis tiddler was automatically created to record the details of this server",
+ serverSaveModifier: "(System)",
+ listViewTemplate: {
+ columns: [
+ {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
+ {name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
+ {name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
+ ],
+ rowClasses: [
+ ]}
+ });
+
+merge(config.macros.upgrade,{
+ wizardTitle: "Upgrade TiddlyWiki core code",
+ step1Title: "Update or repair this TiddlyWiki to the latest release",
+ step1Html: "You are about to upgrade to the latest release of the TiddlyWiki core code (from <a href='%0' class='externalLink' target='_blank'>%1</a>). Your content will be preserved across the upgrade.<br><br>Note that core upgrades have been known to interfere with older plugins. If you run into problems with the upgraded file, see <a href='http://www.tiddlywiki.org/wiki/CoreUpgrades' class='externalLink' target='_blank'>http://www.tiddlywiki.org/wiki/CoreUpgrades</a>",
+ errorCantUpgrade: "Unable to upgrade this TiddlyWiki. You can only perform upgrades on TiddlyWiki files stored locally",
+ errorNotSaved: "You must save changes before you can perform an upgrade",
+ step2Title: "Confirm the upgrade details",
+ step2Html_downgrade: "You are about to downgrade to TiddlyWiki version %0 from %1.<br><br>Downgrading to an earlier version of the core code is not recommended",
+ step2Html_restore: "This TiddlyWiki appears to be already using the latest version of the core code (%0).<br><br>You can continue to upgrade anyway to ensure that the core code hasn't been corrupted or damaged",
+ step2Html_upgrade: "You are about to upgrade to TiddlyWiki version %0 from %1",
+ upgradeLabel: "upgrade",
+ upgradePrompt: "Prepare for the upgrade process",
+ statusPreparingBackup: "Preparing backup",
+ statusSavingBackup: "Saving backup file",
+ errorSavingBackup: "There was a problem saving the backup file",
+ statusLoadingCore: "Loading core code",
+ errorLoadingCore: "Error loading the core code",
+ errorCoreFormat: "Error with the new core code",
+ statusSavingCore: "Saving the new core code",
+ statusReloadingCore: "Reloading the new core code",
+ startLabel: "start",
+ startPrompt: "Start the upgrade process",
+ cancelLabel: "cancel",
+ cancelPrompt: "Cancel the upgrade process",
+ step3Title: "Upgrade cancelled",
+ step3Html: "You have cancelled the upgrade process"
+ });
+
+merge(config.macros.sync,{
+ listViewTemplate: {
+ columns: [
+ {name: 'Selected', field: 'selected', rowName: 'title', type: 'Selector'},
+ {name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
+ {name: 'Server Type', field: 'serverType', title: "Server type", type: 'String'},
+ {name: 'Server Host', field: 'serverHost', title: "Server host", type: 'String'},
+ {name: 'Server Workspace', field: 'serverWorkspace', title: "Server workspace", type: 'String'},
+ {name: 'Status', field: 'status', title: "Synchronisation status", type: 'String'},
+ {name: 'Server URL', field: 'serverUrl', title: "Server URL", text: "View", type: 'Link'}
+ ],
+ rowClasses: [
+ ],
+ buttons: [
+ {caption: "Sync these tiddlers", name: 'sync'}
+ ]},
+ wizardTitle: "Synchronize with external servers and files",
+ step1Title: "Choose the tiddlers you want to synchronize",
+ step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
+ syncLabel: "sync",
+ syncPrompt: "Sync these tiddlers",
+ hasChanged: "Changed while unplugged",
+ hasNotChanged: "Unchanged while unplugged",
+ syncStatusList: {
+ none: {text: "...", display:null, className:'notChanged'},
+ changedServer: {text: "Changed on server", display:null, className:'changedServer'},
+ changedLocally: {text: "Changed while unplugged", display:null, className:'changedLocally'},
+ changedBoth: {text: "Changed while unplugged and on server", display:null, className:'changedBoth'},
+ notFound: {text: "Not found on server", display:null, className:'notFound'},
+ putToServer: {text: "Saved update on server", display:null, className:'putToServer'},
+ gotFromServer: {text: "Retrieved update from server", display:null, className:'gotFromServer'}
+ }
+ });
+
+merge(config.macros.annotations,{
+ });
+
+merge(config.commands.closeTiddler,{
+ text: "close",
+ tooltip: "Close this tiddler"});
+
+merge(config.commands.closeOthers,{
+ text: "close others",
+ tooltip: "Close all other tiddlers"});
+
+merge(config.commands.editTiddler,{
+ text: "edit",
+ tooltip: "Edit this tiddler",
+ readOnlyText: "view",
+ readOnlyTooltip: "View the source of this tiddler"});
+
+merge(config.commands.saveTiddler,{
+ text: "done",
+ tooltip: "Save changes to this tiddler"});
+
+merge(config.commands.cancelTiddler,{
+ text: "cancel",
+ tooltip: "Undo changes to this tiddler",
+ warning: "Are you sure you want to abandon your changes to '%0'?",
+ readOnlyText: "done",
+ readOnlyTooltip: "View this tiddler normally"});
+
+merge(config.commands.deleteTiddler,{
+ text: "delete",
+ tooltip: "Delete this tiddler",
+ warning: "Are you sure you want to delete '%0'?"});
+
+merge(config.commands.permalink,{
+ text: "permalink",
+ tooltip: "Permalink for this tiddler"});
+
+merge(config.commands.references,{
+ text: "references",
+ tooltip: "Show tiddlers that link to this one",
+ popupNone: "No references"});
+
+merge(config.commands.jump,{
+ text: "jump",
+ tooltip: "Jump to another open tiddler"});
+
+merge(config.commands.syncing,{
+ text: "syncing",
+ tooltip: "Control synchronisation of this tiddler with a server or external file",
+ currentlySyncing: "<div>Currently syncing via <span class='popupHighlight'>'%0'</span> to:</"+"div><div>host: <span class='popupHighlight'>%1</span></"+"div><div>workspace: <span class='popupHighlight'>%2</span></"+"div>", // Note escaping of closing <div> tag
+ notCurrentlySyncing: "Not currently syncing",
+ captionUnSync: "Stop synchronising this tiddler",
+ chooseServer: "Synchronise this tiddler with another server:",
+ currServerMarker: "\u25cf ",
+ notCurrServerMarker: " "});
+
+merge(config.commands.fields,{
+ text: "fields",
+ tooltip: "Show the extended fields of this tiddler",
+ emptyText: "There are no extended fields for this tiddler",
+ listViewTemplate: {
+ columns: [
+ {name: 'Field', field: 'field', title: "Field", type: 'String'},
+ {name: 'Value', field: 'value', title: "Value", type: 'String'}
+ ],
+ rowClasses: [
+ ],
+ buttons: [
+ ]}});
+
+merge(config.shadowTiddlers,{
+ DefaultTiddlers: "[[GettingStarted]]",
+ MainMenu: "[[GettingStarted]]",
+ SiteTitle: "My TiddlyWiki",
+ SiteSubtitle: "a reusable non-linear personal web notebook",
+ SiteUrl: "http://www.tiddlywiki.com/",
+ SideBarOptions: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options \u00bb" "Change TiddlyWiki advanced options">>',
+ SideBarTabs: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>',
+ TabMore: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>'
+ });
+
+merge(config.annotations,{
+ AdvancedOptions: "This shadow tiddler provides access to several advanced options",
+ ColorPalette: "These values in this shadow tiddler determine the colour scheme of the ~TiddlyWiki user interface",
+ DefaultTiddlers: "The tiddlers listed in this shadow tiddler will be automatically displayed when ~TiddlyWiki starts up",
+ EditTemplate: "The HTML template in this shadow tiddler determines how tiddlers look while they are being edited",
+ GettingStarted: "This shadow tiddler provides basic usage instructions",
+ ImportTiddlers: "This shadow tiddler provides access to importing tiddlers",
+ MainMenu: "This shadow tiddler is used as the contents of the main menu in the left-hand column of the screen",
+ MarkupPreHead: "This tiddler is inserted at the top of the <head> section of the TiddlyWiki HTML file",
+ MarkupPostHead: "This tiddler is inserted at the bottom of the <head> section of the TiddlyWiki HTML file",
+ MarkupPreBody: "This tiddler is inserted at the top of the <body> section of the TiddlyWiki HTML file",
+ MarkupPostBody: "This tiddler is inserted at the end of the <body> section of the TiddlyWiki HTML file immediately after the script block",
+ OptionsPanel: "This shadow tiddler is used as the contents of the options panel slider in the right-hand sidebar",
+ PageTemplate: "The HTML template in this shadow tiddler determines the overall ~TiddlyWiki layout",
+ PluginManager: "This shadow tiddler provides access to the plugin manager",
+ SideBarOptions: "This shadow tiddler is used as the contents of the option panel in the right-hand sidebar",
+ SideBarTabs: "This shadow tiddler is used as the contents of the tabs panel in the right-hand sidebar",
+ SiteSubtitle: "This shadow tiddler is used as the second part of the page title",
+ SiteTitle: "This shadow tiddler is used as the first part of the page title",
+ SiteUrl: "This shadow tiddler should be set to the full target URL for publication",
+ StyleSheetColors: "This shadow tiddler contains CSS definitions related to the color of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler",
+ StyleSheet: "This tiddler can contain custom CSS definitions",
+ StyleSheetLayout: "This shadow tiddler contains CSS definitions related to the layout of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler",
+ StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale",
+ StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing",
+ TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar",
+ TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar",
+ TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar",
+ TabMoreOrphans: "This shadow tiddler contains the contents of the 'Orphans' tab in the right-hand sidebar",
+ TabMoreShadowed: "This shadow tiddler contains the contents of the 'Shadowed' tab in the right-hand sidebar",
+ TabTags: "This shadow tiddler contains the contents of the 'Tags' tab in the right-hand sidebar",
+ TabTimeline: "This shadow tiddler contains the contents of the 'Timeline' tab in the right-hand sidebar",
+ ToolbarCommands: "This shadow tiddler determines which commands are shown in tiddler toolbars",
+ ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look"
+ });
+
+//--
+//-- Main
+//--
+
+var params = null; // Command line parameters
+var store = null; // TiddlyWiki storage
+var story = null; // Main story
+var formatter = null; // Default formatters for the wikifier
+var anim = typeof Animator == "function" ? new Animator() : null; // Animation engine
+var readOnly = false; // Whether we're in readonly mode
+var highlightHack = null; // Embarrassing hack department...
+var hadConfirmExit = false; // Don't warn more than once
+var safeMode = false; // Disable all plugins and cookies
+var showBackstage; // Whether to include the backstage area
+var installedPlugins = []; // Information filled in when plugins are executed
+var startingUp = false; // Whether we're in the process of starting up
+var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins()
+
+// Whether to use the JavaSaver applet
+var useJavaSaver = (config.browser.isSafari || config.browser.isOpera) && (document.location.toString().substr(0,4) != "http");
+
+// Starting up
+function main()
+{
+ var t10,t9,t8,t7,t6,t5,t4,t3,t2,t1,t0 = new Date();
+ startingUp = true;
+ jQuery.noConflict();
+ window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();};
+ params = getParameters();
+ if(params)
+ params = params.parseParams("open",null,false);
+ store = new TiddlyWiki();
+ invokeParamifier(params,"oninit");
+ story = new Story("tiddlerDisplay","tiddler");
+ addEvent(document,"click",Popup.onDocumentClick);
+ saveTest();
+ loadOptionsCookie();
+ for(var s=0; s<config.notifyTiddlers.length; s++)
+ store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify);
+ t1 = new Date();
+ loadShadowTiddlers();
+ t2 = new Date();
+ store.loadFromDiv("storeArea","store",true);
+ t3 = new Date();
+ invokeParamifier(params,"onload");
+ t4 = new Date();
+ readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;
+ var pluginProblem = loadPlugins();
+ t5 = new Date();
+ formatter = new Formatter(config.formatters);
+ invokeParamifier(params,"onconfig");
+ story.switchTheme(config.options.txtTheme);
+ showBackstage = !readOnly;
+ t6 = new Date();
+ for(var m in config.macros) {
+ if(config.macros[m].init)
+ config.macros[m].init();
+ }
+ t7 = new Date();
+ store.notifyAll();
+ t8 = new Date();
+ restart();
+ refreshDisplay();
+ t9 = new Date();
+ if(pluginProblem) {
+ story.displayTiddler(null,"PluginManager");
+ displayMessage(config.messages.customConfigError);
+ }
+ if(showBackstage)
+ backstage.init();
+ t10 = new Date();
+ if(config.options.chkDisplayInstrumentation) {
+ displayMessage("LoadShadows " + (t2-t1) + " ms");
+ displayMessage("LoadFromDiv " + (t3-t2) + " ms");
+ displayMessage("LoadPlugins " + (t5-t4) + " ms");
+ displayMessage("Macro init " + (t7-t6) + " ms");
+ displayMessage("Notify " + (t8-t7) + " ms");
+ displayMessage("Restart " + (t9-t8) + " ms");
+ displayMessage("Total: " + (t10-t0) + " ms");
+ }
+ startingUp = false;
+}
+
+// Restarting
+function restart()
+{
+ invokeParamifier(params,"onstart");
+ if(story.isEmpty()) {
+ story.displayDefaultTiddlers();
+ }
+ window.scrollTo(0,0);
+}
+
+function saveTest()
+{
+ var s = document.getElementById("saveTest");
+ if(s.hasChildNodes())
+ alert(config.messages.savedSnapshotError);
+ s.appendChild(document.createTextNode("savetest"));
+}
+
+function loadShadowTiddlers()
+{
+ var shadows = new TiddlyWiki();
+ shadows.loadFromDiv("shadowArea","shadows",true);
+ shadows.forEachTiddler(function(title,tiddler){config.shadowTiddlers[title] = tiddler.text;});
+ delete shadows;
+}
+
+function loadPlugins()
+{
+ if(safeMode)
+ return false;
+ var tiddlers = store.getTaggedTiddlers("systemConfig");
+ var toLoad = [];
+ var nLoaded = 0;
+ var map = {};
+ var nPlugins = tiddlers.length;
+ installedPlugins = [];
+ for(var i=0; i<nPlugins; i++) {
+ var p = getPluginInfo(tiddlers[i]);
+ installedPlugins[i] = p;
+ var n = p.Name;
+ if(n)
+ map[n] = p;
+ n = p.Source;
+ if(n)
+ map[n] = p;
+ }
+ var visit = function(p) {
+ if(!p || p.done)
+ return;
+ p.done = 1;
+ var reqs = p.Requires;
+ if(reqs) {
+ reqs = reqs.readBracketedList();
+ for(var i=0; i<reqs.length; i++)
+ visit(map[reqs[i]]);
+ }
+ toLoad.push(p);
+ };
+ for(i=0; i<nPlugins; i++)
+ visit(installedPlugins[i]);
+ for(i=0; i<toLoad.length; i++) {
+ p = toLoad[i];
+ pluginInfo = p;
+ tiddler = p.tiddler;
+ if(isPluginExecutable(p)) {
+ if(isPluginEnabled(p)) {
+ p.executed = true;
+ var startTime = new Date();
+ try {
+ if(tiddler.text)
+ window.eval(tiddler.text);
+ nLoaded++;
+ } catch(ex) {
+ p.log.push(config.messages.pluginError.format([exceptionText(ex)]));
+ p.error = true;
+ }
+ pluginInfo.startupTime = String((new Date()) - startTime) + "ms";
+ } else {
+ nPlugins--;
+ }
+ } else {
+ p.warning = true;
+ }
+ }
+ return nLoaded != nPlugins;
+}
+
+function getPluginInfo(tiddler)
+{
+ var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","Requires","CoreVersion","Date","Source","Author","License","Browsers"]);
+ p.tiddler = tiddler;
+ p.title = tiddler.title;
+ p.log = [];
+ return p;
+}
+
+// Check that a particular plugin is valid for execution
+function isPluginExecutable(plugin)
+{
+ if(plugin.tiddler.isTagged("systemConfigForce")) {
+ plugin.log.push(config.messages.pluginForced);
+ return true;
+ }
+ if(plugin["CoreVersion"]) {
+ var coreVersion = plugin["CoreVersion"].split(".");
+ var w = parseInt(coreVersion[0],10) - version.major;
+ if(w == 0 && coreVersion[1])
+ w = parseInt(coreVersion[1],10) - version.minor;
+ if(w == 0 && coreVersion[2])
+ w = parseInt(coreVersion[2],10) - version.revision;
+ if(w > 0) {
+ plugin.log.push(config.messages.pluginVersionError);
+ return false;
+ }
+ }
+ return true;
+}
+
+function isPluginEnabled(plugin)
+{
+ if(plugin.tiddler.isTagged("systemConfigDisable")) {
+ plugin.log.push(config.messages.pluginDisabled);
+ return false;
+ }
+ return true;
+}
+
+function invokeMacro(place,macro,params,wikifier,tiddler)
+{
+ try {
+ var m = config.macros[macro];
+ if(m && m.handler) {
+ var tiddlerElem = story.findContainingTiddler(place);
+ window.tiddler = tiddlerElem ? store.getTiddler(tiddlerElem.getAttribute("tiddler")) : null;
+ window.place = place;
+ m.handler(place,macro,params.readMacroParams(),wikifier,params,tiddler);
+ } else {
+ createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro]));
+ }
+ } catch(ex) {
+ createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()]));
+ }
+}
+
+//--
+//-- Paramifiers
+//--
+
+function getParameters()
+{
+ var p = null;
+ if(window.location.hash) {
+ p = decodeURIComponent(window.location.hash.substr(1));
+ if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111")
+ p = convertUTF8ToUnicode(p);
+ }
+ return p;
+}
+
+function invokeParamifier(params,handler)
+{
+ if(!params || params.length == undefined || params.length <= 1)
+ return;
+ for(var i=1; i<params.length; i++) {
+ var p = config.paramifiers[params[i].name];
+ if(p && p[handler] instanceof Function)
+ p[handler](params[i].value);
+ else {
+ var h = config.optionHandlers[params[i].name.substr(0,3)];
+ if(h && h.set instanceof Function)
+ h.set(params[i].name,params[i].value);
+ }
+ }
+}
+
+config.paramifiers = {};
+
+config.paramifiers.start = {
+ oninit: function(v) {
+ safeMode = v.toLowerCase() == "safe";
+ }
+};
+
+config.paramifiers.open = {
+ onstart: function(v) {
+ if(!readOnly || store.tiddlerExists(v) || store.isShadowTiddler(v))
+ story.displayTiddler("bottom",v,null,false,null);
+ }
+};
+
+config.paramifiers.story = {
+ onstart: function(v) {
+ var list = store.getTiddlerText(v,"").parseParams("open",null,false);
+ invokeParamifier(list,"onstart");
+ }
+};
+
+config.paramifiers.search = {
+ onstart: function(v) {
+ story.search(v,false,false);
+ }
+};
+
+config.paramifiers.searchRegExp = {
+ onstart: function(v) {
+ story.prototype.search(v,false,true);
+ }
+};
+
+config.paramifiers.tag = {
+ onstart: function(v) {
+ story.displayTiddlers(null,store.filterTiddlers("[tag["+v+"]]"),null,false,null);
+ }
+};
+
+config.paramifiers.newTiddler = {
+ onstart: function(v) {
+ if(!readOnly) {
+ story.displayTiddler(null,v,DEFAULT_EDIT_TEMPLATE);
+ story.focusTiddler(v,"text");
+ }
+ }
+};
+
+config.paramifiers.newJournal = {
+ onstart: function(v) {
+ if(!readOnly) {
+ var now = new Date();
+ var title = now.formatString(v.trim());
+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
+ story.focusTiddler(title,"text");
+ }
+ }
+};
+
+config.paramifiers.readOnly = {
+ onconfig: function(v) {
+ var p = v.toLowerCase();
+ readOnly = p == "yes" ? true : (p == "no" ? false : readOnly);
+ }
+};
+
+config.paramifiers.theme = {
+ onconfig: function(v) {
+ story.switchTheme(v);
+ }
+};
+
+config.paramifiers.upgrade = {
+ onstart: function(v) {
+ upgradeFrom(v);
+ }
+};
+
+config.paramifiers.recent= {
+ onstart: function(v) {
+ var titles=[];
+ var tiddlers=store.getTiddlers("modified","excludeLists").reverse();
+ for(var i=0; i<v && i<tiddlers.length; i++)
+ titles.push(tiddlers[i].title);
+ story.displayTiddlers(null,titles);
+ }
+};
+
+config.paramifiers.filter = {
+ onstart: function(v) {
+ story.displayTiddlers(null,store.filterTiddlers(v),null,false);
+ }
+};
+
+//--
+//-- Formatter helpers
+//--
+
+function Formatter(formatters)
+{
+ this.formatters = [];
+ var pattern = [];
+ for(var n=0; n<formatters.length; n++) {
+ pattern.push("(" + formatters[n].match + ")");
+ this.formatters.push(formatters[n]);
+ }
+ this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
+}
+
+config.formatterHelpers = {
+
+ createElementAndWikify: function(w)
+ {
+ w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
+ },
+
+ inlineCssHelper: function(w)
+ {
+ var styles = [];
+ config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
+ var s,v;
+ if(lookaheadMatch[1]) {
+ s = lookaheadMatch[1].unDash();
+ v = lookaheadMatch[2];
+ } else {
+ s = lookaheadMatch[3].unDash();
+ v = lookaheadMatch[4];
+ }
+ if(s=="bgcolor")
+ s = "backgroundColor";
+ styles.push({style: s, value: v});
+ w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
+ config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
+ lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
+ }
+ return styles;
+ },
+
+ applyCssHelper: function(e,styles)
+ {
+ for(var t=0; t< styles.length; t++) {
+ try {
+ e.style[styles[t].style] = styles[t].value;
+ } catch (ex) {
+ }
+ }
+ },
+
+ enclosedTextHelper: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ var text = lookaheadMatch[1];
+ if(config.browser.isIE)
+ text = text.replace(/\n/g,"\r");
+ createTiddlyElement(w.output,this.element,null,null,text);
+ w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
+ }
+ },
+
+ isExternalLink: function(link)
+ {
+ if(store.tiddlerExists(link) || store.isShadowTiddler(link)) {
+ return false;
+ }
+ var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
+ if(urlRegExp.exec(link)) {
+ return true;
+ }
+ if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) {
+ return true;
+ }
+ return false;
+ }
+
+};
+
+//--
+//-- Standard formatters
+//--
+
+config.formatters = [
+{
+ name: "table",
+ match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
+ lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
+ rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
+ cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
+ cellTermRegExp: /((?:\x20*)\|)/mg,
+ rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
+ handler: function(w)
+ {
+ var table = createTiddlyElement(w.output,"table",null,"twtable");
+ var prevColumns = [];
+ var currRowType = null;
+ var rowContainer;
+ var rowCount = 0;
+ w.nextMatch = w.matchStart;
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
+ var nextRowType = lookaheadMatch[2];
+ if(nextRowType == "k") {
+ table.className = lookaheadMatch[1];
+ w.nextMatch += lookaheadMatch[0].length+1;
+ } else {
+ if(nextRowType != currRowType) {
+ rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]);
+ currRowType = nextRowType;
+ }
+ if(currRowType == "c") {
+ // Caption
+ w.nextMatch++;
+ if(rowContainer != table.firstChild)
+ table.insertBefore(rowContainer,table.firstChild);
+ rowContainer.setAttribute("align",rowCount == 0?"top":"bottom");
+ w.subWikifyTerm(rowContainer,this.rowTermRegExp);
+ } else {
+ var theRow = createTiddlyElement(rowContainer,"tr",null,(rowCount&1)?"oddRow":"evenRow");
+ theRow.onmouseover = function() {addClass(this,"hoverRow");};
+ theRow.onmouseout = function() {removeClass(this,"hoverRow");};
+ this.rowHandler(w,theRow,prevColumns);
+ rowCount++;
+ }
+ }
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ }
+ },
+ rowHandler: function(w,e,prevColumns)
+ {
+ var col = 0;
+ var colSpanCount = 1;
+ var prevCell = null;
+ this.cellRegExp.lastIndex = w.nextMatch;
+ var cellMatch = this.cellRegExp.exec(w.source);
+ while(cellMatch && cellMatch.index == w.nextMatch) {
+ if(cellMatch[1] == "~") {
+ // Rowspan
+ var last = prevColumns[col];
+ if(last) {
+ last.rowSpanCount++;
+ last.element.setAttribute("rowspan",last.rowSpanCount);
+ last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE
+ last.element.valign = "center";
+ }
+ w.nextMatch = this.cellRegExp.lastIndex-1;
+ } else if(cellMatch[1] == ">") {
+ // Colspan
+ colSpanCount++;
+ w.nextMatch = this.cellRegExp.lastIndex-1;
+ } else if(cellMatch[2]) {
+ // End of row
+ if(prevCell && colSpanCount > 1) {
+ prevCell.setAttribute("colspan",colSpanCount);
+ prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE
+ }
+ w.nextMatch = this.cellRegExp.lastIndex;
+ break;
+ } else {
+ // Cell
+ w.nextMatch++;
+ var styles = config.formatterHelpers.inlineCssHelper(w);
+ var spaceLeft = false;
+ var chr = w.source.substr(w.nextMatch,1);
+ while(chr == " ") {
+ spaceLeft = true;
+ w.nextMatch++;
+ chr = w.source.substr(w.nextMatch,1);
+ }
+ var cell;
+ if(chr == "!") {
+ cell = createTiddlyElement(e,"th");
+ w.nextMatch++;
+ } else {
+ cell = createTiddlyElement(e,"td");
+ }
+ prevCell = cell;
+ prevColumns[col] = {rowSpanCount:1,element:cell};
+ if(colSpanCount > 1) {
+ cell.setAttribute("colspan",colSpanCount);
+ cell.setAttribute("colSpan",colSpanCount); // Needed for IE
+ colSpanCount = 1;
+ }
+ config.formatterHelpers.applyCssHelper(cell,styles);
+ w.subWikifyTerm(cell,this.cellTermRegExp);
+ if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
+ cell.align = spaceLeft ? "center" : "left";
+ else if(spaceLeft)
+ cell.align = "right";
+ w.nextMatch--;
+ }
+ col++;
+ this.cellRegExp.lastIndex = w.nextMatch;
+ cellMatch = this.cellRegExp.exec(w.source);
+ }
+ }
+},
+
+{
+ name: "heading",
+ match: "^!{1,6}",
+ termRegExp: /(\n)/mg,
+ handler: function(w)
+ {
+ w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp);
+ }
+},
+
+{
+ name: "list",
+ match: "^(?:[\\*#;:]+)",
+ lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
+ termRegExp: /(\n)/mg,
+ handler: function(w)
+ {
+ var stack = [w.output];
+ var currLevel = 0, currType = null;
+ var listLevel, listType, itemType, baseType;
+ w.nextMatch = w.matchStart;
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
+ if(lookaheadMatch[1]) {
+ listType = "ul";
+ itemType = "li";
+ } else if(lookaheadMatch[2]) {
+ listType = "ol";
+ itemType = "li";
+ } else if(lookaheadMatch[3]) {
+ listType = "dl";
+ itemType = "dt";
+ } else if(lookaheadMatch[4]) {
+ listType = "dl";
+ itemType = "dd";
+ }
+ if(!baseType)
+ baseType = listType;
+ listLevel = lookaheadMatch[0].length;
+ w.nextMatch += lookaheadMatch[0].length;
+ var t;
+ if(listLevel > currLevel) {
+ for(t=currLevel; t<listLevel; t++) {
+ var target = (currLevel == 0) ? stack[stack.length-1] : stack[stack.length-1].lastChild;
+ stack.push(createTiddlyElement(target,listType));
+ }
+ } else if(listType!=baseType && listLevel==1) {
+ w.nextMatch -= lookaheadMatch[0].length;
+ return;
+ } else if(listLevel < currLevel) {
+ for(t=currLevel; t>listLevel; t--)
+ stack.pop();
+ } else if(listLevel == currLevel && listType != currType) {
+ stack.pop();
+ stack.push(createTiddlyElement(stack[stack.length-1].lastChild,listType));
+ }
+ currLevel = listLevel;
+ currType = listType;
+ var e = createTiddlyElement(stack[stack.length-1],itemType);
+ w.subWikifyTerm(e,this.termRegExp);
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ }
+ }
+},
+
+{
+ name: "quoteByBlock",
+ match: "^<<<\\n",
+ termRegExp: /(^<<<(\n|$))/mg,
+ element: "blockquote",
+ handler: config.formatterHelpers.createElementAndWikify
+},
+
+{
+ name: "quoteByLine",
+ match: "^>+",
+ lookaheadRegExp: /^>+/mg,
+ termRegExp: /(\n)/mg,
+ element: "blockquote",
+ handler: function(w)
+ {
+ var stack = [w.output];
+ var currLevel = 0;
+ var newLevel = w.matchLength;
+ var t;
+ do {
+ if(newLevel > currLevel) {
+ for(t=currLevel; t<newLevel; t++)
+ stack.push(createTiddlyElement(stack[stack.length-1],this.element));
+ } else if(newLevel < currLevel) {
+ for(t=currLevel; t>newLevel; t--)
+ stack.pop();
+ }
+ currLevel = newLevel;
+ w.subWikifyTerm(stack[stack.length-1],this.termRegExp);
+ createTiddlyElement(stack[stack.length-1],"br");
+ this.lookaheadRegExp.lastIndex = w.nextMatch;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
+ if(matched) {
+ newLevel = lookaheadMatch[0].length;
+ w.nextMatch += lookaheadMatch[0].length;
+ }
+ } while(matched);
+ }
+},
+
+{
+ name: "rule",
+ match: "^----+$\\n?|<hr ?/?>\\n?",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"hr");
+ }
+},
+
+{
+ name: "monospacedByLine",
+ match: "^(?:/\\*\\{\\{\\{\\*/|\\{\\{\\{|//\\{\\{\\{|<!--\\{\\{\\{-->)\\n",
+ element: "pre",
+ handler: function(w)
+ {
+ switch(w.matchText) {
+ case "/*{{{*/\n": // CSS
+ this.lookaheadRegExp = /\/\*\{\{\{\*\/\n*((?:^[^\n]*\n)+?)(\n*^\/\*\}\}\}\*\/$\n?)/mg;
+ break;
+ case "{{{\n": // monospaced block
+ this.lookaheadRegExp = /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/mg;
+ break;
+ case "//{{{\n": // plugin
+ this.lookaheadRegExp = /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\/\/\}\}\}$\n?)/mg;
+ break;
+ case "<!--{{{-->\n": //template
+ this.lookaheadRegExp = /<!--\{\{\{-->\n*((?:^[^\n]*\n)+?)(\n*^<!--\}\}\}-->$\n?)/mg;
+ break;
+ default:
+ break;
+ }
+ config.formatterHelpers.enclosedTextHelper.call(this,w);
+ }
+},
+
+{
+ name: "wikifyComment",
+ match: "^(?:/\\*\\*\\*|<!---)\\n",
+ handler: function(w)
+ {
+ var termRegExp = (w.matchText == "/***\n") ? (/(^\*\*\*\/\n)/mg) : (/(^--->\n)/mg);
+ w.subWikifyTerm(w.output,termRegExp);
+ }
+},
+
+{
+ name: "macro",
+ match: "<<",
+ lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) {
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
+ }
+ }
+},
+
+{
+ name: "prettyLink",
+ match: "\\[\\[",
+ lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ var e;
+ var text = lookaheadMatch[1];
+ if(lookaheadMatch[3]) {
+ // Pretty bracketted link
+ var link = lookaheadMatch[3];
+ e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link)) ?
+ createExternalLink(w.output,link) : createTiddlyLink(w.output,decodeURIComponent(link),false,null,w.isStatic,w.tiddler);
+ } else {
+ // Simple bracketted link
+ e = createTiddlyLink(w.output,decodeURIComponent(text),false,null,w.isStatic,w.tiddler);
+ }
+ createTiddlyText(e,text);
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "wikiLink",
+ match: config.textPrimitives.unWikiLink+"?"+config.textPrimitives.wikiLink,
+ handler: function(w)
+ {
+ if(w.matchText.substr(0,1) == config.textPrimitives.unWikiLink) {
+ w.outputText(w.output,w.matchStart+1,w.nextMatch);
+ return;
+ }
+ if(w.matchStart > 0) {
+ var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg");
+ preRegExp.lastIndex = w.matchStart-1;
+ var preMatch = preRegExp.exec(w.source);
+ if(preMatch.index == w.matchStart-1) {
+ w.outputText(w.output,w.matchStart,w.nextMatch);
+ return;
+ }
+ }
+ if(w.autoLinkWikiWords || store.isShadowTiddler(w.matchText)) {
+ var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic,w.tiddler);
+ w.outputText(link,w.matchStart,w.nextMatch);
+ } else {
+ w.outputText(w.output,w.matchStart,w.nextMatch);
+ }
+ }
+},
+
+{
+ name: "urlLink",
+ match: config.textPrimitives.urlPattern,
+ handler: function(w)
+ {
+ w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
+ }
+},
+
+{
+ name: "image",
+ match: "\\[[<>]?[Ii][Mm][Gg]\\[",
+ lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ var e = w.output;
+ if(lookaheadMatch[5]) {
+ var link = lookaheadMatch[5];
+ e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
+ addClass(e,"imageLink");
+ }
+ var img = createTiddlyElement(e,"img");
+ if(lookaheadMatch[1])
+ img.align = "left";
+ else if(lookaheadMatch[2])
+ img.align = "right";
+ if(lookaheadMatch[3]) {
+ img.title = lookaheadMatch[3];
+ img.setAttribute("alt",lookaheadMatch[3]);
+ }
+ img.src = lookaheadMatch[4];
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "html",
+ match: "<[Hh][Tt][Mm][Ll]>",
+ lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1];
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "commentByBlock",
+ match: "/%",
+ lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+},
+
+{
+ name: "characterFormat",
+ match: "''|//|__|\\^\\^|~~|--(?!\\s|$)|\\{\\{\\{",
+ handler: function(w)
+ {
+ switch(w.matchText) {
+ case "''":
+ w.subWikifyTerm(w.output.appendChild(document.createElement("strong")),/('')/mg);
+ break;
+ case "//":
+ w.subWikifyTerm(createTiddlyElement(w.output,"em"),/(\/\/)/mg);
+ break;
+ case "__":
+ w.subWikifyTerm(createTiddlyElement(w.output,"u"),/(__)/mg);
+ break;
+ case "^^":
+ w.subWikifyTerm(createTiddlyElement(w.output,"sup"),/(\^\^)/mg);
+ break;
+ case "~~":
+ w.subWikifyTerm(createTiddlyElement(w.output,"sub"),/(~~)/mg);
+ break;
+ case "--":
+ w.subWikifyTerm(createTiddlyElement(w.output,"strike"),/(--)/mg);
+ break;
+ case "{{{":
+ var lookaheadRegExp = /\{\{\{((?:.|\n)*?)\}\}\}/mg;
+ lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]);
+ w.nextMatch = lookaheadRegExp.lastIndex;
+ }
+ break;
+ }
+ }
+},
+
+{
+ name: "customFormat",
+ match: "@@|\\{\\{",
+ handler: function(w)
+ {
+ switch(w.matchText) {
+ case "@@":
+ var e = createTiddlyElement(w.output,"span");
+ var styles = config.formatterHelpers.inlineCssHelper(w);
+ if(styles.length == 0)
+ e.className = "marked";
+ else
+ config.formatterHelpers.applyCssHelper(e,styles);
+ w.subWikifyTerm(e,/(@@)/mg);
+ break;
+ case "{{":
+ var lookaheadRegExp = /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg;
+ lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch) {
+ w.nextMatch = lookaheadRegExp.lastIndex;
+ e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]);
+ w.subWikifyTerm(e,/(\}\}\})/mg);
+ }
+ break;
+ }
+ }
+},
+
+{
+ name: "mdash",
+ match: "--",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"span").innerHTML = "&mdash;";
+ }
+},
+
+{
+ name: "lineBreak",
+ match: "\\n|<br ?/?>",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"br");
+ }
+},
+
+{
+ name: "rawText",
+ match: "\\\"{3}|<nowiki>",
+ lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg,
+ handler: function(w)
+ {
+ this.lookaheadRegExp.lastIndex = w.matchStart;
+ var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
+ if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
+ createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]);
+ w.nextMatch = this.lookaheadRegExp.lastIndex;
+ }
+ }
+},
+
+{
+ name: "htmlEntitiesEncoding",
+ match: "(?:(?:&#?[a-zA-Z0-9]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9a-fA-F]|1D[c-fC-F][0-9a-fA-F]|20[d-fD-F][0-9a-fA-F]|FE2[0-9a-fA-F])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[a-zA-Z0-9]{2,8};)",
+ handler: function(w)
+ {
+ createTiddlyElement(w.output,"span").innerHTML = w.matchText;
+ }
+}
+
+];
+
+//--
+//-- Wikifier
+//--
+
+function getParser(tiddler,format)
+{
+ if(tiddler) {
+ if(!format)
+ format = tiddler.fields["wikiformat"];
+ var i;
+ if(format) {
+ for(i in config.parsers) {
+ if(format == config.parsers[i].format)
+ return config.parsers[i];
+ }
+ } else {
+ for(i in config.parsers) {
+ if(tiddler.isTagged(config.parsers[i].formatTag))
+ return config.parsers[i];
+ }
+ }
+ }
+ return formatter;
+}
+
+function wikify(source,output,highlightRegExp,tiddler)
+{
+ if(source) {
+ var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
+ var t0 = new Date();
+ wikifier.subWikify(output);
+ if(tiddler && config.options.chkDisplayInstrumentation)
+ displayMessage("wikify:" +tiddler.title+ " in " + (new Date()-t0) + " ms");
+ }
+}
+
+function wikifyStatic(source,highlightRegExp,tiddler,format)
+{
+ var e = createTiddlyElement(document.body,"pre");
+ e.style.display = "none";
+ var html = "";
+ if(source && source != "") {
+ if(!tiddler)
+ tiddler = new Tiddler("temp");
+ var wikifier = new Wikifier(source,getParser(tiddler,format),highlightRegExp,tiddler);
+ wikifier.isStatic = true;
+ wikifier.subWikify(e);
+ html = e.innerHTML;
+ removeNode(e);
+ }
+ return html;
+}
+
+function wikifyPlain(title,theStore,limit)
+{
+ if(!theStore)
+ theStore = store;
+ if(theStore.tiddlerExists(title) || theStore.isShadowTiddler(title)) {
+ return wikifyPlainText(theStore.getTiddlerText(title),limit,tiddler);
+ } else {
+ return "";
+ }
+}
+
+function wikifyPlainText(text,limit,tiddler)
+{
+ if(limit > 0)
+ text = text.substr(0,limit);
+ var wikifier = new Wikifier(text,formatter,null,tiddler);
+ return wikifier.wikifyPlain();
+}
+
+function highlightify(source,output,highlightRegExp,tiddler)
+{
+ if(source) {
+ var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
+ wikifier.outputText(output,0,source.length);
+ }
+}
+
+function Wikifier(source,formatter,highlightRegExp,tiddler)
+{
+ this.source = source;
+ this.output = null;
+ this.formatter = formatter;
+ this.nextMatch = 0;
+ this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true;
+ this.highlightRegExp = highlightRegExp;
+ this.highlightMatch = null;
+ this.isStatic = false;
+ if(highlightRegExp) {
+ highlightRegExp.lastIndex = 0;
+ this.highlightMatch = highlightRegExp.exec(source);
+ }
+ this.tiddler = tiddler;
+}
+
+Wikifier.prototype.wikifyPlain = function()
+{
+ var e = createTiddlyElement(document.body,"div");
+ e.style.display = "none";
+ this.subWikify(e);
+ var text = getPlainText(e);
+ removeNode(e);
+ return text;
+};
+
+Wikifier.prototype.subWikify = function(output,terminator)
+{
+ try {
+ if(terminator)
+ this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
+ else
+ this.subWikifyUnterm(output);
+ } catch(ex) {
+ showException(ex);
+ }
+};
+
+Wikifier.prototype.subWikifyUnterm = function(output)
+{
+ var oldOutput = this.output;
+ this.output = output;
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
+ while(formatterMatch) {
+ // Output any text before the match
+ if(formatterMatch.index > this.nextMatch)
+ this.outputText(this.output,this.nextMatch,formatterMatch.index);
+ // Set the match parameters for the handler
+ this.matchStart = formatterMatch.index;
+ this.matchLength = formatterMatch[0].length;
+ this.matchText = formatterMatch[0];
+ this.nextMatch = this.formatter.formatterRegExp.lastIndex;
+ for(var t=1; t<formatterMatch.length; t++) {
+ if(formatterMatch[t]) {
+ this.formatter.formatters[t-1].handler(this);
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ break;
+ }
+ }
+ formatterMatch = this.formatter.formatterRegExp.exec(this.source);
+ }
+ if(this.nextMatch < this.source.length) {
+ this.outputText(this.output,this.nextMatch,this.source.length);
+ this.nextMatch = this.source.length;
+ }
+ this.output = oldOutput;
+};
+
+Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
+{
+ var oldOutput = this.output;
+ this.output = output;
+ terminatorRegExp.lastIndex = this.nextMatch;
+ var terminatorMatch = terminatorRegExp.exec(this.source);
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
+ while(terminatorMatch || formatterMatch) {
+ if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) {
+ if(terminatorMatch.index > this.nextMatch)
+ this.outputText(this.output,this.nextMatch,terminatorMatch.index);
+ this.matchText = terminatorMatch[1];
+ this.matchLength = terminatorMatch[1].length;
+ this.matchStart = terminatorMatch.index;
+ this.nextMatch = this.matchStart + this.matchLength;
+ this.output = oldOutput;
+ return;
+ }
+ if(formatterMatch.index > this.nextMatch)
+ this.outputText(this.output,this.nextMatch,formatterMatch.index);
+ this.matchStart = formatterMatch.index;
+ this.matchLength = formatterMatch[0].length;
+ this.matchText = formatterMatch[0];
+ this.nextMatch = this.formatter.formatterRegExp.lastIndex;
+ for(var t=1; t<formatterMatch.length; t++) {
+ if(formatterMatch[t]) {
+ this.formatter.formatters[t-1].handler(this);
+ this.formatter.formatterRegExp.lastIndex = this.nextMatch;
+ break;
+ }
+ }
+ terminatorRegExp.lastIndex = this.nextMatch;
+ terminatorMatch = terminatorRegExp.exec(this.source);
+ formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
+ }
+ if(this.nextMatch < this.source.length) {
+ this.outputText(this.output,this.nextMatch,this.source.length);
+ this.nextMatch = this.source.length;
+ }
+ this.output = oldOutput;
+};
+
+Wikifier.prototype.outputText = function(place,startPos,endPos)
+{
+ while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) {
+ if(this.highlightMatch.index > startPos) {
+ createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
+ startPos = this.highlightMatch.index;
+ }
+ var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
+ var theHighlight = createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
+ startPos = highlightEnd;
+ if(startPos >= this.highlightRegExp.lastIndex)
+ this.highlightMatch = this.highlightRegExp.exec(this.source);
+ }
+ if(startPos < endPos) {
+ createTiddlyText(place,this.source.substring(startPos,endPos));
+ }
+};
+
+//--
+//-- Macro definitions
+//--
+
+config.macros.today.handler = function(place,macroName,params)
+{
+ var now = new Date();
+ var text = params[0] ? now.formatString(params[0].trim()) : now.toLocaleString();
+ createTiddlyElement(place,"span",null,null,text);
+};
+
+config.macros.version.handler = function(place)
+{
+ createTiddlyElement(place,"span",null,null,formatVersion());
+};
+
+config.macros.list.handler = function(place,macroName,params)
+{
+ var type = params[0] || "all";
+ var list = document.createElement("ul");
+ place.appendChild(list);
+ if(this[type].prompt)
+ createTiddlyElement(list,"li",null,"listTitle",this[type].prompt);
+ var results;
+ if(this[type].handler)
+ results = this[type].handler(params);
+ for(var t = 0; t < results.length; t++) {
+ var li = document.createElement("li");
+ list.appendChild(li);
+ createTiddlyLink(li,typeof results[t] == "string" ? results[t] : results[t].title,true);
+ }
+};
+
+config.macros.list.all.handler = function(params)
+{
+ return store.reverseLookup("tags","excludeLists",false,"title");
+};
+
+config.macros.list.missing.handler = function(params)
+{
+ return store.getMissingLinks();
+};
+
+config.macros.list.orphans.handler = function(params)
+{
+ return store.getOrphans();
+};
+
+config.macros.list.shadowed.handler = function(params)
+{
+ return store.getShadowed();
+};
+
+config.macros.list.touched.handler = function(params)
+{
+ return store.getTouched();
+};
+
+config.macros.list.filter.handler = function(params)
+{
+ var filter = params[1];
+ var results = [];
+ if(filter) {
+ var tiddlers = store.filterTiddlers(filter);
+ for(var t=0; t<tiddlers.length; t++)
+ results.push(tiddlers[t].title);
+ }
+ return results;
+};
+
+config.macros.allTags.handler = function(place,macroName,params)
+{
+ var tags = store.getTags(params[0]);
+ var ul = createTiddlyElement(place,"ul");
+ if(tags.length == 0)
+ createTiddlyElement(ul,"li",null,"listTitle",this.noTags);
+ for(var t=0; t<tags.length; t++) {
+ var title = tags[t][0];
+ var info = getTiddlyLinkInfo(title);
+ var li = createTiddlyElement(ul,"li");
+ var btn = createTiddlyButton(li,title + " (" + tags[t][1] + ")",this.tooltip.format([title]),onClickTag,info.classes);
+ btn.setAttribute("tag",title);
+ btn.setAttribute("refresh","link");
+ btn.setAttribute("tiddlyLink",title);
+ }
+};
+
+config.macros.timeline.handler = function(place,macroName,params)
+{
+ var field = params[0] || "modified";
+ var tiddlers = store.reverseLookup("tags","excludeLists",false,field);
+ var lastDay = "";
+ var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1])) : 0;
+ var dateFormat = params[2] || this.dateFormat;
+ for(var t=tiddlers.length-1; t>=last; t--) {
+ var tiddler = tiddlers[t];
+ var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);
+ if(theDay != lastDay) {
+ var ul = document.createElement("ul");
+ place.appendChild(ul);
+ createTiddlyElement(ul,"li",null,"listTitle",tiddler[field].formatString(dateFormat));
+ lastDay = theDay;
+ }
+ createTiddlyElement(ul,"li",null,"listLink").appendChild(createTiddlyLink(place,tiddler.title,true));
+ }
+};
+
+config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ params = paramString.parseParams("name",null,true,false,true);
+ var names = params[0]["name"];
+ var tiddlerName = names[0];
+ var className = names[1] || null;
+ var args = params[0]["with"];
+ var wrapper = createTiddlyElement(place,"span",null,className);
+ if(!args) {
+ wrapper.setAttribute("refresh","content");
+ wrapper.setAttribute("tiddler",tiddlerName);
+ }
+ var text = store.getTiddlerText(tiddlerName);
+ if(text) {
+ var stack = config.macros.tiddler.tiddlerStack;
+ if(stack.indexOf(tiddlerName) !== -1)
+ return;
+ stack.push(tiddlerName);
+ try {
+ var n = args ? Math.min(args.length,9) : 0;
+ for(var i=0; i<n; i++) {
+ var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
+ text = text.replace(placeholderRE,args[i]);
+ }
+ config.macros.tiddler.renderText(wrapper,text,tiddlerName,params);
+ } finally {
+ stack.pop();
+ }
+ }
+};
+
+config.macros.tiddler.renderText = function(place,text,tiddlerName,params)
+{
+ wikify(text,place,null,store.getTiddler(tiddlerName));
+};
+
+config.macros.tiddler.tiddlerStack = [];
+
+config.macros.tag.handler = function(place,macroName,params)
+{
+ createTagButton(place,params[0],null,params[1],params[2]);
+};
+
+config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var ul = createTiddlyElement(place,"ul");
+ var title = getParam(params,"anon","");
+ if(title && store.tiddlerExists(title))
+ tiddler = store.getTiddler(title);
+ var sep = getParam(params,"sep"," ");
+ var lingo = config.views.wikified.tag;
+ var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags;
+ createTiddlyElement(ul,"li",null,"listTitle",prompt.format([tiddler.title]));
+ for(var t=0; t<tiddler.tags.length; t++) {
+ createTagButton(createTiddlyElement(ul,"li"),tiddler.tags[t],tiddler.title);
+ if(t<tiddler.tags.length-1)
+ createTiddlyText(ul,sep);
+ }
+};
+
+config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var ul = createTiddlyElement(place,"ul");
+ var title = getParam(params,"anon","");
+ if(title == "" && tiddler instanceof Tiddler)
+ title = tiddler.title;
+ var sep = getParam(params,"sep"," ");
+ ul.setAttribute("title",this.tooltip.format([title]));
+ var tagged = store.getTaggedTiddlers(title);
+ var prompt = tagged.length == 0 ? this.labelNotTag : this.label;
+ createTiddlyElement(ul,"li",null,"listTitle",prompt.format([title,tagged.length]));
+ for(var t=0; t<tagged.length; t++) {
+ createTiddlyLink(createTiddlyElement(ul,"li"),tagged[t].title,true);
+ if(t<tagged.length-1)
+ createTiddlyText(ul,sep);
+ }
+};
+
+config.macros.closeAll.handler = function(place)
+{
+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
+};
+
+config.macros.closeAll.onClick = function(e)
+{
+ story.closeAllTiddlers();
+ return false;
+};
+
+config.macros.permaview.handler = function(place)
+{
+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
+};
+
+config.macros.permaview.onClick = function(e)
+{
+ story.permaView();
+ return false;
+};
+
+config.macros.saveChanges.handler = function(place,macroName,params)
+{
+ if(!readOnly)
+ createTiddlyButton(place,params[0] || this.label,params[1] || this.prompt,this.onClick,null,null,this.accessKey);
+};
+
+config.macros.saveChanges.onClick = function(e)
+{
+ saveChanges();
+ return false;
+};
+
+config.macros.slider.onClickSlider = function(ev)
+{
+ var e = ev || window.event;
+ var n = this.nextSibling;
+ var cookie = n.getAttribute("cookie");
+ var isOpen = n.style.display != "none";
+ if(config.options.chkAnimate && anim && typeof Slider == "function")
+ anim.startAnimating(new Slider(n,!isOpen,null,"none"));
+ else
+ n.style.display = isOpen ? "none" : "block";
+ config.options[cookie] = !isOpen;
+ saveOptionCookie(cookie);
+ return false;
+};
+
+config.macros.slider.createSlider = function(place,cookie,title,tooltip)
+{
+ var c = cookie || "";
+ var btn = createTiddlyButton(place,title,tooltip,this.onClickSlider);
+ var panel = createTiddlyElement(null,"div",null,"sliderPanel");
+ panel.setAttribute("cookie",c);
+ panel.style.display = config.options[c] ? "block" : "none";
+ place.appendChild(panel);
+ return panel;
+};
+
+config.macros.slider.handler = function(place,macroName,params)
+{
+ var panel = this.createSlider(place,params[0],params[2],params[3]);
+ var text = store.getTiddlerText(params[1]);
+ panel.setAttribute("refresh","content");
+ panel.setAttribute("tiddler",params[1]);
+ if(text)
+ wikify(text,panel,null,store.getTiddler(params[1]));
+};
+
+// <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >>
+config.macros.gradient.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ var panel = wikifier ? createTiddlyElement(place,"div",null,"gradient") : place;
+ panel.style.position = "relative";
+ panel.style.overflow = "hidden";
+ panel.style.zIndex = "0";
+ if(wikifier) {
+ var styles = config.formatterHelpers.inlineCssHelper(wikifier);
+ config.formatterHelpers.applyCssHelper(panel,styles);
+ }
+ params = paramString.parseParams("color");
+ var locolors = [], hicolors = [];
+ for(var t=2; t<params.length; t++) {
+ var c = params[t].value;
+ if(params[t].name == "snap") {
+ hicolors[hicolors.length-1] = c;
+ } else {
+ locolors.push(c);
+ hicolors.push(c);
+ }
+ }
+ drawGradient(panel,params[1].value != "vert",locolors,hicolors);
+ if(wikifier)
+ wikifier.subWikify(panel,">>");
+ if(document.all) {
+ panel.style.height = "100%";
+ panel.style.width = "100%";
+ }
+};
+
+config.macros.message.handler = function(place,macroName,params)
+{
+ if(params[0]) {
+ var names = params[0].split(".");
+ var lookupMessage = function(root,nameIndex) {
+ if(names[nameIndex] in root) {
+ if(nameIndex < names.length-1)
+ return (lookupMessage(root[names[nameIndex]],nameIndex+1));
+ else
+ return root[names[nameIndex]];
+ } else
+ return null;
+ };
+ var m = lookupMessage(config,0);
+ if(m == null)
+ m = lookupMessage(window,0);
+ createTiddlyText(place,m.toString().format(params.splice(1)));
+ }
+};
+
+
+config.macros.view.views = {
+ text: function(value,place,params,wikifier,paramString,tiddler) {
+ highlightify(value,place,highlightHack,tiddler);
+ },
+ link: function(value,place,params,wikifier,paramString,tiddler) {
+ createTiddlyLink(place,value,true);
+ },
+ wikified: function(value,place,params,wikifier,paramString,tiddler) {
+ if(params[2])
+ value=params[2].unescapeLineBreaks().format([value]);
+ wikify(value,place,highlightHack,tiddler);
+ },
+ date: function(value,place,params,wikifier,paramString,tiddler) {
+ value = Date.convertFromYYYYMMDDHHMM(value);
+ createTiddlyText(place,value.formatString(params[2] ? params[2] : config.views.wikified.dateFormat));
+ }
+};
+
+config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if((tiddler instanceof Tiddler) && params[0]) {
+ var value = store.getValue(tiddler,params[0]);
+ if(value) {
+ var type = params[1] || config.macros.view.defaultView;
+ var handler = config.macros.view.views[type];
+ if(handler)
+ handler(value,place,params,wikifier,paramString,tiddler);
+ }
+ }
+};
+
+config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ var field = params[0];
+ var rows = params[1] || 0;
+ var defVal = params[2] || '';
+ if((tiddler instanceof Tiddler) && field) {
+ story.setDirty(tiddler.title,true);
+ var e,v;
+ if(field != "text" && !rows) {
+ e = createTiddlyElement(null,"input");
+ if(tiddler.isReadOnly())
+ e.setAttribute("readOnly","readOnly");
+ e.setAttribute("edit",field);
+ e.setAttribute("type","text");
+ e.value = store.getValue(tiddler,field) || defVal;
+ e.setAttribute("size","40");
+ e.setAttribute("autocomplete","off");
+ place.appendChild(e);
+ } else {
+ var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix");
+ var wrapper2 = createTiddlyElement(wrapper1,"div");
+ e = createTiddlyElement(wrapper2,"textarea");
+ if(tiddler.isReadOnly())
+ e.setAttribute("readOnly","readOnly");
+ e.value = v = store.getValue(tiddler,field) || defVal;
+ rows = rows || 10;
+ var lines = v.match(/\n/mg);
+ var maxLines = Math.max(parseInt(config.options.txtMaxEditRows),5);
+ if(lines != null && lines.length > rows)
+ rows = lines.length + 5;
+ rows = Math.min(rows,maxLines);
+ e.setAttribute("rows",rows);
+ e.setAttribute("edit",field);
+ place.appendChild(wrapper1);
+ }
+ return e;
+ }
+};
+
+config.macros.tagChooser.onClick = function(ev)
+{
+ var e = ev || window.event;
+ var lingo = config.views.editor.tagChooser;
+ var popup = Popup.create(this);
+ var tags = store.getTags(this.getAttribute("tags"));
+ if(tags.length == 0)
+ createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone);
+ for(var t=0; t<tags.length; t++) {
+ var tag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick);
+ tag.setAttribute("tag",tags[t][0]);
+ tag.setAttribute("tiddler",this.getAttribute("tiddler"));
+ }
+ Popup.show();
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return false;
+};
+
+config.macros.tagChooser.onTagClick = function(ev)
+{
+ var e = ev || window.event;
+ if(e.metaKey || e.ctrlKey) stopEvent(e); //# keep popup open on CTRL-click
+ var tag = this.getAttribute("tag");
+ var title = this.getAttribute("tiddler");
+ if(!readOnly)
+ story.setTiddlerTag(title,tag,0);
+ return false;
+};
+
+config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if(tiddler instanceof Tiddler) {
+ var lingo = config.views.editor.tagChooser;
+ var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick);
+ btn.setAttribute("tiddler",tiddler.title);
+ btn.setAttribute("tags",params[0]);
+ }
+};
+
+config.macros.refreshDisplay.handler = function(place)
+{
+ createTiddlyButton(place,this.label,this.prompt,this.onClick);
+};
+
+config.macros.refreshDisplay.onClick = function(e)
+{
+ refreshAll();
+ return false;
+};
+
+config.macros.annotations.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ var title = tiddler ? tiddler.title : null;
+ var a = title ? config.annotations[title] : null;
+ if(!tiddler || !title || !a)
+ return;
+ var text = a.format([title]);
+ wikify(text,createTiddlyElement(place,"div",null,"annotation"),null,tiddler);
+};
+
+//--
+//-- NewTiddler and NewJournal macros
+//--
+
+config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal)
+{
+ var tags = [];
+ for(var t=1; t<params.length; t++) {
+ if((params[t].name == "anon" && t != 1) || (params[t].name == "tag"))
+ tags.push(params[t].value);
+ }
+ label = getParam(params,"label",label);
+ prompt = getParam(params,"prompt",prompt);
+ accessKey = getParam(params,"accessKey",accessKey);
+ newFocus = getParam(params,"focus",newFocus);
+ var customFields = getParam(params,"fields","");
+ if(!customFields && !store.isShadowTiddler(title))
+ customFields = String.encodeHashMap(config.defaultCustomFields);
+ var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey);
+ btn.setAttribute("newTitle",title);
+ btn.setAttribute("isJournal",isJournal ? "true" : "false");
+ if(tags.length > 0)
+ btn.setAttribute("params",tags.join("|"));
+ btn.setAttribute("newFocus",newFocus);
+ btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE));
+ if(customFields !== "")
+ btn.setAttribute("customFields",customFields);
+ var text = getParam(params,"text");
+ if(text !== undefined)
+ btn.setAttribute("newText",text);
+ return btn;
+};
+
+config.macros.newTiddler.onClickNewTiddler = function()
+{
+ var title = this.getAttribute("newTitle");
+ if(this.getAttribute("isJournal") == "true") {
+ title = new Date().formatString(title.trim());
+ }
+ var params = this.getAttribute("params");
+ var tags = params ? params.split("|") : [];
+ var focus = this.getAttribute("newFocus");
+ var template = this.getAttribute("newTemplate");
+ var customFields = this.getAttribute("customFields");
+ if(!customFields && !store.isShadowTiddler(title))
+ customFields = String.encodeHashMap(config.defaultCustomFields);
+ story.displayTiddler(null,title,template,false,null,null);
+ var tiddlerElem = story.getTiddler(title);
+ if(customFields)
+ story.addCustomFields(tiddlerElem,customFields);
+ var text = this.getAttribute("newText");
+ if(typeof text == "string" && story.getTiddlerField(title,"text"))
+ story.getTiddlerField(title,"text").value = text.format([title]);
+ for(var t=0;t<tags.length;t++)
+ story.setTiddlerTag(title,tags[t],+1);
+ story.focusTiddler(title,focus);
+ return false;
+};
+
+config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString)
+{
+ if(!readOnly) {
+ params = paramString.parseParams("anon",null,true,false,false);
+ var title = params[1] && params[1].name == "anon" ? params[1].value : this.title;
+ title = getParam(params,"title",title);
+ this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false);
+ }
+};
+
+config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString)
+{
+ if(!readOnly) {
+ params = paramString.parseParams("anon",null,true,false,false);
+ var title = params[1] && params[1].name == "anon" ? params[1].value : config.macros.timeline.dateFormat;
+ title = getParam(params,"title",title);
+ config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true);
+ }
+};
+
+//--
+//-- Search macro
+//--
+
+config.macros.search.handler = function(place,macroName,params)
+{
+ var searchTimeout = null;
+ var btn = createTiddlyButton(place,this.label,this.prompt,this.onClick,"searchButton");
+ var txt = createTiddlyElement(null,"input",null,"txtOptionInput searchField");
+ if(params[0])
+ txt.value = params[0];
+ if(config.browser.isSafari) {
+ txt.setAttribute("type","search");
+ txt.setAttribute("results","5");
+ } else {
+ txt.setAttribute("type","text");
+ }
+ place.appendChild(txt);
+ txt.onkeyup = this.onKeyPress;
+ txt.onfocus = this.onFocus;
+ txt.setAttribute("size",this.sizeTextbox);
+ txt.setAttribute("accessKey",this.accessKey);
+ txt.setAttribute("autocomplete","off");
+ txt.setAttribute("lastSearchText","");
+};
+
+// Global because there's only ever one outstanding incremental search timer
+config.macros.search.timeout = null;
+
+config.macros.search.doSearch = function(txt)
+{
+ if(txt.value.length > 0) {
+ story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);
+ txt.setAttribute("lastSearchText",txt.value);
+ }
+};
+
+config.macros.search.onClick = function(e)
+{
+ config.macros.search.doSearch(this.nextSibling);
+ return false;
+};
+
+config.macros.search.onKeyPress = function(ev)
+{
+ var e = ev || window.event;
+ switch(e.keyCode) {
+ case 13: // Ctrl-Enter
+ case 10: // Ctrl-Enter on IE PC
+ config.macros.search.doSearch(this);
+ break;
+ case 27: // Escape
+ this.value = "";
+ clearMessage();
+ break;
+ }
+ if(config.options.chkIncrementalSearch) {
+ if(this.value.length > 2) {
+ if(this.value != this.getAttribute("lastSearchText")) {
+ if(config.macros.search.timeout)
+ clearTimeout(config.macros.search.timeout);
+ var txt = this;
+ config.macros.search.timeout = setTimeout(function() {config.macros.search.doSearch(txt);},500);
+ }
+ } else {
+ if(config.macros.search.timeout)
+ clearTimeout(config.macros.search.timeout);
+ }
+ }
+};
+
+config.macros.search.onFocus = function(e)
+{
+ this.select();
+};
+
+//--
+//-- Tabs macro
+//--
+
+config.macros.tabs.handler = function(place,macroName,params)
+{
+ var cookie = params[0];
+ var numTabs = (params.length-1)/3;
+ var wrapper = createTiddlyElement(null,"div",null,"tabsetWrapper " + cookie);
+ var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
+ tabset.setAttribute("cookie",cookie);
+ var validTab = false;
+ for(var t=0; t<numTabs; t++) {
+ var label = params[t*3+1];
+ var prompt = params[t*3+2];
+ var content = params[t*3+3];
+ var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
+ tab.setAttribute("tab",label);
+ tab.setAttribute("content",content);
+ tab.title = prompt;
+ if(config.options[cookie] == label)
+ validTab = true;
+ }
+ if(!validTab)
+ config.options[cookie] = params[1];
+ place.appendChild(wrapper);
+ this.switchTab(tabset,config.options[cookie]);
+};
+
+config.macros.tabs.onClickTab = function(e)
+{
+ config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
+ return false;
+};
+
+config.macros.tabs.switchTab = function(tabset,tab)
+{
+ var cookie = tabset.getAttribute("cookie");
+ var theTab = null;
+ var nodes = tabset.childNodes;
+ for(var t=0; t<nodes.length; t++) {
+ if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab) {
+ theTab = nodes[t];
+ theTab.className = "tab tabSelected";
+ } else {
+ nodes[t].className = "tab tabUnselected";
+ }
+ }
+ if(theTab) {
+ if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
+ removeNode(tabset.nextSibling);
+ var tabContent = createTiddlyElement(null,"div",null,"tabContents");
+ tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
+ var contentTitle = theTab.getAttribute("content");
+ wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
+ if(cookie) {
+ config.options[cookie] = tab;
+ saveOptionCookie(cookie);
+ }
+ }
+};
+
+//--
+//-- Tiddler toolbar
+//--
+
+// Create a toolbar command button
+config.macros.toolbar.createCommand = function(place,commandName,tiddler,className)
+{
+ if(typeof commandName != "string") {
+ var c = null;
+ for(var t in config.commands) {
+ if(config.commands[t] == commandName)
+ c = t;
+ }
+ commandName = c;
+ }
+ if((tiddler instanceof Tiddler) && (typeof commandName == "string")) {
+ var command = config.commands[commandName];
+ if(command.isEnabled ? command.isEnabled(tiddler) : this.isCommandEnabled(command,tiddler)) {
+ var text = command.getText ? command.getText(tiddler) : this.getCommandText(command,tiddler);
+ var tooltip = command.getTooltip ? command.getTooltip(tiddler) : this.getCommandTooltip(command,tiddler);
+ var cmd;
+ switch(command.type) {
+ case "popup":
+ cmd = this.onClickPopup;
+ break;
+ case "command":
+ default:
+ cmd = this.onClickCommand;
+ break;
+ }
+ var btn = createTiddlyButton(null,text,tooltip,cmd);
+ btn.setAttribute("commandName",commandName);
+ btn.setAttribute("tiddler",tiddler.title);
+ if(className)
+ addClass(btn,className);
+ place.appendChild(btn);
+ }
+ }
+};
+
+config.macros.toolbar.isCommandEnabled = function(command,tiddler)
+{
+ var title = tiddler.title;
+ var ro = tiddler.isReadOnly();
+ var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title);
+ return (!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow);
+};
+
+config.macros.toolbar.getCommandText = function(command,tiddler)
+{
+ return tiddler.isReadOnly() && command.readOnlyText || command.text;
+};
+
+config.macros.toolbar.getCommandTooltip = function(command,tiddler)
+{
+ return tiddler.isReadOnly() && command.readOnlyTooltip || command.tooltip;
+};
+
+config.macros.toolbar.onClickCommand = function(ev)
+{
+ var e = ev || window.event;
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ var command = config.commands[this.getAttribute("commandName")];
+ return command.handler(e,this,this.getAttribute("tiddler"));
+};
+
+config.macros.toolbar.onClickPopup = function(ev)
+{
+ var e = ev || window.event;
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ var popup = Popup.create(this);
+ var command = config.commands[this.getAttribute("commandName")];
+ var title = this.getAttribute("tiddler");
+ var tiddler = store.fetchTiddler(title);
+ popup.setAttribute("tiddler",title);
+ command.handlePopup(popup,title);
+ Popup.show();
+ return false;
+};
+
+// Invoke the first command encountered from a given place that is tagged with a specified class
+config.macros.toolbar.invokeCommand = function(place,className,event)
+{
+ var children = place.getElementsByTagName("a");
+ for(var t=0; t<children.length; t++) {
+ var c = children[t];
+ if(hasClass(c,className) && c.getAttribute && c.getAttribute("commandName")) {
+ if(c.onclick instanceof Function)
+ c.onclick.call(c,event);
+ break;
+ }
+ }
+};
+
+config.macros.toolbar.onClickMore = function(ev)
+{
+ var e = this.nextSibling;
+ e.style.display = "inline";
+ removeNode(this);
+ return false;
+};
+
+config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ for(var t=0; t<params.length; t++) {
+ var c = params[t];
+ switch(c) {
+ case '>':
+ var btn = createTiddlyButton(place,this.moreLabel,this.morePrompt,config.macros.toolbar.onClickMore);
+ addClass(btn,"moreCommand");
+ var e = createTiddlyElement(place,"span",null,"moreCommand");
+ e.style.display = "none";
+ place = e;
+ break;
+ default:
+ var className = "";
+ switch(c.substr(0,1)) {
+ case "+":
+ className = "defaultCommand";
+ c = c.substr(1);
+ break;
+ case "-":
+ className = "cancelCommand";
+ c = c.substr(1);
+ break;
+ }
+ if(c in config.commands)
+ this.createCommand(place,c,tiddler,className);
+ break;
+ }
+ }
+};
+
+//--
+//-- Menu and toolbar commands
+//--
+
+config.commands.closeTiddler.handler = function(event,src,title)
+{
+ if(story.isDirty(title) && !readOnly) {
+ if(!confirm(config.commands.cancelTiddler.warning.format([title])))
+ return false;
+ }
+ story.setDirty(title,false);
+ story.closeTiddler(title,true);
+ return false;
+};
+
+config.commands.closeOthers.handler = function(event,src,title)
+{
+ story.closeAllTiddlers(title);
+ return false;
+};
+
+config.commands.editTiddler.handler = function(event,src,title)
+{
+ clearMessage();
+ var tiddlerElem = story.getTiddler(title);
+ var fields = tiddlerElem.getAttribute("tiddlyFields");
+ story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,fields);
+ story.focusTiddler(title,config.options.txtEditorFocus||"text");
+ return false;
+};
+
+config.commands.saveTiddler.handler = function(event,src,title)
+{
+ var newTitle = story.saveTiddler(title,event.shiftKey);
+ if(newTitle)
+ story.displayTiddler(null,newTitle);
+ return false;
+};
+
+config.commands.cancelTiddler.handler = function(event,src,title)
+{
+ if(story.hasChanges(title) && !readOnly) {
+ if(!confirm(this.warning.format([title])))
+ return false;
+ }
+ story.setDirty(title,false);
+ story.displayTiddler(null,title);
+ return false;
+};
+
+config.commands.deleteTiddler.handler = function(event,src,title)
+{
+ var deleteIt = true;
+ if(config.options.chkConfirmDelete)
+ deleteIt = confirm(this.warning.format([title]));
+ if(deleteIt) {
+ store.removeTiddler(title);
+ story.closeTiddler(title,true);
+ autoSaveChanges();
+ }
+ return false;
+};
+
+config.commands.permalink.handler = function(event,src,title)
+{
+ var t = encodeURIComponent(String.encodeTiddlyLink(title));
+ if(window.location.hash != t)
+ window.location.hash = t;
+ return false;
+};
+
+config.commands.references.handlePopup = function(popup,title)
+{
+ var references = store.getReferringTiddlers(title);
+ var c = false;
+ for(var r=0; r<references.length; r++) {
+ if(references[r].title != title && !references[r].isTagged("excludeLists")) {
+ createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true);
+ c = true;
+ }
+ }
+ if(!c)
+ createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),this.popupNone);
+};
+
+config.commands.jump.handlePopup = function(popup,title)
+{
+ story.forEachTiddler(function(title,element) {
+ createTiddlyLink(createTiddlyElement(popup,"li"),title,true,null,false,null,true);
+ });
+};
+
+config.commands.syncing.handlePopup = function(popup,title)
+{
+ var tiddler = store.fetchTiddler(title);
+ if(!tiddler)
+ return;
+ var serverType = tiddler.getServerType();
+ var serverHost = tiddler.fields['server.host'];
+ var serverWorkspace = tiddler.fields['server.workspace'];
+ if(!serverWorkspace)
+ serverWorkspace = "";
+ if(serverType) {
+ var e = createTiddlyElement(popup,"li",null,"popupMessage");
+ e.innerHTML = config.commands.syncing.currentlySyncing.format([serverType,serverHost,serverWorkspace]);
+ } else {
+ createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.notCurrentlySyncing);
+ }
+ if(serverType) {
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ var btn = createTiddlyButton(createTiddlyElement(popup,"li"),this.captionUnSync,null,config.commands.syncing.onChooseServer);
+ btn.setAttribute("tiddler",title);
+ btn.setAttribute("server.type","");
+ }
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.chooseServer);
+ var feeds = store.getTaggedTiddlers("systemServer","title");
+ for(var t=0; t<feeds.length; t++) {
+ var f = feeds[t];
+ var feedServerType = store.getTiddlerSlice(f.title,"Type");
+ if(!feedServerType)
+ feedServerType = "file";
+ var feedServerHost = store.getTiddlerSlice(f.title,"URL");
+ if(!feedServerHost)
+ feedServerHost = "";
+ var feedServerWorkspace = store.getTiddlerSlice(f.title,"Workspace");
+ if(!feedServerWorkspace)
+ feedServerWorkspace = "";
+ var caption = f.title;
+ if(serverType == feedServerType && serverHost == feedServerHost && serverWorkspace == feedServerWorkspace) {
+ caption = config.commands.syncing.currServerMarker + caption;
+ } else {
+ caption = config.commands.syncing.notCurrServerMarker + caption;
+ }
+ btn = createTiddlyButton(createTiddlyElement(popup,"li"),caption,null,config.commands.syncing.onChooseServer);
+ btn.setAttribute("tiddler",title);
+ btn.setAttribute("server.type",feedServerType);
+ btn.setAttribute("server.host",feedServerHost);
+ btn.setAttribute("server.workspace",feedServerWorkspace);
+ }
+};
+
+config.commands.syncing.onChooseServer = function(e)
+{
+ var tiddler = this.getAttribute("tiddler");
+ var serverType = this.getAttribute("server.type");
+ if(serverType) {
+ store.addTiddlerFields(tiddler,{
+ "server.type": serverType,
+ "server.host": this.getAttribute("server.host"),
+ "server.workspace": this.getAttribute("server.workspace")
+ });
+ } else {
+ store.setValue(tiddler,"server",null);
+ }
+ return false;
+};
+
+config.commands.fields.handlePopup = function(popup,title)
+{
+ var tiddler = store.fetchTiddler(title);
+ if(!tiddler)
+ return;
+ var items = [];
+ store.forEachField(tiddler,function(tiddler,fieldName,value){items.push({field:fieldName,value:value});},true);
+ items.sort(function(a,b) {return a.field < b.field ? -1 : (a.field == b.field ? 0 : +1);});
+ if(items.length > 0)
+ ListView.create(popup,items,this.listViewTemplate);
+ else
+ createTiddlyElement(popup,"div",null,null,this.emptyText);
+};
+
+//--
+//-- Tiddler() object
+//--
+
+function Tiddler(title)
+{
+ this.title = title;
+ this.text = "";
+ this.modifier = null;
+ this.created = new Date();
+ this.modified = this.created;
+ this.links = [];
+ this.linksUpdated = false;
+ this.tags = [];
+ this.fields = {};
+ return this;
+}
+
+Tiddler.prototype.getLinks = function()
+{
+ if(this.linksUpdated==false)
+ this.changed();
+ return this.links;
+};
+
+// Returns the fields that are inherited in string field:"value" field2:"value2" format
+Tiddler.prototype.getInheritedFields = function()
+{
+ var f = {};
+ for(var i in this.fields) {
+ if(i=="server.host" || i=="server.workspace" || i=="wikiformat"|| i=="server.type") {
+ f[i] = this.fields[i];
+ }
+ }
+ return String.encodeHashMap(f);
+};
+
+// Increment the changeCount of a tiddler
+Tiddler.prototype.incChangeCount = function()
+{
+ var c = this.fields['changecount'];
+ c = c ? parseInt(c,10) : 0;
+ this.fields['changecount'] = String(c+1);
+};
+
+// Clear the changeCount of a tiddler
+Tiddler.prototype.clearChangeCount = function()
+{
+ if(this.fields['changecount']) {
+ delete this.fields['changecount'];
+ }
+};
+
+Tiddler.prototype.doNotSave = function()
+{
+ return this.fields['doNotSave'];
+};
+
+// Returns true if the tiddler has been updated since the tiddler was created or downloaded
+Tiddler.prototype.isTouched = function()
+{
+ var changeCount = this.fields['changecount'];
+ if(changeCount === undefined)
+ changeCount = 0;
+ return changeCount > 0;
+};
+
+// Change the text and other attributes of a tiddler
+Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields)
+{
+ this.assign(title,text,modifier,modified,tags,created,fields);
+ this.changed();
+ return this;
+};
+
+// Change the text and other attributes of a tiddler without triggered a tiddler.changed() call
+Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields)
+{
+ if(title != undefined)
+ this.title = title;
+ if(text != undefined)
+ this.text = text;
+ if(modifier != undefined)
+ this.modifier = modifier;
+ if(modified != undefined)
+ this.modified = modified;
+ if(created != undefined)
+ this.created = created;
+ if(fields != undefined)
+ this.fields = fields;
+ if(tags != undefined)
+ this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
+ else if(this.tags == undefined)
+ this.tags = [];
+ return this;
+};
+
+// Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
+Tiddler.prototype.getTags = function()
+{
+ return String.encodeTiddlyLinkList(this.tags);
+};
+
+// Test if a tiddler carries a tag
+Tiddler.prototype.isTagged = function(tag)
+{
+ return this.tags.indexOf(tag) != -1;
+};
+
+// Static method to convert "\n" to newlines, "\s" to "\"
+Tiddler.unescapeLineBreaks = function(text)
+{
+ return text ? text.unescapeLineBreaks() : "";
+};
+
+// Convert newlines to "\n", "\" to "\s"
+Tiddler.prototype.escapeLineBreaks = function()
+{
+ return this.text.escapeLineBreaks();
+};
+
+// Updates the secondary information (like links[] array) after a change to a tiddler
+Tiddler.prototype.changed = function()
+{
+ this.links = [];
+ var text = this.text;
+ // remove 'quoted' text before scanning tiddler source
+ text = text.replace(/\/%((?:.|\n)*?)%\//g,"").
+ replace(/\{{3}((?:.|\n)*?)\}{3}/g,"").
+ replace(/"""((?:.|\n)*?)"""/g,"").
+ replace(/\<nowiki\>((?:.|\n)*?)\<\/nowiki\>/g,"").
+ replace(/\<html\>((?:.|\n)*?)\<\/html\>/g,"").
+ replace(/\<script((?:.|\n)*?)\<\/script\>/g,"");
+ var t = this.autoLinkWikiWords() ? 0 : 1;
+ var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp;
+ tiddlerLinkRegExp.lastIndex = 0;
+ var formatMatch = tiddlerLinkRegExp.exec(text);
+ while(formatMatch) {
+ var lastIndex = tiddlerLinkRegExp.lastIndex;
+ if(t==0 && formatMatch[1] && formatMatch[1] != this.title) {
+ // wikiWordLink
+ if(formatMatch.index > 0) {
+ var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg");
+ preRegExp.lastIndex = formatMatch.index-1;
+ var preMatch = preRegExp.exec(text);
+ if(preMatch.index != formatMatch.index-1)
+ this.links.pushUnique(formatMatch[1]);
+ } else {
+ this.links.pushUnique(formatMatch[1]);
+ }
+ }
+ else if(formatMatch[2-t] && !config.formatterHelpers.isExternalLink(formatMatch[3-t])) // titledBrackettedLink
+ this.links.pushUnique(formatMatch[3-t]);
+ else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink
+ this.links.pushUnique(formatMatch[4-t]);
+ tiddlerLinkRegExp.lastIndex = lastIndex;
+ formatMatch = tiddlerLinkRegExp.exec(text);
+ }
+ this.linksUpdated = true;
+};
+
+Tiddler.prototype.getSubtitle = function()
+{
+ var modifier = this.modifier;
+ if(!modifier)
+ modifier = config.messages.subtitleUnknown;
+ var modified = this.modified;
+ if(modified)
+ modified = modified.toLocaleString();
+ else
+ modified = config.messages.subtitleUnknown;
+ return config.messages.tiddlerLinkTooltip.format([this.title,modifier,modified]);
+};
+
+Tiddler.prototype.isReadOnly = function()
+{
+ return readOnly;
+};
+
+Tiddler.prototype.autoLinkWikiWords = function()
+{
+ return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing"));
+};
+
+Tiddler.prototype.generateFingerprint = function()
+{
+ return "0x" + Crypto.hexSha1Str(this.text);
+};
+
+Tiddler.prototype.getServerType = function()
+{
+ var serverType = null;
+ if(this.fields['server.type'])
+ serverType = this.fields['server.type'];
+ if(!serverType)
+ serverType = this.fields['wikiformat'];
+ if(serverType && !config.adaptors[serverType])
+ serverType = null;
+ return serverType;
+};
+
+Tiddler.prototype.getAdaptor = function()
+{
+ var serverType = this.getServerType();
+ return serverType ? new config.adaptors[serverType]() : null;
+};
+
+//--
+//-- TiddlyWiki() object contains Tiddler()s
+//--
+
+function TiddlyWiki()
+{
+ var tiddlers = {}; // Hashmap by name of tiddlers
+ this.tiddlersUpdated = false;
+ this.namedNotifications = []; // Array of {name:,notify:} of notification functions
+ this.notificationLevel = 0;
+ this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
+ this.clear = function() {
+ tiddlers = {};
+ this.setDirty(false);
+ };
+ this.fetchTiddler = function(title) {
+ var t = tiddlers[title];
+ return t instanceof Tiddler ? t : null;
+ };
+ this.deleteTiddler = function(title) {
+ delete this.slices[title];
+ delete tiddlers[title];
+ };
+ this.addTiddler = function(tiddler) {
+ delete this.slices[tiddler.title];
+ tiddlers[tiddler.title] = tiddler;
+ };
+ this.forEachTiddler = function(callback) {
+ for(var t in tiddlers) {
+ var tiddler = tiddlers[t];
+ if(tiddler instanceof Tiddler)
+ callback.call(this,t,tiddler);
+ }
+ };
+}
+
+TiddlyWiki.prototype.setDirty = function(dirty)
+{
+ this.dirty = dirty;
+};
+
+TiddlyWiki.prototype.isDirty = function()
+{
+ return this.dirty;
+};
+
+TiddlyWiki.prototype.tiddlerExists = function(title)
+{
+ var t = this.fetchTiddler(title);
+ return t != undefined;
+};
+
+TiddlyWiki.prototype.isShadowTiddler = function(title)
+{
+ return config.shadowTiddlers[title] === undefined ? false : true;
+};
+
+TiddlyWiki.prototype.createTiddler = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(!tiddler) {
+ tiddler = new Tiddler(title);
+ this.addTiddler(tiddler);
+ this.setDirty(true);
+ }
+ return tiddler;
+};
+
+TiddlyWiki.prototype.getTiddler = function(title)
+{
+ var t = this.fetchTiddler(title);
+ if(t != undefined)
+ return t;
+ else
+ return null;
+};
+
+TiddlyWiki.prototype.getShadowTiddlerText = function(title)
+{
+ if(typeof config.shadowTiddlers[title] == "string")
+ return config.shadowTiddlers[title];
+ else
+ return "";
+};
+
+TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
+{
+ if(!title)
+ return defaultText;
+ var pos = title.indexOf(config.textPrimitives.sectionSeparator);
+ var section = null;
+ if(pos != -1) {
+ section = title.substr(pos + config.textPrimitives.sectionSeparator.length);
+ title = title.substr(0,pos);
+ }
+ pos = title.indexOf(config.textPrimitives.sliceSeparator);
+ if(pos != -1) {
+ var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
+ if(slice)
+ return slice;
+ }
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ if(!section)
+ return tiddler.text;
+ var re = new RegExp("(^!{1,6}" + section.escapeRegExp() + "[ \t]*\n)","mg");
+ re.lastIndex = 0;
+ var match = re.exec(tiddler.text);
+ if(match) {
+ var t = tiddler.text.substr(match.index+match[1].length);
+ var re2 = /^!/mg;
+ re2.lastIndex = 0;
+ match = re2.exec(t); //# search for the next heading
+ if(match)
+ t = t.substr(0,match.index-1);//# don't include final \n
+ return t;
+ }
+ return defaultText;
+ }
+ if(this.isShadowTiddler(title))
+ return this.getShadowTiddlerText(title);
+ if(defaultText != undefined)
+ return defaultText;
+ return null;
+};
+
+TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth)
+{
+ var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
+ var text = this.getTiddlerText(title,null);
+ if(text == null)
+ return defaultText;
+ var textOut = [];
+ var lastPos = 0;
+ do {
+ var match = bracketRegExp.exec(text);
+ if(match) {
+ textOut.push(text.substr(lastPos,match.index-lastPos));
+ if(match[1]) {
+ if(depth <= 0)
+ textOut.push(match[1]);
+ else
+ textOut.push(this.getRecursiveTiddlerText(match[1],"[[" + match[1] + "]]",depth-1));
+ }
+ lastPos = match.index + match[0].length;
+ } else {
+ textOut.push(text.substr(lastPos));
+ }
+ } while(match);
+ return textOut.join("");
+};
+
+TiddlyWiki.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1[\t\x20]*([^\n]+)[\t\x20]*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|[\t\x20]*([^\n]+)[\t\x20]*\|$)/gm;
+
+// @internal
+TiddlyWiki.prototype.calcAllSlices = function(title)
+{
+ var slices = {};
+ var text = this.getTiddlerText(title,"");
+ this.slicesRE.lastIndex = 0;
+ var m = this.slicesRE.exec(text);
+ while(m) {
+ if(m[2])
+ slices[m[2]] = m[3];
+ else
+ slices[m[5]] = m[6];
+ m = this.slicesRE.exec(text);
+ }
+ return slices;
+};
+
+// Returns the slice of text of the given name
+TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName)
+{
+ var slices = this.slices[title];
+ if(!slices) {
+ slices = this.calcAllSlices(title);
+ this.slices[title] = slices;
+ }
+ return slices[sliceName];
+};
+
+// Build an hashmap of the specified named slices of a tiddler
+TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames)
+{
+ var r = {};
+ for(var t=0; t<sliceNames.length; t++) {
+ var slice = this.getTiddlerSlice(title,sliceNames[t]);
+ if(slice)
+ r[sliceNames[t]] = slice;
+ }
+ return r;
+};
+
+TiddlyWiki.prototype.suspendNotifications = function()
+{
+ this.notificationLevel--;
+};
+
+TiddlyWiki.prototype.resumeNotifications = function()
+{
+ this.notificationLevel++;
+};
+
+// Invoke the notification handlers for a particular tiddler
+TiddlyWiki.prototype.notify = function(title,doBlanket)
+{
+ if(!this.notificationLevel) {
+ for(var t=0; t<this.namedNotifications.length; t++) {
+ var n = this.namedNotifications[t];
+ if((n.name == null && doBlanket) || (n.name == title))
+ n.notify(title);
+ }
+ }
+};
+
+// Invoke the notification handlers for all tiddlers
+TiddlyWiki.prototype.notifyAll = function()
+{
+ if(!this.notificationLevel) {
+ for(var t=0; t<this.namedNotifications.length; t++) {
+ var n = this.namedNotifications[t];
+ if(n.name)
+ n.notify(n.name);
+ }
+ }
+};
+
+// Add a notification handler to a tiddler
+TiddlyWiki.prototype.addNotification = function(title,fn)
+{
+ for(var i=0; i<this.namedNotifications.length; i++) {
+ if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
+ return this;
+ }
+ this.namedNotifications.push({name: title, notify: fn});
+ return this;
+};
+
+TiddlyWiki.prototype.removeTiddler = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ this.deleteTiddler(title);
+ this.notify(title,true);
+ this.setDirty(true);
+ }
+};
+
+// Reset the sync status of a freshly synced tiddler
+TiddlyWiki.prototype.resetTiddler = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ tiddler.clearChangeCount();
+ this.notify(title,true);
+ this.setDirty(true);
+ }
+};
+
+TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ var t = tiddler.tags.indexOf(tag);
+ if(t != -1)
+ tiddler.tags.splice(t,1);
+ if(status)
+ tiddler.tags.push(tag);
+ tiddler.changed();
+ tiddler.incChangeCount();
+ this.notify(title,true);
+ this.setDirty(true);
+ }
+};
+
+TiddlyWiki.prototype.addTiddlerFields = function(title,fields)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(!tiddler)
+ return;
+ merge(tiddler.fields,fields);
+ tiddler.changed();
+ tiddler.incChangeCount();
+ this.notify(title,true);
+ this.setDirty(true);
+};
+
+TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ created = created || tiddler.created; // Preserve created date
+ this.deleteTiddler(title);
+ } else {
+ created = created || modified;
+ tiddler = new Tiddler();
+ }
+ tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields);
+ this.addTiddler(tiddler);
+ if(clearChangeCount)
+ tiddler.clearChangeCount();
+ else
+ tiddler.incChangeCount();
+ if(title != newTitle)
+ this.notify(title,true);
+ this.notify(newTitle,true);
+ this.setDirty(true);
+ return tiddler;
+};
+
+TiddlyWiki.prototype.incChangeCount = function(title)
+{
+ var tiddler = this.fetchTiddler(title);
+ if(tiddler)
+ tiddler.incChangeCount();
+};
+
+TiddlyWiki.prototype.getLoader = function()
+{
+ if(!this.loader)
+ this.loader = new TW21Loader();
+ return this.loader;
+};
+
+TiddlyWiki.prototype.getSaver = function()
+{
+ if(!this.saver)
+ this.saver = new TW21Saver();
+ return this.saver;
+};
+
+// Return all tiddlers formatted as an HTML string
+TiddlyWiki.prototype.allTiddlersAsHtml = function()
+{
+ return this.getSaver().externalize(store);
+};
+
+// Load contents of a TiddlyWiki from an HTML DIV
+TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate)
+{
+ this.idPrefix = idPrefix;
+ var storeElem = (typeof src == "string") ? document.getElementById(src) : src;
+ if(!storeElem)
+ return;
+ var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes);
+ this.setDirty(false);
+ if(!noUpdate) {
+ for(var i = 0;i<tiddlers.length; i++)
+ tiddlers[i].changed();
+ }
+};
+
+// Load contents of a TiddlyWiki from a string
+// Returns null if there's an error
+TiddlyWiki.prototype.importTiddlyWiki = function(text)
+{
+ var posDiv = locateStoreArea(text);
+ if(!posDiv)
+ return null;
+ var content = "<" + "html><" + "body>" + text.substring(posDiv[0],posDiv[1] + endSaveArea.length) + "<" + "/body><" + "/html>";
+ // Create the iframe
+ var iframe = document.createElement("iframe");
+ iframe.style.display = "none";
+ document.body.appendChild(iframe);
+ var doc = iframe.document;
+ if(iframe.contentDocument)
+ doc = iframe.contentDocument; // For NS6
+ else if(iframe.contentWindow)
+ doc = iframe.contentWindow.document; // For IE5.5 and IE6
+ // Put the content in the iframe
+ doc.open();
+ doc.writeln(content);
+ doc.close();
+ // Load the content into a TiddlyWiki() object
+ var storeArea = doc.getElementById("storeArea");
+ this.loadFromDiv(storeArea,"store");
+ // Get rid of the iframe
+ iframe.parentNode.removeChild(iframe);
+ return this;
+};
+
+TiddlyWiki.prototype.updateTiddlers = function()
+{
+ this.tiddlersUpdated = true;
+ this.forEachTiddler(function(title,tiddler) {
+ tiddler.changed();
+ });
+};
+
+// Return an array of tiddlers matching a search regular expression
+TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag,match)
+{
+ var candidates = this.reverseLookup("tags",excludeTag,!!match);
+ var results = [];
+ for(var t=0; t<candidates.length; t++) {
+ if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
+ results.push(candidates[t]);
+ }
+ if(!sortField)
+ sortField = "title";
+ results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
+ return results;
+};
+
+// Returns a list of all tags in use
+// excludeTag - if present, excludes tags that are themselves tagged with excludeTag
+// Returns an array of arrays where [tag][0] is the name of the tag and [tag][1] is the number of occurances
+TiddlyWiki.prototype.getTags = function(excludeTag)
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ for(var g=0; g<tiddler.tags.length; g++) {
+ var tag = tiddler.tags[g];
+ var n = true;
+ for(var c=0; c<results.length; c++) {
+ if(results[c][0] == tag) {
+ n = false;
+ results[c][1]++;
+ }
+ }
+ if(n && excludeTag) {
+ var t = this.fetchTiddler(tag);
+ if(t && t.isTagged(excludeTag))
+ n = false;
+ }
+ if(n)
+ results.push([tag,1]);
+ }
+ });
+ results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
+ return results;
+};
+
+// Return an array of the tiddlers that are tagged with a given tag
+TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
+{
+ return this.reverseLookup("tags",tag,true,sortField);
+};
+
+// Return an array of the tiddlers that link to a given tiddler
+TiddlyWiki.prototype.getReferringTiddlers = function(title,unusedParameter,sortField)
+{
+ if(!this.tiddlersUpdated)
+ this.updateTiddlers();
+ return this.reverseLookup("links",title,true,sortField);
+};
+
+// Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
+// lookupMatch == true to match tiddlers, false to exclude tiddlers
+TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ var f = !lookupMatch;
+ for(var lookup=0; lookup<tiddler[lookupField].length; lookup++) {
+ if(tiddler[lookupField][lookup] == lookupValue)
+ f = lookupMatch;
+ }
+ if(f)
+ results.push(tiddler);
+ });
+ if(!sortField)
+ sortField = "title";
+ results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
+ return results;
+};
+
+// Return the tiddlers as a sorted array
+TiddlyWiki.prototype.getTiddlers = function(field,excludeTag)
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ if(excludeTag == undefined || !tiddler.isTagged(excludeTag))
+ results.push(tiddler);
+ });
+ if(field)
+ results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);});
+ return results;
+};
+
+// Return array of names of tiddlers that are referred to but not defined
+TiddlyWiki.prototype.getMissingLinks = function(sortField)
+{
+ if(!this.tiddlersUpdated)
+ this.updateTiddlers();
+ var results = [];
+ this.forEachTiddler(function (title,tiddler) {
+ if(tiddler.isTagged("excludeMissing") || tiddler.isTagged("systemConfig"))
+ return;
+ for(var n=0; n<tiddler.links.length;n++) {
+ var link = tiddler.links[n];
+ if(this.fetchTiddler(link) == null && !this.isShadowTiddler(link))
+ results.pushUnique(link);
+ }
+ });
+ results.sort();
+ return results;
+};
+
+// Return an array of names of tiddlers that are defined but not referred to
+TiddlyWiki.prototype.getOrphans = function()
+{
+ var results = [];
+ this.forEachTiddler(function (title,tiddler) {
+ if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists"))
+ results.push(title);
+ });
+ results.sort();
+ return results;
+};
+
+// Return an array of names of all the shadow tiddlers
+TiddlyWiki.prototype.getShadowed = function()
+{
+ var results = [];
+ for(var t in config.shadowTiddlers) {
+ if(this.isShadowTiddler(t))
+ results.push(t);
+ }
+ results.sort();
+ return results;
+};
+
+// Return an array of tiddlers that have been touched since they were downloaded or created
+TiddlyWiki.prototype.getTouched = function()
+{
+ var results = [];
+ this.forEachTiddler(function(title,tiddler) {
+ if(tiddler.isTouched())
+ results.push(tiddler);
+ });
+ results.sort();
+ return results;
+};
+
+// Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist
+TiddlyWiki.prototype.resolveTiddler = function(tiddler)
+{
+ var t = (typeof tiddler == 'string') ? this.getTiddler(tiddler) : tiddler;
+ return t instanceof Tiddler ? t : null;
+};
+
+// Filter a list of tiddlers
+TiddlyWiki.prototype.filterTiddlers = function(filter)
+{
+ var results = [];
+ if(filter) {
+ var tiddler;
+ var re = /([^\s\[\]]+)|(?:\[([ \w]+)\[([^\]]+)\]\])|(?:\[\[([^\]]+)\]\])/mg;
+ var match = re.exec(filter);
+ while(match) {
+ if(match[1] || match[4]) {
+ var title = match[1] || match[4];
+ tiddler = this.fetchTiddler(title);
+ if(tiddler) {
+ results.pushUnique(tiddler);
+ } else if(this.isShadowTiddler(title)) {
+ tiddler = new Tiddler();
+ tiddler.set(title,this.getTiddlerText(title));
+ results.pushUnique(tiddler);
+ } else {
+ results.pushUnique(new Tiddler(title));
+ }
+ } else if(match[2]) {
+ switch(match[2]) {
+ case "tag":
+ var matched = this.getTaggedTiddlers(match[3]);
+ for(var m = 0; m < matched.length; m++)
+ results.pushUnique(matched[m]);
+ break;
+ case "sort":
+ results = this.sortTiddlers(results,match[3]);
+ break;
+ }
+ }
+ match = re.exec(filter);
+ }
+ }
+ return results;
+};
+
+// Sort a list of tiddlers
+TiddlyWiki.prototype.sortTiddlers = function(tiddlers,field)
+{
+ var asc = +1;
+ switch(field.substr(0,1)) {
+ case "-":
+ asc = -1;
+ // Note: this fall-through is intentional
+ /*jsl:fallthru*/
+ case "+":
+ field = field.substr(1);
+ break;
+ }
+ if(TiddlyWiki.standardFieldAccess[field])
+ tiddlers.sort(function(a,b) {return a[field] < b[field] ? -asc : (a[field] == b[field] ? 0 : asc);});
+ else
+ tiddlers.sort(function(a,b) {return a.fields[field] < b.fields[field] ? -asc : (a.fields[field] == b.fields[field] ? 0 : +asc);});
+ return tiddlers;
+};
+
+// Returns true if path is a valid field name (path),
+// i.e. a sequence of identifiers, separated by '.'
+TiddlyWiki.isValidFieldName = function(name)
+{
+ var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name);
+ return match && (match[0] == name);
+};
+
+// Throws an exception when name is not a valid field name.
+TiddlyWiki.checkFieldName = function(name)
+{
+ if(!TiddlyWiki.isValidFieldName(name))
+ throw config.messages.invalidFieldName.format([name]);
+};
+
+function StringFieldAccess(n,readOnly)
+{
+ this.set = readOnly ?
+ function(t,v) {if(v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);} :
+ function(t,v) {if(v != t[n]) {t[n] = v; return true;}};
+ this.get = function(t) {return t[n];};
+}
+
+function DateFieldAccess(n)
+{
+ this.set = function(t,v) {
+ var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v);
+ if(d != t[n]) {
+ t[n] = d; return true;
+ }
+ };
+ this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();};
+}
+
+function LinksFieldAccess(n)
+{
+ this.set = function(t,v) {
+ var s = (typeof v == "string") ? v.readBracketedList() : v;
+ if(s.toString() != t[n].toString()) {
+ t[n] = s; return true;
+ }
+ };
+ this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);};
+}
+
+TiddlyWiki.standardFieldAccess = {
+ // The set functions return true when setting the data has changed the value.
+ "title": new StringFieldAccess("title",true),
+ // Handle the "tiddler" field name as the title
+ "tiddler": new StringFieldAccess("title",true),
+ "text": new StringFieldAccess("text"),
+ "modifier": new StringFieldAccess("modifier"),
+ "modified": new DateFieldAccess("modified"),
+ "created": new DateFieldAccess("created"),
+ "tags": new LinksFieldAccess("tags")
+};
+
+TiddlyWiki.isStandardField = function(name)
+{
+ return TiddlyWiki.standardFieldAccess[name] != undefined;
+};
+
+// Sets the value of the given field of the tiddler to the value.
+// Setting an ExtendedField's value to null or undefined removes the field.
+// Setting a namespace to undefined removes all fields of that namespace.
+// The fieldName is case-insensitive.
+// All values will be converted to a string value.
+TiddlyWiki.prototype.setValue = function(tiddler,fieldName,value)
+{
+ TiddlyWiki.checkFieldName(fieldName);
+ var t = this.resolveTiddler(tiddler);
+ if(!t)
+ return;
+ fieldName = fieldName.toLowerCase();
+ var isRemove = (value === undefined) || (value === null);
+ var accessor = TiddlyWiki.standardFieldAccess[fieldName];
+ if(accessor) {
+ if(isRemove)
+ // don't remove StandardFields
+ return;
+ var h = TiddlyWiki.standardFieldAccess[fieldName];
+ if(!h.set(t,value))
+ return;
+ } else {
+ var oldValue = t.fields[fieldName];
+ if(isRemove) {
+ if(oldValue !== undefined) {
+ // deletes a single field
+ delete t.fields[fieldName];
+ } else {
+ // no concrete value is defined for the fieldName
+ // so we guess this is a namespace path.
+ // delete all fields in a namespace
+ var re = new RegExp('^'+fieldName+'\\.');
+ var dirty = false;
+ for(var n in t.fields) {
+ if(n.match(re)) {
+ delete t.fields[n];
+ dirty = true;
+ }
+ }
+ if(!dirty)
+ return;
+ }
+ } else {
+ // the "normal" set case. value is defined (not null/undefined)
+ // For convenience provide a nicer conversion Date->String
+ value = value instanceof Date ? value.convertToYYYYMMDDHHMMSSMMM() : String(value);
+ if(oldValue == value)
+ return;
+ t.fields[fieldName] = value;
+ }
+ }
+ // When we are here the tiddler/store really was changed.
+ this.notify(t.title,true);
+ if(!fieldName.match(/^temp\./))
+ this.setDirty(true);
+};
+
+// Returns the value of the given field of the tiddler.
+// The fieldName is case-insensitive.
+// Will only return String values (or undefined).
+TiddlyWiki.prototype.getValue = function(tiddler,fieldName)
+{
+ var t = this.resolveTiddler(tiddler);
+ if(!t)
+ return undefined;
+ fieldName = fieldName.toLowerCase();
+ var accessor = TiddlyWiki.standardFieldAccess[fieldName];
+ if(accessor) {
+ return accessor.get(t);
+ }
+ return t.fields[fieldName];
+};
+
+// Calls the callback function for every field in the tiddler.
+// When callback function returns a non-false value the iteration stops
+// and that value is returned.
+// The order of the fields is not defined.
+// @param callback a function(tiddler,fieldName,value).
+TiddlyWiki.prototype.forEachField = function(tiddler,callback,onlyExtendedFields)
+{
+ var t = this.resolveTiddler(tiddler);
+ if(!t)
+ return undefined;
+ var n,result;
+ for(n in t.fields) {
+ result = callback(t,n,t.fields[n]);
+ if(result)
+ return result;
+ }
+ if(onlyExtendedFields)
+ return undefined;
+ for(n in TiddlyWiki.standardFieldAccess) {
+ if(n == "tiddler")
+ // even though the "title" field can also be referenced through the name "tiddler"
+ // we only visit this field once.
+ continue;
+ result = callback(t,n,TiddlyWiki.standardFieldAccess[n].get(t));
+ if(result)
+ return result;
+ }
+ return undefined;
+};
+
+//--
+//-- Story functions
+//--
+
+function Story(containerId,idPrefix)
+{
+ this.container = containerId;
+ this.idPrefix = idPrefix;
+ this.highlightRegExp = null;
+ this.tiddlerId = function(title) {
+ var id = this.idPrefix + title;
+ return id==this.container ? this.idPrefix + "_" + title : id;
+ };
+ this.containerId = function() {
+ return this.container;
+ };
+}
+
+Story.prototype.getTiddler = function(title)
+{
+ return document.getElementById(this.tiddlerId(title));
+};
+
+Story.prototype.getContainer = function()
+{
+ return document.getElementById(this.containerId());
+};
+
+Story.prototype.forEachTiddler = function(fn)
+{
+ var place = this.getContainer();
+ if(!place)
+ return;
+ var e = place.firstChild;
+ while(e) {
+ var n = e.nextSibling;
+ var title = e.getAttribute("tiddler");
+ fn.call(this,title,e);
+ e = n;
+ }
+};
+
+Story.prototype.displayDefaultTiddlers = function()
+{
+ this.displayTiddlers(null,store.filterTiddlers(store.getTiddlerText("DefaultTiddlers")));
+};
+
+Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,unused,customFields,toggle)
+{
+ for(var t = titles.length-1;t>=0;t--)
+ this.displayTiddler(srcElement,titles[t],template,animate,unused,customFields);
+};
+
+Story.prototype.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle,animationSrc)
+{
+ var title = (tiddler instanceof Tiddler) ? tiddler.title : tiddler;
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ if(toggle)
+ this.closeTiddler(title,true);
+ else
+ this.refreshTiddler(title,template,false,customFields);
+ } else {
+ var place = this.getContainer();
+ var before = this.positionTiddler(srcElement);
+ tiddlerElem = this.createTiddler(place,before,title,template,customFields);
+ }
+ if(animationSrc && typeof animationSrc !== "string") {
+ srcElement = animationSrc;
+ }
+ if(srcElement && typeof srcElement !== "string") {
+ if(config.options.chkAnimate && (animate == undefined || animate == true) && anim && typeof Zoomer == "function" && typeof Scroller == "function")
+ anim.startAnimating(new Zoomer(title,srcElement,tiddlerElem),new Scroller(tiddlerElem));
+ else
+ window.scrollTo(0,ensureVisible(tiddlerElem));
+ }
+};
+
+Story.prototype.positionTiddler = function(srcElement)
+{
+ var place = this.getContainer();
+ var before = null;
+ if(typeof srcElement == "string") {
+ switch(srcElement) {
+ case "top":
+ before = place.firstChild;
+ break;
+ case "bottom":
+ before = null;
+ break;
+ }
+ } else {
+ var after = this.findContainingTiddler(srcElement);
+ if(after == null) {
+ before = place.firstChild;
+ } else if(after.nextSibling) {
+ before = after.nextSibling;
+ if(before.nodeType != 1)
+ before = null;
+ }
+ }
+ return before;
+};
+
+Story.prototype.createTiddler = function(place,before,title,template,customFields)
+{
+ var tiddlerElem = createTiddlyElement(null,"div",this.tiddlerId(title),"tiddler");
+ tiddlerElem.setAttribute("refresh","tiddler");
+ if(customFields)
+ tiddlerElem.setAttribute("tiddlyFields",customFields);
+ place.insertBefore(tiddlerElem,before);
+ var defaultText = null;
+ if(!store.tiddlerExists(title) && !store.isShadowTiddler(title))
+ defaultText = this.loadMissingTiddler(title,customFields,tiddlerElem);
+ this.refreshTiddler(title,template,false,customFields,defaultText);
+ return tiddlerElem;
+};
+
+Story.prototype.loadMissingTiddler = function(title,fields,tiddlerElem)
+{
+ var tiddler = new Tiddler(title);
+ tiddler.fields = typeof fields == "string" ? fields.decodeHashMap() : (fields || {});
+ var serverType = tiddler.getServerType();
+ var host = tiddler.fields['server.host'];
+ var workspace = tiddler.fields['server.workspace'];
+ if(!serverType || !host)
+ return null;
+ var sm = new SyncMachine(serverType,{
+ start: function() {
+ return this.openHost(host,"openWorkspace");
+ },
+ openWorkspace: function() {
+ return this.openWorkspace(workspace,"getTiddler");
+ },
+ getTiddler: function() {
+ return this.getTiddler(title,"onGetTiddler");
+ },
+ onGetTiddler: function(context) {
+ var tiddler = context.tiddler;
+ if(tiddler && tiddler.text) {
+ var downloaded = new Date();
+ if(!tiddler.created)
+ tiddler.created = downloaded;
+ if(!tiddler.modified)
+ tiddler.modified = tiddler.created;
+ store.saveTiddler(tiddler.title,tiddler.title,tiddler.text,tiddler.modifier,tiddler.modified,tiddler.tags,tiddler.fields,true,tiddler.created);
+ autoSaveChanges();
+ }
+ delete this;
+ return true;
+ },
+ error: function(message) {
+ displayMessage("Error loading missing tiddler from %0: %1".format([host,message]));
+ }
+ });
+ sm.go();
+ return config.messages.loadingMissingTiddler.format([title,serverType,host,workspace]);
+};
+
+Story.prototype.chooseTemplateForTiddler = function(title,template)
+{
+ if(!template)
+ template = DEFAULT_VIEW_TEMPLATE;
+ if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE)
+ template = config.tiddlerTemplates[template];
+ return template;
+};
+
+Story.prototype.getTemplateForTiddler = function(title,template,tiddler)
+{
+ return store.getRecursiveTiddlerText(template,null,10);
+};
+
+Story.prototype.refreshTiddler = function(title,template,force,customFields,defaultText)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ if(tiddlerElem.getAttribute("dirty") == "true" && !force)
+ return tiddlerElem;
+ template = this.chooseTemplateForTiddler(title,template);
+ var currTemplate = tiddlerElem.getAttribute("template");
+ if((template != currTemplate) || force) {
+ var tiddler = store.getTiddler(title);
+ if(!tiddler) {
+ tiddler = new Tiddler();
+ if(store.isShadowTiddler(title)) {
+ var tags = [];
+ tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,tags,version.date);
+ } else {
+ var text = template=="EditTemplate" ?
+ config.views.editor.defaultText.format([title]) :
+ config.views.wikified.defaultText.format([title]);
+ text = defaultText || text;
+ var fields = customFields ? customFields.decodeHashMap() : null;
+ tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date,fields);
+ }
+ }
+ tiddlerElem.setAttribute("tags",tiddler.tags.join(" "));
+ tiddlerElem.setAttribute("tiddler",title);
+ tiddlerElem.setAttribute("template",template);
+ tiddlerElem.onmouseover = this.onTiddlerMouseOver;
+ tiddlerElem.onmouseout = this.onTiddlerMouseOut;
+ tiddlerElem.ondblclick = this.onTiddlerDblClick;
+ tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress;
+ tiddlerElem.innerHTML = this.getTemplateForTiddler(title,template,tiddler);
+ applyHtmlMacros(tiddlerElem,tiddler);
+ if(store.getTaggedTiddlers(title).length > 0)
+ addClass(tiddlerElem,"isTag");
+ else
+ removeClass(tiddlerElem,"isTag");
+ if(store.tiddlerExists(title)) {
+ removeClass(tiddlerElem,"shadow");
+ removeClass(tiddlerElem,"missing");
+ } else {
+ addClass(tiddlerElem,store.isShadowTiddler(title) ? "shadow" : "missing");
+ }
+ if(customFields)
+ this.addCustomFields(tiddlerElem,customFields);
+ forceReflow();
+ }
+ }
+ return tiddlerElem;
+};
+
+Story.prototype.addCustomFields = function(place,customFields)
+{
+ var fields = customFields.decodeHashMap();
+ var w = document.createElement("div");
+ w.style.display = "none";
+ place.appendChild(w);
+ for(var t in fields) {
+ var e = document.createElement("input");
+ e.setAttribute("type","text");
+ e.setAttribute("value",fields[t]);
+ w.appendChild(e);
+ e.setAttribute("edit",t);
+ }
+};
+
+Story.prototype.refreshAllTiddlers = function(force)
+{
+ var e = this.getContainer().firstChild;
+ while(e) {
+ var template = e.getAttribute("template");
+ if(template && e.getAttribute("dirty") != "true") {
+ this.refreshTiddler(e.getAttribute("tiddler"),force ? null : template,true);
+ }
+ e = e.nextSibling;
+ }
+};
+
+Story.prototype.onTiddlerMouseOver = function(e)
+{
+ if(window.addClass instanceof Function)
+ addClass(this,"selected");
+};
+
+Story.prototype.onTiddlerMouseOut = function(e)
+{
+ if(window.removeClass instanceof Function)
+ removeClass(this,"selected");
+};
+
+Story.prototype.onTiddlerDblClick = function(ev)
+{
+ var e = ev || window.event;
+ var target = resolveTarget(e);
+ if(target && target.nodeName.toLowerCase() != "input" && target.nodeName.toLowerCase() != "textarea") {
+ if(document.selection && document.selection.empty)
+ document.selection.empty();
+ config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return true;
+ }
+ return false;
+};
+
+Story.prototype.onTiddlerKeyPress = function(ev)
+{
+ var e = ev || window.event;
+ clearMessage();
+ var consume = false;
+ var title = this.getAttribute("tiddler");
+ var target = resolveTarget(e);
+ switch(e.keyCode) {
+ case 9: // Tab
+ if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea") {
+ replaceSelection(target,String.fromCharCode(9));
+ consume = true;
+ }
+ if(config.isOpera) {
+ target.onblur = function() {
+ this.focus();
+ this.onblur = null;
+ };
+ }
+ break;
+ case 13: // Ctrl-Enter
+ case 10: // Ctrl-Enter on IE PC
+ case 77: // Ctrl-Enter is "M" on some platforms
+ if(e.ctrlKey) {
+ blurElement(this);
+ config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
+ consume = true;
+ }
+ break;
+ case 27: // Escape
+ blurElement(this);
+ config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
+ consume = true;
+ break;
+ }
+ e.cancelBubble = consume;
+ if(consume) {
+ if(e.stopPropagation) e.stopPropagation(); // Stop Propagation
+ e.returnValue = true; // Cancel The Event in IE
+ if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz
+ }
+ return !consume;
+};
+
+Story.prototype.getTiddlerField = function(title,field)
+{
+ var tiddlerElem = this.getTiddler(title);
+ var e = null;
+ if(tiddlerElem ) {
+ var children = tiddlerElem.getElementsByTagName("*");
+ for(var t=0; t<children.length; t++) {
+ var c = children[t];
+ if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
+ if(!e)
+ e = c;
+ if(c.getAttribute("edit") == field)
+ e = c;
+ }
+ }
+ }
+ return e;
+};
+
+Story.prototype.focusTiddler = function(title,field)
+{
+ var e = this.getTiddlerField(title,field);
+ if(e) {
+ e.focus();
+ e.select();
+ }
+};
+
+Story.prototype.blurTiddler = function(title)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem && tiddlerElem.focus && tiddlerElem.blur) {
+ tiddlerElem.focus();
+ tiddlerElem.blur();
+ }
+};
+
+Story.prototype.setTiddlerField = function(title,tag,mode,field)
+{
+ var c = this.getTiddlerField(title,field);
+ var tags = c.value.readBracketedList();
+ tags.setItem(tag,mode);
+ c.value = String.encodeTiddlyLinkList(tags);
+};
+
+Story.prototype.setTiddlerTag = function(title,tag,mode)
+{
+ this.setTiddlerField(title,tag,mode,"tags");
+};
+
+Story.prototype.closeTiddler = function(title,animate,unused)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ clearMessage();
+ this.scrubTiddler(tiddlerElem);
+ if(config.options.chkAnimate && animate && anim && typeof Slider == "function")
+ anim.startAnimating(new Slider(tiddlerElem,false,null,"all"));
+ else {
+ removeNode(tiddlerElem);
+ forceReflow();
+ }
+ }
+};
+
+Story.prototype.scrubTiddler = function(tiddlerElem)
+{
+ tiddlerElem.id = null;
+};
+
+Story.prototype.setDirty = function(title,dirty)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem)
+ tiddlerElem.setAttribute("dirty",dirty ? "true" : "false");
+};
+
+Story.prototype.isDirty = function(title)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem)
+ return tiddlerElem.getAttribute("dirty") == "true";
+ return null;
+};
+
+Story.prototype.areAnyDirty = function()
+{
+ var r = false;
+ this.forEachTiddler(function(title,element) {
+ if(this.isDirty(title))
+ r = true;
+ });
+ return r;
+};
+
+Story.prototype.closeAllTiddlers = function(exclude)
+{
+ clearMessage();
+ this.forEachTiddler(function(title,element) {
+ if((title != exclude) && element.getAttribute("dirty") != "true")
+ this.closeTiddler(title);
+ });
+ window.scrollTo(0,ensureVisible(this.container));
+};
+
+Story.prototype.isEmpty = function()
+{
+ var place = this.getContainer();
+ return place && place.firstChild == null;
+};
+
+Story.prototype.search = function(text,useCaseSensitive,useRegExp)
+{
+ this.closeAllTiddlers();
+ highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img");
+ var matches = store.search(highlightHack,"title","excludeSearch");
+ this.displayTiddlers(null,matches);
+ highlightHack = null;
+ var q = useRegExp ? "/" : "'";
+ if(matches.length > 0)
+ displayMessage(config.macros.search.successMsg.format([matches.length.toString(),q + text + q]));
+ else
+ displayMessage(config.macros.search.failureMsg.format([q + text + q]));
+};
+
+Story.prototype.findContainingTiddler = function(e)
+{
+ while(e && !hasClass(e,"tiddler"))
+ e = e.parentNode;
+ return e;
+};
+
+Story.prototype.gatherSaveFields = function(e,fields)
+{
+ if(e && e.getAttribute) {
+ var f = e.getAttribute("edit");
+ if(f)
+ fields[f] = e.value.replace(/\r/mg,"");
+ if(e.hasChildNodes()) {
+ var c = e.childNodes;
+ for(var t=0; t<c.length; t++)
+ this.gatherSaveFields(c[t],fields);
+ }
+ }
+};
+
+Story.prototype.hasChanges = function(title)
+{
+ var e = this.getTiddler(title);
+ if(e) {
+ var fields = {};
+ this.gatherSaveFields(e,fields);
+ var tiddler = store.fetchTiddler(title);
+ if(!tiddler)
+ return false;
+ for(var n in fields) {
+ if(store.getValue(title,n) != fields[n])
+ return true;
+ }
+ }
+ return false;
+};
+
+Story.prototype.saveTiddler = function(title,minorUpdate)
+{
+ var tiddlerElem = this.getTiddler(title);
+ if(tiddlerElem) {
+ var fields = {};
+ this.gatherSaveFields(tiddlerElem,fields);
+ var newTitle = fields.title || title;
+ if(!store.tiddlerExists(newTitle))
+ newTitle = newTitle.trim();
+ if(store.tiddlerExists(newTitle) && newTitle != title) {
+ if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
+ return null;
+ }
+ if(newTitle != title)
+ this.closeTiddler(newTitle,false);
+ tiddlerElem.id = this.tiddlerId(newTitle);
+ tiddlerElem.setAttribute("tiddler",newTitle);
+ tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE);
+ tiddlerElem.setAttribute("dirty","false");
+ if(config.options.chkForceMinorUpdate)
+ minorUpdate = !minorUpdate;
+ if(!store.tiddlerExists(newTitle))
+ minorUpdate = false;
+ var newDate = new Date();
+ var extendedFields = store.tiddlerExists(newTitle) ? store.fetchTiddler(newTitle).fields : (newTitle!=title && store.tiddlerExists(title) ? store.fetchTiddler(title).fields : merge({},config.defaultCustomFields));
+ for(var n in fields) {
+ if(!TiddlyWiki.isStandardField(n))
+ extendedFields[n] = fields[n];
+ }
+ var tiddler = store.saveTiddler(title,newTitle,fields.text,minorUpdate ? undefined : config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags,extendedFields);
+ autoSaveChanges(null,[tiddler]);
+ return newTitle;
+ }
+ return null;
+};
+
+Story.prototype.permaView = function()
+{
+ var links = [];
+ this.forEachTiddler(function(title,element) {
+ links.push(String.encodeTiddlyLink(title));
+ });
+ var t = encodeURIComponent(links.join(" "));
+ if(t == "")
+ t = "#";
+ if(window.location.hash != t)
+ window.location.hash = t;
+};
+
+Story.prototype.switchTheme = function(theme)
+{
+ if(safeMode)
+ return;
+
+ var isAvailable = function(title) {
+ var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
+ if(s!=-1)
+ title = title.substr(0,s);
+ return store.tiddlerExists(title) || store.isShadowTiddler(title);
+ };
+
+ var getSlice = function(theme,slice) {
+ var r;
+ if(readOnly)
+ r = store.getTiddlerSlice(theme,slice+"ReadOnly") || store.getTiddlerSlice(theme,"Web"+slice);
+ r = r || store.getTiddlerSlice(theme,slice);
+ if(r && r.indexOf(config.textPrimitives.sectionSeparator)==0)
+ r = theme + r;
+ return isAvailable(r) ? r : slice;
+ };
+
+ var replaceNotification = function(i,name,theme,slice) {
+ var newName = getSlice(theme,slice);
+ if(name!=newName && store.namedNotifications[i].name==name) {
+ store.namedNotifications[i].name = newName;
+ return newName;
+ }
+ return name;
+ };
+
+ var pt = config.refresherData.pageTemplate;
+ var vi = DEFAULT_VIEW_TEMPLATE;
+ var vt = config.tiddlerTemplates[vi];
+ var ei = DEFAULT_EDIT_TEMPLATE;
+ var et = config.tiddlerTemplates[ei];
+
+ for(var i=0; i<config.notifyTiddlers.length; i++) {
+ var name = config.notifyTiddlers[i].name;
+ switch(name) {
+ case "PageTemplate":
+ config.refresherData.pageTemplate = replaceNotification(i,config.refresherData.pageTemplate,theme,name);
+ break;
+ case "StyleSheet":
+ removeStyleSheet(config.refresherData.styleSheet);
+ config.refresherData.styleSheet = replaceNotification(i,config.refresherData.styleSheet,theme,name);
+ break;
+ case "ColorPalette":
+ config.refresherData.colorPalette = replaceNotification(i,config.refresherData.colorPalette,theme,name);
+ break;
+ default:
+ break;
+ }
+ }
+ config.tiddlerTemplates[vi] = getSlice(theme,"ViewTemplate");
+ config.tiddlerTemplates[ei] = getSlice(theme,"EditTemplate");
+ if(!startingUp) {
+ if(config.refresherData.pageTemplate!=pt || config.tiddlerTemplates[vi]!=vt || config.tiddlerTemplates[ei]!=et) {
+ refreshAll();
+ this.refreshAllTiddlers(true);
+ } else {
+ setStylesheet(store.getRecursiveTiddlerText(config.refresherData.styleSheet,"",10),config.refreshers.styleSheet);
+ }
+ config.options.txtTheme = theme;
+ saveOptionCookie("txtTheme");
+ }
+};
+
+//--
+//-- Backstage
+//--
+
+var backstage = {
+ area: null,
+ toolbar: null,
+ button: null,
+ showButton: null,
+ hideButton: null,
+ cloak: null,
+ panel: null,
+ panelBody: null,
+ panelFooter: null,
+ currTabName: null,
+ currTabElem: null,
+ content: null,
+
+ init: function() {
+ var cmb = config.messages.backstage;
+ this.area = document.getElementById("backstageArea");
+ this.toolbar = document.getElementById("backstageToolbar");
+ this.button = document.getElementById("backstageButton");
+ this.button.style.display = "block";
+ var t = cmb.open.text + " " + glyph("bentArrowLeft");
+ this.showButton = createTiddlyButton(this.button,t,cmb.open.tooltip,
+ function(e) {backstage.show(); return false;},null,"backstageShow");
+ t = glyph("bentArrowRight") + " " + cmb.close.text;
+ this.hideButton = createTiddlyButton(this.button,t,cmb.close.tooltip,
+ function(e) {backstage.hide(); return false;},null,"backstageHide");
+ this.cloak = document.getElementById("backstageCloak");
+ this.panel = document.getElementById("backstagePanel");
+ this.panelFooter = createTiddlyElement(this.panel,"div",null,"backstagePanelFooter");
+ this.panelBody = createTiddlyElement(this.panel,"div",null,"backstagePanelBody");
+ this.cloak.onmousedown = function(e) {backstage.switchTab(null);};
+ createTiddlyText(this.toolbar,cmb.prompt);
+ for(t=0; t<config.backstageTasks.length; t++) {
+ var taskName = config.backstageTasks[t];
+ var task = config.tasks[taskName];
+ var handler = task.action ? this.onClickCommand : this.onClickTab;
+ var text = task.text + (task.action ? "" : glyph("downTriangle"));
+ var btn = createTiddlyButton(this.toolbar,text,task.tooltip,handler,"backstageTab");
+ btn.setAttribute("task",taskName);
+ addClass(btn,task.action ? "backstageAction" : "backstageTask");
+ }
+ this.content = document.getElementById("contentWrapper");
+ if(config.options.chkBackstage)
+ this.show();
+ else
+ this.hide();
+ },
+
+ isVisible: function() {
+ return this.area ? this.area.style.display == "block" : false;
+ },
+
+ show: function() {
+ this.area.style.display = "block";
+ if(anim && config.options.chkAnimate) {
+ backstage.toolbar.style.left = findWindowWidth() + "px";
+ var p = [{style: "left", start: findWindowWidth(), end: 0, template: "%0px"}];
+ anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p));
+ } else {
+ backstage.area.style.left = "0px";
+ }
+ this.showButton.style.display = "none";
+ this.hideButton.style.display = "block";
+ config.options.chkBackstage = true;
+ saveOptionCookie("chkBackstage");
+ addClass(this.content,"backstageVisible");
+ },
+
+ hide: function() {
+ if(this.currTabElem) {
+ this.switchTab(null);
+ } else {
+ backstage.toolbar.style.left = "0px";
+ if(anim && config.options.chkAnimate) {
+ var p = [{style: "left", start: 0, end: findWindowWidth(), template: "%0px"}];
+ var c = function(element,properties) {backstage.area.style.display = "none";};
+ anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p,c));
+ } else {
+ this.area.style.display = "none";
+ }
+ this.showButton.style.display = "block";
+ this.hideButton.style.display = "none";
+ config.options.chkBackstage = false;
+ saveOptionCookie("chkBackstage");
+ removeClass(this.content,"backstageVisible");
+ }
+ },
+
+ onClickCommand: function(e) {
+ var task = config.tasks[this.getAttribute("task")];
+ displayMessage(task);
+ if(task.action) {
+ backstage.switchTab(null);
+ task.action();
+ }
+ return false;
+ },
+
+ onClickTab: function(e) {
+ backstage.switchTab(this.getAttribute("task"));
+ return false;
+ },
+
+ // Switch to a given tab, or none if null is passed
+ switchTab: function(tabName) {
+ var tabElem = null;
+ var e = this.toolbar.firstChild;
+ while(e)
+ {
+ if(e.getAttribute && e.getAttribute("task") == tabName)
+ tabElem = e;
+ e = e.nextSibling;
+ }
+ if(tabName == backstage.currTabName)
+ return;
+ if(backstage.currTabElem) {
+ removeClass(this.currTabElem,"backstageSelTab");
+ }
+ if(tabElem && tabName) {
+ backstage.preparePanel();
+ addClass(tabElem,"backstageSelTab");
+ var task = config.tasks[tabName];
+ wikify(task.content,backstage.panelBody,null,null);
+ backstage.showPanel();
+ } else if(backstage.currTabElem) {
+ backstage.hidePanel();
+ }
+ backstage.currTabName = tabName;
+ backstage.currTabElem = tabElem;
+ },
+
+ isPanelVisible: function() {
+ return backstage.panel ? backstage.panel.style.display == "block" : false;
+ },
+
+ preparePanel: function() {
+ backstage.cloak.style.height = findWindowHeight() + "px";
+ backstage.cloak.style.display = "block";
+ removeChildren(backstage.panelBody);
+ return backstage.panelBody;
+ },
+
+ showPanel: function() {
+ backstage.panel.style.display = "block";
+ if(anim && config.options.chkAnimate) {
+ backstage.panel.style.top = (-backstage.panel.offsetHeight) + "px";
+ var p = [{style: "top", start: -backstage.panel.offsetHeight, end: 0, template: "%0px"}];
+ anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p),new Scroller(backstage.panel,false));
+ } else {
+ backstage.panel.style.top = "0px";
+ }
+ return backstage.panelBody;
+ },
+
+ hidePanel: function() {
+ if(backstage.currTabElem)
+ removeClass(backstage.currTabElem,"backstageSelTab");
+ backstage.currTabElem = null;
+ backstage.currTabName = null;
+ if(anim && config.options.chkAnimate) {
+ var p = [
+ {style: "top", start: 0, end: -(backstage.panel.offsetHeight), template: "%0px"},
+ {style: "display", atEnd: "none"}
+ ];
+ var c = function(element,properties) {backstage.cloak.style.display = "none";};
+ anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p,c));
+ } else {
+ backstage.panel.style.display = "none";
+ backstage.cloak.style.display = "none";
+ }
+ }
+};
+
+config.macros.backstage = {};
+
+config.macros.backstage.handler = function(place,macroName,params)
+{
+ var backstageTask = config.tasks[params[0]];
+ if(backstageTask)
+ createTiddlyButton(place,backstageTask.text,backstageTask.tooltip,function(e) {backstage.switchTab(params[0]); return false;});
+};
+
+//--
+//-- ImportTiddlers macro
+//--
+
+config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if(readOnly) {
+ createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning);
+ return;
+ }
+ var w = new Wizard();
+ w.createWizard(place,this.wizardTitle);
+ this.restart(w);
+};
+
+config.macros.importTiddlers.onCancel = function(e)
+{
+ var wizard = new Wizard(this);
+ var place = wizard.clear();
+ config.macros.importTiddlers.restart(wizard);
+ return false;
+};
+
+config.macros.importTiddlers.onClose = function(e)
+{
+ backstage.hidePanel();
+ return false;
+};
+
+config.macros.importTiddlers.restart = function(wizard)
+{
+ wizard.addStep(this.step1Title,this.step1Html);
+ var s = wizard.getElement("selTypes");
+ for(var t in config.adaptors) {
+ var e = createTiddlyElement(s,"option",null,null,config.adaptors[t].serverLabel ? config.adaptors[t].serverLabel : t);
+ e.value = t;
+ }
+ if(config.defaultAdaptor)
+ s.value = config.defaultAdaptor;
+ s = wizard.getElement("selFeeds");
+ var feeds = this.getFeeds();
+ for(t in feeds) {
+ e = createTiddlyElement(s,"option",null,null,t);
+ e.value = t;
+ }
+ wizard.setValue("feeds",feeds);
+ s.onchange = config.macros.importTiddlers.onFeedChange;
+ var fileInput = wizard.getElement("txtBrowse");
+ fileInput.onchange = config.macros.importTiddlers.onBrowseChange;
+ fileInput.onkeyup = config.macros.importTiddlers.onBrowseChange;
+ wizard.setButtons([{caption: this.openLabel, tooltip: this.openPrompt, onClick: config.macros.importTiddlers.onOpen}]);
+ wizard.formElem.action = "javascript:;";
+ wizard.formElem.onsubmit = function() {
+ if(this.txtPath.value.length)
+ this.lastChild.firstChild.onclick();
+ };
+};
+
+config.macros.importTiddlers.getFeeds = function()
+{
+ var feeds = {};
+ var tagged = store.getTaggedTiddlers("systemServer","title");
+ for(var t=0; t<tagged.length; t++) {
+ var title = tagged[t].title;
+ var serverType = store.getTiddlerSlice(title,"Type");
+ if(!serverType)
+ serverType = "file";
+ feeds[title] = {title: title,
+ url: store.getTiddlerSlice(title,"URL"),
+ workspace: store.getTiddlerSlice(title,"Workspace"),
+ workspaceList: store.getTiddlerSlice(title,"WorkspaceList"),
+ tiddlerFilter: store.getTiddlerSlice(title,"TiddlerFilter"),
+ serverType: serverType,
+ description: store.getTiddlerSlice(title,"Description")};
+ }
+ return feeds;
+};
+
+config.macros.importTiddlers.onFeedChange = function(e)
+{
+ var wizard = new Wizard(this);
+ var selTypes = wizard.getElement("selTypes");
+ var fileInput = wizard.getElement("txtPath");
+ var feeds = wizard.getValue("feeds");
+ var f = feeds[this.value];
+ if(f) {
+ selTypes.value = f.serverType;
+ fileInput.value = f.url;
+ wizard.setValue("feedName",f.serverType);
+ wizard.setValue("feedHost",f.url);
+ wizard.setValue("feedWorkspace",f.workspace);
+ wizard.setValue("feedWorkspaceList",f.workspaceList);
+ wizard.setValue("feedTiddlerFilter",f.tiddlerFilter);
+ }
+ return false;
+};
+
+config.macros.importTiddlers.onBrowseChange = function(e)
+{
+ var wizard = new Wizard(this);
+ var fileInput = wizard.getElement("txtPath");
+ fileInput.value = config.macros.importTiddlers.getURLFromLocalPath(this.value);
+ var serverType = wizard.getElement("selTypes");
+ serverType.value = "file";
+ return true;
+};
+
+config.macros.importTiddlers.getURLFromLocalPath = function(v)
+{
+ if(!v||!v.length)
+ return v;
+ v = v.replace(/\\/g,"/"); // use "/" for cross-platform consistency
+ var u;
+ var t = v.split(":");
+ var p = t[1]||t[0]; // remove drive letter (if any)
+ if (t[1] && (t[0]=="http"||t[0]=="https"||t[0]=="file")) {
+ u = v;
+ } else if(p.substr(0,1)=="/") {
+ u = document.location.protocol + "//" + document.location.hostname + (t[1] ? "/" : "") + v;
+ } else {
+ var c = document.location.href.replace(/\\/g,"/");
+ var pos = c.lastIndexOf("/");
+ if (pos!=-1)
+ c = c.substr(0,pos); // remove filename
+ u = c + "/" + p;
+ }
+ return u;
+};
+
+config.macros.importTiddlers.onOpen = function(e)
+{
+ var wizard = new Wizard(this);
+ var fileInput = wizard.getElement("txtPath");
+ var url = fileInput.value;
+ var serverType = wizard.getElement("selTypes").value || config.defaultAdaptor;
+ var adaptor = new config.adaptors[serverType]();
+ wizard.setValue("adaptor",adaptor);
+ wizard.setValue("serverType",serverType);
+ wizard.setValue("host",url);
+ var ret = adaptor.openHost(url,null,wizard,config.macros.importTiddlers.onOpenHost);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenHost);
+ return false;
+};
+
+config.macros.importTiddlers.onOpenHost = function(context,wizard)
+{
+ var adaptor = wizard.getValue("adaptor");
+ if(context.status !== true)
+ displayMessage("Error in importTiddlers.onOpenHost: " + context.statusText);
+ var ret = adaptor.getWorkspaceList(context,wizard,config.macros.importTiddlers.onGetWorkspaceList);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetWorkspaceList);
+};
+
+config.macros.importTiddlers.onGetWorkspaceList = function(context,wizard)
+{
+ if(context.status !== true)
+ displayMessage("Error in importTiddlers.onGetWorkspaceList: " + context.statusText);
+ wizard.setValue("context",context);
+ var workspace = wizard.getValue("feedWorkspace");
+ if(!workspace && context.workspaces.length==1)
+ workspace = context.workspaces[0].title;
+ if(workspace) {
+ var ret = context.adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setValue("workspace",workspace);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
+ return;
+ }
+ wizard.addStep(config.macros.importTiddlers.step2Title,config.macros.importTiddlers.step2Html);
+ var s = wizard.getElement("selWorkspace");
+ s.onchange = config.macros.importTiddlers.onWorkspaceChange;
+ for(var t=0; t<context.workspaces.length; t++) {
+ var e = createTiddlyElement(s,"option",null,null,context.workspaces[t].title);
+ e.value = context.workspaces[t].title;
+ }
+ var workspaceList = wizard.getValue("feedWorkspaceList");
+ if(workspaceList) {
+ var list = workspaceList.parseParams("workspace",null,false,true);
+ for(var n=1; n<list.length; n++) {
+ if(context.workspaces.findByField("title",list[n].value) == null) {
+ e = createTiddlyElement(s,"option",null,null,list[n].value);
+ e.value = list[n].value;
+ }
+ }
+ }
+ if(workspace) {
+ t = wizard.getElement("txtWorkspace");
+ t.value = workspace;
+ }
+ wizard.setButtons([{caption: config.macros.importTiddlers.openLabel, tooltip: config.macros.importTiddlers.openPrompt, onClick: config.macros.importTiddlers.onChooseWorkspace}]);
+};
+
+config.macros.importTiddlers.onWorkspaceChange = function(e)
+{
+ var wizard = new Wizard(this);
+ var t = wizard.getElement("txtWorkspace");
+ t.value = this.value;
+ this.selectedIndex = 0;
+ return false;
+};
+
+config.macros.importTiddlers.onChooseWorkspace = function(e)
+{
+ var wizard = new Wizard(this);
+ var adaptor = wizard.getValue("adaptor");
+ var workspace = wizard.getElement("txtWorkspace").value;
+ wizard.setValue("workspace",workspace);
+ var context = wizard.getValue("context");
+ var ret = adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
+ return false;
+};
+
+config.macros.importTiddlers.onOpenWorkspace = function(context,wizard)
+{
+ if(context.status !== true)
+ displayMessage("Error in importTiddlers.onOpenWorkspace: " + context.statusText);
+ var adaptor = wizard.getValue("adaptor");
+ var ret = adaptor.getTiddlerList(context,wizard,config.macros.importTiddlers.onGetTiddlerList,wizard.getValue("feedTiddlerFilter"));
+ if(ret !== true)
+ displayMessage(ret);
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetTiddlerList);
+};
+
+config.macros.importTiddlers.onGetTiddlerList = function(context,wizard)
+{
+ if(context.status !== true) {
+ wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.errorGettingTiddlerList);
+ return;
+ }
+ // Extract data for the listview
+ var listedTiddlers = [];
+ if(context.tiddlers) {
+ for(var n=0; n<context.tiddlers.length; n++) {
+ var tiddler = context.tiddlers[n];
+ listedTiddlers.push({
+ title: tiddler.title,
+ modified: tiddler.modified,
+ modifier: tiddler.modifier,
+ text: tiddler.text ? wikifyPlainText(tiddler.text,100) : "",
+ tags: tiddler.tags,
+ size: tiddler.text ? tiddler.text.length : 0,
+ tiddler: tiddler
+ });
+ }
+ }
+ listedTiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
+ // Display the listview
+ wizard.addStep(config.macros.importTiddlers.step3Title,config.macros.importTiddlers.step3Html);
+ var markList = wizard.getElement("markList");
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ var listView = ListView.create(listWrapper,listedTiddlers,config.macros.importTiddlers.listViewTemplate);
+ wizard.setValue("listView",listView);
+ wizard.setValue("context",context);
+ var txtSaveTiddler = wizard.getElement("txtSaveTiddler");
+ txtSaveTiddler.value = config.macros.importTiddlers.generateSystemServerName(wizard);
+ wizard.setButtons([
+ {caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel},
+ {caption: config.macros.importTiddlers.importLabel, tooltip: config.macros.importTiddlers.importPrompt, onClick: config.macros.importTiddlers.doImport}
+ ]);
+};
+
+config.macros.importTiddlers.generateSystemServerName = function(wizard)
+{
+ var serverType = wizard.getValue("serverType");
+ var host = wizard.getValue("host");
+ var workspace = wizard.getValue("workspace");
+ var pattern = config.macros.importTiddlers[workspace ? "systemServerNamePattern" : "systemServerNamePatternNoWorkspace"];
+ return pattern.format([serverType,host,workspace]);
+};
+
+config.macros.importTiddlers.saveServerTiddler = function(wizard)
+{
+ var txtSaveTiddler = wizard.getElement("txtSaveTiddler").value;
+ if(store.tiddlerExists(txtSaveTiddler)) {
+ if(!confirm(config.macros.importTiddlers.confirmOverwriteSaveTiddler.format([txtSaveTiddler])))
+ return;
+ store.suspendNotifications();
+ store.removeTiddler(txtSaveTiddler);
+ store.resumeNotifications();
+ }
+ var serverType = wizard.getValue("serverType");
+ var host = wizard.getValue("host");
+ var workspace = wizard.getValue("workspace");
+ var text = config.macros.importTiddlers.serverSaveTemplate.format([serverType,host,workspace]);
+ store.saveTiddler(txtSaveTiddler,txtSaveTiddler,text,config.macros.importTiddlers.serverSaveModifier,new Date(),["systemServer"]);
+};
+
+config.macros.importTiddlers.doImport = function(e)
+{
+ var wizard = new Wizard(this);
+ if(wizard.getElement("chkSave").checked)
+ config.macros.importTiddlers.saveServerTiddler(wizard);
+ var chkSync = wizard.getElement("chkSync").checked;
+ wizard.setValue("sync",chkSync);
+ var listView = wizard.getValue("listView");
+ var rowNames = ListView.getSelectedRows(listView);
+ var adaptor = wizard.getValue("adaptor");
+ var overwrite = [];
+ var t;
+ for(t=0; t<rowNames.length; t++) {
+ if(store.tiddlerExists(rowNames[t]))
+ overwrite.push(rowNames[t]);
+ }
+ if(overwrite.length > 0) {
+ if(!confirm(config.macros.importTiddlers.confirmOverwriteText.format([overwrite.join(", ")])))
+ return false;
+ }
+ wizard.addStep(config.macros.importTiddlers.step4Title.format([rowNames.length]),config.macros.importTiddlers.step4Html);
+ for(t=0; t<rowNames.length; t++) {
+ var link = document.createElement("div");
+ createTiddlyLink(link,rowNames[t],true);
+ var place = wizard.getElement("markReport");
+ place.parentNode.insertBefore(link,place);
+ }
+ wizard.setValue("remainingImports",rowNames.length);
+ wizard.setButtons([
+ {caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}
+ ],config.macros.importTiddlers.statusDoingImport);
+ var wizardContext = wizard.getValue("context");
+ var tiddlers = wizardContext ? wizardContext.tiddlers : [];
+ for(t=0; t<rowNames.length; t++) {
+ var context = {
+ allowSynchronous:true,
+ tiddler:tiddlers[tiddlers.findByField("title",rowNames[t])]
+ };
+ adaptor.getTiddler(rowNames[t],context,wizard,config.macros.importTiddlers.onGetTiddler);
+ }
+ return false;
+};
+
+config.macros.importTiddlers.onGetTiddler = function(context,wizard)
+{
+ if(!context.status)
+ displayMessage("Error in importTiddlers.onGetTiddler: " + context.statusText);
+ var tiddler = context.tiddler;
+ store.suspendNotifications();
+ store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
+ if(!wizard.getValue("sync")) {
+ store.setValue(tiddler.title,'server',null);
+ }
+ store.resumeNotifications();
+ if(!context.isSynchronous)
+ store.notify(tiddler.title,true);
+ var remainingImports = wizard.getValue("remainingImports")-1;
+ wizard.setValue("remainingImports",remainingImports);
+ if(remainingImports == 0) {
+ if(context.isSynchronous) {
+ store.notifyAll();
+ refreshDisplay();
+ }
+ wizard.setButtons([
+ {caption: config.macros.importTiddlers.doneLabel, tooltip: config.macros.importTiddlers.donePrompt, onClick: config.macros.importTiddlers.onClose}
+ ],config.macros.importTiddlers.statusDoneImport);
+ autoSaveChanges();
+ }
+};
+
+//--
+//-- Upgrade macro
+//--
+
+config.macros.upgrade.handler = function(place)
+{
+ var w = new Wizard();
+ w.createWizard(place,this.wizardTitle);
+ w.addStep(this.step1Title,this.step1Html.format([this.source,this.source]));
+ w.setButtons([{caption: this.upgradeLabel, tooltip: this.upgradePrompt, onClick: this.onClickUpgrade}]);
+};
+
+config.macros.upgrade.onClickUpgrade = function(e)
+{
+ var me = config.macros.upgrade;
+ var w = new Wizard(this);
+ if(window.location.protocol != "file:") {
+ alert(me.errorCantUpgrade);
+ return false;
+ }
+ if(story.areAnyDirty() || store.isDirty()) {
+ alert(me.errorNotSaved);
+ return false;
+ }
+ var localPath = getLocalPath(document.location.toString());
+ var backupPath = getBackupPath(localPath,me.backupExtension);
+ w.setValue("backupPath",backupPath);
+ w.setButtons([],me.statusPreparingBackup);
+ var original = loadOriginal(localPath);
+ w.setButtons([],me.statusSavingBackup);
+ var backup = config.browser.isIE ? ieCopyFile(backupPath,localPath) : saveFile(backupPath,original);
+ if(backup != true) {
+ w.setButtons([],me.errorSavingBackup);
+ alert(me.errorSavingBackup);
+ return false;
+ }
+ w.setButtons([],me.statusLoadingCore);
+ var load = loadRemoteFile(me.source,me.onLoadCore,w);
+ if(typeof load == "string") {
+ w.setButtons([],me.errorLoadingCore);
+ alert(me.errorLoadingCore);
+ return false;
+ }
+ return false;
+};
+
+config.macros.upgrade.onLoadCore = function(status,params,responseText,url,xhr)
+{
+ var me = config.macros.upgrade;
+ var w = params;
+ var errMsg;
+ if(!status)
+ errMsg = me.errorLoadingCore;
+ var newVer = me.extractVersion(responseText);
+ if(!newVer)
+ errMsg = me.errorCoreFormat;
+ if(errMsg) {
+ w.setButtons([],errMsg);
+ alert(errMsg);
+ return;
+ }
+ var onStartUpgrade = function(e) {
+ w.setButtons([],me.statusSavingCore);
+ var localPath = getLocalPath(document.location.toString());
+ saveFile(localPath,responseText);
+ w.setButtons([],me.statusReloadingCore);
+ var backupPath = w.getValue("backupPath");
+ var newLoc = document.location.toString() + '?time=' + new Date().convertToYYYYMMDDHHMM() + '#upgrade:[[' + encodeURI(backupPath) + ']]';
+ window.setTimeout(function () {window.location = newLoc;},10);
+ };
+ var step2 = [me.step2Html_downgrade,me.step2Html_restore,me.step2Html_upgrade][compareVersions(version,newVer) + 1];
+ w.addStep(me.step2Title,step2.format([formatVersion(newVer),formatVersion(version)]));
+ w.setButtons([{caption: me.startLabel, tooltip: me.startPrompt, onClick: onStartUpgrade},{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}]);
+};
+
+config.macros.upgrade.onCancel = function(e)
+{
+ var me = config.macros.upgrade;
+ var w = new Wizard(this);
+ w.addStep(me.step3Title,me.step3Html);
+ w.setButtons([]);
+ return false;
+};
+
+config.macros.upgrade.extractVersion = function(upgradeFile)
+{
+ var re = /^var version = \{title: "([^"]+)", major: (\d+), minor: (\d+), revision: (\d+)(, beta: (\d+)){0,1}, date: new Date\("([^"]+)"\)/mg;
+ var m = re.exec(upgradeFile);
+ return m ? {title: m[1], major: m[2], minor: m[3], revision: m[4], beta: m[6], date: new Date(m[7])} : null;
+};
+
+function upgradeFrom(path)
+{
+ var importStore = new TiddlyWiki();
+ var tw = loadFile(path);
+ if(window.netscape !== undefined)
+ tw = convertUTF8ToUnicode(tw);
+ importStore.importTiddlyWiki(tw);
+ importStore.forEachTiddler(function(title,tiddler) {
+ if(!store.getTiddler(title)) {
+ store.addTiddler(tiddler);
+ }
+ });
+ refreshDisplay();
+ saveChanges(); //# To create appropriate Markup* sections
+ alert(config.messages.upgradeDone.format([formatVersion()]));
+ window.location = window.location.toString().substr(0,window.location.toString().lastIndexOf('?'));
+}
+
+//--
+//-- Sync macro
+//--
+
+// Synchronisation handlers
+config.syncers = {};
+
+// Sync state.
+var currSync = null;
+
+// sync macro
+config.macros.sync.handler = function(place,macroName,params,wikifier,paramString,tiddler)
+{
+ if(!wikifier.isStatic)
+ this.startSync(place);
+};
+
+config.macros.sync.cancelSync = function()
+{
+ currSync = null;
+};
+
+config.macros.sync.startSync = function(place)
+{
+ if(currSync)
+ config.macros.sync.cancelSync();
+ currSync = {};
+ currSync.syncList = this.getSyncableTiddlers();
+ currSync.syncTasks = this.createSyncTasks(currSync.syncList);
+ this.preProcessSyncableTiddlers(currSync.syncList);
+ var wizard = new Wizard();
+ currSync.wizard = wizard;
+ wizard.createWizard(place,this.wizardTitle);
+ wizard.addStep(this.step1Title,this.step1Html);
+ var markList = wizard.getElement("markList");
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ currSync.listView = ListView.create(listWrapper,currSync.syncList,this.listViewTemplate);
+ this.processSyncableTiddlers(currSync.syncList);
+ wizard.setButtons([{caption: this.syncLabel, tooltip: this.syncPrompt, onClick: this.doSync}]);
+};
+
+config.macros.sync.getSyncableTiddlers = function()
+{
+ var list = [];
+ store.forEachTiddler(function(title,tiddler) {
+ var syncItem = {};
+ syncItem.serverType = tiddler.getServerType();
+ syncItem.serverHost = tiddler.fields['server.host'];
+ if(syncItem.serverType && syncItem.serverHost) {
+ syncItem.serverWorkspace = tiddler.fields['server.workspace'];
+ syncItem.tiddler = tiddler;
+ syncItem.title = tiddler.title;
+ syncItem.isTouched = tiddler.isTouched();
+ syncItem.selected = syncItem.isTouched;
+ syncItem.syncStatus = config.macros.sync.syncStatusList[syncItem.isTouched ? "changedLocally" : "none"];
+ syncItem.status = syncItem.syncStatus.text;
+ list.push(syncItem);
+ }
+ });
+ list.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
+ return list;
+};
+
+config.macros.sync.preProcessSyncableTiddlers = function(syncList)
+{
+ for(var i=0; i<syncList.length; i++) {
+ var si = syncList[i];
+ si.serverUrl = si.syncTask.syncMachine.generateTiddlerInfo(si.tiddler).uri;
+ }
+};
+
+config.macros.sync.processSyncableTiddlers = function(syncList)
+{
+ for(var i=0; i<syncList.length; i++) {
+ var si = syncList[i];
+ if(si.syncStatus.display)
+ si.rowElement.style.display = si.syncStatus.display;
+ if(si.syncStatus.className)
+ si.rowElement.className = si.syncStatus.className;
+ }
+};
+
+config.macros.sync.createSyncTasks = function(syncList)
+{
+ var syncTasks = [];
+ for(var i=0; i<syncList.length; i++) {
+ var si = syncList[i];
+ var r = null;
+ for(var j=0; j<syncTasks.length; j++) {
+ var cst = syncTasks[j];
+ if(si.serverType == cst.serverType && si.serverHost == cst.serverHost && si.serverWorkspace == cst.serverWorkspace)
+ r = cst;
+ }
+ if(r) {
+ si.syncTask = r;
+ r.syncItems.push(si);
+ } else {
+ si.syncTask = this.createSyncTask(si);
+ syncTasks.push(si.syncTask);
+ }
+ }
+ return syncTasks;
+};
+
+config.macros.sync.createSyncTask = function(syncItem)
+{
+ var st = {};
+ st.serverType = syncItem.serverType;
+ st.serverHost = syncItem.serverHost;
+ st.serverWorkspace = syncItem.serverWorkspace;
+ st.syncItems = [syncItem];
+ st.syncMachine = new SyncMachine(st.serverType,{
+ start: function() {
+ return this.openHost(st.serverHost,"openWorkspace");
+ },
+ openWorkspace: function() {
+ return this.openWorkspace(st.serverWorkspace,"getTiddlerList");
+ },
+ getTiddlerList: function() {
+ return this.getTiddlerList("onGetTiddlerList");
+ },
+ onGetTiddlerList: function(context) {
+ var tiddlers = context.tiddlers;
+ for(var i=0; i<st.syncItems.length; i++) {
+ var si = st.syncItems[i];
+ var f = tiddlers.findByField("title",si.title);
+ if(f !== null) {
+ if(tiddlers[f].fields['server.page.revision'] > si.tiddler.fields['server.page.revision']) {
+ si.syncStatus = config.macros.sync.syncStatusList[si.isTouched ? 'changedBoth' : 'changedServer'];
+ }
+ } else {
+ si.syncStatus = config.macros.sync.syncStatusList.notFound;
+ }
+ config.macros.sync.updateSyncStatus(si);
+ }
+ },
+ getTiddler: function(title) {
+ return this.getTiddler(title,"onGetTiddler");
+ },
+ onGetTiddler: function(context) {
+ var tiddler = context.tiddler;
+ var syncItem = st.syncItems.findByField("title",tiddler.title);
+ if(syncItem !== null) {
+ syncItem = st.syncItems[syncItem];
+ store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
+ syncItem.syncStatus = config.macros.sync.syncStatusList.gotFromServer;
+ config.macros.sync.updateSyncStatus(syncItem);
+ }
+ },
+ putTiddler: function(tiddler) {
+ return this.putTiddler(tiddler,"onPutTiddler");
+ },
+ onPutTiddler: function(context) {
+ var title = context.title;
+ var syncItem = st.syncItems.findByField("title",title);
+ if(syncItem !== null) {
+ syncItem = st.syncItems[syncItem];
+ store.resetTiddler(title);
+ if(context.status) {
+ syncItem.syncStatus = config.macros.sync.syncStatusList.putToServer;
+ config.macros.sync.updateSyncStatus(syncItem);
+ }
+ }
+ }
+ });
+ st.syncMachine.go();
+ return st;
+};
+
+config.macros.sync.updateSyncStatus = function(syncItem)
+{
+ var e = syncItem.colElements["status"];
+ removeChildren(e);
+ createTiddlyText(e,syncItem.syncStatus.text);
+ if(syncItem.syncStatus.display)
+ syncItem.rowElement.style.display = syncItem.syncStatus.display;
+ if(syncItem.syncStatus.className)
+ syncItem.rowElement.className = syncItem.syncStatus.className;
+};
+
+config.macros.sync.doSync = function(e)
+{
+ var rowNames = ListView.getSelectedRows(currSync.listView);
+ var sl = config.macros.sync.syncStatusList;
+ for(var i=0; i<currSync.syncList.length; i++) {
+ var si = currSync.syncList[i];
+ if(rowNames.indexOf(si.title) != -1) {
+ var r = true;
+ switch(si.syncStatus) {
+ case sl.changedServer:
+ r = si.syncTask.syncMachine.go("getTiddler",si.title);
+ break;
+ case sl.notFound:
+ case sl.changedLocally:
+ case sl.changedBoth:
+ r = si.syncTask.syncMachine.go("putTiddler",si.tiddler);
+ break;
+ default:
+ break;
+ }
+ if(!r)
+ displayMessage("Error in doSync: " + r);
+ }
+ }
+ return false;
+};
+
+function SyncMachine(serverType,steps)
+{
+ this.serverType = serverType;
+ this.adaptor = new config.adaptors[serverType]();
+ this.steps = steps;
+}
+
+SyncMachine.prototype.go = function(step,context)
+{
+ var r = context ? context.status : null;
+ if(typeof r == "string") {
+ this.invokeError(r);
+ return r;
+ }
+ var h = this.steps[step ? step : "start"];
+ if(!h)
+ return null;
+ r = h.call(this,context);
+ if(typeof r == "string")
+ this.invokeError(r);
+ return r;
+};
+
+SyncMachine.prototype.invokeError = function(message)
+{
+ if(this.steps.error)
+ this.steps.error(message);
+};
+
+SyncMachine.prototype.openHost = function(host,nextStep)
+{
+ var me = this;
+ return me.adaptor.openHost(host,null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.getWorkspaceList = function(nextStep)
+{
+ var me = this;
+ return me.adaptor.getWorkspaceList(null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.openWorkspace = function(workspace,nextStep)
+{
+ var me = this;
+ return me.adaptor.openWorkspace(workspace,null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.getTiddlerList = function(nextStep)
+{
+ var me = this;
+ return me.adaptor.getTiddlerList(null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.generateTiddlerInfo = function(tiddler)
+{
+ return this.adaptor.generateTiddlerInfo(tiddler);
+};
+
+SyncMachine.prototype.getTiddler = function(title,nextStep)
+{
+ var me = this;
+ return me.adaptor.getTiddler(title,null,null,function(context) {me.go(nextStep,context);});
+};
+
+SyncMachine.prototype.putTiddler = function(tiddler,nextStep)
+{
+ var me = this;
+ if(me.adaptor.putTiddler)
+ return me.adaptor.putTiddler(tiddler,null,null,function(context) {me.go(nextStep,context);});
+ return false;
+};
+
+//--
+//-- Manager UI for groups of tiddlers
+//--
+
+config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString)
+{
+ var wizard = new Wizard();
+ wizard.createWizard(place,this.wizardTitle);
+ wizard.addStep(this.step1Title,this.step1Html);
+ var markList = wizard.getElement("markList");
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ listWrapper.setAttribute("refresh","macro");
+ listWrapper.setAttribute("macroName","plugins");
+ listWrapper.setAttribute("params",paramString);
+ this.refresh(listWrapper,paramString);
+};
+
+config.macros.plugins.refresh = function(listWrapper,params)
+{
+ var wizard = new Wizard(listWrapper);
+ var selectedRows = [];
+ ListView.forEachSelector(listWrapper,function(e,rowName) {
+ if(e.checked)
+ selectedRows.push(e.getAttribute("rowName"));
+ });
+ removeChildren(listWrapper);
+ params = params.parseParams("anon");
+ var plugins = installedPlugins.slice(0);
+ var t,tiddler,p;
+ var configTiddlers = store.getTaggedTiddlers("systemConfig");
+ for(t=0; t<configTiddlers.length; t++) {
+ tiddler = configTiddlers[t];
+ if(plugins.findByField("title",tiddler.title) == null) {
+ p = getPluginInfo(tiddler);
+ p.executed = false;
+ p.log.splice(0,0,this.skippedText);
+ plugins.push(p);
+ }
+ }
+ for(t=0; t<plugins.length; t++) {
+ p = plugins[t];
+ p.size = p.tiddler.text ? p.tiddler.text.length : 0;
+ p.forced = p.tiddler.isTagged("systemConfigForce");
+ p.disabled = p.tiddler.isTagged("systemConfigDisable");
+ p.Selected = selectedRows.indexOf(plugins[t].title) != -1;
+ p.desc = store.getTiddlerSlice(p.tiddler.title,"Description");
+ }
+ if(plugins.length == 0) {
+ createTiddlyElement(listWrapper,"em",null,null,this.noPluginText);
+ wizard.setButtons([]);
+ } else {
+ var listView = ListView.create(listWrapper,plugins,this.listViewTemplate,this.onSelectCommand);
+ wizard.setValue("listView",listView);
+ wizard.setButtons([
+ {caption: config.macros.plugins.removeLabel, tooltip: config.macros.plugins.removePrompt, onClick: config.macros.plugins.doRemoveTag},
+ {caption: config.macros.plugins.deleteLabel, tooltip: config.macros.plugins.deletePrompt, onClick: config.macros.plugins.doDelete}
+ ]);
+ }
+};
+
+config.macros.plugins.doRemoveTag = function(e)
+{
+ var wizard = new Wizard(this);
+ var listView = wizard.getValue("listView");
+ var rowNames = ListView.getSelectedRows(listView);
+ if(rowNames.length == 0) {
+ alert(config.messages.nothingSelected);
+ } else {
+ for(var t=0; t<rowNames.length; t++)
+ store.setTiddlerTag(rowNames[t],false,"systemConfig");
+ }
+};
+
+config.macros.plugins.doDelete = function(e)
+{
+ var wizard = new Wizard(this);
+ var listView = wizard.getValue("listView");
+ var rowNames = ListView.getSelectedRows(listView);
+ if(rowNames.length == 0) {
+ alert(config.messages.nothingSelected);
+ } else {
+ if(confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")]))) {
+ for(var t=0; t<rowNames.length; t++) {
+ store.removeTiddler(rowNames[t]);
+ story.closeTiddler(rowNames[t],true);
+ }
+ }
+ }
+};
+
+//--
+//-- Message area
+//--
+
+function getMessageDiv()
+{
+ var msgArea = document.getElementById("messageArea");
+ if(!msgArea)
+ return null;
+ if(!msgArea.hasChildNodes())
+ createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"),
+ config.messages.messageClose.text,
+ config.messages.messageClose.tooltip,
+ clearMessage);
+ msgArea.style.display = "block";
+ return createTiddlyElement(msgArea,"div");
+}
+
+function displayMessage(text,linkText)
+{
+ var e = getMessageDiv();
+ if(!e) {
+ alert(text);
+ return;
+ }
+ if(linkText) {
+ var link = createTiddlyElement(e,"a",null,null,text);
+ link.href = linkText;
+ link.target = "_blank";
+ } else {
+ e.appendChild(document.createTextNode(text));
+ }
+}
+
+function clearMessage()
+{
+ var msgArea = document.getElementById("messageArea");
+ if(msgArea) {
+ removeChildren(msgArea);
+ msgArea.style.display = "none";
+ }
+ return false;
+}
+
+//--
+//-- Refresh mechanism
+//--
+
+config.notifyTiddlers = [
+ {name: "StyleSheetLayout", notify: refreshStyles},
+ {name: "StyleSheetColors", notify: refreshStyles},
+ {name: "StyleSheet", notify: refreshStyles},
+ {name: "StyleSheetPrint", notify: refreshStyles},
+ {name: "PageTemplate", notify: refreshPageTemplate},
+ {name: "SiteTitle", notify: refreshPageTitle},
+ {name: "SiteSubtitle", notify: refreshPageTitle},
+ {name: "ColorPalette", notify: refreshColorPalette},
+ {name: null, notify: refreshDisplay}
+];
+
+config.refreshers = {
+ link: function(e,changeList)
+ {
+ var title = e.getAttribute("tiddlyLink");
+ refreshTiddlyLink(e,title);
+ return true;
+ },
+
+ tiddler: function(e,changeList)
+ {
+ var title = e.getAttribute("tiddler");
+ var template = e.getAttribute("template");
+ if(changeList && changeList.indexOf(title) != -1 && !story.isDirty(title))
+ story.refreshTiddler(title,template,true);
+ else
+ refreshElements(e,changeList);
+ return true;
+ },
+
+ content: function(e,changeList)
+ {
+ var title = e.getAttribute("tiddler");
+ var force = e.getAttribute("force");
+ if(force != null || changeList == null || changeList.indexOf(title) != -1) {
+ removeChildren(e);
+ wikify(store.getTiddlerText(title,""),e,null,store.fetchTiddler(title));
+ return true;
+ } else
+ return false;
+ },
+
+ macro: function(e,changeList)
+ {
+ var macro = e.getAttribute("macroName");
+ var params = e.getAttribute("params");
+ if(macro)
+ macro = config.macros[macro];
+ if(macro && macro.refresh)
+ macro.refresh(e,params);
+ return true;
+ }
+};
+
+config.refresherData = {
+ styleSheet: "StyleSheet",
+ defaultStyleSheet: "StyleSheet",
+ pageTemplate: "PageTemplate",
+ defaultPageTemplate: "PageTemplate",
+ colorPalette: "ColorPalette",
+ defaultColorPalette: "ColorPalette"
+};
+
+function refreshElements(root,changeList)
+{
+ var nodes = root.childNodes;
+ for(var c=0; c<nodes.length; c++) {
+ var e = nodes[c], type = null;
+ if(e.getAttribute && (e.tagName ? e.tagName != "IFRAME" : true))
+ type = e.getAttribute("refresh");
+ var refresher = config.refreshers[type];
+ var refreshed = false;
+ if(refresher != undefined)
+ refreshed = refresher(e,changeList);
+ if(e.hasChildNodes() && !refreshed)
+ refreshElements(e,changeList);
+ }
+}
+
+function applyHtmlMacros(root,tiddler)
+{
+ var e = root.firstChild;
+ while(e) {
+ var nextChild = e.nextSibling;
+ if(e.getAttribute) {
+ var macro = e.getAttribute("macro");
+ if(macro) {
+ e.removeAttribute("macro");
+ var params = "";
+ var p = macro.indexOf(" ");
+ if(p != -1) {
+ params = macro.substr(p+1);
+ macro = macro.substr(0,p);
+ }
+ invokeMacro(e,macro,params,null,tiddler);
+ }
+ }
+ if(e.hasChildNodes())
+ applyHtmlMacros(e,tiddler);
+ e = nextChild;
+ }
+}
+
+function refreshPageTemplate(title)
+{
+ var stash = createTiddlyElement(document.body,"div");
+ stash.style.display = "none";
+ var display = story.getContainer();
+ var nodes,t;
+ if(display) {
+ nodes = display.childNodes;
+ for(t=nodes.length-1; t>=0; t--)
+ stash.appendChild(nodes[t]);
+ }
+ var wrapper = document.getElementById("contentWrapper");
+
+ var isAvailable = function(title) {
+ var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
+ if(s!=-1)
+ title = title.substr(0,s);
+ return store.tiddlerExists(title) || store.isShadowTiddler(title);
+ };
+ if(!title || !isAvailable(title))
+ title = config.refresherData.pageTemplate;
+ if(!isAvailable(title))
+ title = config.refresherData.defaultPageTemplate; //# this one is always avaialable
+ wrapper.innerHTML = store.getRecursiveTiddlerText(title,null,10);
+ applyHtmlMacros(wrapper);
+ refreshElements(wrapper);
+ display = story.getContainer();
+ removeChildren(display);
+ if(!display)
+ display = createTiddlyElement(wrapper,"div",story.containerId());
+ nodes = stash.childNodes;
+ for(t=nodes.length-1; t>=0; t--)
+ display.appendChild(nodes[t]);
+ removeNode(stash);
+}
+
+function refreshDisplay(hint)
+{
+ if(typeof hint == "string")
+ hint = [hint];
+ var e = document.getElementById("contentWrapper");
+ refreshElements(e,hint);
+ if(backstage.isPanelVisible()) {
+ e = document.getElementById("backstage");
+ refreshElements(e,hint);
+ }
+}
+
+function refreshPageTitle()
+{
+ document.title = getPageTitle();
+}
+
+function getPageTitle()
+{
+ var st = wikifyPlain("SiteTitle");
+ var ss = wikifyPlain("SiteSubtitle");
+ return st + ((st == "" || ss == "") ? "" : " - ") + ss;
+}
+
+function refreshStyles(title,doc)
+{
+ setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title,doc || document);
+}
+
+function refreshColorPalette(title)
+{
+ if(!startingUp)
+ refreshAll();
+}
+
+function refreshAll()
+{
+ refreshPageTemplate();
+ refreshDisplay();
+ refreshStyles("StyleSheetLayout");
+ refreshStyles("StyleSheetColors");
+ refreshStyles(config.refresherData.styleSheet);
+ refreshStyles("StyleSheetPrint");
+}
+
+//--
+//-- Options stuff
+//--
+
+config.optionHandlers = {
+ 'txt': {
+ get: function(name) {return encodeCookie(config.options[name].toString());},
+ set: function(name,value) {config.options[name] = decodeCookie(value);}
+ },
+ 'chk': {
+ get: function(name) {return config.options[name] ? "true" : "false";},
+ set: function(name,value) {config.options[name] = value == "true";}
+ }
+};
+
+function loadOptionsCookie()
+{
+ if(safeMode)
+ return;
+ var cookies = document.cookie.split(";");
+ for(var c=0; c<cookies.length; c++) {
+ var p = cookies[c].indexOf("=");
+ if(p != -1) {
+ var name = cookies[c].substr(0,p).trim();
+ var value = cookies[c].substr(p+1).trim();
+ var optType = name.substr(0,3);
+ if(config.optionHandlers[optType] && config.optionHandlers[optType].set)
+ config.optionHandlers[optType].set(name,value);
+ }
+ }
+}
+
+function saveOptionCookie(name)
+{
+ if(safeMode)
+ return;
+ var c = name + "=";
+ var optType = name.substr(0,3);
+ if(config.optionHandlers[optType] && config.optionHandlers[optType].get)
+ c += config.optionHandlers[optType].get(name);
+ c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/";
+ document.cookie = c;
+}
+
+function removeCookie(name)
+{
+ document.cookie = name + "=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;";
+}
+
+function encodeCookie(s)
+{
+ return escape(convertUnicodeToHtmlEntities(s));
+}
+
+function decodeCookie(s)
+{
+ s = unescape(s);
+ var re = /&#[0-9]{1,5};/g;
+ return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));});
+}
+
+
+config.macros.option.genericCreate = function(place,type,opt,className,desc)
+{
+ var typeInfo = config.macros.option.types[type];
+ var c = document.createElement(typeInfo.elementType);
+ if(typeInfo.typeValue)
+ c.setAttribute("type",typeInfo.typeValue);
+ c[typeInfo.eventName] = typeInfo.onChange;
+ c.setAttribute("option",opt);
+ c.className = className || typeInfo.className;
+ if(config.optionsDesc[opt])
+ c.setAttribute("title",config.optionsDesc[opt]);
+ place.appendChild(c);
+ if(desc != "no")
+ createTiddlyText(place,config.optionsDesc[opt] || opt);
+ c[typeInfo.valueField] = config.options[opt];
+ return c;
+};
+
+config.macros.option.genericOnChange = function(e)
+{
+ var opt = this.getAttribute("option");
+ if(opt) {
+ var optType = opt.substr(0,3);
+ var handler = config.macros.option.types[optType];
+ if(handler.elementType && handler.valueField)
+ config.macros.option.propagateOption(opt,handler.valueField,this[handler.valueField],handler.elementType,this);
+ }
+ return true;
+};
+
+config.macros.option.types = {
+ 'txt': {
+ elementType: "input",
+ valueField: "value",
+ eventName: "onchange",
+ className: "txtOptionInput",
+ create: config.macros.option.genericCreate,
+ onChange: config.macros.option.genericOnChange
+ },
+ 'chk': {
+ elementType: "input",
+ valueField: "checked",
+ eventName: "onclick",
+ className: "chkOptionInput",
+ typeValue: "checkbox",
+ create: config.macros.option.genericCreate,
+ onChange: config.macros.option.genericOnChange
+ }
+};
+
+config.macros.option.propagateOption = function(opt,valueField,value,elementType,elem)
+{
+ config.options[opt] = value;
+ saveOptionCookie(opt);
+ var nodes = document.getElementsByTagName(elementType);
+ for(var t=0; t<nodes.length; t++) {
+ var optNode = nodes[t].getAttribute("option");
+ if(opt == optNode && nodes[t]!=elem)
+ nodes[t][valueField] = value;
+ }
+};
+
+config.macros.option.handler = function(place,macroName,params,wikifier,paramString)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var opt = (params[1] && params[1].name == "anon") ? params[1].value : getParam(params,"name",null);
+ var className = (params[2] && params[2].name == "anon") ? params[2].value : getParam(params,"class",null);
+ var desc = getParam(params,"desc","no");
+ var type = opt.substr(0,3);
+ var h = config.macros.option.types[type];
+ if(h && h.create)
+ h.create(place,type,opt,className,desc);
+};
+
+config.macros.options.handler = function(place,macroName,params,wikifier,paramString)
+{
+ params = paramString.parseParams("anon",null,true,false,false);
+ var showUnknown = getParam(params,"showUnknown","no");
+ var wizard = new Wizard();
+ wizard.createWizard(place,this.wizardTitle);
+ wizard.addStep(this.step1Title,this.step1Html);
+ var markList = wizard.getElement("markList");
+ var chkUnknown = wizard.getElement("chkUnknown");
+ chkUnknown.checked = showUnknown == "yes";
+ chkUnknown.onchange = this.onChangeUnknown;
+ var listWrapper = document.createElement("div");
+ markList.parentNode.insertBefore(listWrapper,markList);
+ wizard.setValue("listWrapper",listWrapper);
+ this.refreshOptions(listWrapper,showUnknown == "yes");
+};
+
+config.macros.options.refreshOptions = function(listWrapper,showUnknown)
+{
+ var opts = [];
+ for(var n in config.options) {
+ var opt = {};
+ opt.option = "";
+ opt.name = n;
+ opt.lowlight = !config.optionsDesc[n];
+ opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
+ if(!opt.lowlight || showUnknown)
+ opts.push(opt);
+ }
+ opts.sort(function(a,b) {return a.name.substr(3) < b.name.substr(3) ? -1 : (a.name.substr(3) == b.name.substr(3) ? 0 : +1);});
+ var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
+ for(n=0; n<opts.length; n++) {
+ var type = opts[n].name.substr(0,3);
+ var h = config.macros.option.types[type];
+ if(h && h.create) {
+ h.create(opts[n].colElements['option'],type,opts[n].name,null,"no");
+ }
+ }
+};
+
+config.macros.options.onChangeUnknown = function(e)
+{
+ var wizard = new Wizard(this);
+ var listWrapper = wizard.getValue("listWrapper");
+ removeChildren(listWrapper);
+ config.macros.options.refreshOptions(listWrapper,this.checked);
+ return false;
+};
+
+//--
+//-- Saving
+//--
+
+var saveUsingSafari = false;
+
+var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it
+var endSaveArea = '</d' + 'iv>';
+
+// If there are unsaved changes, force the user to confirm before exitting
+function confirmExit()
+{
+ hadConfirmExit = true;
+ if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty()))
+ return config.messages.confirmExit;
+}
+
+// Give the user a chance to save changes before exitting
+function checkUnsavedChanges()
+{
+ if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false) {
+ if(confirm(config.messages.unsavedChangesWarning))
+ saveChanges();
+ }
+}
+
+function updateLanguageAttribute(s)
+{
+ if(config.locale) {
+ var mRE = /(<html(?:.*?)?)(?: xml:lang\="([a-z]+)")?(?: lang\="([a-z]+)")?>/;
+ var m = mRE.exec(s);
+ if(m) {
+ var t = m[1];
+ if(m[2])
+ t += ' xml:lang="' + config.locale + '"';
+ if(m[3])
+ t += ' lang="' + config.locale + '"';
+ t += ">";
+ s = s.substr(0,m.index) + t + s.substr(m.index+m[0].length);
+ }
+ }
+ return s;
+}
+
+function updateMarkupBlock(s,blockName,tiddlerName)
+{
+ return s.replaceChunk(
+ "<!--%0-START-->".format([blockName]),
+ "<!--%0-END-->".format([blockName]),
+ "\n" + convertUnicodeToFileFormat(store.getRecursiveTiddlerText(tiddlerName,"")) + "\n");
+}
+
+function updateOriginal(original,posDiv,localPath)
+{
+ if(!posDiv)
+ posDiv = locateStoreArea(original);
+ if(!posDiv) {
+ alert(config.messages.invalidFileError.format([localPath]));
+ return null;
+ }
+ var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
+ convertUnicodeToFileFormat(store.allTiddlersAsHtml()) + "\n" +
+ original.substr(posDiv[1]);
+ var newSiteTitle = convertUnicodeToFileFormat(getPageTitle()).htmlEncode();
+ revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
+ revised = updateLanguageAttribute(revised);
+ revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
+ revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
+ revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
+ revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
+ return revised;
+}
+
+function locateStoreArea(original)
+{
+ // Locate the storeArea div's
+ var posOpeningDiv = original.indexOf(startSaveArea);
+ var limitClosingDiv = original.indexOf("<"+"!--POST-STOREAREA--"+">");
+ if(limitClosingDiv == -1)
+ limitClosingDiv = original.indexOf("<"+"!--POST-BODY-START--"+">");
+ var posClosingDiv = original.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? original.length : limitClosingDiv);
+ return (posOpeningDiv != -1 && posClosingDiv != -1) ? [posOpeningDiv,posClosingDiv] : null;
+}
+
+function autoSaveChanges(onlyIfDirty,tiddlers)
+{
+ if(config.options.chkAutoSave)
+ saveChanges(onlyIfDirty,tiddlers);
+}
+
+function loadOriginal(localPath)
+{
+ return loadFile(localPath);
+}
+
+// Save this tiddlywiki with the pending changes
+function saveChanges(onlyIfDirty,tiddlers)
+{
+ if(onlyIfDirty && !store.isDirty())
+ return;
+ clearMessage();
+ var t0 = new Date();
+ var originalPath = document.location.toString();
+ if(originalPath.substr(0,5) != "file:") {
+ alert(config.messages.notFileUrlError);
+ if(store.tiddlerExists(config.messages.saveInstructions))
+ story.displayTiddler(null,config.messages.saveInstructions);
+ return;
+ }
+ var localPath = getLocalPath(originalPath);
+ var original = loadOriginal(localPath);
+ if(original == null) {
+ alert(config.messages.cantSaveError);
+ if(store.tiddlerExists(config.messages.saveInstructions))
+ story.displayTiddler(null,config.messages.saveInstructions);
+ return;
+ }
+ var posDiv = locateStoreArea(original);
+ if(!posDiv) {
+ alert(config.messages.invalidFileError.format([localPath]));
+ return;
+ }
+ saveMain(localPath,original,posDiv);
+ if(config.options.chkSaveBackups)
+ saveBackup(localPath,original);
+ if(config.options.chkSaveEmptyTemplate)
+ saveEmpty(localPath,original,posDiv);
+ if(config.options.chkGenerateAnRssFeed && saveRss instanceof Function)
+ saveRss(localPath);
+ if(config.options.chkDisplayInstrumentation)
+ displayMessage("saveChanges " + (new Date()-t0) + " ms");
+}
+
+function saveMain(localPath,original,posDiv)
+{
+ var save;
+ try {
+ var revised = updateOriginal(original,posDiv,localPath);
+ save = saveFile(localPath,revised);
+ } catch (ex) {
+ showException(ex);
+ }
+ if(save) {
+ displayMessage(config.messages.mainSaved,"file://" + localPath);
+ store.setDirty(false);
+ } else {
+ alert(config.messages.mainFailed);
+ }
+}
+
+function saveBackup(localPath,original)
+{
+ var backupPath = getBackupPath(localPath);
+ var backup = copyFile(backupPath,localPath);
+ if(!backup)
+ backup = saveFile(backupPath,original);
+ if(backup)
+ displayMessage(config.messages.backupSaved,"file://" + backupPath);
+ else
+ alert(config.messages.backupFailed);
+ displayMessage(config.messages.backupFailed,"failed" + backup + "file://" + backupPath);
+}
+
+function saveEmpty(localPath,original,posDiv)
+{
+ var emptyPath,p;
+ if((p = localPath.lastIndexOf("/")) != -1)
+ emptyPath = localPath.substr(0,p) + "/";
+ else if((p = localPath.lastIndexOf("\\")) != -1)
+ emptyPath = localPath.substr(0,p) + "\\";
+ else
+ emptyPath = localPath + ".";
+ emptyPath += "empty.html";
+ var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]);
+ var emptySave = saveFile(emptyPath,empty);
+ if(emptySave)
+ displayMessage(config.messages.emptySaved,"file://" + emptyPath);
+ else
+ alert(config.messages.emptyFailed);
+}
+
+function getLocalPath(origPath)
+{
+ var originalPath = convertUriToUTF8(origPath,config.options.txtFileSystemCharSet);
+ // Remove any location or query part of the URL
+ var argPos = originalPath.indexOf("?");
+ if(argPos != -1)
+ originalPath = originalPath.substr(0,argPos);
+ var hashPos = originalPath.indexOf("#");
+ if(hashPos != -1)
+ originalPath = originalPath.substr(0,hashPos);
+ // Convert file://localhost/ to file:///
+ if(originalPath.indexOf("file://localhost/") == 0)
+ originalPath = "file://" + originalPath.substr(16);
+ // Convert to a native file format
+ var localPath;
+ if(originalPath.charAt(9) == ":") // pc local file
+ localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
+ else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
+ localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
+ else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
+ localPath = unescape(originalPath.substr(7));
+ else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
+ localPath = unescape(originalPath.substr(5));
+ else // pc network file
+ localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
+ return localPath;
+}
+
+function getBackupPath(localPath,title,extension)
+{
+ var slash = "\\";
+ var dirPathPos = localPath.lastIndexOf("\\");
+ if(dirPathPos == -1) {
+ dirPathPos = localPath.lastIndexOf("/");
+ slash = "/";
+ }
+ var backupFolder = config.options.txtBackupFolder;
+ if(!backupFolder || backupFolder == "")
+ backupFolder = ".";
+ var backupPath = localPath.substr(0,dirPathPos) + slash + backupFolder + localPath.substr(dirPathPos);
+ backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + ".";
+ if(title)
+ backupPath += title.replace(/[\\\/\*\?\":<> ]/g,"_") + ".";
+ backupPath += (new Date()).convertToYYYYMMDDHHMMSSMMM() + "." + (extension || "html");
+ return backupPath;
+}
+
+//--
+//-- RSS Saving
+//--
+
+function saveRss(localPath)
+{
+ var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
+ if(saveFile(rssPath,convertUnicodeToFileFormat(generateRss())))
+ displayMessage(config.messages.rssSaved,"file://" + rssPath);
+ else
+ alert(config.messages.rssFailed);
+}
+
+tiddlerToRssItem = function(tiddler,uri)
+{
+ var s = "<title" + ">" + tiddler.title.htmlEncode() + "</title" + ">\n";
+ s += "<description>" + wikifyStatic(tiddler.text,null,tiddler).htmlEncode() + "</description>\n";
+ for(var i=0; i<tiddler.tags.length; i++)
+ s += "<category>" + tiddler.tags[i] + "</category>\n";
+ s += "<link>" + uri + "#" + encodeURIComponent(String.encodeTiddlyLink(tiddler.title)) + "</link>\n";
+ s +="<pubDate>" + tiddler.modified.toGMTString() + "</pubDate>\n";
+ return s;
+};
+
+function generateRss()
+{
+ var s = [];
+ var d = new Date();
+ var u = store.getTiddlerText("SiteUrl");
+ // Assemble the header
+ s.push("<" + "?xml version=\"1.0\"?" + ">");
+ s.push("<rss version=\"2.0\">");
+ s.push("<channel>");
+ s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">");
+ if(u)
+ s.push("<link>" + u.htmlEncode() + "</link>");
+ s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");
+ s.push("<language>" + config.locale + "</language>");
+ s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
+ s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
+ s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
+ s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
+ s.push("<generator>TiddlyWiki " + formatVersion() + "</generator>");
+ // The body
+ var tiddlers = store.getTiddlers("modified","excludeLists");
+ var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
+ for(var i=tiddlers.length-1; i>=n; i--) {
+ s.push("<item>\n" + tiddlerToRssItem(tiddlers[i],u) + "\n</item>");
+ }
+ // And footer
+ s.push("</channel>");
+ s.push("</rss>");
+ // Save it all
+ return s.join("\n");
+}
+
+//--
+//-- Filesystem code
+//--
+
+function convertUTF8ToUnicode(u)
+{
+ return config.browser.isOpera || !window.netscape ? manualConvertUTF8ToUnicode(u) : mozConvertUTF8ToUnicode(u);
+}
+
+function manualConvertUTF8ToUnicode(utf)
+{
+ var uni = utf;
+ var src = 0;
+ var dst = 0;
+ var b1, b2, b3;
+ var c;
+ while(src < utf.length) {
+ b1 = utf.charCodeAt(src++);
+ if(b1 < 0x80) {
+ dst++;
+ } else if(b1 < 0xE0) {
+ b2 = utf.charCodeAt(src++);
+ c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F));
+ uni = uni.substring(0,dst++).concat(c,utf.substr(src));
+ } else {
+ b2 = utf.charCodeAt(src++);
+ b3 = utf.charCodeAt(src++);
+ c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F));
+ uni = uni.substring(0,dst++).concat(c,utf.substr(src));
+ }
+ }
+ return uni;
+}
+
+function mozConvertUTF8ToUnicode(u)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+ converter.charset = "UTF-8";
+ } catch(ex) {
+ return manualConvertUTF8ToUnicode(u);
+ } // fallback
+ var s = converter.ConvertToUnicode(u);
+ var fin = converter.Finish();
+ return fin.length > 0 ? s+fin : s;
+}
+
+function convertUnicodeToFileFormat(s)
+{
+ return config.browser.isOpera || !window.netscape ? convertUnicodeToHtmlEntities(s) : mozConvertUnicodeToUTF8(s);
+}
+
+function convertUnicodeToHtmlEntities(s)
+{
+ var re = /[^\u0000-\u007F]/g;
+ return s.replace(re,function($0) {return "&#" + $0.charCodeAt(0).toString() + ";";});
+}
+
+function convertUnicodeToUTF8(s)
+{
+// return convertUnicodeToFileFormat to allow plugin migration
+ return convertUnicodeToFileFormat(s);
+}
+
+function manualConvertUnicodeToUTF8(s)
+{
+ return unescape(encodeURIComponent(s));
+}
+
+function mozConvertUnicodeToUTF8(s)
+{
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+ converter.charset = "UTF-8";
+ } catch(ex) {
+ return manualConvertUnicodeToUTF8(s);
+ } // fallback
+ var u = converter.ConvertFromUnicode(s);
+ var fin = converter.Finish();
+ return fin.length > 0 ? u + fin : u;
+}
+
+function convertUriToUTF8(uri,charSet)
+{
+ if(window.netscape == undefined || charSet == undefined || charSet == "")
+ return uri;
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService);
+ } catch(ex) {
+ return uri;
+ }
+ return converter.convertURISpecToUTF8(uri,charSet);
+}
+
+function copyFile(dest,source)
+{
+ return config.browser.isIE ? ieCopyFile(dest,source) : false;
+}
+
+function saveFile(fileUrl,content)
+{
+ var r = mozillaSaveFile(fileUrl,content);
+ if(!r)
+ r = ieSaveFile(fileUrl,content);
+ if(!r)
+ r = javaSaveFile(fileUrl,content);
+ system.print r + ' ' + fileUrl
+ alert(r + ' ' + fileUrl)
+ return r;
+}
+
+function loadFile(fileUrl)
+{
+ var r = mozillaLoadFile(fileUrl);
+ if((r == null) || (r == false))
+ r = ieLoadFile(fileUrl);
+ if((r == null) || (r == false))
+ r = javaLoadFile(fileUrl);
+ return r;
+}
+
+function ieCreatePath(path)
+{
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ } catch(ex) {
+ return null;
+ }
+
+ var pos = path.lastIndexOf("\\");
+ if(pos==-1)
+ pos = path.lastIndexOf("/");
+ if(pos!=-1)
+ path = path.substring(0,pos+1);
+
+ var scan = [path];
+ var parent = fso.GetParentFolderName(path);
+ while(parent && !fso.FolderExists(parent)) {
+ scan.push(parent);
+ parent = fso.GetParentFolderName(parent);
+ }
+
+ for(i=scan.length-1;i>=0;i--) {
+ if(!fso.FolderExists(scan[i])) {
+ fso.CreateFolder(scan[i]);
+ }
+ }
+ return true;
+}
+
+// Returns null if it can't do it, false if there's an error, true if it saved OK
+function ieSaveFile(filePath,content)
+{
+ ieCreatePath(filePath);
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ } catch(ex) {
+ return null;
+ }
+ var file = fso.OpenTextFile(filePath,2,-1,0);
+ file.Write(content);
+ file.Close();
+ return true;
+}
+
+// Returns null if it can't do it, false if there's an error, or a string of the content if successful
+function ieLoadFile(filePath)
+{
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ var file = fso.OpenTextFile(filePath,1);
+ var content = file.ReadAll();
+ file.Close();
+ } catch(ex) {
+ return null;
+ }
+ return content;
+}
+
+function ieCopyFile(dest,source)
+{
+ ieCreatePath(dest);
+ try {
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
+ fso.GetFile(source).Copy(dest);
+ } catch(ex) {
+ return false;
+ }
+ return true;
+}
+
+// Returns null if it can't do it, false if there's an error, true if it saved OK
+function mozillaSaveFile(filePath,content)
+{
+ if(window.Components) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath(filePath);
+ if(!file.exists())
+ file.create(0,0664);
+ var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
+ out.init(file,0x20|0x02,00004,null);
+ out.write(content,content.length);
+ out.flush();
+ out.close();
+ return true;
+ } catch(ex) {
+ return false;
+ }
+ }
+ return null;
+}
+
+// Returns null if it can't do it, false if there's an error, or a string of the content if successful
+function mozillaLoadFile(filePath)
+{
+ if(window.Components) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath(filePath);
+ if(!file.exists())
+ return null;
+ var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
+ inputStream.init(file,0x01,00004,null);
+ var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
+ sInputStream.init(inputStream);
+ var contents = sInputStream.read(sInputStream.available());
+ sInputStream.close();
+ inputStream.close();
+ return contents;
+ } catch(ex) {
+ return false;
+ }
+ }
+ return null;
+}
+
+function javaUrlToFilename(url)
+{
+ var f = "//localhost";
+ if(url.indexOf(f) == 0)
+ return url.substring(f.length);
+ var i = url.indexOf(":");
+ return i > 0 ? url.substring(i-1) : url;
+}
+
+function javaSaveFile(filePath,content)
+{
+ try {
+ if(document.applets["TiddlySaver"])
+ return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content);
+ } catch(ex) {
+ }
+ try {
+ var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath)));
+ s.print(content);
+ s.close();
+ } catch(ex) {
+ return null;
+ }
+ return true;
+}
+
+function javaLoadFile(filePath)
+{
+ try {
+ if(document.applets["TiddlySaver"])
+ return String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8"));
+ } catch(ex) {
+ }
+ var content = [];
+ try {
+ var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath)));
+ var line;
+ while((line = r.readLine()) != null)
+ content.push(new String(line));
+ r.close();
+ } catch(ex) {
+ return null;
+ }
+ return content.join("\n");
+}
+
+//--
+//-- Server adaptor base class
+//--
+
+function AdaptorBase()
+{
+ this.host = null;
+ this.store = null;
+ return this;
+}
+
+AdaptorBase.prototype.close = function()
+{
+ return true;
+};
+
+AdaptorBase.prototype.fullHostName = function(host)
+{
+ if(!host)
+ return '';
+ host = host.trim();
+ if(!host.match(/:\/\//))
+ host = 'http://' + host;
+ if(host.substr(host.length-1) == '/')
+ host = host.substr(0,host.length-1);
+ return host;
+};
+
+AdaptorBase.minHostName = function(host)
+{
+ return host ? host.replace(/^http:\/\//,'').replace(/\/$/,'') : '';
+};
+
+AdaptorBase.prototype.setContext = function(context,userParams,callback)
+{
+ if(!context) context = {};
+ context.userParams = userParams;
+ if(callback) context.callback = callback;
+ context.adaptor = this;
+ if(!context.host)
+ context.host = this.host;
+ context.host = this.fullHostName(context.host);
+ if(!context.workspace)
+ context.workspace = this.workspace;
+ return context;
+};
+
+// Open the specified host
+AdaptorBase.prototype.openHost = function(host,context,userParams,callback)
+{
+ this.host = host;
+ context = this.setContext(context,userParams,callback);
+ context.status = true;
+ if(callback)
+ window.setTimeout(function() {context.callback(context,userParams);},10);
+ return true;
+};
+
+// Open the specified workspace
+AdaptorBase.prototype.openWorkspace = function(workspace,context,userParams,callback)
+{
+ this.workspace = workspace;
+ context = this.setContext(context,userParams,callback);
+ context.status = true;
+ if(callback)
+ window.setTimeout(function() {callback(context,userParams);},10);
+ return true;
+};
+
+//--
+//-- Server adaptor for talking to static TiddlyWiki files
+//--
+
+function FileAdaptor()
+{
+}
+
+FileAdaptor.prototype = new AdaptorBase();
+
+FileAdaptor.serverType = 'file';
+FileAdaptor.serverLabel = 'TiddlyWiki';
+
+FileAdaptor.loadTiddlyWikiCallback = function(status,context,responseText,url,xhr)
+{
+ context.status = status;
+ if(!status) {
+ context.statusText = "Error reading file";
+ } else {
+ context.adaptor.store = new TiddlyWiki();
+ if(!context.adaptor.store.importTiddlyWiki(responseText)) {
+ context.statusText = config.messages.invalidFileError.format([url]);
+ context.status = false;
+ }
+ }
+ context.complete(context,context.userParams);
+};
+
+// Get the list of workspaces on a given server
+FileAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
+{
+ context = this.setContext(context,userParams,callback);
+ context.workspaces = [{title:"(default)"}];
+ context.status = true;
+ if(callback)
+ window.setTimeout(function() {callback(context,userParams);},10);
+ return true;
+};
+
+// Gets the list of tiddlers within a given workspace
+FileAdaptor.prototype.getTiddlerList = function(context,userParams,callback,filter)
+{
+ context = this.setContext(context,userParams,callback);
+ if(!context.filter)
+ context.filter = filter;
+ context.complete = FileAdaptor.getTiddlerListComplete;
+ if(this.store) {
+ var ret = context.complete(context,context.userParams);
+ } else {
+ ret = loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context);
+ if(typeof ret != "string")
+ ret = true;
+ }
+ return ret;
+};
+
+FileAdaptor.getTiddlerListComplete = function(context,userParams)
+{
+ if(context.status) {
+ if(context.filter) {
+ context.tiddlers = context.adaptor.store.filterTiddlers(context.filter);
+ } else {
+ context.tiddlers = [];
+ context.adaptor.store.forEachTiddler(function(title,tiddler) {context.tiddlers.push(tiddler);});
+ }
+ for(var i=0; i<context.tiddlers.length; i++) {
+ context.tiddlers[i].fields['server.type'] = FileAdaptor.serverType;
+ context.tiddlers[i].fields['server.host'] = AdaptorBase.minHostName(context.host);
+ context.tiddlers[i].fields['server.page.revision'] = context.tiddlers[i].modified.convertToYYYYMMDDHHMM();
+ }
+ context.status = true;
+ }
+ if(context.callback) {
+ window.setTimeout(function() {context.callback(context,userParams);},10);
+ }
+ return true;
+};
+
+FileAdaptor.prototype.generateTiddlerInfo = function(tiddler)
+{
+ var info = {};
+ info.uri = tiddler.fields['server.host'] + "#" + tiddler.title;
+ return info;
+};
+
+// Retrieve a tiddler from a given workspace on a given server
+FileAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
+{
+ context = this.setContext(context,userParams,callback);
+ context.title = title;
+ context.complete = FileAdaptor.getTiddlerComplete;
+ return context.adaptor.store ?
+ context.complete(context,context.userParams) :
+ loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context);
+};
+
+FileAdaptor.getTiddlerComplete = function(context,userParams)
+{
+ var t = context.adaptor.store.fetchTiddler(context.title);
+ t.fields['server.type'] = FileAdaptor.serverType;
+ t.fields['server.host'] = AdaptorBase.minHostName(context.host);
+ t.fields['server.page.revision'] = t.modified.convertToYYYYMMDDHHMM();
+ context.tiddler = t;
+ context.status = true;
+ if(context.allowSynchronous) {
+ context.isSynchronous = true;
+ context.callback(context,userParams);
+ } else {
+ window.setTimeout(function() {context.callback(context,userParams);},10);
+ }
+ return true;
+};
+
+FileAdaptor.prototype.close = function()
+{
+ delete this.store;
+ this.store = null;
+};
+
+config.adaptors[FileAdaptor.serverType] = FileAdaptor;
+
+config.defaultAdaptor = FileAdaptor.serverType;
+
+//--
+//-- Remote HTTP requests
+//--
+
+function loadRemoteFile(url,callback,params)
+{
+ return httpReq("GET",url,callback,params);
+}
+
+function httpReq(type,url,callback,params,headers,data,contentType,username,password,allowCache)
+{
+ var x = null;
+ try {
+ x = new XMLHttpRequest(); //# Modern
+ } catch(ex) {
+ try {
+ x = new ActiveXObject("Msxml2.XMLHTTP"); //# IE 6
+ } catch(ex2) {
+ }
+ }
+ if(!x)
+ return "Can't create XMLHttpRequest object";
+ x.onreadystatechange = function() {
+ try {
+ var status = x.status;
+ } catch(ex) {
+ status = false;
+ }
+ if(x.readyState == 4 && callback && (status !== undefined)) {
+ if([0, 200, 201, 204, 207].contains(status))
+ callback(true,params,x.responseText,url,x);
+ else
+ callback(false,params,null,url,x);
+ x.onreadystatechange = function(){};
+ x = null;
+ }
+ };
+ if(window.Components && window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1)
+ window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
+ try {
+ if(!allowCache)
+ url = url + (url.indexOf("?") < 0 ? "?" : "&") + "nocache=" + Math.random();
+ x.open(type,url,true,username,password);
+ if(data)
+ x.setRequestHeader("Content-Type", contentType || "application/x-www-form-urlencoded");
+ if(x.overrideMimeType)
+ x.setRequestHeader("Connection", "close");
+ if(headers) {
+ for(var n in headers)
+ x.setRequestHeader(n,headers[n]);
+ }
+ x.setRequestHeader("X-Requested-With", "TiddlyWiki " + formatVersion());
+ x.send(data);
+ } catch(ex) {
+ return exceptionText(ex);
+ }
+ return x;
+}
+
+// included for compatibility
+function getXMLHttpRequest()
+{
+ try {
+ var x = new XMLHttpRequest(); // Modern
+ } catch(ex) {
+ try {
+ x = new ActiveXObject("Msxml2.XMLHTTP"); // IE 6
+ } catch (ex2) {
+ return null;
+ }
+ }
+ return x;
+}
+
+// included for compatibility
+function doHttp(type,url,data,contentType,username,password,callback,params,headers,allowCache)
+{
+ return httpReq(type,url,callback,params,headers,data,contentType,username,password,allowCache);
+}
+
+//--
+//-- TiddlyWiki-specific utility functions
+//--
+
+function formatVersion(v)
+{
+ v = v || version;
+ return v.major + "." + v.minor + "." + v.revision + (v.beta ? " (beta " + v.beta + ")" : "");
+}
+
+function compareVersions(v1,v2)
+{
+ var a = ["major","minor","revision"];
+ for(var i = 0; i<a.length; i++) {
+ var x1 = v1[a[i]] || 0;
+ var x2 = v2[a[i]] || 0;
+ if(x1<x2)
+ return 1;
+ if(x1>x2)
+ return -1;
+ }
+ x1 = v1.beta || 9999;
+ x2 = v2.beta || 9999;
+ if(x1<x2)
+ return 1;
+ return x1 > x2 ? -1 : 0;
+}
+
+function createTiddlyButton(parent,text,tooltip,action,className,id,accessKey,attribs)
+{
+ var btn = document.createElement("a");
+ if(action) {
+ btn.onclick = action;
+ btn.setAttribute("href","javascript:;");
+ }
+ if(tooltip)
+ btn.setAttribute("title",tooltip);
+ if(text)
+ btn.appendChild(document.createTextNode(text));
+ btn.className = className || "button";
+ if(id)
+ btn.id = id;
+ if(attribs) {
+ for(var i in attribs) {
+ btn.setAttribute(i,attribs[i]);
+ }
+ }
+ if(parent)
+ parent.appendChild(btn);
+ if(accessKey)
+ btn.setAttribute("accessKey",accessKey);
+ return btn;
+}
+
+function createTiddlyLink(place,title,includeText,className,isStatic,linkedFromTiddler,noToggle)
+{
+ var text = includeText ? title : null;
+ var i = getTiddlyLinkInfo(title,className);
+ var btn = isStatic ? createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" + title) : createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
+ if(isStatic)
+ btn.className += ' ' + className;
+ btn.setAttribute("refresh","link");
+ btn.setAttribute("tiddlyLink",title);
+ if(noToggle)
+ btn.setAttribute("noToggle","true");
+ if(linkedFromTiddler) {
+ var fields = linkedFromTiddler.getInheritedFields();
+ if(fields)
+ btn.setAttribute("tiddlyFields",fields);
+ }
+ return btn;
+}
+
+function refreshTiddlyLink(e,title)
+{
+ var i = getTiddlyLinkInfo(title,e.className);
+ e.className = i.classes;
+ e.title = i.subTitle;
+}
+
+function getTiddlyLinkInfo(title,currClasses)
+{
+ var classes = currClasses ? currClasses.split(" ") : [];
+ classes.pushUnique("tiddlyLink");
+ var tiddler = store.fetchTiddler(title);
+ var subTitle;
+ if(tiddler) {
+ subTitle = tiddler.getSubtitle();
+ classes.pushUnique("tiddlyLinkExisting");
+ classes.remove("tiddlyLinkNonExisting");
+ classes.remove("shadow");
+ } else {
+ classes.remove("tiddlyLinkExisting");
+ classes.pushUnique("tiddlyLinkNonExisting");
+ if(store.isShadowTiddler(title)) {
+ subTitle = config.messages.shadowedTiddlerToolTip.format([title]);
+ classes.pushUnique("shadow");
+ } else {
+ subTitle = config.messages.undefinedTiddlerToolTip.format([title]);
+ classes.remove("shadow");
+ }
+ }
+ if(typeof config.annotations[title]=="string")
+ subTitle = config.annotations[title];
+ return {classes: classes.join(" "),subTitle: subTitle};
+}
+
+function createExternalLink(place,url)
+{
+ var link = document.createElement("a");
+ link.className = "externalLink";
+ link.href = url;
+ link.title = config.messages.externalLinkTooltip.format([url]);
+ if(config.options.chkOpenInNewWindow)
+ link.target = "_blank";
+ place.appendChild(link);
+ return link;
+}
+
+// Event handler for clicking on a tiddly link
+function onClickTiddlerLink(ev)
+{
+ var e = ev || window.event;
+ var target = resolveTarget(e);
+ var link = target;
+ var title = null;
+ var fields = null;
+ var noToggle = null;
+ do {
+ title = link.getAttribute("tiddlyLink");
+ fields = link.getAttribute("tiddlyFields");
+ noToggle = link.getAttribute("noToggle");
+ link = link.parentNode;
+ } while(title == null && link != null);
+ if(!store.isShadowTiddler(title)) {
+ var f = fields ? fields.decodeHashMap() : {};
+ fields = String.encodeHashMap(merge(f,config.defaultCustomFields,true));
+ }
+ if(title) {
+ var toggling = e.metaKey || e.ctrlKey;
+ if(config.options.chkToggleLinks)
+ toggling = !toggling;
+ if(noToggle)
+ toggling = false;
+ if(store.getTiddler(title))
+ fields = null;
+ story.displayTiddler(target,title,null,true,null,fields,toggling);
+ }
+ clearMessage();
+ return false;
+}
+
+// Create a button for a tag with a popup listing all the tiddlers that it tags
+function createTagButton(place,tag,excludeTiddler,title,tooltip)
+{
+ var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag);
+ btn.setAttribute("tag",tag);
+ if(excludeTiddler)
+ btn.setAttribute("tiddler",excludeTiddler);
+ return btn;
+}
+
+// Event handler for clicking on a tiddler tag
+function onClickTag(ev)
+{
+ var e = ev || window.event;
+ var popup = Popup.create(this);
+ var tag = this.getAttribute("tag");
+ var title = this.getAttribute("tiddler");
+ if(popup && tag) {
+ var tagged = store.getTaggedTiddlers(tag);
+ var titles = [];
+ var li,r;
+ for(r=0;r<tagged.length;r++) {
+ if(tagged[r].title != title)
+ titles.push(tagged[r].title);
+ }
+ var lingo = config.views.wikified.tag;
+ if(titles.length > 0) {
+ var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);
+ openAll.setAttribute("tag",tag);
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ for(r=0; r<titles.length; r++) {
+ createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);
+ }
+ } else {
+ createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag]));
+ }
+ createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
+ var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);
+ createTiddlyText(h,lingo.openTag.format([tag]));
+ }
+ Popup.show();
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return false;
+}
+
+// Event handler for 'open all' on a tiddler popup
+function onClickTagOpenAll(ev)
+{
+ var tiddlers = store.getTaggedTiddlers(this.getAttribute("tag"));
+ story.displayTiddlers(this,tiddlers);
+ return false;
+}
+
+function onClickError(ev)
+{
+ var e = ev || window.event;
+ var popup = Popup.create(this);
+ var lines = this.getAttribute("errorText").split("\n");
+ for(var t=0; t<lines.length; t++)
+ createTiddlyElement(popup,"li",null,null,lines[t]);
+ Popup.show();
+ e.cancelBubble = true;
+ if(e.stopPropagation) e.stopPropagation();
+ return false;
+}
+
+function createTiddlyDropDown(place,onchange,options,defaultValue)
+{
+ var sel = createTiddlyElement(place,"select");
+ sel.onchange = onchange;
+ for(var t=0; t<options.length; t++) {
+ var e = createTiddlyElement(sel,"option",null,null,options[t].caption);
+ e.value = options[t].name;
+ if(options[t].name == defaultValue)
+ e.selected = true;
+ }
+ return sel;
+}
+
+function createTiddlyPopup(place,caption,tooltip,tiddler)
+{
+ if(tiddler.text) {
+ createTiddlyLink(place,caption,true);
+ var btn = createTiddlyButton(place,glyph("downArrow"),tooltip,onClickTiddlyPopup,"tiddlerPopupButton");
+ btn.tiddler = tiddler;
+ } else {
+ createTiddlyText(place,caption);
+ }
+}
+
+function onClickTiddlyPopup(ev)
+{
+ var e = ev || window.event;
+ var tiddler = this.tiddler;
+ if(tiddler.text) {
+ var popup = Popup.create(this,"div","popupTiddler");
+ wikify(tiddler.text,popup,null,tiddler);
+ Popup.show();
+ }
+ if(e) e.cancelBubble = true;
+ if(e && e.stopPropagation) e.stopPropagation();
+ return false;
+}
+
+function createTiddlyError(place,title,text)
+{
+ var btn = createTiddlyButton(place,title,null,onClickError,"errorButton");
+ if(text) btn.setAttribute("errorText",text);
+}
+
+function merge(dst,src,preserveExisting)
+{
+ for(var i in src) {
+ if(!preserveExisting || dst[i] === undefined)
+ dst[i] = src[i];
+ }
+ return dst;
+}
+
+// Returns a string containing the description of an exception, optionally prepended by a message
+function exceptionText(e,message)
+{
+ var s = e.description || e.toString();
+ return message ? "%0:\n%1".format([message,s]) : s;
+}
+
+// Displays an alert of an exception description with optional message
+function showException(e,message)
+{
+ alert(exceptionText(e,message));
+}
+
+function alertAndThrow(m)
+{
+ alert(m);
+ throw(m);
+}
+
+function glyph(name)
+{
+ var g = config.glyphs;
+ var b = g.currBrowser;
+ if(b == null) {
+ b = 0;
+ while(!g.browsers[b]() && b < g.browsers.length-1)
+ b++;
+ g.currBrowser = b;
+ }
+ if(!g.codes[name])
+ return "";
+ return g.codes[name][b];
+}
+
+if(!window.console) {
+ console = {tiddlywiki:true,log:function(message) {displayMessage(message);}};
+}
+
+//-
+//- Animation engine
+//-
+
+function Animator()
+{
+ this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
+ this.timerID = 0; // ID of the timer used for animating
+ this.animations = []; // List of animations in progress
+ return this;
+}
+
+// Start animation engine
+Animator.prototype.startAnimating = function() //# Variable number of arguments
+{
+ for(var t=0; t<arguments.length; t++)
+ this.animations.push(arguments[t]);
+ if(this.running == 0) {
+ var me = this;
+ this.timerID = window.setInterval(function() {me.doAnimate(me);},10);
+ }
+ this.running += arguments.length;
+};
+
+// Perform an animation engine tick, calling each of the known animation modules
+Animator.prototype.doAnimate = function(me)
+{
+ var a = 0;
+ while(a < me.animations.length) {
+ var animation = me.animations[a];
+ if(animation.tick()) {
+ a++;
+ } else {
+ me.animations.splice(a,1);
+ if(--me.running == 0)
+ window.clearInterval(me.timerID);
+ }
+ }
+};
+
+Animator.slowInSlowOut = function(progress)
+{
+ return(1-((Math.cos(progress * Math.PI)+1)/2));
+};
+
+//--
+//-- Morpher animation
+//--
+
+// Animate a set of properties of an element
+function Morpher(element,duration,properties,callback)
+{
+ this.element = element;
+ this.duration = duration;
+ this.properties = properties;
+ this.startTime = new Date();
+ this.endTime = Number(this.startTime) + duration;
+ this.callback = callback;
+ this.tick();
+ return this;
+}
+
+Morpher.prototype.assignStyle = function(element,style,value)
+{
+ switch(style) {
+ case "-tw-vertScroll":
+ window.scrollTo(findScrollX(),value);
+ break;
+ case "-tw-horizScroll":
+ window.scrollTo(value,findScrollY());
+ break;
+ default:
+ element.style[style] = value;
+ break;
+ }
+};
+
+Morpher.prototype.stop = function()
+{
+ for(var t=0; t<this.properties.length; t++) {
+ var p = this.properties[t];
+ if(p.atEnd !== undefined) {
+ this.assignStyle(this.element,p.style,p.atEnd);
+ }
+ }
+ if(this.callback)
+ this.callback(this.element,this.properties);
+};
+
+Morpher.prototype.tick = function()
+{
+ var currTime = Number(new Date());
+ var progress = Animator.slowInSlowOut(Math.min(1,(currTime-this.startTime)/this.duration));
+ for(var t=0; t<this.properties.length; t++) {
+ var p = this.properties[t];
+ if(p.start !== undefined && p.end !== undefined) {
+ var template = p.template || "%0";
+ switch(p.format) {
+ case undefined:
+ case "style":
+ var v = p.start + (p.end-p.start) * progress;
+ this.assignStyle(this.element,p.style,template.format([v]));
+ break;
+ case "color":
+ break;
+ }
+ }
+ }
+ if(currTime >= this.endTime) {
+ this.stop();
+ return false;
+ }
+ return true;
+};
+
+//--
+//-- Zoomer animation
+//--
+
+function Zoomer(text,startElement,targetElement,unused)
+{
+ var e = createTiddlyElement(document.body,"div",null,"zoomer");
+ createTiddlyElement(e,"div",null,null,text);
+ var winWidth = findWindowWidth();
+ var winHeight = findWindowHeight();
+ var p = [
+ {style: 'left', start: findPosX(startElement), end: findPosX(targetElement), template: '%0px'},
+ {style: 'top', start: findPosY(startElement), end: findPosY(targetElement), template: '%0px'},
+ {style: 'width', start: Math.min(startElement.scrollWidth,winWidth), end: Math.min(targetElement.scrollWidth,winWidth), template: '%0px', atEnd: 'auto'},
+ {style: 'height', start: Math.min(startElement.scrollHeight,winHeight), end: Math.min(targetElement.scrollHeight,winHeight), template: '%0px', atEnd: 'auto'},
+ {style: 'fontSize', start: 8, end: 24, template: '%0pt'}
+ ];
+ var c = function(element,properties) {removeNode(element);};
+ return new Morpher(e,config.animDuration,p,c);
+}
+
+//--
+//-- Scroller animation
+//--
+
+function Scroller(targetElement)
+{
+ var p = [{style: '-tw-vertScroll', start: findScrollY(), end: ensureVisible(targetElement)}];
+ return new Morpher(targetElement,config.animDuration,p);
+}
+
+//--
+//-- Slider animation
+//--
+
+// deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element]
+function Slider(element,opening,unused,deleteMode)
+{
+ element.style.overflow = 'hidden';
+ if(opening)
+ element.style.height = '0px'; // Resolves a Firefox flashing bug
+ element.style.display = 'block';
+ var left = findPosX(element);
+ var width = element.scrollWidth;
+ var height = element.scrollHeight;
+ var winWidth = findWindowWidth();
+ var p = [];
+ var c = null;
+ if(opening) {
+ p.push({style: 'height', start: 0, end: height, template: '%0px', atEnd: 'auto'});
+ p.push({style: 'opacity', start: 0, end: 1, template: '%0'});
+ p.push({style: 'filter', start: 0, end: 100, template: 'alpha(opacity:%0)'});
+ } else {
+ p.push({style: 'height', start: height, end: 0, template: '%0px'});
+ p.push({style: 'display', atEnd: 'none'});
+ p.push({style: 'opacity', start: 1, end: 0, template: '%0'});
+ p.push({style: 'filter', start: 100, end: 0, template: 'alpha(opacity:%0)'});
+ switch(deleteMode) {
+ case "all":
+ c = function(element,properties) {removeNode(element);};
+ break;
+ case "children":
+ c = function(element,properties) {removeChildren(element);};
+ break;
+ }
+ }
+ return new Morpher(element,config.animDuration,p,c);
+}
+
+//--
+//-- Popup menu
+//--
+
+var Popup = {
+ stack: [] // Array of objects with members root: and popup:
+ };
+
+Popup.create = function(root,elem,className)
+{
+ var stackPosition = this.find(root,"popup");
+ Popup.remove(stackPosition+1);
+ var popup = createTiddlyElement(document.body,elem || "ol","popup",className || "popup");
+ popup.stackPosition = stackPosition;
+ Popup.stack.push({root: root, popup: popup});
+ return popup;
+};
+
+Popup.onDocumentClick = function(ev)
+{
+ var e = ev || window.event;
+ if(e.eventPhase == undefined)
+ Popup.remove();
+ else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET)
+ Popup.remove();
+ return true;
+};
+
+Popup.show = function(valign,halign,offset)
+{
+ var curr = Popup.stack[Popup.stack.length-1];
+ this.place(curr.root,curr.popup,valign,halign,offset);
+ addClass(curr.root,"highlight");
+ if(config.options.chkAnimate && anim && typeof Scroller == "function")
+ anim.startAnimating(new Scroller(curr.popup));
+ else
+ window.scrollTo(0,ensureVisible(curr.popup));
+};
+
+Popup.place = function(root,popup,valign,halign,offset)
+{
+ if(!offset)
+ var offset = {x:0,y:0};
+ if(popup.stackPosition >= 0 && !valign && !halign) {
+ offset.x = offset.x + root.offsetWidth;
+ } else {
+ offset.x = (halign == 'right') ? offset.x + root.offsetWidth : offset.x;
+ offset.y = (valign == 'top') ? offset.y : offset.y + root.offsetHeight;
+ }
+ var rootLeft = findPosX(root);
+ var rootTop = findPosY(root);
+ var popupLeft = rootLeft + offset.x;
+ var popupTop = rootTop + offset.y;
+ var winWidth = findWindowWidth();
+ if(popup.offsetWidth > winWidth*0.75)
+ popup.style.width = winWidth*0.75 + "px";
+ var popupWidth = popup.offsetWidth;
+ var scrollWidth = winWidth - document.body.offsetWidth;
+ if(popupLeft + popupWidth > winWidth - scrollWidth - 1) {
+ if(halign == 'right')
+ popupLeft = popupLeft - root.offsetWidth - popupWidth;
+ else
+ popupLeft = winWidth - popupWidth - scrollWidth - 1;
+ }
+ popup.style.left = popupLeft + "px";
+ popup.style.top = popupTop + "px";
+ popup.style.display = "block";
+};
+
+Popup.find = function(e)
+{
+ var pos = -1;
+ for (var t=this.stack.length-1; t>=0; t--) {
+ if(isDescendant(e,this.stack[t].popup))
+ pos = t;
+ }
+ return pos;
+};
+
+Popup.remove = function(pos)
+{
+ if(!pos) var pos = 0;
+ if(Popup.stack.length > pos) {
+ Popup.removeFrom(pos);
+ }
+};
+
+Popup.removeFrom = function(from)
+{
+ for(var t=Popup.stack.length-1; t>=from; t--) {
+ var p = Popup.stack[t];
+ removeClass(p.root,"highlight");
+ removeNode(p.popup);
+ }
+ Popup.stack = Popup.stack.slice(0,from);
+};
+
+//--
+//-- Wizard support
+//--
+
+function Wizard(elem)
+{
+ if(elem) {
+ this.formElem = findRelated(elem,"wizard","className");
+ this.bodyElem = findRelated(this.formElem.firstChild,"wizardBody","className","nextSibling");
+ this.footElem = findRelated(this.formElem.firstChild,"wizardFooter","className","nextSibling");
+ } else {
+ this.formElem = null;
+ this.bodyElem = null;
+ this.footElem = null;
+ }
+}
+
+Wizard.prototype.setValue = function(name,value)
+{
+ if(this.formElem)
+ this.formElem[name] = value;
+};
+
+Wizard.prototype.getValue = function(name)
+{
+ return this.formElem ? this.formElem[name] : null;
+};
+
+Wizard.prototype.createWizard = function(place,title)
+{
+ this.formElem = createTiddlyElement(place,"form",null,"wizard");
+ createTiddlyElement(this.formElem,"h1",null,null,title);
+ this.bodyElem = createTiddlyElement(this.formElem,"div",null,"wizardBody");
+ this.footElem = createTiddlyElement(this.formElem,"div",null,"wizardFooter");
+};
+
+Wizard.prototype.clear = function()
+{
+ removeChildren(this.bodyElem);
+};
+
+Wizard.prototype.setButtons = function(buttonInfo,status)
+{
+ removeChildren(this.footElem);
+ for(var t=0; t<buttonInfo.length; t++) {
+ createTiddlyButton(this.footElem,buttonInfo[t].caption,buttonInfo[t].tooltip,buttonInfo[t].onClick);
+ insertSpacer(this.footElem);
+ }
+ if(typeof status == "string") {
+ createTiddlyElement(this.footElem,"span",null,"status",status);
+ }
+};
+
+Wizard.prototype.addStep = function(stepTitle,html)
+{
+ removeChildren(this.bodyElem);
+ var w = createTiddlyElement(this.bodyElem,"div");
+ createTiddlyElement(w,"h2",null,null,stepTitle);
+ var step = createTiddlyElement(w,"div",null,"wizardStep");
+ step.innerHTML = html;
+ applyHtmlMacros(step,tiddler);
+};
+
+Wizard.prototype.getElement = function(name)
+{
+ return this.formElem.elements[name];
+};
+
+//--
+//-- ListView gadget
+//--
+
+var ListView = {};
+
+// Create a listview
+ListView.create = function(place,listObject,listTemplate,callback,className)
+{
+ var table = createTiddlyElement(place,"table",null,className || "listView twtable");
+ var thead = createTiddlyElement(table,"thead");
+ var r = createTiddlyElement(thead,"tr");
+ for(var t=0; t<listTemplate.columns.length; t++) {
+ var columnTemplate = listTemplate.columns[t];
+ var c = createTiddlyElement(r,"th");
+ var colType = ListView.columnTypes[columnTemplate.type];
+ if(colType && colType.createHeader) {
+ colType.createHeader(c,columnTemplate,t);
+ if(columnTemplate.className)
+ addClass(c,columnTemplate.className);
+ }
+ }
+ var tbody = createTiddlyElement(table,"tbody");
+ for(var rc=0; rc<listObject.length; rc++) {
+ var rowObject = listObject[rc];
+ r = createTiddlyElement(tbody,"tr");
+ for(c=0; c<listTemplate.rowClasses.length; c++) {
+ if(rowObject[listTemplate.rowClasses[c].field])
+ addClass(r,listTemplate.rowClasses[c].className);
+ }
+ rowObject.rowElement = r;
+ rowObject.colElements = {};
+ for(var cc=0; cc<listTemplate.columns.length; cc++) {
+ c = createTiddlyElement(r,"td");
+ columnTemplate = listTemplate.columns[cc];
+ var field = columnTemplate.field;
+ colType = ListView.columnTypes[columnTemplate.type];
+ if(colType && colType.createItem) {
+ colType.createItem(c,rowObject,field,columnTemplate,cc,rc);
+ if(columnTemplate.className)
+ addClass(c,columnTemplate.className);
+ }
+ rowObject.colElements[field] = c;
+ }
+ }
+ if(callback && listTemplate.actions)
+ createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions);
+ if(callback && listTemplate.buttons) {
+ for(t=0; t<listTemplate.buttons.length; t++) {
+ var a = listTemplate.buttons[t];
+ if(a && a.name != "")
+ createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection));
+ }
+ }
+ return table;
+};
+
+ListView.getCommandHandler = function(callback,name,allowEmptySelection)
+{
+ return function(e) {
+ var view = findRelated(this,"TABLE",null,"previousSibling");
+ var tiddlers = [];
+ ListView.forEachSelector(view,function(e,rowName) {
+ if(e.checked)
+ tiddlers.push(rowName);
+ });
+ if(tiddlers.length == 0 && !allowEmptySelection) {
+ alert(config.messages.nothingSelected);
+ } else {
+ if(this.nodeName.toLowerCase() == "select") {
+ callback(view,this.value,tiddlers);
+ this.selectedIndex = 0;
+ } else {
+ callback(view,name,tiddlers);
+ }
+ }
+ };
+};
+
+// Invoke a callback for each selector checkbox in the listview
+ListView.forEachSelector = function(view,callback)
+{
+ var checkboxes = view.getElementsByTagName("input");
+ var hadOne = false;
+ for(var t=0; t<checkboxes.length; t++) {
+ var cb = checkboxes[t];
+ if(cb.getAttribute("type") == "checkbox") {
+ var rn = cb.getAttribute("rowName");
+ if(rn) {
+ callback(cb,rn);
+ hadOne = true;
+ }
+ }
+ }
+ return hadOne;
+};
+
+ListView.getSelectedRows = function(view)
+{
+ var rowNames = [];
+ ListView.forEachSelector(view,function(e,rowName) {
+ if(e.checked)
+ rowNames.push(rowName);
+ });
+ return rowNames;
+};
+
+ListView.columnTypes = {};
+
+ListView.columnTypes.String = {
+ createHeader: function(place,columnTemplate,col)
+ {
+ createTiddlyText(place,columnTemplate.title);
+ },
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined)
+ createTiddlyText(place,v);
+ }
+};
+
+ListView.columnTypes.WikiText = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined)
+ wikify(v,place,null,null);
+ }
+};
+
+ListView.columnTypes.Tiddler = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined && v.title)
+ createTiddlyPopup(place,v.title,config.messages.listView.tiddlerTooltip,v);
+ }
+};
+
+ListView.columnTypes.Size = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined) {
+ var t = 0;
+ while(t<config.messages.sizeTemplates.length-1 && v<config.messages.sizeTemplates[t].unit)
+ t++;
+ createTiddlyText(place,config.messages.sizeTemplates[t].template.format([Math.round(v/config.messages.sizeTemplates[t].unit)]));
+ }
+ }
+};
+
+ListView.columnTypes.Link = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ var c = columnTemplate.text;
+ if(v != undefined)
+ createTiddlyText(createExternalLink(place,v),c || v);
+ }
+};
+
+ListView.columnTypes.Date = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined)
+ createTiddlyText(place,v.formatString(columnTemplate.dateFormat));
+ }
+};
+
+ListView.columnTypes.StringList = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined) {
+ for(var t=0; t<v.length; t++) {
+ createTiddlyText(place,v[t]);
+ createTiddlyElement(place,"br");
+ }
+ }
+ }
+};
+
+ListView.columnTypes.Selector = {
+ createHeader: function(place,columnTemplate,col)
+ {
+ createTiddlyCheckbox(place,null,false,this.onHeaderChange);
+ },
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var e = createTiddlyCheckbox(place,null,listObject[field],null);
+ e.setAttribute("rowName",listObject[columnTemplate.rowName]);
+ },
+ onHeaderChange: function(e)
+ {
+ var state = this.checked;
+ var view = findRelated(this,"TABLE");
+ if(!view)
+ return;
+ ListView.forEachSelector(view,function(e,rowName) {
+ e.checked = state;
+ });
+ }
+};
+
+ListView.columnTypes.Tags = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var tags = listObject[field];
+ createTiddlyText(place,String.encodeTiddlyLinkList(tags));
+ }
+};
+
+ListView.columnTypes.Boolean = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ if(listObject[field] == true)
+ createTiddlyText(place,columnTemplate.trueText);
+ if(listObject[field] == false)
+ createTiddlyText(place,columnTemplate.falseText);
+ }
+};
+
+ListView.columnTypes.TagCheckbox = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange);
+ e.setAttribute("tiddler",listObject.title);
+ e.setAttribute("tag",columnTemplate.tag);
+ },
+ onChange : function(e)
+ {
+ var tag = this.getAttribute("tag");
+ var tiddler = this.getAttribute("tiddler");
+ store.setTiddlerTag(tiddler,this.checked,tag);
+ }
+};
+
+ListView.columnTypes.TiddlerLink = {
+ createHeader: ListView.columnTypes.String.createHeader,
+ createItem: function(place,listObject,field,columnTemplate,col,row)
+ {
+ var v = listObject[field];
+ if(v != undefined) {
+ var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null);
+ createTiddlyText(link,listObject[field]);
+ }
+ }
+};
+
+//--
+//-- Augmented methods for the JavaScript Number(), Array(), String() and Date() objects
+//--
+
+// Clamp a number to a range
+Number.prototype.clamp = function(min,max)
+{
+ var c = this;
+ if(c < min)
+ c = min;
+ if(c > max)
+ c = max;
+ return c;
+};
+
+// Add indexOf function if browser does not support it
+if(!Array.indexOf) {
+Array.prototype.indexOf = function(item,from)
+{
+ if(!from)
+ from = 0;
+ for(var i=from; i<this.length; i++) {
+ if(this[i] === item)
+ return i;
+ }
+ return -1;
+};}
+
+// Find an entry in a given field of the members of an array
+Array.prototype.findByField = function(field,value)
+{
+ for(var t=0; t<this.length; t++) {
+ if(this[t][field] == value)
+ return t;
+ }
+ return null;
+};
+
+// Return whether an entry exists in an array
+Array.prototype.contains = function(item)
+{
+ return this.indexOf(item) != -1;
+};
+
+// Adds, removes or toggles a particular value within an array
+// value - value to add
+// mode - +1 to add value, -1 to remove value, 0 to toggle it
+Array.prototype.setItem = function(value,mode)
+{
+ var p = this.indexOf(value);
+ if(mode == 0)
+ mode = (p == -1) ? +1 : -1;
+ if(mode == +1) {
+ if(p == -1)
+ this.push(value);
+ } else if(mode == -1) {
+ if(p != -1)
+ this.splice(p,1);
+ }
+};
+
+// Return whether one of a list of values exists in an array
+Array.prototype.containsAny = function(items)
+{
+ for(var i=0; i<items.length; i++) {
+ if(this.indexOf(items[i]) != -1)
+ return true;
+ }
+ return false;
+};
+
+// Return whether all of a list of values exists in an array
+Array.prototype.containsAll = function(items)
+{
+ for(var i = 0; i<items.length; i++) {
+ if(this.indexOf(items[i]) == -1)
+ return false;
+ }
+ return true;
+};
+
+// Push a new value into an array only if it is not already present in the array. If the optional unique parameter is false, it reverts to a normal push
+Array.prototype.pushUnique = function(item,unique)
+{
+ if(unique === false) {
+ this.push(item);
+ } else {
+ if(this.indexOf(item) == -1)
+ this.push(item);
+ }
+};
+
+Array.prototype.remove = function(item)
+{
+ var p = this.indexOf(item);
+ if(p != -1)
+ this.splice(p,1);
+};
+
+if(!Array.prototype.map) {
+Array.prototype.map = function(fn,thisObj)
+{
+ var scope = thisObj || window;
+ var a = [];
+ for(var i=0, j=this.length; i < j; ++i) {
+ a.push(fn.call(scope,this[i],i,this));
+ }
+ return a;
+};}
+
+// Get characters from the right end of a string
+String.prototype.right = function(n)
+{
+ return n < this.length ? this.slice(this.length-n) : this;
+};
+
+// Trim whitespace from both ends of a string
+String.prototype.trim = function()
+{
+ return this.replace(/^\s*|\s*$/g,"");
+};
+
+// Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor")
+String.prototype.unDash = function()
+{
+ var s = this.split("-");
+ if(s.length > 1) {
+ for(var t=1; t<s.length; t++)
+ s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1);
+ }
+ return s.join("");
+};
+
+// Substitute substrings from an array into a format string that includes '%1'-type specifiers
+String.prototype.format = function(substrings)
+{
+ var subRegExp = /(?:%(\d+))/mg;
+ var currPos = 0;
+ var r = [];
+ do {
+ var match = subRegExp.exec(this);
+ if(match && match[1]) {
+ if(match.index > currPos)
+ r.push(this.substring(currPos,match.index));
+ r.push(substrings[parseInt(match[1])]);
+ currPos = subRegExp.lastIndex;
+ }
+ } while(match);
+ if(currPos < this.length)
+ r.push(this.substring(currPos,this.length));
+ return r.join("");
+};
+
+// Escape any special RegExp characters with that character preceded by a backslash
+String.prototype.escapeRegExp = function()
+{
+ var s = "\\^$*+?()=!|,{}[].";
+ var c = this;
+ for(var t=0; t<s.length; t++)
+ c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1));
+ return c;
+};
+
+// Convert "\" to "\s", newlines to "\n" (and remove carriage returns)
+String.prototype.escapeLineBreaks = function()
+{
+ return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,"");
+};
+
+// Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns)
+String.prototype.unescapeLineBreaks = function()
+{
+ return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,"");
+};
+
+// Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;"
+String.prototype.htmlEncode = function()
+{
+ return this.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;");
+};
+
+// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
+String.prototype.htmlDecode = function()
+{
+ return this.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&");
+};
+
+// Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org
+String.prototype.toJSONString = function()
+{
+ var m = {
+ '\b': '\\b',
+ '\f': '\\f',
+ '\n': '\\n',
+ '\r': '\\r',
+ '\t': '\\t',
+ '"' : '\\"',
+ '\\': '\\\\'
+ };
+ var replaceFn = function(a,b) {
+ var c = m[b];
+ if(c)
+ return c;
+ c = b.charCodeAt();
+ return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
+ };
+ if(/["\\\x00-\x1f]/.test(this))
+ return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"';
+ return '"' + this + '"';
+};
+
+// Parse a space-separated string of name:value parameters
+// The result is an array of objects:
+// result[0] = object with a member for each parameter name, value of that member being an array of values
+// result[1..n] = one object for each parameter, with 'name' and 'value' members
+String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults)
+{
+ var parseToken = function(match,p) {
+ var n;
+ if(match[p]) // Double quoted
+ n = match[p];
+ else if(match[p+1]) // Single quoted
+ n = match[p+1];
+ else if(match[p+2]) // Double-square-bracket quoted
+ n = match[p+2];
+ else if(match[p+3]) // Double-brace quoted
+ try {
+ n = match[p+3];
+ if(allowEval)
+ n = window.eval(n);
+ } catch(ex) {
+ throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(ex);
+ }
+ else if(match[p+4]) // Unquoted
+ n = match[p+4];
+ else if(match[p+5]) // empty quote
+ n = "";
+ return n;
+ };
+ var r = [{}];
+ var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
+ var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
+ var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
+ var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
+ var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
+ var emptyQuote = "((?:\"\")|(?:''))";
+ var skipSpace = "(?:\\s*)";
+ var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
+ var re = noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
+ var params = [];
+ do {
+ var match = re.exec(this);
+ if(match) {
+ var n = parseToken(match,1);
+ if(noNames) {
+ r.push({name:"",value:n});
+ } else {
+ var v = parseToken(match,8);
+ if(v == null && defaultName) {
+ v = n;
+ n = defaultName;
+ } else if(v == null && defaultValue) {
+ v = defaultValue;
+ }
+ r.push({name:n,value:v});
+ if(cascadeDefaults) {
+ defaultName = n;
+ defaultValue = v;
+ }
+ }
+ }
+ } while(match);
+ // Summarise parameters into first element
+ for(var t=1; t<r.length; t++) {
+ if(r[0][r[t].name])
+ r[0][r[t].name].push(r[t].value);
+ else
+ r[0][r[t].name] = [r[t].value];
+ }
+ return r;
+};
+
+// Process a string list of macro parameters into an array. Parameters can be quoted with "", '',
+// [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in
+// an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name.
+String.prototype.readMacroParams = function()
+{
+ var p = this.parseParams("list",null,true,true);
+ var n = [];
+ for(var t=1; t<p.length; t++)
+ n.push(p[t].value);
+ return n;
+};
+
+// Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]]
+String.prototype.readBracketedList = function(unique)
+{
+ var p = this.parseParams("list",null,false,true);
+ var n = [];
+ for(var t=1; t<p.length; t++) {
+ if(p[t].value)
+ n.pushUnique(p[t].value,unique);
+ }
+ return n;
+};
+
+// Returns array with start and end index of chunk between given start and end marker, or undefined.
+String.prototype.getChunkRange = function(start,end)
+{
+ var s = this.indexOf(start);
+ if(s != -1) {
+ s += start.length;
+ var e = this.indexOf(end,s);
+ if(e != -1)
+ return [s,e];
+ }
+};
+
+// Replace a chunk of a string given start and end markers
+String.prototype.replaceChunk = function(start,end,sub)
+{
+ var r = this.getChunkRange(start,end);
+ return r ? this.substring(0,r[0]) + sub + this.substring(r[1]) : this;
+};
+
+// Returns a chunk of a string between start and end markers, or undefined
+String.prototype.getChunk = function(start,end)
+{
+ var r = this.getChunkRange(start,end);
+ if(r)
+ return this.substring(r[0],r[1]);
+};
+
+
+// Static method to bracket a string with double square brackets if it contains a space
+String.encodeTiddlyLink = function(title)
+{
+ return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
+};
+
+// Static method to encodeTiddlyLink for every item in an array and join them with spaces
+String.encodeTiddlyLinkList = function(list)
+{
+ if(list) {
+ var results = [];
+ for(var t=0; t<list.length; t++)
+ results.push(String.encodeTiddlyLink(list[t]));
+ return results.join(" ");
+ } else {
+ return "";
+ }
+};
+
+// Convert a string as a sequence of name:"value" pairs into a hashmap
+String.prototype.decodeHashMap = function()
+{
+ var fields = this.parseParams("anon","",false);
+ var r = {};
+ for(var t=1; t<fields.length; t++)
+ r[fields[t].name] = fields[t].value;
+ return r;
+};
+
+// Static method to encode a hashmap into a name:"value"... string
+String.encodeHashMap = function(hashmap)
+{
+ var r = [];
+ for(var t in hashmap)
+ r.push(t + ':"' + hashmap[t] + '"');
+ return r.join(" ");
+};
+
+// Static method to left-pad a string with 0s to a certain width
+String.zeroPad = function(n,d)
+{
+ var s = n.toString();
+ if(s.length < d)
+ s = "000000000000000000000000000".substr(0,d-s.length) + s;
+ return s;
+};
+
+String.prototype.startsWith = function(prefix)
+{
+ return !prefix || this.substring(0,prefix.length) == prefix;
+};
+
+// Returns the first value of the given named parameter.
+function getParam(params,name,defaultValue)
+{
+ if(!params)
+ return defaultValue;
+ var p = params[0][name];
+ return p ? p[0] : defaultValue;
+}
+
+// Returns the first value of the given boolean named parameter.
+function getFlag(params,name,defaultValue)
+{
+ return !!getParam(params,name,defaultValue);
+}
+
+// Substitute date components into a string
+Date.prototype.formatString = function(template)
+{
+ var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
+ t = t.replace(/hh12/g,this.getHours12());
+ t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2));
+ t = t.replace(/hh/g,this.getHours());
+ t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]);
+ t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
+ t = t.replace(/mm/g,this.getMinutes());
+ t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
+ t = t.replace(/ss/g,this.getSeconds());
+ t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase());
+ t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase());
+ t = t.replace(/wYYYY/g,this.getYearForWeekNo());
+ t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
+ t = t.replace(/YYYY/g,this.getFullYear());
+ t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
+ t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]);
+ t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
+ t = t.replace(/MM/g,this.getMonth()+1);
+ t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
+ t = t.replace(/WW/g,this.getWeek());
+ t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]);
+ t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]);
+ t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2));
+ t = t.replace(/DDth/g,this.getDate()+this.daySuffix());
+ t = t.replace(/DD/g,this.getDate());
+ var tz = this.getTimezoneOffset();
+ var atz = Math.abs(tz);
+ t = t.replace(/TZD/g,(tz < 0 ? '+' : '-') + String.zeroPad(Math.floor(atz / 60),2) + ':' + String.zeroPad(atz % 60,2));
+ t = t.replace(/\\/g,"");
+ return t;
+};
+
+Date.prototype.getWeek = function()
+{
+ var dt = new Date(this.getTime());
+ var d = dt.getDay();
+ if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
+ dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo
+ var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);
+ return Math.floor(n/7)+1;
+};
+
+Date.prototype.getYearForWeekNo = function()
+{
+ var dt = new Date(this.getTime());
+ var d = dt.getDay();
+ if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
+ dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week
+ return dt.getFullYear();
+};
+
+Date.prototype.getHours12 = function()
+{
+ var h = this.getHours();
+ return h > 12 ? h-12 : ( h > 0 ? h : 12 );
+};
+
+Date.prototype.getAmPm = function()
+{
+ return this.getHours() >= 12 ? config.messages.dates.pm : config.messages.dates.am;
+};
+
+Date.prototype.daySuffix = function()
+{
+ return config.messages.dates.daySuffixes[this.getDate()-1];
+};
+
+// Convert a date to local YYYYMMDDHHMM string format
+Date.prototype.convertToLocalYYYYMMDDHHMM = function()
+{
+ return this.getFullYear() + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2);
+};
+
+// Convert a date to UTC YYYYMMDDHHMM string format
+Date.prototype.convertToYYYYMMDDHHMM = function()
+{
+ return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2);
+};
+
+// Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
+Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
+{
+ return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),4);
+};
+
+// Static method to create a date from a UTC YYYYMMDDHHMM format string
+Date.convertFromYYYYMMDDHHMM = function(d)
+{
+ var hh = d.substr(8,2) || "00";
+ var mm = d.substr(10,2) || "00";
+ return new Date(Date.UTC(parseInt(d.substr(0,4),10),
+ parseInt(d.substr(4,2),10)-1,
+ parseInt(d.substr(6,2),10),
+ parseInt(hh,10),
+ parseInt(mm,10),0,0));
+};
+
+//--
+//-- Crypto functions and associated conversion routines
+//--
+
+// Crypto 'namespace'
+function Crypto() {}
+
+// Convert a string to an array of big-endian 32-bit words
+Crypto.strToBe32s = function(str)
+{
+ var be=[];
+ var len=Math.floor(str.length/4);
+ var i, j;
+ for(i=0, j=0; i<len; i++, j+=4) {
+ be[i]=((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
+ }
+ while(j<str.length) {
+ be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
+ j++;
+ }
+ return be;
+};
+
+// Convert an array of big-endian 32-bit words to a string
+Crypto.be32sToStr = function(be)
+{
+ var str='';
+ for(var i=0;i<be.length*32;i+=8) {
+ str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
+ }
+ return str;
+};
+
+// Convert an array of big-endian 32-bit words to a hex string
+Crypto.be32sToHex = function(be)
+{
+ var hex='0123456789ABCDEF';
+ var str='';
+ for(var i=0;i<be.length*4;i++) {
+ str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
+ }
+ return str;
+};
+
+// Return, in hex, the SHA-1 hash of a string
+Crypto.hexSha1Str = function(str)
+{
+ return Crypto.be32sToHex(Crypto.sha1Str(str));
+};
+
+// Return the SHA-1 hash of a string
+Crypto.sha1Str = function(str)
+{
+ return Crypto.sha1(Crypto.strToBe32s(str),str.length);
+};
+
+// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
+Crypto.sha1 = function(x,blen)
+{
+ // Add 32-bit integers, wrapping at 32 bits
+ function add32(a,b)
+ {
+ var lsw=(a&0xFFFF)+(b&0xFFFF);
+ var msw=(a>>16)+(b>>16)+(lsw>>16);
+ return (msw<<16)|(lsw&0xFFFF);
+ }
+ function AA(a,b,c,d,e)
+ {
+ b=(b>>>27)|(b<<5);
+ var lsw=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
+ var msw=(a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
+ return (msw<<16)|(lsw&0xFFFF);
+ }
+ function RR(w,j)
+ {
+ var n=w[j-3]^w[j-8]^w[j-14]^w[j-16];
+ return (n>>>31)|(n<<1);
+ }
+
+ var len=blen*8;
+ x[len>>5] |= 0x80 << (24-len%32);
+ x[((len+64>>9)<<4)+15]=len;
+ var w=new Array(80);
+
+ var k1=0x5A827999;
+ var k2=0x6ED9EBA1;
+ var k3=0x8F1BBCDC;
+ var k4=0xCA62C1D6;
+
+ var h0=0x67452301;
+ var h1=0xEFCDAB89;
+ var h2=0x98BADCFE;
+ var h3=0x10325476;
+ var h4=0xC3D2E1F0;
+
+ for(var i=0;i<x.length;i+=16) {
+ var j=0;
+ var t;
+ var a=h0;
+ var b=h1;
+ var c=h2;
+ var d=h3;
+ var e=h4;
+ while(j<16) {
+ w[j]=x[i+j];
+ t=AA(e,a,d^(b&(c^d)),w[j],k1);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<20) {
+ w[j]=RR(w,j);
+ t=AA(e,a,d^(b&(c^d)),w[j],k1);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<40) {
+ w[j]=RR(w,j);
+ t=AA(e,a,b^c^d,w[j],k2);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<60) {
+ w[j]=RR(w,j);
+ t=AA(e,a,(b&c)|(d&(b|c)),w[j],k3);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ while(j<80) {
+ w[j]=RR(w,j);
+ t=AA(e,a,b^c^d,w[j],k4);
+ e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
+ }
+ h0=add32(h0,a);
+ h1=add32(h1,b);
+ h2=add32(h2,c);
+ h3=add32(h3,d);
+ h4=add32(h4,e);
+ }
+ return [h0,h1,h2,h3,h4];
+};
+
+//--
+//-- RGB colour object
+//--
+
+// Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values
+function RGB(r,g,b)
+{
+ this.r = 0;
+ this.g = 0;
+ this.b = 0;
+ if(typeof r == "string") {
+ if(r.substr(0,1) == "#") {
+ if(r.length == 7) {
+ this.r = parseInt(r.substr(1,2),16)/255;
+ this.g = parseInt(r.substr(3,2),16)/255;
+ this.b = parseInt(r.substr(5,2),16)/255;
+ } else {
+ this.r = parseInt(r.substr(1,1),16)/15;
+ this.g = parseInt(r.substr(2,1),16)/15;
+ this.b = parseInt(r.substr(3,1),16)/15;
+ }
+ } else {
+ var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/;
+ var c = r.match(rgbPattern);
+ if(c) {
+ this.r = parseInt(c[1],10)/255;
+ this.g = parseInt(c[2],10)/255;
+ this.b = parseInt(c[3],10)/255;
+ }
+ }
+ } else {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ }
+ return this;
+}
+
+// Mixes this colour with another in a specified proportion
+// c = other colour to mix
+// f = 0..1 where 0 is this colour and 1 is the new colour
+// Returns an RGB object
+RGB.prototype.mix = function(c,f)
+{
+ return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f);
+};
+
+// Return an rgb colour as a #rrggbb format hex string
+RGB.prototype.toString = function()
+{
+ return "#" + ("0" + Math.floor(this.r.clamp(0,1) * 255).toString(16)).right(2) +
+ ("0" + Math.floor(this.g.clamp(0,1) * 255).toString(16)).right(2) +
+ ("0" + Math.floor(this.b.clamp(0,1) * 255).toString(16)).right(2);
+};
+
+//--
+//-- DOM utilities - many derived from www.quirksmode.org
+//--
+
+function drawGradient(place,horiz,locolors,hicolors)
+{
+ if(!hicolors)
+ hicolors = locolors;
+ for(var t=0; t<= 100; t+=2) {
+ var bar = document.createElement("div");
+ place.appendChild(bar);
+ bar.style.position = "absolute";
+ bar.style.left = horiz ? t + "%" : 0;
+ bar.style.top = horiz ? 0 : t + "%";
+ bar.style.width = horiz ? (101-t) + "%" : "100%";
+ bar.style.height = horiz ? "100%" : (101-t) + "%";
+ bar.style.zIndex = -1;
+ var p = t/100*(locolors.length-1);
+ var hc = hicolors[Math.floor(p)];
+ if(typeof hc == "string")
+ hc = new RGB(hc);
+ var lc = locolors[Math.ceil(p)];
+ if(typeof lc == "string")
+ lc = new RGB(lc);
+ bar.style.backgroundColor = hc.mix(lc,p-Math.floor(p)).toString();
+ }
+}
+
+function createTiddlyText(parent,text)
+{
+ return parent.appendChild(document.createTextNode(text));
+}
+
+function createTiddlyCheckbox(parent,caption,checked,onChange)
+{
+ var cb = document.createElement("input");
+ cb.setAttribute("type","checkbox");
+ cb.onclick = onChange;
+ parent.appendChild(cb);
+ cb.checked = checked;
+ cb.className = "chkOptionInput";
+ if(caption)
+ wikify(caption,parent);
+ return cb;
+}
+
+function createTiddlyElement(parent,element,id,className,text,attribs)
+{
+ var e = document.createElement(element);
+ if(className != null)
+ e.className = className;
+ if(id != null)
+ e.setAttribute("id",id);
+ if(text != null)
+ e.appendChild(document.createTextNode(text));
+ if(attribs) {
+ for(var n in attribs) {
+ e.setAttribute(n,attribs[n]);
+ }
+ }
+ if(parent != null)
+ parent.appendChild(e);
+ return e;
+}
+
+function addEvent(obj,type,fn)
+{
+ if(obj.attachEvent) {
+ obj['e'+type+fn] = fn;
+ obj[type+fn] = function(){obj['e'+type+fn](window.event);};
+ obj.attachEvent('on'+type,obj[type+fn]);
+ } else {
+ obj.addEventListener(type,fn,false);
+ }
+}
+
+function removeEvent(obj,type,fn)
+{
+ if(obj.detachEvent) {
+ obj.detachEvent('on'+type,obj[type+fn]);
+ obj[type+fn] = null;
+ } else {
+ obj.removeEventListener(type,fn,false);
+ }
+}
+
+function addClass(e,className)
+{
+ var currClass = e.className.split(" ");
+ if(currClass.indexOf(className) == -1)
+ e.className += " " + className;
+}
+
+function removeClass(e,className)
+{
+ var currClass = e.className.split(" ");
+ var i = currClass.indexOf(className);
+ while(i != -1) {
+ currClass.splice(i,1);
+ i = currClass.indexOf(className);
+ }
+ e.className = currClass.join(" ");
+}
+
+function hasClass(e,className)
+{
+ if(e.className && e.className.split(" ").indexOf(className) != -1) {
+ return true;
+ }
+ return false;
+}
+
+// Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode)
+function findRelated(e,value,name,relative)
+{
+ name = name || "tagName";
+ relative = relative || "parentNode";
+ if(name == "className") {
+ while(e && !hasClass(e,value)) {
+ e = e[relative];
+ }
+ } else {
+ while(e && e[name] != value) {
+ e = e[relative];
+ }
+ }
+ return e;
+}
+
+// Resolve the target object of an event
+function resolveTarget(e)
+{
+ var obj;
+ if(e.target)
+ obj = e.target;
+ else if(e.srcElement)
+ obj = e.srcElement;
+ if(obj.nodeType == 3) // defeat Safari bug
+ obj = obj.parentNode;
+ return obj;
+}
+
+// Prevent an event from bubbling
+function stopEvent(e)
+{
+ var ev = e || window.event;
+ ev.cancelBubble = true;
+ if(ev.stopPropagation) ev.stopPropagation();
+ return false;
+}
+
+// Return the content of an element as plain text with no formatting
+function getPlainText(e)
+{
+ var text = "";
+ if(e.innerText)
+ text = e.innerText;
+ else if(e.textContent)
+ text = e.textContent;
+ return text;
+}
+
+// Get the scroll position for window.scrollTo necessary to scroll a given element into view
+function ensureVisible(e)
+{
+ var posTop = findPosY(e);
+ var posBot = posTop + e.offsetHeight;
+ var winTop = findScrollY();
+ var winHeight = findWindowHeight();
+ var winBot = winTop + winHeight;
+ if(posTop < winTop) {
+ return posTop;
+ } else if(posBot > winBot) {
+ if(e.offsetHeight < winHeight)
+ return posTop - (winHeight - e.offsetHeight);
+ else
+ return posTop;
+ } else {
+ return winTop;
+ }
+}
+
+// Get the current width of the display window
+function findWindowWidth()
+{
+ return window.innerWidth || document.documentElement.clientWidth;
+}
+
+// Get the current height of the display window
+function findWindowHeight()
+{
+ return window.innerHeight || document.documentElement.clientHeight;
+}
+
+// Get the current horizontal page scroll position
+function findScrollX()
+{
+ return window.scrollX || document.documentElement.scrollLeft;
+}
+
+// Get the current vertical page scroll position
+function findScrollY()
+{
+ return window.scrollY || document.documentElement.scrollTop;
+}
+
+function findPosX(obj)
+{
+ var curleft = 0;
+ while(obj.offsetParent) {
+ curleft += obj.offsetLeft;
+ obj = obj.offsetParent;
+ }
+ return curleft;
+}
+
+function findPosY(obj)
+{
+ var curtop = 0;
+ while(obj.offsetParent) {
+ curtop += obj.offsetTop;
+ obj = obj.offsetParent;
+ }
+ return curtop;
+}
+
+// Blur a particular element
+function blurElement(e)
+{
+ if(e && e.focus && e.blur) {
+ e.focus();
+ e.blur();
+ }
+}
+
+// Create a non-breaking space
+function insertSpacer(place)
+{
+ var e = document.createTextNode(String.fromCharCode(160));
+ if(place)
+ place.appendChild(e);
+ return e;
+}
+
+// Remove all children of a node
+function removeChildren(e)
+{
+ while(e && e.hasChildNodes())
+ removeNode(e.firstChild);
+}
+
+// Remove a node and all it's children
+function removeNode(e)
+{
+ scrubNode(e);
+ e.parentNode.removeChild(e);
+}
+
+// Remove any event handlers or non-primitve custom attributes
+function scrubNode(e)
+{
+ if(!config.browser.isIE)
+ return;
+ var att = e.attributes;
+ if(att) {
+ for(var t=0; t<att.length; t++) {
+ var n = att[t].name;
+ if(n !== 'style' && (typeof e[n] === 'function' || (typeof e[n] === 'object' && e[n] != null))) {
+ try {
+ e[n] = null;
+ } catch(ex) {
+ }
+ }
+ }
+ }
+ var c = e.firstChild;
+ while(c) {
+ scrubNode(c);
+ c = c.nextSibling;
+ }
+}
+
+// Add a stylesheet, replacing any previous custom stylesheet
+function setStylesheet(s,id,doc)
+{
+ if(!id)
+ id = "customStyleSheet";
+ if(!doc)
+ doc = document;
+ var n = doc.getElementById(id);
+ if(doc.createStyleSheet) {
+ // Test for IE's non-standard createStyleSheet method
+ if(n)
+ n.parentNode.removeChild(n);
+ // This failed without the &nbsp;
+ doc.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd","&nbsp;<style id='" + id + "'>" + s + "</style>");
+ } else {
+ if(n) {
+ n.replaceChild(doc.createTextNode(s),n.firstChild);
+ } else {
+ n = doc.createElement("style");
+ n.type = "text/css";
+ n.id = id;
+ n.appendChild(doc.createTextNode(s));
+ doc.getElementsByTagName("head")[0].appendChild(n);
+ }
+ }
+}
+
+function removeStyleSheet(id)
+{
+ var e = document.getElementById(id);
+ if(e)
+ e.parentNode.removeChild(e);
+}
+
+// Force the browser to do a document reflow when needed to workaround browser bugs
+function forceReflow()
+{
+ if(config.browser.isGecko) {
+ setStylesheet("body {top:0px;margin-top:0px;}","forceReflow");
+ setTimeout(function() {setStylesheet("","forceReflow");},1);
+ }
+}
+
+// Replace the current selection of a textarea or text input and scroll it into view
+function replaceSelection(e,text)
+{
+ if(e.setSelectionRange) {
+ var oldpos = e.selectionStart;
+ var isRange = e.selectionEnd > e.selectionStart;
+ e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionEnd);
+ e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + text.length);
+ var linecount = e.value.split('\n').length;
+ var thisline = e.value.substr(0,e.selectionStart).split('\n').length-1;
+ e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / linecount);
+ } else if(document.selection) {
+ var range = document.selection.createRange();
+ if(range.parentElement() == e) {
+ var isCollapsed = range.text == "";
+ range.text = text;
+ if(!isCollapsed) {
+ range.moveStart('character', -text.length);
+ range.select();
+ }
+ }
+ }
+}
+
+// Returns the text of the given (text) node, possibly merging subsequent text nodes
+function getNodeText(e)
+{
+ var t = "";
+ while(e && e.nodeName == "#text") {
+ t += e.nodeValue;
+ e = e.nextSibling;
+ }
+ return t;
+}
+
+// Returns true if the element e has a given ancestor element
+function isDescendant(e,ancestor)
+{
+ while(e) {
+ if(e === ancestor)
+ return true;
+ e = e.parentNode;
+ }
+ return false;
+}
+
+//--
+//-- LoaderBase and SaverBase
+//--
+
+function LoaderBase() {}
+
+LoaderBase.prototype.loadTiddler = function(store,node,tiddlers)
+{
+ var title = this.getTitle(store,node);
+ if(safeMode && store.isShadowTiddler(title))
+ return;
+ if(title) {
+ var tiddler = store.createTiddler(title);
+ this.internalizeTiddler(store,tiddler,title,node);
+ tiddlers.push(tiddler);
+ }
+};
+
+LoaderBase.prototype.loadTiddlers = function(store,nodes)
+{
+ var tiddlers = [];
+ for(var t = 0; t < nodes.length; t++) {
+ try {
+ this.loadTiddler(store,nodes[t],tiddlers);
+ } catch(ex) {
+ showException(ex,config.messages.tiddlerLoadError.format([this.getTitle(store,nodes[t])]));
+ }
+ }
+ return tiddlers;
+};
+
+function SaverBase() {}
+
+SaverBase.prototype.externalize = function(store)
+{
+ var results = [];
+ var tiddlers = store.getTiddlers("title");
+ for(var t = 0; t < tiddlers.length; t++) {
+ if(!tiddlers[t].doNotSave())
+ results.push(this.externalizeTiddler(store, tiddlers[t]));
+ }
+ return results.join("\n");
+};
+
+//--
+//-- TW21Loader (inherits from LoaderBase)
+//--
+
+function TW21Loader() {}
+
+TW21Loader.prototype = new LoaderBase();
+
+TW21Loader.prototype.getTitle = function(store,node)
+{
+ var title = null;
+ if(node.getAttribute) {
+ title = node.getAttribute("title");
+ if(!title)
+ title = node.getAttribute("tiddler");
+ }
+ if(!title && node.id) {
+ var lenPrefix = store.idPrefix.length;
+ if(node.id.substr(0,lenPrefix) == store.idPrefix)
+ title = node.id.substr(lenPrefix);
+ }
+ return title;
+};
+
+TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node)
+{
+ var e = node.firstChild;
+ var text = null;
+ if(node.getAttribute("tiddler")) {
+ text = getNodeText(e).unescapeLineBreaks();
+ } else {
+ while(e.nodeName!="PRE" && e.nodeName!="pre") {
+ e = e.nextSibling;
+ }
+ text = e.innerHTML.replace(/\r/mg,"").htmlDecode();
+ }
+ var modifier = node.getAttribute("modifier");
+ var c = node.getAttribute("created");
+ var m = node.getAttribute("modified");
+ var created = c ? Date.convertFromYYYYMMDDHHMM(c) : version.date;
+ var modified = m ? Date.convertFromYYYYMMDDHHMM(m) : created;
+ var tags = node.getAttribute("tags");
+ var fields = {};
+ var attrs = node.attributes;
+ for(var i = attrs.length-1; i >= 0; i--) {
+ var name = attrs[i].name;
+ if(attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
+ fields[name] = attrs[i].value.unescapeLineBreaks();
+ }
+ }
+ tiddler.assign(title,text,modifier,modified,tags,created,fields);
+ return tiddler;
+};
+
+//--
+//-- TW21Saver (inherits from SaverBase)
+//--
+
+function TW21Saver() {}
+
+TW21Saver.prototype = new SaverBase();
+
+TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
+{
+ try {
+ var extendedAttributes = "";
+ var usePre = config.options.chkUsePreForStorage;
+ store.forEachField(tiddler,
+ function(tiddler,fieldName,value) {
+ // don't store stuff from the temp namespace
+ if(typeof value != "string")
+ value = "";
+ if(!fieldName.match(/^temp\./))
+ extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
+ },true);
+ var created = tiddler.created;
+ var modified = tiddler.modified;
+ var attributes = tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
+ attributes += (usePre && created == version.date) ? "" :' created="' + created.convertToYYYYMMDDHHMM() + '"';
+ attributes += (usePre && modified == created) ? "" : ' modified="' + modified.convertToYYYYMMDDHHMM() +'"';
+ var tags = tiddler.getTags();
+ if(!usePre || tags)
+ attributes += ' tags="' + tags.htmlEncode() + '"';
+ return ('<div %0="%1"%2%3>%4</'+'div>').format([
+ usePre ? "title" : "tiddler",
+ tiddler.title.htmlEncode(),
+ attributes,
+ extendedAttributes,
+ usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode()
+ ]);
+ } catch (ex) {
+ throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
+ }
+};
+
+//]]>
+</script>
+<script id="jsdeprecatedArea" type="text/javascript">
+//<![CDATA[
+//--
+//-- Deprecated Tiddler code
+//--
+
+// @Deprecated: Use tiddlerToRssItem(tiddler,uri) instead
+Tiddler.prototype.toRssItem = function(uri)
+{
+ return tiddlerToRssItem(this,uri);
+};
+
+// @Deprecated: Use "<item>\n" + tiddlerToRssItem(tiddler,uri) + "\n</item>" instead
+Tiddler.prototype.saveToRss = function(uri)
+{
+ return "<item>\n" + tiddlerToRssItem(this,uri) + "\n</item>";
+};
+
+//]]>
+</script>
+<script id="jqueryArea" type="text/javascript">
+//<![CDATA[
+//]]>
+</script>
+<script type="text/javascript">
+//<![CDATA[
+if(useJavaSaver)
+ document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>");
+//]]>
+</script>
+<!--POST-SCRIPT-START-->
+<!--POST-SCRIPT-END-->
+</body>
+</html>
diff --git a/utils.py b/utils.py
new file mode 100755
index 0000000..0fb2026
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,32 @@
+# -*- mode:python; tab-width:4; indent-tabs-mode:t; -*-
+
+import os
+import gtk
+
+def getFileType(filename):
+ return os.path.basename(filename).split('.').pop()
+
+def copy_file(src, dest):
+ f1 = open(src, "rb")
+ data = f1.read()
+ f1.close()
+ f2 = open(dest, "wb")
+ f2.write(data)
+ f2.close()
+
+def run_dialog(header,msg):
+ """Pops up a blocking dialog box with 'msg'"""
+ dialog = gtk.Dialog(str(header), None, gtk.DIALOG_MODAL,
+ (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+
+ hbox = gtk.HBox(False, 12)
+ hbox.set_border_width(12)
+ dialog.vbox.pack_start(hbox, True, True, 0)
+ hbox.show()
+
+ label = gtk.Label(str(msg))
+ hbox.pack_start(label, False, False, 0)
+ label.show()
+
+ dialog.run()
+ dialog.destroy()