-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfirstversion.html
More file actions
1235 lines (1046 loc) · 39.9 KB
/
firstversion.html
File metadata and controls
1235 lines (1046 loc) · 39.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
TiddlyWiki 1.0 by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
Copyright (c) Osmosoft Limited, 20 September 2004
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither the name of the Osmosoft Limited nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
-->
<html>
<head>
<title>TiddlyWiki</title>
<script type="text/javascript">
// ---------------------------------------------------------------------------------
// Main
// ---------------------------------------------------------------------------------
function main()
{
// Do the header, menu and sidebar
refreshAll();
// Display the StartHere tiddler
displayTiddler(null,'StartHere',1);
}
// ---------------------------------------------------------------------------------
// Tiddler functions
// ---------------------------------------------------------------------------------
// Display a tiddler with animation and scrolling, as though a link to it has been clicked on
// src = source element object (eg link) for animation effects and positioning
// title = title of tiddler to display
// state = 0 is default or current state, 1 is read only and 2 is edittable
function displayTiddler(src,title,state)
{
// Figure out the tiddler this one must go after
var after = findContainingTiddler(src);
//alert(after);
// Create the tiddler if needed
var theTiddler = createTiddler(title,state,after);
// Make it invisible if we got here on an event
if(src != null)
theTiddler.style.opacity = 0;
// Ensure the new tiddler is visible
ensureVisible(theTiddler);
// Animate from the target of the event that followed the link
if(src)
{
// Set the text of the floater to match the title
var floater = document.getElementById("floater");
var floaterTitle = document.createTextNode(title);
floater.replaceChild(floaterTitle,floater.firstChild);
// Animate the floater from the link location to the location of the new tiddler
startZoomer(floater,src,theTiddler);
}
}
// Create a tiddler if it doesn't exist (with no fancy animating). The tiddler is invisible unless it was already visible
// title = title of tiddler to display
// state = 0 is default or current state, 1 is read only and 2 is edittable
// after = optional existing tiddler element to put the new one after
function createTiddler(title,state,after)
{
// See if the tiddler div is already there
var theTiddler = document.getElementById("tiddler" + title);
if(!theTiddler)
{
// If it's not there, create the tiddler header
theTiddler = createTiddlerHeader(title,after);
// Create the tiddler body appropriately
if(state != 2)
createTiddlerBody(theTiddler,title);
else
createTiddlerEditor(theTiddler,title);
}
else
{
// If the tiddler does exist, make sure that it's in the right state
var theBody = document.getElementById("body" + title);
var theEditor = document.getElementById("editor" + title);
// Create and delete as appropriate
switch (state)
{
case 0: // For default state, leave everything alone
break;
case 1: // For read-only state, delete any editor
if(!theBody)
{
if(theEditor)
theEditor.parentNode.removeChild(theEditor);
createTiddlerBody(theTiddler,title);
}
break;
case 2: // For editor state, delete any read-only body
if(!theEditor)
{
if(theBody)
theBody.parentNode.removeChild(theBody);
createTiddlerEditor(theTiddler,title);
}
break;
}
}
// Return the completed tiddler
return(theTiddler);
}
// Create an invisible common header section of a tiddler
// title = title of tiddler to display
// after = optional existing tiddler element to put the new one after
function createTiddlerHeader(title,after)
{
// Create the tiddler div
theTiddler = createTiddlyElement(null,"div","tiddler",null);
theTiddler.setAttribute("id","tiddler" + title);
theTiddler.onmouseover = onMouseOverTiddler;
theTiddler.onmouseout = onMouseOutTiddler;
theTiddler.ondblclick = onDblClickTiddler;
// Get the subtitle
var subtitle = getTiddlerSubtitle(title);
theTiddler.title = subtitle;
// Link it in
var place = document.getElementById("tiddlerDisplay");
if(after)
{
if(after.nextSibling)
place.insertBefore(theTiddler,after.nextSibling);
else
place.appendChild(theTiddler);
}
else
{
if(place.firstChild)
place.insertBefore(theTiddler,place.firstChild);
else
place.appendChild(theTiddler);
}
// Create the anchor
var theAnchor = createTiddlyElement(theTiddler,"a",null,null);
theAnchor.setAttribute("name","link" + title);
// Create the title
var theTitle = createTiddlyElement(theTiddler,"div","title",title);
theTitle.setAttribute("id","title" + title);
// Return the created tiddler
return(theTiddler);
}
// Create a tiddler toolbar according to whether it's an editor or not
function createTiddlerToolbar(title,editor)
{
// Delete any existing toolbar
var theToolbar = document.getElementById("toolbar" + title);
if(theToolbar)
theToolbar.parentNode.removeChild(theToolbar);
// Create the toolbar
var theTitle = document.getElementById("title" + title);
var theToolbar = createTiddlyElement(theTitle,"div","toolbar", String.fromCharCode(160));
theToolbar.setAttribute("id","toolbar" + title);
// Create each button in turn
if(!editor)
{
// Non-editor toolbar
createTiddlyButton(theToolbar,
"close",
"Close this tiddler",
onClickToolbarClose);
theToolbar.appendChild(document.createTextNode(String.fromCharCode(160)));
createTiddlyButton(theToolbar,
"link",
"Permalink for this tiddler",
onClickToolbarLink);
theToolbar.appendChild(document.createTextNode(String.fromCharCode(160)));
createTiddlyButton(theToolbar,
"edit",
"Edit this tiddler",
onClickToolbarEdit);
}
else
{
// Editor toolbar
createTiddlyButton(theToolbar,
"done",
"Finish changing this tiddler",
onClickToolbarSave);
theToolbar.appendChild(document.createTextNode(String.fromCharCode(160)));
createTiddlyButton(theToolbar,
"undo",
"Undo changes to this tiddler",
onClickToolbarUndo);
theToolbar.appendChild(document.createTextNode(String.fromCharCode(160)));
createTiddlyButton(theToolbar,
"delete",
"Delete this tiddler",
onClickToolbarDelete);
}
}
// Create the body section of a read-only tiddler
function createTiddlerBody(place,title)
{
// Create the toolbar
createTiddlerToolbar(title,false);
// Get the body of the tiddler
var tiddlerText = getTiddlerText(title);
var tiddlerExists = (tiddlerText != null);
if(!tiddlerExists)
tiddlerText = "[This tiddler doesn't yet exist. Double-click to create it]";
// Create the body
var theBody = createTiddlyElement(place,"div","body",null);
theBody.setAttribute("id","body" + title);
if(!tiddlerExists)
theBody.style.fontStyle = "italic";
// Add the body text wikifing the links
wikify(tiddlerText,theBody);
}
// Create the body section of a read-only tiddler
function createTiddlerEditor(place,title)
{
// Create the toolbar
createTiddlerToolbar(title,true);
// Get the body of the tiddler
var tiddlerText = getTiddlerText(title);
var tiddlerExists = (tiddlerText != null);
if(!tiddlerExists)
tiddlerText = "Type the text for '" + title + "' here.";
// Create the editor div
var theEditor = createTiddlyElement(place,"div","editor",null);
theEditor.setAttribute("id","editor" + title);
// Create the title editor
var theTitle = createTiddlyElement(theEditor,"div",null,null);
var theTitleBox = createTiddlyElement(theTitle,"input",null,null);
theTitleBox.setAttribute("id","editorTitle" + title);
theTitleBox.setAttribute("type","text");
theTitleBox.value = title;
theTitleBox.setAttribute("size","40");
// Do the body
var theBody = createTiddlyElement(theEditor,"div",null,null);
var theBodyBox = createTiddlyElement(theBody,"textarea",null,null);
theBodyBox.value = tiddlerText;
theBodyBox.setAttribute("id","editorBody" + title);
theBodyBox.setAttribute("rows","10");
theBodyBox.setAttribute("cols","50");
}
// Create child text nodes and link elements to represent a wiki-fied version of some text
function wikify(text,parent)
{
// Link patterns
var upperLetter = "[A-Z]";
var lowerLetter = "[a-z]";
var anyLetter = "[A-Za-z_0-9]";
var linkPattern = upperLetter + "+" + lowerLetter + "+" + upperLetter + anyLetter + "*";
var urlPattern = "(?:http|https|mailto|ftp):\\S*";
var breakPattern = "\\n";
// Create the RegExp object
var theRegExp = new RegExp("(" + linkPattern + ")|(" + urlPattern + ")|(" + breakPattern + ")","mg");
// Set the position after the last match
var lastMatch = 0;
// Loop through the bits of the body text
do {
// Get the next match
var theMatch = theRegExp.exec(text);
if(theMatch)
{
// If so, dump out any text before the link
if(theMatch.index > lastMatch)
parent.appendChild(document.createTextNode(text.substring(lastMatch,theMatch.index)));
lastMatch = theRegExp.lastIndex;
// Dump out the link itself in the appropriate format
if(theMatch[1])
createTiddlyLink(parent,theMatch[0],true);
else if(theMatch[2])
createExternalLink(parent,theMatch[0]);
else if(theMatch[3])
parent.appendChild(document.createElement("br")); }
else
{
// If no match, just dump out the remaining text
parent.appendChild(document.createTextNode(text.substring(lastMatch)));
}
} while(theMatch != null);
}
function saveTiddler(title)
{
// Get the title and body text
var theNewTitle = document.getElementById("editorTitle" + title).value;
var theNewBody = document.getElementById("editorBody" + title).value;
// Remove any existing entry from the store
var theExisting = document.getElementById("store" + title);
if(theExisting)
theExisting.parentNode.removeChild(theExisting);
// Create the new entry in the store
var place = document.getElementById("storeArea");
var storeItem = createTiddlyElement(place,"div",null,theNewBody);
storeItem.setAttribute("id","store" + theNewTitle);
var now = new Date();
storeItem.setAttribute("modified",ConvertToYYYYMMDDHHMM(now));
storeItem.setAttribute("modifier","JeremyRuston");
// Display the new tiddler read-only
displayTiddler(null,theNewTitle,1,null);
// Refresh the menu and sidebars to take it into account
refreshAll();
}
function selectTiddler(title)
{
// Change the background colour
var e = document.getElementById("tiddler" + title);
if(e != null)
e.className = "tiddlerSelected";
// Make the toolbar visible
e = document.getElementById("toolbar" + title);
if(e != null)
e.style.visibility = "visible";
}
function deselectTiddler(title)
{
// Change the background colour
var e = document.getElementById("tiddler" + title);
if(e != null)
e.className = "tiddler";
// Make the toolbar invisible
e = document.getElementById("toolbar" + title);
if(e != null)
e.style.visibility = "hidden";
}
function deleteTiddler(title)
{
// Remove the tiddler from the display
closeTiddler(title);
// Delete it from the store
var tiddler = document.getElementById("store" + title);
if(tiddler)
tiddler.parentNode.removeChild(tiddler);
// Refresh the menu and sidebars to take it into account
refreshAll();
}
function closeTiddler(title)
{
var tiddler = document.getElementById("tiddler" + title);
if(tiddler != null)
tiddler.parentNode.removeChild(tiddler);
}
function closeAllTiddlers()
{
// Delete all the elements in the displayArea
var e = document.getElementById("tiddlerDisplay");
while(e.firstChild != null)
e.removeChild(e.firstChild);
}
// ---------------------------------------------------------------------------------
// Tiddler-related utility functions
// ---------------------------------------------------------------------------------
function getTiddlerText(title)
{
// Attempt to retrieve it from the store
var tiddlerStore = document.getElementById("store" + title);
if(tiddlerStore != null)
return(tiddlerStore.firstChild.nodeValue);
else
return(null);
}
function getTiddlerSubtitle(title)
{
var tiddlerStore = document.getElementById("store" + title);
if(tiddlerStore != null)
{
var theModifier = tiddlerStore.getAttribute("modifier");
if(!theModifier)
theModifier = "(unknown)";
var theModified = tiddlerStore.getAttribute("modified");
if(theModified)
theModified = ConvertFromYYYYMMDDHHMM(theModified);
else
theModified = "(unknown)";
return("Modified by " + theModifier + " on " + theModified);
}
else
return(null);
}
function createTiddlyElement(theParent,theElement,theClass,theText)
{
var e = document.createElement(theElement);
if(theClass != null)
e.className = theClass;
if(theText != null)
e.appendChild(document.createTextNode(theText));
if(theParent != null)
theParent.appendChild(e);
return(e);
}
function createTiddlyButton(theParent,theText,theTooltip,theAction)
{
var theButton = document.createElement("a");
theButton.onclick = theAction;
theButton.setAttribute("href","JavaScript:;");
theButton.setAttribute("title",theTooltip);
theButton.appendChild(document.createTextNode(theText));
theParent.appendChild(theButton);
return(theButton);
}
// Create a link to a tiddler
function createTiddlyLink(place,title,styleIt)
{
// Figure out if the wiki word exists
var btn;
if(getTiddlerText(title) == null)
{
// If it does not exist
btn = createTiddlyButton(place,title,
title + " doesn't yet exist",
onClickTiddlerLink);
if(styleIt)
btn.style.fontStyle = "italic";
}
else
{
// If it does exist
btn = createTiddlyButton(place,title,
getTiddlerSubtitle(title),
onClickTiddlerLink);
if(styleIt)
btn.style.fontWeight = "bold";
}
}
// Create an external link
function createExternalLink(place,url)
{
var theLink = document.createElement("a");
theLink.setAttribute("href",url);
theLink.setAttribute("title","External link to " + url);
theLink.setAttribute("target","_blank");
theLink.appendChild(document.createTextNode(url));
place.appendChild(theLink);
}
// Find the tiddler instance (if any) containing a specified element
function findContainingTiddler(e)
{
if(e == null)
return(null);
do {
if(e != document)
{
if(e.id)
if(e.id.substr(0,7) == "tiddler")
return(e);
}
e = e.parentNode;
} while(e != document);
return(null);
}
// ---------------------------------------------------------------------------------
// Menu and sidebar functions
// ---------------------------------------------------------------------------------
// Refresh everything
function refreshAll()
{
refreshHeader();
refreshMenu();
refreshSidebar();
}
// Refresh all parts of the header
function refreshHeader()
{
// Get the site title and subtitle
var theTitle = getTiddlerText("SiteTitle");
var theSubtitle = getTiddlerText("SiteSubtitle");
// Set the page title
document.title = theTitle + " - " + theSubtitle;
// Do the title
var place = document.getElementById("headerTitle");
while(place.firstChild != null)
place.removeChild(place.firstChild);
wikify(theTitle,place);
// Do the subtitle
var place = document.getElementById("headerSubtitle");
while(place.firstChild != null)
place.removeChild(place.firstChild);
wikify(theSubtitle,place);
}
// Refresh all parts of the main menu
function refreshMenu()
{
var place = document.getElementById("leftMenuMain");
while(place.firstChild != null)
place.removeChild(place.firstChild);
var theMenu = document.createElement("div");
place.appendChild(theMenu);
wikify(getTiddlerText("MainMenu"),theMenu);
}
// Refresh all parts of the sidebar
function refreshSidebar()
{
// Get names and dates of all tiddlers from the store
var allTiddlers = new Array(); // Will be an array of 2-entry arrays, where entry 0 = name, 1 = date
var storeNodes = document.getElementById("storeArea").childNodes;
for (var t = 0; t < storeNodes.length; t++)
{
var n = storeNodes[t];
if(n.id)
if(n.id.substr(0,5) == "store")
allTiddlers.push(new Array(n.id.substr(5),n.getAttribute("modified")));
}
// Sort the tiddlers by name
allTiddlers.sort(function (a,b) { if(a[0] == b[0]) return(0); else return (a[0] > b[0]) ? +1 : -1; });
// Delete any existing entries in the 'all' list
var place = document.getElementById("sidebarAllTiddlers");
while(place.firstChild != null)
place.removeChild(place.firstChild);
// Output the links
var separator = false;
for (t = 0; t < allTiddlers.length; t++)
{
if(separator)
place.appendChild(document.createElement("br"));
createTiddlyLink(place,allTiddlers[t][0],false)
separator = true;
}
// Sort the tiddlers by date
allTiddlers.sort(function (a,b) { if(a[1] == b[1]) return(1); else return (a[1] < b[1]) ? +1 : -1; });
// Delete any existing entries in the 'recent' list
var place = document.getElementById("sidebarRecentTiddlers");
while(place.firstChild != null)
place.removeChild(place.firstChild);
// Output the most recent few as links
var separator = false;
var inList = 5;
if (allTiddlers.length < inList)
inList = allTiddlers.length;
for (t = 0; t < inList; t++)
{
if(separator)
place.appendChild(document.createElement("br"));
createTiddlyLink(place,allTiddlers[t][0],false)
separator = true;
}
}
// ---------------------------------------------------------------------------------
// Quine (http://www.google.com/search?q=quine&ie=UTF-8&oe=UTF-8)
// ---------------------------------------------------------------------------------
// Get the text of the TiddlyWiki HTML file itself, incorporating new edits
function ShowSource()
{
// Create the popup window
var srcWindow = window.open("","sourceWindow","width=700,height=600");
var srcDocument = srcWindow.document;
// Jam in the text template
srcDocument.write("<html><head></head><body>" +
window.document.getElementById("saveMessage").innerHTML +
"</body></html>");
srcDocument.close();
// Get a reference to the text area
var theTextBox = srcDocument.getElementById("source");
// Jam in the current source
//theTextBox.value = "<html>\n" + window.document.getElementsByTagName("html")[0].innerHTML + "\n</html>";
theTextBox.value = window.document.getElementById("storeArea").innerHTML; // Optionally, add .replace(/\n+/g, "\n");
// Select the text in the textbox
theTextBox.focus();
theTextBox.select();
;
}
// ---------------------------------------------------------------------------------
// Event handlers
// ---------------------------------------------------------------------------------
// Event handler for clicking on the logo
function onClickLogo(e)
{
closeAllTiddlers();
displayTiddler(document.getElementById("headerTitle"),"StartHere",1);
}
// Event handler for clicking on a tiddly link
function onClickTiddlerLink(e)
{
// Get the text of the link
var title;
if(this.firstChild)
title = this.firstChild.nodeValue;
else if (this.nodeValue)
title = this.nodeValue;
// Display that tiddler
if(title)
displayTiddler(this,title,0);
}
// Event handler for mouse over a tiddler
function onMouseOverTiddler(e)
{
// Get the name of this tiddler
var tiddler;
if(this.id.substr(0,7) == "tiddler")
tiddler = this.id.substr(7);
// Select that tiddler
if(tiddler)
selectTiddler(tiddler);
}
// Event handler for mouse out of a tiddler
function onMouseOutTiddler(e)
{
// Get the name of this tiddler
var tiddler;
if(this.id.substr(0,7) == "tiddler")
tiddler = this.id.substr(7);
// Deselect that tiddler
if(tiddler)
deselectTiddler(tiddler);
}
// Event handler for double click on a tiddler
function onDblClickTiddler(e)
{
// Empty the current selection
if(document.selection)
document.selection.empty();
// Get the name of this tiddler
var tiddler;
if(this.id.substr(0,7) == "tiddler")
tiddler = this.id.substr(7);
// Deselect that tiddler
if(tiddler)
displayTiddler(null,tiddler,2);
}
// Event handler for clicking on toolbar close
function onClickToolbarClose(e)
{
// Close that tiddler
if(this.parentNode.id)
closeTiddler(this.parentNode.id.substr(7));
}
// Event handler for clicking on toolbar close
function onClickToolbarDelete(e)
{
// Close that tiddler
if(this.parentNode.id)
deleteTiddler(this.parentNode.id.substr(7));
}
// Event handler for clicking on toolbar link
function onClickToolbarLink(e)
{
// Close all other tiddlers
if(this.parentNode.id)
{
closeAllTiddlers();
displayTiddler(null,this.parentNode.id.substr(7),1);
}
}
// Event handler for clicking on toolbar close
function onClickToolbarEdit(e)
{
// Edit that tiddler
if(this.parentNode.id)
displayTiddler(null,this.parentNode.id.substr(7),2);
}
// Event handler for clicking on toolbar save
function onClickToolbarSave(e)
{
// Save that tiddler
if(this.parentNode.id)
saveTiddler(this.parentNode.id.substr(7));
}
// Event handler for clicking on toolbar save
function onClickToolbarUndo(e)
{
// Redisplay that tiddler in read-only mode
if(this.parentNode.id)
displayTiddler(null,this.parentNode.id.substr(7),1);
}
// ---------------------------------------------------------------------------------
// Animation engine
// ---------------------------------------------------------------------------------
// Animation housekeeping
var animating = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
var animaterID; // ID of the timer used for animating
// 'zoomer' module of the animation engine that smoothly moves an element from the position/size of the start element to th etarget element
var zoomerElement = null; // Element being shifted; null if none
var zoomerStart; // Where we're shifting to
var zoomerTarget; // Where we're shifting to
var zoomerProgress; // 0..1 of how far we are
var zoomerStep; // 0..1 of how much to shift each step
// Start animation engine
function startAnimating()
{
if(animating++ == 0)
animaterID = window.setInterval("doAnimate();",25);
}
// Stop animation engine
function stopAnimating()
{
if(--animating == 0)
window.clearInterval(animaterID)
}
// Perform an animation engine tick, calling each of the known animation modules
function doAnimate()
{
if(zoomerElement != null)
doZoomer();
}
// Start moving the element 'e' from the position of the element 'start' to the position of the element 'target'
function startZoomer(e,start,target)
{
stopZoomer();
zoomerElement = e;
zoomerStart = start;
zoomerTarget = target;
zoomerProgress = 0;
zoomerStep = 0.08;
startAnimating();
}
// Stop any ongoing zoomer animation
function stopZoomer()
{
if(zoomerElement != null)
{
stopAnimating();
zoomerElement.style.visibility = "hidden";
zoomerElement = null;
}
}
// Perform a tick of the zoomer animation
function doZoomer()
{
zoomerProgress += zoomerStep;
if(zoomerProgress > 1.0)
stopZoomer();
else
{
zoomerTarget.style.opacity = zoomerProgress;
var f = slowInSlowOut(zoomerProgress);
var zoomerStartLeft = findPosX(zoomerStart);
var zoomerStartTop = findPosY(zoomerStart);
var zoomerStartWidth = zoomerStart.offsetWidth;
var zoomerStartHeight = zoomerStart.offsetHeight;
var zoomerTargetLeft = findPosX(zoomerTarget);
var zoomerTargetTop = findPosY(zoomerTarget);
var zoomerTargetWidth = zoomerTarget.offsetWidth;
var zoomerTargetHeight = zoomerTarget.offsetHeight;
zoomerElement.style.left = zoomerStartLeft + (zoomerTargetLeft-zoomerStartLeft) * f;
zoomerElement.style.top = zoomerStartTop + (zoomerTargetTop-zoomerStartTop) * f;
zoomerElement.style.width = zoomerStartWidth + (zoomerTargetWidth-zoomerStartWidth) * f;
zoomerElement.style.height = zoomerStartHeight + (zoomerTargetHeight-zoomerStartHeight) * f;
zoomerElement.style.visibility = "visible";
}
}
// ---------------------------------------------------------------------------------
// Standalone utility functions
// ---------------------------------------------------------------------------------
// Return a date in UTC YYYYMMDDHHMM format
function ConvertToYYYYMMDDHHMM(d)
{
return(d.getFullYear() + '' + (d.getMonth() <= 8 ? '0' : '') + (d.getMonth() + 1) + '' + (d.getDate() <= 9 ? '0' : '') + d.getDate() + (d.getHours() <= 9 ? '0' : '') + d.getHours() + (d.getMinutes() <= 9 ? '0' : '') + d.getMinutes());
}
// Convert a date in UTC YYYYMMDDHHMM format to printable local time
function ConvertFromYYYYMMDDHHMM(d)
{
var theDate = new Date(parseInt(d.substr(0,4),10),
parseInt(d.substr(4,2),10)-1,
parseInt(d.substr(6,2),10),
parseInt(d.substr(8,2),10),
parseInt(d.substr(10,2),10),0,0);
return(theDate.toLocaleString());
}
// Map a 0..1 value to 0..1, but slow down at the start and end
function slowInSlowOut(progress)
{
return(1-((Math.cos(progress * Math.PI)+1)/2));
}
// Scroll if necessary to ensure that a given element is visible
function ensureVisible(e)
{
// The position we're trying to scroll into view; the top of it...
var posY = findPosY(e);
// ...or, if the element will fit on the screen, the bottom of it
if(e.offsetHeight < window.innerHeight)
posY += e.offsetHeight;
// Make sure the chosen position is visible
if ((posY < window.scrollY) || (posY > (window.scrollY + window.innerHeight)))
window.scrollTo(0,posY);
}
// From QuirksMode.com
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
// From QuirksMode.com
function findPosY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
// ---------------------------------------------------------------------------------
// End of scripts
// ---------------------------------------------------------------------------------
</script>
<style type="text/css">
body {
background-color: #ffffff;
font-size: 9pt;
font-family: tahoma,arial,helvetica;
margin: 0px 0px 0px 0px;
}
img {
border: none;
}
#header {
width: 789px;
margin: 0px 16px 16px 16px;
padding: 6px 6px 6px 6px;
border-bottom: 2px solid #4d5577;
background-color: #a2b3f9;
font-size: 16pt;
text-shadow: #4d5577 3px 3px 8px;
}
#headerTitle {
font-size: 30pt;
font-weight: bold;
}
#headerSubtitle {
font-family: georgia,times;
font-style: italic;
color: #4d5577;
}
#header a:link, #header a:visited {
text-decoration: none;
color: #000000;
}
#leftMenu {
float: left;
width: 127px;
background: #fbe9a2;
color: black;
text-align: right;
border: 1px dotted #46412d;
margin: 0px 6px 16px 16px;
}
#leftMenu div {
font-size: 10pt;
padding: 6px 6px 6px 6px;
overflow: hidden;
line-height: 140%;
}
#leftMenu a:link, #leftMenu a:visited {
text-decoration: none;
color: #46412d;
}
#leftMenu a:hover {
color: #fbe9a2;
background-color: #46412d;
}
#sidebar {
float: left;
width: 145px;
margin: 0px 0px 0px 6px;
padding: 6px 6px 6px 6px;
color: #777777;
font-size: 8pt;
background-color: #ffffff;
border-left: 1px solid #777777;
}
#sidebar a:link, #sidebar a:visited {
color: #777777;
text-decoration: none;
}
#sidebar a:hover {
color: blue;
text-decoration: underline;
}
#displayArea {
float: left;
width: 511px;
}
.tiddler {
font-family: georgia,times;
padding: 8px 8px 8px 8px;
background-color: #ffffff;
}
.tiddlerSelected {
font-family: georgia,times;
padding: 8px 8px 8px 8px;
background-color: #d5e7ff;
}
.title {
font-family: tahoma,arial,helvetica;
font-size: 10pt;
color: #5d1914;
font-weight: bold;
display: inline;
text-shadow: #AAAAAA 3px 3px 3px;
}
.body {
padding-top: 2px;