app/taggable-mixin/taggable.html
author James Levy <jamesalexanderlevy@gmail.com>
Sun, 28 Jun 2009 14:18:01 +0200
changeset 2431 800a020c9bcf
parent 2368 e07c425c7135
permissions -rw-r--r--
Added logic for Survey and SurveyRecord. The logic for the SurveyRecord will be seperated within the upcoming days. Patch by: James Levy, Daniel Diniz, Lennard de Rijk Reviewed by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2368
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     3
<head>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
<script id="versionArea" type="text/javascript">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
//<![CDATA[
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
var version = {title: "TiddlyWiki", major: 2, minor: 4, revision: 0, date: new Date("May 9, 2008"), extensions: {}};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
//]]>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
</script>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
<meta name="copyright" content="
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    11
TiddlyWiki created by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    12
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    13
Copyright (c) UnaMesa Association 2004-2008
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    14
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    15
Redistribution and use in source and binary forms, with or without modification,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    16
are permitted provided that the following conditions are met:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    17
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    18
Redistributions of source code must retain the above copyright notice, this
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    19
list of conditions and the following disclaimer.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    20
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    21
Redistributions in binary form must reproduce the above copyright notice, this
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    22
list of conditions and the following disclaimer in the documentation and/or other
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
materials provided with the distribution.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    24
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    25
Neither the name of the UnaMesa Association nor the names of its contributors may be
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    26
used to endorse or promote products derived from this software without specific
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    27
prior written permission.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    28
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    29
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    30
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    31
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    32
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    33
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    34
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    35
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    36
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    37
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    38
DAMAGE.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    39
" />
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    40
<!--PRE-HEAD-START-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    41
<!--{{{-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    42
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    43
<!--}}}-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    44
<!--PRE-HEAD-END-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    45
<title> Taggable - a portable mixin class for adding Tags to Google AppEngine Models </title>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    46
<style id="styleArea" type="text/css">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    47
#saveTest {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    48
#messageArea {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    49
#copyright {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    50
#storeArea {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    51
#storeArea div {padding:0.5em; margin:1em 0em 0em 0em; border-color:#fff #666 #444 #ddd; border-style:solid; border-width:2px; overflow:auto;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    52
#shadowArea {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    53
#javascriptWarning {width:100%; text-align:center; font-weight:bold; background-color:#dd1100; color:#fff; padding:1em 0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    54
</style>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    55
<!--POST-HEAD-START-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    56
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    57
<!--POST-HEAD-END-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    58
</head>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    59
<body onload="main();" onunload="if(window.checkUnsavedChanges) checkUnsavedChanges(); if(window.scrubNodes) scrubNodes(document.body);">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    60
<!--PRE-BODY-START-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    61
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    62
<!--PRE-BODY-END-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    63
<div id="copyright">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    64
Welcome to TiddlyWiki created by Jeremy Ruston, Copyright &copy; 2007 UnaMesa Association
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    65
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    66
<noscript>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    67
	<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>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    68
</noscript>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    69
<div id="saveTest"></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    70
<div id="backstageCloak"></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    71
<div id="backstageButton"></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    72
<div id="backstageArea"><div id="backstageToolbar"></div></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    73
<div id="backstage">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    74
	<div id="backstagePanel"></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    75
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    76
<div id="contentWrapper"></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    77
<div id="contentStash"></div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    78
<div id="shadowArea">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    79
<div title="MarkupPreHead">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    80
<pre>&lt;!--{{{--&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    81
&lt;link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    82
&lt;!--}}}--&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    83
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    84
<div title="ColorPalette">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    85
<pre>Background: #fff
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    86
Foreground: #000
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    87
PrimaryPale: #8cf
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    88
PrimaryLight: #18f
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    89
PrimaryMid: #04b
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    90
PrimaryDark: #014
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    91
SecondaryPale: #ffc
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    92
SecondaryLight: #fe8
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    93
SecondaryMid: #db4
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    94
SecondaryDark: #841
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    95
TertiaryPale: #eee
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    96
TertiaryLight: #ccc
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    97
TertiaryMid: #999
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    98
TertiaryDark: #666
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    99
Error: #f88</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   100
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   101
<div title="StyleSheetColors">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   102
<pre>/*{{{*/
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   103
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   104
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   105
a {color:[[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   106
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   107
a img {border:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   108
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   109
h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   110
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   111
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   112
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   113
.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   114
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   115
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   116
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   117
.header {background:[[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   118
.headerShadow {color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   119
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   120
.headerForeground {color:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   121
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   122
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   123
.tabSelected{color:[[ColorPalette::PrimaryDark]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   124
	background:[[ColorPalette::TertiaryPale]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   125
	border-left:1px solid [[ColorPalette::TertiaryLight]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   126
	border-top:1px solid [[ColorPalette::TertiaryLight]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   127
	border-right:1px solid [[ColorPalette::TertiaryLight]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   128
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   129
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   130
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   131
.tabContents .button {border:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   132
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   133
#sidebar {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   134
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   135
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   136
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   137
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   138
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   139
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   140
.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   141
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   142
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   143
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   144
	border:1px solid [[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   145
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   146
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   147
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   148
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   149
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   150
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   151
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   152
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   153
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   154
#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   155
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   156
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   157
.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   158
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   159
.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]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   160
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   161
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   162
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   163
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   164
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   165
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   166
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   167
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   168
.tiddler .defaultCommand {font-weight:bold;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   169
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   170
.shadow .title {color:[[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   171
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   172
.title {color:[[ColorPalette::SecondaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   173
.subtitle {color:[[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   174
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   175
.toolbar {color:[[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   176
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   177
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   178
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   179
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   180
.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   181
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   182
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   183
.tagging .button, .tagged .button {border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   184
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   185
.footer {color:[[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   186
.selected .footer {color:[[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   187
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   188
.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   189
.sparktick {background:[[ColorPalette::PrimaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   190
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   191
.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   192
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   193
.lowlight {background:[[ColorPalette::TertiaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   194
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   195
.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   196
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   197
.imageLink, #displayArea .imageLink {background:transparent;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   198
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   199
.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   200
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   201
.viewer .listTitle {list-style-type:none; margin-left:-2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   202
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   203
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   204
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   205
.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   206
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   207
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   208
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   209
.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   210
.viewer code {color:[[ColorPalette::SecondaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   211
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   212
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   213
.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   214
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   215
.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   216
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   217
.editorFooter {color:[[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   218
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   219
#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   220
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   221
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   222
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   223
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   224
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   225
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   226
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   227
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   228
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   229
/*}}}*/</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   230
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   231
<div title="StyleSheetLayout">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   232
<pre>/*{{{*/
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   233
* html .tiddler {height:1%;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   234
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   235
body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   236
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   237
h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   238
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   239
h4,h5,h6 {margin-top:1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   240
h1 {font-size:1.35em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   241
h2 {font-size:1.25em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   242
h3 {font-size:1.1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   243
h4 {font-size:1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   244
h5 {font-size:.9em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   245
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   246
hr {height:1px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   247
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   248
a {text-decoration:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   249
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   250
dt {font-weight:bold;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   251
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   252
ol {list-style-type:decimal;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   253
ol ol {list-style-type:lower-alpha;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   254
ol ol ol {list-style-type:lower-roman;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   255
ol ol ol ol {list-style-type:decimal;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   256
ol ol ol ol ol {list-style-type:lower-alpha;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   257
ol ol ol ol ol ol {list-style-type:lower-roman;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   258
ol ol ol ol ol ol ol {list-style-type:decimal;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   259
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   260
.txtOptionInput {width:11em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   261
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   262
#contentWrapper .chkOptionInput {border:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   263
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   264
.externalLink {text-decoration:underline;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   265
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   266
.indent {margin-left:3em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   267
.outdent {margin-left:3em; text-indent:-3em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   268
code.escaped {white-space:nowrap;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   269
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   270
.tiddlyLinkExisting {font-weight:bold;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   271
.tiddlyLinkNonExisting {font-style:italic;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   272
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   273
/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   274
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   275
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   276
#mainMenu .tiddlyLinkExisting,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   277
	#mainMenu .tiddlyLinkNonExisting,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   278
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   279
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   280
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   281
.header {position:relative;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   282
.header a:hover {background:transparent;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   283
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   284
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   285
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   286
.siteTitle {font-size:3em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   287
.siteSubtitle {font-size:1.2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   288
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   289
#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;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   290
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   291
#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   292
#sidebarOptions {padding-top:0.3em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   293
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   294
#sidebarOptions input {margin:0.4em 0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   295
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   296
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   297
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   298
#sidebarTabs .tabContents {width:15em; overflow:hidden;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   299
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   300
.wizard {padding:0.1em 1em 0em 2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   301
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   302
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   303
.wizardStep {padding:1em 1em 1em 1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   304
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   305
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   306
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   307
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   308
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   309
#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   310
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   311
#messageArea a {text-decoration:underline;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   312
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   313
.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   314
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   315
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   316
.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   317
.popup .popupMessage {padding:0.4em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   318
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   319
.popup li.disabled {padding:0.4em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   320
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   321
.listBreak {font-size:1px; line-height:1px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   322
.listBreak div {margin:2px 0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   323
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   324
.tabset {padding:1em 0em 0em 0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   325
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   326
.tabContents {padding:0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   327
.tabContents ul, .tabContents ol {margin:0; padding:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   328
.txtMainTab .tabContents li {list-style:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   329
.tabContents li.listLink { margin-left:.75em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   330
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   331
#contentWrapper {display:block;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   332
#splashScreen {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   333
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   334
#displayArea {margin:1em 17em 0em 14em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   335
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   336
.toolbar {text-align:right; font-size:.9em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   337
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   338
.tiddler {padding:1em 1em 0em 1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   339
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   340
.missing .viewer,.missing .title {font-style:italic;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   341
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   342
.title {font-size:1.6em; font-weight:bold;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   343
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   344
.missing .subtitle {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   345
.subtitle {font-size:1.1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   346
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   347
.tiddler .button {padding:0.2em 0.4em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   348
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   349
.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   350
.isTag .tagging {display:block;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   351
.tagged {margin:0.5em; float:right;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   352
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   353
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   354
.tagClear {clear:both;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   355
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   356
.footer {font-size:.9em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   357
.footer li {display:inline;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   358
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   359
.annotation {padding:0.5em; margin:0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   360
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   361
* html .viewer pre {width:99%; padding:0 0 1em 0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   362
.viewer {line-height:1.4em; padding-top:0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   363
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   364
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   365
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   366
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   367
.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   368
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   369
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   370
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   371
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   372
.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   373
.viewer code {font-size:1.2em; line-height:1.4em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   374
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   375
.editor {font-size:1.1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   376
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   377
.editorFooter {padding:0.25em 0em; font-size:.9em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   378
.editorFooter .button {padding-top:0px; padding-bottom:0px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   379
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   380
.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   381
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   382
.sparkline {line-height:1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   383
.sparktick {outline:0;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   384
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   385
.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   386
.zoomer div {padding:1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   387
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   388
* html #backstage {width:99%;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   389
* html #backstageArea {width:99%;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   390
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   391
#backstageToolbar {position:relative;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   392
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   393
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   394
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   395
#backstage {position:relative; width:100%; z-index:50;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   396
#backstagePanel {display:none; z-index:100; position:absolute; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   397
.backstagePanelFooter {padding-top:0.2em; float:right;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   398
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   399
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   400
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   401
.whenBackstage {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   402
.backstageVisible .whenBackstage {display:block;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   403
/*}}}*/</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   404
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   405
<div title="StyleSheetLocale">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   406
<pre>/***
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   407
StyleSheet for use when a translation requires any css style changes.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   408
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   409
***/
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   410
/*{{{*/
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   411
body {font-size:0.8em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   412
#sidebarOptions {font-size:1.05em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   413
#sidebarOptions a {font-style:normal;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   414
#sidebarOptions .sliderPanel {font-size:0.95em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   415
.subtitle {font-size:0.8em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   416
.viewer table.listView {font-size:0.95em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   417
/*}}}*/</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   418
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   419
<div title="StyleSheetPrint">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   420
<pre>/*{{{*/
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   421
@media print {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   422
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none ! important;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   423
#displayArea {margin: 1em 1em 0em 1em;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   424
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   425
noscript {display:none;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   426
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   427
/*}}}*/</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   428
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   429
<div title="PageTemplate">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   430
<pre>&lt;!--{{{--&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   431
&lt;div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   432
&lt;div class='headerShadow'&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   433
&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   434
&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   435
&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   436
&lt;div class='headerForeground'&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   437
&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   438
&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   439
&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   440
&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   441
&lt;div id='mainMenu' refresh='content' tiddler='MainMenu'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   442
&lt;div id='sidebar'&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   443
&lt;div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   444
&lt;div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   445
&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   446
&lt;div id='displayArea'&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   447
&lt;div id='messageArea'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   448
&lt;div id='tiddlerDisplay'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   449
&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   450
&lt;!--}}}--&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   451
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   452
<div title="ViewTemplate">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   453
<pre>&lt;!--{{{--&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   454
&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   455
&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   456
&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;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   457
&lt;div class='tagging' macro='tagging'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   458
&lt;div class='tagged' macro='tags'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   459
&lt;div class='viewer' macro='view text wikified'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   460
&lt;div class='tagClear'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   461
&lt;!--}}}--&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   462
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   463
<div title="EditTemplate">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   464
<pre>&lt;!--{{{--&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   465
&lt;div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   466
&lt;div class='title' macro='view title'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   467
&lt;div class='editor' macro='edit title'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   468
&lt;div macro='annotations'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   469
&lt;div class='editor' macro='edit text'&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   470
&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'&gt;&lt;/span&gt;&lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   471
&lt;!--}}}--&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   472
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   473
<div title="GettingStarted">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   474
<pre>To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   475
* SiteTitle &amp; SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   476
* MainMenu: The menu (usually on the left)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   477
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   478
You'll also need to enter your username for signing your edits: &lt;&lt;option txtUserName&gt;&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   479
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   480
<div title="OptionsPanel">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   481
<pre>These InterfaceOptions for customising TiddlyWiki are saved in your browser
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   482
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   483
Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   484
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   485
&lt;&lt;option txtUserName&gt;&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   486
&lt;&lt;option chkSaveBackups&gt;&gt; SaveBackups
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   487
&lt;&lt;option chkAutoSave&gt;&gt; AutoSave
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   488
&lt;&lt;option chkRegExpSearch&gt;&gt; RegExpSearch
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   489
&lt;&lt;option chkCaseSensitiveSearch&gt;&gt; CaseSensitiveSearch
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   490
&lt;&lt;option chkAnimate&gt;&gt; EnableAnimations
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   491
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   492
----
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   493
Also see AdvancedOptions</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   494
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   495
<div title="ImportTiddlers">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   496
<pre>&lt;&lt;importTiddlers&gt;&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   497
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   498
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   499
<!--POST-SHADOWAREA-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   500
<div id="storeArea">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   501
<div title="AdamCrossland" modifier="AdamCrossland" created="200805201949" modified="200805201951" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   502
<pre>Adam is the author of ''Taggable.''  To find out more about him and other software that he has created, visit http://www.adamcrossland.net.  You can also visit his blog, http://blog.adamcrossland.net, to see the code in action; he created ''Taggable'' as part of the blogging software project the he wrote as a vehicle to learn about [[Google AppEngine]].</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   503
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   504
<div title="Apache 2.0 Open Source license" modifier="AdamCrossland" created="200805202001" modified="200805211430" changecount="5">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   505
<pre>{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   506
Copyright 2008 Adam A. Crossland
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   507
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   508
Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   509
you may not use this file except in compliance with the License.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   510
You may obtain a copy of the License at
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   511
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   512
http://www.apache.org/licenses/LICENSE-2.0
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   513
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   514
Unless required by applicable law or agreed to in writing, software
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   515
distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   516
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   517
See the License for the specific language governing permissions and
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   518
limitations under the License.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   519
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   520
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   521
<div title="ChangeLog" modifier="AdamCrossland" created="200812041728" modified="200812042045" changecount="9">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   522
<pre>''1.0''
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   523
Initial release
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   524
----
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   525
''2.0''
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   526
This release has major changes to both [[Tag|Tag Class]] and [[Taggable|Taggable Class]], reflecting significant and important lessons that [[the author|AdamCrossland]] learned about [[Google AppEngine]].  Specifically, this release's changes should substantially improve the performance of any code that uses tags.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   527
*[[Tag|Tag Class]] entities are now stored with a custom key_name that allows them to be much-more-quickly retrieved from the data store.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   528
*The [[Tag|Tag Class]] has been rewritten to breakdown Tag/Taggable interactions in to a series of simple, atomic transactions.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   529
*[[Tag|Tag Class]] has a new property, [[tagged_count|Tag tagged_count Property]], that records the number of Taggable entities in its [[tagged|Tag tagged Property]] property.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   530
*Two new methods, [[get_tags_by_frequency|Tag get_tags_by_frequency Method]] and [[popular_tags|Tag popular_tags Method]], provide access to lists of [[Tags|Tag Class]] based on the number of [[Taggable|Taggable Class]] entities to which they refer.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   531
*A new method, [[get_tags_by_name|Tag get_tags_by_name Method]], provides lists of tags in alphabetical order.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   532
*The [[Taggable|Taggable Class]] class has been greatly simplified.  Multiple methods for getting and setting tags have been replaced with a single property, [[tags|Taggable tags Property]], that handles both getting and setting operations.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   533
*A full suite of automated unit tests for both classes has been created.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   534
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   535
<div title="Contact" modifier="AdamCrossland" created="200805211444" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   536
<pre>If you have any questions or suggestions about ''Taggable'', please feel free to contact the author, AdamCrossland, at adam@adamcrossland.net.  Alternatively, you could post the question in &lt;html&gt;&lt;a href=&quot;http://groups.google.com/group/google-appengine/topics&quot;&gt;the Google AppEngine Group.&lt;/a&gt;&lt;/html&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   537
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   538
<div title="Contribute" modifier="AdamCrossland" created="200805211441" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   539
<pre>If you are using ''Taggable'' and you have some changes, improvements or bug fixes that you'd like to contribute, please contact AdamCrossland at adam@adamcrossland.net.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   540
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   541
<div title="Converting from 1.0 to 2.0" modifier="AdamCrossland" created="200812051535" modified="200812051536" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   542
<pre>Because the Tag records are stored and queried slightly differently (yet much-more efficiently) in //Taggable-mixin 2.0//, an existing application will have to go through a process of converting all of its existing tags.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   543
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   544
For AdamCBlog, the application from which //Taggable-mixin// is extracted, I added a new RequestHandler called UpdateTag:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   545
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   546
class UpdateTag(RequestHandler):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   547
    def get(self):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   548
        from taggable import Tag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   549
        tag_name = self.request.get('tag')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   550
        tag = db.Query(Tag).filter('tag =', tag_name).fetch(1)[0]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   551
        if tag is not None:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   552
            new_tag = Tag.get_or_create(tag_name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   553
            for each_tagged in tag.tagged:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   554
                new_tag.add_tagged(each_tagged)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   555
        tag.delete()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   556
    
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   557
        self.redirect('/')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   558
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   559
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   560
Then, I made the request /~UpdateTag?tag=//inserttaghere// for each Tag in the datastore.  Yes, it is laborious.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   561
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   562
Why not just create a RequestHandler that cycled through all of the tags automatically, converting them as it went?  I tried that, but there is too much processing involved; the request uses up its time quota and is killed before it can finish.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   563
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   564
<div title="DateTimeProperty" modifier="AdamCrossland" created="200812042027" tags="appengine" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   565
<pre>A [[Google AppEngine]] datastore property that holds a Python //datetime//.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   566
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   567
http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#DateTimeProperty</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   568
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   569
<div title="DefaultTiddlers" modifier="AdamCrossland" created="200805202104" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   570
<pre>[[Introduction]]</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   571
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   572
<div title="Google AppEngine" modifier="AdamCrossland" created="200805201811" modified="200805202010" changecount="3">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   573
<pre>Google ~AppEngine is Google's platform for developing web applications that run inside Google's computing cloud.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   574
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   575
Find out more about it at &lt;html&gt;&lt;a href=&quot;http://code.google.com/appengine/&quot;&gt;The Google AppEngine website&lt;/a&gt;&lt;/html&gt;.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   576
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   577
</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   578
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   579
<div title="IntegerProperty" modifier="AdamCrossland" created="200812041949" tags="appengine" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   580
<pre>A [[Google AppEngine]] datastore property that holds a Python //long//.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   581
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   582
http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#IntegerProperty</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   583
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   584
<div title="Introduction" modifier="AdamCrossland" created="200805201810" modified="200812051536" changecount="8">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   585
<pre>''Taggable'' is a &lt;html&gt;&lt;a href=&quot;http://www.linuxjournal.com/node/4540/print&quot;&gt;mixin&lt;/a&gt;&lt;/html&gt; class that AdamCrossland created in order to add [[tags|Tag Definition]] to his personal blog (http://blog.adamcrossland.net) which is built on [[Google AppEngine]].  The design seemed clean and portable, so he decided to share it with the greater [[AppEngine|Google AppEngine]] community.  It is available under [[Apache 2.0 Open Source license]].
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   586
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   587
Users of taggable-mixin 1.0 should note that taggable-mixin 2.0 is not directly compatible with 1.0.  While it is possible to upgrade, existing Tag entities will have to be [[converted|Converting from 1.0 to 2.0]].</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   588
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   589
<div title="Key Class" modifier="AdamCrossland" created="200812042055" tags="appengine" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   590
<pre>A [[Google AppEngine]] class that represents a unique key for a datastore entity.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   591
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   592
http://code.google.com/appengine/docs/datastore/keyclass.html</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   593
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   594
<div title="ListProperty" modifier="AdamCrossland" created="200812042030" tags="appengine" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   595
<pre>A [[Google AppEngine]] datastore property that represents a Python //list//.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   596
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   597
http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#ListProperty</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   598
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   599
<div title="MainMenu" modifier="AdamCrossland" created="200805201814" modified="200812041913" changecount="10">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   600
<pre>[[Introduction|Introduction]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   601
ChangeLog
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   602
StepByStep
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   603
&lt;&lt;tag api&gt;&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   604
----
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   605
[[License|Apache 2.0 Open Source license]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   606
[[Contribute]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   607
[[Contact]]</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   608
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   609
<div title="RequestHandler" modifier="AdamCrossland" created="200805211437" modified="200805211438" changecount="4">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   610
<pre>A //~RequestHandler// is a Python class that inherits from //webapp.~RequestHandler//.  It is used to answer HTTP requests that are received by your [[Google AppEngine]] application.  For more information on this subject, please consult the &lt;html&gt;&lt;a href=&quot;http://code.google.com/appengine/docs/webapp/requesthandlers.html&quot;&gt;documentation.&lt;/a&gt;&lt;/html&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   611
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   612
</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   613
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   614
<div title="SideBarOptions" modifier="AdamCrossland" created="200805211439" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   615
<pre>&lt;&lt;search&gt;&gt;&lt;&lt;closeAll&gt;&gt;&lt;&lt;permaview&gt;&gt;&lt;&lt;newTiddler&gt;&gt;&lt;&lt;saveChanges&gt;&gt;&lt;&lt;slider chkSliderOptionsPanel OptionsPanel &quot;options »&quot; &quot;Change TiddlyWiki advanced options&quot;&gt;&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   616
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   617
<div title="SiteSubtitle" modifier="AdamCrossland" created="200805201806" modified="200805201807" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   618
<pre>a portable mixin class for adding Tags to Google ~AppEngine Models</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   619
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   620
<div title="SiteTitle" modifier="AdamCrossland" created="200805201805" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   621
<pre>Taggable</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   622
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   623
<div title="StepByStep" modifier="AdamCrossland" created="200805201831" modified="200812041926" tags="help examples code" changecount="14">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   624
<pre>Here's a step-by-step guide to adding ''Taggable'' to your [[Google AppEngine]] application.  This presents the simplest, most straightforward path to integrating ''Taggable'' as as such, it does not cover all of the options that are available.  
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   625
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   626
All of the code examples are modified extracts from the blogging software for which I originally created ''Taggable.''  //''These examples do not represent what the author considers to be complete and secure code; please make sure that you are familiar with best practices for building secure web applications before creating a web application.  The author of this document and the accompanying code bears no responsibility whatsoever for any losses or damages that you incur as a result of failing to take the appropriate steps to create a stable, secure, well-written web application.''//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   627
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   628
*Copy [[taggable.py]] to your application directory.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   629
*Import [[taggable.py]] into the python file that defines the Model that you want to make taggable:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   630
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   631
from taggable import Taggable
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   632
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   633
*Add //Taggable// to the list of classes from which your Model class inherits.  Taggable -- and any other mixin classes -- should come before db.Model:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   634
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   635
class Post(Taggable, db.Model):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   636
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   637
*Add code to your Model's //init// method to call Taggable's //init// method.  If your Model class does not already override //init//, it will have to, and you will have to explicitly call the //init// method of any other superclass -- such as db.Model:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   638
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   639
    def __init__(self, parent=None, key_name=None, app=None, **entity_values):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   640
        db.Model.__init__(self, parent, key_name, app, **entity_values)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   641
        Taggable.__init__(self)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   642
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   643
*Add code to your template to express the tagging information:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   644
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   645
{% if post.tags %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   646
    &lt;div class=&quot;posttags&quot;&gt;tags:&amp;nbsp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   647
        {% for each_tag in post.tags %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   648
            &lt;a href=&quot;/searchbytag?tag={{ each_tag.tag|escape }}&quot;&gt;{{ each_tag.tag }}&lt;/a&gt;{% if forloop.last %}{% else %}, {% endif %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   649
        {% endfor %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   650
    &lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   651
{% endif %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   652
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   653
or
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   654
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   655
&lt;tr&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   656
    &lt;td&gt;Tags:&lt;/td&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   657
    &lt;td&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   658
        &lt;input type=&quot;TEXT&quot; name=&quot;tags&quot; size=&quot;106&quot; value=&quot;{% if post %}{{ post.tags_string }}{% endif %}&quot; /&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   659
    &lt;/td&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   660
&lt;/tr&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   661
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   662
*In any RequestHandler method that updates a Model object that has tags associated with it,  assign any new value to the ''Taggable'' object's [[tags|TaggableTagsProperty]]:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   663
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   664
class EditPost(SmartHandler.SmartHandler):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   665
    def post(self):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   666
        postid = self.request.get('id')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   667
        post = Post.get(postid)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   668
        post.title = self.request.get('title')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   669
        post.body = self.request.get('body')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   670
        post.edited = datetime.datetime.now()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   671
        post.tags = self.request.get('tags')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   672
        post.put()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   673
        .
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   674
        . do whatever else you need to do in your handler...
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   675
        .
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   676
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   677
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   678
<div title="StringProperty" modifier="AdamCrossland" created="200812042024" tags="appengine" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   679
<pre>A [[Google AppEngine]] datastore property that holds a Python //string// of 500 characters or less.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   680
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   681
http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#StringProperty</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   682
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   683
<div title="Tag Class" modifier="AdamCrossland" created="200812041942" modified="200812050051" tags="api" changecount="6">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   684
<pre>The //Tag// class is the Model class that holds the data for an individual [[tag|Tag Definition]].
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   685
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   686
It has four properties:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   687
*[[tag|Tag tag Property]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   688
*[[added|Tag tag_added Property]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   689
*[[tagged|Tag tagged Property]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   690
*[[tagged_count|Tag tagged_count Property]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   691
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   692
and ten methods:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   693
*[[remove_tagged|Tag remove_tagged Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   694
*[[add_tagged|Tag add_tagged Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   695
*[[clear_tagged|Tag clear_tagged Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   696
*[[get_by_name|Tag get_by_name Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   697
*[[get_tags_for_key|Tag get_tags_for_key Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   698
*[[get_or_create|Tag get_or_create Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   699
*[[get_tags_by_frequency|Tag get_tags_by_frequency Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   700
*[[get_tags_by_name|Tag get_tags_by_name Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   701
*[[popular_tags|Tag popular_tags Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   702
*[[expire_cached_tags|Tag expire_cached_tags Method]]</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   703
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   704
<div title="Tag Definition" modifier="AdamCrossland" created="200812050049" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   705
<pre>A //Tag// is a word or short phrase that acts as metadata; it describes and increases the searchability and findability of data.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   706
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   707
http://en.wikipedia.org/wiki/Tag_(metadata)</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   708
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   709
<div title="Tag add_tagged Method" modifier="AdamCrossland" created="200812042059" modified="200812042332" tags="api" changecount="3">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   710
<pre>//tag_instance.add_tagged(key)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   711
* key - a [[Key|Key Class]] for a //Taggable// Model to mark with the [[Tag|Tag Class]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   712
Returns: nothing
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   713
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   714
The //add_tagged// method adds the [[Key|Key Class]] passed in to the Tag's [[tagged|Tag tagged Property]] collection and increments the [[tagged_count|Tag tagged_count Property]].  The operations are performed inside a transaction to ensure data intergity.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   715
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   716
Under most circumstances, the programmer will not need to call //add_tagged// directly; it is meant to be used internally by the [[Tagged Class]].  However, it is available for use by those who wish to customize the behavior of Taggable.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   717
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   718
<div title="Tag clear_tagged Method" modifier="AdamCrossland" created="200812042103" modified="200812042332" tags="api" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   719
<pre>//tag_instance.clear_tagged(key)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   720
* key - a [[Key|Key Class]] for a //Taggable// object.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   721
Returns: nothing
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   722
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   723
The //clear_tagged// method empties the Tag's [[tagged|Tag tagged Property]] collection and sets the [[tagged_count|Tag tagged_count Property]] to zero.  The operations are performed inside a transaction to ensure data intergity.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   724
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   725
Under most circumstances, the programmer will not need to call //clear_tagged// directly; it is meant to be used internally by the [[Tagged Class]].  However, it is available for use by those who wish to customize the behavior of Taggable.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   726
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   727
<div title="Tag expire_cached_tags Method" modifier="AdamCrossland" created="200812050015" tags="api" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   728
<pre>//Tag.expire_cached_tags()//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   729
Returns: nothing
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   730
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   731
Comments:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   732
This method removes from memcache any objects that have been cached by other [[Tag|Tag Class]] methods.  Usually, the programmer will not call this method directly, as it is used behind-the-scenes by code that affects the validity of the cached items.  It is available, however, in case the programmer wishes to customize existing behavior.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   733
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   734
<div title="Tag get_by_name Method" modifier="AdamCrossland" created="200812042151" modified="200812042227" tags="api example" changecount="5">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   735
<pre>//Tag.get_by_name(tag_name)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   736
*tag_name - the tag, in text form
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   737
Returns: a [[Tag|Tag Class]] or //None//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   738
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   739
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   740
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   741
class SearchByTag(RequestHandler):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   742
    def get(self):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   743
        from post import Post
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   744
        from taggable import Tag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   745
        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   746
        requested_tag = self.request.get('tag')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   747
        if requested_tag is not None and len(requested_tag) &gt; 0:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   748
            tag = Tag.get_by_name(requested_tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   749
            posts = None
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   750
            if tag is not None:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   751
                posts = Post.get(tag.tagged)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   752
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   753
            self.template_values['posts'] = posts
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   754
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   755
</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   756
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   757
<div title="Tag get_or_create Method" modifier="AdamCrossland" created="200812042332" modified="200812042334" tags="api" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   758
<pre>//Tag.get_or_create(tag_name)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   759
*tag_name - the name of the tag that is to be retrieved from or created in the datastore
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   760
Returns: a [[Tag|Tag Class]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   761
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   762
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   763
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   764
for each_tag in tags:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   765
    each_tag = string.strip(each_tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   766
    if len(each_tag) &gt; 0 and each_tag not in self.__tags:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   767
        # A tag that was not previously assigned to this entity
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   768
        # is present in the list that is being assigned, so we
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   769
        # associate this entity with the tag.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   770
        tag = Tag.get_or_create(each_tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   771
        tag.add_tagged(self.key())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   772
        self.__tags.append(tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   773
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   774
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   775
<div title="Tag get_tags_by_frequency Method" modifier="AdamCrossland" created="200812042356" tags="api" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   776
<pre>//Tag.get_tags_by_frequency(limit=1000)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   777
*limit - the number of records to return; the maximum is 1000
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   778
Returns: a list of [[Tag|Tag Class]] objects, ordered by the number of //Taggable// objects assigned to it.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   779
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   780
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   781
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   782
@classmethod
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   783
def popular_tags(cls, limit=5):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   784
    from google.appengine.api import memcache
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   785
        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   786
    tags = memcache.get('popular_tags')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   787
    if tags is None:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   788
        tags = Tag.get_tags_by_frequency(limit)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   789
        memcache.add('popular_tags', tags, 3600)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   790
        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   791
    return tags
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   792
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   793
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   794
<div title="Tag get_tags_by_name Method" modifier="AdamCrossland" created="200812050018" tags="api" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   795
<pre>//Tag.get_tags_by_name(tag_name)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   796
*tag_name - the string value of a [[Tag|Tag Class]] to be retrieved from the datastore
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   797
Returns: a [[Tag|Tag Class]] object or None if the given //tag_name// does not exist
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   798
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   799
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   800
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   801
requested_tag = self.request.get('tag')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   802
if requested_tag is not None and len(requested_tag) &gt; 0:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   803
    tag = Tag.get_by_name(requested_tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   804
    posts = None
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   805
    if tag is not None:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   806
        posts = Post.get(tag.tagged)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   807
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   808
    self.template_values['posts'] = posts
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   809
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   810
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   811
<div title="Tag get_tags_for_key Method" modifier="AdamCrossland" created="200812042318" modified="200812042355" tags="api example" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   812
<pre>//Tag.get_tags_for_key(key)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   813
*key - a [[Key|Key Class]] for a //Taggable// object.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   814
Returns: a //list// of [[Tag|Tag Class]] objects
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   815
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   816
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   817
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   818
def __get_tags(self):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   819
    &quot;Get a List of Tag objects for all Tags that apply to this object.&quot;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   820
    if self.__tags is None or len(self.__tags) == 0:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   821
        self.__tags = Tag.get_tags_for_key(self.key())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   822
    return self.__tags
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   823
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   824
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   825
<div title="Tag popular_tags Method" modifier="AdamCrossland" created="200812050000" tags="api" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   826
<pre>//Tag.popular_tags(limit=5)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   827
*limit - the number of records to return; the default is 5 and the maximum is 1000
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   828
Returns: a list of [[Tag|Tag Class]] objects, ordered by the number of [[Taggable|Taggable Class]] objects assigned to it.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   829
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   830
Comments:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   831
This method is a thin wrapper around [[get_tags_by_frequency|Tag get_tags_by_frequency]] that caches the returned values.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   832
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   833
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   834
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   835
self.template_values['popular_tags'] = Tag.popular_tags()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   836
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   837
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   838
<div title="Tag remove_tagged Method" modifier="AdamCrossland" created="200812042054" modified="200812042332" tags="api" changecount="5">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   839
<pre>//tag_instance.remove_tagged(key)//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   840
* key - a [[Key|Key Class]] for a //Taggable// object.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   841
Returns: nothing
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   842
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   843
The //remove_tagged// method removes the [[Key|Key Class]] passed in from the Tag's [[tagged|Tag tagged Property]] collection and decrements the [[tagged_count|Tag tagged_count Property]].  The operations are performed inside a transaction to ensure data intergity.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   844
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   845
Under most circumstances, the programmer will not need to call //remove_tagged// directly; it is meant to be used internally by the [[Tagged Class]].  However, it is available for use by those who wish to customize the behavior of Taggable.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   846
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   847
<div title="Tag tag Property" modifier="AdamCrossland" created="200812042022" tags="api" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   848
<pre>A StringProperty that holds the name or value of the tag.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   849
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   850
<div title="Tag tag_added Property" modifier="AdamCrossland" created="200812042025" modified="200812042026" tags="api" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   851
<pre>The DateTimeProperty that records that date and time that the [[Tag|TagClass]] was first added.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   852
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   853
<div title="Tag tagged Property" modifier="AdamCrossland" created="200812042028" tags="api" changecount="1">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   854
<pre>A ListProperty that holds the Keys of all of the entities that have the given [[Tag|TagClass]] assigned to them.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   855
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   856
<div title="Tag tagged_count Property" modifier="AdamCrossland" created="200812041947" modified="200812042018" tags="api" changecount="3">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   857
<pre>An IntegerProperty that holds the number of items that have the Tag assigned to them.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   858
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   859
<div title="Taggable Class" modifier="AdamCrossland" created="200812050054" modified="200812051431" tags="api" changecount="8">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   860
<pre>The //Taggable// class can be mixed-in to any other Python class that inherits from //db.Model// in order to associate [[Tags|Tag Definition]] with that model.  For instance, if you were creating blogging software, one of your fundamental objects would be a //Post// that would comprise all of the information about an individual entry in your blog.  Usually, a Post can have [[Tags|Tag Definition]] added to it in order to provide easily-digested information to the reader about the content.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   861
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   862
It has two properties:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   863
*[[tags|Taggable tags Property]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   864
*[[tag_separator|Taggable tag_separator Property]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   865
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   866
and one method:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   867
*[[tags_string|Taggable tags_string Method]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   868
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   869
Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   870
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   871
class Post(Taggable, db.Model):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   872
    index = db.IntegerProperty(required=True, default=0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   873
    body = db.TextProperty(required = True)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   874
    title = db.StringProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   875
    added = db.DateTimeProperty(auto_now_add=True)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   876
    added_month = db.IntegerProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   877
    added_year = db.IntegerProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   878
    edited = db.DateTimeProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   879
        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   880
    def __init__(self, parent=None, key_name=None, app=None, **entity_values):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   881
        db.Model.__init__(self, parent, key_name, app, **entity_values)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   882
        Taggable.__init__(self)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   883
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   884
Notes:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   885
*Notice that [[Taggable|Taggable Class]] is placed before db.Model in the inheritance list.  While this is not strictly required for //Taggable-mixin// to function correctly, it //is// required for other mixin classes, and it is generally a good practice.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   886
*It //is// required that the [[Taggable|Taggable Class]] //init// method is explicitly called, so it should be placed in the inherting class's //init// method.  If the class would not otherwise have one, it should be created, and the db.Model //init// must be called as well, as shown.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   887
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   888
<div title="Taggable tag_separator Property" modifier="AdamCrossland" created="200805201936" modified="200812042033" tags="api" changecount="6">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   889
<pre>The //tag_separator// property is the string that is used to separate individual tags in a string representation of a list of tags.  It is used by the [[tags property|TaggableTagsProperty]] to parse a string that may contain one or more tags to be applied to a [[Taggable|TaggableClass]] object.  It is also used by the [[tags_string|TaggableTagsStringMethod]] method to construct a string representation of the tags for a [[Taggable|TaggableClass]] object.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   890
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   891
*By default, it is set to a comma (','), but it can be programatically-set to whatever value the developer desires
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   892
*It is probably best to avoid using whitespace characters, as that would prevent users from entering multi-word tags
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   893
*Custom separator values can be set at different levels.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   894
**To set one value for all [[Taggable|TaggableClass]] objects, modify the //init// method in the //Taggable// class in the taggable.py file:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   895
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   896
class Taggable:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   897
     def __init__(self):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   898
        self.tag_separator = &quot;;&quot; # Made it semi-colon instead of comma
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   899
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   900
**To set one value for all instances of a particular [[Taggable|TaggableClass]] class, modify the //init// method of that class:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   901
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   902
class Post(Taggable, db.Model):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   903
    body = db.TextProperty(required = True)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   904
    title = db.StringProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   905
    added = db.DateTimeProperty(auto_now_add=True)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   906
    edited = db.DateTimeProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   907
            
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   908
    def __init__(self, parent=None, key_name=None, app=None, **entity_values):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   909
        db.Model.__init__(self, parent, key_name, app, **entity_values)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   910
        Taggable.__init__(self)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   911
        self.tag_separator = &quot;;&quot; # Made it semi-colon instead of comma        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   912
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   913
**To set a value for one particular instance of a [[Taggable|TaggableClass]] class, set the value after creating the instance:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   914
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   915
newpost = Post(title = self.request.get('title'), body = self.request.get('body'))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   916
newpost.tag_separator = &quot;;&quot; # Made it semi-colon instead of comma
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   917
newpost.set_tags_from_string(&quot;foo; bar; bletch; this is a tag; tags rule&quot;     
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   918
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   919
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   920
<div title="Taggable tags Property" modifier="AdamCrossland" created="200812051447" modified="200812051516" tags="api" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   921
<pre>The a [[Taggable|Taggable Class]] class's //tags// property is used to assign [[Tags|Tag Class]] to the [[Taggable|Taggable Class]] instance or retrieve a //list// of those already assigned.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   922
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   923
Assignment Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   924
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   925
class Post(Taggable, db.Model):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   926
    index = db.IntegerProperty(required=True, default=0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   927
    body = db.TextProperty(required = True)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   928
    title = db.StringProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   929
    added = db.DateTimeProperty(auto_now_add=True)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   930
    added_month = db.IntegerProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   931
    added_year = db.IntegerProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   932
    edited = db.DateTimeProperty()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   933
        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   934
    def __init__(self, parent=None, key_name=None, app=None, **entity_values):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   935
        db.Model.__init__(self, parent, key_name, app, **entity_values)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   936
        Taggable.__init__(self)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   937
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   938
    @classmethod
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   939
    def new_post(cls, new_title=None, new_body=None, new_tags=[]):
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   940
        if new_title is not None and new_body is not None:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   941
            
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   942
            new_post = Post(title = new_title, body = new_body)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   943
            new_post.put()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   944
        
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   945
            new_post.tags = new_tags
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   946
            new_post.save()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   947
        else:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   948
            raise Exception(&quot;Must supply both new_title and new_body when creating a new Post.&quot;)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   949
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   950
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   951
Retrieval Example:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   952
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   953
{% if post.tags %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   954
    &lt;div class=&quot;posttags&quot;&gt;tags:&amp;nbsp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   955
        {% for each_tag in post.tags %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   956
            &lt;a href=&quot;/searchbytag?tag={{ each_tag.tag|escape }}&quot;&gt;{{ each_tag.tag }}&lt;/a&gt;{% if forloop.last %}{% else %}, {% endif %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   957
        {% endfor %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   958
    &lt;/div&gt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   959
{% endif %}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   960
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   961
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   962
<div title="Taggable tags_string Method" modifier="AdamCrossland" created="200812051441" modified="200812051441" tags="api" changecount="3">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   963
<pre>//taggable_instance.tags_string()//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   964
Returns: a string representation of the tags assigned to the [[Taggable|Taggable Class]] instance.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   965
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   966
This method simply joins the string versions of each [[Tag|Tag Class]] in the [[Taggable|Taggable Class]] class's //list//, placing the value stored in [[tag_separator|Taggable tag_separator Property]] inbetween each element.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   967
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   968
<div title="TaggableAPI" modifier="AdamCrossland" created="200805201953" modified="200805201956" changecount="6">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   969
<pre>&lt;&lt;tagging api&gt;&gt;</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   970
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   971
<div title="get_tags_as_string" modifier="AdamCrossland" created="200805201952" modified="200812041913" tags="obsolete" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   972
<pre>The //get_tags_as_string// method creates a string representation of all of the tags that apply to a ''Taggable'' object.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   973
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   974
<div title="set_tags" modifier="AdamCrossland" created="200805201919" modified="200812041848" tags="obsolete" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   975
<pre>The //set_tags// method sets the tags for a ''Taggable'' object from a list of strings:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   976
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   977
tag_list = [&quot;foo&quot;, &quot;bar&quot;, &quot;bletch&quot;,&quot;this is a tag&quot;, &quot;tags rule&quot;]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   978
my_taggable_object.set_tags(tag_list)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   979
}}}</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   980
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   981
<div title="set_tags_from_string" modifier="AdamCrossland" created="200805201926" modified="200812041848" tags="obsolete" changecount="3">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   982
<pre>The //set_tags_from_string method// sets the tags for a Taggable object from a string that contains one or more tags separated by the character or characters in //self.tag_seperator//:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   983
{{{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   984
tag_list = &quot;foo, bar, bletch, this is a tag, tags rule&quot;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   985
my_taggable_object.set_tags_from_string(tag_list)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   986
}}}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   987
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   988
By default, [[tag_separator|tag_separator]] is set to a comma (','), but it can be anything that the programmer wants.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   989
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   990
<div title="taggable.py" modifier="AdamCrossland" created="200805201904" modified="200805201946" changecount="2">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   991
<pre>All of the code for the ''Taggable'' mixin class lives in the file taggable.py.  Simply copy this file in to your Google ~AppEngine main directory, and it should be available to your code.</pre>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   992
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   993
</div>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   994
<!--POST-STOREAREA-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   995
<!--POST-BODY-START-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   996
<!--POST-BODY-END-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   997
<script id="jsArea" type="text/javascript">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   998
//<![CDATA[
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
   999
//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1000
// Please note:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1001
//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1002
// * This code is designed to be readable but for compactness it only includes brief comments. You can see fuller comments
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1003
//   in the project Subversion repository at http://svn.tiddlywiki.org/Trunk/core/
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1004
//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1005
// * You should never need to modify this source code directly. TiddlyWiki is carefully designed to allow deep customisation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1006
//   without changing the core code. Please consult the development group at http://groups.google.com/group/TiddlyWikiDev
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1007
//
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1008
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1009
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1010
//-- Configuration repository
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1011
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1012
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1013
// Miscellaneous options
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1014
var config = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1015
	numRssItems: 20, // Number of items in the RSS feed
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1016
	animDuration: 400, // Duration of UI animations in milliseconds
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1017
	cascadeFast: 20, // Speed for cascade animations (higher == slower)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1018
	cascadeSlow: 60, // Speed for EasterEgg cascade animations
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1019
	cascadeDepth: 5, // Depth of cascade animation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1020
	locale: "en" // W3C language tag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1021
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1022
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1023
// Hashmap of alternative parsers for the wikifier
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1024
config.parsers = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1025
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1026
// Adaptors
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1027
config.adaptors = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1028
config.defaultAdaptor = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1029
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1030
// Backstage tasks
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1031
config.tasks = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1032
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1033
// Annotations
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1034
config.annotations = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1035
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1036
// Custom fields to be automatically added to new tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1037
config.defaultCustomFields = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1038
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1039
// Messages
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1040
config.messages = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1041
	messageClose: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1042
	dates: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1043
	tiddlerPopup: {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1044
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1045
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1046
// Options that can be set in the options panel and/or cookies
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1047
config.options = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1048
	chkRegExpSearch: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1049
	chkCaseSensitiveSearch: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1050
	chkIncrementalSearch: true,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1051
	chkAnimate: true,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1052
	chkSaveBackups: true,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1053
	chkAutoSave: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1054
	chkGenerateAnRssFeed: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1055
	chkSaveEmptyTemplate: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1056
	chkOpenInNewWindow: true,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1057
	chkToggleLinks: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1058
	chkHttpReadOnly: true,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1059
	chkForceMinorUpdate: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1060
	chkConfirmDelete: true,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1061
	chkInsertTabs: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1062
	chkUsePreForStorage: true, // Whether to use <pre> format for storage
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1063
	chkDisplayInstrumentation: false,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1064
	txtBackupFolder: "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1065
	txtEditorFocus: "text",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1066
	txtMainTab: "tabTimeline",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1067
	txtMoreTab: "moreTabAll",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1068
	txtMaxEditRows: "30",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1069
	txtFileSystemCharSet: "UTF-8",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1070
	txtTheme: ""
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1071
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1072
config.optionsDesc = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1073
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1074
// List of notification functions to be called when certain tiddlers are changed or deleted
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1075
config.notifyTiddlers = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1076
	{name: "StyleSheetLayout", notify: refreshStyles},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1077
	{name: "StyleSheetColors", notify: refreshStyles},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1078
	{name: "StyleSheet", notify: refreshStyles},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1079
	{name: "StyleSheetPrint", notify: refreshStyles},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1080
	{name: "PageTemplate", notify: refreshPageTemplate},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1081
	{name: "SiteTitle", notify: refreshPageTitle},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1082
	{name: "SiteSubtitle", notify: refreshPageTitle},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1083
	{name: "ColorPalette", notify: refreshColorPalette},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1084
	{name: null, notify: refreshDisplay}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1085
];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1086
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1087
// Default tiddler templates
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1088
var DEFAULT_VIEW_TEMPLATE = 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1089
var DEFAULT_EDIT_TEMPLATE = 2;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1090
config.tiddlerTemplates = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1091
	1: "ViewTemplate",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1092
	2: "EditTemplate"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1093
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1094
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1095
// More messages (rather a legacy layout that shouldn't really be like this)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1096
config.views = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1097
	wikified: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1098
		tag: {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1099
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1100
	editor: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1101
		tagChooser: {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1102
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1103
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1104
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1105
// Backstage tasks
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1106
config.backstageTasks = ["save","sync","importTask","tweak","upgrade","plugins"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1107
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1108
// Macros; each has a 'handler' member that is inserted later
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1109
config.macros = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1110
	today: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1111
	version: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1112
	search: {sizeTextbox: 15},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1113
	tiddler: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1114
	tag: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1115
	tags: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1116
	tagging: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1117
	timeline: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1118
	allTags: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1119
	list: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1120
		all: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1121
		missing: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1122
		orphans: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1123
		shadowed: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1124
		touched: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1125
		filter: {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1126
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1127
	closeAll: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1128
	permaview: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1129
	saveChanges: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1130
	slider: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1131
	option: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1132
	options: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1133
	newTiddler: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1134
	newJournal: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1135
	tabs: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1136
	gradient: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1137
	message: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1138
	view: {defaultView: "text"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1139
	edit: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1140
	tagChooser: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1141
	toolbar: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1142
	plugins: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1143
	refreshDisplay: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1144
	importTiddlers: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1145
	upgrade: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1146
		source: "http://www.tiddlywiki.com/upgrade/",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1147
		backupExtension: "pre.core.upgrade"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1148
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1149
	sync: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1150
	annotations: {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1151
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1152
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1153
// Commands supported by the toolbar macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1154
config.commands = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1155
	closeTiddler: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1156
	closeOthers: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1157
	editTiddler: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1158
	saveTiddler: {hideReadOnly: true},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1159
	cancelTiddler: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1160
	deleteTiddler: {hideReadOnly: true},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1161
	permalink: {},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1162
	references: {type: "popup"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1163
	jump: {type: "popup"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1164
	syncing: {type: "popup"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1165
	fields: {type: "popup"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1166
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1167
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1168
// Browser detection... In a very few places, there's nothing else for it but to know what browser we're using.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1169
config.userAgent = navigator.userAgent.toLowerCase();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1170
config.browser = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1171
	isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1172
	isGecko: config.userAgent.indexOf("gecko") != -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1173
	ieVersion: /MSIE (\d.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1174
	isSafari: config.userAgent.indexOf("applewebkit") != -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1175
	isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1176
	firefoxDate: /gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1177
	isOpera: config.userAgent.indexOf("opera") != -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1178
	isLinux: config.userAgent.indexOf("linux") != -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1179
	isUnix: config.userAgent.indexOf("x11") != -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1180
	isMac: config.userAgent.indexOf("mac") != -1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1181
	isWindows: config.userAgent.indexOf("win") != -1
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1182
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1183
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1184
// Basic regular expressions
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1185
config.textPrimitives = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1186
	upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1187
	lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1188
	anyLetter:   "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1189
	anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1190
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1191
if(config.browser.isBadSafari) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1192
	config.textPrimitives = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1193
		upperLetter: "[A-Z\u00c0-\u00de]",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1194
		lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1195
		anyLetter:   "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1196
		anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1197
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1198
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1199
config.textPrimitives.sliceSeparator = "::";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1200
config.textPrimitives.sectionSeparator = "##";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1201
config.textPrimitives.urlPattern = "(?:file|http|https|mailto|ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1202
config.textPrimitives.unWikiLink = "~";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1203
config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1204
	config.textPrimitives.lowerLetter + "+" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1205
	config.textPrimitives.upperLetter +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1206
	config.textPrimitives.anyLetter + "*)|(?:" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1207
	config.textPrimitives.upperLetter + "{2,}" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1208
	config.textPrimitives.lowerLetter + "+))";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1209
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1210
config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1211
config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1212
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1213
config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1214
config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1215
config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1216
	config.textPrimitives.brackettedLink + ")|(?:" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1217
	config.textPrimitives.urlPattern + ")","mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1218
config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1219
	config.textPrimitives.titledBrackettedLink + ")|(?:" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1220
	config.textPrimitives.brackettedLink + ")|(?:" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1221
	config.textPrimitives.urlPattern + ")","mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1222
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1223
config.glyphs = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1224
	browsers: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1225
		function() {return config.browser.isIE;},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1226
		function() {return true;}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1227
	],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1228
	currBrowser: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1229
	codes: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1230
		downTriangle: ["\u25BC","\u25BE"],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1231
		downArrow: ["\u2193","\u2193"],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1232
		bentArrowLeft: ["\u2190","\u21A9"],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1233
		bentArrowRight: ["\u2192","\u21AA"]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1234
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1235
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1236
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1237
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1238
//-- Shadow tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1239
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1240
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1241
config.shadowTiddlers = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1242
	StyleSheet: "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1243
	MarkupPreHead: "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1244
	MarkupPostHead: "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1245
	MarkupPreBody: "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1246
	MarkupPostBody: "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1247
	TabTimeline: '<<timeline>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1248
	TabAll: '<<list all>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1249
	TabTags: '<<allTags excludeLists>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1250
	TabMoreMissing: '<<list missing>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1251
	TabMoreOrphans: '<<list orphans>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1252
	TabMoreShadowed: '<<list shadowed>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1253
	AdvancedOptions: '<<options>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1254
	PluginManager: '<<plugins>>'
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1255
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1256
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1257
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1258
//-- Translateable strings
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1259
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1260
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1261
// Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1262
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1263
merge(config.options,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1264
	txtUserName: "YourName"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1265
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1266
merge(config.tasks,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1267
	save: {text: "save", tooltip: "Save your changes to this TiddlyWiki", action: saveChanges},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1268
	sync: {text: "sync", tooltip: "Synchronise changes with other TiddlyWiki files and servers", content: '<<sync>>'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1269
	importTask: {text: "import", tooltip: "Import tiddlers and plugins from other TiddlyWiki files and servers", content: '<<importTiddlers>>'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1270
	tweak: {text: "tweak", tooltip: "Tweak the appearance and behaviour of TiddlyWiki", content: '<<options>>'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1271
	upgrade: {text: "upgrade", tooltip: "Upgrade TiddlyWiki core code", content: '<<upgrade>>'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1272
	plugins: {text: "plugins", tooltip: "Manage installed plugins", content: '<<plugins>>'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1273
});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1274
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1275
// Options that can be set in the options panel and/or cookies
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1276
merge(config.optionsDesc,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1277
	txtUserName: "Username for signing your edits",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1278
	chkRegExpSearch: "Enable regular expressions for searches",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1279
	chkCaseSensitiveSearch: "Case-sensitive searching",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1280
	chkIncrementalSearch: "Incremental key-by-key searching",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1281
	chkAnimate: "Enable animations",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1282
	chkSaveBackups: "Keep backup file when saving changes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1283
	chkAutoSave: "Automatically save changes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1284
	chkGenerateAnRssFeed: "Generate an RSS feed when saving changes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1285
	chkSaveEmptyTemplate: "Generate an empty template when saving changes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1286
	chkOpenInNewWindow: "Open external links in a new window",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1287
	chkToggleLinks: "Clicking on links to open tiddlers causes them to close",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1288
	chkHttpReadOnly: "Hide editing features when viewed over HTTP",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1289
	chkForceMinorUpdate: "Don't update modifier username and date when editing tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1290
	chkConfirmDelete: "Require confirmation before deleting tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1291
	chkInsertTabs: "Use the tab key to insert tab characters instead of moving between fields",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1292
	txtBackupFolder: "Name of folder to use for backups",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1293
	txtMaxEditRows: "Maximum number of rows in edit boxes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1294
	txtFileSystemCharSet: "Default character set for saving changes (Firefox/Mozilla only)"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1295
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1296
merge(config.messages,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1297
	customConfigError: "Problems were encountered loading plugins. See PluginManager for details",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1298
	pluginError: "Error: %0",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1299
	pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1300
	pluginForced: "Executed because forced via 'systemConfigForce' tag",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1301
	pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1302
	nothingSelected: "Nothing is selected. You must select one or more items first",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1303
	savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#DownloadSoftware for details",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1304
	subtitleUnknown: "(unknown)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1305
	undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1306
	shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1307
	tiddlerLinkTooltip: "%0 - %1, %2",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1308
	externalLinkTooltip: "External link to %0",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1309
	noTags: "There are no tagged tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1310
	notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1311
	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",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1312
	invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1313
	backupSaved: "Backup saved",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1314
	backupFailed: "Failed to save backup file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1315
	rssSaved: "RSS feed saved",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1316
	rssFailed: "Failed to save RSS feed file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1317
	emptySaved: "Empty template saved",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1318
	emptyFailed: "Failed to save empty template file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1319
	mainSaved: "Main TiddlyWiki file saved",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1320
	mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1321
	macroError: "Error in macro <<\%0>>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1322
	macroErrorDetails: "Error while executing macro <<\%0>>:\n%1",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1323
	missingMacro: "No such macro",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1324
	overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1325
	unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1326
	confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1327
	saveInstructions: "SaveChanges",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1328
	unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1329
	tiddlerSaveError: "Error when saving tiddler '%0'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1330
	tiddlerLoadError: "Error when loading tiddler '%0'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1331
	wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1332
	invalidFieldName: "Invalid field name %0",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1333
	fieldCannotBeChanged: "Field '%0' cannot be changed",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1334
	loadingMissingTiddler: "Attempting to retrieve the tiddler '%0' from the '%1' server at:\n\n'%2' in the workspace '%3'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1335
	upgradeDone: "The upgrade to version %0 is now complete\n\nClick 'OK' to reload the newly upgraded TiddlyWiki"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1336
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1337
merge(config.messages.messageClose,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1338
	text: "close",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1339
	tooltip: "close this message area"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1340
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1341
config.messages.backstage = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1342
	open: {text: "backstage", tooltip: "Open the backstage area to perform authoring and editing tasks"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1343
	close: {text: "close", tooltip: "Close the backstage area"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1344
	prompt: "backstage: ",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1345
	decal: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1346
		edit: {text: "edit", tooltip: "Edit the tiddler '%0'"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1347
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1348
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1349
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1350
config.messages.listView = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1351
	tiddlerTooltip: "Click for the full text of this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1352
	previewUnavailable: "(preview not available)"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1353
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1354
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1355
config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1356
config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1357
config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1358
config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1359
// suffixes for dates, eg "1st","2nd","3rd"..."30th","31st"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1360
config.messages.dates.daySuffixes = ["st","nd","rd","th","th","th","th","th","th","th",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1361
		"th","th","th","th","th","th","th","th","th","th",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1362
		"st","nd","rd","th","th","th","th","th","th","th",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1363
		"st"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1364
config.messages.dates.am = "am";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1365
config.messages.dates.pm = "pm";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1366
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1367
merge(config.messages.tiddlerPopup,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1368
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1369
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1370
merge(config.views.wikified.tag,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1371
	labelNoTags: "no tags",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1372
	labelTags: "tags: ",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1373
	openTag: "Open tag '%0'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1374
	tooltip: "Show tiddlers tagged with '%0'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1375
	openAllText: "Open all",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1376
	openAllTooltip: "Open all of these tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1377
	popupNone: "No other tiddlers tagged with '%0'"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1378
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1379
merge(config.views.wikified,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1380
	defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1381
	defaultModifier: "(missing)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1382
	shadowModifier: "(built-in shadow tiddler)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1383
	dateFormat: "DD MMM YYYY",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1384
	createdPrompt: "created"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1385
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1386
merge(config.views.editor,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1387
	tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1388
	defaultText: "Type the text for '%0'"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1389
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1390
merge(config.views.editor.tagChooser,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1391
	text: "tags",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1392
	tooltip: "Choose existing tags to add to this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1393
	popupNone: "There are no tags defined",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1394
	tagTooltip: "Add the tag '%0'"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1395
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1396
merge(config.messages,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1397
	sizeTemplates:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1398
		[
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1399
		{unit: 1024*1024*1024, template: "%0\u00a0GB"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1400
		{unit: 1024*1024, template: "%0\u00a0MB"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1401
		{unit: 1024, template: "%0\u00a0KB"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1402
		{unit: 1, template: "%0\u00a0B"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1403
		]});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1404
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1405
merge(config.macros.search,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1406
	label: "search",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1407
	prompt: "Search this TiddlyWiki",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1408
	accessKey: "F",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1409
	successMsg: "%0 tiddlers found matching %1",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1410
	failureMsg: "No tiddlers found matching %0"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1411
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1412
merge(config.macros.tagging,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1413
	label: "tagging: ",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1414
	labelNotTag: "not tagging",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1415
	tooltip: "List of tiddlers tagged with '%0'"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1416
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1417
merge(config.macros.timeline,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1418
	dateFormat: "DD MMM YYYY"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1419
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1420
merge(config.macros.allTags,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1421
	tooltip: "Show tiddlers tagged with '%0'",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1422
	noTags: "There are no tagged tiddlers"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1423
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1424
config.macros.list.all.prompt = "All tiddlers in alphabetical order";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1425
config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1426
config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1427
config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1428
config.macros.list.touched.prompt = "Tiddlers that have been modified locally";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1429
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1430
merge(config.macros.closeAll,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1431
	label: "close all",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1432
	prompt: "Close all displayed tiddlers (except any that are being edited)"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1433
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1434
merge(config.macros.permaview,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1435
	label: "permaview",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1436
	prompt: "Link to an URL that retrieves all the currently displayed tiddlers"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1437
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1438
merge(config.macros.saveChanges,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1439
	label: "save changes",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1440
	prompt: "Save all tiddlers to create a new TiddlyWiki",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1441
	accessKey: "S"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1442
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1443
merge(config.macros.newTiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1444
	label: "new tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1445
	prompt: "Create a new tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1446
	title: "New Tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1447
	accessKey: "N"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1448
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1449
merge(config.macros.newJournal,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1450
	label: "new journal",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1451
	prompt: "Create a new tiddler from the current date and time",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1452
	accessKey: "J"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1453
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1454
merge(config.macros.options,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1455
	wizardTitle: "Tweak advanced options",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1456
	step1Title: "These options are saved in cookies in your browser",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1457
	step1Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='false' name='chkUnknown'>Show unknown options</input>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1458
	unknownDescription: "//(unknown)//",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1459
	listViewTemplate: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1460
		columns: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1461
			{name: 'Option', field: 'option', title: "Option", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1462
			{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1463
			{name: 'Name', field: 'name', title: "Name", type: 'String'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1464
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1465
		rowClasses: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1466
			{className: 'lowlight', field: 'lowlight'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1467
			]}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1468
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1469
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1470
merge(config.macros.plugins,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1471
	wizardTitle: "Manage plugins",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1472
	step1Title: "Currently loaded plugins",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1473
	step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1474
	skippedText: "(This plugin has not been executed because it was added since startup)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1475
	noPluginText: "There are no plugins installed",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1476
	confirmDeleteText: "Are you sure you want to delete these plugins:\n\n%0",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1477
	removeLabel: "remove systemConfig tag",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1478
	removePrompt: "Remove systemConfig tag",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1479
	deleteLabel: "delete",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1480
	deletePrompt: "Delete these tiddlers forever",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1481
	listViewTemplate: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1482
		columns: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1483
			{name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1484
			{name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1485
			{name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1486
			{name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1487
			{name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1488
			{name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1489
			{name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1490
			{name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1491
			{name: 'Log', field: 'log', title: "Log", type: 'StringList'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1492
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1493
		rowClasses: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1494
			{className: 'error', field: 'error'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1495
			{className: 'warning', field: 'warning'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1496
			]}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1497
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1498
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1499
merge(config.macros.toolbar,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1500
	moreLabel: "more",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1501
	morePrompt: "Reveal further commands"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1502
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1503
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1504
merge(config.macros.refreshDisplay,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1505
	label: "refresh",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1506
	prompt: "Redraw the entire TiddlyWiki display"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1507
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1508
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1509
merge(config.macros.importTiddlers,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1510
	readOnlyWarning: "You cannot import into a read-only TiddlyWiki file. Try opening it from a file:// URL",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1511
	wizardTitle: "Import tiddlers from another file or server",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1512
	step1Title: "Step 1: Locate the server or TiddlyWiki file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1513
	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>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1514
	openLabel: "open",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1515
	openPrompt: "Open the connection to this file or server",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1516
	openError: "There were problems fetching the tiddlywiki file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1517
	statusOpenHost: "Opening the host",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1518
	statusGetWorkspaceList: "Getting the list of available workspaces",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1519
	step2Title: "Step 2: Choose the workspace",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1520
	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>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1521
	cancelLabel: "cancel",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1522
	cancelPrompt: "Cancel this import",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1523
	statusOpenWorkspace: "Opening the workspace",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1524
	statusGetTiddlerList: "Getting the list of available tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1525
	errorGettingTiddlerList: "Error getting list of tiddlers, click Cancel to try again",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1526
	step3Title: "Step 3: Choose the tiddlers to import",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1527
	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'>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1528
	importLabel: "import",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1529
	importPrompt: "Import these tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1530
	confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1531
	step4Title: "Step 4: Importing %0 tiddler(s)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1532
	step4Html: "<input type='hidden' name='markReport'></input>", // DO NOT TRANSLATE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1533
	doneLabel: "done",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1534
	donePrompt: "Close this wizard",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1535
	statusDoingImport: "Importing tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1536
	statusDoneImport: "All tiddlers imported",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1537
	systemServerNamePattern: "%2 on %1",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1538
	systemServerNamePatternNoWorkspace: "%1",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1539
	confirmOverwriteSaveTiddler: "The tiddler '%0' already exists. Click 'OK' to overwrite it with the details of this server, or 'Cancel' to leave it unchanged",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1540
	serverSaveTemplate: "|''Type:''|%0|\n|''URL:''|%1|\n|''Workspace:''|%2|\n\nThis tiddler was automatically created to record the details of this server",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1541
	serverSaveModifier: "(System)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1542
	listViewTemplate: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1543
		columns: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1544
			{name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1545
			{name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1546
			{name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1547
			{name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1548
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1549
		rowClasses: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1550
			]}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1551
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1552
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1553
merge(config.macros.upgrade,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1554
	wizardTitle: "Upgrade TiddlyWiki core code",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1555
	step1Title: "Update or repair this TiddlyWiki to the latest release",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1556
	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>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1557
	errorCantUpgrade: "Unable to upgrade this TiddlyWiki. You can only perform upgrades on TiddlyWiki files stored locally",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1558
	errorNotSaved: "You must save changes before you can perform an upgrade",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1559
	step2Title: "Confirm the upgrade details",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1560
	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",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1561
	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",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1562
	step2Html_upgrade: "You are about to upgrade to TiddlyWiki version %0 from %1",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1563
	upgradeLabel: "upgrade",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1564
	upgradePrompt: "Prepare for the upgrade process",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1565
	statusPreparingBackup: "Preparing backup",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1566
	statusSavingBackup: "Saving backup file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1567
	errorSavingBackup: "There was a problem saving the backup file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1568
	statusLoadingCore: "Loading core code",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1569
	errorLoadingCore: "Error loading the core code",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1570
	errorCoreFormat: "Error with the new core code",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1571
	statusSavingCore: "Saving the new core code",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1572
	statusReloadingCore: "Reloading the new core code",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1573
	startLabel: "start",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1574
	startPrompt: "Start the upgrade process",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1575
	cancelLabel: "cancel",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1576
	cancelPrompt: "Cancel the upgrade process",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1577
	step3Title: "Upgrade cancelled",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1578
	step3Html: "You have cancelled the upgrade process"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1579
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1580
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1581
merge(config.macros.sync,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1582
	listViewTemplate: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1583
		columns: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1584
			{name: 'Selected', field: 'selected', rowName: 'title', type: 'Selector'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1585
			{name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1586
			{name: 'Server Type', field: 'serverType', title: "Server type", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1587
			{name: 'Server Host', field: 'serverHost', title: "Server host", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1588
			{name: 'Server Workspace', field: 'serverWorkspace', title: "Server workspace", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1589
			{name: 'Status', field: 'status', title: "Synchronisation status", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1590
			{name: 'Server URL', field: 'serverUrl', title: "Server URL", text: "View", type: 'Link'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1591
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1592
		rowClasses: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1593
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1594
		buttons: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1595
			{caption: "Sync these tiddlers", name: 'sync'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1596
			]},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1597
	wizardTitle: "Synchronize with external servers and files",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1598
	step1Title: "Choose the tiddlers you want to synchronize",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1599
	step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1600
	syncLabel: "sync",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1601
	syncPrompt: "Sync these tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1602
	hasChanged: "Changed while unplugged",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1603
	hasNotChanged: "Unchanged while unplugged",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1604
	syncStatusList: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1605
		none: {text: "...", color: "transparent"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1606
		changedServer: {text: "Changed on server", color: '#80ff80'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1607
		changedLocally: {text: "Changed while unplugged", color: '#80ff80'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1608
		changedBoth: {text: "Changed while unplugged and on server", color: '#ff8080'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1609
		notFound: {text: "Not found on server", color: '#ffff80'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1610
		putToServer: {text: "Saved update on server", color: '#ff80ff'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1611
		gotFromServer: {text: "Retrieved update from server", color: '#80ffff'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1612
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1613
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1614
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1615
merge(config.macros.annotations,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1616
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1617
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1618
merge(config.commands.closeTiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1619
	text: "close",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1620
	tooltip: "Close this tiddler"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1621
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1622
merge(config.commands.closeOthers,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1623
	text: "close others",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1624
	tooltip: "Close all other tiddlers"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1625
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1626
merge(config.commands.editTiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1627
	text: "edit",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1628
	tooltip: "Edit this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1629
	readOnlyText: "view",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1630
	readOnlyTooltip: "View the source of this tiddler"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1631
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1632
merge(config.commands.saveTiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1633
	text: "done",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1634
	tooltip: "Save changes to this tiddler"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1635
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1636
merge(config.commands.cancelTiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1637
	text: "cancel",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1638
	tooltip: "Undo changes to this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1639
	warning: "Are you sure you want to abandon your changes to '%0'?",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1640
	readOnlyText: "done",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1641
	readOnlyTooltip: "View this tiddler normally"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1642
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1643
merge(config.commands.deleteTiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1644
	text: "delete",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1645
	tooltip: "Delete this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1646
	warning: "Are you sure you want to delete '%0'?"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1647
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1648
merge(config.commands.permalink,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1649
	text: "permalink",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1650
	tooltip: "Permalink for this tiddler"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1651
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1652
merge(config.commands.references,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1653
	text: "references",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1654
	tooltip: "Show tiddlers that link to this one",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1655
	popupNone: "No references"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1656
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1657
merge(config.commands.jump,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1658
	text: "jump",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1659
	tooltip: "Jump to another open tiddler"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1660
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1661
merge(config.commands.syncing,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1662
	text: "syncing",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1663
	tooltip: "Control synchronisation of this tiddler with a server or external file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1664
	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
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1665
	notCurrentlySyncing: "Not currently syncing",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1666
	captionUnSync: "Stop synchronising this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1667
	chooseServer: "Synchronise this tiddler with another server:",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1668
	currServerMarker: "\u25cf ",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1669
	notCurrServerMarker: "  "});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1670
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1671
merge(config.commands.fields,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1672
	text: "fields",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1673
	tooltip: "Show the extended fields of this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1674
	emptyText: "There are no extended fields for this tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1675
	listViewTemplate: {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1676
		columns: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1677
			{name: 'Field', field: 'field', title: "Field", type: 'String'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1678
			{name: 'Value', field: 'value', title: "Value", type: 'String'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1679
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1680
		rowClasses: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1681
			],
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1682
		buttons: [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1683
			]}});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1684
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1685
merge(config.shadowTiddlers,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1686
	DefaultTiddlers: "GettingStarted",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1687
	MainMenu: "GettingStarted",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1688
	SiteTitle: "My TiddlyWiki",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1689
	SiteSubtitle: "a reusable non-linear personal web notebook",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1690
	SiteUrl: "http://www.tiddlywiki.com/",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1691
	SideBarOptions: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY" "journal">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options \u00bb" "Change TiddlyWiki advanced options">>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1692
	SideBarTabs: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1693
	TabMore: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1694
	ToolbarCommands: "|~ViewToolbar|closeTiddler closeOthers +editTiddler > fields syncing permalink references jump|\n|~EditToolbar|+saveTiddler -cancelTiddler deleteTiddler|"});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1695
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1696
merge(config.annotations,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1697
	AdvancedOptions: "This shadow tiddler provides access to several advanced options",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1698
	ColorPalette: "These values in this shadow tiddler determine the colour scheme of the ~TiddlyWiki user interface",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1699
	DefaultTiddlers: "The tiddlers listed in this shadow tiddler will be automatically displayed when ~TiddlyWiki starts up",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1700
	EditTemplate: "The HTML template in this shadow tiddler determines how tiddlers look while they are being edited",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1701
	GettingStarted: "This shadow tiddler provides basic usage instructions",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1702
	ImportTiddlers: "This shadow tiddler provides access to importing tiddlers",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1703
	MainMenu: "This shadow tiddler is used as the contents of the main menu in the left-hand column of the screen",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1704
	MarkupPreHead: "This tiddler is inserted at the top of the <head> section of the TiddlyWiki HTML file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1705
	MarkupPostHead: "This tiddler is inserted at the bottom of the <head> section of the TiddlyWiki HTML file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1706
	MarkupPreBody: "This tiddler is inserted at the top of the <body> section of the TiddlyWiki HTML file",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1707
	MarkupPostBody: "This tiddler is inserted at the end of the <body> section of the TiddlyWiki HTML file immediately after the script block",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1708
	OptionsPanel: "This shadow tiddler is used as the contents of the options panel slider in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1709
	PageTemplate: "The HTML template in this shadow tiddler determines the overall ~TiddlyWiki layout",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1710
	PluginManager: "This shadow tiddler provides access to the plugin manager",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1711
	SideBarOptions: "This shadow tiddler is used as the contents of the option panel in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1712
	SideBarTabs: "This shadow tiddler is used as the contents of the tabs panel in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1713
	SiteSubtitle: "This shadow tiddler is used as the second part of the page title",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1714
	SiteTitle: "This shadow tiddler is used as the first part of the page title",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1715
	SiteUrl: "This shadow tiddler should be set to the full target URL for publication",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1716
	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",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1717
	StyleSheet: "This tiddler can contain custom CSS definitions",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1718
	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",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1719
	StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1720
	StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1721
	TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1722
	TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1723
	TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1724
	TabMoreOrphans: "This shadow tiddler contains the contents of the 'Orphans' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1725
	TabMoreShadowed: "This shadow tiddler contains the contents of the 'Shadowed' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1726
	TabTags: "This shadow tiddler contains the contents of the 'Tags' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1727
	TabTimeline: "This shadow tiddler contains the contents of the 'Timeline' tab in the right-hand sidebar",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1728
	ToolbarCommands: "This shadow tiddler determines which commands are shown in tiddler toolbars",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1729
	ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1730
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1731
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1732
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1733
//-- Main
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1734
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1735
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1736
var params = null; // Command line parameters
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1737
var store = null; // TiddlyWiki storage
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1738
var story = null; // Main story
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1739
var formatter = null; // Default formatters for the wikifier
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1740
var anim = typeof Animator == "function" ? new Animator() : null; // Animation engine
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1741
var readOnly = false; // Whether we're in readonly mode
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1742
var highlightHack = null; // Embarrassing hack department...
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1743
var hadConfirmExit = false; // Don't warn more than once
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1744
var safeMode = false; // Disable all plugins and cookies
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1745
var showBackstage; // Whether to include the backstage area
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1746
var installedPlugins = []; // Information filled in when plugins are executed
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1747
var startingUp = false; // Whether we're in the process of starting up
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1748
var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1749
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1750
// Whether to use the JavaSaver applet
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1751
var useJavaSaver = (config.browser.isSafari || config.browser.isOpera) && (document.location.toString().substr(0,4) != "http");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1752
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1753
// Starting up
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1754
function main()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1755
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1756
	var t10,t9,t8,t7,t6,t5,t4,t3,t2,t1,t0 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1757
	startingUp = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1758
	window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1759
	params = getParameters();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1760
	if(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1761
		params = params.parseParams("open",null,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1762
	store = new TiddlyWiki();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1763
	invokeParamifier(params,"oninit");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1764
	story = new Story("tiddlerDisplay","tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1765
	addEvent(document,"click",Popup.onDocumentClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1766
	saveTest();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1767
	loadOptionsCookie();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1768
	for(var s=0; s<config.notifyTiddlers.length; s++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1769
		store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1770
	t1 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1771
	loadShadowTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1772
	t2 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1773
	store.loadFromDiv("storeArea","store",true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1774
	t3 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1775
	invokeParamifier(params,"onload");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1776
	t4 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1777
	readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1778
	showBackstage = !readOnly;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1779
	var pluginProblem = loadPlugins();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1780
	t5 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1781
	formatter = new Formatter(config.formatters);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1782
	story.switchTheme(config.options.txtTheme);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1783
	invokeParamifier(params,"onconfig");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1784
	t6 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1785
	store.notifyAll();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1786
	t7 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1787
	restart();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1788
	refreshDisplay();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1789
	t8 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1790
	if(pluginProblem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1791
		story.displayTiddler(null,"PluginManager");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1792
		displayMessage(config.messages.customConfigError);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1793
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1794
	for(var m in config.macros) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1795
		if(config.macros[m].init)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1796
			config.macros[m].init();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1797
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1798
	t9 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1799
	if(showBackstage)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1800
		backstage.init();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1801
	t10 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1802
	if(config.options.chkDisplayInstrumentation) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1803
		displayMessage("LoadShadows " + (t2-t1) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1804
		displayMessage("LoadFromDiv " + (t3-t2) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1805
		displayMessage("LoadPlugins " + (t5-t4) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1806
		displayMessage("Notify " + (t7-t6) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1807
		displayMessage("Restart " + (t8-t7) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1808
		displayMessage("Macro init " + (t9-t8) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1809
		displayMessage("Total: " + (t10-t0) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1810
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1811
	startingUp = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1812
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1813
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1814
// Restarting
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1815
function restart()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1816
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1817
	invokeParamifier(params,"onstart");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1818
	if(story.isEmpty()) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1819
		var tiddlers = store.filterTiddlers(store.getTiddlerText("DefaultTiddlers"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1820
		story.displayTiddlers(null,tiddlers);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1821
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1822
	window.scrollTo(0,0);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1823
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1824
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1825
function saveTest()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1826
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1827
	var s = document.getElementById("saveTest");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1828
	if(s.hasChildNodes())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1829
		alert(config.messages.savedSnapshotError);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1830
	s.appendChild(document.createTextNode("savetest"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1831
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1832
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1833
function loadShadowTiddlers()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1834
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1835
	var shadows = new TiddlyWiki();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1836
	shadows.loadFromDiv("shadowArea","shadows",true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1837
	shadows.forEachTiddler(function(title,tiddler){config.shadowTiddlers[title] = tiddler.text;});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1838
	delete shadows;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1839
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1840
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1841
function loadPlugins()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1842
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1843
	if(safeMode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1844
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1845
	var tiddlers = store.getTaggedTiddlers("systemConfig");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1846
	var toLoad = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1847
	var nLoaded = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1848
	var map = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1849
	var nPlugins = tiddlers.length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1850
	installedPlugins = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1851
	for(var i=0; i<nPlugins; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1852
		var p = getPluginInfo(tiddlers[i]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1853
		installedPlugins[i] = p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1854
		var n = p.Name;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1855
		if(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1856
			map[n] = p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1857
		n = p.Source;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1858
		if(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1859
			map[n] = p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1860
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1861
	var visit = function(p) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1862
		if(!p || p.done)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1863
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1864
		p.done = 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1865
		var reqs = p.Requires;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1866
		if(reqs) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1867
			reqs = reqs.readBracketedList();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1868
			for(var i=0; i<reqs.length; i++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1869
				visit(map[reqs[i]]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1870
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1871
		toLoad.push(p);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1872
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1873
	for(i=0; i<nPlugins; i++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1874
		visit(installedPlugins[i]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1875
	for(i=0; i<toLoad.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1876
		p = toLoad[i];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1877
		pluginInfo = p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1878
		tiddler = p.tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1879
		if(isPluginExecutable(p)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1880
			if(isPluginEnabled(p)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1881
				p.executed = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1882
				var startTime = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1883
				try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1884
					if(tiddler.text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1885
						window.eval(tiddler.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1886
					nLoaded++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1887
				} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1888
					p.log.push(config.messages.pluginError.format([exceptionText(ex)]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1889
					p.error = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1890
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1891
				pluginInfo.startupTime = String((new Date()) - startTime) + "ms";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1892
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1893
				nPlugins--;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1894
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1895
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1896
			p.warning = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1897
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1898
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1899
	return nLoaded != nPlugins;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1900
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1901
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1902
function getPluginInfo(tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1903
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1904
	var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","Requires","CoreVersion","Date","Source","Author","License","Browsers"]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1905
	p.tiddler = tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1906
	p.title = tiddler.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1907
	p.log = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1908
	return p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1909
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1910
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1911
// Check that a particular plugin is valid for execution
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1912
function isPluginExecutable(plugin)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1913
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1914
	if(plugin.tiddler.isTagged("systemConfigForce"))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1915
		return verifyTail(plugin,true,config.messages.pluginForced);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1916
	if(plugin["CoreVersion"]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1917
		var coreVersion = plugin["CoreVersion"].split(".");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1918
		var w = parseInt(coreVersion[0]) - version.major;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1919
		if(w == 0 && coreVersion[1])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1920
			w = parseInt(coreVersion[1]) - version.minor;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1921
		if(w == 0 && coreVersion[2])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1922
			w = parseInt(coreVersion[2]) - version.revision;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1923
		if(w > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1924
			return verifyTail(plugin,false,config.messages.pluginVersionError);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1925
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1926
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1927
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1928
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1929
function isPluginEnabled(plugin)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1930
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1931
	if(plugin.tiddler.isTagged("systemConfigDisable"))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1932
		return verifyTail(plugin,false,config.messages.pluginDisabled);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1933
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1934
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1935
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1936
function verifyTail(plugin,result,message)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1937
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1938
	plugin.log.push(message);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1939
	return result;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1940
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1941
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1942
function invokeMacro(place,macro,params,wikifier,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1943
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1944
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1945
		var m = config.macros[macro];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1946
		if(m && m.handler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1947
			m.handler(place,macro,params.readMacroParams(),wikifier,params,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1948
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1949
			createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1950
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1951
		createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1952
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1953
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1954
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1955
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1956
//-- Paramifiers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1957
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1958
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1959
function getParameters()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1960
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1961
	var p = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1962
	if(window.location.hash) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1963
		p = decodeURIComponent(window.location.hash.substr(1));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1964
		if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1965
			p = convertUTF8ToUnicode(p);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1966
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1967
	return p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1968
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1969
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1970
function invokeParamifier(params,handler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1971
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1972
	if(!params || params.length == undefined || params.length <= 1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1973
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1974
	for(var t=1; t<params.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1975
		var p = config.paramifiers[params[t].name];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1976
		if(p && p[handler] instanceof Function)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1977
			p[handler](params[t].value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1978
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1979
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1980
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1981
config.paramifiers = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1982
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1983
config.paramifiers.start = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1984
	oninit: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1985
		safeMode = v.toLowerCase() == "safe";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1986
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1987
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1988
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1989
config.paramifiers.open = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1990
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1991
		if(!readOnly || store.tiddlerExists(v) || store.isShadowTiddler(v))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1992
			story.displayTiddler("bottom",v,null,false,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1993
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1994
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1995
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1996
config.paramifiers.story = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1997
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1998
		var list = store.getTiddlerText(v,"").parseParams("open",null,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  1999
		invokeParamifier(list,"onstart");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2000
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2001
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2002
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2003
config.paramifiers.search = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2004
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2005
		story.search(v,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2006
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2007
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2008
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2009
config.paramifiers.searchRegExp = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2010
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2011
		story.prototype.search(v,false,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2012
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2013
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2014
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2015
config.paramifiers.tag = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2016
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2017
		var tagged = store.getTaggedTiddlers(v,"title");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2018
		story.displayTiddlers(null,tagged,null,false,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2019
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2020
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2021
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2022
config.paramifiers.newTiddler = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2023
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2024
		if(!readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2025
			story.displayTiddler(null,v,DEFAULT_EDIT_TEMPLATE);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2026
			story.focusTiddler(v,"text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2027
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2028
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2029
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2030
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2031
config.paramifiers.newJournal = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2032
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2033
		if(!readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2034
			var now = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2035
			var title = now.formatString(v.trim());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2036
			story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2037
			story.focusTiddler(title,"text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2038
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2039
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2040
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2041
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2042
config.paramifiers.readOnly = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2043
	onconfig: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2044
		var p = v.toLowerCase();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2045
		readOnly = p == "yes" ? true : (p == "no" ? false : readOnly);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2046
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2047
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2048
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2049
config.paramifiers.theme = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2050
	onconfig: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2051
		story.switchTheme(v);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2052
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2053
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2054
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2055
config.paramifiers.upgrade = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2056
	onstart: function(v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2057
		upgradeFrom(v);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2058
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2059
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2060
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2061
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2062
//-- Formatter helpers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2063
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2064
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2065
function Formatter(formatters)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2066
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2067
	this.formatters = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2068
	var pattern = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2069
	for(var n=0; n<formatters.length; n++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2070
		pattern.push("(" + formatters[n].match + ")");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2071
		this.formatters.push(formatters[n]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2072
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2073
	this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2074
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2075
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2076
config.formatterHelpers = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2077
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2078
	createElementAndWikify: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2079
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2080
		w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2081
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2082
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2083
	inlineCssHelper: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2084
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2085
		var styles = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2086
		config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2087
		var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2088
		while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2089
			var s,v;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2090
			if(lookaheadMatch[1]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2091
				s = lookaheadMatch[1].unDash();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2092
				v = lookaheadMatch[2];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2093
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2094
				s = lookaheadMatch[3].unDash();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2095
				v = lookaheadMatch[4];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2096
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2097
			if(s=="bgcolor")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2098
				s = "backgroundColor";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2099
			styles.push({style: s, value: v});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2100
			w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2101
			config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2102
			lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2103
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2104
		return styles;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2105
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2106
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2107
	applyCssHelper: function(e,styles)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2108
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2109
		for(var t=0; t< styles.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2110
			try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2111
				e.style[styles[t].style] = styles[t].value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2112
			} catch (ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2113
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2114
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2115
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2116
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2117
	enclosedTextHelper: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2118
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2119
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2120
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2121
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2122
			var text = lookaheadMatch[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2123
			if(config.browser.isIE)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2124
				text = text.replace(/\n/g,"\r");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2125
			createTiddlyElement(w.output,this.element,null,null,text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2126
			w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2127
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2128
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2129
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2130
	isExternalLink: function(link)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2131
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2132
		if(store.tiddlerExists(link) || store.isShadowTiddler(link)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2133
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2134
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2135
		var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2136
		if(urlRegExp.exec(link)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2137
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2138
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2139
		if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2140
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2141
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2142
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2143
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2144
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2145
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2146
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2147
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2148
//-- Standard formatters
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2149
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2150
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2151
config.formatters = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2152
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2153
	name: "table",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2154
	match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2155
	lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2156
	rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2157
	cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2158
	cellTermRegExp: /((?:\x20*)\|)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2159
	rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2160
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2161
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2162
		var table = createTiddlyElement(w.output,"table",null,"twtable");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2163
		var prevColumns = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2164
		var currRowType = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2165
		var rowContainer;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2166
		var rowCount = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2167
		w.nextMatch = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2168
		this.lookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2169
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2170
		while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2171
			var nextRowType = lookaheadMatch[2];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2172
			if(nextRowType == "k") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2173
				table.className = lookaheadMatch[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2174
				w.nextMatch += lookaheadMatch[0].length+1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2175
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2176
				if(nextRowType != currRowType) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2177
					rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2178
					currRowType = nextRowType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2179
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2180
				if(currRowType == "c") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2181
					// Caption
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2182
					w.nextMatch++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2183
					if(rowContainer != table.firstChild)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2184
						table.insertBefore(rowContainer,table.firstChild);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2185
					rowContainer.setAttribute("align",rowCount == 0?"top":"bottom");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2186
					w.subWikifyTerm(rowContainer,this.rowTermRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2187
				} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2188
					var theRow = createTiddlyElement(rowContainer,"tr",null,(rowCount&1)?"oddRow":"evenRow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2189
					theRow.onmouseover = function() {addClass(this,"hoverRow");};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2190
					theRow.onmouseout = function() {removeClass(this,"hoverRow");};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2191
					this.rowHandler(w,theRow,prevColumns);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2192
					rowCount++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2193
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2194
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2195
			this.lookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2196
			lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2197
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2198
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2199
	rowHandler: function(w,e,prevColumns)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2200
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2201
		var col = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2202
		var colSpanCount = 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2203
		var prevCell = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2204
		this.cellRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2205
		var cellMatch = this.cellRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2206
		while(cellMatch && cellMatch.index == w.nextMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2207
			if(cellMatch[1] == "~") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2208
				// Rowspan
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2209
				var last = prevColumns[col];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2210
				if(last) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2211
					last.rowSpanCount++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2212
					last.element.setAttribute("rowspan",last.rowSpanCount);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2213
					last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2214
					last.element.valign = "center";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2215
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2216
				w.nextMatch = this.cellRegExp.lastIndex-1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2217
			} else if(cellMatch[1] == ">") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2218
				// Colspan
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2219
				colSpanCount++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2220
				w.nextMatch = this.cellRegExp.lastIndex-1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2221
			} else if(cellMatch[2]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2222
				// End of row
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2223
				if(prevCell && colSpanCount > 1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2224
					prevCell.setAttribute("colspan",colSpanCount);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2225
					prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2226
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2227
				w.nextMatch = this.cellRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2228
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2229
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2230
				// Cell
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2231
				w.nextMatch++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2232
				var styles = config.formatterHelpers.inlineCssHelper(w);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2233
				var spaceLeft = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2234
				var chr = w.source.substr(w.nextMatch,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2235
				while(chr == " ") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2236
					spaceLeft = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2237
					w.nextMatch++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2238
					chr = w.source.substr(w.nextMatch,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2239
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2240
				var cell;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2241
				if(chr == "!") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2242
					cell = createTiddlyElement(e,"th");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2243
					w.nextMatch++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2244
				} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2245
					cell = createTiddlyElement(e,"td");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2246
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2247
				prevCell = cell;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2248
				prevColumns[col] = {rowSpanCount:1,element:cell};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2249
				if(colSpanCount > 1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2250
					cell.setAttribute("colspan",colSpanCount);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2251
					cell.setAttribute("colSpan",colSpanCount); // Needed for IE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2252
					colSpanCount = 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2253
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2254
				config.formatterHelpers.applyCssHelper(cell,styles);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2255
				w.subWikifyTerm(cell,this.cellTermRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2256
				if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2257
					cell.align = spaceLeft ? "center" : "left";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2258
				else if(spaceLeft)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2259
					cell.align = "right";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2260
				w.nextMatch--;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2261
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2262
			col++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2263
			this.cellRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2264
			cellMatch = this.cellRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2265
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2266
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2267
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2268
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2269
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2270
	name: "heading",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2271
	match: "^!{1,6}",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2272
	termRegExp: /(\n)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2273
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2274
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2275
		w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2276
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2277
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2278
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2279
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2280
	name: "list",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2281
	match: "^(?:[\\*#;:]+)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2282
	lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2283
	termRegExp: /(\n)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2284
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2285
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2286
		var stack = [w.output];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2287
		var currLevel = 0, currType = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2288
		var listLevel, listType, itemType, baseType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2289
		w.nextMatch = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2290
		this.lookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2291
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2292
		while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2293
			if(lookaheadMatch[1]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2294
				listType = "ul";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2295
				itemType = "li";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2296
			} else if(lookaheadMatch[2]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2297
				listType = "ol";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2298
				itemType = "li";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2299
			} else if(lookaheadMatch[3]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2300
				listType = "dl";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2301
				itemType = "dt";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2302
			} else if(lookaheadMatch[4]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2303
				listType = "dl";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2304
				itemType = "dd";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2305
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2306
			if(!baseType)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2307
				baseType = listType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2308
			listLevel = lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2309
			w.nextMatch += lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2310
			var t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2311
			if(listLevel > currLevel) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2312
				for(t=currLevel; t<listLevel; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2313
					var target = (currLevel == 0) ? stack[stack.length-1] : stack[stack.length-1].lastChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2314
					stack.push(createTiddlyElement(target,listType));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2315
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2316
			} else if(listType!=baseType && listLevel==1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2317
				w.nextMatch -= lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2318
				return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2319
			} else if(listLevel < currLevel) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2320
				for(t=currLevel; t>listLevel; t--)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2321
					stack.pop();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2322
			} else if(listLevel == currLevel && listType != currType) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2323
				stack.pop();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2324
				stack.push(createTiddlyElement(stack[stack.length-1].lastChild,listType));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2325
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2326
			currLevel = listLevel;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2327
			currType = listType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2328
			var e = createTiddlyElement(stack[stack.length-1],itemType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2329
			w.subWikifyTerm(e,this.termRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2330
			this.lookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2331
			lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2332
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2333
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2334
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2335
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2336
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2337
	name: "quoteByBlock",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2338
	match: "^<<<\\n",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2339
	termRegExp: /(^<<<(\n|$))/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2340
	element: "blockquote",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2341
	handler: config.formatterHelpers.createElementAndWikify
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2342
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2343
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2344
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2345
	name: "quoteByLine",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2346
	match: "^>+",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2347
	lookaheadRegExp: /^>+/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2348
	termRegExp: /(\n)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2349
	element: "blockquote",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2350
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2351
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2352
		var stack = [w.output];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2353
		var currLevel = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2354
		var newLevel = w.matchLength;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2355
		var t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2356
		do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2357
			if(newLevel > currLevel) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2358
				for(t=currLevel; t<newLevel; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2359
					stack.push(createTiddlyElement(stack[stack.length-1],this.element));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2360
			} else if(newLevel < currLevel) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2361
				for(t=currLevel; t>newLevel; t--)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2362
					stack.pop();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2363
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2364
			currLevel = newLevel;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2365
			w.subWikifyTerm(stack[stack.length-1],this.termRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2366
			createTiddlyElement(stack[stack.length-1],"br");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2367
			this.lookaheadRegExp.lastIndex = w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2368
			var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2369
			var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2370
			if(matched) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2371
				newLevel = lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2372
				w.nextMatch += lookaheadMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2373
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2374
		} while(matched);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2375
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2376
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2377
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2378
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2379
	name: "rule",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2380
	match: "^----+$\\n?",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2381
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2382
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2383
		createTiddlyElement(w.output,"hr");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2384
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2385
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2386
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2387
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2388
	name: "monospacedByLine",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2389
	match: "^(?:/\\*\\{\\{\\{\\*/|\\{\\{\\{|//\\{\\{\\{|<!--\\{\\{\\{-->)\\n",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2390
	element: "pre",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2391
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2392
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2393
		switch(w.matchText) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2394
		case "/*{{{*/\n": // CSS
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2395
			this.lookaheadRegExp = /\/\*\{\{\{\*\/\n*((?:^[^\n]*\n)+?)(\n*^\/\*\}\}\}\*\/$\n?)/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2396
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2397
		case "{{{\n": // monospaced block
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2398
			this.lookaheadRegExp = /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2399
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2400
		case "//{{{\n": // plugin
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2401
			this.lookaheadRegExp = /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\/\/\}\}\}$\n?)/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2402
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2403
		case "<!--{{{-->\n": //template
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2404
			this.lookaheadRegExp = /<!--\{\{\{-->\n*((?:^[^\n]*\n)+?)(\n*^<!--\}\}\}-->$\n?)/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2405
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2406
		default:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2407
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2408
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2409
		config.formatterHelpers.enclosedTextHelper.call(this,w);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2410
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2411
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2412
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2413
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2414
	name: "wikifyComment",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2415
	match: "^(?:/\\*\\*\\*|<!---)\\n",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2416
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2417
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2418
		var termRegExp = (w.matchText == "/***\n") ? (/(^\*\*\*\/\n)/mg) : (/(^--->\n)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2419
		w.subWikifyTerm(w.output,termRegExp);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2420
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2421
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2422
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2423
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2424
	name: "macro",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2425
	match: "<<",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2426
	lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2427
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2428
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2429
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2430
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2431
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2432
			w.nextMatch = this.lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2433
			invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2434
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2435
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2436
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2437
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2438
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2439
	name: "prettyLink",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2440
	match: "\\[\\[",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2441
	lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2442
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2443
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2444
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2445
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2446
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2447
			var e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2448
			var text = lookaheadMatch[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2449
			if(lookaheadMatch[3]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2450
				// Pretty bracketted link
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2451
				var link = lookaheadMatch[3];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2452
				e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link)) ?
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2453
						createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2454
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2455
				// Simple bracketted link
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2456
				e = createTiddlyLink(w.output,text,false,null,w.isStatic,w.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2457
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2458
			createTiddlyText(e,text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2459
			w.nextMatch = this.lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2460
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2461
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2462
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2463
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2464
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2465
	name: "wikiLink",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2466
	match: config.textPrimitives.unWikiLink+"?"+config.textPrimitives.wikiLink,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2467
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2468
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2469
		if(w.matchText.substr(0,1) == config.textPrimitives.unWikiLink) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2470
			w.outputText(w.output,w.matchStart+1,w.nextMatch);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2471
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2472
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2473
		if(w.matchStart > 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2474
			var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2475
			preRegExp.lastIndex = w.matchStart-1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2476
			var preMatch = preRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2477
			if(preMatch.index == w.matchStart-1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2478
				w.outputText(w.output,w.matchStart,w.nextMatch);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2479
				return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2480
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2481
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2482
		if(w.autoLinkWikiWords || store.isShadowTiddler(w.matchText)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2483
			var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic,w.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2484
			w.outputText(link,w.matchStart,w.nextMatch);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2485
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2486
			w.outputText(w.output,w.matchStart,w.nextMatch);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2487
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2488
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2489
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2490
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2491
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2492
	name: "urlLink",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2493
	match: config.textPrimitives.urlPattern,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2494
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2495
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2496
		w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2497
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2498
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2499
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2500
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2501
	name: "image",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2502
	match: "\\[[<>]?[Ii][Mm][Gg]\\[",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2503
	lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2504
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2505
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2506
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2507
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2508
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2509
			var e = w.output;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2510
			if(lookaheadMatch[5]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2511
				var link = lookaheadMatch[5];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2512
				e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2513
				addClass(e,"imageLink");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2514
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2515
			var img = createTiddlyElement(e,"img");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2516
			if(lookaheadMatch[1])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2517
				img.align = "left";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2518
			else if(lookaheadMatch[2])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2519
				img.align = "right";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2520
			if(lookaheadMatch[3]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2521
				img.title = lookaheadMatch[3];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2522
				img.setAttribute("alt",lookaheadMatch[3]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2523
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2524
			img.src = lookaheadMatch[4];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2525
			w.nextMatch = this.lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2526
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2527
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2528
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2529
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2530
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2531
	name: "html",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2532
	match: "<[Hh][Tt][Mm][Ll]>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2533
	lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2534
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2535
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2536
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2537
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2538
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2539
			createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2540
			w.nextMatch = this.lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2541
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2542
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2543
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2544
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2545
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2546
	name: "commentByBlock",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2547
	match: "/%",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2548
	lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2549
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2550
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2551
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2552
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2553
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2554
			w.nextMatch = this.lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2555
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2556
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2557
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2558
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2559
	name: "characterFormat",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2560
	match: "''|//|__|\\^\\^|~~|--(?!\\s|$)|\\{\\{\\{",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2561
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2562
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2563
		switch(w.matchText) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2564
		case "''":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2565
			w.subWikifyTerm(w.output.appendChild(document.createElement("strong")),/('')/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2566
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2567
		case "//":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2568
			w.subWikifyTerm(createTiddlyElement(w.output,"em"),/(\/\/)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2569
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2570
		case "__":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2571
			w.subWikifyTerm(createTiddlyElement(w.output,"u"),/(__)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2572
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2573
		case "^^":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2574
			w.subWikifyTerm(createTiddlyElement(w.output,"sup"),/(\^\^)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2575
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2576
		case "~~":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2577
			w.subWikifyTerm(createTiddlyElement(w.output,"sub"),/(~~)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2578
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2579
		case "--":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2580
			w.subWikifyTerm(createTiddlyElement(w.output,"strike"),/(--)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2581
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2582
		case "{{{":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2583
			var lookaheadRegExp = /\{\{\{((?:.|\n)*?)\}\}\}/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2584
			lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2585
			var lookaheadMatch = lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2586
			if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2587
				createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2588
				w.nextMatch = lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2589
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2590
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2591
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2592
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2593
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2594
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2595
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2596
	name: "customFormat",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2597
	match: "@@|\\{\\{",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2598
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2599
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2600
		switch(w.matchText) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2601
		case "@@":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2602
			var e = createTiddlyElement(w.output,"span");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2603
			var styles = config.formatterHelpers.inlineCssHelper(w);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2604
			if(styles.length == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2605
				e.className = "marked";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2606
			else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2607
				config.formatterHelpers.applyCssHelper(e,styles);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2608
			w.subWikifyTerm(e,/(@@)/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2609
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2610
		case "{{":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2611
			lookaheadRegExp = /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2612
			lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2613
			lookaheadMatch = lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2614
			if(lookaheadMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2615
				w.nextMatch = lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2616
				e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2617
				w.subWikifyTerm(e,/(\}\}\})/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2618
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2619
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2620
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2621
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2622
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2623
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2624
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2625
	name: "mdash",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2626
	match: "--",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2627
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2628
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2629
		createTiddlyElement(w.output,"span").innerHTML = "&mdash;";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2630
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2631
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2632
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2633
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2634
	name: "lineBreak",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2635
	match: "\\n|<br ?/?>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2636
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2637
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2638
		createTiddlyElement(w.output,"br");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2639
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2640
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2641
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2642
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2643
	name: "rawText",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2644
	match: "\\\"{3}|<nowiki>",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2645
	lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2646
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2647
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2648
		this.lookaheadRegExp.lastIndex = w.matchStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2649
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2650
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2651
			createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2652
			w.nextMatch = this.lookaheadRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2653
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2654
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2655
},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2656
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2657
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2658
	name: "htmlEntitiesEncoding",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2659
	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};)",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2660
	handler: function(w)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2661
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2662
		createTiddlyElement(w.output,"span").innerHTML = w.matchText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2663
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2664
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2665
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2666
];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2667
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2668
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2669
//-- Wikifier
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2670
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2671
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2672
function getParser(tiddler,format)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2673
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2674
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2675
		if(!format)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2676
			format = tiddler.fields["wikiformat"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2677
		var i;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2678
		if(format) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2679
			for(i in config.parsers) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2680
				if(format == config.parsers[i].format)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2681
					return config.parsers[i];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2682
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2683
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2684
			for(i in config.parsers) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2685
				if(tiddler.isTagged(config.parsers[i].formatTag))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2686
					return config.parsers[i];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2687
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2688
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2689
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2690
	return formatter;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2691
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2692
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2693
function wikify(source,output,highlightRegExp,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2694
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2695
	if(source && source != "") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2696
		var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2697
		wikifier.subWikify(output);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2698
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2699
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2700
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2701
function wikifyStatic(source,highlightRegExp,tiddler,format)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2702
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2703
	var e = createTiddlyElement(document.body,"pre");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2704
	e.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2705
	var html = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2706
	if(source && source != "") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2707
		if(!tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2708
			tiddler = new Tiddler("temp");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2709
		var wikifier = new Wikifier(source,getParser(tiddler,format),highlightRegExp,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2710
		wikifier.isStatic = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2711
		wikifier.subWikify(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2712
		html = e.innerHTML;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2713
		removeNode(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2714
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2715
	return html;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2716
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2717
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2718
function wikifyPlain(title,theStore,limit)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2719
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2720
	if(!theStore)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2721
		theStore = store;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2722
	if(theStore.tiddlerExists(title) || theStore.isShadowTiddler(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2723
		return wikifyPlainText(theStore.getTiddlerText(title),limit,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2724
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2725
		return "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2726
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2727
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2728
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2729
function wikifyPlainText(text,limit,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2730
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2731
	if(limit > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2732
		text = text.substr(0,limit);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2733
	var wikifier = new Wikifier(text,formatter,null,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2734
	return wikifier.wikifyPlain();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2735
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2736
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2737
function highlightify(source,output,highlightRegExp,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2738
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2739
	if(source && source != "") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2740
		var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2741
		wikifier.outputText(output,0,source.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2742
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2743
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2744
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2745
function Wikifier(source,formatter,highlightRegExp,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2746
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2747
	this.source = source;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2748
	this.output = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2749
	this.formatter = formatter;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2750
	this.nextMatch = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2751
	this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2752
	this.highlightRegExp = highlightRegExp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2753
	this.highlightMatch = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2754
	this.isStatic = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2755
	if(highlightRegExp) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2756
		highlightRegExp.lastIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2757
		this.highlightMatch = highlightRegExp.exec(source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2758
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2759
	this.tiddler = tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2760
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2761
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2762
Wikifier.prototype.wikifyPlain = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2763
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2764
	var e = createTiddlyElement(document.body,"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2765
	e.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2766
	this.subWikify(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2767
	var text = getPlainText(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2768
	removeNode(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2769
	return text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2770
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2771
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2772
Wikifier.prototype.subWikify = function(output,terminator)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2773
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2774
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2775
		if(terminator)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2776
			this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2777
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2778
			this.subWikifyUnterm(output);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2779
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2780
		showException(ex);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2781
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2782
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2783
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2784
Wikifier.prototype.subWikifyUnterm = function(output)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2785
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2786
	var oldOutput = this.output;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2787
	this.output = output;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2788
	this.formatter.formatterRegExp.lastIndex = this.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2789
	var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2790
	while(formatterMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2791
		// Output any text before the match
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2792
		if(formatterMatch.index > this.nextMatch)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2793
			this.outputText(this.output,this.nextMatch,formatterMatch.index);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2794
		// Set the match parameters for the handler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2795
		this.matchStart = formatterMatch.index;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2796
		this.matchLength = formatterMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2797
		this.matchText = formatterMatch[0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2798
		this.nextMatch = this.formatter.formatterRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2799
		for(var t=1; t<formatterMatch.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2800
			if(formatterMatch[t]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2801
				this.formatter.formatters[t-1].handler(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2802
				this.formatter.formatterRegExp.lastIndex = this.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2803
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2804
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2805
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2806
		formatterMatch = this.formatter.formatterRegExp.exec(this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2807
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2808
	if(this.nextMatch < this.source.length) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2809
		this.outputText(this.output,this.nextMatch,this.source.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2810
		this.nextMatch = this.source.length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2811
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2812
	this.output = oldOutput;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2813
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2814
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2815
Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2816
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2817
	var oldOutput = this.output;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2818
	this.output = output;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2819
	terminatorRegExp.lastIndex = this.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2820
	var terminatorMatch = terminatorRegExp.exec(this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2821
	this.formatter.formatterRegExp.lastIndex = this.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2822
	var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2823
	while(terminatorMatch || formatterMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2824
		if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2825
			if(terminatorMatch.index > this.nextMatch)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2826
				this.outputText(this.output,this.nextMatch,terminatorMatch.index);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2827
			this.matchText = terminatorMatch[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2828
			this.matchLength = terminatorMatch[1].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2829
			this.matchStart = terminatorMatch.index;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2830
			this.nextMatch = this.matchStart + this.matchLength;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2831
			this.output = oldOutput;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2832
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2833
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2834
		if(formatterMatch.index > this.nextMatch)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2835
			this.outputText(this.output,this.nextMatch,formatterMatch.index);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2836
		this.matchStart = formatterMatch.index;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2837
		this.matchLength = formatterMatch[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2838
		this.matchText = formatterMatch[0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2839
		this.nextMatch = this.formatter.formatterRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2840
		for(var t=1; t<formatterMatch.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2841
			if(formatterMatch[t]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2842
				this.formatter.formatters[t-1].handler(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2843
				this.formatter.formatterRegExp.lastIndex = this.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2844
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2845
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2846
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2847
		terminatorRegExp.lastIndex = this.nextMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2848
		terminatorMatch = terminatorRegExp.exec(this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2849
		formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2850
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2851
	if(this.nextMatch < this.source.length) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2852
		this.outputText(this.output,this.nextMatch,this.source.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2853
		this.nextMatch = this.source.length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2854
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2855
	this.output = oldOutput;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2856
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2857
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2858
Wikifier.prototype.outputText = function(place,startPos,endPos)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2859
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2860
	while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2861
		if(this.highlightMatch.index > startPos) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2862
			createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2863
			startPos = this.highlightMatch.index;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2864
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2865
		var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2866
		var theHighlight = createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2867
		startPos = highlightEnd;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2868
		if(startPos >= this.highlightRegExp.lastIndex)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2869
			this.highlightMatch = this.highlightRegExp.exec(this.source);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2870
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2871
	if(startPos < endPos) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2872
		createTiddlyText(place,this.source.substring(startPos,endPos));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2873
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2874
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2875
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2876
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2877
//-- Macro definitions
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2878
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2879
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2880
config.macros.today.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2881
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2882
	var now = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2883
	var text = params[0] ? now.formatString(params[0].trim()) : now.toLocaleString();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2884
	createTiddlyElement(place,"span",null,null,text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2885
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2886
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2887
config.macros.version.handler = function(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2888
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2889
	createTiddlyElement(place,"span",null,null,formatVersion());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2890
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2891
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2892
config.macros.list.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2893
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2894
	var type = params[0] ? params[0] : "all";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2895
	var list = document.createElement("ul");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2896
	place.appendChild(list);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2897
	if(this[type].prompt)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2898
		createTiddlyElement(list,"li",null,"listTitle",this[type].prompt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2899
	var results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2900
	if(this[type].handler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2901
		results = this[type].handler(params);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2902
	for(var t = 0; t < results.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2903
		var li = document.createElement("li");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2904
		list.appendChild(li);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2905
		createTiddlyLink(li,typeof results[t] == "string" ? results[t] : results[t].title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2906
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2907
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2908
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2909
config.macros.list.all.handler = function(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2910
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2911
	return store.reverseLookup("tags","excludeLists",false,"title");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2912
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2913
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2914
config.macros.list.missing.handler = function(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2915
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2916
	return store.getMissingLinks();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2917
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2918
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2919
config.macros.list.orphans.handler = function(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2920
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2921
	return store.getOrphans();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2922
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2923
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2924
config.macros.list.shadowed.handler = function(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2925
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2926
	return store.getShadowed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2927
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2928
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2929
config.macros.list.touched.handler = function(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2930
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2931
	return store.getTouched();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2932
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2933
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2934
config.macros.list.filter.handler = function(params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2935
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2936
	var filter = params[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2937
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2938
	if(filter) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2939
		var tiddlers = store.filterTiddlers(filter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2940
		for(var t=0; t<tiddlers.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2941
			results.push(tiddlers[t].title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2942
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2943
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2944
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2945
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2946
config.macros.allTags.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2947
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2948
	var tags = store.getTags(params[0]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2949
	var ul = createTiddlyElement(place,"ul");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2950
	if(tags.length == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2951
		createTiddlyElement(ul,"li",null,"listTitle",this.noTags);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2952
	for(var t=0; t<tags.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2953
		var title = tags[t][0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2954
		var info = getTiddlyLinkInfo(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2955
		var li = createTiddlyElement(ul,"li");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2956
		var btn = createTiddlyButton(li,title + " (" + tags[t][1] + ")",this.tooltip.format([title]),onClickTag,info.classes);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2957
		btn.setAttribute("tag",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2958
		btn.setAttribute("refresh","link");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2959
		btn.setAttribute("tiddlyLink",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2960
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2961
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2962
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2963
config.macros.timeline.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2964
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2965
	var field = params[0] ? params[0] : "modified";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2966
	var tiddlers = store.reverseLookup("tags","excludeLists",false,field);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2967
	var lastDay = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2968
	var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1])) : 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2969
	var dateFormat = params[2] ? params[2] : this.dateFormat;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2970
	for(var t=tiddlers.length-1; t>=last; t--) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2971
		var tiddler = tiddlers[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2972
		var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2973
		if(theDay != lastDay) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2974
			var ul = document.createElement("ul");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2975
			place.appendChild(ul);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2976
			createTiddlyElement(ul,"li",null,"listTitle",tiddler[field].formatString(dateFormat));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2977
			lastDay = theDay;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2978
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2979
		createTiddlyElement(ul,"li",null,"listLink").appendChild(createTiddlyLink(place,tiddler.title,true));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2980
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2981
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2982
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2983
config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2984
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2985
	params = paramString.parseParams("name",null,true,false,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2986
	var names = params[0]["name"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2987
	var tiddlerName = names[0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2988
	var className = names[1] ? names[1] : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2989
	var args = params[0]["with"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2990
	var wrapper = createTiddlyElement(place,"span",null,className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2991
	if(!args) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2992
		wrapper.setAttribute("refresh","content");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2993
		wrapper.setAttribute("tiddler",tiddlerName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2994
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2995
	var text = store.getTiddlerText(tiddlerName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2996
	if(text) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2997
		var stack = config.macros.tiddler.tiddlerStack;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2998
		if(stack.indexOf(tiddlerName) !== -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  2999
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3000
		stack.push(tiddlerName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3001
		try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3002
			var n = args ? Math.min(args.length,9) : 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3003
			for(var i=0; i<n; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3004
				var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3005
				text = text.replace(placeholderRE,args[i]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3006
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3007
			config.macros.tiddler.renderText(wrapper,text,tiddlerName,params);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3008
		} finally {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3009
			stack.pop();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3010
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3011
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3012
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3013
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3014
config.macros.tiddler.renderText = function(place,text,tiddlerName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3015
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3016
	wikify(text,place,null,store.getTiddler(tiddlerName));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3017
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3018
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3019
config.macros.tiddler.tiddlerStack = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3020
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3021
config.macros.tag.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3022
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3023
	createTagButton(place,params[0],null,params[1],params[2]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3024
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3025
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3026
config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3027
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3028
	params = paramString.parseParams("anon",null,true,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3029
	var ul = createTiddlyElement(place,"ul");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3030
	var title = getParam(params,"anon","");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3031
	if(title && store.tiddlerExists(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3032
		tiddler = store.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3033
	var sep = getParam(params,"sep"," ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3034
	var lingo = config.views.wikified.tag;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3035
	var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3036
	createTiddlyElement(ul,"li",null,"listTitle",prompt.format([tiddler.title]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3037
	for(var t=0; t<tiddler.tags.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3038
		createTagButton(createTiddlyElement(ul,"li"),tiddler.tags[t],tiddler.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3039
		if(t<tiddler.tags.length-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3040
			createTiddlyText(ul,sep);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3041
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3042
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3043
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3044
config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3045
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3046
	params = paramString.parseParams("anon",null,true,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3047
	var ul = createTiddlyElement(place,"ul");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3048
	var title = getParam(params,"anon","");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3049
	if(title == "" && tiddler instanceof Tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3050
		title = tiddler.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3051
	var sep = getParam(params,"sep"," ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3052
	ul.setAttribute("title",this.tooltip.format([title]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3053
	var tagged = store.getTaggedTiddlers(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3054
	var prompt = tagged.length == 0 ? this.labelNotTag : this.label;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3055
	createTiddlyElement(ul,"li",null,"listTitle",prompt.format([title,tagged.length]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3056
	for(var t=0; t<tagged.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3057
		createTiddlyLink(createTiddlyElement(ul,"li"),tagged[t].title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3058
		if(t<tagged.length-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3059
			createTiddlyText(ul,sep);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3060
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3061
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3062
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3063
config.macros.closeAll.handler = function(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3064
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3065
	createTiddlyButton(place,this.label,this.prompt,this.onClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3066
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3067
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3068
config.macros.closeAll.onClick = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3069
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3070
	story.closeAllTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3071
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3072
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3073
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3074
config.macros.permaview.handler = function(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3075
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3076
	createTiddlyButton(place,this.label,this.prompt,this.onClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3077
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3078
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3079
config.macros.permaview.onClick = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3080
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3081
	story.permaView();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3082
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3083
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3084
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3085
config.macros.saveChanges.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3086
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3087
	if(!readOnly)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3088
		createTiddlyButton(place,params[0] || this.label,params[1] || this.prompt,this.onClick,null,null,this.accessKey);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3089
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3090
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3091
config.macros.saveChanges.onClick = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3092
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3093
	saveChanges();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3094
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3095
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3096
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3097
config.macros.slider.onClickSlider = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3098
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3099
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3100
	var n = this.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3101
	var cookie = n.getAttribute("cookie");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3102
	var isOpen = n.style.display != "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3103
	if(config.options.chkAnimate && anim && typeof Slider == "function")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3104
		anim.startAnimating(new Slider(n,!isOpen,null,"none"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3105
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3106
		n.style.display = isOpen ? "none" : "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3107
	config.options[cookie] = !isOpen;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3108
	saveOptionCookie(cookie);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3109
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3110
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3111
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3112
config.macros.slider.createSlider = function(place,cookie,title,tooltip)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3113
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3114
	var c = cookie ? cookie : "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3115
	var btn = createTiddlyButton(place,title,tooltip,this.onClickSlider);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3116
	var panel = createTiddlyElement(null,"div",null,"sliderPanel");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3117
	panel.setAttribute("cookie",c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3118
	panel.style.display = config.options[c] ? "block" : "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3119
	place.appendChild(panel);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3120
	return panel;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3121
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3122
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3123
config.macros.slider.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3124
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3125
	var panel = this.createSlider(place,params[0],params[2],params[3]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3126
	var text = store.getTiddlerText(params[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3127
	panel.setAttribute("refresh","content");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3128
	panel.setAttribute("tiddler",params[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3129
	if(text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3130
		wikify(text,panel,null,store.getTiddler(params[1]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3131
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3132
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3133
// <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3134
config.macros.gradient.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3135
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3136
	var panel = wikifier ? createTiddlyElement(place,"div",null,"gradient") : place;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3137
	panel.style.position = "relative";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3138
	panel.style.overflow = "hidden";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3139
	panel.style.zIndex = "0";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3140
	if(wikifier) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3141
		var styles = config.formatterHelpers.inlineCssHelper(wikifier);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3142
		config.formatterHelpers.applyCssHelper(panel,styles);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3143
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3144
	params = paramString.parseParams("color");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3145
	var locolors = [], hicolors = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3146
	for(var t=2; t<params.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3147
		var c = new RGB(params[t].value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3148
		if(params[t].name == "snap") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3149
			hicolors[hicolors.length-1] = c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3150
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3151
			locolors.push(c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3152
			hicolors.push(c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3153
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3154
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3155
	drawGradient(panel,params[1].value != "vert",locolors,hicolors);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3156
	if(wikifier)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3157
		wikifier.subWikify(panel,">>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3158
	if(document.all) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3159
		panel.style.height = "100%";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3160
		panel.style.width = "100%";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3161
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3162
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3163
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3164
config.macros.message.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3165
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3166
	if(params[0]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3167
		var names = params[0].split(".");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3168
		var lookupMessage = function(root,nameIndex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3169
				if(names[nameIndex] in root) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3170
					if(nameIndex < names.length-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3171
						return (lookupMessage(root[names[nameIndex]],nameIndex+1));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3172
					else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3173
						return root[names[nameIndex]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3174
				} else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3175
					return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3176
			};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3177
		var m = lookupMessage(config,0);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3178
		if(m == null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3179
			m = lookupMessage(window,0);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3180
		createTiddlyText(place,m.toString().format(params.splice(1)));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3181
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3182
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3183
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3184
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3185
config.macros.view.views = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3186
	text: function(value,place,params,wikifier,paramString,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3187
		highlightify(value,place,highlightHack,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3188
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3189
	link: function(value,place,params,wikifier,paramString,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3190
		createTiddlyLink(place,value,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3191
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3192
	wikified: function(value,place,params,wikifier,paramString,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3193
		if(params[2])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3194
			value=params[2].unescapeLineBreaks().format([value]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3195
		wikify(value,place,highlightHack,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3196
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3197
	date: function(value,place,params,wikifier,paramString,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3198
		value = Date.convertFromYYYYMMDDHHMM(value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3199
		createTiddlyText(place,value.formatString(params[2] ? params[2] : config.views.wikified.dateFormat));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3200
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3201
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3202
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3203
config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3204
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3205
	if((tiddler instanceof Tiddler) && params[0]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3206
		var value = store.getValue(tiddler,params[0]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3207
		if(value) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3208
			var type = params[1] ? params[1] : config.macros.view.defaultView;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3209
			var handler = config.macros.view.views[type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3210
			if(handler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3211
				handler(value,place,params,wikifier,paramString,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3212
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3213
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3214
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3215
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3216
config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3217
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3218
	var field = params[0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3219
	var rows = params[1] || 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3220
	var defVal = params[2] || '';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3221
	if((tiddler instanceof Tiddler) && field) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3222
		story.setDirty(tiddler.title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3223
		var e,v;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3224
		if(field != "text" && !rows) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3225
			e = createTiddlyElement(null,"input");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3226
			if(tiddler.isReadOnly())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3227
				e.setAttribute("readOnly","readOnly");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3228
			e.setAttribute("edit",field);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3229
			e.setAttribute("type","text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3230
			e.value = store.getValue(tiddler,field) || defVal;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3231
			e.setAttribute("size","40");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3232
			e.setAttribute("autocomplete","off");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3233
			place.appendChild(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3234
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3235
			var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3236
			var wrapper2 = createTiddlyElement(wrapper1,"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3237
			e = createTiddlyElement(wrapper2,"textarea");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3238
			if(tiddler.isReadOnly())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3239
				e.setAttribute("readOnly","readOnly");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3240
			e.value = v = store.getValue(tiddler,field) || defVal;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3241
			rows = rows ? rows : 10;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3242
			var lines = v.match(/\n/mg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3243
			var maxLines = Math.max(parseInt(config.options.txtMaxEditRows),5);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3244
			if(lines != null && lines.length > rows)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3245
				rows = lines.length + 5;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3246
			rows = Math.min(rows,maxLines);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3247
			e.setAttribute("rows",rows);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3248
			e.setAttribute("edit",field);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3249
			place.appendChild(wrapper1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3250
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3251
		return e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3252
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3253
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3254
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3255
config.macros.tagChooser.onClick = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3256
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3257
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3258
	if(e.metaKey || e.ctrlKey) stopEvent(e); //# keep popup open on CTRL-click
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3259
	var lingo = config.views.editor.tagChooser;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3260
	var popup = Popup.create(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3261
	var tags = store.getTags();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3262
	if(tags.length == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3263
		createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3264
	for(var t=0; t<tags.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3265
		var tag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3266
		tag.setAttribute("tag",tags[t][0]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3267
		tag.setAttribute("tiddler",this.getAttribute("tiddler"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3268
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3269
	Popup.show();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3270
	e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3271
	if(e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3272
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3273
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3274
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3275
config.macros.tagChooser.onTagClick = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3276
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3277
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3278
	var tag = this.getAttribute("tag");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3279
	var title = this.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3280
	if(!readOnly)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3281
		story.setTiddlerTag(title,tag,0);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3282
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3283
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3284
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3285
config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3286
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3287
	if(tiddler instanceof Tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3288
		var lingo = config.views.editor.tagChooser;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3289
		var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3290
		btn.setAttribute("tiddler",tiddler.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3291
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3292
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3293
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3294
config.macros.refreshDisplay.handler = function(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3295
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3296
	createTiddlyButton(place,this.label,this.prompt,this.onClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3297
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3298
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3299
config.macros.refreshDisplay.onClick = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3300
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3301
	refreshAll();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3302
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3303
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3304
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3305
config.macros.annotations.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3306
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3307
	var title = tiddler ? tiddler.title : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3308
	var a = title ? config.annotations[title] : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3309
	if(!tiddler || !title || !a)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3310
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3311
	var text = a.format([title]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3312
	wikify(text,createTiddlyElement(place,"div",null,"annotation"),null,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3313
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3314
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3315
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3316
//-- NewTiddler and NewJournal macros
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3317
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3318
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3319
config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3320
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3321
	var tags = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3322
	for(var t=1; t<params.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3323
		if((params[t].name == "anon" && t != 1) || (params[t].name == "tag"))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3324
			tags.push(params[t].value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3325
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3326
	label = getParam(params,"label",label);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3327
	prompt = getParam(params,"prompt",prompt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3328
	accessKey = getParam(params,"accessKey",accessKey);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3329
	newFocus = getParam(params,"focus",newFocus);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3330
	var customFields = getParam(params,"fields","");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3331
	if(!customFields && !store.isShadowTiddler(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3332
		customFields = String.encodeHashMap(config.defaultCustomFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3333
	var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3334
	btn.setAttribute("newTitle",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3335
	btn.setAttribute("isJournal",isJournal ? "true" : "false");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3336
	if(tags.length > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3337
		btn.setAttribute("params",tags.join("|"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3338
	btn.setAttribute("newFocus",newFocus);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3339
	btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3340
	if(customFields !== "")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3341
		btn.setAttribute("customFields",customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3342
	var text = getParam(params,"text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3343
	if(text !== undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3344
		btn.setAttribute("newText",text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3345
	return btn;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3346
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3347
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3348
config.macros.newTiddler.onClickNewTiddler = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3349
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3350
	var title = this.getAttribute("newTitle");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3351
	if(this.getAttribute("isJournal") == "true") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3352
		var now = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3353
		title = now.formatString(title.trim());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3354
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3355
	var params = this.getAttribute("params");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3356
	var tags = params ? params.split("|") : [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3357
	var focus = this.getAttribute("newFocus");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3358
	var template = this.getAttribute("newTemplate");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3359
	var customFields = this.getAttribute("customFields");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3360
	story.displayTiddler(null,title,template,false,null,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3361
	var tiddlerElem = story.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3362
	if(customFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3363
		story.addCustomFields(tiddlerElem,customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3364
	var text = this.getAttribute("newText");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3365
	if(typeof text == "string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3366
		story.getTiddlerField(title,"text").value = text.format([title]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3367
	for(var t=0;t<tags.length;t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3368
		story.setTiddlerTag(title,tags[t],+1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3369
	story.focusTiddler(title,focus);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3370
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3371
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3372
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3373
config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3374
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3375
	if(!readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3376
		params = paramString.parseParams("anon",null,true,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3377
		var title = params[1] && params[1].name == "anon" ? params[1].value : this.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3378
		title = getParam(params,"title",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3379
		this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3380
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3381
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3382
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3383
config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3384
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3385
	if(!readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3386
		params = paramString.parseParams("anon",null,true,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3387
		var title = params[1] && params[1].name == "anon" ? params[1].value : config.macros.timeline.dateFormat;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3388
		title = getParam(params,"title",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3389
		config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3390
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3391
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3392
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3393
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3394
//-- Search macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3395
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3396
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3397
config.macros.search.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3398
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3399
	var searchTimeout = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3400
	var btn = createTiddlyButton(place,this.label,this.prompt,this.onClick,"searchButton");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3401
	var txt = createTiddlyElement(place,"input",null,"txtOptionInput searchField");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3402
	if(params[0])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3403
		txt.value = params[0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3404
	txt.onkeyup = this.onKeyPress;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3405
	txt.onfocus = this.onFocus;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3406
	txt.setAttribute("size",this.sizeTextbox);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3407
	txt.setAttribute("accessKey",this.accessKey);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3408
	txt.setAttribute("autocomplete","off");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3409
	txt.setAttribute("lastSearchText","");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3410
	if(config.browser.isSafari) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3411
		txt.setAttribute("type","search");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3412
		txt.setAttribute("results","5");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3413
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3414
		txt.setAttribute("type","text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3415
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3416
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3417
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3418
// Global because there's only ever one outstanding incremental search timer
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3419
config.macros.search.timeout = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3420
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3421
config.macros.search.doSearch = function(txt)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3422
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3423
	if(txt.value.length > 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3424
		story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3425
		txt.setAttribute("lastSearchText",txt.value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3426
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3427
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3428
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3429
config.macros.search.onClick = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3430
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3431
	config.macros.search.doSearch(this.nextSibling);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3432
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3433
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3434
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3435
config.macros.search.onKeyPress = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3436
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3437
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3438
	switch(e.keyCode) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3439
		case 13: // Ctrl-Enter
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3440
		case 10: // Ctrl-Enter on IE PC
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3441
			config.macros.search.doSearch(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3442
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3443
		case 27: // Escape
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3444
			this.value = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3445
			clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3446
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3447
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3448
	if(config.options.chkIncrementalSearch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3449
		if(this.value.length > 2) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3450
			if(this.value != this.getAttribute("lastSearchText")) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3451
				if(config.macros.search.timeout)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3452
					clearTimeout(config.macros.search.timeout);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3453
				var txt = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3454
				config.macros.search.timeout = setTimeout(function() {config.macros.search.doSearch(txt);},500);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3455
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3456
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3457
			if(config.macros.search.timeout)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3458
				clearTimeout(config.macros.search.timeout);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3459
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3460
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3461
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3462
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3463
config.macros.search.onFocus = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3464
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3465
	this.select();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3466
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3467
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3468
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3469
//-- Tabs macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3470
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3471
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3472
config.macros.tabs.handler = function(place,macroName,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3473
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3474
	var cookie = params[0];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3475
	var numTabs = (params.length-1)/3;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3476
	var wrapper = createTiddlyElement(null,"div",null,"tabsetWrapper " + cookie);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3477
	var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3478
	tabset.setAttribute("cookie",cookie);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3479
	var validTab = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3480
	for(var t=0; t<numTabs; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3481
		var label = params[t*3+1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3482
		var prompt = params[t*3+2];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3483
		var content = params[t*3+3];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3484
		var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3485
		tab.setAttribute("tab",label);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3486
		tab.setAttribute("content",content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3487
		tab.title = prompt;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3488
		if(config.options[cookie] == label)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3489
			validTab = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3490
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3491
	if(!validTab)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3492
		config.options[cookie] = params[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3493
	place.appendChild(wrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3494
	this.switchTab(tabset,config.options[cookie]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3495
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3496
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3497
config.macros.tabs.onClickTab = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3498
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3499
	config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3500
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3501
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3502
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3503
config.macros.tabs.switchTab = function(tabset,tab)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3504
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3505
	var cookie = tabset.getAttribute("cookie");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3506
	var theTab = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3507
	var nodes = tabset.childNodes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3508
	for(var t=0; t<nodes.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3509
		if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3510
			theTab = nodes[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3511
			theTab.className = "tab tabSelected";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3512
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3513
			nodes[t].className = "tab tabUnselected";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3514
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3515
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3516
	if(theTab) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3517
		if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3518
			removeNode(tabset.nextSibling);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3519
		var tabContent = createTiddlyElement(null,"div",null,"tabContents");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3520
		tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3521
		var contentTitle = theTab.getAttribute("content");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3522
		wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3523
		if(cookie) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3524
			config.options[cookie] = tab;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3525
			saveOptionCookie(cookie);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3526
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3527
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3528
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3529
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3530
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3531
//-- Tiddler toolbar
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3532
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3533
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3534
// Create a toolbar command button
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3535
config.macros.toolbar.createCommand = function(place,commandName,tiddler,className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3536
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3537
	if(typeof commandName != "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3538
		var c = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3539
		for(var t in config.commands) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3540
			if(config.commands[t] == commandName)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3541
				c = t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3542
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3543
		commandName = c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3544
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3545
	if((tiddler instanceof Tiddler) && (typeof commandName == "string")) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3546
		var command = config.commands[commandName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3547
		if(command.isEnabled ? command.isEnabled(tiddler) : this.isCommandEnabled(command,tiddler)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3548
			var text = command.getText ? command.getText(tiddler) : this.getCommandText(command,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3549
			var tooltip = command.getTooltip ? command.getTooltip(tiddler) : this.getCommandTooltip(command,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3550
			var cmd;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3551
			switch(command.type) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3552
				case "popup":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3553
					cmd = this.onClickPopup;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3554
					break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3555
				case "command":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3556
				default:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3557
					cmd = this.onClickCommand;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3558
					break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3559
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3560
			var btn = createTiddlyButton(null,text,tooltip,cmd);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3561
			btn.setAttribute("commandName",commandName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3562
			btn.setAttribute("tiddler",tiddler.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3563
			if(className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3564
				addClass(btn,className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3565
			place.appendChild(btn);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3566
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3567
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3568
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3569
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3570
config.macros.toolbar.isCommandEnabled = function(command,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3571
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3572
	var title = tiddler.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3573
	var ro = tiddler.isReadOnly();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3574
	var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3575
	return (!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3576
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3577
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3578
config.macros.toolbar.getCommandText = function(command,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3579
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3580
	return tiddler.isReadOnly() && command.readOnlyText ? command.readOnlyText : command.text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3581
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3582
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3583
config.macros.toolbar.getCommandTooltip = function(command,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3584
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3585
	return tiddler.isReadOnly() && command.readOnlyTooltip ? command.readOnlyTooltip : command.tooltip;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3586
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3587
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3588
config.macros.toolbar.onClickCommand = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3589
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3590
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3591
	e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3592
	if(e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3593
	var command = config.commands[this.getAttribute("commandName")];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3594
	return command.handler(e,this,this.getAttribute("tiddler"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3595
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3596
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3597
config.macros.toolbar.onClickPopup = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3598
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3599
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3600
	e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3601
	if(e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3602
	var popup = Popup.create(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3603
	var command = config.commands[this.getAttribute("commandName")];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3604
	var title = this.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3605
	var tiddler = store.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3606
	popup.setAttribute("tiddler",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3607
	command.handlePopup(popup,title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3608
	Popup.show();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3609
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3610
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3611
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3612
// Invoke the first command encountered from a given place that is tagged with a specified class
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3613
config.macros.toolbar.invokeCommand = function(place,className,event)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3614
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3615
	var children = place.getElementsByTagName("a");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3616
	for(var t=0; t<children.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3617
		var c = children[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3618
		if(hasClass(c,className) && c.getAttribute && c.getAttribute("commandName")) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3619
			if(c.onclick instanceof Function)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3620
				c.onclick.call(c,event);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3621
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3622
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3623
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3624
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3625
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3626
config.macros.toolbar.onClickMore = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3627
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3628
	var e = this.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3629
	e.style.display = "inline";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3630
	removeNode(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3631
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3632
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3633
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3634
config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3635
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3636
	for(var t=0; t<params.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3637
		var c = params[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3638
		switch(c) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3639
			case '>':
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3640
				var btn = createTiddlyButton(place,this.moreLabel,this.morePrompt,config.macros.toolbar.onClickMore);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3641
				addClass(btn,"moreCommand");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3642
				var e = createTiddlyElement(place,"span",null,"moreCommand");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3643
				e.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3644
				place = e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3645
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3646
			default:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3647
				var className = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3648
				switch(c.substr(0,1)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3649
					case "+":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3650
						className = "defaultCommand";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3651
						c = c.substr(1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3652
						break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3653
					case "-":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3654
						className = "cancelCommand";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3655
						c = c.substr(1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3656
						break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3657
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3658
				if(c in config.commands)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3659
					this.createCommand(place,c,tiddler,className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3660
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3661
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3662
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3663
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3664
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3665
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3666
//-- Menu and toolbar commands
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3667
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3668
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3669
config.commands.closeTiddler.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3670
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3671
	if(story.isDirty(title) && !readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3672
		if(!confirm(config.commands.cancelTiddler.warning.format([title])))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3673
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3674
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3675
	story.setDirty(title,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3676
	story.closeTiddler(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3677
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3678
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3679
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3680
config.commands.closeOthers.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3681
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3682
	story.closeAllTiddlers(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3683
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3684
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3685
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3686
config.commands.editTiddler.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3687
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3688
	clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3689
	var tiddlerElem = story.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3690
	var fields = tiddlerElem.getAttribute("tiddlyFields");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3691
	story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3692
	story.focusTiddler(title,config.options.txtEditorFocus||"text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3693
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3694
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3695
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3696
config.commands.saveTiddler.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3697
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3698
	var newTitle = story.saveTiddler(title,event.shiftKey);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3699
	if(newTitle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3700
		story.displayTiddler(null,newTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3701
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3702
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3703
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3704
config.commands.cancelTiddler.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3705
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3706
	if(story.hasChanges(title) && !readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3707
		if(!confirm(this.warning.format([title])))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3708
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3709
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3710
	story.setDirty(title,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3711
	story.displayTiddler(null,title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3712
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3713
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3714
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3715
config.commands.deleteTiddler.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3716
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3717
	var deleteIt = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3718
	if(config.options.chkConfirmDelete)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3719
		deleteIt = confirm(this.warning.format([title]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3720
	if(deleteIt) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3721
		store.removeTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3722
		story.closeTiddler(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3723
		autoSaveChanges();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3724
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3725
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3726
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3727
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3728
config.commands.permalink.handler = function(event,src,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3729
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3730
	var t = encodeURIComponent(String.encodeTiddlyLink(title));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3731
	if(window.location.hash != t)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3732
		window.location.hash = t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3733
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3734
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3735
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3736
config.commands.references.handlePopup = function(popup,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3737
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3738
	var references = store.getReferringTiddlers(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3739
	var c = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3740
	for(var r=0; r<references.length; r++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3741
		if(references[r].title != title && !references[r].isTagged("excludeLists")) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3742
			createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3743
			c = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3744
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3745
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3746
	if(!c)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3747
		createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),this.popupNone);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3748
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3749
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3750
config.commands.jump.handlePopup = function(popup,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3751
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3752
	story.forEachTiddler(function(title,element) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3753
		createTiddlyLink(createTiddlyElement(popup,"li"),title,true,null,false,null,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3754
		});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3755
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3756
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3757
config.commands.syncing.handlePopup = function(popup,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3758
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3759
	var tiddler = store.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3760
	if(!tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3761
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3762
	var serverType = tiddler.getServerType();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3763
	var serverHost = tiddler.fields['server.host'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3764
	var serverWorkspace = tiddler.fields['server.workspace'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3765
	if(!serverWorkspace)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3766
		serverWorkspace = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3767
	if(serverType) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3768
		var e = createTiddlyElement(popup,"li",null,"popupMessage");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3769
		e.innerHTML = config.commands.syncing.currentlySyncing.format([serverType,serverHost,serverWorkspace]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3770
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3771
		createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.notCurrentlySyncing);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3772
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3773
	if(serverType) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3774
		createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3775
		var btn = createTiddlyButton(createTiddlyElement(popup,"li"),this.captionUnSync,null,config.commands.syncing.onChooseServer);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3776
		btn.setAttribute("tiddler",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3777
		btn.setAttribute("server.type","");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3778
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3779
	createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3780
	createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.chooseServer);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3781
	var feeds = store.getTaggedTiddlers("systemServer","title");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3782
	for(var t=0; t<feeds.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3783
		var f = feeds[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3784
		var feedServerType = store.getTiddlerSlice(f.title,"Type");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3785
		if(!feedServerType)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3786
			feedServerType = "file";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3787
		var feedServerHost = store.getTiddlerSlice(f.title,"URL");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3788
		if(!feedServerHost)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3789
			feedServerHost = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3790
		var feedServerWorkspace = store.getTiddlerSlice(f.title,"Workspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3791
		if(!feedServerWorkspace)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3792
			feedServerWorkspace = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3793
		var caption = f.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3794
		if(serverType == feedServerType && serverHost == feedServerHost && serverWorkspace == feedServerWorkspace) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3795
			caption = config.commands.syncing.currServerMarker + caption;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3796
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3797
			caption = config.commands.syncing.notCurrServerMarker + caption;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3798
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3799
		btn = createTiddlyButton(createTiddlyElement(popup,"li"),caption,null,config.commands.syncing.onChooseServer);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3800
		btn.setAttribute("tiddler",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3801
		btn.setAttribute("server.type",feedServerType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3802
		btn.setAttribute("server.host",feedServerHost);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3803
		btn.setAttribute("server.workspace",feedServerWorkspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3804
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3805
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3806
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3807
config.commands.syncing.onChooseServer = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3808
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3809
	var tiddler = this.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3810
	var serverType = this.getAttribute("server.type");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3811
	if(serverType) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3812
		store.addTiddlerFields(tiddler,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3813
			'server.type': serverType,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3814
			'server.host': this.getAttribute("server.host"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3815
			'server.workspace': this.getAttribute("server.workspace")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3816
			});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3817
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3818
		store.setValue(tiddler,'server',null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3819
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3820
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3821
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3822
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3823
config.commands.fields.handlePopup = function(popup,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3824
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3825
	var tiddler = store.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3826
	if(!tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3827
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3828
	var fields = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3829
	store.forEachField(tiddler,function(tiddler,fieldName,value) {fields[fieldName] = value;},true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3830
	var items = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3831
	for(var t in fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3832
		items.push({field: t,value: fields[t]});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3833
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3834
	items.sort(function(a,b) {return a.field < b.field ? -1 : (a.field == b.field ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3835
	if(items.length > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3836
		ListView.create(popup,items,this.listViewTemplate);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3837
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3838
		createTiddlyElement(popup,"div",null,null,this.emptyText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3839
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3840
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3841
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3842
//-- Tiddler() object
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3843
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3844
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3845
function Tiddler(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3846
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3847
	this.title = title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3848
	this.text = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3849
	this.modifier = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3850
	this.created = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3851
	this.modified = this.created;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3852
	this.links = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3853
	this.linksUpdated = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3854
	this.tags = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3855
	this.fields = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3856
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3857
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3858
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3859
Tiddler.prototype.getLinks = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3860
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3861
	if(this.linksUpdated==false)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3862
		this.changed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3863
	return this.links;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3864
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3865
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3866
// Returns the fields that are inherited in string field:"value" field2:"value2" format
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3867
Tiddler.prototype.getInheritedFields = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3868
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3869
	var f = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3870
	for(i in this.fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3871
		if(i=="server.host" || i=="server.workspace" || i=="wikiformat"|| i=="server.type") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3872
			f[i] = this.fields[i];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3873
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3874
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3875
	return String.encodeHashMap(f);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3876
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3877
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3878
// Increment the changeCount of a tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3879
Tiddler.prototype.incChangeCount = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3880
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3881
	var c = this.fields['changecount'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3882
	c = c ? parseInt(c) : 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3883
	this.fields['changecount'] = String(c+1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3884
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3885
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3886
// Clear the changeCount of a tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3887
Tiddler.prototype.clearChangeCount = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3888
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3889
	if(this.fields['changecount']) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3890
		delete this.fields['changecount'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3891
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3892
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3893
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3894
Tiddler.prototype.doNotSave = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3895
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3896
	return this.fields['doNotSave'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3897
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3898
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3899
// Returns true if the tiddler has been updated since the tiddler was created or downloaded
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3900
Tiddler.prototype.isTouched = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3901
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3902
	var changeCount = this.fields['changecount'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3903
	if(changeCount === undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3904
		changeCount = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3905
	return changeCount > 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3906
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3907
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3908
// Return the tiddler as an RSS item
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3909
Tiddler.prototype.toRssItem = function(uri)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3910
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3911
	var s = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3912
	s.push("<title" + ">" + this.title.htmlEncode() + "</title" + ">");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3913
	s.push("<description>" + wikifyStatic(this.text,null,this).htmlEncode() + "</description>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3914
	for(var t=0; t<this.tags.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3915
		s.push("<category>" + this.tags[t] + "</category>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3916
	s.push("<link>" + uri + "#" + encodeURIComponent(String.encodeTiddlyLink(this.title)) + "</link>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3917
	s.push("<pubDate>" + this.modified.toGMTString() + "</pubDate>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3918
	return s.join("\n");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3919
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3920
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3921
// Format the text for storage in an RSS item
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3922
Tiddler.prototype.saveToRss = function(uri)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3923
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3924
	return "<item>\n" + this.toRssItem(uri) + "\n</item>";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3925
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3926
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3927
// Change the text and other attributes of a tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3928
Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3929
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3930
	this.assign(title,text,modifier,modified,tags,created,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3931
	this.changed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3932
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3933
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3934
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3935
// Change the text and other attributes of a tiddler without triggered a tiddler.changed() call
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3936
Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3937
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3938
	if(title != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3939
		this.title = title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3940
	if(text != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3941
		this.text = text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3942
	if(modifier != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3943
		this.modifier = modifier;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3944
	if(modified != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3945
		this.modified = modified;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3946
	if(created != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3947
		this.created = created;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3948
	if(fields != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3949
		this.fields = fields;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3950
	if(tags != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3951
		this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3952
	else if(this.tags == undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3953
		this.tags = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3954
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3955
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3956
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3957
// Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3958
Tiddler.prototype.getTags = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3959
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3960
	return String.encodeTiddlyLinkList(this.tags);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3961
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3962
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3963
// Test if a tiddler carries a tag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3964
Tiddler.prototype.isTagged = function(tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3965
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3966
	return this.tags.indexOf(tag) != -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3967
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3968
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3969
// Static method to convert "\n" to newlines, "\s" to "\"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3970
Tiddler.unescapeLineBreaks = function(text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3971
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3972
	return text ? text.unescapeLineBreaks() : "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3973
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3974
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3975
// Convert newlines to "\n", "\" to "\s"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3976
Tiddler.prototype.escapeLineBreaks = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3977
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3978
	return this.text.escapeLineBreaks();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3979
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3980
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3981
// Updates the secondary information (like links[] array) after a change to a tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3982
Tiddler.prototype.changed = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3983
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3984
	this.links = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3985
	var t = this.autoLinkWikiWords() ? 0 : 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3986
	var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3987
	tiddlerLinkRegExp.lastIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3988
	var formatMatch = tiddlerLinkRegExp.exec(this.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3989
	while(formatMatch) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3990
		var lastIndex = tiddlerLinkRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3991
		if(t==0 && formatMatch[1] && formatMatch[1] != this.title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3992
			// wikiWordLink
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3993
			if(formatMatch.index > 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3994
				var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3995
				preRegExp.lastIndex = formatMatch.index-1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3996
				var preMatch = preRegExp.exec(this.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3997
				if(preMatch.index != formatMatch.index-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3998
					this.links.pushUnique(formatMatch[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  3999
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4000
				this.links.pushUnique(formatMatch[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4001
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4002
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4003
		else if(formatMatch[2-t] && !config.formatterHelpers.isExternalLink(formatMatch[3-t])) // titledBrackettedLink
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4004
			this.links.pushUnique(formatMatch[3-t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4005
		else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4006
			this.links.pushUnique(formatMatch[4-t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4007
		tiddlerLinkRegExp.lastIndex = lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4008
		formatMatch = tiddlerLinkRegExp.exec(this.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4009
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4010
	this.linksUpdated = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4011
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4012
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4013
Tiddler.prototype.getSubtitle = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4014
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4015
	var modifier = this.modifier;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4016
	if(!modifier)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4017
		modifier = config.messages.subtitleUnknown;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4018
	var modified = this.modified;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4019
	if(modified)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4020
		modified = modified.toLocaleString();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4021
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4022
		modified = config.messages.subtitleUnknown;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4023
	return config.messages.tiddlerLinkTooltip.format([this.title,modifier,modified]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4024
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4025
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4026
Tiddler.prototype.isReadOnly = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4027
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4028
	return readOnly;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4029
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4030
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4031
Tiddler.prototype.autoLinkWikiWords = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4032
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4033
	return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4034
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4035
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4036
Tiddler.prototype.generateFingerprint = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4037
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4038
	return "0x" + Crypto.hexSha1Str(this.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4039
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4040
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4041
Tiddler.prototype.getServerType = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4042
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4043
	var serverType = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4044
	if(this.fields && this.fields['server.type'])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4045
		serverType = this.fields['server.type'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4046
	if(!serverType)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4047
		serverType = this.fields['wikiformat'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4048
	if(serverType && !config.adaptors[serverType])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4049
		serverType = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4050
	return serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4051
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4052
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4053
Tiddler.prototype.getAdaptor = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4054
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4055
	var serverType = this.getServerType();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4056
	return serverType ? new config.adaptors[serverType] : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4057
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4058
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4059
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4060
//-- TiddlyWiki() object contains Tiddler()s
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4061
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4062
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4063
function TiddlyWiki()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4064
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4065
	var tiddlers = {}; // Hashmap by name of tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4066
	this.tiddlersUpdated = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4067
	this.namedNotifications = []; // Array of {name:,notify:} of notification functions
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4068
	this.notificationLevel = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4069
	this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4070
	this.clear = function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4071
		tiddlers = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4072
		this.setDirty(false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4073
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4074
	this.fetchTiddler = function(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4075
		var t = tiddlers[title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4076
		return t instanceof Tiddler ? t : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4077
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4078
	this.deleteTiddler = function(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4079
		delete this.slices[title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4080
		delete tiddlers[title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4081
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4082
	this.addTiddler = function(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4083
		delete this.slices[tiddler.title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4084
		tiddlers[tiddler.title] = tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4085
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4086
	this.forEachTiddler = function(callback) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4087
		for(var t in tiddlers) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4088
			var tiddler = tiddlers[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4089
			if(tiddler instanceof Tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4090
				callback.call(this,t,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4091
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4092
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4093
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4094
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4095
TiddlyWiki.prototype.setDirty = function(dirty)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4096
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4097
	this.dirty = dirty;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4098
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4099
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4100
TiddlyWiki.prototype.isDirty = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4101
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4102
	return this.dirty;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4103
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4104
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4105
TiddlyWiki.prototype.suspendNotifications = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4106
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4107
	this.notificationLevel--;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4108
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4109
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4110
TiddlyWiki.prototype.resumeNotifications = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4111
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4112
	this.notificationLevel++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4113
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4114
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4115
// Invoke the notification handlers for a particular tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4116
TiddlyWiki.prototype.notify = function(title,doBlanket)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4117
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4118
	if(!this.notificationLevel) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4119
		for(var t=0; t<this.namedNotifications.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4120
			var n = this.namedNotifications[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4121
			if((n.name == null && doBlanket) || (n.name == title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4122
				n.notify(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4123
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4124
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4125
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4126
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4127
// Invoke the notification handlers for all tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4128
TiddlyWiki.prototype.notifyAll = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4129
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4130
	if(!this.notificationLevel) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4131
		for(var t=0; t<this.namedNotifications.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4132
			var n = this.namedNotifications[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4133
			if(n.name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4134
				n.notify(n.name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4135
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4136
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4137
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4138
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4139
// Add a notification handler to a tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4140
TiddlyWiki.prototype.addNotification = function(title,fn)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4141
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4142
	for(var i=0; i<this.namedNotifications.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4143
		if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4144
			return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4145
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4146
	this.namedNotifications.push({name: title, notify: fn});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4147
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4148
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4149
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4150
TiddlyWiki.prototype.removeTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4151
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4152
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4153
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4154
		this.deleteTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4155
		this.notify(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4156
		this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4157
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4158
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4159
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4160
TiddlyWiki.prototype.tiddlerExists = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4161
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4162
	var t = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4163
	return t != undefined;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4164
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4165
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4166
TiddlyWiki.prototype.isShadowTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4167
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4168
	return typeof config.shadowTiddlers[title] == "string";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4169
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4170
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4171
TiddlyWiki.prototype.getTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4172
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4173
	var t = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4174
	if(t != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4175
		return t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4176
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4177
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4178
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4179
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4180
TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4181
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4182
	if(!title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4183
		return defaultText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4184
	var pos = title.indexOf(config.textPrimitives.sectionSeparator);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4185
	var section = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4186
	if(pos != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4187
		section = title.substr(pos + config.textPrimitives.sectionSeparator.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4188
		title = title.substr(0,pos);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4189
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4190
	pos = title.indexOf(config.textPrimitives.sliceSeparator);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4191
	if(pos != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4192
		var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4193
		if(slice)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4194
			return slice;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4195
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4196
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4197
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4198
		if(!section)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4199
			return tiddler.text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4200
		var re = new RegExp("(^!{1,6}" + section.escapeRegExp() + "[ \t]*\n)","mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4201
		re.lastIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4202
		var match =  re.exec(tiddler.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4203
		if(match) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4204
			var t = tiddler.text.substr(match.index+match[1].length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4205
			var re2 = /^!/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4206
			re2.lastIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4207
			match = re2.exec(t); //# search for the next heading
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4208
			if(match)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4209
				t = t.substr(0,match.index-1);//# don't include final \n
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4210
			return t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4211
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4212
		return defaultText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4213
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4214
	if(this.isShadowTiddler(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4215
		return config.shadowTiddlers[title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4216
	if(defaultText != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4217
		return defaultText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4218
	return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4219
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4220
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4221
TiddlyWiki.prototype.slicesRE = /(?:[\'\/]*~?([\.\w]+)[\'\/]*\:[\'\/]*\s*(.*?)\s*$)|(?:\|[\'\/]*~?([\.\w]+)\:?[\'\/]*\|\s*(.*?)\s*\|)/gm;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4222
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4223
// @internal
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4224
TiddlyWiki.prototype.calcAllSlices = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4225
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4226
	var slices = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4227
	var text = this.getTiddlerText(title,"");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4228
	this.slicesRE.lastIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4229
	do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4230
		var m = this.slicesRE.exec(text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4231
		if(m) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4232
			if(m[1])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4233
				slices[m[1]] = m[2];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4234
			else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4235
				slices[m[3]] = m[4];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4236
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4237
	} while(m);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4238
	return slices;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4239
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4240
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4241
// Returns the slice of text of the given name
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4242
TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4243
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4244
	var slices = this.slices[title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4245
	if(!slices) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4246
		slices = this.calcAllSlices(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4247
		this.slices[title] = slices;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4248
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4249
	return slices[sliceName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4250
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4251
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4252
// Build an hashmap of the specified named slices of a tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4253
TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4254
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4255
	var r = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4256
	for(var t=0; t<sliceNames.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4257
		var slice = this.getTiddlerSlice(title,sliceNames[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4258
		if(slice)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4259
			r[sliceNames[t]] = slice;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4260
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4261
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4262
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4263
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4264
TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4265
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4266
	var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4267
	var text = this.getTiddlerText(title,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4268
	if(text == null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4269
		return defaultText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4270
	var textOut = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4271
	var lastPos = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4272
	do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4273
		var match = bracketRegExp.exec(text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4274
		if(match) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4275
			textOut.push(text.substr(lastPos,match.index-lastPos));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4276
			if(match[1]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4277
				if(depth <= 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4278
					textOut.push(match[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4279
				else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4280
					textOut.push(this.getRecursiveTiddlerText(match[1],"[[" + match[1] + "]]",depth-1));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4281
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4282
			lastPos = match.index + match[0].length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4283
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4284
			textOut.push(text.substr(lastPos));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4285
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4286
	} while(match);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4287
	return textOut.join("");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4288
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4289
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4290
TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4291
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4292
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4293
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4294
		var t = tiddler.tags.indexOf(tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4295
		if(t != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4296
			tiddler.tags.splice(t,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4297
		if(status)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4298
			tiddler.tags.push(tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4299
		tiddler.changed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4300
		this.incChangeCount(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4301
		this.notify(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4302
		this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4303
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4304
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4305
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4306
TiddlyWiki.prototype.addTiddlerFields = function(title,fields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4307
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4308
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4309
	if(!tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4310
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4311
	merge(tiddler.fields,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4312
	tiddler.changed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4313
	this.incChangeCount(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4314
	this.notify(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4315
	this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4316
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4317
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4318
TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4319
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4320
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4321
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4322
		created = created ? created : tiddler.created; // Preserve created date
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4323
		this.deleteTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4324
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4325
		created = created ? created : modified;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4326
		tiddler = new Tiddler();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4327
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4328
	tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4329
	this.addTiddler(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4330
	if(clearChangeCount)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4331
		tiddler.clearChangeCount();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4332
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4333
		tiddler.incChangeCount();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4334
	if(title != newTitle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4335
		this.notify(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4336
	this.notify(newTitle,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4337
	this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4338
	return tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4339
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4340
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4341
// Reset the sync status of a freshly synced tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4342
TiddlyWiki.prototype.resetTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4343
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4344
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4345
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4346
		tiddler.clearChangeCount();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4347
		this.notify(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4348
		this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4349
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4350
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4351
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4352
TiddlyWiki.prototype.incChangeCount = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4353
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4354
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4355
	if(tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4356
		tiddler.incChangeCount();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4357
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4358
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4359
TiddlyWiki.prototype.createTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4360
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4361
	var tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4362
	if(!tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4363
		tiddler = new Tiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4364
		this.addTiddler(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4365
		this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4366
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4367
	return tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4368
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4369
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4370
// Load contents of a TiddlyWiki from an HTML DIV
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4371
TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4372
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4373
	this.idPrefix = idPrefix;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4374
	var storeElem = (typeof src == "string") ? document.getElementById(src) : src;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4375
	if(!storeElem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4376
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4377
	var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4378
	this.setDirty(false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4379
	if(!noUpdate) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4380
		for(var i = 0;i<tiddlers.length; i++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4381
			tiddlers[i].changed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4382
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4383
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4384
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4385
// Load contents of a TiddlyWiki from a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4386
// Returns null if there's an error
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4387
TiddlyWiki.prototype.importTiddlyWiki = function(text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4388
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4389
	var posDiv = locateStoreArea(text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4390
	if(!posDiv)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4391
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4392
	var content = "<" + "html><" + "body>" + text.substring(posDiv[0],posDiv[1] + endSaveArea.length) + "<" + "/body><" + "/html>";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4393
	// Create the iframe
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4394
	var iframe = document.createElement("iframe");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4395
	iframe.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4396
	document.body.appendChild(iframe);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4397
	var doc = iframe.document;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4398
	if(iframe.contentDocument)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4399
		doc = iframe.contentDocument; // For NS6
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4400
	else if(iframe.contentWindow)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4401
		doc = iframe.contentWindow.document; // For IE5.5 and IE6
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4402
	// Put the content in the iframe
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4403
	doc.open();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4404
	doc.writeln(content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4405
	doc.close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4406
	// Load the content into a TiddlyWiki() object
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4407
	var storeArea = doc.getElementById("storeArea");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4408
	this.loadFromDiv(storeArea,"store");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4409
	// Get rid of the iframe
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4410
	iframe.parentNode.removeChild(iframe);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4411
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4412
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4413
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4414
TiddlyWiki.prototype.updateTiddlers = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4415
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4416
	this.tiddlersUpdated = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4417
	this.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4418
		tiddler.changed();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4419
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4420
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4421
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4422
// Return all tiddlers formatted as an HTML string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4423
TiddlyWiki.prototype.allTiddlersAsHtml = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4424
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4425
	return store.getSaver().externalize(store);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4426
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4427
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4428
// Return an array of tiddlers matching a search regular expression
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4429
TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag,match)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4430
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4431
	var candidates = this.reverseLookup("tags",excludeTag,!!match);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4432
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4433
	for(var t=0; t<candidates.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4434
		if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4435
			results.push(candidates[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4436
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4437
	if(!sortField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4438
		sortField = "title";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4439
	results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4440
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4441
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4442
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4443
// Returns a list of all tags in use
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4444
//   excludeTag - if present, excludes tags that are themselves tagged with excludeTag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4445
// Returns an array of arrays where [tag][0] is the name of the tag and [tag][1] is the number of occurances
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4446
TiddlyWiki.prototype.getTags = function(excludeTag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4447
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4448
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4449
	this.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4450
		for(var g=0; g<tiddler.tags.length; g++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4451
			var tag = tiddler.tags[g];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4452
			var n = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4453
			for(var c=0; c<results.length; c++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4454
				if(results[c][0] == tag) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4455
					n = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4456
					results[c][1]++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4457
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4458
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4459
			if(n && excludeTag) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4460
				var t = store.fetchTiddler(tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4461
				if(t && t.isTagged(excludeTag))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4462
					n = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4463
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4464
			if(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4465
				results.push([tag,1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4466
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4467
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4468
	results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4469
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4470
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4471
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4472
// Return an array of the tiddlers that are tagged with a given tag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4473
TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4474
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4475
	return this.reverseLookup("tags",tag,true,sortField);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4476
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4477
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4478
// Return an array of the tiddlers that link to a given tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4479
TiddlyWiki.prototype.getReferringTiddlers = function(title,unusedParameter,sortField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4480
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4481
	if(!this.tiddlersUpdated)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4482
		this.updateTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4483
	return this.reverseLookup("links",title,true,sortField);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4484
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4485
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4486
// Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4487
// lookupMatch == true to match tiddlers, false to exclude tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4488
TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4489
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4490
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4491
	this.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4492
		var f = !lookupMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4493
		for(var lookup=0; lookup<tiddler[lookupField].length; lookup++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4494
			if(tiddler[lookupField][lookup] == lookupValue)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4495
				f = lookupMatch;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4496
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4497
		if(f)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4498
			results.push(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4499
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4500
	if(!sortField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4501
		sortField = "title";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4502
	results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4503
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4504
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4505
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4506
// Return the tiddlers as a sorted array
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4507
TiddlyWiki.prototype.getTiddlers = function(field,excludeTag)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4508
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4509
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4510
	this.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4511
		if(excludeTag == undefined || !tiddler.isTagged(excludeTag))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4512
			results.push(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4513
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4514
	if(field)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4515
		results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4516
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4517
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4518
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4519
// Return array of names of tiddlers that are referred to but not defined
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4520
TiddlyWiki.prototype.getMissingLinks = function(sortField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4521
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4522
	if(!this.tiddlersUpdated)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4523
		this.updateTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4524
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4525
	this.forEachTiddler(function (title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4526
		if(tiddler.isTagged("excludeMissing") || tiddler.isTagged("systemConfig"))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4527
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4528
		for(var n=0; n<tiddler.links.length;n++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4529
			var link = tiddler.links[n];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4530
			if(this.fetchTiddler(link) == null && !this.isShadowTiddler(link))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4531
				results.pushUnique(link);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4532
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4533
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4534
	results.sort();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4535
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4536
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4537
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4538
// Return an array of names of tiddlers that are defined but not referred to
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4539
TiddlyWiki.prototype.getOrphans = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4540
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4541
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4542
	this.forEachTiddler(function (title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4543
		if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists"))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4544
			results.push(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4545
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4546
	results.sort();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4547
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4548
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4549
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4550
// Return an array of names of all the shadow tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4551
TiddlyWiki.prototype.getShadowed = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4552
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4553
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4554
	for(var t in config.shadowTiddlers) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4555
		if(typeof config.shadowTiddlers[t] == "string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4556
			results.push(t);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4557
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4558
	results.sort();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4559
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4560
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4561
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4562
// Return an array of tiddlers that have been touched since they were downloaded or created
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4563
TiddlyWiki.prototype.getTouched = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4564
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4565
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4566
	this.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4567
		if(tiddler.isTouched())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4568
			results.push(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4569
		});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4570
	results.sort();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4571
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4572
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4573
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4574
// Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4575
TiddlyWiki.prototype.resolveTiddler = function(tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4576
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4577
	var t = (typeof tiddler == 'string') ? this.getTiddler(tiddler) : tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4578
	return t instanceof Tiddler ? t : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4579
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4580
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4581
TiddlyWiki.prototype.getLoader = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4582
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4583
	if(!this.loader)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4584
		this.loader = new TW21Loader();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4585
	return this.loader;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4586
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4587
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4588
TiddlyWiki.prototype.getSaver = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4589
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4590
	if(!this.saver)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4591
		this.saver = new TW21Saver();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4592
	return this.saver;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4593
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4594
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4595
// Filter a list of tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4596
TiddlyWiki.prototype.filterTiddlers = function(filter)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4597
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4598
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4599
	if(filter) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4600
		var tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4601
		var re = /([^\s\[\]]+)|(?:\[([ \w]+)\[([^\]]+)\]\])|(?:\[\[([^\]]+)\]\])/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4602
		var match = re.exec(filter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4603
		while(match) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4604
			if(match[1] || match[4]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4605
				var title = match[1] ? match[1] : match[4];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4606
				tiddler = this.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4607
				if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4608
					results.pushUnique(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4609
				} else if(store.isShadowTiddler(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4610
					tiddler = new Tiddler();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4611
					tiddler.set(title,store.getTiddlerText(title));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4612
					results.pushUnique(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4613
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4614
			} else if(match[2]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4615
				switch(match[2]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4616
					case "tag":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4617
						var matched = this.getTaggedTiddlers(match[3]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4618
						for(var m = 0; m < matched.length; m++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4619
							results.pushUnique(matched[m]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4620
						break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4621
					case "sort":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4622
						results = this.sortTiddlers(results,match[3]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4623
						break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4624
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4625
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4626
			match = re.exec(filter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4627
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4628
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4629
	return results;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4630
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4631
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4632
// Sort a list of tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4633
TiddlyWiki.prototype.sortTiddlers = function(tiddlers,field)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4634
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4635
	var asc = +1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4636
	switch(field.substr(0,1)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4637
		case "-":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4638
			asc = -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4639
			// Note: this fall-through is intentional
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4640
		case "+":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4641
			field = field.substr(1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4642
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4643
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4644
	if(TiddlyWiki.standardFieldAccess[field])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4645
		tiddlers.sort(function(a,b) {return a[field] < b[field] ? -asc : (a[field] == b[field] ? 0 : asc);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4646
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4647
		tiddlers.sort(function(a,b) {return a.fields[field] < b.fields[field] ? -asc : (a.fields[field] == b.fields[field] ? 0 : +asc);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4648
	return tiddlers;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4649
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4650
// Returns true if path is a valid field name (path),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4651
// i.e. a sequence of identifiers, separated by '.'
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4652
TiddlyWiki.isValidFieldName = function(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4653
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4654
	var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4655
	return match && (match[0] == name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4656
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4657
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4658
// Throws an exception when name is not a valid field name.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4659
TiddlyWiki.checkFieldName = function(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4660
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4661
	if(!TiddlyWiki.isValidFieldName(name))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4662
		throw config.messages.invalidFieldName.format([name]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4663
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4664
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4665
function StringFieldAccess(n,readOnly)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4666
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4667
	this.set = readOnly ?
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4668
			function(t,v) {if(v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);} :
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4669
			function(t,v) {if(v != t[n]) {t[n] = v; return true;}};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4670
	this.get = function(t) {return t[n];};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4671
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4672
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4673
function DateFieldAccess(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4674
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4675
	this.set = function(t,v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4676
		var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4677
		if(d != t[n]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4678
			t[n] = d; return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4679
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4680
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4681
	this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4682
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4683
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4684
function LinksFieldAccess(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4685
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4686
	this.set = function(t,v) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4687
		var s = (typeof v == "string") ? v.readBracketedList() : v;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4688
		if(s.toString() != t[n].toString()) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4689
			t[n] = s; return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4690
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4691
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4692
	this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4693
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4694
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4695
TiddlyWiki.standardFieldAccess = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4696
	// The set functions return true when setting the data has changed the value.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4697
	"title":    new StringFieldAccess("title",true),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4698
	// Handle the "tiddler" field name as the title
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4699
	"tiddler":  new StringFieldAccess("title",true),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4700
	"text":     new StringFieldAccess("text"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4701
	"modifier": new StringFieldAccess("modifier"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4702
	"modified": new DateFieldAccess("modified"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4703
	"created":  new DateFieldAccess("created"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4704
	"tags":     new LinksFieldAccess("tags")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4705
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4706
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4707
TiddlyWiki.isStandardField = function(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4708
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4709
	return TiddlyWiki.standardFieldAccess[name] != undefined;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4710
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4711
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4712
// Sets the value of the given field of the tiddler to the value.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4713
// Setting an ExtendedField's value to null or undefined removes the field.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4714
// Setting a namespace to undefined removes all fields of that namespace.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4715
// The fieldName is case-insensitive.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4716
// All values will be converted to a string value.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4717
TiddlyWiki.prototype.setValue = function(tiddler,fieldName,value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4718
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4719
	TiddlyWiki.checkFieldName(fieldName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4720
	var t = this.resolveTiddler(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4721
	if(!t)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4722
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4723
	fieldName = fieldName.toLowerCase();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4724
	var isRemove = (value === undefined) || (value === null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4725
	var accessor = TiddlyWiki.standardFieldAccess[fieldName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4726
	if(accessor) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4727
		if(isRemove)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4728
			// don't remove StandardFields
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4729
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4730
		var h = TiddlyWiki.standardFieldAccess[fieldName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4731
		if(!h.set(t,value))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4732
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4733
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4734
		var oldValue = t.fields[fieldName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4735
		if(isRemove) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4736
			if(oldValue !== undefined) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4737
				// deletes a single field
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4738
				delete t.fields[fieldName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4739
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4740
				// no concrete value is defined for the fieldName
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4741
				// so we guess this is a namespace path.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4742
				// delete all fields in a namespace
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4743
				var re = new RegExp('^'+fieldName+'\\.');
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4744
				var dirty = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4745
				for(var n in t.fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4746
					if(n.match(re)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4747
						delete t.fields[n];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4748
						dirty = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4749
					}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4750
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4751
				if(!dirty)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4752
					return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4753
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4754
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4755
			// the "normal" set case. value is defined (not null/undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4756
			// For convenience provide a nicer conversion Date->String
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4757
			value = value instanceof Date ? value.convertToYYYYMMDDHHMMSSMMM() : String(value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4758
			if(oldValue == value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4759
				return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4760
			t.fields[fieldName] = value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4761
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4762
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4763
	// When we are here the tiddler/store really was changed.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4764
	this.notify(t.title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4765
	if(!fieldName.match(/^temp\./))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4766
		this.setDirty(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4767
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4768
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4769
// Returns the value of the given field of the tiddler.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4770
// The fieldName is case-insensitive.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4771
// Will only return String values (or undefined).
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4772
TiddlyWiki.prototype.getValue = function(tiddler,fieldName)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4773
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4774
	var t = this.resolveTiddler(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4775
	if(!t)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4776
		return undefined;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4777
	fieldName = fieldName.toLowerCase();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4778
	var accessor = TiddlyWiki.standardFieldAccess[fieldName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4779
	if(accessor) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4780
		return accessor.get(t);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4781
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4782
	return t.fields[fieldName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4783
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4784
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4785
// Calls the callback function for every field in the tiddler.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4786
// When callback function returns a non-false value the iteration stops
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4787
// and that value is returned.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4788
// The order of the fields is not defined.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4789
// @param callback a function(tiddler,fieldName,value).
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4790
TiddlyWiki.prototype.forEachField = function(tiddler,callback,onlyExtendedFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4791
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4792
	var t = this.resolveTiddler(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4793
	if(!t)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4794
		return undefined;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4795
	var n,result;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4796
	for(n in t.fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4797
		result = callback(t,n,t.fields[n]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4798
		if(result)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4799
			return result;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4800
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4801
	if(onlyExtendedFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4802
		return undefined;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4803
	for(n in TiddlyWiki.standardFieldAccess) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4804
		if(n == "tiddler")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4805
			// even though the "title" field can also be referenced through the name "tiddler"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4806
			// we only visit this field once.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4807
			continue;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4808
		result = callback(t,n,TiddlyWiki.standardFieldAccess[n].get(t));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4809
		if(result)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4810
			return result;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4811
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4812
	return undefined;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4813
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4814
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4815
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4816
//-- Story functions
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4817
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4818
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4819
function Story(containerId,idPrefix)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4820
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4821
	this.container = containerId;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4822
	this.idPrefix = idPrefix;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4823
	this.highlightRegExp = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4824
	this.tiddlerId = function(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4825
		return this.idPrefix + title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4826
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4827
	this.containerId = function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4828
		return this.container;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4829
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4830
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4831
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4832
Story.prototype.forEachTiddler = function(fn)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4833
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4834
	var place = this.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4835
	if(!place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4836
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4837
	var e = place.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4838
	while(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4839
		var n = e.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4840
		var title = e.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4841
		fn.call(this,title,e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4842
		e = n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4843
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4844
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4845
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4846
Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,unused,customFields,toggle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4847
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4848
	for(var t = titles.length-1;t>=0;t--)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4849
		this.displayTiddler(srcElement,titles[t],template,animate,unused,customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4850
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4851
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4852
Story.prototype.displayTiddler = function(srcElement,tiddler,template,animate,unused,customFields,toggle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4853
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4854
	var title = (tiddler instanceof Tiddler)? tiddler.title : tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4855
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4856
	if(tiddlerElem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4857
		if(toggle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4858
			this.closeTiddler(title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4859
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4860
			this.refreshTiddler(title,template,false,customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4861
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4862
		var place = this.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4863
		var before = this.positionTiddler(srcElement);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4864
		tiddlerElem = this.createTiddler(place,before,title,template,customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4865
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4866
	if(srcElement && typeof srcElement !== "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4867
		if(config.options.chkAnimate && (animate == undefined || animate == true) && anim && typeof Zoomer == "function" && typeof Scroller == "function")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4868
			anim.startAnimating(new Zoomer(title,srcElement,tiddlerElem),new Scroller(tiddlerElem));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4869
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4870
			window.scrollTo(0,ensureVisible(tiddlerElem));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4871
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4872
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4873
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4874
Story.prototype.positionTiddler = function(srcElement)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4875
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4876
	var place = this.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4877
	var before = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4878
	if(typeof srcElement == "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4879
		switch(srcElement) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4880
			case "top":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4881
				before = place.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4882
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4883
			case "bottom":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4884
				before = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4885
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4886
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4887
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4888
		var after = this.findContainingTiddler(srcElement);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4889
		if(after == null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4890
			before = place.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4891
		} else if(after.nextSibling) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4892
			before = after.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4893
			if(before.nodeType != 1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4894
				before = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4895
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4896
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4897
	return before;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4898
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4899
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4900
Story.prototype.createTiddler = function(place,before,title,template,customFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4901
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4902
	var tiddlerElem = createTiddlyElement(null,"div",this.tiddlerId(title),"tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4903
	tiddlerElem.setAttribute("refresh","tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4904
	if(customFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4905
		tiddlerElem.setAttribute("tiddlyFields",customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4906
	place.insertBefore(tiddlerElem,before);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4907
	var defaultText = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4908
	if(!store.tiddlerExists(title) && !store.isShadowTiddler(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4909
		defaultText = this.loadMissingTiddler(title,customFields,tiddlerElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4910
	this.refreshTiddler(title,template,false,customFields,defaultText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4911
	return tiddlerElem;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4912
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4913
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4914
Story.prototype.loadMissingTiddler = function(title,fields,tiddlerElem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4915
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4916
	var tiddler = new Tiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4917
	tiddler.fields = typeof fields == "string" ? fields.decodeHashMap() : (fields ? fields : {});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4918
	var serverType = tiddler.getServerType();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4919
	var host = tiddler.fields['server.host'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4920
	var workspace = tiddler.fields['server.workspace'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4921
	if(!serverType || !host)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4922
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4923
	var sm = new SyncMachine(serverType,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4924
			start: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4925
				return this.openHost(host,"openWorkspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4926
			},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4927
			openWorkspace: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4928
				return this.openWorkspace(workspace,"getTiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4929
			},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4930
			getTiddler: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4931
				return this.getTiddler(title,"onGetTiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4932
			},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4933
			onGetTiddler: function(context) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4934
				var tiddler = context.tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4935
				if(tiddler && tiddler.text) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4936
					var downloaded = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4937
					if(!tiddler.created)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4938
						tiddler.created = downloaded;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4939
					if(!tiddler.modified)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4940
						tiddler.modified = tiddler.created;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4941
					store.saveTiddler(tiddler.title,tiddler.title,tiddler.text,tiddler.modifier,tiddler.modified,tiddler.tags,tiddler.fields,true,tiddler.created);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4942
					autoSaveChanges();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4943
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4944
				delete this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4945
				return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4946
			},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4947
			error: function(message) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4948
				displayMessage("Error loading missing tiddler from %0: %1".format([host,message]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4949
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4950
		});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4951
	sm.go();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4952
	return config.messages.loadingMissingTiddler.format([title,serverType,host,workspace]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4953
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4954
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4955
Story.prototype.chooseTemplateForTiddler = function(title,template)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4956
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4957
	if(!template)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4958
		template = DEFAULT_VIEW_TEMPLATE;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4959
	if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4960
		template = config.tiddlerTemplates[template];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4961
	return template;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4962
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4963
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4964
Story.prototype.getTemplateForTiddler = function(title,template,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4965
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4966
	return store.getRecursiveTiddlerText(template,null,10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4967
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4968
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4969
Story.prototype.refreshTiddler = function(title,template,force,customFields,defaultText)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4970
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4971
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4972
	if(tiddlerElem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4973
		if(tiddlerElem.getAttribute("dirty") == "true" && !force)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4974
			return tiddlerElem;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4975
		template = this.chooseTemplateForTiddler(title,template);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4976
		var currTemplate = tiddlerElem.getAttribute("template");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4977
		if((template != currTemplate) || force) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4978
			var tiddler = store.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4979
			if(!tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4980
				tiddler = new Tiddler();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4981
				if(store.isShadowTiddler(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4982
					tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,[],version.date);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4983
				} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4984
					var text = template=="EditTemplate" ?
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4985
								config.views.editor.defaultText.format([title]) :
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4986
								config.views.wikified.defaultText.format([title]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4987
					text = defaultText ? defaultText : text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4988
					var fields = customFields ? customFields.decodeHashMap() : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4989
					tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4990
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4991
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4992
			tiddlerElem.setAttribute("tags",tiddler.tags.join(" "));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4993
			tiddlerElem.setAttribute("tiddler",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4994
			tiddlerElem.setAttribute("template",template);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4995
			tiddlerElem.onmouseover = this.onTiddlerMouseOver;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4996
			tiddlerElem.onmouseout = this.onTiddlerMouseOut;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4997
			tiddlerElem.ondblclick = this.onTiddlerDblClick;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4998
			tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  4999
			tiddlerElem.innerHTML = this.getTemplateForTiddler(title,template,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5000
			applyHtmlMacros(tiddlerElem,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5001
			if(store.getTaggedTiddlers(title).length > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5002
				addClass(tiddlerElem,"isTag");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5003
			else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5004
				removeClass(tiddlerElem,"isTag");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5005
			if(store.tiddlerExists(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5006
				removeClass(tiddlerElem,"shadow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5007
				removeClass(tiddlerElem,"missing");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5008
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5009
				addClass(tiddlerElem,store.isShadowTiddler(title) ? "shadow" : "missing");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5010
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5011
			if(customFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5012
				this.addCustomFields(tiddlerElem,customFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5013
			forceReflow();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5014
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5015
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5016
	return tiddlerElem;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5017
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5018
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5019
Story.prototype.addCustomFields = function(place,customFields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5020
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5021
	var fields = customFields.decodeHashMap();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5022
	var w = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5023
	w.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5024
	place.appendChild(w);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5025
	for(var t in fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5026
		var e = document.createElement("input");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5027
		e.setAttribute("type","text");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5028
		e.setAttribute("value",fields[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5029
		w.appendChild(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5030
		e.setAttribute("edit",t);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5031
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5032
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5033
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5034
Story.prototype.refreshAllTiddlers = function(force)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5035
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5036
	var place = this.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5037
	var e = place.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5038
	if(!e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5039
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5040
	this.refreshTiddler(e.getAttribute("tiddler"),force ? null : e.getAttribute("template"),true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5041
	while((e = e.nextSibling) != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5042
		this.refreshTiddler(e.getAttribute("tiddler"),force ? null : e.getAttribute("template"),true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5043
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5044
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5045
Story.prototype.onTiddlerMouseOver = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5046
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5047
	if(window.addClass instanceof Function)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5048
		addClass(this,"selected");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5049
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5050
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5051
Story.prototype.onTiddlerMouseOut = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5052
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5053
	if(window.removeClass instanceof Function)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5054
		removeClass(this,"selected");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5055
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5056
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5057
Story.prototype.onTiddlerDblClick = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5058
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5059
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5060
	var theTarget = resolveTarget(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5061
	if(theTarget && theTarget.nodeName.toLowerCase() != "input" && theTarget.nodeName.toLowerCase() != "textarea") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5062
		if(document.selection && document.selection.empty)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5063
			document.selection.empty();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5064
		config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5065
		e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5066
		if(e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5067
		return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5068
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5069
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5070
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5071
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5072
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5073
Story.prototype.onTiddlerKeyPress = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5074
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5075
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5076
	clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5077
	var consume = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5078
	var title = this.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5079
	var target = resolveTarget(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5080
	switch(e.keyCode) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5081
		case 9: // Tab
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5082
			if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5083
				replaceSelection(target,String.fromCharCode(9));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5084
				consume = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5085
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5086
			if(config.isOpera) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5087
				target.onblur = function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5088
					this.focus();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5089
					this.onblur = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5090
				};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5091
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5092
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5093
		case 13: // Ctrl-Enter
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5094
		case 10: // Ctrl-Enter on IE PC
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5095
		case 77: // Ctrl-Enter is "M" on some platforms
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5096
			if(e.ctrlKey) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5097
				blurElement(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5098
				config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5099
				consume = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5100
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5101
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5102
		case 27: // Escape
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5103
			blurElement(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5104
			config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5105
			consume = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5106
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5107
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5108
	e.cancelBubble = consume;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5109
	if(consume) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5110
		if(e.stopPropagation) e.stopPropagation(); // Stop Propagation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5111
		e.returnValue = true; // Cancel The Event in IE
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5112
		if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5113
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5114
	return !consume;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5115
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5116
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5117
Story.prototype.getTiddlerField = function(title,field)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5118
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5119
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5120
	var e = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5121
	if(tiddlerElem != null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5122
		var children = tiddlerElem.getElementsByTagName("*");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5123
		for(var t=0; t<children.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5124
			var c = children[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5125
			if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5126
				if(!e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5127
					e = c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5128
				if(c.getAttribute("edit") == field)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5129
					e = c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5130
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5131
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5132
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5133
	return e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5134
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5135
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5136
Story.prototype.focusTiddler = function(title,field)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5137
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5138
	var e = this.getTiddlerField(title,field);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5139
	if(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5140
		e.focus();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5141
		e.select();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5142
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5143
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5144
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5145
Story.prototype.blurTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5146
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5147
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5148
	if(tiddlerElem != null && tiddlerElem.focus && tiddlerElem.blur) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5149
		tiddlerElem.focus();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5150
		tiddlerElem.blur();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5151
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5152
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5153
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5154
Story.prototype.setTiddlerField = function(title,tag,mode,field)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5155
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5156
	var c = story.getTiddlerField(title,field);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5157
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5158
	var tags = c.value.readBracketedList();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5159
	tags.setItem(tag,mode);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5160
	c.value = String.encodeTiddlyLinkList(tags);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5161
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5162
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5163
Story.prototype.setTiddlerTag = function(title,tag,mode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5164
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5165
	Story.prototype.setTiddlerField(title,tag,mode,"tags");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5166
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5167
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5168
Story.prototype.closeTiddler = function(title,animate,unused)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5169
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5170
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5171
	if(tiddlerElem != null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5172
		clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5173
		this.scrubTiddler(tiddlerElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5174
		if(config.options.chkAnimate && animate && anim && typeof Slider == "function")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5175
			anim.startAnimating(new Slider(tiddlerElem,false,null,"all"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5176
		else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5177
			removeNode(tiddlerElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5178
			forceReflow();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5179
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5180
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5181
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5182
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5183
Story.prototype.scrubTiddler = function(tiddlerElem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5184
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5185
	tiddlerElem.id = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5186
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5187
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5188
Story.prototype.setDirty = function(title,dirty)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5189
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5190
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5191
	if(tiddlerElem != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5192
		tiddlerElem.setAttribute("dirty",dirty ? "true" : "false");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5193
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5194
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5195
Story.prototype.isDirty = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5196
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5197
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5198
	if(tiddlerElem != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5199
		return tiddlerElem.getAttribute("dirty") == "true";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5200
	return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5201
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5202
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5203
Story.prototype.areAnyDirty = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5204
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5205
	var r = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5206
	this.forEachTiddler(function(title,element) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5207
		if(this.isDirty(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5208
			r = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5209
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5210
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5211
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5212
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5213
Story.prototype.closeAllTiddlers = function(exclude)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5214
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5215
	clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5216
	this.forEachTiddler(function(title,element) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5217
		if((title != exclude) && element.getAttribute("dirty") != "true")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5218
			this.closeTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5219
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5220
	window.scrollTo(0,ensureVisible(this.container));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5221
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5222
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5223
Story.prototype.isEmpty = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5224
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5225
	var place = this.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5226
	return place && place.firstChild == null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5227
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5228
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5229
Story.prototype.search = function(text,useCaseSensitive,useRegExp)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5230
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5231
	this.closeAllTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5232
	highlightHack = new RegExp(useRegExp ?	 text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5233
	var matches = store.search(highlightHack,"title","excludeSearch");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5234
	this.displayTiddlers(null,matches);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5235
	highlightHack = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5236
	var q = useRegExp ? "/" : "'";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5237
	if(matches.length > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5238
		displayMessage(config.macros.search.successMsg.format([matches.length.toString(),q + text + q]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5239
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5240
		displayMessage(config.macros.search.failureMsg.format([q + text + q]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5241
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5242
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5243
Story.prototype.findContainingTiddler = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5244
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5245
	while(e && !hasClass(e,"tiddler"))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5246
		e = e.parentNode;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5247
	return e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5248
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5249
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5250
Story.prototype.gatherSaveFields = function(e,fields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5251
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5252
	if(e && e.getAttribute) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5253
		var f = e.getAttribute("edit");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5254
		if(f)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5255
			fields[f] = e.value.replace(/\r/mg,"");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5256
		if(e.hasChildNodes()) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5257
			var c = e.childNodes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5258
			for(var t=0; t<c.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5259
				this.gatherSaveFields(c[t],fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5260
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5261
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5262
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5263
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5264
Story.prototype.hasChanges = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5265
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5266
	var e = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5267
	if(e != null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5268
		var fields = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5269
		this.gatherSaveFields(e,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5270
		var tiddler = store.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5271
		if(!tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5272
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5273
		for(var n in fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5274
			if(store.getValue(title,n) != fields[n])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5275
				return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5276
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5277
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5278
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5279
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5280
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5281
Story.prototype.saveTiddler = function(title,minorUpdate)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5282
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5283
	var tiddlerElem = this.getTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5284
	if(tiddlerElem != null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5285
		var fields = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5286
		this.gatherSaveFields(tiddlerElem,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5287
		var newTitle = fields.title ? fields.title : title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5288
		if(!store.tiddlerExists(newTitle))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5289
			newTitle = newTitle.trim();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5290
		if(store.tiddlerExists(newTitle) && newTitle != title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5291
			if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5292
				return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5293
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5294
		if(newTitle != title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5295
			this.closeTiddler(newTitle,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5296
		tiddlerElem.id = this.tiddlerId(newTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5297
		tiddlerElem.setAttribute("tiddler",newTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5298
		tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5299
		tiddlerElem.setAttribute("dirty","false");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5300
		if(config.options.chkForceMinorUpdate)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5301
			minorUpdate = !minorUpdate;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5302
		if(!store.tiddlerExists(newTitle))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5303
			minorUpdate = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5304
		var newDate = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5305
		var extendedFields = store.tiddlerExists(newTitle) ? store.fetchTiddler(newTitle).fields : (newTitle!=title && store.tiddlerExists(title) ? store.fetchTiddler(title).fields : {});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5306
		for(var n in fields) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5307
			if(!TiddlyWiki.isStandardField(n))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5308
				extendedFields[n] = fields[n];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5309
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5310
		var tiddler = store.saveTiddler(title,newTitle,fields.text,minorUpdate ? undefined : config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags,extendedFields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5311
		autoSaveChanges(null,[tiddler]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5312
		return newTitle;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5313
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5314
	return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5315
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5316
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5317
Story.prototype.permaView = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5318
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5319
	var links = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5320
	this.forEachTiddler(function(title,element) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5321
		links.push(String.encodeTiddlyLink(title));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5322
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5323
	var t = encodeURIComponent(links.join(" "));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5324
	if(t == "")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5325
		t = "#";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5326
	if(window.location.hash != t)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5327
		window.location.hash = t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5328
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5329
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5330
Story.prototype.switchTheme = function(theme)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5331
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5332
	if(safeMode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5333
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5334
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5335
	isAvailable = function(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5336
		var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5337
		if(s!=-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5338
			title = title.substr(0,s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5339
		return store.tiddlerExists(title) || store.isShadowTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5340
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5341
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5342
	getSlice = function(theme,slice) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5343
		var r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5344
		if(readOnly)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5345
			r = store.getTiddlerSlice(theme,slice+"ReadOnly") || store.getTiddlerSlice(theme,"Web"+slice);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5346
		r = r || store.getTiddlerSlice(theme,slice);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5347
		if(r && r.indexOf(config.textPrimitives.sectionSeparator)==0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5348
			r = theme + r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5349
		return isAvailable(r) ? r : slice;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5350
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5351
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5352
	replaceNotification = function(i,name,theme,slice) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5353
		var newName = getSlice(theme,slice);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5354
		if(name!=newName && store.namedNotifications[i].name==name) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5355
			store.namedNotifications[i].name = newName;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5356
			return newName;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5357
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5358
		return name;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5359
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5360
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5361
	var pt = config.refresherData.pageTemplate;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5362
	var vi = DEFAULT_VIEW_TEMPLATE;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5363
	var vt = config.tiddlerTemplates[vi];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5364
	var ei = DEFAULT_EDIT_TEMPLATE;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5365
	var et = config.tiddlerTemplates[ei];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5366
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5367
	for(var i=0; i<config.notifyTiddlers.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5368
		var name = config.notifyTiddlers[i].name;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5369
		switch(name) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5370
		case "PageTemplate":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5371
			config.refresherData.pageTemplate = replaceNotification(i,config.refresherData.pageTemplate,theme,name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5372
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5373
		case "StyleSheet":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5374
			removeStyleSheet(config.refresherData.styleSheet);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5375
			config.refresherData.styleSheet = replaceNotification(i,config.refresherData.styleSheet,theme,name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5376
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5377
		case "ColorPalette":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5378
			config.refresherData.colorPalette = replaceNotification(i,config.refresherData.colorPalette,theme,name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5379
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5380
		default:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5381
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5382
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5383
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5384
	config.tiddlerTemplates[vi] = getSlice(theme,"ViewTemplate");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5385
	config.tiddlerTemplates[ei] = getSlice(theme,"EditTemplate");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5386
	if(!startingUp) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5387
		if(config.refresherData.pageTemplate!=pt || config.tiddlerTemplates[vi]!=vt || config.tiddlerTemplates[ei]!=et) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5388
			refreshAll();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5389
			story.refreshAllTiddlers(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5390
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5391
			setStylesheet(store.getRecursiveTiddlerText(config.refresherData.styleSheet,"",10),config.refreshers.styleSheet);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5392
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5393
		config.options.txtTheme = theme;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5394
		saveOptionCookie("txtTheme");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5395
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5396
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5397
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5398
Story.prototype.getTiddler = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5399
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5400
	return document.getElementById(this.tiddlerId(title));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5401
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5402
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5403
Story.prototype.getContainer = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5404
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5405
	return document.getElementById(this.containerId());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5406
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5407
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5408
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5409
//-- Backstage
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5410
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5411
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5412
var backstage = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5413
	area: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5414
	toolbar: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5415
	button: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5416
	showButton: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5417
	hideButton: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5418
	cloak: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5419
	panel: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5420
	panelBody: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5421
	panelFooter: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5422
	currTabName: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5423
	currTabElem: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5424
	content: null,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5425
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5426
	init: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5427
		var cmb = config.messages.backstage;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5428
		this.area = document.getElementById("backstageArea");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5429
		this.toolbar = document.getElementById("backstageToolbar");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5430
		this.button = document.getElementById("backstageButton");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5431
		this.button.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5432
		var t = cmb.open.text + " " + glyph("bentArrowLeft");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5433
		this.showButton = createTiddlyButton(this.button,t,cmb.open.tooltip,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5434
						function (e) {backstage.show(); return false;},null,"backstageShow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5435
		t = glyph("bentArrowRight") + " " + cmb.close.text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5436
		this.hideButton = createTiddlyButton(this.button,t,cmb.close.tooltip,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5437
						function (e) {backstage.hide(); return false;},null,"backstageHide");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5438
		this.cloak = document.getElementById("backstageCloak");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5439
		this.panel = document.getElementById("backstagePanel");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5440
		this.panelFooter = createTiddlyElement(this.panel,"div",null,"backstagePanelFooter");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5441
		this.panelBody = createTiddlyElement(this.panel,"div",null,"backstagePanelBody");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5442
		this.cloak.onmousedown = function(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5443
			backstage.switchTab(null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5444
		};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5445
		createTiddlyText(this.toolbar,cmb.prompt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5446
		for(t=0; t<config.backstageTasks.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5447
			var taskName = config.backstageTasks[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5448
			var task = config.tasks[taskName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5449
			var handler = task.action ? this.onClickCommand : this.onClickTab;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5450
			var text = task.text + (task.action ? "" : glyph("downTriangle"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5451
			var btn = createTiddlyButton(this.toolbar,text,task.tooltip,handler,"backstageTab");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5452
			btn.setAttribute("task",taskName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5453
			addClass(btn,task.action ? "backstageAction" : "backstageTask");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5454
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5455
		this.content = document.getElementById("contentWrapper");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5456
		if(config.options.chkBackstage)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5457
			this.show();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5458
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5459
			this.hide();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5460
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5461
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5462
	isVisible: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5463
		return this.area ? this.area.style.display == "block" : false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5464
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5465
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5466
	show: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5467
		this.area.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5468
		if(anim && config.options.chkAnimate) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5469
			backstage.toolbar.style.left = findWindowWidth() + "px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5470
			var p = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5471
				{style: "left", start: findWindowWidth(), end: 0, template: "%0px"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5472
			];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5473
			anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5474
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5475
			backstage.area.style.left = "0px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5476
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5477
		this.showButton.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5478
		this.hideButton.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5479
		config.options.chkBackstage = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5480
		saveOptionCookie("chkBackstage");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5481
		addClass(this.content,"backstageVisible");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5482
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5483
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5484
	hide: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5485
		if(this.currTabElem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5486
			this.switchTab(null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5487
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5488
			backstage.toolbar.style.left = "0px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5489
			if(anim && config.options.chkAnimate) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5490
				var p = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5491
					{style: "left", start: 0, end: findWindowWidth(), template: "%0px"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5492
				];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5493
				var c = function(element,properties) {backstage.area.style.display = "none";};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5494
				anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p,c));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5495
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5496
				this.area.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5497
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5498
			this.showButton.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5499
			this.hideButton.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5500
			config.options.chkBackstage = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5501
			saveOptionCookie("chkBackstage");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5502
			removeClass(this.content,"backstageVisible");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5503
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5504
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5505
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5506
	onClickCommand: function(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5507
		var task = config.tasks[this.getAttribute("task")];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5508
		displayMessage(task);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5509
		if(task.action) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5510
			backstage.switchTab(null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5511
			task.action();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5512
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5513
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5514
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5515
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5516
	onClickTab: function(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5517
		backstage.switchTab(this.getAttribute("task"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5518
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5519
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5520
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5521
	// Switch to a given tab, or none if null is passed
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5522
	switchTab: function(tabName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5523
		var tabElem = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5524
		var e = this.toolbar.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5525
		while(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5526
			{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5527
			if(e.getAttribute && e.getAttribute("task") == tabName)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5528
				tabElem = e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5529
			e = e.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5530
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5531
		if(tabName == backstage.currTabName)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5532
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5533
		if(backstage.currTabElem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5534
			removeClass(this.currTabElem,"backstageSelTab");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5535
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5536
		if(tabElem && tabName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5537
			backstage.preparePanel();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5538
			addClass(tabElem,"backstageSelTab");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5539
			var task = config.tasks[tabName];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5540
			wikify(task.content,backstage.panelBody,null,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5541
			backstage.showPanel();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5542
		} else if(backstage.currTabElem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5543
			backstage.hidePanel();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5544
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5545
		backstage.currTabName = tabName;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5546
		backstage.currTabElem = tabElem;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5547
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5548
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5549
	isPanelVisible: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5550
		return backstage.panel ? backstage.panel.style.display == "block" : false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5551
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5552
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5553
	preparePanel: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5554
		backstage.cloak.style.height = findWindowHeight() + "px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5555
		backstage.cloak.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5556
		removeChildren(backstage.panelBody);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5557
		return backstage.panelBody;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5558
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5559
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5560
	showPanel: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5561
		backstage.panel.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5562
		if(anim && config.options.chkAnimate) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5563
			backstage.panel.style.top = (-backstage.panel.offsetHeight) + "px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5564
			var p = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5565
				{style: "top", start: -backstage.panel.offsetHeight, end: 0, template: "%0px"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5566
			];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5567
			anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p),new Scroller(backstage.panel,false));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5568
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5569
			backstage.panel.style.top = "0px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5570
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5571
		return backstage.panelBody;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5572
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5573
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5574
	hidePanel: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5575
		backstage.currTabName = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5576
		backstage.currTabElem = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5577
		if(anim && config.options.chkAnimate) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5578
			var p = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5579
				{style: "top", start: 0, end: -(backstage.panel.offsetHeight), template: "%0px"},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5580
				{style: "display", atEnd: "none"}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5581
			];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5582
			var c = function(element,properties) {backstage.cloak.style.display = "none";};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5583
			anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p,c));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5584
		 } else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5585
			backstage.panel.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5586
			backstage.cloak.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5587
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5588
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5589
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5590
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5591
config.macros.backstage = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5592
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5593
config.macros.backstage.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5594
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5595
	var backstageTask = config.tasks[params[0]];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5596
	if(backstageTask)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5597
		createTiddlyButton(place,backstageTask.text,backstageTask.tooltip,function(e) {backstage.switchTab(params[0]); return false;});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5598
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5599
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5600
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5601
//-- ImportTiddlers macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5602
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5603
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5604
config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5605
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5606
	if(readOnly) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5607
		createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5608
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5609
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5610
	var w = new Wizard();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5611
	w.createWizard(place,this.wizardTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5612
	this.restart(w);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5613
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5614
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5615
config.macros.importTiddlers.onCancel = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5616
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5617
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5618
	var place = wizard.clear();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5619
	config.macros.importTiddlers.restart(wizard);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5620
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5621
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5622
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5623
config.macros.importTiddlers.onClose = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5624
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5625
	backstage.hidePanel();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5626
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5627
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5628
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5629
config.macros.importTiddlers.restart = function(wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5630
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5631
	wizard.addStep(this.step1Title,this.step1Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5632
	var s = wizard.getElement("selTypes");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5633
	for(var t in config.adaptors) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5634
		var e = createTiddlyElement(s,"option",null,null,config.adaptors[t].serverLabel ? config.adaptors[t].serverLabel : t);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5635
		e.value = t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5636
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5637
	if(config.defaultAdaptor)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5638
		s.value = config.defaultAdaptor;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5639
	s = wizard.getElement("selFeeds");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5640
	var feeds = this.getFeeds();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5641
	for(t in feeds) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5642
		e = createTiddlyElement(s,"option",null,null,t);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5643
		e.value = t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5644
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5645
	wizard.setValue("feeds",feeds);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5646
	s.onchange = config.macros.importTiddlers.onFeedChange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5647
	var fileInput = wizard.getElement("txtBrowse");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5648
	fileInput.onchange = config.macros.importTiddlers.onBrowseChange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5649
	fileInput.onkeyup = config.macros.importTiddlers.onBrowseChange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5650
	wizard.setButtons([{caption: this.openLabel, tooltip: this.openPrompt, onClick: config.macros.importTiddlers.onOpen}]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5651
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5652
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5653
config.macros.importTiddlers.getFeeds = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5654
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5655
	var feeds = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5656
	var tagged = store.getTaggedTiddlers("systemServer","title");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5657
	for(var t=0; t<tagged.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5658
		var title = tagged[t].title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5659
		var serverType = store.getTiddlerSlice(title,"Type");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5660
		if(!serverType)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5661
			serverType = "file";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5662
		feeds[title] = {title: title,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5663
						url: store.getTiddlerSlice(title,"URL"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5664
						workspace: store.getTiddlerSlice(title,"Workspace"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5665
						workspaceList: store.getTiddlerSlice(title,"WorkspaceList"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5666
						tiddlerFilter: store.getTiddlerSlice(title,"TiddlerFilter"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5667
						serverType: serverType,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5668
						description: store.getTiddlerSlice(title,"Description")};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5669
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5670
	return feeds;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5671
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5672
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5673
config.macros.importTiddlers.onFeedChange = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5674
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5675
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5676
	var selTypes = wizard.getElement("selTypes");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5677
	var fileInput = wizard.getElement("txtPath");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5678
	var feeds = wizard.getValue("feeds");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5679
	var f = feeds[this.value];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5680
	if(f) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5681
		selTypes.value = f.serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5682
		fileInput.value = f.url;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5683
		wizard.setValue("feedName",f.serverType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5684
		wizard.setValue("feedHost",f.url);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5685
		wizard.setValue("feedWorkspace",f.workspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5686
		wizard.setValue("feedWorkspaceList",f.workspaceList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5687
		wizard.setValue("feedTiddlerFilter",f.tiddlerFilter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5688
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5689
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5690
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5691
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5692
config.macros.importTiddlers.onBrowseChange = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5693
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5694
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5695
	var fileInput = wizard.getElement("txtPath");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5696
	fileInput.value = "file://" + this.value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5697
	var serverType = wizard.getElement("selTypes");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5698
	serverType.value = "file";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5699
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5700
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5701
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5702
config.macros.importTiddlers.onOpen = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5703
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5704
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5705
	var fileInput = wizard.getElement("txtPath");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5706
	var url = fileInput.value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5707
	var serverType = wizard.getElement("selTypes").value || config.defaultAdaptor;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5708
	var adaptor = new config.adaptors[serverType];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5709
	wizard.setValue("adaptor",adaptor);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5710
	wizard.setValue("serverType",serverType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5711
	wizard.setValue("host",url);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5712
	var ret = adaptor.openHost(url,null,wizard,config.macros.importTiddlers.onOpenHost);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5713
	if(ret !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5714
		displayMessage(ret);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5715
	wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenHost);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5716
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5717
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5718
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5719
config.macros.importTiddlers.onOpenHost = function(context,wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5720
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5721
	var adaptor = wizard.getValue("adaptor");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5722
	if(context.status !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5723
		displayMessage("Error in importTiddlers.onOpenHost: " + context.statusText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5724
	var ret = adaptor.getWorkspaceList(context,wizard,config.macros.importTiddlers.onGetWorkspaceList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5725
	if(ret !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5726
		displayMessage(ret);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5727
	wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetWorkspaceList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5728
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5729
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5730
config.macros.importTiddlers.onGetWorkspaceList = function(context,wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5731
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5732
	if(context.status !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5733
		displayMessage("Error in importTiddlers.onGetWorkspaceList: " + context.statusText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5734
	wizard.setValue("context",context);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5735
	var workspace = wizard.getValue("feedWorkspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5736
	if(!workspace && context.workspaces.length==1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5737
		workspace = context.workspaces[0].title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5738
	if(workspace) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5739
		var ret = context.adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5740
		if(ret !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5741
			displayMessage(ret);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5742
		wizard.setValue("workspace",workspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5743
		wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5744
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5745
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5746
	wizard.addStep(config.macros.importTiddlers.step2Title,config.macros.importTiddlers.step2Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5747
	var s = wizard.getElement("selWorkspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5748
	s.onchange = config.macros.importTiddlers.onWorkspaceChange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5749
	for(var t=0; t<context.workspaces.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5750
		var e = createTiddlyElement(s,"option",null,null,context.workspaces[t].title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5751
		e.value = context.workspaces[t].title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5752
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5753
	var workspaceList = wizard.getValue("feedWorkspaceList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5754
	if(workspaceList) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5755
		var list = workspaceList.parseParams("workspace",null,false,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5756
		for(var n=1; n<list.length; n++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5757
			if(context.workspaces.findByField("title",list[n].value) == null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5758
				e = createTiddlyElement(s,"option",null,null,list[n].value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5759
				e.value = list[n].value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5760
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5761
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5762
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5763
	if(workspace) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5764
		t = wizard.getElement("txtWorkspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5765
		t.value = workspace;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5766
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5767
	wizard.setButtons([{caption: config.macros.importTiddlers.openLabel, tooltip: config.macros.importTiddlers.openPrompt, onClick: config.macros.importTiddlers.onChooseWorkspace}]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5768
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5769
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5770
config.macros.importTiddlers.onWorkspaceChange = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5771
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5772
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5773
	var t = wizard.getElement("txtWorkspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5774
	t.value  = this.value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5775
	this.selectedIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5776
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5777
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5778
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5779
config.macros.importTiddlers.onChooseWorkspace = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5780
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5781
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5782
	var adaptor = wizard.getValue("adaptor");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5783
	var workspace = wizard.getElement("txtWorkspace").value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5784
	wizard.setValue("workspace",workspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5785
	var context = wizard.getValue("context");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5786
	var ret = adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5787
	if(ret !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5788
		displayMessage(ret);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5789
	wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5790
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5791
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5792
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5793
config.macros.importTiddlers.onOpenWorkspace = function(context,wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5794
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5795
	if(context.status !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5796
		displayMessage("Error in importTiddlers.onOpenWorkspace: " + context.statusText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5797
	var adaptor = wizard.getValue("adaptor");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5798
	var ret = adaptor.getTiddlerList(context,wizard,config.macros.importTiddlers.onGetTiddlerList,wizard.getValue("feedTiddlerFilter"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5799
	if(ret !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5800
		displayMessage(ret);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5801
	wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetTiddlerList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5802
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5803
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5804
config.macros.importTiddlers.onGetTiddlerList = function(context,wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5805
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5806
	if(context.status !== true) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5807
		wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.errorGettingTiddlerList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5808
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5809
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5810
	// Extract data for the listview
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5811
	var listedTiddlers = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5812
	if(context.tiddlers) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5813
		for(var n=0; n<context.tiddlers.length; n++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5814
			var tiddler = context.tiddlers[n];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5815
			listedTiddlers.push({
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5816
				title: tiddler.title,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5817
				modified: tiddler.modified,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5818
				modifier: tiddler.modifier,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5819
				text: tiddler.text ? wikifyPlainText(tiddler.text,100) : "",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5820
				tags: tiddler.tags,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5821
				size: tiddler.text ? tiddler.text.length : 0,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5822
				tiddler: tiddler
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5823
			});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5824
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5825
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5826
	listedTiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5827
	// Display the listview
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5828
	wizard.addStep(config.macros.importTiddlers.step3Title,config.macros.importTiddlers.step3Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5829
	var markList = wizard.getElement("markList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5830
	var listWrapper = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5831
	markList.parentNode.insertBefore(listWrapper,markList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5832
	var listView = ListView.create(listWrapper,listedTiddlers,config.macros.importTiddlers.listViewTemplate);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5833
	wizard.setValue("listView",listView);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5834
	var txtSaveTiddler = wizard.getElement("txtSaveTiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5835
	txtSaveTiddler.value = config.macros.importTiddlers.generateSystemServerName(wizard);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5836
	wizard.setButtons([
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5837
			{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5838
			{caption: config.macros.importTiddlers.importLabel, tooltip: config.macros.importTiddlers.importPrompt, onClick:  config.macros.importTiddlers.doImport}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5839
		]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5840
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5841
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5842
config.macros.importTiddlers.generateSystemServerName = function(wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5843
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5844
	var serverType = wizard.getValue("serverType");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5845
	var host = wizard.getValue("host");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5846
	var workspace = wizard.getValue("workspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5847
	var pattern = config.macros.importTiddlers[workspace ? "systemServerNamePattern" : "systemServerNamePatternNoWorkspace"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5848
	return pattern.format([serverType,host,workspace]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5849
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5850
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5851
config.macros.importTiddlers.saveServerTiddler = function(wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5852
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5853
	var txtSaveTiddler = wizard.getElement("txtSaveTiddler").value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5854
	if(store.tiddlerExists(txtSaveTiddler)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5855
		if(!confirm(config.macros.importTiddlers.confirmOverwriteSaveTiddler.format([txtSaveTiddler])))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5856
			return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5857
		store.suspendNotifications();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5858
		store.removeTiddler(txtSaveTiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5859
		store.resumeNotifications();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5860
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5861
	var serverType = wizard.getValue("serverType");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5862
	var host = wizard.getValue("host");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5863
	var workspace = wizard.getValue("workspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5864
	var text = config.macros.importTiddlers.serverSaveTemplate.format([serverType,host,workspace]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5865
	store.saveTiddler(txtSaveTiddler,txtSaveTiddler,text,config.macros.importTiddlers.serverSaveModifier,new Date(),["systemServer"]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5866
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5867
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5868
config.macros.importTiddlers.doImport = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5869
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5870
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5871
	if(wizard.getElement("chkSave").checked)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5872
		config.macros.importTiddlers.saveServerTiddler(wizard);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5873
	var chkSync = wizard.getElement("chkSync").checked;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5874
	wizard.setValue("sync",chkSync);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5875
	var listView = wizard.getValue("listView");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5876
	var rowNames = ListView.getSelectedRows(listView);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5877
	var adaptor = wizard.getValue("adaptor");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5878
	var overwrite = new Array();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5879
	var t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5880
	for(t=0; t<rowNames.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5881
		if(store.tiddlerExists(rowNames[t]))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5882
			overwrite.push(rowNames[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5883
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5884
	if(overwrite.length > 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5885
		if(!confirm(config.macros.importTiddlers.confirmOverwriteText.format([overwrite.join(", ")])))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5886
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5887
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5888
	wizard.addStep(config.macros.importTiddlers.step4Title.format([rowNames.length]),config.macros.importTiddlers.step4Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5889
	for(t=0; t<rowNames.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5890
		var link = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5891
		createTiddlyLink(link,rowNames[t],true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5892
		var place = wizard.getElement("markReport");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5893
		place.parentNode.insertBefore(link,place);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5894
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5895
	wizard.setValue("remainingImports",rowNames.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5896
	wizard.setButtons([
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5897
			{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5898
		],config.macros.importTiddlers.statusDoingImport);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5899
	for(t=0; t<rowNames.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5900
		var context = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5901
		context.allowSynchronous = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5902
		var inbound = adaptor.getTiddler(rowNames[t],context,wizard,config.macros.importTiddlers.onGetTiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5903
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5904
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5905
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5906
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5907
config.macros.importTiddlers.onGetTiddler = function(context,wizard)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5908
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5909
	if(!context.status)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5910
		displayMessage("Error in importTiddlers.onGetTiddler: " + context.statusText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5911
	var tiddler = context.tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5912
	store.suspendNotifications();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5913
	store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5914
	if(!wizard.getValue("sync")) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5915
		store.setValue(tiddler.title,'server',null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5916
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5917
	store.resumeNotifications();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5918
	if(!context.isSynchronous)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5919
		store.notify(tiddler.title,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5920
	var remainingImports = wizard.getValue("remainingImports")-1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5921
	wizard.setValue("remainingImports",remainingImports);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5922
	if(remainingImports == 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5923
		if(context.isSynchronous) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5924
			store.notifyAll();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5925
			refreshDisplay();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5926
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5927
		wizard.setButtons([
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5928
				{caption: config.macros.importTiddlers.doneLabel, tooltip: config.macros.importTiddlers.donePrompt, onClick: config.macros.importTiddlers.onClose}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5929
			],config.macros.importTiddlers.statusDoneImport);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5930
		autoSaveChanges();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5931
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5932
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5933
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5934
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5935
//-- Upgrade macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5936
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5937
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5938
config.macros.upgrade.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5939
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5940
	var w = new Wizard();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5941
	w.createWizard(place,this.wizardTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5942
	w.addStep(this.step1Title,this.step1Html.format([this.source,this.source]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5943
	w.setButtons([{caption: this.upgradeLabel, tooltip: this.upgradePrompt, onClick: this.onClickUpgrade}]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5944
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5945
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5946
config.macros.upgrade.onClickUpgrade = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5947
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5948
	var me = config.macros.upgrade;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5949
	var w = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5950
	if(window.location.protocol != "file:") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5951
		alert(me.errorCantUpgrade);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5952
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5953
	}	
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5954
	if(story.areAnyDirty() || store.isDirty()) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5955
		alert(me.errorNotSaved);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5956
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5957
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5958
	var localPath = getLocalPath(document.location.toString());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5959
	var backupPath = getBackupPath(localPath,me.backupExtension);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5960
	w.setValue("backupPath",backupPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5961
	w.setButtons([],me.statusPreparingBackup);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5962
	var original = loadOriginal(localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5963
	w.setButtons([],me.statusSavingBackup);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5964
	var backup = config.browser.isIE ? ieCopyFile(backupPath,localPath) : saveFile(backupPath,original);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5965
	if(backup != true) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5966
		w.setButtons([],me.errorSavingBackup);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5967
		alert(me.errorSavingBackup);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5968
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5969
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5970
	w.setButtons([],me.statusLoadingCore);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5971
	var load = loadRemoteFile(me.source,me.onLoadCore,w);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5972
	if(typeof load == "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5973
		w.setButtons([],me.errorLoadingCore);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5974
		alert(me.errorLoadingCore);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5975
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5976
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5977
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5978
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5979
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5980
config.macros.upgrade.onLoadCore = function(status,params,responseText,url,xhr)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5981
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5982
	var me = config.macros.upgrade;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5983
	var w = params;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5984
	var errMsg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5985
	if(!status)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5986
		errMsg = me.errorLoadingCore;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5987
	var newVer = me.extractVersion(responseText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5988
	if(!newVer)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5989
		errMsg = me.errorCoreFormat;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5990
	if(errMsg) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5991
		w.setButtons([],errMsg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5992
		alert(errMsg);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5993
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5994
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5995
	var onStartUpgrade = function(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5996
		w.setButtons([],me.statusSavingCore);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5997
		var localPath = getLocalPath(document.location.toString());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5998
		saveFile(localPath,responseText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  5999
		w.setButtons([],me.statusReloadingCore);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6000
		var backupPath = w.getValue("backupPath");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6001
		var newLoc = document.location.toString() + '?time=' + new Date().convertToYYYYMMDDHHMM()  + '#upgrade:[[' + encodeURI(backupPath) + ']]';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6002
		window.setTimeout(function () {window.location = newLoc;},10)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6003
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6004
	var step2 = [me.step2Html_downgrade,me.step2Html_restore,me.step2Html_upgrade][compareVersions(version,newVer) + 1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6005
	w.addStep(me.step2Title,step2.format([formatVersion(newVer),formatVersion(version)]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6006
	w.setButtons([{caption: me.startLabel, tooltip: me.startPrompt, onClick: onStartUpgrade},{caption: me.cancelLabel, tooltip: me.cancelPrompt, onClick: me.onCancel}]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6007
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6008
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6009
config.macros.upgrade.onCancel = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6010
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6011
	var me = config.macros.upgrade;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6012
	var w = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6013
	w.addStep(me.step3Title,me.step3Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6014
	w.setButtons([]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6015
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6016
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6017
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6018
config.macros.upgrade.extractVersion = function(upgradeFile)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6019
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6020
	var re = /^var version = \{title: "([^"]+)", major: (\d+), minor: (\d+), revision: (\d+)(, beta: (\d+)){0,1}, date: new Date\("([^"]+)"\)/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6021
	var m = re.exec(upgradeFile);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6022
	return  m ? {title: m[1], major: m[2], minor: m[3], revision: m[4], beta: m[6], date: new Date(m[7])} : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6023
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6024
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6025
function upgradeFrom(path)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6026
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6027
	var importStore = new TiddlyWiki();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6028
	var tw = loadFile(path);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6029
	if(window.netscape !== undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6030
		tw = convertUTF8ToUnicode(tw);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6031
	importStore.importTiddlyWiki(tw);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6032
	importStore.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6033
		if(!store.getTiddler(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6034
			store.addTiddler(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6035
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6036
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6037
	refreshDisplay();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6038
	saveChanges(); //# To create appropriate Markup* sections
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6039
	alert(config.messages.upgradeDone.format([formatVersion()]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6040
	window.location = window.location.toString().substr(0,window.location.toString().lastIndexOf('?'));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6041
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6042
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6043
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6044
//-- Sync macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6045
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6046
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6047
// Synchronisation handlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6048
config.syncers = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6049
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6050
// Sync state.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6051
var currSync = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6052
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6053
// sync macro
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6054
config.macros.sync.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6055
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6056
	if(!wikifier.isStatic)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6057
		this.startSync(place);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6058
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6059
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6060
config.macros.sync.startSync = function(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6061
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6062
	if(currSync)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6063
		config.macros.sync.cancelSync();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6064
	currSync = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6065
	currSync.syncList = this.getSyncableTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6066
	this.createSyncTasks();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6067
	this.preProcessSyncableTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6068
	var wizard = new Wizard();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6069
	currSync.wizard = wizard;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6070
	wizard.createWizard(place,this.wizardTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6071
	wizard.addStep(this.step1Title,this.step1Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6072
	var markList = wizard.getElement("markList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6073
	var listWrapper = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6074
	markList.parentNode.insertBefore(listWrapper,markList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6075
	currSync.listView = ListView.create(listWrapper,currSync.syncList,this.listViewTemplate);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6076
	this.processSyncableTiddlers();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6077
	wizard.setButtons([
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6078
			{caption: this.syncLabel, tooltip: this.syncPrompt, onClick: this.doSync}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6079
		]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6080
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6081
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6082
config.macros.sync.getSyncableTiddlers = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6083
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6084
	var list = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6085
	store.forEachTiddler(function(title,tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6086
		var syncItem = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6087
		syncItem.serverType = tiddler.getServerType();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6088
		syncItem.serverHost = tiddler.fields['server.host'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6089
		syncItem.serverWorkspace = tiddler.fields['server.workspace'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6090
		syncItem.tiddler = tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6091
		syncItem.title = tiddler.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6092
		syncItem.isTouched = tiddler.isTouched();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6093
		syncItem.selected = syncItem.isTouched;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6094
		syncItem.syncStatus = config.macros.sync.syncStatusList[syncItem.isTouched ? "changedLocally" : "none"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6095
		syncItem.status = syncItem.syncStatus.text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6096
		if(syncItem.serverType && syncItem.serverHost)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6097
			list.push(syncItem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6098
		});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6099
	list.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6100
	return list;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6101
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6102
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6103
config.macros.sync.preProcessSyncableTiddlers = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6104
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6105
	for(var t=0; t<currSync.syncList.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6106
		si = currSync.syncList[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6107
		var ti = si.syncTask.syncMachine.generateTiddlerInfo(si.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6108
		si.serverUrl = ti.uri;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6109
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6110
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6111
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6112
config.macros.sync.processSyncableTiddlers = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6113
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6114
	for(var t=0; t<currSync.syncList.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6115
		si = currSync.syncList[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6116
		si.rowElement.style.backgroundColor = si.syncStatus.color;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6117
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6118
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6119
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6120
config.macros.sync.createSyncTasks = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6121
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6122
	currSync.syncTasks = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6123
	for(var t=0; t<currSync.syncList.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6124
		var si = currSync.syncList[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6125
		var r = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6126
		for(var st=0; st<currSync.syncTasks.length; st++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6127
			var cst = currSync.syncTasks[st];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6128
			if(si.serverType == cst.serverType && si.serverHost == cst.serverHost && si.serverWorkspace == cst.serverWorkspace)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6129
				r = cst;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6130
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6131
		if(r == null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6132
			si.syncTask = this.createSyncTask(si);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6133
			currSync.syncTasks.push(si.syncTask);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6134
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6135
			si.syncTask = r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6136
			r.syncItems.push(si);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6137
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6138
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6139
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6140
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6141
config.macros.sync.createSyncTask = function(syncItem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6142
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6143
	var st = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6144
	st.serverType = syncItem.serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6145
	st.serverHost = syncItem.serverHost;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6146
	st.serverWorkspace = syncItem.serverWorkspace;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6147
	st.syncItems = [syncItem];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6148
	st.syncMachine = new SyncMachine(st.serverType,{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6149
		start: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6150
			return this.openHost(st.serverHost,"openWorkspace");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6151
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6152
		openWorkspace: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6153
			return this.openWorkspace(st.serverWorkspace,"getTiddlerList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6154
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6155
		getTiddlerList: function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6156
			return this.getTiddlerList("onGetTiddlerList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6157
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6158
		onGetTiddlerList: function(context) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6159
			var tiddlers = context.tiddlers;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6160
			for(var t=0; t<st.syncItems.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6161
				var si = st.syncItems[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6162
				var f = tiddlers.findByField("title",si.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6163
				if(f !== null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6164
					if(tiddlers[f].fields['server.page.revision'] > si.tiddler.fields['server.page.revision']) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6165
						si.syncStatus = config.macros.sync.syncStatusList[si.isTouched ? 'changedBoth' : 'changedServer'];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6166
					}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6167
				} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6168
					si.syncStatus = config.macros.sync.syncStatusList.notFound;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6169
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6170
				config.macros.sync.updateSyncStatus(si);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6171
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6172
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6173
		getTiddler: function(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6174
			return this.getTiddler(title,"onGetTiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6175
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6176
		onGetTiddler: function(context) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6177
			var tiddler = context.tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6178
			var syncItem = st.syncItems.findByField("title",tiddler.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6179
			if(syncItem !== null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6180
				syncItem = st.syncItems[syncItem];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6181
				store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6182
				syncItem.syncStatus = config.macros.sync.syncStatusList.gotFromServer;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6183
				config.macros.sync.updateSyncStatus(syncItem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6184
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6185
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6186
		putTiddler: function(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6187
			return this.putTiddler(tiddler,"onPutTiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6188
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6189
		onPutTiddler: function(context) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6190
			var title = context.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6191
			var syncItem = st.syncItems.findByField("title",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6192
			if(syncItem !== null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6193
				syncItem = st.syncItems[syncItem];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6194
				store.resetTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6195
				syncItem.syncStatus = config.macros.sync.syncStatusList.putToServer;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6196
				config.macros.sync.updateSyncStatus(syncItem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6197
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6198
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6199
	});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6200
	st.syncMachine.go();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6201
	return st;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6202
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6203
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6204
config.macros.sync.updateSyncStatus = function(syncItem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6205
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6206
	var e = syncItem.colElements["status"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6207
	removeChildren(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6208
	createTiddlyText(e,syncItem.syncStatus.text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6209
	syncItem.rowElement.style.backgroundColor = syncItem.syncStatus.color;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6210
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6211
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6212
config.macros.sync.doSync = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6213
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6214
	var rowNames = ListView.getSelectedRows(currSync.listView);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6215
	for(var t=0; t<currSync.syncList.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6216
		var si = currSync.syncList[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6217
		if(rowNames.indexOf(si.title) != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6218
			config.macros.sync.doSyncItem(si);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6219
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6220
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6221
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6222
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6223
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6224
config.macros.sync.doSyncItem = function(syncItem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6225
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6226
	var r = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6227
	var sl = config.macros.sync.syncStatusList;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6228
	switch(syncItem.syncStatus) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6229
		case sl.changedServer:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6230
			r = syncItem.syncTask.syncMachine.go("getTiddler",syncItem.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6231
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6232
		case sl.notFound:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6233
		case sl.changedLocally:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6234
		case sl.changedBoth:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6235
			r = syncItem.syncTask.syncMachine.go("putTiddler",syncItem.tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6236
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6237
		default:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6238
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6239
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6240
	if(r !== true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6241
		displayMessage("Error in doSyncItem: " + r);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6242
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6243
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6244
config.macros.sync.cancelSync = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6245
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6246
	currSync = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6247
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6248
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6249
function SyncMachine(serverType,steps)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6250
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6251
	this.serverType = serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6252
	this.adaptor = new config.adaptors[serverType];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6253
	this.steps = steps;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6254
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6255
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6256
SyncMachine.prototype.go = function(step,context)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6257
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6258
	var r = context ? context.status : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6259
	if(typeof r == "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6260
		this.invokeError(r);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6261
		return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6262
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6263
	var h = this.steps[step ? step : "start"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6264
	if(!h)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6265
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6266
	r = h.call(this,context);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6267
	if(typeof r == "string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6268
		this.invokeError(r);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6269
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6270
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6271
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6272
SyncMachine.prototype.invokeError = function(message)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6273
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6274
	if(this.steps.error)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6275
		this.steps.error(message);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6276
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6277
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6278
SyncMachine.prototype.openHost = function(host,nextStep)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6279
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6280
	var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6281
	return me.adaptor.openHost(host,null,null,function(context) {me.go(nextStep,context);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6282
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6283
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6284
SyncMachine.prototype.getWorkspaceList = function(nextStep)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6285
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6286
	var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6287
	return me.adaptor.getWorkspaceList(null,null,function(context) {me.go(nextStep,context);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6288
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6289
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6290
SyncMachine.prototype.openWorkspace = function(workspace,nextStep)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6291
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6292
	var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6293
	return me.adaptor.openWorkspace(workspace,null,null,function(context) {me.go(nextStep,context);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6294
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6295
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6296
SyncMachine.prototype.getTiddlerList = function(nextStep)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6297
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6298
	var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6299
	return me.adaptor.getTiddlerList(null,null,function(context) {me.go(nextStep,context);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6300
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6301
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6302
SyncMachine.prototype.generateTiddlerInfo = function(tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6303
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6304
	return this.adaptor.generateTiddlerInfo(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6305
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6306
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6307
SyncMachine.prototype.getTiddler = function(title,nextStep)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6308
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6309
	var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6310
	return me.adaptor.getTiddler(title,null,null,function(context) {me.go(nextStep,context);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6311
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6312
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6313
SyncMachine.prototype.putTiddler = function(tiddler,nextStep)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6314
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6315
	var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6316
	return me.adaptor.putTiddler(tiddler,null,null,function(context) {me.go(nextStep,context);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6317
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6318
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6319
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6320
//-- Manager UI for groups of tiddlers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6321
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6322
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6323
config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6324
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6325
	var wizard = new Wizard();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6326
	wizard.createWizard(place,this.wizardTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6327
	wizard.addStep(this.step1Title,this.step1Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6328
	var markList = wizard.getElement("markList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6329
	var listWrapper = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6330
	markList.parentNode.insertBefore(listWrapper,markList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6331
	listWrapper.setAttribute("refresh","macro");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6332
	listWrapper.setAttribute("macroName","plugins");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6333
	listWrapper.setAttribute("params",paramString);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6334
	this.refresh(listWrapper,paramString);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6335
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6336
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6337
config.macros.plugins.refresh = function(listWrapper,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6338
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6339
	var wizard = new Wizard(listWrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6340
	var selectedRows = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6341
	ListView.forEachSelector(listWrapper,function(e,rowName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6342
			if(e.checked)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6343
				selectedRows.push(e.getAttribute("rowName"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6344
		});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6345
	removeChildren(listWrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6346
	params = params.parseParams("anon");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6347
	var plugins = installedPlugins.slice(0);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6348
	var t,tiddler,p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6349
	var configTiddlers = store.getTaggedTiddlers("systemConfig");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6350
	for(t=0; t<configTiddlers.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6351
		tiddler = configTiddlers[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6352
		if(plugins.findByField("title",tiddler.title) == null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6353
			p = getPluginInfo(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6354
			p.executed = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6355
			p.log.splice(0,0,this.skippedText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6356
			plugins.push(p);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6357
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6358
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6359
	for(t=0; t<plugins.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6360
		p = plugins[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6361
		p.size = p.tiddler.text ? p.tiddler.text.length : 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6362
		p.forced = p.tiddler.isTagged("systemConfigForce");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6363
		p.disabled = p.tiddler.isTagged("systemConfigDisable");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6364
		p.Selected = selectedRows.indexOf(plugins[t].title) != -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6365
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6366
	if(plugins.length == 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6367
		createTiddlyElement(listWrapper,"em",null,null,this.noPluginText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6368
		wizard.setButtons([]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6369
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6370
		var listView = ListView.create(listWrapper,plugins,this.listViewTemplate,this.onSelectCommand);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6371
		wizard.setValue("listView",listView);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6372
		wizard.setButtons([
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6373
				{caption: config.macros.plugins.removeLabel, tooltip: config.macros.plugins.removePrompt, onClick:  config.macros.plugins.doRemoveTag},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6374
				{caption: config.macros.plugins.deleteLabel, tooltip: config.macros.plugins.deletePrompt, onClick:  config.macros.plugins.doDelete}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6375
			]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6376
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6377
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6378
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6379
config.macros.plugins.doRemoveTag = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6380
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6381
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6382
	var listView = wizard.getValue("listView");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6383
	var rowNames = ListView.getSelectedRows(listView);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6384
	if(rowNames.length == 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6385
		alert(config.messages.nothingSelected);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6386
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6387
		for(var t=0; t<rowNames.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6388
			store.setTiddlerTag(rowNames[t],false,"systemConfig");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6389
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6390
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6391
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6392
config.macros.plugins.doDelete = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6393
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6394
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6395
	var listView = wizard.getValue("listView");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6396
	var rowNames = ListView.getSelectedRows(listView);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6397
	if(rowNames.length == 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6398
		alert(config.messages.nothingSelected);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6399
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6400
		if(confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")]))) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6401
			for(t=0; t<rowNames.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6402
				store.removeTiddler(rowNames[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6403
				story.closeTiddler(rowNames[t],true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6404
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6405
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6406
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6407
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6408
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6409
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6410
//-- Message area
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6411
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6412
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6413
function getMessageDiv()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6414
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6415
	var msgArea = document.getElementById("messageArea");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6416
	if(!msgArea)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6417
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6418
	if(!msgArea.hasChildNodes())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6419
		createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6420
			config.messages.messageClose.text,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6421
			config.messages.messageClose.tooltip,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6422
			clearMessage);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6423
	msgArea.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6424
	return createTiddlyElement(msgArea,"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6425
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6426
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6427
function displayMessage(text,linkText)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6428
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6429
	var e = getMessageDiv();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6430
	if(!e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6431
		alert(text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6432
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6433
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6434
	if(linkText) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6435
		var link = createTiddlyElement(e,"a",null,null,text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6436
		link.href = linkText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6437
		link.target = "_blank";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6438
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6439
		e.appendChild(document.createTextNode(text));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6440
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6441
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6442
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6443
function clearMessage()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6444
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6445
	var msgArea = document.getElementById("messageArea");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6446
	if(msgArea) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6447
		removeChildren(msgArea);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6448
		msgArea.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6449
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6450
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6451
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6452
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6453
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6454
//-- Refresh mechanism
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6455
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6456
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6457
config.refreshers = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6458
	link: function(e,changeList)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6459
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6460
		var title = e.getAttribute("tiddlyLink");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6461
		refreshTiddlyLink(e,title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6462
		return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6463
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6464
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6465
	tiddler: function(e,changeList)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6466
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6467
		var title = e.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6468
		var template = e.getAttribute("template");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6469
		if(changeList && changeList.indexOf(title) != -1 && !story.isDirty(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6470
			story.refreshTiddler(title,template,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6471
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6472
			refreshElements(e,changeList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6473
		return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6474
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6475
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6476
	content: function(e,changeList)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6477
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6478
		var title = e.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6479
		var force = e.getAttribute("force");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6480
		if(force != null || changeList == null || changeList.indexOf(title) != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6481
			removeChildren(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6482
			wikify(store.getTiddlerText(title,title),e,null,store.fetchTiddler(title));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6483
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6484
		} else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6485
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6486
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6487
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6488
	macro: function(e,changeList)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6489
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6490
		var macro = e.getAttribute("macroName");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6491
		var params = e.getAttribute("params");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6492
		if(macro)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6493
			macro = config.macros[macro];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6494
		if(macro && macro.refresh)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6495
			macro.refresh(e,params);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6496
		return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6497
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6498
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6499
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6500
config.refresherData = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6501
	styleSheet: "StyleSheet",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6502
	defaultStyleSheet: "StyleSheet",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6503
	pageTemplate: "PageTemplate",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6504
	defaultPageTemplate: "PageTemplate",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6505
	colorPalette: "ColorPalette",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6506
	defaultColorPalette: "ColorPalette"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6507
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6508
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6509
function refreshElements(root,changeList)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6510
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6511
	var nodes = root.childNodes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6512
	for(var c=0; c<nodes.length; c++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6513
		var e = nodes[c], type = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6514
		if(e.getAttribute  && (e.tagName ? e.tagName != "IFRAME" : true))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6515
			type = e.getAttribute("refresh");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6516
		var refresher = config.refreshers[type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6517
		var refreshed = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6518
		if(refresher != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6519
			refreshed = refresher(e,changeList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6520
		if(e.hasChildNodes() && !refreshed)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6521
			refreshElements(e,changeList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6522
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6523
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6524
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6525
function applyHtmlMacros(root,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6526
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6527
	var e = root.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6528
	while(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6529
		var nextChild = e.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6530
		if(e.getAttribute) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6531
			var macro = e.getAttribute("macro");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6532
			if(macro) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6533
				var params = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6534
				var p = macro.indexOf(" ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6535
				if(p != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6536
					params = macro.substr(p+1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6537
					macro = macro.substr(0,p);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6538
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6539
				invokeMacro(e,macro,params,null,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6540
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6541
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6542
		if(e.hasChildNodes())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6543
			applyHtmlMacros(e,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6544
		e = nextChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6545
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6546
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6547
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6548
function refreshPageTemplate(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6549
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6550
	var stash = createTiddlyElement(document.body,"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6551
	stash.style.display = "none";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6552
	var display = story.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6553
	var nodes,t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6554
	if(display) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6555
		nodes = display.childNodes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6556
		for(t=nodes.length-1; t>=0; t--)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6557
			stash.appendChild(nodes[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6558
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6559
	var wrapper = document.getElementById("contentWrapper");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6560
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6561
	isAvailable = function(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6562
		var s = title ? title.indexOf(config.textPrimitives.sectionSeparator) : -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6563
		if(s!=-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6564
			title = title.substr(0,s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6565
		return store.tiddlerExists(title) || store.isShadowTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6566
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6567
	if(!title || !isAvailable(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6568
		title = config.refresherData.pageTemplate;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6569
	if(!isAvailable(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6570
		title = config.refresherData.defaultPageTemplate; //# this one is always avaialable
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6571
	html = store.getRecursiveTiddlerText(title,null,10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6572
	wrapper.innerHTML = html;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6573
	applyHtmlMacros(wrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6574
	refreshElements(wrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6575
	display = story.getContainer();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6576
	removeChildren(display);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6577
	if(!display)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6578
		display = createTiddlyElement(wrapper,"div",story.containerId());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6579
	nodes = stash.childNodes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6580
	for(t=nodes.length-1; t>=0; t--)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6581
		display.appendChild(nodes[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6582
	removeNode(stash);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6583
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6584
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6585
function refreshDisplay(hint)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6586
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6587
	if(typeof hint == "string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6588
		hint = [hint];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6589
	var e = document.getElementById("contentWrapper");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6590
	refreshElements(e,hint);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6591
	if(backstage.isPanelVisible()) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6592
		e = document.getElementById("backstage");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6593
		refreshElements(e,hint);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6594
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6595
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6596
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6597
function refreshPageTitle()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6598
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6599
	document.title = getPageTitle();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6600
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6601
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6602
function getPageTitle()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6603
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6604
	var st = wikifyPlain("SiteTitle");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6605
	var ss = wikifyPlain("SiteSubtitle");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6606
	return st + ((st == "" || ss == "") ? "" : " - ") + ss;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6607
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6608
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6609
function refreshStyles(title,doc)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6610
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6611
	setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title,doc ? doc : document);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6612
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6613
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6614
function refreshColorPalette(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6615
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6616
	if(!startingUp)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6617
		refreshAll();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6618
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6619
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6620
function refreshAll()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6621
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6622
	refreshPageTemplate();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6623
	refreshDisplay();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6624
	refreshStyles("StyleSheetLayout");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6625
	refreshStyles("StyleSheetColors");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6626
	refreshStyles(config.refresherData.styleSheet);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6627
	refreshStyles("StyleSheetPrint");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6628
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6629
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6630
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6631
//-- Options stuff
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6632
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6633
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6634
config.optionHandlers = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6635
	'txt': {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6636
		get: function(name) {return encodeCookie(config.options[name].toString());},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6637
		set: function(name,value) {config.options[name] = decodeCookie(value);}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6638
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6639
	'chk': {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6640
		get: function(name) {return config.options[name] ? "true" : "false";},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6641
		set: function(name,value) {config.options[name] = value == "true";}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6642
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6643
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6644
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6645
function loadOptionsCookie()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6646
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6647
	if(safeMode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6648
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6649
	var cookies = document.cookie.split(";");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6650
	for(var c=0; c<cookies.length; c++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6651
		var p = cookies[c].indexOf("=");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6652
		if(p != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6653
			var name = cookies[c].substr(0,p).trim();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6654
			var value = cookies[c].substr(p+1).trim();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6655
			var optType = name.substr(0,3);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6656
			if(config.optionHandlers[optType] && config.optionHandlers[optType].set)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6657
				config.optionHandlers[optType].set(name,value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6658
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6659
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6660
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6661
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6662
function saveOptionCookie(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6663
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6664
	if(safeMode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6665
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6666
	var c = name + "=";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6667
	var optType = name.substr(0,3);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6668
	if(config.optionHandlers[optType] && config.optionHandlers[optType].get)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6669
		c += config.optionHandlers[optType].get(name);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6670
	c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6671
	document.cookie = c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6672
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6673
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6674
function encodeCookie(s)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6675
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6676
	return escape(manualConvertUnicodeToUTF8(s));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6677
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6678
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6679
function decodeCookie(s)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6680
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6681
	s = unescape(s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6682
	var re = /&#[0-9]{1,5};/g;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6683
	return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6684
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6685
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6686
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6687
config.macros.option.genericCreate = function(place,type,opt,className,desc)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6688
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6689
	var typeInfo = config.macros.option.types[type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6690
	var c = document.createElement(typeInfo.elementType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6691
	if(typeInfo.typeValue)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6692
		c.setAttribute("type",typeInfo.typeValue);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6693
	c[typeInfo.eventName] = typeInfo.onChange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6694
	c.setAttribute("option",opt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6695
	if(className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6696
		c.className = className;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6697
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6698
		c.className = typeInfo.className;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6699
	if(config.optionsDesc[opt])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6700
		c.setAttribute("title",config.optionsDesc[opt]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6701
	place.appendChild(c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6702
	if(desc != "no")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6703
		createTiddlyText(place,config.optionsDesc[opt] ? config.optionsDesc[opt] : opt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6704
	c[typeInfo.valueField] = config.options[opt];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6705
	return c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6706
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6707
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6708
config.macros.option.genericOnChange = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6709
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6710
	var opt = this.getAttribute("option");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6711
	if(opt) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6712
		var optType = opt.substr(0,3);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6713
		var handler = config.macros.option.types[optType];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6714
		if(handler.elementType && handler.valueField)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6715
			config.macros.option.propagateOption(opt,handler.valueField,this[handler.valueField],handler.elementType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6716
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6717
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6718
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6719
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6720
config.macros.option.types = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6721
	'txt': {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6722
		elementType: "input",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6723
		valueField: "value",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6724
		eventName: "onkeyup",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6725
		className: "txtOptionInput",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6726
		create: config.macros.option.genericCreate,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6727
		onChange: config.macros.option.genericOnChange
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6728
	},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6729
	'chk': {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6730
		elementType: "input",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6731
		valueField: "checked",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6732
		eventName: "onclick",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6733
		className: "chkOptionInput",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6734
		typeValue: "checkbox",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6735
		create: config.macros.option.genericCreate,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6736
		onChange: config.macros.option.genericOnChange
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6737
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6738
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6739
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6740
config.macros.option.propagateOption = function(opt,valueField,value,elementType)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6741
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6742
	config.options[opt] = value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6743
	saveOptionCookie(opt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6744
	var nodes = document.getElementsByTagName(elementType);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6745
	for(var t=0; t<nodes.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6746
		var optNode = nodes[t].getAttribute("option");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6747
		if(opt == optNode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6748
			nodes[t][valueField] = value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6749
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6750
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6751
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6752
config.macros.option.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6753
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6754
	params = paramString.parseParams("anon",null,true,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6755
	var opt = (params[1] && params[1].name == "anon") ? params[1].value : getParam(params,"name",null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6756
	var className = (params[2] && params[2].name == "anon") ? params[2].value : getParam(params,"class",null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6757
	var desc = getParam(params,"desc","no");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6758
	var type = opt.substr(0,3);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6759
	var h = config.macros.option.types[type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6760
	if(h && h.create)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6761
		h.create(place,type,opt,className,desc);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6762
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6763
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6764
config.macros.options.handler = function(place,macroName,params,wikifier,paramString,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6765
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6766
	params = paramString.parseParams("anon",null,true,false,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6767
	var showUnknown = getParam(params,"showUnknown","no");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6768
	var wizard = new Wizard();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6769
	wizard.createWizard(place,this.wizardTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6770
	wizard.addStep(this.step1Title,this.step1Html);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6771
	var markList = wizard.getElement("markList");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6772
	var chkUnknown = wizard.getElement("chkUnknown");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6773
	chkUnknown.checked = showUnknown == "yes";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6774
	chkUnknown.onchange = this.onChangeUnknown;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6775
	var listWrapper = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6776
	markList.parentNode.insertBefore(listWrapper,markList);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6777
	wizard.setValue("listWrapper",listWrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6778
	this.refreshOptions(listWrapper,showUnknown == "yes");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6779
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6780
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6781
config.macros.options.refreshOptions = function(listWrapper,showUnknown)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6782
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6783
	var opts = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6784
	for(var n in config.options) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6785
		var opt = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6786
		opt.option = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6787
		opt.name = n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6788
		opt.lowlight = !config.optionsDesc[n];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6789
		opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6790
		if(!opt.lowlight || showUnknown)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6791
			opts.push(opt);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6792
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6793
	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);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6794
	var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6795
	for(n=0; n<opts.length; n++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6796
		var type = opts[n].name.substr(0,3);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6797
		var h = config.macros.option.types[type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6798
		if(h && h.create) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6799
			h.create(opts[n].colElements['option'],type,opts[n].name,null,"no");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6800
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6801
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6802
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6803
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6804
config.macros.options.onChangeUnknown = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6805
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6806
	var wizard = new Wizard(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6807
	var listWrapper = wizard.getValue("listWrapper");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6808
	removeChildren(listWrapper);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6809
	config.macros.options.refreshOptions(listWrapper,this.checked);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6810
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6811
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6812
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6813
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6814
//-- Saving
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6815
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6816
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6817
var saveUsingSafari = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6818
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6819
var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6820
var endSaveArea = '</d' + 'iv>';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6821
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6822
// If there are unsaved changes, force the user to confirm before exitting
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6823
function confirmExit()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6824
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6825
	hadConfirmExit = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6826
	if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty()))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6827
		return config.messages.confirmExit;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6828
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6829
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6830
// Give the user a chance to save changes before exitting
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6831
function checkUnsavedChanges()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6832
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6833
	if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6834
		if(confirm(config.messages.unsavedChangesWarning))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6835
			saveChanges();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6836
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6837
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6838
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6839
function updateLanguageAttribute(s)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6840
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6841
	if(config.locale) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6842
		var mRE = /(<html(?:.*?)?)(?: xml:lang\="([a-z]+)")?(?: lang\="([a-z]+)")?>/;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6843
		var m = mRE.exec(s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6844
		if(m) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6845
			var t = m[1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6846
			if(m[2])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6847
				t += ' xml:lang="' + config.locale + '"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6848
			if(m[3])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6849
				t += ' lang="' + config.locale + '"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6850
			t += ">";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6851
			s = s.substr(0,m.index) + t + s.substr(m.index+m[0].length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6852
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6853
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6854
	return s;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6855
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6856
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6857
function updateMarkupBlock(s,blockName,tiddlerName)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6858
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6859
	return s.replaceChunk(
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6860
			"<!--%0-START-->".format([blockName]),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6861
			"<!--%0-END-->".format([blockName]),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6862
			"\n" + convertUnicodeToUTF8(store.getRecursiveTiddlerText(tiddlerName,"")) + "\n");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6863
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6864
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6865
function updateOriginal(original,posDiv)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6866
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6867
	if(!posDiv)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6868
		posDiv = locateStoreArea(original);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6869
	if(!posDiv) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6870
		alert(config.messages.invalidFileError.format([localPath]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6871
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6872
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6873
	var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6874
				convertUnicodeToUTF8(store.allTiddlersAsHtml()) + "\n" +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6875
				original.substr(posDiv[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6876
	var newSiteTitle = convertUnicodeToUTF8(getPageTitle()).htmlEncode();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6877
	revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6878
	revised = updateLanguageAttribute(revised);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6879
	revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6880
	revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6881
	revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6882
	revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6883
	return revised;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6884
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6885
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6886
function locateStoreArea(original)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6887
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6888
	// Locate the storeArea div's
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6889
	var posOpeningDiv = original.indexOf(startSaveArea);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6890
	var limitClosingDiv = original.indexOf("<"+"!--POST-STOREAREA--"+">");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6891
	if(limitClosingDiv == -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6892
		limitClosingDiv = original.indexOf("<"+"!--POST-BODY-START--"+">");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6893
	var posClosingDiv = original.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? original.length : limitClosingDiv);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6894
	return (posOpeningDiv != -1 && posClosingDiv != -1) ? [posOpeningDiv,posClosingDiv] : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6895
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6896
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6897
function autoSaveChanges(onlyIfDirty,tiddlers)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6898
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6899
	if(config.options.chkAutoSave)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6900
		saveChanges(onlyIfDirty,tiddlers);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6901
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6902
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6903
function loadOriginal(localPath)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6904
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6905
	return loadFile(localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6906
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6907
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6908
// Save this tiddlywiki with the pending changes
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6909
function saveChanges(onlyIfDirty,tiddlers)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6910
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6911
	if(onlyIfDirty && !store.isDirty())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6912
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6913
	clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6914
	var t0 = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6915
	var originalPath = document.location.toString();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6916
	if(originalPath.substr(0,5) != "file:") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6917
		alert(config.messages.notFileUrlError);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6918
		if(store.tiddlerExists(config.messages.saveInstructions))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6919
			story.displayTiddler(null,config.messages.saveInstructions);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6920
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6921
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6922
	var localPath = getLocalPath(originalPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6923
	var original = loadOriginal(localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6924
	if(original == null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6925
		alert(config.messages.cantSaveError);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6926
		if(store.tiddlerExists(config.messages.saveInstructions))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6927
			story.displayTiddler(null,config.messages.saveInstructions);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6928
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6929
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6930
	var posDiv = locateStoreArea(original);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6931
	if(!posDiv) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6932
		alert(config.messages.invalidFileError.format([localPath]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6933
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6934
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6935
	saveMain(localPath,original,posDiv);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6936
	if(config.options.chkSaveBackups)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6937
		saveBackup(localPath,original);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6938
	if(config.options.chkSaveEmptyTemplate)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6939
		saveEmpty(localPath,original,posDiv);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6940
	if(config.options.chkGenerateAnRssFeed)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6941
		saveRss(localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6942
	if(config.options.chkDisplayInstrumentation)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6943
		displayMessage("saveChanges " + (new Date()-t0) + " ms");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6944
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6945
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6946
function saveMain(localPath,original,posDiv)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6947
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6948
	var save;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6949
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6950
		var revised = updateOriginal(original,posDiv);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6951
		save = saveFile(localPath,revised);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6952
	} catch (ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6953
		showException(ex);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6954
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6955
	if(save) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6956
		displayMessage(config.messages.mainSaved,"file://" + localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6957
		store.setDirty(false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6958
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6959
		alert(config.messages.mainFailed);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6960
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6961
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6962
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6963
function saveBackup(localPath,original)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6964
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6965
	var backupPath = getBackupPath(localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6966
	var backup = copyFile(backupPath,localPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6967
	if(!backup)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6968
		backup = saveFile(backupPath,original);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6969
	if(backup)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6970
		displayMessage(config.messages.backupSaved,"file://" + backupPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6971
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6972
		alert(config.messages.backupFailed);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6973
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6974
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6975
function saveEmpty(localPath,original,posDiv)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6976
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6977
	var emptyPath,p;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6978
	if((p = localPath.lastIndexOf("/")) != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6979
		emptyPath = localPath.substr(0,p) + "/";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6980
	else if((p = localPath.lastIndexOf("\\")) != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6981
		emptyPath = localPath.substr(0,p) + "\\";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6982
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6983
		emptyPath = localPath + ".";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6984
	emptyPath += "empty.html";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6985
	var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6986
	var emptySave = saveFile(emptyPath,empty);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6987
	if(emptySave)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6988
		displayMessage(config.messages.emptySaved,"file://" + emptyPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6989
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6990
		alert(config.messages.emptyFailed);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6991
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6992
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6993
function saveRss(localPath)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6994
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6995
	var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6996
	if(saveFile(rssPath,convertUnicodeToUTF8(generateRss())))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6997
		displayMessage(config.messages.rssSaved,"file://" + rssPath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6998
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  6999
		alert(config.messages.rssFailed);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7000
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7001
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7002
function getLocalPath(origPath)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7003
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7004
	var originalPath = convertUriToUTF8(origPath,config.options.txtFileSystemCharSet);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7005
	// Remove any location or query part of the URL
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7006
	var argPos = originalPath.indexOf("?");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7007
	if(argPos != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7008
		originalPath = originalPath.substr(0,argPos);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7009
	var hashPos = originalPath.indexOf("#");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7010
	if(hashPos != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7011
		originalPath = originalPath.substr(0,hashPos);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7012
	// Convert file://localhost/ to file:///
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7013
	if(originalPath.indexOf("file://localhost/") == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7014
		originalPath = "file://" + originalPath.substr(16);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7015
	// Convert to a native file format
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7016
	var localPath;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7017
	if(originalPath.charAt(9) == ":") // pc local file
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7018
		localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7019
	else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7020
		localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7021
	else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7022
		localPath = unescape(originalPath.substr(7));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7023
	else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7024
		localPath = unescape(originalPath.substr(5));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7025
	else // pc network file
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7026
		localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7027
	return localPath;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7028
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7029
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7030
function getBackupPath(localPath,title,extension)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7031
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7032
	var slash = "\\";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7033
	var dirPathPos = localPath.lastIndexOf("\\");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7034
	if(dirPathPos == -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7035
		dirPathPos = localPath.lastIndexOf("/");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7036
		slash = "/";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7037
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7038
	var backupFolder = config.options.txtBackupFolder;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7039
	if(!backupFolder || backupFolder == "")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7040
		backupFolder = ".";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7041
	var backupPath = localPath.substr(0,dirPathPos) + slash + backupFolder + localPath.substr(dirPathPos);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7042
	backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + ".";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7043
	if(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7044
		backupPath += title.replace(/[\\\/\*\?\":<> ]/g,"_") + ".";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7045
	backupPath += (new Date()).convertToYYYYMMDDHHMMSSMMM() + "." + (extension ? extension : "html");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7046
	return backupPath;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7047
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7048
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7049
function generateRss()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7050
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7051
	var s = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7052
	var d = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7053
	var u = store.getTiddlerText("SiteUrl");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7054
	// Assemble the header
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7055
	s.push("<" + "?xml version=\"1.0\"?" + ">");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7056
	s.push("<rss version=\"2.0\">");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7057
	s.push("<channel>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7058
	s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7059
	if(u)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7060
		s.push("<link>" + u.htmlEncode() + "</link>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7061
	s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7062
	s.push("<language>en-us</language>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7063
	s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7064
	s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7065
	s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7066
	s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7067
	s.push("<generator>TiddlyWiki " + formatVersion() + "</generator>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7068
	// The body
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7069
	var tiddlers = store.getTiddlers("modified","excludeLists");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7070
	var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7071
	for(var t=tiddlers.length-1; t>=n; t--) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7072
		s.push("<item>\n" + tiddlers[t].toRssItem(u) + "\n</item>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7073
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7074
	// And footer
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7075
	s.push("</channel>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7076
	s.push("</rss>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7077
	// Save it all
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7078
	return s.join("\n");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7079
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7080
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7081
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7082
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7083
//-- Filesystem code
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7084
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7085
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7086
function convertUTF8ToUnicode(u)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7087
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7088
	return window.netscape == undefined ? manualConvertUTF8ToUnicode(u) : mozConvertUTF8ToUnicode(u);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7089
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7090
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7091
function manualConvertUTF8ToUnicode(utf)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7092
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7093
	var uni = utf;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7094
	var src = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7095
	var dst = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7096
	var b1, b2, b3;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7097
	var c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7098
	while(src < utf.length) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7099
		b1 = utf.charCodeAt(src++);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7100
		if(b1 < 0x80) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7101
			dst++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7102
		} else if(b1 < 0xE0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7103
			b2 = utf.charCodeAt(src++);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7104
			c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7105
			uni = uni.substring(0,dst++).concat(c,utf.substr(src));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7106
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7107
			b2 = utf.charCodeAt(src++);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7108
			b3 = utf.charCodeAt(src++);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7109
			c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7110
			uni = uni.substring(0,dst++).concat(c,utf.substr(src));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7111
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7112
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7113
	return uni;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7114
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7115
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7116
function mozConvertUTF8ToUnicode(u)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7117
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7118
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7119
		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7120
		var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7121
		converter.charset = "UTF-8";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7122
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7123
		return manualConvertUTF8ToUnicode(u);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7124
	} // fallback
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7125
	var s = converter.ConvertToUnicode(u);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7126
	var fin = converter.Finish();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7127
	return (fin.length > 0) ? s+fin : s;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7128
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7129
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7130
function convertUnicodeToUTF8(s)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7131
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7132
	if(window.netscape == undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7133
		return manualConvertUnicodeToUTF8(s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7134
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7135
		return mozConvertUnicodeToUTF8(s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7136
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7137
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7138
function manualConvertUnicodeToUTF8(s)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7139
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7140
	var re = /[^\u0000-\u007F]/g ;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7141
	return s.replace(re,function($0) {return "&#" + $0.charCodeAt(0).toString() + ";";});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7142
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7143
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7144
function mozConvertUnicodeToUTF8(s)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7145
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7146
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7147
		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7148
		var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7149
		converter.charset = "UTF-8";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7150
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7151
		return manualConvertUnicodeToUTF8(s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7152
	} // fallback
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7153
	var u = converter.ConvertFromUnicode(s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7154
	var fin = converter.Finish();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7155
	return fin.length > 0 ? u + fin : u;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7156
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7157
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7158
function convertUriToUTF8(uri,charSet)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7159
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7160
	if(window.netscape == undefined || charSet == undefined || charSet == "")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7161
		return uri;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7162
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7163
		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7164
		var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7165
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7166
		return uri;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7167
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7168
	return converter.convertURISpecToUTF8(uri,charSet);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7169
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7170
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7171
function copyFile(dest,source)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7172
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7173
	return config.browser.isIE ? ieCopyFile(dest,source) : false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7174
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7175
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7176
function saveFile(fileUrl,content)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7177
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7178
	var r = mozillaSaveFile(fileUrl,content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7179
	if(!r)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7180
		r = ieSaveFile(fileUrl,content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7181
	if(!r)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7182
		r = javaSaveFile(fileUrl,content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7183
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7184
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7185
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7186
function loadFile(fileUrl)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7187
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7188
	var r = mozillaLoadFile(fileUrl);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7189
	if((r == null) || (r == false))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7190
		r = ieLoadFile(fileUrl);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7191
	if((r == null) || (r == false))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7192
		r = javaLoadFile(fileUrl);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7193
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7194
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7195
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7196
function ieCreatePath(path)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7197
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7198
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7199
		var fso = new ActiveXObject("Scripting.FileSystemObject");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7200
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7201
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7202
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7203
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7204
	var pos = path.lastIndexOf("\\");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7205
	if(pos!=-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7206
		path = path.substring(0, pos+1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7207
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7208
	var scan = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7209
	scan.push(path);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7210
	var i = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7211
	do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7212
		var parent = fso.GetParentFolderName(scan[i++]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7213
		if(fso.FolderExists(parent))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7214
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7215
		scan.push(parent);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7216
	} while(true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7217
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7218
	for(i=scan.length-1;i>=0;i--) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7219
		if(!fso.FolderExists(scan[i]))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7220
			fso.CreateFolder(scan[i]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7221
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7222
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7223
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7224
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7225
// Returns null if it can't do it, false if there's an error, true if it saved OK
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7226
function ieSaveFile(filePath,content)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7227
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7228
	ieCreatePath(filePath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7229
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7230
		var fso = new ActiveXObject("Scripting.FileSystemObject");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7231
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7232
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7233
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7234
	var file = fso.OpenTextFile(filePath,2,-1,0);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7235
	file.Write(content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7236
	file.Close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7237
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7238
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7239
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7240
// Returns null if it can't do it, false if there's an error, or a string of the content if successful
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7241
function ieLoadFile(filePath)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7242
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7243
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7244
		var fso = new ActiveXObject("Scripting.FileSystemObject");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7245
		var file = fso.OpenTextFile(filePath,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7246
		var content = file.ReadAll();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7247
		file.Close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7248
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7249
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7250
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7251
	return content;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7252
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7253
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7254
function ieCopyFile(dest,source)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7255
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7256
	ieCreatePath(dest);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7257
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7258
		var fso = new ActiveXObject("Scripting.FileSystemObject");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7259
		fso.GetFile(source).Copy(dest);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7260
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7261
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7262
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7263
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7264
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7265
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7266
// Returns null if it can't do it, false if there's an error, true if it saved OK
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7267
function mozillaSaveFile(filePath,content)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7268
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7269
	if(window.Components) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7270
		try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7271
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7272
			var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7273
			file.initWithPath(filePath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7274
			if(!file.exists())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7275
				file.create(0,0664);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7276
			var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7277
			out.init(file,0x20|0x02,00004,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7278
			out.write(content,content.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7279
			out.flush();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7280
			out.close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7281
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7282
		} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7283
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7284
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7285
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7286
	return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7287
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7288
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7289
// Returns null if it can't do it, false if there's an error, or a string of the content if successful
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7290
function mozillaLoadFile(filePath)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7291
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7292
	if(window.Components) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7293
		try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7294
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7295
			var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7296
			file.initWithPath(filePath);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7297
			if(!file.exists())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7298
				return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7299
			var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7300
			inputStream.init(file,0x01,00004,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7301
			var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7302
			sInputStream.init(inputStream);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7303
			var contents = sInputStream.read(sInputStream.available());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7304
			sInputStream.close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7305
			inputStream.close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7306
			return contents;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7307
		} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7308
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7309
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7310
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7311
	return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7312
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7313
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7314
function javaUrlToFilename(url)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7315
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7316
	var f = "//localhost";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7317
	if(url.indexOf(f) == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7318
		return url.substring(f.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7319
	var i = url.indexOf(":");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7320
	if(i > 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7321
		return url.substring(i-1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7322
	return url;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7323
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7324
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7325
function javaSaveFile(filePath,content)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7326
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7327
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7328
		if(document.applets["TiddlySaver"])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7329
			return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7330
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7331
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7332
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7333
		var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath)));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7334
		s.print(content);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7335
		s.close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7336
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7337
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7338
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7339
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7340
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7341
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7342
function javaLoadFile(filePath)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7343
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7344
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7345
		if(document.applets["TiddlySaver"])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7346
			return String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8"));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7347
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7348
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7349
	var content = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7350
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7351
		var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath)));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7352
		var line;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7353
		while((line = r.readLine()) != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7354
			content.push(new String(line));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7355
		r.close();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7356
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7357
		return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7358
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7359
	return content.join("\n");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7360
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7361
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7362
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7363
//-- Server adaptor for talking to static TiddlyWiki files
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7364
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7365
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7366
function FileAdaptor()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7367
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7368
	this.host = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7369
	this.store = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7370
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7371
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7372
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7373
FileAdaptor.serverType = 'file';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7374
FileAdaptor.serverLabel = 'TiddlyWiki';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7375
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7376
FileAdaptor.prototype.setContext = function(context,userParams,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7377
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7378
	if(!context) context = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7379
	context.userParams = userParams;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7380
	if(callback) context.callback = callback;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7381
	context.adaptor = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7382
	if(!context.host)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7383
		context.host = this.host;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7384
	context.host = FileAdaptor.fullHostName(context.host);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7385
	if(!context.workspace)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7386
		context.workspace = this.workspace;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7387
	return context;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7388
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7389
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7390
FileAdaptor.fullHostName = function(host)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7391
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7392
	if(!host)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7393
		return '';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7394
	if(!host.match(/:\/\//))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7395
		host = 'http://' + host;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7396
	return host;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7397
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7398
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7399
FileAdaptor.minHostName = function(host)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7400
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7401
	return host ? host.replace(/^http:\/\//,'').replace(/\/$/,'') : '';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7402
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7403
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7404
// Open the specified host
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7405
FileAdaptor.prototype.openHost = function(host,context,userParams,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7406
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7407
	this.host = host;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7408
	context = this.setContext(context,userParams,callback);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7409
	context.status = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7410
	if(callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7411
		window.setTimeout(function() {context.callback(context,userParams);},10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7412
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7413
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7414
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7415
FileAdaptor.loadTiddlyWikiCallback = function(status,context,responseText,url,xhr)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7416
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7417
	context.status = status;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7418
	if(!status) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7419
		context.statusText = "Error reading file";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7420
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7421
		context.adaptor.store = new TiddlyWiki();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7422
		if(!context.adaptor.store.importTiddlyWiki(responseText))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7423
			context.statusText = config.messages.invalidFileError.format([url]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7424
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7425
	context.complete(context,context.userParams);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7426
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7427
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7428
// Get the list of workspaces on a given server
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7429
FileAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7430
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7431
	context = this.setContext(context,userParams,callback);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7432
	context.workspaces = [{title:"(default)"}];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7433
	context.status = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7434
	if(callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7435
		window.setTimeout(function() {callback(context,userParams);},10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7436
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7437
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7438
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7439
// Open the specified workspace
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7440
FileAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7441
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7442
	this.workspace = workspace;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7443
	context = this.setContext(context,userParams,callback);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7444
	context.status = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7445
	if(callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7446
		window.setTimeout(function() {callback(context,userParams);},10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7447
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7448
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7449
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7450
// Gets the list of tiddlers within a given workspace
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7451
FileAdaptor.prototype.getTiddlerList = function(context,userParams,callback,filter)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7452
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7453
	context = this.setContext(context,userParams,callback);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7454
	if(!context.filter)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7455
		context.filter = filter;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7456
	context.complete = FileAdaptor.getTiddlerListComplete;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7457
	if(this.store) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7458
		var ret = context.complete(context,context.userParams);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7459
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7460
		ret = loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7461
		if(typeof ret != "string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7462
			ret = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7463
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7464
	return ret;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7465
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7466
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7467
FileAdaptor.getTiddlerListComplete = function(context,userParams)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7468
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7469
	if(context.status) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7470
		if(context.filter) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7471
			context.tiddlers = context.adaptor.store.filterTiddlers(context.filter);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7472
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7473
			context.tiddlers = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7474
			context.adaptor.store.forEachTiddler(function(title,tiddler) {context.tiddlers.push(tiddler);});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7475
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7476
		for(var i=0; i<context.tiddlers.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7477
			context.tiddlers[i].fields['server.type'] = FileAdaptor.serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7478
			context.tiddlers[i].fields['server.host'] = FileAdaptor.minHostName(context.host);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7479
			context.tiddlers[i].fields['server.page.revision'] = context.tiddlers[i].modified.convertToYYYYMMDDHHMM();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7480
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7481
		context.status = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7482
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7483
	if(context.callback) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7484
		window.setTimeout(function() {context.callback(context,userParams);},10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7485
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7486
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7487
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7488
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7489
FileAdaptor.prototype.generateTiddlerInfo = function(tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7490
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7491
	var info = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7492
	info.uri = tiddler.fields['server.host'] + "#" + tiddler.title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7493
	return info;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7494
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7495
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7496
// Retrieve a tiddler from a given workspace on a given server
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7497
FileAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7498
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7499
	context = this.setContext(context,userParams,callback);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7500
	context.title = title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7501
	context.complete = FileAdaptor.getTiddlerComplete;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7502
	return context.adaptor.store ?
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7503
		context.complete(context,context.userParams) :
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7504
		loadRemoteFile(context.host,FileAdaptor.loadTiddlyWikiCallback,context);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7505
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7506
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7507
FileAdaptor.getTiddlerComplete = function(context,userParams)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7508
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7509
	var t = context.adaptor.store.fetchTiddler(context.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7510
	t.fields['server.type'] = FileAdaptor.serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7511
	t.fields['server.host'] = FileAdaptor.minHostName(context.host);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7512
	t.fields['server.page.revision'] = t.modified.convertToYYYYMMDDHHMM();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7513
	context.tiddler = t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7514
	context.status = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7515
	if(context.allowSynchronous) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7516
		context.isSynchronous = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7517
		context.callback(context,userParams);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7518
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7519
		window.setTimeout(function() {context.callback(context,userParams);},10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7520
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7521
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7522
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7523
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7524
FileAdaptor.prototype.close = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7525
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7526
	delete this.store;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7527
	this.store = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7528
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7529
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7530
config.adaptors[FileAdaptor.serverType] = FileAdaptor;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7531
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7532
config.defaultAdaptor = FileAdaptor.serverType;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7533
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7534
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7535
//-- Remote HTTP requests
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7536
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7537
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7538
function loadRemoteFile(url,callback,params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7539
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7540
	return doHttp("GET",url,null,null,null,null,callback,params,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7541
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7542
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7543
// HTTP status codes
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7544
var httpStatus = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7545
	OK: 200,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7546
	ContentCreated: 201,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7547
	NoContent: 204,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7548
	MultiStatus: 207,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7549
	Unauthorized: 401,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7550
	Forbidden: 403,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7551
	NotFound: 404,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7552
	MethodNotAllowed: 405
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7553
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7554
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7555
function doHttp(type,url,data,contentType,username,password,callback,params,headers,allowCache)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7556
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7557
	var x = getXMLHttpRequest();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7558
	if(!x)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7559
		return "Can't create XMLHttpRequest object";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7560
	x.onreadystatechange = function() {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7561
		try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7562
			var status = x.status;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7563
		} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7564
			status = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7565
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7566
		if(x.readyState == 4 && callback && (status !== undefined)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7567
			if([0, httpStatus.OK, httpStatus.ContentCreated, httpStatus.NoContent, httpStatus.MultiStatus].contains(status))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7568
				callback(true,params,x.responseText,url,x);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7569
			else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7570
				callback(false,params,null,url,x);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7571
			x.onreadystatechange = function(){};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7572
			x = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7573
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7574
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7575
	if(window.Components && window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7576
		window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7577
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7578
		if(!allowCache)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7579
			url = url + (url.indexOf("?") < 0 ? "?" : "&") + "nocache=" + Math.random();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7580
		x.open(type,url,true,username,password);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7581
		if(data)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7582
			x.setRequestHeader("Content-Type", contentType ? contentType : "application/x-www-form-urlencoded");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7583
		if(x.overrideMimeType)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7584
			x.setRequestHeader("Connection", "close");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7585
		if(headers) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7586
			for(var n in headers)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7587
				x.setRequestHeader(n,headers[n]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7588
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7589
		x.setRequestHeader("X-Requested-With", "TiddlyWiki " + formatVersion());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7590
		x.send(data);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7591
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7592
		return exceptionText(ex);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7593
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7594
	return x;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7595
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7596
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7597
function getXMLHttpRequest()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7598
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7599
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7600
		var x = new XMLHttpRequest(); // Modern
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7601
	} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7602
		try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7603
			x = new ActiveXObject("Msxml2.XMLHTTP"); // IE 6
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7604
		} catch (ex2) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7605
			return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7606
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7607
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7608
	return x;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7609
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7610
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7611
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7612
//-- TiddlyWiki-specific utility functions
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7613
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7614
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7615
formatVersion = function(v)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7616
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7617
	v = v || version;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7618
	return v.major + "." + v.minor + "." + v.revision + (v.beta ? " (beta " + v.beta + ")" : "");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7619
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7620
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7621
compareVersions = function(v1,v2)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7622
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7623
	var a = ["major","minor","revision"];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7624
	for(var i = 0; i<a.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7625
		var x1 = v1[a[i]] || 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7626
		var x2 = v2[a[i]] || 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7627
		if(x1<x2)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7628
			return 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7629
		if(x1>x2)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7630
			return -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7631
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7632
	x1 = v1.beta || 9999;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7633
	x2 = v2.beta || 9999;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7634
	if(x1<x2)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7635
		return 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7636
	return x1 > x2 ? -1 : 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7637
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7638
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7639
function createTiddlyButton(parent,text,tooltip,action,className,id,accessKey,attribs)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7640
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7641
	var btn = document.createElement("a");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7642
	if(action) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7643
		btn.onclick = action;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7644
		btn.setAttribute("href","javascript:;");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7645
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7646
	if(tooltip)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7647
		btn.setAttribute("title",tooltip);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7648
	if(text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7649
		btn.appendChild(document.createTextNode(text));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7650
	btn.className = className ? className : "button";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7651
	if(id)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7652
		btn.id = id;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7653
	if(attribs) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7654
		for(var n in attribs) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7655
			btn.setAttribute(n,attribs[n]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7656
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7657
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7658
	if(parent)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7659
		parent.appendChild(btn);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7660
	if(accessKey)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7661
		btn.setAttribute("accessKey",accessKey);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7662
	return btn;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7663
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7664
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7665
function createTiddlyLink(place,title,includeText,className,isStatic,linkedFromTiddler,noToggle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7666
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7667
	var text = includeText ? title : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7668
	var i = getTiddlyLinkInfo(title,className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7669
	var btn = isStatic ? createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" + title) : createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7670
	btn.setAttribute("refresh","link");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7671
	btn.setAttribute("tiddlyLink",title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7672
	if(noToggle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7673
		btn.setAttribute("noToggle","true");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7674
	if(linkedFromTiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7675
		var fields = linkedFromTiddler.getInheritedFields();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7676
		if(fields)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7677
			btn.setAttribute("tiddlyFields",fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7678
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7679
	return btn;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7680
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7681
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7682
function refreshTiddlyLink(e,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7683
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7684
	var i = getTiddlyLinkInfo(title,e.className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7685
	e.className = i.classes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7686
	e.title = i.subTitle;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7687
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7688
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7689
function getTiddlyLinkInfo(title,currClasses)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7690
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7691
	var classes = currClasses ? currClasses.split(" ") : [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7692
	classes.pushUnique("tiddlyLink");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7693
	var tiddler = store.fetchTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7694
	var subTitle;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7695
	if(tiddler) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7696
		subTitle = tiddler.getSubtitle();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7697
		classes.pushUnique("tiddlyLinkExisting");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7698
		classes.remove("tiddlyLinkNonExisting");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7699
		classes.remove("shadow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7700
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7701
		classes.remove("tiddlyLinkExisting");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7702
		classes.pushUnique("tiddlyLinkNonExisting");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7703
		if(store.isShadowTiddler(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7704
			subTitle = config.messages.shadowedTiddlerToolTip.format([title]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7705
			classes.pushUnique("shadow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7706
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7707
			subTitle = config.messages.undefinedTiddlerToolTip.format([title]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7708
			classes.remove("shadow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7709
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7710
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7711
	if(typeof config.annotations[title]=="string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7712
		subTitle = config.annotations[title];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7713
	return {classes: classes.join(" "),subTitle: subTitle};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7714
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7715
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7716
function createExternalLink(place,url)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7717
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7718
	var link = document.createElement("a");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7719
	link.className = "externalLink";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7720
	link.href = url;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7721
	link.title = config.messages.externalLinkTooltip.format([url]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7722
	if(config.options.chkOpenInNewWindow)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7723
		link.target = "_blank";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7724
	place.appendChild(link);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7725
	return link;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7726
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7727
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7728
// Event handler for clicking on a tiddly link
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7729
function onClickTiddlerLink(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7730
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7731
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7732
	var target = resolveTarget(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7733
	var link = target;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7734
	var title = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7735
	var fields = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7736
	var noToggle = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7737
	do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7738
		title = link.getAttribute("tiddlyLink");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7739
		fields = link.getAttribute("tiddlyFields");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7740
		noToggle = link.getAttribute("noToggle");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7741
		link = link.parentNode;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7742
	} while(title == null && link != null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7743
	if(!store.isShadowTiddler(title)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7744
		var f = fields ? fields.decodeHashMap() : {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7745
		fields = String.encodeHashMap(merge(f,config.defaultCustomFields,true));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7746
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7747
	if(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7748
		var toggling = e.metaKey || e.ctrlKey;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7749
		if(config.options.chkToggleLinks)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7750
			toggling = !toggling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7751
		if(noToggle)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7752
			toggling = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7753
		if(store.getTiddler(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7754
			fields = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7755
		story.displayTiddler(target,title,null,true,null,fields,toggling);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7756
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7757
	clearMessage();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7758
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7759
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7760
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7761
// Create a button for a tag with a popup listing all the tiddlers that it tags
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7762
function createTagButton(place,tag,excludeTiddler,title,tooltip)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7763
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7764
	var btn = createTiddlyButton(place,title||tag,(tooltip||config.views.wikified.tag.tooltip).format([tag]),onClickTag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7765
	btn.setAttribute("tag",tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7766
	if(excludeTiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7767
		btn.setAttribute("tiddler",excludeTiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7768
	return btn;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7769
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7770
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7771
// Event handler for clicking on a tiddler tag
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7772
function onClickTag(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7773
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7774
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7775
	var popup = Popup.create(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7776
	var tag = this.getAttribute("tag");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7777
	var title = this.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7778
	if(popup && tag) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7779
		var tagged = store.getTaggedTiddlers(tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7780
		var titles = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7781
		var li,r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7782
		for(r=0;r<tagged.length;r++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7783
			if(tagged[r].title != title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7784
				titles.push(tagged[r].title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7785
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7786
		var lingo = config.views.wikified.tag;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7787
		if(titles.length > 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7788
			var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7789
			openAll.setAttribute("tag",tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7790
			createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7791
			for(r=0; r<titles.length; r++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7792
				createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7793
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7794
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7795
			createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7796
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7797
		createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7798
		var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7799
		createTiddlyText(h,lingo.openTag.format([tag]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7800
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7801
	Popup.show();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7802
	e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7803
	if(e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7804
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7805
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7806
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7807
// Event handler for 'open all' on a tiddler popup
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7808
function onClickTagOpenAll(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7809
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7810
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7811
	var tag = this.getAttribute("tag");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7812
	var tagged = store.getTaggedTiddlers(tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7813
	story.displayTiddlers(this,tagged);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7814
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7815
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7816
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7817
function onClickError(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7818
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7819
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7820
	var popup = Popup.create(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7821
	var lines = this.getAttribute("errorText").split("\n");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7822
	for(var t=0; t<lines.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7823
		createTiddlyElement(popup,"li",null,null,lines[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7824
	Popup.show();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7825
	e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7826
	if(e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7827
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7828
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7829
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7830
function createTiddlyDropDown(place,onchange,options,defaultValue)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7831
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7832
	var sel = createTiddlyElement(place,"select");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7833
	sel.onchange = onchange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7834
	for(var t=0; t<options.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7835
		var e = createTiddlyElement(sel,"option",null,null,options[t].caption);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7836
		e.value = options[t].name;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7837
		if(options[t].name == defaultValue)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7838
			e.selected = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7839
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7840
	return sel;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7841
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7842
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7843
function createTiddlyPopup(place,caption,tooltip,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7844
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7845
	if(tiddler.text) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7846
		createTiddlyLink(place,caption,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7847
		var btn = createTiddlyButton(place,glyph("downArrow"),tooltip,onClickTiddlyPopup,"tiddlerPopupButton");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7848
		btn.tiddler = tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7849
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7850
		createTiddlyText(place,caption);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7851
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7852
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7853
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7854
function onClickTiddlyPopup(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7855
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7856
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7857
	var tiddler = this.tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7858
	if(tiddler.text) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7859
		var popup = Popup.create(this,"div","popupTiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7860
		wikify(tiddler.text,popup,null,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7861
		Popup.show();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7862
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7863
	if(e) e.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7864
	if(e && e.stopPropagation) e.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7865
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7866
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7867
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7868
function createTiddlyError(place,title,text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7869
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7870
	var btn = createTiddlyButton(place,title,null,onClickError,"errorButton");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7871
	if(text) btn.setAttribute("errorText",text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7872
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7873
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7874
function merge(dst,src,preserveExisting)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7875
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7876
	for(p in src) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7877
		if(!preserveExisting || dst[p] === undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7878
			dst[p] = src[p];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7879
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7880
	return dst;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7881
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7882
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7883
// Returns a string containing the description of an exception, optionally prepended by a message
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7884
function exceptionText(e,message)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7885
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7886
	var s = e.description ? e.description : e.toString();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7887
	return message ? "%0:\n%1".format([message,s]) : s;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7888
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7889
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7890
// Displays an alert of an exception description with optional message
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7891
function showException(e,message)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7892
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7893
	alert(exceptionText(e,message));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7894
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7895
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7896
function alertAndThrow(m)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7897
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7898
	alert(m);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7899
	throw(m);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7900
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7901
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7902
function glyph(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7903
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7904
	var g = config.glyphs;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7905
	var b = g.currBrowser;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7906
	if(b == null) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7907
		b = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7908
		while(!g.browsers[b]() && b < g.browsers.length-1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7909
			b++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7910
		g.currBrowser = b;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7911
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7912
	if(!g.codes[name])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7913
		return "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7914
	return g.codes[name][b];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7915
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7916
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7917
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7918
//-
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7919
//- Animation engine
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7920
//-
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7921
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7922
function Animator()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7923
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7924
	this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7925
	this.timerID = 0; // ID of the timer used for animating
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7926
	this.animations = []; // List of animations in progress
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7927
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7928
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7929
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7930
// Start animation engine
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7931
Animator.prototype.startAnimating = function() //# Variable number of arguments
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7932
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7933
	for(var t=0; t<arguments.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7934
		this.animations.push(arguments[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7935
	if(this.running == 0) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7936
		var me = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7937
		this.timerID = window.setInterval(function() {me.doAnimate(me);},10);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7938
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7939
	this.running += arguments.length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7940
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7941
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7942
// Perform an animation engine tick, calling each of the known animation modules
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7943
Animator.prototype.doAnimate = function(me)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7944
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7945
	var a = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7946
	while(a < me.animations.length) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7947
		var animation = me.animations[a];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7948
		if(animation.tick()) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7949
			a++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7950
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7951
			me.animations.splice(a,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7952
			if(--me.running == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7953
				window.clearInterval(me.timerID);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7954
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7955
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7956
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7957
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7958
Animator.slowInSlowOut = function(progress)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7959
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7960
	return(1-((Math.cos(progress * Math.PI)+1)/2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7961
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7962
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7963
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7964
//-- Morpher animation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7965
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7966
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7967
// Animate a set of properties of an element
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7968
function Morpher(element,duration,properties,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7969
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7970
	this.element = element;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7971
	this.duration = duration;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7972
	this.properties = properties;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7973
	this.startTime = new Date();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7974
	this.endTime = Number(this.startTime) + duration;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7975
	this.callback = callback;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7976
	this.tick();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7977
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7978
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7979
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7980
Morpher.prototype.assignStyle = function(element,style,value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7981
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7982
	switch(style) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7983
		case "-tw-vertScroll":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7984
			window.scrollTo(findScrollX(),value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7985
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7986
		case "-tw-horizScroll":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7987
			window.scrollTo(value,findScrollY());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7988
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7989
		default:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7990
			element.style[style] = value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7991
			break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7992
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7993
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7994
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7995
Morpher.prototype.stop = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7996
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7997
	for(var t=0; t<this.properties.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7998
		var p = this.properties[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  7999
		if(p.atEnd !== undefined) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8000
			this.assignStyle(this.element,p.style,p.atEnd);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8001
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8002
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8003
	if(this.callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8004
		this.callback(this.element,this.properties);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8005
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8006
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8007
Morpher.prototype.tick = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8008
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8009
	var currTime = Number(new Date());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8010
	progress = Animator.slowInSlowOut(Math.min(1,(currTime-this.startTime)/this.duration));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8011
	for(var t=0; t<this.properties.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8012
		var p = this.properties[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8013
		if(p.start !== undefined && p.end !== undefined) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8014
			var template = p.template ? p.template : "%0";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8015
			switch(p.format) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8016
				case undefined:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8017
				case "style":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8018
					var v = p.start + (p.end-p.start) * progress;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8019
					this.assignStyle(this.element,p.style,template.format([v]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8020
					break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8021
				case "color":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8022
					break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8023
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8024
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8025
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8026
	if(currTime >= this.endTime) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8027
		this.stop();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8028
		return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8029
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8030
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8031
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8032
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8033
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8034
//-- Zoomer animation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8035
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8036
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8037
function Zoomer(text,startElement,targetElement,unused)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8038
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8039
	var e = createTiddlyElement(document.body,"div",null,"zoomer");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8040
	createTiddlyElement(e,"div",null,null,text);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8041
	var winWidth = findWindowWidth();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8042
	var winHeight = findWindowHeight();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8043
	var p = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8044
		{style: 'left', start: findPosX(startElement), end: findPosX(targetElement), template: '%0px'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8045
		{style: 'top', start: findPosY(startElement), end: findPosY(targetElement), template: '%0px'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8046
		{style: 'width', start: Math.min(startElement.scrollWidth,winWidth), end: Math.min(targetElement.scrollWidth,winWidth), template: '%0px', atEnd: 'auto'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8047
		{style: 'height', start: Math.min(startElement.scrollHeight,winHeight), end: Math.min(targetElement.scrollHeight,winHeight), template: '%0px', atEnd: 'auto'},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8048
		{style: 'fontSize', start: 8, end: 24, template: '%0pt'}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8049
	];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8050
	var c = function(element,properties) {removeNode(element);};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8051
	return new Morpher(e,config.animDuration,p,c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8052
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8053
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8054
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8055
//-- Scroller animation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8056
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8057
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8058
function Scroller(targetElement,unused)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8059
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8060
	var p = [
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8061
		{style: '-tw-vertScroll', start: findScrollY(), end: ensureVisible(targetElement)}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8062
	];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8063
	return new Morpher(targetElement,config.animDuration,p);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8064
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8065
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8066
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8067
//-- Slider animation
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8068
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8069
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8070
// deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8071
function Slider(element,opening,unused,deleteMode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8072
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8073
	element.style.overflow = 'hidden';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8074
	if(opening)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8075
		element.style.height = '0px'; // Resolves a Firefox flashing bug
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8076
	element.style.display = 'block';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8077
	var left = findPosX(element);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8078
	var width = element.scrollWidth;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8079
	var height = element.scrollHeight;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8080
	var winWidth = findWindowWidth();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8081
	var p = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8082
	var c = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8083
	if(opening) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8084
		p.push({style: 'height', start: 0, end: height, template: '%0px', atEnd: 'auto'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8085
		p.push({style: 'opacity', start: 0, end: 1, template: '%0'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8086
		p.push({style: 'filter', start: 0, end: 100, template: 'alpha(opacity:%0)'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8087
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8088
		p.push({style: 'height', start: height, end: 0, template: '%0px'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8089
		p.push({style: 'display', atEnd: 'none'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8090
		p.push({style: 'opacity', start: 1, end: 0, template: '%0'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8091
		p.push({style: 'filter', start: 100, end: 0, template: 'alpha(opacity:%0)'});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8092
		switch(deleteMode) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8093
			case "all":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8094
				c = function(element,properties) {removeNode(element);};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8095
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8096
			case "children":
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8097
				c = function(element,properties) {removeChildren(element);};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8098
				break;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8099
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8100
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8101
	return new Morpher(element,config.animDuration,p,c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8102
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8103
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8104
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8105
//-- Popup menu
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8106
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8107
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8108
var Popup = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8109
	stack: [] // Array of objects with members root: and popup:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8110
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8111
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8112
Popup.create = function(root,elem,theClass)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8113
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8114
	var stackPosition = this.find(root,"popup");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8115
	Popup.remove(stackPosition+1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8116
	var popup = createTiddlyElement(document.body,elem ? elem : "ol","popup",theClass ? theClass : "popup");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8117
	popup.stackPosition = stackPosition;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8118
	Popup.stack.push({root: root, popup: popup});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8119
	return popup;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8120
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8121
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8122
Popup.onDocumentClick = function(ev)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8123
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8124
	var e = ev ? ev : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8125
	if(e.eventPhase == undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8126
		Popup.remove();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8127
	else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8128
		Popup.remove();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8129
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8130
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8131
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8132
Popup.show = function(valign,halign,offset)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8133
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8134
	var curr = Popup.stack[Popup.stack.length-1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8135
	this.place(curr.root,curr.popup,valign,halign,offset);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8136
	addClass(curr.root,"highlight");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8137
	if(config.options.chkAnimate && anim && typeof Scroller == "function")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8138
		anim.startAnimating(new Scroller(curr.popup));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8139
	else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8140
		window.scrollTo(0,ensureVisible(curr.popup));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8141
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8142
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8143
Popup.place = function(root,popup,valign,halign,offset)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8144
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8145
	if(!offset)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8146
		var offset = {x:0,y:0};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8147
	if(popup.stackPosition >= 0 && !valign && !halign) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8148
		offset.x = offset.x + root.offsetWidth;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8149
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8150
		offset.x = (halign == 'right') ? offset.x + root.offsetWidth : offset.x;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8151
		offset.y = (valign == 'top') ? offset.y : offset.y + root.offsetHeight;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8152
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8153
	var rootLeft = findPosX(root);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8154
	var rootTop = findPosY(root);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8155
	var popupLeft = rootLeft + offset.x;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8156
	var popupTop = rootTop + offset.y;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8157
	var winWidth = findWindowWidth();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8158
	if(popup.offsetWidth > winWidth*0.75)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8159
		popup.style.width = winWidth*0.75 + "px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8160
	var popupWidth = popup.offsetWidth;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8161
	var scrollWidth = winWidth - document.body.offsetWidth;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8162
	if(popupLeft + popupWidth > winWidth - scrollWidth - 1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8163
		if(halign == 'right')
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8164
			popupLeft = popupLeft - root.offsetWidth - popupWidth;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8165
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8166
			popupLeft = winWidth - popupWidth - scrollWidth - 1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8167
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8168
	popup.style.left = popupLeft + "px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8169
	popup.style.top = popupTop + "px";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8170
	popup.style.display = "block";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8171
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8172
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8173
Popup.find = function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8174
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8175
	var pos = -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8176
	for (var t=this.stack.length-1; t>=0; t--) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8177
		if(isDescendant(e,this.stack[t].popup))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8178
			pos = i;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8179
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8180
	return pos;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8181
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8182
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8183
Popup.remove = function(pos)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8184
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8185
	if(!pos) var pos = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8186
	if(Popup.stack.length > pos) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8187
		Popup.removeFrom(pos);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8188
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8189
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8190
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8191
Popup.removeFrom = function(from)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8192
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8193
	for(var t=Popup.stack.length-1; t>=from; t--) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8194
		var p = Popup.stack[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8195
		removeClass(p.root,"highlight");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8196
		removeNode(p.popup);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8197
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8198
	Popup.stack = Popup.stack.slice(0,from);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8199
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8200
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8201
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8202
//-- Wizard support
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8203
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8204
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8205
function Wizard(elem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8206
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8207
	if(elem) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8208
		this.formElem = findRelated(elem,"wizard","className");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8209
		this.bodyElem = findRelated(this.formElem.firstChild,"wizardBody","className","nextSibling");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8210
		this.footElem = findRelated(this.formElem.firstChild,"wizardFooter","className","nextSibling");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8211
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8212
		this.formElem = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8213
		this.bodyElem = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8214
		this.footElem = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8215
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8216
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8217
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8218
Wizard.prototype.setValue = function(name,value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8219
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8220
	if(this.formElem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8221
		this.formElem[name] = value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8222
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8223
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8224
Wizard.prototype.getValue = function(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8225
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8226
	return this.formElem ? this.formElem[name] : null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8227
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8228
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8229
Wizard.prototype.createWizard = function(place,title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8230
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8231
	this.formElem = createTiddlyElement(place,"form",null,"wizard");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8232
	createTiddlyElement(this.formElem,"h1",null,null,title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8233
	this.bodyElem = createTiddlyElement(this.formElem,"div",null,"wizardBody");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8234
	this.footElem = createTiddlyElement(this.formElem,"div",null,"wizardFooter");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8235
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8236
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8237
Wizard.prototype.clear = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8238
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8239
	removeChildren(this.bodyElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8240
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8241
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8242
Wizard.prototype.setButtons = function(buttonInfo,status)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8243
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8244
	removeChildren(this.footElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8245
	for(var t=0; t<buttonInfo.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8246
		createTiddlyButton(this.footElem,buttonInfo[t].caption,buttonInfo[t].tooltip,buttonInfo[t].onClick);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8247
		insertSpacer(this.footElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8248
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8249
	if(typeof status == "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8250
		createTiddlyElement(this.footElem,"span",null,"status",status);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8251
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8252
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8253
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8254
Wizard.prototype.addStep = function(stepTitle,html)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8255
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8256
	removeChildren(this.bodyElem);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8257
	var w = createTiddlyElement(this.bodyElem,"div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8258
	createTiddlyElement(w,"h2",null,null,stepTitle);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8259
	var step = createTiddlyElement(w,"div",null,"wizardStep");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8260
	step.innerHTML = html;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8261
	applyHtmlMacros(step,tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8262
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8263
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8264
Wizard.prototype.getElement = function(name)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8265
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8266
	return this.formElem.elements[name];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8267
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8268
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8269
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8270
//-- ListView gadget
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8271
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8272
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8273
var ListView = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8274
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8275
// Create a listview
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8276
ListView.create = function(place,listObject,listTemplate,callback,className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8277
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8278
	var table = createTiddlyElement(place,"table",null,className ? className : "listView twtable");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8279
	var thead = createTiddlyElement(table,"thead");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8280
	var r = createTiddlyElement(thead,"tr");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8281
	for(var t=0; t<listTemplate.columns.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8282
		var columnTemplate = listTemplate.columns[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8283
		var c = createTiddlyElement(r,"th");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8284
		var colType = ListView.columnTypes[columnTemplate.type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8285
		if(colType && colType.createHeader)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8286
			colType.createHeader(c,columnTemplate,t);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8287
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8288
	var tbody = createTiddlyElement(table,"tbody");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8289
	for(var rc=0; rc<listObject.length; rc++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8290
		rowObject = listObject[rc];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8291
		r = createTiddlyElement(tbody,"tr");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8292
		for(c=0; c<listTemplate.rowClasses.length; c++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8293
			if(rowObject[listTemplate.rowClasses[c].field])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8294
				addClass(r,listTemplate.rowClasses[c].className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8295
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8296
		rowObject.rowElement = r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8297
		rowObject.colElements = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8298
		for(var cc=0; cc<listTemplate.columns.length; cc++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8299
			c = createTiddlyElement(r,"td");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8300
			columnTemplate = listTemplate.columns[cc];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8301
			var field = columnTemplate.field;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8302
			colType = ListView.columnTypes[columnTemplate.type];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8303
			if(colType && colType.createItem)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8304
				colType.createItem(c,rowObject,field,columnTemplate,cc,rc);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8305
			rowObject.colElements[field] = c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8306
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8307
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8308
	if(callback && listTemplate.actions)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8309
		createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8310
	if(callback && listTemplate.buttons) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8311
		for(t=0; t<listTemplate.buttons.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8312
			var a = listTemplate.buttons[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8313
			if(a && a.name != "")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8314
				createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8315
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8316
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8317
	return table;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8318
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8319
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8320
ListView.getCommandHandler = function(callback,name,allowEmptySelection)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8321
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8322
	return function(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8323
		var view = findRelated(this,"TABLE",null,"previousSibling");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8324
		var tiddlers = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8325
		ListView.forEachSelector(view,function(e,rowName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8326
					if(e.checked)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8327
						tiddlers.push(rowName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8328
					});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8329
		if(tiddlers.length == 0 && !allowEmptySelection) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8330
			alert(config.messages.nothingSelected);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8331
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8332
			if(this.nodeName.toLowerCase() == "select") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8333
				callback(view,this.value,tiddlers);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8334
				this.selectedIndex = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8335
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8336
				callback(view,name,tiddlers);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8337
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8338
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8339
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8340
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8341
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8342
// Invoke a callback for each selector checkbox in the listview
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8343
ListView.forEachSelector = function(view,callback)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8344
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8345
	var checkboxes = view.getElementsByTagName("input");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8346
	var hadOne = false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8347
	for(var t=0; t<checkboxes.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8348
		var cb = checkboxes[t];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8349
		if(cb.getAttribute("type") == "checkbox") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8350
			var rn = cb.getAttribute("rowName");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8351
			if(rn) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8352
				callback(cb,rn);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8353
				hadOne = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8354
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8355
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8356
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8357
	return hadOne;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8358
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8359
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8360
ListView.getSelectedRows = function(view)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8361
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8362
	var rowNames = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8363
	ListView.forEachSelector(view,function(e,rowName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8364
				if(e.checked)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8365
					rowNames.push(rowName);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8366
				});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8367
	return rowNames;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8368
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8369
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8370
ListView.columnTypes = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8371
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8372
ListView.columnTypes.String = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8373
	createHeader: function(place,columnTemplate,col)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8374
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8375
			createTiddlyText(place,columnTemplate.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8376
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8377
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8378
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8379
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8380
			if(v != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8381
				createTiddlyText(place,v);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8382
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8383
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8384
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8385
ListView.columnTypes.WikiText = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8386
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8387
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8388
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8389
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8390
			if(v != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8391
				wikify(v,place,null,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8392
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8393
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8394
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8395
ListView.columnTypes.Tiddler = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8396
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8397
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8398
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8399
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8400
			if(v != undefined && v.title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8401
				createTiddlyPopup(place,v.title,config.messages.listView.tiddlerTooltip,v);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8402
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8403
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8404
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8405
ListView.columnTypes.Size = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8406
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8407
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8408
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8409
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8410
			if(v != undefined) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8411
				var t = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8412
				while(t<config.messages.sizeTemplates.length-1 && v<config.messages.sizeTemplates[t].unit)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8413
					t++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8414
				createTiddlyText(place,config.messages.sizeTemplates[t].template.format([Math.round(v/config.messages.sizeTemplates[t].unit)]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8415
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8416
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8417
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8418
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8419
ListView.columnTypes.Link = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8420
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8421
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8422
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8423
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8424
			var c = columnTemplate.text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8425
			if(v != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8426
				createTiddlyText(createExternalLink(place,v),c ? c : v);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8427
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8428
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8429
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8430
ListView.columnTypes.Date = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8431
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8432
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8433
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8434
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8435
			if(v != undefined)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8436
				createTiddlyText(place,v.formatString(columnTemplate.dateFormat));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8437
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8438
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8439
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8440
ListView.columnTypes.StringList = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8441
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8442
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8443
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8444
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8445
			if(v != undefined) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8446
				for(var t=0; t<v.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8447
					createTiddlyText(place,v[t]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8448
					createTiddlyElement(place,"br");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8449
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8450
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8451
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8452
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8453
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8454
ListView.columnTypes.Selector = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8455
	createHeader: function(place,columnTemplate,col)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8456
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8457
			createTiddlyCheckbox(place,null,false,this.onHeaderChange);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8458
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8459
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8460
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8461
			var e = createTiddlyCheckbox(place,null,listObject[field],null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8462
			e.setAttribute("rowName",listObject[columnTemplate.rowName]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8463
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8464
	onHeaderChange: function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8465
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8466
			var state = this.checked;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8467
			var view = findRelated(this,"TABLE");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8468
			if(!view)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8469
				return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8470
			ListView.forEachSelector(view,function(e,rowName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8471
								e.checked = state;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8472
							});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8473
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8474
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8475
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8476
ListView.columnTypes.Tags = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8477
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8478
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8479
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8480
			var tags = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8481
			createTiddlyText(place,String.encodeTiddlyLinkList(tags));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8482
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8483
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8484
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8485
ListView.columnTypes.Boolean = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8486
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8487
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8488
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8489
			if(listObject[field] == true)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8490
				createTiddlyText(place,columnTemplate.trueText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8491
			if(listObject[field] == false)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8492
				createTiddlyText(place,columnTemplate.falseText);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8493
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8494
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8495
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8496
ListView.columnTypes.TagCheckbox = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8497
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8498
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8499
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8500
			var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8501
			e.setAttribute("tiddler",listObject.title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8502
			e.setAttribute("tag",columnTemplate.tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8503
		},
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8504
	onChange : function(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8505
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8506
			var tag = this.getAttribute("tag");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8507
			var tiddler = this.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8508
			store.setTiddlerTag(tiddler,this.checked,tag);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8509
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8510
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8511
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8512
ListView.columnTypes.TiddlerLink = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8513
	createHeader: ListView.columnTypes.String.createHeader,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8514
	createItem: function(place,listObject,field,columnTemplate,col,row)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8515
		{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8516
			var v = listObject[field];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8517
			if(v != undefined) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8518
				var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8519
				createTiddlyText(link,listObject[field]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8520
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8521
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8522
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8523
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8524
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8525
//-- Augmented methods for the JavaScript Number(), Array(), String() and Date() objects
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8526
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8527
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8528
// Clamp a number to a range
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8529
Number.prototype.clamp = function(min,max)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8530
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8531
	var c = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8532
	if(c < min)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8533
		c = min;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8534
	if(c > max)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8535
		c = max;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8536
	return c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8537
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8538
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8539
// Add indexOf function if browser does not support it
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8540
if(!Array.indexOf) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8541
Array.prototype.indexOf = function(item,from)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8542
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8543
	if(!from)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8544
		from = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8545
	for(var i=from; i<this.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8546
		if(this[i] === item)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8547
			return i;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8548
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8549
	return -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8550
};}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8551
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8552
// Find an entry in a given field of the members of an array
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8553
Array.prototype.findByField = function(field,value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8554
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8555
	for(var t=0; t<this.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8556
		if(this[t][field] == value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8557
			return t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8558
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8559
	return null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8560
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8561
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8562
// Return whether an entry exists in an array
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8563
Array.prototype.contains = function(item)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8564
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8565
	return this.indexOf(item) != -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8566
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8567
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8568
// Adds, removes or toggles a particular value within an array
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8569
//  value - value to add
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8570
//  mode - +1 to add value, -1 to remove value, 0 to toggle it
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8571
Array.prototype.setItem = function(value,mode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8572
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8573
	var p = this.indexOf(value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8574
	if(mode == 0)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8575
		mode = (p == -1) ? +1 : -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8576
	if(mode == +1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8577
		if(p == -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8578
			this.push(value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8579
	} else if(mode == -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8580
		if(p != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8581
			this.splice(p,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8582
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8583
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8584
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8585
// Return whether one of a list of values exists in an array
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8586
Array.prototype.containsAny = function(items)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8587
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8588
	for(var i=0; i<items.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8589
		if(this.indexOf(items[i]) != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8590
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8591
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8592
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8593
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8594
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8595
// Return whether all of a list of values exists in an array
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8596
Array.prototype.containsAll = function(items)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8597
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8598
	for(var i = 0; i<items.length; i++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8599
		if(this.indexOf(items[i]) == -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8600
			return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8601
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8602
	return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8603
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8604
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8605
// 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
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8606
Array.prototype.pushUnique = function(item,unique)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8607
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8608
	if(unique === false) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8609
		this.push(item);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8610
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8611
		if(this.indexOf(item) == -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8612
			this.push(item);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8613
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8614
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8615
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8616
Array.prototype.remove = function(item)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8617
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8618
	var p = this.indexOf(item);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8619
	if(p != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8620
		this.splice(p,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8621
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8622
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8623
if(!Array.prototype.map) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8624
Array.prototype.map = function(fn,thisObj)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8625
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8626
	var scope = thisObj || window;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8627
	var a = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8628
	for(var i=0, j=this.length; i < j; ++i) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8629
		a.push(fn.call(scope,this[i],i,this));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8630
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8631
	return a;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8632
};}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8633
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8634
// Get characters from the right end of a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8635
String.prototype.right = function(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8636
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8637
	return n < this.length ? this.slice(this.length-n) : this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8638
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8639
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8640
// Trim whitespace from both ends of a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8641
String.prototype.trim = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8642
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8643
	return this.replace(/^\s*|\s*$/g,"");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8644
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8645
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8646
// Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8647
String.prototype.unDash = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8648
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8649
	var s = this.split("-");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8650
	if(s.length > 1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8651
		for(var t=1; t<s.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8652
			s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8653
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8654
	return s.join("");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8655
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8656
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8657
// Substitute substrings from an array into a format string that includes '%1'-type specifiers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8658
String.prototype.format = function(substrings)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8659
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8660
	var subRegExp = /(?:%(\d+))/mg;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8661
	var currPos = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8662
	var r = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8663
	do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8664
		var match = subRegExp.exec(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8665
		if(match && match[1]) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8666
			if(match.index > currPos)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8667
				r.push(this.substring(currPos,match.index));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8668
			r.push(substrings[parseInt(match[1])]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8669
			currPos = subRegExp.lastIndex;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8670
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8671
	} while(match);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8672
	if(currPos < this.length)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8673
		r.push(this.substring(currPos,this.length));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8674
	return r.join("");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8675
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8676
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8677
// Escape any special RegExp characters with that character preceded by a backslash
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8678
String.prototype.escapeRegExp = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8679
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8680
	var s = "\\^$*+?()=!|,{}[].";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8681
	var c = this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8682
	for(var t=0; t<s.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8683
		c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8684
	return c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8685
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8686
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8687
// Convert "\" to "\s", newlines to "\n" (and remove carriage returns)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8688
String.prototype.escapeLineBreaks = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8689
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8690
	return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,"");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8691
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8692
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8693
// Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8694
String.prototype.unescapeLineBreaks = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8695
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8696
	return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,"");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8697
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8698
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8699
// Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;"
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8700
String.prototype.htmlEncode = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8701
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8702
	return this.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8703
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8704
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8705
// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8706
String.prototype.htmlDecode = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8707
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8708
	return this.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8709
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8710
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8711
// Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8712
String.prototype.toJSONString = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8713
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8714
	var m = {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8715
		'\b': '\\b',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8716
		'\f': '\\f',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8717
		'\n': '\\n',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8718
		'\r': '\\r',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8719
		'\t': '\\t',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8720
		'"' : '\\"',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8721
		'\\': '\\\\'
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8722
		};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8723
	var replaceFn = function(a,b) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8724
		var c = m[b];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8725
		if(c)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8726
			return c;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8727
		c = b.charCodeAt();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8728
		return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8729
		};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8730
	if(/["\\\x00-\x1f]/.test(this))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8731
		return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8732
	return '"' + this + '"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8733
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8734
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8735
// Parse a space-separated string of name:value parameters
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8736
// The result is an array of objects:
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8737
//   result[0] = object with a member for each parameter name, value of that member being an array of values
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8738
//   result[1..n] = one object for each parameter, with 'name' and 'value' members
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8739
String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8740
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8741
	var parseToken = function(match,p) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8742
		var n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8743
		if(match[p]) // Double quoted
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8744
			n = match[p];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8745
		else if(match[p+1]) // Single quoted
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8746
			n = match[p+1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8747
		else if(match[p+2]) // Double-square-bracket quoted
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8748
			n = match[p+2];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8749
		else if(match[p+3]) // Double-brace quoted
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8750
			try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8751
				n = match[p+3];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8752
				if(allowEval)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8753
					n = window.eval(n);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8754
			} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8755
				throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(ex);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8756
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8757
		else if(match[p+4]) // Unquoted
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8758
			n = match[p+4];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8759
		else if(match[p+5]) // empty quote
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8760
			n = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8761
		return n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8762
	};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8763
	var r = [{}];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8764
	var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8765
	var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8766
	var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8767
	var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8768
	var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8769
	var emptyQuote = "((?:\"\")|(?:''))";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8770
	var skipSpace = "(?:\\s*)";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8771
	var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8772
	var re = noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8773
	var params = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8774
	do {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8775
		var match = re.exec(this);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8776
		if(match) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8777
			var n = parseToken(match,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8778
			if(noNames) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8779
				r.push({name:"",value:n});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8780
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8781
				var v = parseToken(match,8);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8782
				if(v == null && defaultName) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8783
					v = n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8784
					n = defaultName;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8785
				} else if(v == null && defaultValue) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8786
					v = defaultValue;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8787
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8788
				r.push({name:n,value:v});
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8789
				if(cascadeDefaults) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8790
					defaultName = n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8791
					defaultValue = v;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8792
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8793
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8794
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8795
	} while(match);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8796
	// Summarise parameters into first element
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8797
	for(var t=1; t<r.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8798
		if(r[0][r[t].name])
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8799
			r[0][r[t].name].push(r[t].value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8800
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8801
			r[0][r[t].name] = [r[t].value];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8802
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8803
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8804
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8805
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8806
// Process a string list of macro parameters into an array. Parameters can be quoted with "", '',
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8807
// [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8808
// an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8809
String.prototype.readMacroParams = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8810
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8811
	var p = this.parseParams("list",null,true,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8812
	var n = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8813
	for(var t=1; t<p.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8814
		n.push(p[t].value);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8815
	return n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8816
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8817
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8818
// Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]]
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8819
String.prototype.readBracketedList = function(unique)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8820
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8821
	var p = this.parseParams("list",null,false,true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8822
	var n = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8823
	for(var t=1; t<p.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8824
		if(p[t].value)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8825
			n.pushUnique(p[t].value,unique);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8826
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8827
	return n;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8828
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8829
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8830
// Returns array with start and end index of chunk between given start and end marker, or undefined.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8831
String.prototype.getChunkRange = function(start,end)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8832
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8833
	var s = this.indexOf(start);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8834
	if(s != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8835
		s += start.length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8836
		var e = this.indexOf(end,s);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8837
		if(e != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8838
			return [s,e];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8839
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8840
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8841
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8842
// Replace a chunk of a string given start and end markers
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8843
String.prototype.replaceChunk = function(start,end,sub)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8844
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8845
	var r = this.getChunkRange(start,end);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8846
	return r ? this.substring(0,r[0]) + sub + this.substring(r[1]) : this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8847
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8848
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8849
// Returns a chunk of a string between start and end markers, or undefined
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8850
String.prototype.getChunk = function(start,end)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8851
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8852
	var r = this.getChunkRange(start,end);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8853
	if(r)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8854
		return this.substring(r[0],r[1]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8855
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8856
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8857
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8858
// Static method to bracket a string with double square brackets if it contains a space
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8859
String.encodeTiddlyLink = function(title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8860
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8861
	return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8862
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8863
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8864
// Static method to encodeTiddlyLink for every item in an array and join them with spaces
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8865
String.encodeTiddlyLinkList = function(list)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8866
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8867
	if(list) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8868
		var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8869
		for(var t=0; t<list.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8870
			results.push(String.encodeTiddlyLink(list[t]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8871
		return results.join(" ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8872
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8873
		return "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8874
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8875
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8876
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8877
// Convert a string as a sequence of name:"value" pairs into a hashmap
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8878
String.prototype.decodeHashMap = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8879
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8880
	var fields = this.parseParams("anon","",false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8881
	var r = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8882
	for(var t=1; t<fields.length; t++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8883
		r[fields[t].name] = fields[t].value;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8884
	return r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8885
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8886
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8887
// Static method to encode a hashmap into a name:"value"... string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8888
String.encodeHashMap = function(hashmap)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8889
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8890
	var r = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8891
	for(var t in hashmap)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8892
		r.push(t + ':"' + hashmap[t] + '"');
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8893
	return r.join(" ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8894
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8895
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8896
// Static method to left-pad a string with 0s to a certain width
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8897
String.zeroPad = function(n,d)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8898
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8899
	var s = n.toString();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8900
	if(s.length < d)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8901
		s = "000000000000000000000000000".substr(0,d-s.length) + s;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8902
	return s;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8903
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8904
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8905
String.prototype.startsWith = function(prefix)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8906
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8907
	return !prefix || this.substring(0,prefix.length) == prefix;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8908
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8909
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8910
// Returns the first value of the given named parameter.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8911
function getParam(params,name,defaultValue)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8912
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8913
	if(!params)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8914
		return defaultValue;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8915
	var p = params[0][name];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8916
	return p ? p[0] : defaultValue;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8917
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8918
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8919
// Returns the first value of the given boolean named parameter.
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8920
function getFlag(params,name,defaultValue)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8921
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8922
	return !!getParam(params,name,defaultValue);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8923
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8924
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8925
// Substitute date components into a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8926
Date.prototype.formatString = function(template)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8927
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8928
	var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8929
	t = t.replace(/hh12/g,this.getHours12());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8930
	t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8931
	t = t.replace(/hh/g,this.getHours());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8932
	t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8933
	t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8934
	t = t.replace(/mm/g,this.getMinutes());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8935
	t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8936
	t = t.replace(/ss/g,this.getSeconds());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8937
	t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8938
	t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8939
	t = t.replace(/wYYYY/g,this.getYearForWeekNo());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8940
	t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8941
	t = t.replace(/YYYY/g,this.getFullYear());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8942
	t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8943
	t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8944
	t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8945
	t = t.replace(/MM/g,this.getMonth()+1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8946
	t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8947
	t = t.replace(/WW/g,this.getWeek());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8948
	t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8949
	t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8950
	t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8951
	t = t.replace(/DDth/g,this.getDate()+this.daySuffix());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8952
	t = t.replace(/DD/g,this.getDate());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8953
	var tz = this.getTimezoneOffset();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8954
	var atz = Math.abs(tz);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8955
	t = t.replace(/TZD/g,(tz < 0 ? '+' : '-') + String.zeroPad(Math.floor(atz / 60),2) + ':' + String.zeroPad(atz % 60,2));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8956
	return t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8957
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8958
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8959
Date.prototype.getWeek = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8960
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8961
	var dt = new Date(this.getTime());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8962
	var d = dt.getDay();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8963
	if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8964
	dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8965
	var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8966
	return Math.floor(n/7)+1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8967
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8968
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8969
Date.prototype.getYearForWeekNo = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8970
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8971
	var dt = new Date(this.getTime());
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8972
	var d = dt.getDay();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8973
	if(d==0) d=7;// JavaScript Sun=0, ISO Sun=7
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8974
	dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8975
	return dt.getFullYear();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8976
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8977
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8978
Date.prototype.getHours12 = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8979
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8980
	var h = this.getHours();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8981
	return h > 12 ? h-12 : ( h > 0 ? h : 12 );
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8982
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8983
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8984
Date.prototype.getAmPm = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8985
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8986
	return this.getHours() >= 12 ? config.messages.dates.pm : config.messages.dates.am;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8987
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8988
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8989
Date.prototype.daySuffix = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8990
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8991
	return config.messages.dates.daySuffixes[this.getDate()-1];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8992
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8993
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8994
// Convert a date to local YYYYMMDDHHMM string format
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8995
Date.prototype.convertToLocalYYYYMMDDHHMM = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8996
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8997
	return this.getFullYear() + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8998
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  8999
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9000
// Convert a date to UTC YYYYMMDDHHMM string format
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9001
Date.prototype.convertToYYYYMMDDHHMM = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9002
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9003
	return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9004
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9005
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9006
// Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9007
Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9008
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9009
	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);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9010
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9011
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9012
// Static method to create a date from a UTC YYYYMMDDHHMM format string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9013
Date.convertFromYYYYMMDDHHMM = function(d)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9014
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9015
	var hh = d.substr(8,2) || "00";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9016
	var mm = d.substr(10,2) || "00";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9017
	return new Date(Date.UTC(parseInt(d.substr(0,4),10),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9018
			parseInt(d.substr(4,2),10)-1,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9019
			parseInt(d.substr(6,2),10),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9020
			parseInt(hh,10),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9021
			parseInt(mm,10),0,0));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9022
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9023
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9024
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9025
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9026
//-- Crypto functions and associated conversion routines
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9027
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9028
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9029
// Crypto 'namespace'
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9030
function Crypto() {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9031
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9032
// Convert a string to an array of big-endian 32-bit words
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9033
Crypto.strToBe32s = function(str)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9034
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9035
	var be=Array();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9036
	var len=Math.floor(str.length/4);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9037
	var i, j;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9038
	for(i=0, j=0; i<len; i++, j+=4) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9039
		be[i]=((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9040
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9041
	while(j<str.length) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9042
		be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9043
		j++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9044
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9045
	return be;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9046
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9047
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9048
// Convert an array of big-endian 32-bit words to a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9049
Crypto.be32sToStr = function(be)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9050
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9051
	var str='';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9052
	for(var i=0;i<be.length*32;i+=8)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9053
		str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9054
	return str;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9055
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9056
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9057
// Convert an array of big-endian 32-bit words to a hex string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9058
Crypto.be32sToHex = function(be)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9059
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9060
	var hex='0123456789ABCDEF';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9061
	var str='';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9062
	for(var i=0;i<be.length*4;i++)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9063
		str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9064
	return str;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9065
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9066
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9067
// Return, in hex, the SHA-1 hash of a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9068
Crypto.hexSha1Str = function(str)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9069
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9070
	return Crypto.be32sToHex(Crypto.sha1Str(str));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9071
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9072
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9073
// Return the SHA-1 hash of a string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9074
Crypto.sha1Str = function(str)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9075
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9076
	return Crypto.sha1(Crypto.strToBe32s(str),str.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9077
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9078
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9079
// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9080
Crypto.sha1 = function(x,blen)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9081
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9082
	// Add 32-bit integers, wrapping at 32 bits
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9083
	function add32(a,b)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9084
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9085
		var lsw=(a&0xFFFF)+(b&0xFFFF);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9086
		var msw=(a>>16)+(b>>16)+(lsw>>16);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9087
		return (msw<<16)|(lsw&0xFFFF);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9088
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9089
	function AA(a,b,c,d,e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9090
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9091
		b=(b>>>27)|(b<<5);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9092
		var lsw=(a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9093
		var msw=(a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9094
		return (msw<<16)|(lsw&0xFFFF);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9095
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9096
	function RR(w,j)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9097
	{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9098
		var n=w[j-3]^w[j-8]^w[j-14]^w[j-16];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9099
		return (n>>>31)|(n<<1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9100
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9101
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9102
	var len=blen*8;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9103
	x[len>>5] |= 0x80 << (24-len%32);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9104
	x[((len+64>>9)<<4)+15]=len;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9105
	var w=Array(80);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9106
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9107
	var k1=0x5A827999;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9108
	var k2=0x6ED9EBA1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9109
	var k3=0x8F1BBCDC;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9110
	var k4=0xCA62C1D6;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9111
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9112
	var h0=0x67452301;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9113
	var h1=0xEFCDAB89;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9114
	var h2=0x98BADCFE;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9115
	var h3=0x10325476;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9116
	var h4=0xC3D2E1F0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9117
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9118
	for(var i=0;i<x.length;i+=16) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9119
		var j=0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9120
		var t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9121
		var a=h0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9122
		var b=h1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9123
		var c=h2;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9124
		var d=h3;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9125
		var e=h4;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9126
		while(j<16) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9127
			w[j]=x[i+j];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9128
			t=AA(e,a,d^(b&(c^d)),w[j],k1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9129
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9130
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9131
		while(j<20) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9132
			w[j]=RR(w,j);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9133
			t=AA(e,a,d^(b&(c^d)),w[j],k1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9134
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9135
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9136
		while(j<40) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9137
			w[j]=RR(w,j);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9138
			t=AA(e,a,b^c^d,w[j],k2);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9139
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9140
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9141
		while(j<60) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9142
			w[j]=RR(w,j);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9143
			t=AA(e,a,(b&c)|(d&(b|c)),w[j],k3);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9144
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9145
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9146
		while(j<80) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9147
			w[j]=RR(w,j);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9148
			t=AA(e,a,b^c^d,w[j],k4);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9149
			e=d; d=c; c=(b>>>2)|(b<<30); b=a; a=t; j++;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9150
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9151
		h0=add32(h0,a);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9152
		h1=add32(h1,b);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9153
		h2=add32(h2,c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9154
		h3=add32(h3,d);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9155
		h4=add32(h4,e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9156
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9157
	return [h0,h1,h2,h3,h4];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9158
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9159
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9160
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9161
//-- RGB colour object
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9162
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9163
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9164
// Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9165
function RGB(r,g,b)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9166
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9167
	this.r = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9168
	this.g = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9169
	this.b = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9170
	if(typeof r == "string") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9171
		if(r.substr(0,1) == "#") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9172
			if(r.length == 7) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9173
				this.r = parseInt(r.substr(1,2),16)/255;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9174
				this.g = parseInt(r.substr(3,2),16)/255;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9175
				this.b = parseInt(r.substr(5,2),16)/255;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9176
			} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9177
				this.r = parseInt(r.substr(1,1),16)/15;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9178
				this.g = parseInt(r.substr(2,1),16)/15;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9179
				this.b = parseInt(r.substr(3,1),16)/15;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9180
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9181
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9182
			var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9183
			var c = r.match(rgbPattern);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9184
			if(c) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9185
				this.r = parseInt(c[1],10)/255;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9186
				this.g = parseInt(c[2],10)/255;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9187
				this.b = parseInt(c[3],10)/255;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9188
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9189
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9190
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9191
		this.r = r;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9192
		this.g = g;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9193
		this.b = b;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9194
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9195
	return this;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9196
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9197
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9198
// Mixes this colour with another in a specified proportion
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9199
// c = other colour to mix
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9200
// f = 0..1 where 0 is this colour and 1 is the new colour
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9201
// Returns an RGB object
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9202
RGB.prototype.mix = function(c,f)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9203
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9204
	return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9205
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9206
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9207
// Return an rgb colour as a #rrggbb format hex string
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9208
RGB.prototype.toString = function()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9209
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9210
	return "#" + ("0" + Math.floor(this.r.clamp(0,1) * 255).toString(16)).right(2) +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9211
				 ("0" + Math.floor(this.g.clamp(0,1) * 255).toString(16)).right(2) +
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9212
				 ("0" + Math.floor(this.b.clamp(0,1) * 255).toString(16)).right(2);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9213
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9214
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9215
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9216
//-- DOM utilities - many derived from www.quirksmode.org
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9217
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9218
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9219
function drawGradient(place,horiz,locolors,hicolors)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9220
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9221
	if(!hicolors)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9222
		hicolors = locolors;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9223
	for(var t=0; t<= 100; t+=2) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9224
		var bar = document.createElement("div");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9225
		place.appendChild(bar);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9226
		bar.style.position = "absolute";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9227
		bar.style.left = horiz ? t + "%" : 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9228
		bar.style.top = horiz ? 0 : t + "%";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9229
		bar.style.width = horiz ? (101-t) + "%" : "100%";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9230
		bar.style.height = horiz ? "100%" : (101-t) + "%";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9231
		bar.style.zIndex = -1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9232
		var p = t/100*(locolors.length-1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9233
		bar.style.backgroundColor = hicolors[Math.floor(p)].mix(locolors[Math.ceil(p)],p-Math.floor(p)).toString();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9234
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9235
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9236
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9237
function createTiddlyText(parent,text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9238
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9239
	return parent.appendChild(document.createTextNode(text));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9240
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9241
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9242
function createTiddlyCheckbox(parent,caption,checked,onChange)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9243
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9244
	var cb = document.createElement("input");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9245
	cb.setAttribute("type","checkbox");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9246
	cb.onclick = onChange;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9247
	parent.appendChild(cb);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9248
	cb.checked = checked;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9249
	cb.className = "chkOptionInput";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9250
	if(caption)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9251
		wikify(caption,parent);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9252
	return cb;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9253
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9254
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9255
function createTiddlyElement(parent,element,id,className,text,attribs)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9256
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9257
	var e = document.createElement(element);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9258
	if(className != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9259
		e.className = className;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9260
	if(id != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9261
		e.setAttribute("id",id);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9262
	if(text != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9263
		e.appendChild(document.createTextNode(text));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9264
	if(attribs) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9265
		for(var n in attribs) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9266
			e.setAttribute(n,attribs[n]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9267
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9268
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9269
	if(parent != null)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9270
		parent.appendChild(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9271
	return e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9272
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9273
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9274
function addEvent(obj,type,fn)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9275
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9276
	if(obj.attachEvent) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9277
		obj['e'+type+fn] = fn;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9278
		obj[type+fn] = function(){obj['e'+type+fn](window.event);};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9279
		obj.attachEvent('on'+type,obj[type+fn]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9280
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9281
		obj.addEventListener(type,fn,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9282
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9283
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9284
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9285
function removeEvent(obj,type,fn)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9286
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9287
	if(obj.detachEvent) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9288
		obj.detachEvent('on'+type,obj[type+fn]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9289
		obj[type+fn] = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9290
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9291
		obj.removeEventListener(type,fn,false);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9292
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9293
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9294
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9295
function addClass(e,className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9296
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9297
	var currClass = e.className.split(" ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9298
	if(currClass.indexOf(className) == -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9299
		e.className += " " + className;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9300
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9301
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9302
function removeClass(e,className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9303
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9304
	var currClass = e.className.split(" ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9305
	var i = currClass.indexOf(className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9306
	while(i != -1) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9307
		currClass.splice(i,1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9308
		i = currClass.indexOf(className);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9309
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9310
	e.className = currClass.join(" ");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9311
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9312
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9313
function hasClass(e,className)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9314
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9315
	if(e.className) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9316
		if(e.className.split(" ").indexOf(className) != -1)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9317
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9318
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9319
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9320
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9321
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9322
// Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9323
function findRelated(e,value,name,relative)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9324
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9325
	name = name ? name : "tagName";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9326
	relative = relative ? relative : "parentNode";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9327
	if(name == "className") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9328
		while(e && !hasClass(e,value)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9329
			e = e[relative];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9330
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9331
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9332
		while(e && e[name] != value) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9333
			e = e[relative];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9334
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9335
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9336
	return e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9337
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9338
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9339
// Resolve the target object of an event
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9340
function resolveTarget(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9341
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9342
	var obj;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9343
	if(e.target)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9344
		obj = e.target;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9345
	else if(e.srcElement)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9346
		obj = e.srcElement;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9347
	if(obj.nodeType == 3) // defeat Safari bug
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9348
		obj = obj.parentNode;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9349
	return obj;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9350
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9351
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9352
// Prevent an event from bubbling
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9353
function stopEvent(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9354
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9355
	var ev = e ? e : window.event;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9356
	ev.cancelBubble = true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9357
	if(ev.stopPropagation) ev.stopPropagation();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9358
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9359
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9360
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9361
// Return the content of an element as plain text with no formatting
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9362
function getPlainText(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9363
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9364
	var text = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9365
	if(e.innerText)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9366
		text = e.innerText;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9367
	else if(e.textContent)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9368
		text = e.textContent;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9369
	return text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9370
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9371
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9372
// Get the scroll position for window.scrollTo necessary to scroll a given element into view
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9373
function ensureVisible(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9374
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9375
	var posTop = findPosY(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9376
	var posBot = posTop + e.offsetHeight;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9377
	var winTop = findScrollY();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9378
	var winHeight = findWindowHeight();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9379
	var winBot = winTop + winHeight;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9380
	if(posTop < winTop) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9381
		return posTop;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9382
	} else if(posBot > winBot) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9383
		if(e.offsetHeight < winHeight)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9384
			return posTop - (winHeight - e.offsetHeight);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9385
		else
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9386
			return posTop;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9387
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9388
		return winTop;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9389
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9390
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9391
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9392
// Get the current width of the display window
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9393
function findWindowWidth()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9394
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9395
	return window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9396
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9397
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9398
// Get the current height of the display window
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9399
function findWindowHeight()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9400
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9401
	return window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9402
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9403
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9404
// Get the current horizontal page scroll position
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9405
function findScrollX()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9406
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9407
	return window.scrollX ? window.scrollX : document.documentElement.scrollLeft;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9408
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9409
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9410
// Get the current vertical page scroll position
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9411
function findScrollY()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9412
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9413
	return window.scrollY ? window.scrollY : document.documentElement.scrollTop;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9414
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9415
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9416
function findPosX(obj)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9417
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9418
	var curleft = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9419
	while(obj.offsetParent) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9420
		curleft += obj.offsetLeft;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9421
		obj = obj.offsetParent;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9422
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9423
	return curleft;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9424
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9425
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9426
function findPosY(obj)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9427
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9428
	var curtop = 0;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9429
	while(obj.offsetParent) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9430
		curtop += obj.offsetTop;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9431
		obj = obj.offsetParent;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9432
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9433
	return curtop;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9434
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9435
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9436
// Blur a particular element
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9437
function blurElement(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9438
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9439
	if(e != null && e.focus && e.blur) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9440
		e.focus();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9441
		e.blur();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9442
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9443
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9444
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9445
// Create a non-breaking space
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9446
function insertSpacer(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9447
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9448
	var e = document.createTextNode(String.fromCharCode(160));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9449
	if(place)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9450
		place.appendChild(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9451
	return e;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9452
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9453
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9454
// Remove all children of a node
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9455
function removeChildren(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9456
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9457
	while(e && e.hasChildNodes())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9458
		removeNode(e.firstChild);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9459
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9460
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9461
// Remove a node and all it's children
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9462
function removeNode(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9463
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9464
	scrubNode(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9465
	e.parentNode.removeChild(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9466
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9467
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9468
// Remove any event handlers or non-primitve custom attributes
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9469
function scrubNode(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9470
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9471
	if(!config.browser.isIE)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9472
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9473
	var att = e.attributes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9474
	if(att) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9475
		for(var t=0; t<att.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9476
			var n = att[t].name;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9477
			if(n !== 'style' && (typeof e[n] === 'function' || (typeof e[n] === 'object' && e[n] != null))) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9478
				try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9479
					e[n] = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9480
				} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9481
				}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9482
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9483
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9484
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9485
	var c = e.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9486
	while(c) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9487
		scrubNode(c);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9488
		c = c.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9489
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9490
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9491
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9492
// Add a stylesheet, replacing any previous custom stylesheet
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9493
function setStylesheet(s,id,doc)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9494
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9495
	if(!id)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9496
		id = "customStyleSheet";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9497
	if(!doc)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9498
		doc = document;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9499
	var n = doc.getElementById(id);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9500
	if(doc.createStyleSheet) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9501
		// Test for IE's non-standard createStyleSheet method
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9502
		if(n)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9503
			n.parentNode.removeChild(n);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9504
		// This failed without the &nbsp;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9505
		doc.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd","&nbsp;<style id='" + id + "'>" + s + "</style>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9506
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9507
		if(n) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9508
			n.replaceChild(doc.createTextNode(s),n.firstChild);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9509
		} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9510
			n = doc.createElement("style");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9511
			n.type = "text/css";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9512
			n.id = id;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9513
			n.appendChild(doc.createTextNode(s));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9514
			doc.getElementsByTagName("head")[0].appendChild(n);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9515
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9516
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9517
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9518
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9519
function removeStyleSheet(id)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9520
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9521
	var e = document.getElementById(id);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9522
	if(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9523
		e.parentNode.removeChild(e);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9524
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9525
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9526
// Force the browser to do a document reflow when needed to workaround browser bugs
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9527
function forceReflow()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9528
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9529
	if(config.browser.isGecko) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9530
		setStylesheet("body {top:0px;margin-top:0px;}","forceReflow");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9531
		setTimeout(function() {setStylesheet("","forceReflow");},1);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9532
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9533
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9534
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9535
// Replace the current selection of a textarea or text input and scroll it into view
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9536
function replaceSelection(e,text)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9537
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9538
	if(e.setSelectionRange) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9539
		var oldpos = e.selectionStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9540
		var isRange = e.selectionEnd > e.selectionStart;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9541
		e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionEnd);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9542
		e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + text.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9543
		var linecount = e.value.split('\n').length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9544
		var thisline = e.value.substr(0,e.selectionStart).split('\n').length-1;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9545
		e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / linecount);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9546
	} else if(document.selection) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9547
		var range = document.selection.createRange();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9548
		if(range.parentElement() == e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9549
			var isCollapsed = range.text == "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9550
			range.text = text;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9551
			if(!isCollapsed) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9552
				range.moveStart('character', -text.length);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9553
				range.select();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9554
			}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9555
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9556
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9557
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9558
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9559
// Returns the text of the given (text) node, possibly merging subsequent text nodes
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9560
function getNodeText(e)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9561
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9562
	var t = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9563
	while(e && e.nodeName == "#text") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9564
		t += e.nodeValue;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9565
		e = e.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9566
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9567
	return t;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9568
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9569
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9570
// Returns true if the element e has a given ancestor element
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9571
function isDescendant(e,ancestor)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9572
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9573
	while(e) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9574
		if(e === ancestor)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9575
			return true;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9576
		e = e.parentNode;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9577
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9578
	return false;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9579
}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9580
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9581
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9582
//-- LoaderBase and SaverBase
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9583
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9584
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9585
function LoaderBase() {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9586
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9587
LoaderBase.prototype.loadTiddler = function(store,node,tiddlers)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9588
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9589
	var title = this.getTitle(store,node);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9590
	if(safeMode && store.isShadowTiddler(title))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9591
		return;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9592
	if(title) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9593
		var tiddler = store.createTiddler(title);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9594
		this.internalizeTiddler(store,tiddler,title,node);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9595
		tiddlers.push(tiddler);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9596
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9597
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9598
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9599
LoaderBase.prototype.loadTiddlers = function(store,nodes)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9600
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9601
	var tiddlers = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9602
	for(var t = 0; t < nodes.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9603
		try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9604
			this.loadTiddler(store,nodes[t],tiddlers);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9605
		} catch(ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9606
			showException(ex,config.messages.tiddlerLoadError.format([this.getTitle(store,nodes[t])]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9607
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9608
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9609
	return tiddlers;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9610
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9611
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9612
function SaverBase() {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9613
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9614
SaverBase.prototype.externalize = function(store)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9615
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9616
	var results = [];
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9617
	var tiddlers = store.getTiddlers("title");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9618
	for(var t = 0; t < tiddlers.length; t++) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9619
		if(!tiddlers[t].doNotSave())
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9620
			results.push(this.externalizeTiddler(store, tiddlers[t]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9621
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9622
	return results.join("\n");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9623
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9624
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9625
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9626
//-- TW21Loader (inherits from LoaderBase)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9627
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9628
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9629
function TW21Loader() {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9630
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9631
TW21Loader.prototype = new LoaderBase();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9632
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9633
TW21Loader.prototype.getTitle = function(store,node)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9634
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9635
	var title = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9636
	if(node.getAttribute) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9637
		title = node.getAttribute("title");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9638
		if(!title)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9639
			title = node.getAttribute("tiddler");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9640
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9641
	if(!title && node.id) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9642
		var lenPrefix = store.idPrefix.length;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9643
		if(node.id.substr(0,lenPrefix) == store.idPrefix)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9644
			title = node.id.substr(lenPrefix);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9645
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9646
	return title;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9647
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9648
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9649
TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9650
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9651
	var e = node.firstChild;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9652
	var text = null;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9653
	if(node.getAttribute("tiddler")) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9654
		text = getNodeText(e).unescapeLineBreaks();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9655
	} else {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9656
		while(e.nodeName!="PRE" && e.nodeName!="pre") {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9657
			e = e.nextSibling;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9658
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9659
		text = e.innerHTML.replace(/\r/mg,"").htmlDecode();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9660
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9661
	var modifier = node.getAttribute("modifier");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9662
	var c = node.getAttribute("created");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9663
	var m = node.getAttribute("modified");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9664
	var created = c ? Date.convertFromYYYYMMDDHHMM(c) : version.date;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9665
	var modified = m ? Date.convertFromYYYYMMDDHHMM(m) : created;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9666
	var tags = node.getAttribute("tags");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9667
	var fields = {};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9668
	var attrs = node.attributes;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9669
	for(var i = attrs.length-1; i >= 0; i--) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9670
		var name = attrs[i].name;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9671
		if(attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9672
			fields[name] = attrs[i].value.unescapeLineBreaks();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9673
		}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9674
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9675
	tiddler.assign(title,text,modifier,modified,tags,created,fields);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9676
	return tiddler;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9677
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9678
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9679
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9680
//-- TW21Saver (inherits from SaverBase)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9681
//--
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9682
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9683
function TW21Saver() {}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9684
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9685
TW21Saver.prototype = new SaverBase();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9686
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9687
TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9688
{
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9689
	try {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9690
		var extendedAttributes = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9691
		var usePre = config.options.chkUsePreForStorage;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9692
		store.forEachField(tiddler,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9693
			function(tiddler,fieldName,value) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9694
				// don't store stuff from the temp namespace
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9695
				if(typeof value != "string")
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9696
					value = "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9697
				if(!fieldName.match(/^temp\./))
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9698
					extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9699
			},true);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9700
		var created = tiddler.created;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9701
		var modified = tiddler.modified;
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9702
		var attributes = tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9703
		attributes += (usePre && created == version.date) ? "" :' created="' + created.convertToYYYYMMDDHHMM() + '"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9704
		attributes += (usePre && modified == created) ? "" : ' modified="' + modified.convertToYYYYMMDDHHMM() +'"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9705
		var tags = tiddler.getTags();
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9706
		if(!usePre || tags)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9707
			attributes += ' tags="' + tags.htmlEncode() + '"';
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9708
		return ('<div %0="%1"%2%3>%4</'+'div>').format([
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9709
				usePre ? "title" : "tiddler",
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9710
				tiddler.title.htmlEncode(),
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9711
				attributes,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9712
				extendedAttributes,
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9713
				usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode()
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9714
			]);
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9715
	} catch (ex) {
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9716
		throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9717
	}
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9718
};
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9719
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9720
//]]>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9721
</script>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9722
<script type="text/javascript">
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9723
//<![CDATA[
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9724
if(useJavaSaver)
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9725
	document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>");
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9726
//]]>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9727
</script>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9728
<!--POST-SCRIPT-START-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9729
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9730
<!--POST-SCRIPT-END-->
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9731
</body>
e07c425c7135 Add taggable-mixin to Melange repository.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
  9732
</html>