/***\n!Metadata:\n|''Name:''|XMLReader|\n|''Description:''||\n|''Version:''|1.2.0|\n|''Date:''|Jul 20, 2006|\n|''Source:''|http://sourceforge.net/project/showfiles.php?group_id=150646|\n|''Author:''|BramChen (bram.chen (at) gmail (dot) com)|\n|''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License]]|\n|''~CoreVersion:''|2.1.0|\n|''Browser:''|Firefox 1.5+; InternetExplorer 6.0|\n!Syntax:\n{{{<<xmlreader withDesc|noDesc|asHtml rssfeed.xml|http://www.example.com/rssfeed.rdf>>}}}\n!Revision History:\n|''Version''|''Date''|''Note''|\n|1.2.0|Jul 20, 2006|Runs compatibly with TW 2.1.0 (rev #403+)|\n|1.1.0|Jul 10, 2006)|change xmlhttp.send(null)/send() to xmlhttp.send("") for more compatibility for some browsers|\n|1.0.0|Mar 11, 2006|Initial release|\n|~|~|This macro is reworked from RssNewsMacro, but it can be easy to extended to support different structure of xml document from rss feeds|\n|~|~|You could uninstall the RssNewsMacro, but still use the original syntax,<<br>>{{{<<rssfeed withDesc|noDesc|asHtml rssfeed.xml|http://www.example.com/rssfeed.rdf>>}}}|\n\n!Code section:\n***/\n\n//{{{\nversion.extensions.xmlreader = {major: 1, minor: 2, revision: 0,\n date: new Date("Jul 20, 2006"),\n name: "XMLReader",\n type: "Macro",\n author: "BramChen",\n source: "http://sourceforge.net/project/showfiles.php?group_id=150646"\n};\nconfig.macros.xmlreader= {\n itemStructure:{title:'Title',link:'Link',pubDate:'PubDate',description:'Desc'},\n// rsTemplate:function(){var t='';for (var i in itemStructure){t+='_'+itemStructure[i]}},\n rsTemplate:'_pubDate\sn**[[_title|_link]]_description',\n items: {Elm: "%0Elm", Text: "_%0"},\n keyItem: "item",\n dateFormat: "DDD, DD MMM YYYY",\n msg:{\n permissionDenied: "Permission to read preferences was denied.",\n errorInDataRetriveing: "Problem retrieving XML data: %0",\n invalidXML: "Invalid XML retrieved from: %0",\n urlNotAccessible: "Access to %0 is not allowed,\snPlease check the setting of your browser:\sn1.For Gecko based, you should set the 'signed.applets.codebase_principal_support' to be true, in about:config.\sn2.For IE, you should add this web site to your trust list."\n },\n cache: [], // url => request\n withDesc: null,\n xmlURL: null,\n groupBy: null,\n xmlhttp: null,\n place:null\n};\n\nconfig.macros.xmlreader.handler = function(place,macroName,params){\n this.withDesc = params[0];\n this.xmlURL = params[1];\n this.place=place;\n if (this.cache[this.xmlURL]) {\n wikify("^^(//from cache//)^^\sn",place);\n this.processResponse(this.xmlURL,this.cache[this.xmlURL]);\n }\n else {\n this.asyncGet(this.xmlURL,this.processResponse);\n }\n};\n\nconfig.macros.xmlreader.asyncGet = function (xmlURL,callback){\n var xmlhttp;\n try {xmlhttp=new XMLHttpRequest();}\n catch (e) {\n try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}\n catch (e) {\n try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}\n catch (e) { displayMessage(e.description?e.description:e.toString());}\n }\n }\n if (!xmlhttp){\n return;\n }\n this.xmlhttp = xmlhttp;\n if (window.netscape){\n if (!this.testURL(xmlURL)){\n try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");}\n catch (e) { displayMessage(e.description?e.description:e.toString()); }\n }\n }\n// if (xmlhttp.overrideMimeType) {xmlhttp.overrideMimeType('text/xml');}\n\n xmlhttp.onreadystatechange=function(){\n var xmlhttp = config.macros.xmlreader.xmlhttp;\n if (xmlhttp.readyState==4) {\n if (xmlhttp.status==200 || xmlhttp.status===0) {\n if (callback) callback(xmlURL,xmlhttp);\n }\n else {\n displayMessage(config.macros.xmlreader.msg.errorInDataRetriveing.format([xmlhttp.statusText]));\n }\n }\n };\n try {\n var url=xmlURL+(xmlURL.indexOf('?')<0?'?':'&')+'nocache='+Math.random();\n xmlhttp.open("GET",url,true);\n xmlhttp.send("");\n }\n catch (e) {\n wikify(e.toString()+this.msg.urlNotAccessible.format([xmlURL]), this.place);\n }\n};\n\nconfig.macros.xmlreader.processResponse = function(xmlURL,xmlhttp){\n if (window.netscape){\n if (!config.macros.xmlreader.testURL(xmlURL)){\n try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");}\n catch (e) { displayMessage(e.description?e.description:e.toString()); }\n }\n }\n if (xmlhttp.responseXML){\n config.macros.xmlreader.cache[xmlURL] = xmlhttp;\n config.macros.xmlreader.genLists(xmlhttp.responseXML);\n }\n else {\n wikify("<html>"+xmlhttp.responseText+"</html>", this.place);\n displayMessage(this.msg.invalidXML.format([xmlURL]));\n }\n};\n \nconfig.macros.xmlreader.genLists = function(xml){\n var itemList = xml.getElementsByTagName(this.keyItem);\n var itemStructure = this.itemStructure;\n var items = this.items;\n var rsLists='', rssItem; this.groupBy='';\n for (var i=0; i<itemList.length; i++){\n var itemElms=[],itemTexts=[];\n var rsTemplate=this.rsTemplate;\n for (var j in itemStructure){\n var itemElm = items.Elm.format([j]);\n var itemText = items.Text.format([j]);\n itemElms[itemElm] = itemList[i].getElementsByTagName(j).item(0);\n if(itemElms[itemElm]){\n var theTitle = itemStructure[j];\n var theText = (itemElms[itemElm].firstChild)?itemElms[itemElm].firstChild.nodeValue:'';\n rsTemplate=this.convertTemplate(rsTemplate,j,theText);\n }\n else {\n rsTemplate = rsTemplate.replace('_'+j, '');\n }\n }\n rsLists += rsTemplate;\n }\n wikify(rsLists,this.place);\n};\n \nconfig.macros.xmlreader.convertTemplate = function(rsTemplate,j,theText){\n switch (j){\n case 'title':\n rsTemplate = rsTemplate.replace(/_title/,theText.replace(/\s[|\s]/g,''));\n break;\n case 'link':\n rsTemplate = rsTemplate.replace(/_link/, theText);\n break;\n case 'pubDate':\n theText = this.formatString(this.dateFormat, theText);\n if (this.groupBy == theText){\n rsTemplate = rsTemplate.replace(/_pubDate/, '');\n }\n else{\n rsTemplate = rsTemplate.replace(/_pubDate/, '\sn* '+theText);\n this.groupBy = theText;\n }\n break;\n case 'description':\n var regexpDesc = new RegExp("withDesc|asHtml","g");\n if (regexpDesc.exec(this.withDesc) && theText){\n var _description = theText.replace(/\sn/g,' ');\n _description =_description.replace(/<br \s/>/ig,'\sn'); \n if (version.extensions.nestedSliders){\n _description = ((this.withDesc == "asHtml")?"<html>"+_description+"</html>":_description);\n rsTemplate = rsTemplate.replace(/_description/,'+++[...]'+_description+'\sn===\sn');\n }\n else {\n rsTemplate = rsTemplate.replace(/_description/,_description+'\sn');\n }\n }\n else {\n rsTemplate = rsTemplate.replace(/_description/,'');\n }\n break;\n }\n return (rsTemplate);\n};\n \nconfig.macros.xmlreader.formatString = function(template, theDate){\n var dateString = new Date(theDate);\n template = template.replace(/hh|mm|ss/g,'');\n return dateString.formatString(template);\n};\nconfig.macros.xmlreader.testURL = function (url){\n var rsURL={protocol: '', host: '', hostname:'', port:'', path: ''};\n if (url.indexOf(':') == -1) {\n return true;\n }\n rsURL.protocol = url.substr(0,url.indexOf(":")+1);\n var s1 = url.substr(url.lastIndexOf("//")+2);\n var i = s1.indexOf(':');\n if (i != -1){\n rsURL.host=s1.substr(0,s1.indexOf("/"));\n rsURL.hostname = s1.substr(0,i);\n var s2 = s1.substr(i+1);\n var j = s2.indexOf("/");\n if ( j != -1){\n rsURL.port = s2.substr(0, j);\n rsURL.path = s2.substr(j);\n }\n else {\n rsURL.port = s2;\n }\n }\n else {\n if (s1.indexOf("/") != -1){\n rsURL.host = s1.substr(0,s1.indexOf("/"));\n rsURL.hostname = rsURL.host;\n rsURL.path = s1.substr(s1.indexOf("/"));\n }\n else {\n rsURL.host = s1;\n rsURL.hostname = s1;\n }\n }\n var curLoc = document.location;\n// var curPort = curLoc.host.substr(curLoc.host.indexOf(":")+1);\n var result = (curLoc.protocol == rsURL.protocol && curLoc.host == rsURL.host);\n return (result);\n};\n//}}}\n// // ''Redefine RssNewsMacro''\n//{{{\nconfig.macros.rssfeed=config.macros.xmlreader;\n//}}}
/***\n!Metadata:\n|''Name:''|ArchivedTimeline|\n|''Description:''|Timeline archived monthly.|\n|''Version:''|0.6.1|\n|''Date:''|Jul 25, 2006|\n|''Source:''|http://sourceforge.net/project/showfiles.php?group_id=150646|\n|''Author:''|BramChen (bram.chen (at) gmail (dot) com)|\n|''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License]]|\n|''~CoreVersion:''|2.0.11|\n|''Browser:''|Firefox 1.5+; InternetExplorer 6.0|\n\n!Syntax/Examples:\n|{{{<<timeline [modified | created] [maxentries]>>}}}|\n!Revision History:\n|''Version''|''Date''|''Note''|\n|0.6.1|Aug 12, 2006|A great effect on config.macros.timeline.slider for Firefox, thanks Bob McElrath|\n|0.6.0|Jul 25, 2006|Runs compatibly with TW 2.1.0 (rev #403+)|\n|0.5.2|Jun 21, 2006|Fixed bugs for dateFormat of TW 2.1|\n|~|~|Change default dateFormat to "0DD mmm, YYYY"|\n|0.5.1|Jun 04, 2006|Added config.macros.archivedTimeline.orderBy for localization|\n|0.5.0|Apr 19, 2006|Fixed bug for twice records of the same date ()|\n|~|~|Added Date.prototype.convertToLocalYYYYMMDDHHMM<<br>>in order to backward compatible with 2.0.6-|\n|0.4.0|Apr 03, 2006|Added new parameter, {{{<<timeline [sortfield] [maxentries]>>}}}|\n|~|~|Added config.options.txtTimelineMaxentries|\n|0.3.1|Feb 04, 2006|JSLint checked|\n|0.3.0|Feb 04, 2006|Fixed several missing variable declarations|\n|0.2.0|Dec 26, 2005|changed for the new feature of Macro timeline of TW 2.0.0 beta 6|\n|0.1.0|Nov 3, 2005|Initial release|\n\n!Code section:\n***/\n//{{{\nversion.extensions.archivedTimeline = {major: 0, minor: 6, revision: 1,\n date: new Date("Aug 12, 2006"),\n name: "ArchivedTimeline",\n type: "Macro",\n author: "BramChen",\n source: "http://sourceforge.net/project/showfiles.php?group_id=150646"\n};\nconfig.options.txtTimelineMaxentries=0;\nconfig.macros.archivedTimeline = {\n tooltips: "Archives sorted by ",\n orderBy:{modified: "modified", created: "created"},\n dateFormat: "0DD mmm YYYY"\n};\nconfig.macros.timeline = config.macros.archivedTimeline;\n\nconfig.macros.timeline.handler = function(place,macroName,params) {\n var field = params[0] ? params[0] : "modified";\n\n place.appendChild(document.createTextNode(this.tooltips + this.orderBy[field]));\n var tiddlers = store.reverseLookup("tags","excludeLists",false,field);\n var lastMonth = ""; var lastDay = ""; var theText = "----\sn"; var i = 0;\n var last = (params[1])?params[1]:config.options.txtTimelineMaxentries;\n last = (isNaN(last)||last<1) ? 0:tiddlers.length-Math.min(tiddlers.length,parseInt(last));\n var cookie; var archives;\n for (var t=tiddlers.length-1; t>=last; t--) {\n var tiddler = tiddlers[t];\n var theMonth = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,6);\n var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);\n if(theMonth != lastMonth) {\n if (lastMonth === "") {\n lastMonth = theMonth;\n }\n else {\n place.appendChild(document.createElement("hr"));\n cookie = 'chktimeline'+(i++);\n archives = this.formatString(this.dateFormat, lastMonth);\n this.slider(place,cookie,theText,archives,this.tooltips + archives);\n lastMonth = theMonth; theText = "----\sn";\n }\n }\n if(theDay != lastDay){\n theText += tiddler[field].formatString(this.dateFormat) + '\sn';\n lastDay = theDay; \n }\n theText += '* [[' + tiddler.title + ']]\sn';\n }\n place.appendChild(document.createElement("hr"));\n cookie = 'chktimeline'+(i++);\n archives = this.formatString(this.dateFormat, lastMonth);\n this.slider(place,cookie,theText,archives,this.tooltips + archives);\n place.appendChild(document.createElement("hr"));\n};\n\nconfig.macros.timeline.onClickSlider = config.macros.slider.onClickSlider;\n\nconfig.macros.timeline.slider = function(place,cookie,text,id,tooltips)\n{\n var btn = createTiddlyButton(place,id,tooltips,this.onClickSlider);\n var panel = document.createElement("div");\n panel.className = "timelineSliderPanel";\n panel.setAttribute("cookie",cookie);\n panel.style.display = config.options[cookie] ? "block" : "none";\n place.appendChild(panel);\n if(text){\n wikify(text,panel);\n }\n};\n\nconfig.macros.timeline.formatString = function(template, yyyymm)\n{\n var dateString = new Date(yyyymm.substr(0,4)+'/'+yyyymm.substr(4,2)+'/01');\n template = template.replace(/DDD|0DD|DD/g,'');\n return dateString.formatString(template);\n};\nif (!Date.prototype.convertToLocalYYYYMMDDHHMM){\n Date.prototype.convertToLocalYYYYMMDDHHMM = function(){\n return(String.zeroPad(this.getFullYear(),4) + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2));\n }\n}\n//}}}
//Removes hidden tiddlers from lists. Hopefully this code will be included in the core TW soon.//\n//{{{\nTiddlyWiki.prototype.getTags = function()\n{\n var results = [];\n this.forEachTiddler(function(title,tiddler) {\n if(tiddler.tags.find('excludeLists')===null)\n {\n for(var g=0; g<tiddler.tags.length; g++){\n var tag = tiddler.tags[g];\n var taggingTiddler = store.fetchTiddler(tag);\n if(!taggingTiddler || !taggingTiddler.tags || taggingTiddler.tags.find('excludeLists')===null){\n var f = false;\n for(var c=0; c<results.length; c++){\n if(results[c][0] == tag){\n f = true;\n results[c][1]++;\n }\n }\n if(!f){\n results.push([tag,1]);\n }\n }\n }\n }\n });\n results.sort(function (a,b) {if(a[0].toLowerCase() == b[0].toLowerCase()){ return(0);} else {return (a[0].toLowerCase() < b[0].toLowerCase()) ? -1 : +1;} });\n return results;\n};\n\nTiddlyWiki.prototype.getOrphans = function()\n{\n var results = [];\n this.forEachTiddler(function (title,tiddler) {\n if(this.getReferringTiddlers(title).length === 0 && tiddler.tags.find('excludeLists')===null){\n results.push(title);\n }\n });\n results.sort();\n return results;\n};\n//}}}
//''Breaks the Timeline tab into "Tiddlers" and "Comments".''//\n//Makes sense with the CommentPlugin.//\n\n{{{\nfunction in_array(item, arr){for(var i=0;i<arr.length;i++)if(item==arr[i])return true};\nfunction get_parent(tiddler){while(tiddler && in_array(config.CommentPlugin.CPlingo.comments, tiddler.tags)) tiddler=store.fetchTiddler(tiddler.tags[0]);return tiddler};\nconfig.options.txtTimelineTab = 'timelineTab'; // huh?\nconfig.shadowTiddlers.TabTimelineTiddlers = config.shadowTiddlers.TabTimeline;\nconfig.shadowTiddlers.TabTimeline = "<<tabs txtTimelineTab Tiddlers Tiddlers TabTimelineTiddlers "+ config.CommentPlugin.CPlingo.comments + config.CommentPlugin.CPlingo.CommentInTitle + " TabTimelineComments>>";\nconfig.shadowTiddlers.TabTimelineComments = "<<tiddlerComments>>";\n\nconfig.macros.tiddlerComments = {\n dateFormat: 'DD MMM YYYY',\n handler: function(place,macroName,params)\n {\n var field = params[0] ? params[0] : "modified";\n var comments = store.reverseLookup("tags",CPlingo.comments,true,field);\n var lastDay = "";\n for (var c=comments.length-1; c>=0; c--)\n {\n if(comments[c].tags.length == 0) continue;\n var tiddler = get_parent(comments[c]);\n if(!tiddler) continue;\n var theDay = comments[c][field].convertToLocalYYYYMMDDHHMM().substr(0,8);\n if(theDay != lastDay)\n {\n var theDateList = document.createElement("ul");\n place.appendChild(theDateList);\n createTiddlyElement(theDateList,"li",null,"listTitle",comments[c][field].formatString(this.dateFormat));\n lastDay = theDay;\n }\n var theDateListItem = createTiddlyElement(theDateList,"li",null,"listLink",null);\n var link = createTiddlyLink(place,comments[c].title);\n link.innerHTML = comments[c].modifier + ' on ' + tiddler.title;\n link.setAttribute("tiddlyLink",tiddler.title);\n theDateListItem.appendChild(link);\n }\n }\n};\n}}}
/***\n|''Name:''|CommentPlugin|\n|''Source:''| |\n|''Author:''|Tim Morgan (modified by Bram Chen|\n|''Desc:''|''Adds "comments" to any TiddlyWiki or adaptation.''|\n| |Used in conjunction with the RecentPlugin, one can have a decent forum environment.|\n''Syntax:'' {{{}}}\n''Translation sample 1:'' {{{config.CommentPlugin.CPlingo:{CommentInTitle: ' 附錄 ', comments:'附錄',add:'增加附錄 »',edit:'編輯', tooltips:'新增關於此文的補充說明', Title: '%0_CommentInTitle_%1'};}}}\n''Translation sample 2:'' {{{config.CommentPlugin.CPlingo:{CommentInTitle: ' Comment ', comments:'comments',add:'New Comment Here...',edit:'Edit', tooltips:'Create a new comment tiddler associated with this tiddler', Title: '%0_CommentInTitle_%1'};}}}\n\n''Revision history:''\n* v0.5.0 (Jun 15, 2006)\n** Fixed bug for feature of CommentEditTemplate (bug reported by MilchFlasche, fixed by Bram)\n** Fixed bug in redefined TiddlyWiki.prototype.saveTiddler (Bram)\n* v0.4.0 (Jun 03, 2006) Added CommentEditTemplate (Bram)\n* v0.3.0 (Jun 01, 2006) Some minor changes for readOnly mode (Bram)\n* v0.2.0 (Apr 04, 2006) Fixed bug for only_on_tags (Bram)\n* v0.1.0 (Mar 13, 2006) Modified by Bram Chen.\n***/\n// //''Code section:''\n//{{{\nconfig.CommentPlugin = {\n CPlingo:{CommentInTitle: ' 迴響 ', comments:'迴響',add:'回應 »',edit:'編輯', tooltips:'發表關於此文的相關意見',\n Title: '%0_CommentInTitle_%1'\n },\n only_on_tags: ['Public'],\n not_on_tags: ['about'],\n // "true" or "false"...\n fold_comments: true,\n default_fold: true,\n max_comment_count: 500\n};\nconfig.CommentPlugin.only_on_tags.push(config.CommentPlugin.CPlingo.comments);\n\nvar CPlingo = config.CommentPlugin.CPlingo;\nfunction in_array(item, arr){\n for(var i=0;i<arr.length;i++){\n if(item==arr[i]) {return true;}\n }\n};\n\nfunction one_in_array(items, arr){\n for(var i=0;i<items.length;i++){\n if(in_array(items[i], arr)){return true;}\n }\n return false\n};\n\nfunction get_parent(tiddler){\n while(in_array(CPlingo.comments, tiddler.tags)){\n tiddler=store.fetchTiddler(tiddler.tags[0]);\n }\n return tiddler\n};\n\nfunction count_comments(title){\n var tagged=store.getTaggedTiddlers(title);\n var count=0;\n for(var i=0;i<tagged.length;i++){\n if(in_array(CPlingo.comments, tagged[i].tags)){\n count+=count_comments(tagged[i].title)+1;\n }\n }\n return count\n};\nconfig.shadowTiddlers.ViewTemplate += "\sn<div class='comments' macro='comments'></div>";\n\nconfig.shadowTiddlers.CommentEditTemplate="<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler wikibar'></div><div class='title' macro='view title'></div><div class='editor' macro='edit tags' style='display:none;'></div><div class='GuestSign' >請簽名:<span macro='option txtUserName'></span>(中英文暱稱)<br />留言內容:</div><div class='editor' macro='edit text'></div>";\nconfig.tiddlerTemplates[3]="CommentEditTemplate";\nvar COMMENT_EDIT_TEMPLATE = 3;\n\nconfig.shadowTiddlers.CommentPluginStyle = '\sn/*{{{*/\sn.commentTags ul{list-style:none; padding-left:0px;margin: 0 0 3px 0;} .commentTags li{display:inline;color:#999;} .commentTags li a.button{color:#999;} .comment{border-left:1px solid #ccc; margin-top:10px; margin-left:10px; padding:5px;} .newCommentLink{padding-top:10px} .tagging, .selected .tagging, .tiddler .tagging{display:none;} .comment a.button{padding:0px; font-size:smaller;}\sn/*}}}*/';\nconfig.shadowTiddlers.StyleSheet += config.shadowTiddlers.CommentPluginStyle;\nconfig.macros.newCommentLink = {\n CPlingo:config.CommentPlugin.CPlingo,\n label: CPlingo.add,\n prompt: CPlingo.tooltips,\n handler: function(place,macroName,params,wikifier,paramString,tiddler) {\n if(tiddler && store.tiddlerExists(tiddler.title) && !readOnly && (!window.zw || zw.loggedIn || zw.anonEdit)) {\n if(config.CommentPlugin.only_on_tags.length>0 && !one_in_array(tiddler.tags, config.CommentPlugin.only_on_tags)) return;\n if(config.CommentPlugin.not_on_tags.length>0 && one_in_array(tiddler.tags, config.CommentPlugin.not_on_tags)) return;\n var onclick = function(e) {\n var e = (e)?e:window.event;\n var theTarget = resolveTarget(e);\n var titlex=tiddler.title.split(CPlingo.CommentInTitle)[0];\n var title = (tiddler.title.indexOf(CPlingo.CommentInTitle)!=-1)? titlex : tiddler.title;\n title = title +CPlingo.CommentInTitle+ (new Date()).formatString('YYYY0MM0DD 0hh:0mm:0ss');\n// title = CPlingo.Title.format([title,(new Date()).formatString('YYYY0MM0DD 0hh:0mm:0ss')]);\n title = title.replace(/_CommentInTitle_/,CPlingo.CommentInTitle);\n var comment = store.createTiddler(title);\n comment.text = '';\n comment.tags = [tiddler.title, CPlingo.comments, 'excludeLists'];\n// comment.tags=comment.tags.concat(config.CommentPlugin.only_on_tags);\n readOnly = false;\n story.displayTiddler(theTarget, title, COMMENT_EDIT_TEMPLATE);\n readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;\n story.focusTiddler(title,"text");\n return false;\n }\n createTiddlyButton(place, this.label, this.prompt, onclick);\n }\n }\n};\nconfig.macros.comments = {\n CPlingo:config.CommentPlugin.CPlingo,\n dateFormat: 'YYYY0MM0DD 0hh:0mm',\n handler: function(place,macroName,params,wikifier,paramString,tiddler) {\n if(tiddler.title==CPlingo.comments) return;\n var comments = store.getTaggedTiddlers(tiddler.title, 'created');\n var count = count_comments(tiddler.title);\n if(comments.length>0 && !in_array(CPlingo.comments, tiddler.tags) && config.CommentPlugin.fold_comments) {\n var show = createTiddlyElement(place, 'p');\n show.innerHTML = '<a href="#" onclick="var e=document.getElementById(\s'comments'+tiddler.title+'\s');e.style.display=e.style.display==\s'block\s'?\s'none\s':\s'block\s';return false;">' + CPlingo.comments +'('+count+') »</a>';\n }\n var place = createTiddlyElement(place, 'div', 'comments'+tiddler.title, 'comments');\n if(comments.length>0 && !in_array(CPlingo.comments, tiddler.tags) && config.CommentPlugin.fold_comments && config.CommentPlugin.default_fold)\n place.style.display = 'none';\n else\n place.style.display = 'block';\n for(var i=0; i<comments.length; i++) {\n// for(var i=comments.length-1; i>0; i--) {\n if(!in_array(CPlingo.comments, comments[i].tags))continue;\n var container = createTiddlyElement(place, 'div', null, 'comment');\n var title = createTiddlyElement(container, 'strong');\n var link = createTiddlyLink(title, comments[i].modifier, true);\n createTiddlyElement(title, 'span', null, null, ', '+comments[i].created.formatString(this.dateFormat));\n/* -- remove editable option for security concern\n if(comments[i].modifier == config.options.txtUserName) {\n createTiddlyElement(title, 'span', null, null, ' (');\n var edit = createTiddlyLink(title, comments[i].title);\n edit.innerHTML = CPlingo.edit;\n createTiddlyElement(title, 'span', null, null, ')');\n }\n*/\n createTiddlyElement(container, 'br');\n config.macros.tiddler.handler(container, null, [comments[i].title],wikifier,'"'+comments[i].title+'"');\n createTiddlyElement(container, 'br');\n\n config.macros.comments.handler(container,null,null,null,null,comments[i]);\n }\n readOnly = false;\n config.macros.newCommentLink.handler(place,null,null,null,null,tiddler);\n readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;\n }\n};\nvar CPCloseTiddlers = [];\nTiddlyWiki.prototype.CommentPlugin_saveTiddler = TiddlyWiki.prototype.saveTiddler;\nTiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags) {\n tags=(typeof tags == "string") ? tags.readBracketedList() : tags;\n if(in_array(CPlingo.comments, tags)){\n newBody=newBody.htmlDecode();\n newBody=newBody.substr(0,config.CommentPlugin.max_comment_count);\n newBody=newBody.htmlEncode();\n }\n var t = this.CommentPlugin_saveTiddler(title,newTitle,newBody,modifier,modified,tags);\n if(in_array(CPlingo.comments, tags)) {\n var original = config.CommentPlugin.default_fold;\n config.CommentPlugin.default_fold = false;\n story.refreshTiddler(get_parent(t).title, DEFAULT_VIEW_TEMPLATE, true);\n config.CommentPlugin.default_fold = original;\n CPCloseTiddlers.push(newTitle);\n setTimeout("story.closeTiddler(CPCloseTiddlers.pop(), true)", 500);\n }\n return t;\n};\nStory.prototype.chooseTemplateForTiddler = function(title,template)\n{\n if(!template)\n template = DEFAULT_VIEW_TEMPLATE;\n if(template == DEFAULT_VIEW_TEMPLATE\n || template == DEFAULT_EDIT_TEMPLATE\n || template == COMMENT_EDIT_TEMPLATE)\n template = config.tiddlerTemplates[template];\n return template;\n};\n//}}}
/***\n|''Name:''|~TaggerPlugin|\n|''Version:''|1.0.1 (2006-06-01)|\n|''Source:''|http://lewcid.googlepages.com/lewcid.html/#TaggerPlugin|\n|''Author:''|SaqImtiaz|\n|''Description:''|Provides a drop down listing current tiddler tags, and allowing toggling of tags.|\n|''Documentation:''|[[TaggerPluginDocumentation]]|\n|''Source Code:''|[[TaggerPluginSource]]|\n|''~TiddlyWiki:''|Version 2.0.8 or better|\n***/\n//{{{\n\nconfig.tagger={\n defaults:{\n label: 'Tags: ',\n tooltip: 'Manage tiddler tags',\n taglist: 'true',\n excludeTags: '',\n notags: 'tiddler has no tags',\n aretags: 'current tiddler tags:',\n toggletext: 'add tags:'\n }\n};\n\nconfig.macros.tagger={};\nconfig.macros.tagger.arrow = (document.all?"▼":"▾"); // the fat one is the only one that works in IE\nconfig.macros.tagger.handler = function(place,macroName,params,wikifier,paramString,tiddler) {\n var defaults = config.tagger.defaults;\n var nAV = paramString.parseParams('tagman', null, true);\n var label = ((nAV[0].label)&&(nAV[0].label[0])!='.')?nAV[0].label[0]+this.arrow: defaults.label+this.arrow;\n var tooltip = ((nAV[0].tooltip)&&(nAV[0].tooltip[0])!='.')?nAV[0].tooltip[0]: defaults.tooltip;\n var taglist = ((nAV[0].taglist)&&(nAV[0].taglist[0])!='.')?nAV[0].taglist[0]: defaults.taglist;\n var exclude = ((nAV[0].exclude)&&(nAV[0].exclude[0])!='.')?(nAV[0].exclude[0]).readBracketedList(): defaults.excludeTags.readBracketedList();\n if ((nAV[0].source)&&(nAV[0].source[0])!='.')var source = nAV[0].source[0];\n if (source&&!store.getTiddler(source)) return false;\n\n var onclick = function(e) {\n if (!e) var e = window.event;\n var popup = Popup.create(this);\n var tagsarray = store.getTags();\n var tags=new Array();\n\n for (var i=0; i<tagsarray.length; i++){\n tags.push(tagsarray[i][0]);}\n\n if (source)\n {var sourcetiddler=store.getTiddler(source);\n tags=sourcetiddler.tags.sort();}\n\n var currentTags = tiddler.tags.sort();\n\n var createButtons=function(text,theTag,tooltipPrefix){\n var sp = createTiddlyElement(createTiddlyElement(popup,"li"),"span",null,"tagger");\n var theToggle = createTiddlyButton(sp,text,tooltipPrefix+" '"+theTag+"'",taggerOnToggle,"button","toggleButton");\n theToggle.setAttribute("tiddler",tiddler.title);\n theToggle.setAttribute("tag",theTag);\n insertSpacer(sp);\n if (window.createTagButton_orig_mptw)\n createTagButton_orig_mptw(sp,theTag);\n else\n createTagButton(sp,theTag);\n }\n\n createTiddlyElement(popup,"li",null,"listTitle",(tiddler.tags.length == 0 ? defaults.notags : defaults.aretags));\n\n for (var t=0; t<currentTags.length; t++){\n createButtons("[x]",currentTags[t],"remove tag ");\n }\n\n createTiddlyElement(createTiddlyElement(popup,"li"),"hr");\n\n if (taglist!='false')\n { createTiddlyElement(popup,"li",null,"listTitle",defaults.toggletext);\n for (var i=0; i<tags.length; i++){\n if (!tiddler.tags.contains(tags[i])&&!exclude.contains(tags[i]))\n {createButtons("[ ]",tags[i],"add tag ");\n }\n }\n createTiddlyElement(createTiddlyElement(popup,"li"),"hr");\n }\n\n var newTagButton = createTiddlyButton(createTiddlyElement(popup,"li"),("Create new tag"),null,taggerOnToggle);\n newTagButton.setAttribute("tiddler",tiddler.title);\n if (source) newTagButton.setAttribute("source",source);\n\n Popup.show(popup,false);\n e.cancelBubble = true;\n if (e.stopPropagation) e.stopPropagation();\n return(false);\n };\n\n createTiddlyButton(place,label,tooltip,onclick,"button","taggerDrpBtn");\n};\n\nwindow.taggerOnToggle = function(e) {\n var tag = this.getAttribute("tag");\n var title = this.getAttribute("tiddler");\n var tiddler = store.getTiddler(title);\n if (!tag)\n {\n var newtag=prompt("Enter new tag:","");\n if (newtag!=''&&newtag!=null)\n {\n var tag=newtag;\n if (this.getAttribute("source"))\n {var sourcetiddler = store.getTiddler(this.getAttribute("source"));\n sourcetiddler.tags.pushUnique(newtag);}\n }\n else\n {return false;};\n }\n if (!tiddler || !tiddler.tags)\n {store.saveTiddler(title,title,'',config.options.txtUserName,new Date(),tag);}\n else\n {if (tiddler.tags.find(tag)==null)\n {tiddler.tags.push(tag)}\n else if(!newtag)\n {tiddler.tags.splice(tiddler.tags.find(tag),1)};\n store.saveTiddler(tiddler.title,tiddler.title,tiddler.text,config.options.txtUserName,tiddler.modified,tiddler.tags);};\n story.refreshTiddler(title,null,true);\n if(config.options.chkAutoSave)\n saveChanges();\n return false;\n};\n\nsetStylesheet(\n ".tagger a.button {font-weight: bold;display:inline; padding:0px;}\sn"+\n ".tagger #toggleButton {padding-left:2px; padding-right:2px; margin-right:1px; font-size:110%;}\sn"+\n "#nestedtagger {background:#2E5ADF; border: 1px solid #0331BF;}\sn"+\n ".popup .listTitle {color:#000;}\sn"+\n "",\n"TaggerStyles");\n\nwindow.lewcidTiddlerSwapTag = function (tiddler, oldTag, newTag){\n for (var i = 0; i < tiddler.tags.length; i++)\n if (tiddler.tags[i] == oldTag) {\n tiddler.tags[i] = newTag;\n return true;}\n return false;\n}\n\nwindow.lewcidRenameTag = function(e) {\n var tag=this.getAttribute("tag");\n var newtag=prompt("Rename tag '"+tag+"' to:",tag);\n\n if ((newtag==tag)||(newtag==null)) {return false;}\n\n if(store.tiddlerExists(newtag))\n {if(confirm(config.messages.overwriteWarning.format([newtag.toString()])))\n story.closeTiddler(newtag,false,false);\n else\n return null;}\n\n tagged=store.getTaggedTiddlers(tag);\n if (tagged.length!=0){\n for (var j = 0; j < tagged.length; j++)\n lewcidTiddlerSwapTag(tagged[j],tag,newtag);}\n\n if (store.tiddlerExists(tag))\n {store.saveTiddler(tag,newtag);}\n if (document.getElementById("tiddler"+tag))\n {var oldTagTiddler = document.getElementById(story.idPrefix + tag);\n var before= story.positionTiddler(oldTagTiddler);\n var place = document.getElementById(story.container);\n story.closeTiddler(tag,false,false);\n story.createTiddler(place,before,newtag,null);\n story.saveTiddler(newtag);}\n if(config.options.chkAutoSave)\n saveChanges();\n return false;\n}\n\n\nwindow.onClickTag=function(e)\n{\n if (!e) var e = window.event;\n var theTarget = resolveTarget(e);\n\n var nested = (!isNested(theTarget));\n if ((Popup.stack.length > 1)&&(nested==true)) {Popup.removeFrom(1);}\n else if(Popup.stack.length > 0 && nested==false) {Popup.removeFrom(0);};\n\n var theId = (nested==false)? "popup" : "nestedtagger";\n var popup = createTiddlyElement(document.body,"ol",theId,"popup",null);\n Popup.stack.push({root: this, popup: popup});\n\n var tag = this.getAttribute("tag");\n var title = this.getAttribute("tiddler");\n if(popup && tag)\n {\n var tagged = store.getTaggedTiddlers(tag);\n var titles = [];\n var li,r;\n for(r=0;r<tagged.length;r++)\n if(tagged[r].title != title)\n titles.push(tagged[r].title);\n var lingo = config.views.wikified.tag;\n if(titles.length > 0)\n {\n var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);\n openAll.setAttribute("tag",tag);\n createTiddlyElement(createTiddlyElement(popup,"li"),"hr");\n for(r=0; r<titles.length; r++)\n {\n createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);\n }\n }\n else\n createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag]));\n createTiddlyElement(createTiddlyElement(popup,"li"),"hr");\n var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);\n createTiddlyText(h,lingo.openTag.format([tag]));\n\n createTiddlyElement(createTiddlyElement(popup,"li"),"hr");\n\n var renameTagButton = createTiddlyButton(createTiddlyElement(popup,"li"),("Rename tag '"+tag+"'"),null,lewcidRenameTag);\n renameTagButton.setAttribute("tag",tag)\n }\n Popup.show(popup,false);\n e.cancelBubble = true;\n if (e.stopPropagation) e.stopPropagation();\n return(false);\n}\n\nif (!window.isNested)\n window.isNested = function(e) {\n while (e != null) {\n var contentWrapper = document.getElementById("contentWrapper");\n if (contentWrapper == e) return true;\n e = e.parentNode;\n }\n return false;\n };\n\nconfig.shadowTiddlers.TaggerPluginDocumentation="The documentation is available [[here.|http://lewcid.googlepages.com/lewcid.html#TaggerPluginDocumentation]]";\n\nconfig.shadowTiddlers.TaggerPluginSource="The uncompressed source code is available [[here.|http://lewcid.googlepages.com/lewcid.html#TaggerPluginSource]]";\n//}}}
/***\n|''Name:''|CommentPlugin|\n|''Source:''| |\n|''Author:''|Tim Morgan (modified by Bram Chen|\n|''Desc:''|''Adds "comments" to any TiddlyWiki or adaptation.''|\n| |Used in conjunction with the RecentPlugin, one can have a decent forum environment.|\n''Syntax:'' {{{}}}\n''Translation sample 1:'' {{{config.CommentPlugin.CPlingo:{CommentInTitle: ' 附錄 ', comments:'附錄',add:'增加附錄 »',edit:'編輯', tooltips:'新增關於此文的補充說明', Title: '%0_CommentInTitle_%1'};}}}\n''Translation sample 2:'' {{{config.CommentPlugin.CPlingo:{CommentInTitle: ' Comment ', comments:'comments',add:'New Comment Here...',edit:'Edit', tooltips:'Create a new comment tiddler associated with this tiddler', Title: '%0_CommentInTitle_%1'};}}}\n\n''Revision history:''\n* v0.5.0 (Jun 15, 2006)\n** Fixed bug for feature of CommentEditTemplate (bug reported by MilchFlasche, fixed by Bram)\n** Fixed bug in redefined TiddlyWiki.prototype.saveTiddler (Bram)\n* v0.4.0 (Jun 03, 2006) Add CommentEditTemplate (Bram)\n* v0.3.0 (Jun 01, 2006) Some minor changes for readOnly mode (Bram)\n* v0.2.0 (Apr 04, 2006) Fix bug for only_on_tags (Bram)\n* v0.1.0 (Mar 13, 2006) Modified by Bram Chen.\n***/\n// //''Code section:''\n//{{{\nconfig.CommentPlugin = {\n CPlingo:{CommentInTitle: ' Comment ', comments:'comments',add:'New Comment Here...',edit:'Edit', tooltips:'Create a new comment tiddler associated with this tiddler',\n Title: '%0_CommentInTitle_%1'},\n only_on_tags: ['Public'],\n not_on_tags: ['about'],\n // "true" or "false"...\n fold_comments: true,\n default_fold: true\n};\nconfig.CommentPlugin.only_on_tags.push(config.CommentPlugin.CPlingo.comments);\n\nvar CPlingo = config.CommentPlugin.CPlingo;\nfunction in_array(item, arr){for(var i=0;i<arr.length;i++)if(item==arr[i])return true};\nfunction one_in_array(items, arr){for(var i=0;i<items.length;i++)if(in_array(items[i], arr))return true;return false};\nfunction get_parent(tiddler){while(in_array(CPlingo.comments, tiddler.tags)) tiddler=store.fetchTiddler(tiddler.tags[0]);return tiddler};\nfunction count_comments(tiddler){var tagged=store.getTaggedTiddlers(tiddler.title);var count=0;for(var i=0;i<tagged.length;i++)if(in_array(CPlingo.comments, tagged[i].tags)){count++;count+=count_comments(tagged[i])}return count};\nconfig.shadowTiddlers.ViewTemplate += "\sn<div class='comments' macro='comments'></div>";\n\nconfig.shadowTiddlers.CommentEditTemplate="<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler wikibar'></div><div class='title' macro='view title'></div><div class='editor' macro='edit tags' style='display:none;'></div><div class='GuestSign' >Your Name: <span macro='option txtUserName'></span>(NickName)<br />Comments:</div><div class='editor' macro='edit text'></div>";\nconfig.tiddlerTemplates[3]="CommentEditTemplate";\nvar COMMENT_EDIT_TEMPLATE = 3;\n\nconfig.shadowTiddlers.CommentPluginStyle = '\sn/*{{{*/\sn.commentTags ul{list-style:none; padding-left:0px;margin: 0 0 3px 0;} .commentTags li{display:inline;color:#999;} .commentTags li a.button{color:#999;} .comment{border-left:1px solid #ccc; margin-top:10px; margin-left:10px; padding:5px;} .newCommentLink{padding-top:10px} .tagging, .selected .tagging, .tiddler .tagging{display:none;} .comment a.button{padding:0px; font-size:smaller;}\sn/*}}}*/';\nconfig.shadowTiddlers.StyleSheet += config.shadowTiddlers.CommentPluginStyle;\nconfig.macros.newCommentLink = {\n CPlingo:config.CommentPlugin.CPlingo,\n label: CPlingo.add,\n prompt: CPlingo.tooltips,\n handler: function(place,macroName,params,wikifier,paramString,tiddler) {\n\n if(tiddler && store.tiddlerExists(tiddler.title) && !readOnly && (!window.zw || zw.loggedIn || zw.anonEdit)) {\n if(config.CommentPlugin.only_on_tags.length>0 && !one_in_array(tiddler.tags, config.CommentPlugin.only_on_tags)) return;\n if(config.CommentPlugin.not_on_tags.length>0 && one_in_array(tiddler.tags, config.CommentPlugin.not_on_tags)) return;\n var onclick = function(e) {\n\n var e = (e)?e:window.event;\n var theTarget = resolveTarget(e);\n var titlex=tiddler.title.split(CPlingo.CommentInTitle)[0];\n var title = (tiddler.title.indexOf(CPlingo.CommentInTitle)!=-1)? titlex : tiddler.title;\n title = title +CPlingo.CommentInTitle+ (new Date()).formatString('YYYY0MM0DD 0hh:0mm:0ss');\n// title = CPlingo.Title.format([title,(new Date()).formatString('YYYY0MM0DD 0hh:0mm:0ss')]);\n title = title.replace(/_CommentInTitle_/,CPlingo.CommentInTitle);\n var comment = store.createTiddler(title);\n comment.text = '';\n comment.tags = [tiddler.title, CPlingo.comments, 'excludeLists'];\n// comment.tags=comment.tags.concat(config.CommentPlugin.only_on_tags);\n readOnly = false;\n story.displayTiddler(theTarget, title, COMMENT_EDIT_TEMPLATE);\n readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;\n story.focusTiddler(title,"text");\n return false;\n }\n createTiddlyButton(place, this.label, this.prompt, onclick);\n }\n }\n};\nconfig.macros.comments = {\n CPlingo:config.CommentPlugin.CPlingo,\n dateFormat: 'YYYY0MM0DD 0hh:0mm',\n handler: function(place,macroName,params,wikifier,paramString,tiddler) {\n if(tiddler.title==CPlingo.comments) return;\n var comments = store.getTaggedTiddlers(tiddler.title, 'created');\n if(comments.length>0 && !in_array(CPlingo.comments, tiddler.tags) && config.CommentPlugin.fold_comments) {\n var show = createTiddlyElement(place, 'p');\n show.innerHTML = '<a href="#" onclick="var e=document.getElementById(\s'comments'+tiddler.title+'\s');e.style.display=e.style.display==\s'block\s'?\s'none\s':\s'block\s';return false;">' + CPlingo.comments +'('+count_comments(tiddler)+') »</a>';\n }\n var place = createTiddlyElement(place, 'div', 'comments'+tiddler.title, 'comments');\n if(comments.length>0 && !in_array(CPlingo.comments, tiddler.tags) && config.CommentPlugin.fold_comments && config.CommentPlugin.default_fold)\n place.style.display = 'none';\n else\n place.style.display = 'block';\n for(var i=0; i<comments.length; i++) {\n// for(var i=comments.length-1; i>0; i--) {\n if(!in_array(CPlingo.comments, comments[i].tags))continue;\n var container = createTiddlyElement(place, 'div', null, 'comment');\n var title = createTiddlyElement(container, 'strong');\n var link = createTiddlyLink(title, comments[i].modifier, true);\n createTiddlyElement(title, 'span', null, null, ', '+comments[i].created.formatString(this.dateFormat));\n/* -- remove editable option for security concern\n if(comments[i].modifier == config.options.txtUserName) {\n createTiddlyElement(title, 'span', null, null, ' (');\n var edit = createTiddlyLink(title, comments[i].title);\n edit.innerHTML = CPlingo.edit;\n createTiddlyElement(title, 'span', null, null, ')');\n }\n*/\n createTiddlyElement(container, 'br');\n config.macros.tiddler.handler(container, null, [comments[i].title],wikifier,'"'+comments[i].title+'"');\n createTiddlyElement(container, 'br');\n\n config.macros.comments.handler(container,null,null,null,null,comments[i]);\n }\n readOnly = false;\n config.macros.newCommentLink.handler(place,null,null,null,null,tiddler);\n readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;\n }\n};\nvar CPCloseTiddlers = [];\nTiddlyWiki.prototype.CommentPlugin_saveTiddler = TiddlyWiki.prototype.saveTiddler;\nTiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags) {\n tags=(typeof tags == "string") ? tags.readBracketedList() : tags;\n if(in_array(CPlingo.comments, tags)){\n newBody=newBody.htmlDecode();\n newBody=newBody.substr(0,200);\n newBody=newBody.htmlEncode();\n }\n var t = this.CommentPlugin_saveTiddler(title,newTitle,newBody,modifier,modified,tags);\n if(in_array(CPlingo.comments, tags)) {\n var original = config.CommentPlugin.default_fold;\n config.CommentPlugin.default_fold = false;\n story.refreshTiddler(get_parent(t).title, DEFAULT_VIEW_TEMPLATE, true);\n config.CommentPlugin.default_fold = original;\n CPCloseTiddlers.push(newTitle);\n setTimeout("story.closeTiddler(CPCloseTiddlers.pop(), true)", 500);\n }\n \n return t;\n};\nStory.prototype.chooseTemplateForTiddler = function(title,template)\n{\n if(!template)\n template = DEFAULT_VIEW_TEMPLATE;\n if(template == DEFAULT_VIEW_TEMPLATE\n || template == DEFAULT_EDIT_TEMPLATE\n || template == COMMENT_EDIT_TEMPLATE)\n template = config.tiddlerTemplates[template];\n return template;\n};\n//}}}
/***\n|''Name:''|RecentPlugin|\n|''Source:''| |\n|''Author:''|Tim Morgan (modified by Bram Chen)|\n|''Desc:''|Shows DefaultTiddlers + most recently modified tiddlers as default when any TiddlyWiki or adaptation is first loaded.|\n| |copy this tiddler's contents to a new tiddler on your site and tag it "systemConfig".|\n''Syntax:'' {{{}}}\n\n''Revision history:''\n* v0.1.0 (Mar 13, 2006) modified by Bram Chen.\n***/\n// //''Code section:''\n//{{{\nvar num = 15;\nvar ignore_tags = ['systemConfig', 'systemTiddlers'];\nvar CPlingo = config.CommentPlugin.CPlingo;\nfunction in_array(item, arr){for(var i=0;i<arr.length;i++)if(item==arr[i])return true};\nfunction get_parent(tiddler){while(tiddler && in_array(CPlingo.comments, tiddler.tags)) tiddler=store.fetchTiddler(tiddler.tags[0]);return tiddler};\nfunction unique_list(list){var l=[];for(i=0;i<list.length;i++)if(!in_array(list[i], l))l.push(list[i]);return l};\nfunction get_recent_tiddlers(){\n var tiddlers = store.getTiddlers('modified');\n var names = store.getTiddlerText("DefaultTiddlers").readBracketedList();\n var ignore_tiddlers = [];\n for(var i=0; i<ignore_tags.length; i++)\n ignore_tiddlers=ignore_tiddlers.concat(store.getTaggedTiddlers(ignore_tags[i]));\n for(var i=tiddlers.length-1; i>=0; i--) {\n if(in_array(CPlingo.comments, tiddlers[i].tags)) {\n var t = get_parent(tiddlers[i]);\n if(t)names.push(t.title)\n }\n else if(!in_array(tiddlers[i], ignore_tiddlers))\n names.push(tiddlers[i].title);\n }\n return unique_list(names).slice(0, num);\n}\nvar names = get_recent_tiddlers();\n_restart = restart\nrestart = function() {\n if(window.location.hash) _restart();\n else story.displayTiddlers(null,names);\n}\n//}}}
//''Breaks the Timeline tab into "Tiddlers" and "Comments".''//\n//Makes sense with the CommentPlugin.//\n\n{{{\nfunction in_array(item, arr){for(var i=0;i<arr.length;i++)if(item==arr[i])return true};\nfunction get_parent(tiddler){while(tiddler && in_array(config.CommentPlugin.CPlingo.comments, tiddler.tags)) tiddler=store.fetchTiddler(tiddler.tags[0]);return tiddler};\nconfig.options.txtTimelineTab = 'timelineTab'; // huh?\nconfig.shadowTiddlers.TabTimelineTiddlers = config.shadowTiddlers.TabTimeline;\nconfig.shadowTiddlers.TabTimeline = "<<tabs txtTimelineTab 文章 最近更新的文章 TabTimelineTiddlers "+ config.CommentPlugin.CPlingo.comments + " 最近的回應 TabTimelineComments>>";\nconfig.shadowTiddlers.TabTimelineComments = "<<tiddlerComments>>";\n\nconfig.macros.tiddlerComments = {\n dateFormat: 'YYYY0MM0DD',\n handler: function(place,macroName,params)\n {\n var field = params[0] ? params[0] : "modified";\n var comments = store.reverseLookup("tags",CPlingo.comments,true,field);\n var lastDay = "";\n for (var c=comments.length-1; c>=0; c--)\n {\n if(comments[c].tags.length == 0) continue;\n var tiddler = get_parent(comments[c]);\n if(!tiddler) continue;\n var theDay = comments[c][field].convertToLocalYYYYMMDDHHMM().substr(0,8);\n if(theDay != lastDay)\n {\n var theDateList = document.createElement("ul");\n place.appendChild(theDateList);\n createTiddlyElement(theDateList,"li",null,"listTitle",comments[c][field].formatString(this.dateFormat));\n lastDay = theDay;\n }\n var theDateListItem = createTiddlyElement(theDateList,"li",null,"listLink",null);\n var link = createTiddlyLink(place,comments[c].title);\n link.innerHTML = comments[c].modifier + ' on ' + tiddler.title;\n link.setAttribute("tiddlyLink",tiddler.title);\n theDateListItem.appendChild(link);\n }\n }\n};\n}}}
/***\n\n''This plugin was previously called StyleChooser.''\n\n|Name|SelectThemePlugin|\n|Created by|SimonBaird and SaqImtiaz|\n|Location|http://lewcid.googlepages.com/lewcid.html#SelectThemePlugin|\n|Version|1.2.4|\n|Requires|~TW2.x|\n!Description\n*An alternative style switcher, can be used to switch just stylesheets and/or pagetemplates, or a combination of both (a theme)\n*you can add your own stylesheets and pagetemplates, or use a ThemePack, like BigThemePack.\n\n!Usage\n* You have to have fetch or create some styleSheets and pageTemplates to use this plugin.\n**You can either get a ThemePack like BigThemePack which automatically adds themes to ThemeSelect.\n**or create tiddlers with styleSheets and pageTemplates and tag them styleSheets and pageTemplates respectively.\n* Put {{{<<themeSelect style 'Select theme'>>}}} in your SideBarOptions.\n\n!Creating Theme Packs\n*You can create your own theme pack if you like. Instructions can be found [[here.|CreateThemePack]]\n\n!History\n* 08-Sept-06, v1.2.4, fixed bug with TW2.1\n* 15-May-06, v1.2.3, added paramifier so you can put theme on url, eg http://www.somewhere.com/twfile.html#theme:Berry2, thanks Clint (Simon).\n* 28-Apr-o6, v1.2.2, fixed bug with opening TW after deleting themepacks. (Saq)\n* 26-Apr-06, v1.2.1, more code optimization, dropdowns now updated on the fly. (Saq)\n* 25-Apr-06, v1.2.0, added 3rd party ThemePack support, and made various other improvements.(Simon & Saq)\n* 24-Apr-06, v1.1.0, added: no styles and default styles options,<<br>>support for ThemePack, support for tag variations(Saq)\n* 21-Apr-06, v1.0.0, Reworked dropdowns to include option for pagetemplates (Saq)\n* 21-Apr-06, v0.9.0, Rewrote and added Saq's lovely dropdown select (Simon)\n* 20-Apr-06, v0.0.1, Basic switcher working (Simon)\n\n!Examples\n|!Source|!Output|h\n|{{{<<themeSelect style>>}}} for a dropdown with StyleSheets|<<themeSelect style>>|\n|{{{<<themeSelect pagetemplate>>}}} for a dropdown with PageTemplates|<<themeSelect pagetemplate>>|\n|{{{<<themeSelect style customlabel>>}}} to use a customlabel|<<themeSelect style customlabel>>|\n* When applying a stylesheet or template, it also looks for a template or stylesheet respectively based on naming convention, eg MyFunkyStyleSheet and MyFunkyPageTemplate.\n\n!Notes\n* See also http://www.tiddlytools.com/#SelectStyleSheetPlugin for a more feature-rich style sheet switcher\n\n! Ideas\n* do ViewTemplate also?\n* Pretty up the [x] bit\n\n!Code\n***/\n//{{{\n// for compatibility with TW <2.0.9\nif (!Array.prototype.contains)\n Array.prototype.contains = function(item)\n {\n return this.find(item) != null;\n };\n\n// for compatibility with TW <2.0.9\nif (!Array.prototype.containsAny)\n Array.prototype.containsAny = function(items)\n {\n for(var i=0; i<items.length; i++)\n if (this.contains(items[i]))\n return true;\n return false;\n };\n//}}}\n\n//{{{\nversion.extensions.SelectTheme = { major: 1, minor: 2, revision: 4, date: new Date(2006,9,8),\n source: "http://lewcid.googlepages.com/lewcid.html#SelectTheme"\n};\n\nconfig.SelectTheme = {\n things: {\n style: {\n tag: ["StyleSheets","StyleSheet","styleSheet","styleSheets","stylesheet","stylesheets"],\n theDefault: "StyleSheet",\n suffix: "StyleSheet",\n notify: refreshStyles,\n cookie: "txtStyleSheet",\n otherThing: "pagetemplate",\n label: "Choose StyleSheet: ",\n tooltip: "Choose a StyleSheet",\n caseNone: { text:"None", title:"NoStyleSheet"},\n caseDefault: { text:"Default", title:"StyleSheet" }\n\n },\n pagetemplate: {\n tag: ["PageTemplates","PageTemplate","pageTemplates","pageTemplate","pagetemplate","pagetemplates"],\n theDefault: "PageTemplate",\n suffix: "PageTemplate",\n notify: refreshPageTemplate,\n cookie: "txtPageTemplate",\n otherThing: "style",\n label: "Choose PageTemplate: ",\n tooltip: "Choose a PageTemplate",\n caseNone: { text:"None", title:"NoPageTemplate"},\n caseDefault: { text:"Default", title:"PageTemplate" }\n }\n\n },\n\n specialCases: ["caseNone","caseDefault"]\n\n};\n\nTiddlyWiki.prototype.removeNotification = function(title,fn) {\n for (var i=0;i<this.namedNotifications.length;i++)\n if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))\n this.namedNotifications.splice(i,1); // counting on it only being there once\n}\n\n\nvar things = config.SelectTheme.things;\nvar specialCases=config.SelectTheme.specialCases;\n\nfor (var zz in things) {\n // make sure we have a value\n if (!config.options[things[zz].cookie])\n config.options[things[zz].cookie] = things[zz].theDefault;\n\n // remove core notify\n store.removeNotification(things[zz].theDefault,things[zz].notify);\n\n // and add our one\n store.addNotification(config.options[things[zz].cookie],things[zz].notify);\n\n}\n\n//checks to see if a tiddler exists in store or as a shadow.\nTiddlyWiki.prototype.isTiddler= function (title)\n {return store.tiddlerExists(title) || store.isShadowTiddler(title)}\n\n//hijack core function & make sure template exists\nwindow.applyPageTemplate_themeSelect=window.applyPageTemplate;\nwindow.applyPageTemplate=function(title){\n if(!store.isTiddler(title))\n {title = things.pagetemplate.theDefault;}\n applyPageTemplate_themeSelect(title);\n }\n\nTiddlyWiki.prototype.makeActiveTheme = function(what,title,alsoCheckOtherThing) {\n\n var thing = things[what];\n if (!store.isTiddler(title))\n title = thing.theDefault;\n\n var oldTitle = config.options[thing.cookie];\n\n if (what == "style") {\n // remove old style element from DOM\n var oldStyleElement = document.getElementById(oldTitle);\n oldStyleElement.parentNode.removeChild(oldStyleElement);\n }\n\n store.removeNotification(oldTitle,thing.notify);\n store.addNotification(title,thing.notify);\n store.notify(title);\n\n config.options[thing.cookie] = title;\n saveOptionCookie(thing.cookie);\n if (alsoCheckOtherThing)\n this.makeActiveTheme(thing.otherThing,\n title.replace(new RegExp(thing.suffix+"$"),"") + things[thing.otherThing].suffix,\n false);\n};\n\n\nconfig.shadowTiddlers.NoStyleSheet = "";\nconfig.shadowTiddlers.NoPageTemplate = config.shadowTiddlers.PageTemplate;\n\n\nfunction switchTheme(e){\n if (!e) var e = window.event;\n var theTarget = resolveTarget(e);\n var theLink = theTarget;\n var switchTo= theLink.getAttribute("switchTo");\n var mode = theLink.getAttribute("mode");\n if ((config.options[things[mode].cookie])!=switchTo)\n {store.makeActiveTheme(mode,switchTo,true);};\n return(false);\n}\n\n\nconfig.macros.themeSelect={};\nconfig.macros.themeSelect.dropdownchar = (document.all?"▼":"▾");\nconfig.macros.themeSelect.handler = function(place,macroName,params,wikifier,paramString,tiddler){\n var arrow = config.macros.themeSelect.dropdownchar;\n var mode = params[0];\n var label = (params[1]?params[1]:things[mode].label) + arrow;\n var cookie = (config.options[things[mode].cookie]);\n\n var onclick = function(e)\n { if (!e) var e = window.event;\n var popup = Popup.create(this);\n\n var tagged=[];\n\n store.forEachTiddler(function(title,tiddler) {\n if ((tiddler.tags).containsAny(things[mode].tag)){\n tagged.push(tiddler.title);}\n });\n\n //integrate ThemePacks\n if (config.themes) {\n // see what themes have been loaded...\n for (var i=0;i<config.themes.length;i++) {\n // see if there is one\n var lookForThis = config.themes[i] + things[mode].suffix;\n if (store.isShadowTiddler(lookForThis)) {\n tagged.pushUnique(lookForThis);\n }\n }\n tagged = tagged.sort();\n }\n\n //this function used later to create buttons\n var createThemeButton = function(switchTo){\n var theButton = createTiddlyButton(createTiddlyElement(popup,"li"),text,null,switchTheme,useClass);\n theButton.setAttribute("switchTo",switchTo);\n theButton.setAttribute("mode",mode);};\n\n //create Buttons for None(shadow styles) & Default (StyleSheet)\n // Default button is not created if StyleSheet doesnt exist.\n for(var t=0; t<specialCases.length; t++){\n var special = specialCases[t];\n var text = things[mode][special].text;\n var useClass = "tiddlyLinkExisting"; //redundant, optimize!\n if ((things[mode][special].title==cookie)||(special=="caseNone"&&!store.isTiddler(cookie)))\n {text+= " [x]";\n useClass = "currentlySelected";}\n if (!((special=="caseDefault")&&(!store.getTiddler(things[mode][special].title))))\n createThemeButton(things[mode][special].title); }\n\n //insert horizontal rule\n createTiddlyElement(createTiddlyElement(popup,"li"),"hr");\n\n //create buttons for all other stylesheet tiddlers\n for(var t=0; t<tagged.length; t++)\n { var useClass = "tiddlyLinkExisting";\n var text = (tagged[t]).replace((things[mode].suffix),"");\n if (tagged[t]==(cookie) )\n {text+=" [x]"; useClass="currentlySelected";}\n if ((tagged[t]!= (things[mode].theDefault))&&tagged[t]!= (things[mode].none))\n {createThemeButton(tagged[t]);}}\n Popup.show(popup,false);\n e.cancelBubble = true;\n if (e.stopPropagation)\n e.stopPropagation();\n return(false);\n };\n\n var createdropperButton = function(place){\n var sp = createTiddlyElement(place,"span",null,"ThemeChooserButton");\n var theDropDownBtn = createTiddlyButton(sp,label,things[mode].tooltip,onclick);\n };\n\n createdropperButton(place);\n};\n\n\nsetStylesheet(".popup li a.currentlySelected {background:#ccc;color:black;font-weight:bold;}","currentlySelectedStyle"); // could do better probably...\n\nconfig.macros.layoutChooser=config.macros.themeSelect;\n\n//shadow tiddler to hold instructions for creating ThemePacks\nconfig.shadowTiddlers.ThemePack='See http://simonbaird.com/mptw/#CreateThemePack'; \n\nconfig.macros.applyTheme = {handler: function (place,macroName,params,wikifier,paramString,tiddler) {\n var theme = params[0];\n var label = params[1]?params[1]:'Apply theme "' + theme + '"';\n var tooltip = 'Apply the "'+theme+'" theme to this TiddlyWiki';\n createTiddlyButton(place,label,tooltip,function() {\n store.makeActiveTheme("style",theme+things.style.suffix,true);\n });\n}};\n\n\n// this means you can put #theme:ThemeName in url. suggested by Clint\nconfig.paramifiers.theme = {\n onstart: function(themeName) {\n store.makeActiveTheme("style",themeName+config.SelectTheme.things.style.suffix,true);\n }\n};\n\n//}}}\n\n
/***\n''Name:'' GenRssPlugin\n''Source:'' http://www.sourceforge.net/projects/ptw/\n''Author:'' BramChen\n''Type:'' Plugin\n''Description:'' \n* This plugin add a "xml-stylesheet" processing into the rss file generated by TW.\n* Resources used: \n** rssfeed.xsl\n** rssfeed.css\n** xsl.css\n<<<\n''Descriptions:''\n* if 'config.options.txtGenRssTags is empty then the outputs limited to 'config.numRssItems' except tiddlers taged with 'excludeLists'.\n* you can add the macro <<option txtGenRssTags>> to some configure tiddler, eg 'AdvancedOptions' for changing the tag list,\n* and add <<option txtRssItems>> to change number of rsfeed item.\n''Revision History:''\n* v0.2.0 (Mar 30 2006)\n** add a new feature that rssfeed limited to tiddlers taged with the tag list specified in 'config.options.txtGenRssTags'.\n** add config.options.txtRssItems.\n** if it's empty then the outputs limited to 'config.numRssItems' except tiddlers taged with 'excludeLists'.\n** you can add the macro <<option txtGenRssTags>> to some configure tiddler, eg 'AdvancedOptions' for changing the tag list.\n* v0.1.1 (Feb 04 2006)\n** JSLint checked\nv0.1.0 (Feb 1, 2006) \n* initial release\n***/\n// //''Code section:''\n//{{{\nversion.extensions.genRss = {major: 0, minor: 2, revision: 0,\n date: new Date("Mar 30, 2006"),\n info: {\n type: "Macro",\n name: "GenRssPlugin",\n author: "BramChen",\n source: "http://sourceforge.net/project/showfiles.php?group_id=150646"\n }\n};\n\nwindow.generateRss_ori = window.generateRss;\n\nconfig.options.txtGenRssTags = "";\nconfig.options.txtRssItems = "20";\n\nwindow.generateRss = function () {\n var rssTags = config.options.txtGenRssTags.readBracketedList();\n var numRssItems = config.options.txtRssItems;\n var s = [];\n var d = new Date();\n var u = store.getTiddlerText("SiteUrl",null);\n // Assemble the header\n s.push("<" + "?xml version=\s"1.0\s" encoding=\s"utf-8\s"?" + ">");\n s.push("<" + "?xml-stylesheet type=\s"text/xsl\s" href=\s"rss/rssfeed.xsl\s"?" +">");\n s.push("<" + "?xml-stylesheet type=\s"text/css\s" href=\s"rss/rssfeed.css\s"?" +">");\n s.push("<" + "rss version=\s"2.0\s">");\n s.push("<channel>");\n s.push("<title>" + wikifyPlain("SiteTitle").htmlEncode() + "</title>");\n if(u)\n s.push("<link>" + u.htmlEncode() + "</link>");\n s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");\n s.push("<language>en-us</language>");\n s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");\n s.push("<pubDate>" + d.toGMTString() + "</pubDate>");\n s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");\n s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");\n s.push("<generator>TiddlyWiki " + version.major + "." + version.minor + "." + version.revision + "</generator>");\n // The body\n var tiddlers = store.getTiddlers("modified","excludeLists");\n var n = numRssItems > tiddlers.length ? 0 : tiddlers.length-numRssItems;\n for (var t=tiddlers.length-1; t>=n; t--){\n var f=(rssTags.length===0);\n for (var i = 0; i<rssTags.length; i++){\n if (tiddlers[t].tags.find(rssTags[i])!=null){f=true;break;}\n }\n if (f){s.push(tiddlers[t].saveToRss(u));}\n }\n // And footer\n s.push("</channel>");\n s.push("</rss>");\n // Save it all\n return s.join("\sn");\n};\n//}}}
/***\n|''Name:''|NestedSlidersPlugin|\n|''Source:''|http://www.TiddlyTools.com/#NestedSlidersPlugin|\n|''Author:''|Eric Shulman - ELS Design Studios|\n|''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|\n|''~CoreVersion:''|2.0.10|\n\nQuickly make any tiddler content into an expandable 'slider' panel, without needing to create a separate tiddler to contain the slider content. Optional syntax allows ''default to open'', ''custom button label/tooltip'' and ''automatic blockquote formatting.''\n\nYou can also 'nest' these sliders as deep as you like (see complex nesting example below), so that expandable 'tree-like' hierarchical displays can be created. This is most useful when converting existing in-line text content to create in-line annotations, footnotes, context-sensitive help, or other subordinate information displays.\n\nFor more details, please click on a section headline below:\n++++!!!!![Configuration]>\nDebugging messages for 'lazy sliders' deferred rendering:\n<<option chkDebugLazySliderDefer>> show debugging alert when deferring slider rendering\n<<option chkDebugLazySliderRender>> show debugging alert when deferred slider is actually rendered\n===\n++++!!!!![Usage]>\nWhen installed, this plugin adds new wiki syntax for embedding 'slider' panels directly into tiddler content. Use {{{+++}}} and {{{===}}} to delimit the slider content. Additional optional syntax elements let you specify\n*default to open\n*cookiename\n*heading level\n*floater (with optional CSS width value)\n*mouse auto rollover\n*custom class/label/tooltip/accesskey\n*automatic blockquote\n*deferred rendering\nThe complete syntax, using all options, is:\n//{{{\n++++(cookiename)!!!!!^width^*{{class{[label=key|tooltip]}}}>...\ncontent goes here\n===\n//}}}\nwhere:\n* {{{+++}}} (or {{{++++}}}) and {{{===}}}^^\nmarks the start and end of the slider definition, respectively. When the extra {{{+}}} is used, the slider will be open when initially displayed.^^\n* {{{(cookiename)}}}^^\nsaves the slider opened/closed state, and restores this state whenever the slider is re-rendered.^^\n* {{{!}}} through {{{!!!!!}}}^^\ndisplays the slider label using a formatted headline (Hn) style instead of a button/link style^^\n* {{{^width^}}} (or just {{{^}}})^^\nmakes the slider 'float' on top of other content rather than shifting that content downward. 'width' must be a valid CSS value (e.g., "30em", "180px", "50%", etc.). If omitted, the default width is "auto" (i.e., fit to content)^^\n* {{{*}}}^^\nautomatically opens/closes slider on "rollover" as well as when clicked^^\n* {{{{{class{[label=key|tooltip]}}}}}}^^\nuses custom label/tooltip/accesskey. {{{{{class{...}}}}}}, {{{=key}}} and {{{|tooltip}}} are optional. 'class' is any valid CSS class name, used to style the slider label text. 'key' must be a ''single letter only''. Default labels/tootips are: ">" (more) and "<" (less), with no default access key assignment.^^\n* {{{">"}}} //(without the quotes)//^^\nautomatically adds blockquote formatting to slider content^^\n* {{{"..."}}} //(without the quotes)//^^\ndefers rendering of closed sliders until the first time they are opened. //Note: deferred rendering may produce unexpected results in some cases. Use with care.//^^\n\n//Note: to make slider definitions easier to read and recognize when editing a tiddler, newlines immediately following the {{{+++}}} 'start slider' or preceding the {{{===}}} 'end slider' sequence are automatically supressed so that excess whitespace is eliminated from the output.//\n===\n++++!!!!![Examples]>\nsimple in-line slider: \n{{{\n+++\n content\n===\n}}}\n+++\n content\n===\n----\nuse a custom label and tooltip: \n{{{\n+++[label|tooltip]\n content\n===\n}}}\n+++[label|tooltip]\n content\n===\n----\ncontent automatically blockquoted: \n{{{\n+++>\n content\n===\n}}}\n+++>\n content\n===\n----\nall options combined //(default open, cookie, heading, sized floater, rollover, class, label/tooltip/key, blockquoted, deferred)//\n{{{\n++++(testcookie)!!!^30em^*{{big{[label=Z|click or press Alt-Z to open]}}}>...\n content\n===\n}}}\n++++(testcookie)!!!^30em^*{{big{[label=Z|click or press Alt-Z to open]}}}>...\n content\n===\n----\ncomplex nesting example:\n{{{\n+++^[get info...=I|click for information or press Alt-I]\n put some general information here, plus a floating slider with more specific info:\n +++^10em^[view details...|click for details]\n put some detail here, which could include a rollover with a +++^25em^*[glossary definition]explaining technical terms===\n ===\n===\n}}}\n+++^[get info...=I|click for information or press Alt-I]\n put some general information here, plus a floating slider with more specific info:\n +++^10em^[view details...|click for details]\n put some detail here, which could include a rollover with a +++^25em^*[glossary definition]explaining technical terms===\n ===\n===\n===\n!!!!!Installation\n<<<\nimport (or copy/paste) the following tiddlers into your document:\n''NestedSlidersPlugin'' (tagged with <<tag systemConfig>>)\n<<<\n!!!!!Revision History\n<<<\n''2006.07.28 - 2.0.0'' added custom class syntax around label/tip/key syntax: {{{{{classname{[label=key|tip]}}}}}}\n''2006.07.25 - 1.9.3'' when parsing slider, save default open/closed state in button element, then in onClickNestedSlider(), if slider state matches saved default, instead of saving cookie, delete it. Significantly reduces the 'cookie overhead' when default slider states are used.\n''2006.06.29 - 1.9.2'' in onClickNestedSlider(), when setting focus to first control, skip over type="hidden"\n''2006.06.22 - 1.9.1'' added panel.defaultPanelWidth to save requested panel width, even after resizing has changed the style value\n''2006.05.11 - 1.9.0'' added optional '^width^' syntax for floating sliders and '=key' syntax for setting an access key on a slider label\n''2006.05.09 - 1.8.0'' in onClickNestedSlider(), when showing panel, set focus to first child input/textarea/select element\n''2006.04.24 - 1.7.8'' in adjustSliderPos(), if floating panel is contained inside another floating panel, subtract offset of containing panel to find correct position\n''2006.02.16 - 1.7.7'' corrected deferred rendering to account for use-case where show/hide state is tracked in a cookie\n''2006.02.15 - 1.7.6'' in adjustSliderPos(), ensure that floating panel is positioned completely within the browser window (i.e., does not go beyond the right edge of the browser window)\n''2006.02.04 - 1.7.5'' add 'var' to unintended global variable declarations to avoid FireFox 1.5.0.1 crash bug when assigning to globals\n''2006.01.18 - 1.7.4'' only define adjustSliderPos() function if it has not already been provided by another plugin. This lets other plugins 'hijack' the function even when they are loaded first.\n''2006.01.16 - 1.7.3'' added adjustSliderPos(place,btn,panel,panelClass) function to permit specialized logic for placement of floating panels. While it provides improved placement for many uses of floating panels, it exhibits a relative offset positioning error when used within *nested* floating panels. Short-term workaround is to only adjust the position for 'top-level' floaters.\n''2006.01.16 - 1.7.2'' added button property to slider panel elements so that slider panel can tell which button it belongs to. Also, re-activated and corrected animation handling so that nested sliders aren't clipped by hijacking Slider.prototype.stop so that "overflow:hidden" can be reset to "overflow:visible" after animation ends\n''2006.01.14 - 1.7.1'' added optional "^" syntax for floating panels. Defines new CSS class, ".floatingPanel", as an alternative for standard in-line ".sliderPanel" styles.\n''2006.01.14 - 1.7.0'' added optional "*" syntax for rollover handling to show/hide slider without requiring a click (Based on a suggestion by tw4efl)\n''2006.01.03 - 1.6.2'' When using optional "!" heading style, instead of creating a clickable "Hn" element, create an "A" element inside the "Hn" element. (allows click-through in SlideShowPlugin, which captures nearly all click events, except for hyperlinks)\n''2005.12.15 - 1.6.1'' added optional "..." syntax to invoke deferred ('lazy') rendering for initially hidden sliders\nremoved checkbox option for 'global' application of lazy sliders\n''2005.11.25 - 1.6.0'' added optional handling for 'lazy sliders' (deferred rendering for initially hidden sliders)\n''2005.11.21 - 1.5.1'' revised regular expressions: if present, a single newline //preceding// and/or //following// a slider definition will be suppressed so start/end syntax can be place on separate lines in the tiddler 'source' for improved readability. Similarly, any whitespace (newlines, tabs, spaces, etc.) trailing the 'start slider' syntax or preceding the 'end slider' syntax is also suppressed.\n''2005.11.20 - 1.5.0'' added (cookiename) syntax for optional tracking and restoring of slider open/close state\n''2005.11.11 - 1.4.0'' added !!!!! syntax to render slider label as a header (Hn) style instead of a button/link style\n''2005.11.07 - 1.3.0'' removed alternative syntax {{{(((}}} and {{{)))}}} (so they can be used by other\nformatting extensions) and simplified/improved regular expressions to trim multiple excess newlines\n''2005.11.05 - 1.2.1'' changed name to NestedSlidersPlugin\nmore documentation\n''2005.11.04 - 1.2.0'' added alternative character-mode syntax {{{(((}}} and {{{)))}}}\ntweaked "eat newlines" logic for line-mode {{{+++}}} and {{{===}}} syntax\n''2005.11.03 - 1.1.1'' fixed toggling of default tooltips ("more..." and "less...") when a non-default button label is used\ncode cleanup, added documentation\n''2005.11.03 - 1.1.0'' changed delimiter syntax from {{{(((}}} and {{{)))}}} to {{{+++}}} and {{{===}}}\nchanged name to EasySlidersPlugin\n''2005.11.03 - 1.0.0'' initial public release\n<<<\n!!!!!Credits\n<<<\nThis feature was implemented by EricShulman from [[ELS Design Studios|http:/www.elsdesign.com]] with initial research and suggestions from RodneyGomes, GeoffSlocock, and PaulPetterson.\n<<<\n!!!!!Code\n***/\n//{{{\nversion.extensions.nestedSliders = {major: 2, minor: 0, revision: 0, date: new Date(2006,7,28)};\n//}}}\n\n//{{{\n// options for deferred rendering of sliders that are not initially displayed\nif (config.options.chkDebugLazySliderDefer==undefined) config.options.chkDebugLazySliderDefer=false;\nif (config.options.chkDebugLazySliderRender==undefined) config.options.chkDebugLazySliderRender=false;\n\n// default styles for 'floating' class\nsetStylesheet(".floatingPanel { position:absolute; z-index:10; padding:0.5em; margin:0em; \s\n background-color:#eee; color:#000; border:1px solid #000; text-align:left; }","floatingPanelStylesheet");\n//}}}\n\n//{{{\nconfig.formatters.push( {\n name: "nestedSliders",\n match: "\s\sn?\s\s+{3}",\n terminator: "\s\ss*\s\s={3}\s\sn?",\n lookahead: "\s\sn?\s\s+{3}(\s\s+)?(\s\s([^\s\s)]*\s\s))?(\s\s!*)?(\s\s^(?:[^\s\s^\s\s*\s\s[\s\s>]*\s\s^)?)?(\s\s*)?(?:\s\s{\s\s{([\s\sw]+[\s\ss\s\sw]*)\s\s{)?(\s\s[[^\s\s]]*\s\s])?(?:\s\s}{3})?(\s\s>)?(\s\s.\s\s.\s\s.)?\s\ss*",\n handler: function(w)\n {\n // defopen=lookaheadMatch[1]\n // cookiename=lookaheadMatch[2]\n // header=lookaheadMatch[3]\n // panelwidth=lookaheadMatch[4]\n // rollover=lookaheadMatch[5]\n // class=lookaheadMatch[6]\n // label=lookaheadMatch[7]\n // blockquote=lookaheadMatch[8]\n // deferred=lookaheadMatch[9]\n\n lookaheadRegExp = new RegExp(this.lookahead,"mg");\n lookaheadRegExp.lastIndex = w.matchStart;\n var lookaheadMatch = lookaheadRegExp.exec(w.source)\n if(lookaheadMatch && lookaheadMatch.index == w.matchStart)\n {\n // location for rendering button and panel\n var place=w.output;\n\n // default to closed, no cookie, no accesskey\n var show="none"; var title=">"; var tooltip="show"; var cookie=""; var key="";\n\n // extra "+", default to open\n if (lookaheadMatch[1])\n { show="block"; title="<"; tooltip="hide"; }\n\n // cookie, use saved open/closed state\n if (lookaheadMatch[2]) {\n cookie=lookaheadMatch[2].trim().slice(1,-1);\n cookie="chkSlider"+cookie;\n if (config.options[cookie]==undefined)\n { config.options[cookie] = (show=="block") }\n if (config.options[cookie])\n { show="block"; title="<"; tooltip="hide"; }\n else\n { show="none"; title=">"; tooltip="show"; }\n }\n\n // parse custom label/tooltip/accesskey: [label=X|tooltip]\n if (lookaheadMatch[7]) {\n title = lookaheadMatch[7].trim().slice(1,-1);\n var pos=title.indexOf("|");\n if (pos!=-1) { tooltip = title.substr(pos+1,title.length); title=title.substr(0,pos); }\n if (title.substr(title.length-2,1)=="=") { key=title.substr(title.length-1,1); title=title.slice(0,-2); }\n if (pos==-1) tooltip += " "+title; // default tooltip: "show/hide <title>"\n }\n\n // create the button\n if (lookaheadMatch[3]) { // use "Hn" header format instead of button/link\n var lvl=(lookaheadMatch[3].length>6)?6:lookaheadMatch[3].length;\n var btn = createTiddlyElement(createTiddlyElement(place,"h"+lvl,null,null,null),"a",null,lookaheadMatch[6],title);\n btn.onclick=onClickNestedSlider;\n btn.setAttribute("href","javascript:;");\n btn.setAttribute("title",tooltip);\n }\n else\n var btn = createTiddlyButton(place,title,tooltip,onClickNestedSlider,lookaheadMatch[6]);\n\n // set extra button attributes\n btn.sliderCookie = cookie; // save the cookiename (if any) in the button object\n btn.defOpen=lookaheadMatch[1]!=null; // save default open/closed state (boolean)\n btn.keyparam=key; // save the access key letter ("" if none)\n if (key.length) {\n btn.setAttribute("accessKey",key); // init access key\n btn.onfocus=function(){this.setAttribute("accessKey",this.keyparam);}; // **reclaim** access key on focus\n }\n\n // "non-click" MouseOver open/close slider\n if (lookaheadMatch[5]) btn.onmouseover=onClickNestedSlider;\n\n // create slider panel\n var panelClass=lookaheadMatch[4]?"floatingPanel":"sliderPanel";\n var panel=createTiddlyElement(place,"div",null,panelClass,null);\n panel.button = btn; // so the slider panel know which button it belongs to\n panel.defaultPanelWidth=(lookaheadMatch[4] && lookaheadMatch[4].length>2)?lookaheadMatch[4].slice(1,-1):""; // save requested panel size\n btn.sliderPanel=panel;\n panel.style.display = show;\n panel.style.width=panel.defaultPanelWidth;\n\n // render slider (or defer until shown) \n w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;\n if ((show=="block")||!lookaheadMatch[9]) {\n // render now if panel is supposed to be shown or NOT deferred rendering\n w.subWikify(lookaheadMatch[8]?createTiddlyElement(panel,"blockquote"):panel,this.terminator);\n // align slider/floater position with button\n adjustSliderPos(place,btn,panel,panelClass);\n }\n else {\n var src = w.source.substr(w.nextMatch);\n var endpos=findMatchingDelimiter(src,"+++","===");\n panel.setAttribute("raw",src.substr(0,endpos));\n panel.setAttribute("blockquote",lookaheadMatch[8]?"true":"false");\n panel.setAttribute("rendered","false");\n w.nextMatch += endpos+3;\n if (w.source.substr(w.nextMatch,1)=="\sn") w.nextMatch++;\n if (config.options.chkDebugLazySliderDefer) alert("deferred '"+title+"':\sn\sn"+panel.getAttribute("raw"));\n }\n }\n }\n }\n)\n\n// TBD: ignore 'quoted' delimiters (e.g., "{{{+++foo===}}}" isn't really a slider)\nfunction findMatchingDelimiter(src,starttext,endtext) {\n var startpos = 0;\n var endpos = src.indexOf(endtext);\n // check for nested delimiters\n while (src.substring(startpos,endpos-1).indexOf(starttext)!=-1) {\n // count number of nested 'starts'\n var startcount=0;\n var temp = src.substring(startpos,endpos-1);\n var pos=temp.indexOf(starttext);\n while (pos!=-1) { startcount++; pos=temp.indexOf(starttext,pos+starttext.length); }\n // set up to check for additional 'starts' after adjusting endpos\n startpos=endpos+endtext.length;\n // find endpos for corresponding number of matching 'ends'\n while (startcount && endpos!=-1) {\n endpos = src.indexOf(endtext,endpos+endtext.length);\n startcount--;\n }\n }\n return (endpos==-1)?src.length:endpos;\n}\n//}}}\n\n//{{{\nwindow.onClickNestedSlider=function(e)\n{\n if (!e) var e = window.event;\n var theTarget = resolveTarget(e);\n var theLabel = theTarget.firstChild.data;\n var theSlider = theTarget.sliderPanel\n var isOpen = theSlider.style.display!="none";\n // if using default button labels, toggle labels\n if (theLabel==">") theTarget.firstChild.data = "<";\n else if (theLabel=="<") theTarget.firstChild.data = ">";\n // if using default tooltips, toggle tooltips\n if (theTarget.getAttribute("title")=="show")\n theTarget.setAttribute("title","hide");\n else if (theTarget.getAttribute("title")=="hide")\n theTarget.setAttribute("title","show");\n if (theTarget.getAttribute("title")=="show "+theLabel)\n theTarget.setAttribute("title","hide "+theLabel);\n else if (theTarget.getAttribute("title")=="hide "+theLabel)\n theTarget.setAttribute("title","show "+theLabel);\n // deferred rendering (if needed)\n if (theSlider.getAttribute("rendered")=="false") {\n if (config.options.chkDebugLazySliderRender)\n alert("rendering '"+theLabel+"':\sn\sn"+theSlider.getAttribute("raw"));\n var place=theSlider;\n if (theSlider.getAttribute("blockquote")=="true")\n place=createTiddlyElement(place,"blockquote");\n wikify(theSlider.getAttribute("raw"),place);\n theSlider.setAttribute("rendered","true");\n }\n // show/hide the slider\n if(config.options.chkAnimate)\n anim.startAnimating(new Slider(theSlider,!isOpen,e.shiftKey || e.altKey,"none"));\n else\n theSlider.style.display = isOpen ? "none" : "block";\n // reset to default width (might have been changed via plugin code)\n theSlider.style.width=theSlider.defaultPanelWidth;\n // align slider/floater position with target button\n if (!isOpen) adjustSliderPos(theSlider.parentNode,theTarget,theSlider,theSlider.className);\n // if showing panel, set focus to first 'focus-able' element in panel\n if (theSlider.style.display!="none") {\n var ctrls=theSlider.getElementsByTagName("*");\n for (var c=0; c<ctrls.length; c++) {\n var t=ctrls[c].tagName.toLowerCase();\n if ((t=="input" && ctrls[c].type!="hidden") || t=="textarea" || t=="select")\n { ctrls[c].focus(); break; }\n }\n }\n if (this.sliderCookie && this.sliderCookie.length) {\n config.options[this.sliderCookie]=!isOpen;\n if (config.options[this.sliderCookie]!=this.defOpen)\n saveOptionCookie(this.sliderCookie);\n else { // remove cookie if slider is in default display state\n var ex=new Date(); ex.setTime(ex.getTime()-1000);\n document.cookie = this.sliderCookie+"=novalue; path=/; expires="+ex.toGMTString();\n }\n }\n return false;\n}\n\n// hijack animation handler 'stop' handler so overflow is visible after animation has completed\nSlider.prototype.coreStop = Slider.prototype.stop;\nSlider.prototype.stop = function() { this.coreStop(); this.element.style.overflow = "visible"; }\n\n// adjust panel position based on button position\nif (window.adjustSliderPos==undefined) window.adjustSliderPos=function(place,btn,panel,panelClass) {\n if (panelClass=="floatingPanel") {\n var left=0;\n var top=btn.offsetHeight; \n if (place.style.position!="relative") {\n var left=findPosX(btn);\n var top=findPosY(btn)+btn.offsetHeight;\n var p=place; while (p && p.className!='floatingPanel') p=p.parentNode;\n if (p) { left-=findPosX(p); top-=findPosY(p); }\n }\n if (left+panel.offsetWidth > getWindowWidth()) left=getWindowWidth()-panel.offsetWidth-10;\n panel.style.left=left+"px"; panel.style.top=top+"px";\n }\n}\n\nfunction getWindowWidth() {\n if(document.width!=undefined)\n return document.width; // moz (FF)\n if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )\n return document.documentElement.clientWidth; // IE6\n if(document.body && ( document.body.clientWidth || document.body.clientHeight ) )\n return document.body.clientWidth; // IE4\n if(window.innerWidth!=undefined)\n return window.innerWidth; // IE - general\n return 0; // unknown\n}\n//}}}
/***\n|''Name:''|WikiBar|\n|''Version:''|2.0.0 beta3|\n|''Source:''|[[AiddlyWiki|http://aiddlywiki.sourceforge.net]]|\n|''Author:''|[[Arphen Lin|mailto:arphenlin@gmail.com]]|\n|''Type:''|toolbar macro command extension|\n|''Required:''|TiddlyWiki 2.0.0 beta6|\n!Description\nWikiBar is a toolbar that gives access to most of TiddlyWiki's formatting features with a few clicks. It's a handy tool for people who are not familiar with TiddlyWiki syntax.\nBesides, with WikiBar-addons, users can extend the power of WikiBar.\n!Support browser\n*Firefox 1.5\n!Revision history\n*v2.0.0 beta3 (2005/12/30)\n** remove macros (replaced by TWMacro addon)\n** add wikibar command in toolbar automatically\n** rename DOIT to HANDLER\n** rename TIP to TOOLTIP\n*v2.0.0 beta2 (2005/12/21)\n** re-design Wikibar addon framework\n*v2.0.0 beta1 (2005/12/14)\n** Note:\n*** WikiBarPlugin is renamed to WikiBar\n** New Features:\n*** support TiddlyWiki 2.0.0 template mechanism\n*** new wikibar data structure\n*** new wikibar-addon framework for developers\n**** support dynamic popup menu generator\n*** support most new macros added in TiddlyWiki 2.0.0\n*** multi-level popup menu\n*** fix wikibar tab stop\n*** remove paletteSelector\n** Known Bugs:\n*** popup-menu and color-picker can't be closed correctly\n*** some macros can't be displayed correctly in previewer\n*** text in previewer will be displayed italic\n*v1.2.0 (2005/11/21)\n**New Features:\n***User defined color palettes supported\n####Get color palettes from [[ColorZilla Palettes|http://www.iosart.com/firefox/colorzilla/palettes.html]].\n####Save the palette file(*.gpl) as a new tiddler and tag it with 'ColorPalettes', then you can use it in WikiBar.\n***WikiBar style sheet supported\n***Click on document to close current colorPicker, paletteSelector or aboutWikibar\n*v1.1.1 (2005/11/03)\n**Bugs fixed:\n***'Not enough parameters!' message is displayed when the parameter includes '%+number', ex: 'hello%20world!'\n*v1.1.0 (2005/11/01)\n**Bugs fixed:\n***WikiBar overruns (reported by by GeoffS <gslocock@yahoo.co.uk>)\n**New features:\n***Insert a color code at the cursor. (Thanks to RunningUtes <RunningUtes@gmail.com>)\n***Enable gradient macro. (Thanks to RunningUtes <RunningUtes@gmail.com>)\n***Insert tiddler comment tags {{{/% ... %/}}}. (new feature supported by TiddlyWiki 1.2.37)\n***Insert DateFormatString for {{{<<today>>}}} macro. (new feature supported by TiddlyWiki 1.2.37)\n**Enhanced:\n***Allow optional parameters in syntax.\n**Bugs:\n***'Not enough parameters!' message is displayed when the parameter includes '%+number', ex: 'hello%20world!'\n*v1.0.0 (2005/10/30)\n**Initial release\n!Code\n***/\n//{{{\nconfig.macros.wikibar = {major: 2, minor: 0, revision: 0, beta: 3, date: new Date(2005,12,30)};\nconfig.macros.wikibar.handler = function(place,macroName,params,wikifier,paramString,tiddler){\n if(!(tiddler instanceof Tiddler)) {return;}\n story.setDirty(tiddler.title,true);\n place.id = 'wikibar'+tiddler.title;\n place.className = 'toolbar wikibar';\n};\nfunction wikibar_install(){\n config.commands.wikibar = {\n text: 'wikibar',\n tooltip: 'wikibar on/off',\n handler: function(e,src,title) {\n if(!e){ e = window.event; }\n var theButton = resolveTarget(e);\n theButton.id = 'wikibarButton'+title;\n wikibarPopup.remove();\n wikibar_installAddons(theButton, title);\n wikibar_createWikibar(title);\n return(false);\n }\n };\n config.shadowTiddlers['EditTemplate'] = wikibar_addWikibarCommand(config.shadowTiddlers['EditTemplate']);\n var tiddler = store.getTiddler('EditTemplate');\n if(tiddler){\n tiddler.text = wikibar_addWikibarCommand(tiddler.text);\n }\n}\nfunction wikibar_installAddons(theButton, title){\n var tiddlers = store.getTaggedTiddlers('wikibarAddons');\n if(!tiddlers) { return; }\n theButton.addons=[];\n for(var i=0; i<tiddlers.length; i++){\n try{\n eval(tiddlers[i].text);\n try{\n wikibar_addonInstall(title);\n wikibar_addonInstall = null;\n theButton.addons.push({ok:true, name:tiddlers[i].title});\n }catch(ex){\n theButton.addons.push({ok:false, name:tiddlers[i].title, error:ex});\n }\n }catch(ex){\n theButton.addons.push({ok:false, name:tiddlers[i].title, error:ex});\n }\n }\n}\nfunction wikibar_addWikibarCommand(tiddlerText){\n var div = document.createElement('div');\n div.style.display = 'none';\n div.innerHTML = tiddlerText;\n for(var i=0; i<div.childNodes.length; i++){\n var o=div.childNodes[i];\n if(o.tagName==='DIV'){\n if(o.className=='toolbar'){\n var macroText = o.getAttribute('macro').trim();\n if(macroText.search('wikibar')<=0){\n macroText += ' wikibar';\n o.setAttribute('macro', macroText);\n }\n break;\n }\n }\n }\n return div.innerHTML.replace(/\s"/g, "\s'");\n}\nfunction wikibar_processSyntaxParams(theSyntax, params){\n try{\n var pcr = 'AplWikibarPcr';\n var rx=null;\n var allParams=null;\n if(params){\n if(typeof(params)=='object'){\n for(var i=0; i<params.length; i++){\n if(params[i]){\n params[i] = params[i].replace(new RegExp('%','g'), pcr).trim();\n rx = '(\s\s[%'+(i+1)+'\s\s])' + '|' + '(%'+(i+1)+')';\n theSyntax = theSyntax.replace(new RegExp(rx,'g'), params[i] );\n }\n }\n allParams = params.join(' ').trim();\n }else{\n allParams = params.replace(new RegExp('%','g'), pcr).trim();\n rx = /(\s[%1{1}\s])|(%1{1})/g;\n theSyntax = theSyntax.replace(rx, allParams);\n }\n }\n if(allParams){\n theSyntax = theSyntax.replace(new RegExp('%N{1}','g'), allParams);\n }\n rx=/\s[%(([1-9]{1,}[0-9]{0,})|(N{1}))\s]/g;\n theSyntax = theSyntax.replace(rx, '');\n rx=/%(([1-9]{1,}[0-9]{0,})|(N{1}))/g;\n if( theSyntax.match(rx) ){\n throw 'Not enough parameters! ' + theSyntax;\n }\n theSyntax=theSyntax.replace(new RegExp(pcr,'g'), '%');\n return theSyntax;\n } catch(ex){\n return null;\n }\n}\nfunction wikibar_resolveEditItem(tiddlerWrapper, itemName){\n if(tiddlerWrapper.hasChildNodes()){\n var c=tiddlerWrapper.childNodes;\n for(var i=0; i<c.length; i++){\n var txt=wikibar_resolveEditItem(c[i], itemName);\n if(!txt){\n continue;\n }else{\n return txt;\n }\n }\n }\n return ((tiddlerWrapper.getAttribute && tiddlerWrapper.getAttribute('edit')==itemName)? tiddlerWrapper : null);\n}\nfunction wikibar_resolveEditItemValue(tiddlerWrapper, itemName){\n var o = wikibar_resolveEditItem(tiddlerWrapper, itemName);\n return (o? o.value.replace(/\sr/mg,'') : null);\n}\nfunction wikibar_resolveTiddlerEditorWrapper(obj){\n if(obj.id=='tiddlerDisplay'){return null;}\n if((obj.getAttribute && obj.getAttribute('macro')=='edit text')){return obj;}\n return wikibar_resolveTiddlerEditorWrapper(obj.parentNode);\n}\nfunction wikibar_resolveTiddlerEditor(obj){\n if(obj.hasChildNodes()){\n var c = obj.childNodes;\n for(var i=0; i<c.length; i++){\n var o=wikibar_resolveTiddlerEditor(c[i]);\n if(o){ return o;}\n }\n }\n return ((obj.getAttribute && obj.getAttribute('edit')=='text')? obj : null);\n}\nfunction wikibar_resolveTargetButton(obj){\n if(obj.id && obj.id.substring(0,7)=='wikibar'){ return null; }\n if(obj.tiddlerTitle){\n return obj;\n }else{\n return wikibar_resolveTargetButton(obj.parentNode);\n }\n}\nfunction wikibar_isValidMenuItem(tool){\n if(!tool){ return false; }\n if(tool.TYPE=='MENU' || tool.TYPE=='MAIN_MENU'){\n for(var key in tool){\n if(key.substring(0,8)=='DYNAITEM'){ return true; }\n if(wikibar_isValidMenuItem(tool[key])){ return true; }\n }\n return false;\n }else{\n return (tool.HANDLER? true : false);\n }\n}\nfunction wikibar_editFormat(param){\n var editor = param.button.editor;\n var params = param.params;\n clearMessage();\n if(!editor){ return; }\n var repText = wikibar_processSyntaxParams(this.syntax, params);\n if(repText===null){ return; }\n var st = editor.scrollTop;\n var ss = editor.selectionStart;\n var se = editor.selectionEnd;\n var frontText= '';\n var endText = '';\n var fullText = editor.value;\n if(se>ss && ss>=0){\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n }\n else if(ss===0 && (se===0 || se == fullText.length) ){\n endText = fullText;\n }\n else if(se==ss && ss>0){\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n }\n if(repText.indexOf('user_text')>=0 && this.hint){\n repText = repText.replace('user_text', this.hint);\n }\n editor.value = frontText + repText + endText;\n editor.selectionStart = ss;\n editor.selectionEnd = ss + repText.length;\n editor.scrollTop = st;\n editor.focus();\n}\nfunction wikibar_editFormatByWord(param){\n var editor = param.button.editor;\n var params = param.params;\n clearMessage();\n if(!editor){return;}\n var repText = wikibar_processSyntaxParams(this.syntax, params);\n if(repText===null){ return; }\n var st = editor.scrollTop;\n var ss = editor.selectionStart;\n var se = editor.selectionEnd;\n var frontText= '';\n var selText = '';\n var endText = '';\n var fullText = editor.value;\n if(se>ss && ss>=0){\n frontText = fullText.substring(0, ss);\n selText = fullText.substring(ss,se);\n endText = fullText.substring(se, fullText.length);\n }\n else if(ss===0 && (se===0 || se == fullText.length) ){\n endText = fullText;\n }\n else if(se==ss && ss>0){\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n if(!( fullText.charAt(ss-1).match(/\sW/gi) || fullText.charAt(ss).match(/\sW/gi) )){\n var m = frontText.match(/\sW/gi);\n if(m){\n ss = frontText.lastIndexOf(m[m.length-1])+1;\n }\n else{\n ss = 0;\n }\n m = endText.match(/\sW/gi);\n if(m){\n se += endText.indexOf(m[0]);\n }\n else{\n se = fullText.length;\n }\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n selText = fullText.substring(ss,se);\n }\n }\n if(selText.length>0){\n repText = repText.replace('user_text', selText);\n }\n if(repText.indexOf('user_text')>=0 && this.hint){\n repText = repText.replace('user_text', this.hint);\n }\n editor.value = frontText + repText + endText;\n editor.selectionStart = ss;\n editor.selectionEnd = ss + repText.length;\n editor.scrollTop = st;\n editor.focus();\n}\nfunction wikibar_editFormatByCursor(param){\n var editor = param.button.editor;\n var params = param.params;\n clearMessage();\n if(!editor){ return; }\n var repText = wikibar_processSyntaxParams(this.syntax, params);\n if(repText===null){ return; }\n var st = editor.scrollTop;\n var ss = editor.selectionStart;\n var se = editor.selectionEnd;\n var frontText= '';\n var endText = '';\n var fullText = editor.value;\n if(se>ss && ss>=0){\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n }\n else if(ss===0 && (se===0 || se == fullText.length) ){\n endText = fullText;\n }\n else if(se==ss && ss>0){\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n }\n if(repText.indexOf('user_text')>=0 && this.hint){\n repText = repText.replace('user_text', this.hint);\n }\n editor.value = frontText + repText + endText;\n editor.selectionStart = ss;\n editor.selectionEnd = ss + repText.length;\n editor.scrollTop = st;\n editor.focus();\n}\nfunction wikibar_editFormatByLine(param){\n var editor = param.button.editor;\n var params = param.params;\n clearMessage();\n if(!editor){ return; }\n var repText = wikibar_processSyntaxParams(this.syntax, params);\n if(repText===null){ return; }\n var st = editor.scrollTop;\n var ss = editor.selectionStart;\n var se = editor.selectionEnd;\n var frontText= '';\n var selText = '';\n var endText = '';\n var fullText = editor.value;\n if(se>ss && ss>=0){\n if(this.byBlock){\n frontText = fullText.substring(0, ss);\n selText = fullText.substring(ss,se);\n endText = fullText.substring(se, fullText.length);\n }\n else{\n se = ss;\n }\n }\n if(ss===0 && (se===0 || se == fullText.length) ){\n var m=fullText.match(/(\sn|\sr)/g);\n if(m){\n se = fullText.indexOf(m[0]);\n }else{\n se = fullText.length;\n }\n selText = fullText.substring(0, se);\n endText = fullText.substring(se, fullText.length);\n }\n else if(se==ss && ss>0){\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n m = frontText.match(/(\sn|\sr)/g);\n if(m){\n ss = frontText.lastIndexOf(m[m.length-1])+1;\n }\n else{\n ss = 0;\n }\n m = endText.match(/(\sn|\sr)/g);\n if(m){\n se += endText.indexOf(m[0]);\n }\n else{\n se = fullText.length;\n }\n frontText = fullText.substring(0, ss);\n selText = fullText.substring(ss,se);\n endText = fullText.substring(se, fullText.length);\n }\n if(selText.length>0){\n repText = repText.replace('user_text', selText);\n }\n if(repText.indexOf('user_text')>=0 && this.hint){\n repText = repText.replace('user_text', this.hint);\n }\n if(this.byBlock){\n if( (frontText.charAt(frontText.length-1)!='\sn') && ss>0 ){\n repText = '\sn' + repText;\n }\n if( (endText.charAt(0)!='\sn') || se==fullText.length){\n repText += '\sn';\n }\n }\n editor.value = frontText + repText + endText;\n editor.selectionStart = ss;\n editor.selectionEnd = ss + repText.length;\n editor.scrollTop = st;\n editor.focus();\n}\nfunction wikibar_editFormatByTableCell(param){\n var editor = param.button.editor;\n var params = param.params;\n clearMessage();\n if(!editor){ return; }\n var repText = wikibar_processSyntaxParams(this.syntax, params);\n if(repText===null){ return; }\n var st = editor.scrollTop;\n var ss = editor.selectionStart;\n var se = editor.selectionEnd;\n var frontText= '';\n var selText = '';\n var endText = '';\n var fullText = editor.value;\n if(ss===0 || ss==fullText.length){\n throw 'not valid cell!';\n }\n se=ss;\n frontText = fullText.substring(0, ss);\n endText = fullText.substring(se, fullText.length);\n i=frontText.lastIndexOf('\sn');\n j=frontText.lastIndexOf('|');\n if(i>j || j<0){\n throw 'not valid cell!';\n }\n ss = j+1;\n i=endText.indexOf('\sn');\n j=endText.indexOf('|');\n if(i<j || j<0){\n throw 'not valid cell!';\n }\n se += j;\n frontText = fullText.substring(0, ss-1);\n selText = fullText.substring(ss,se);\n endText = fullText.substring(se+1, fullText.length);\n if(this.key.substring(0,5)=='align'){\n selText = selText.trim();\n if( selText=='>' || selText=='~' || selText.substring(0,8)=='bgcolor(') {return; }\n }\n if(selText.length>0){\n repText = repText.replace('user_text', selText);\n }\n if(repText.indexOf('user_text')>=0 && this.hint){\n repText = repText.replace('user_text', this.hint);\n }\n editor.value = frontText + repText + endText;\n editor.selectionStart = ss;\n editor.selectionEnd = ss + repText.length - 2;\n editor.scrollTop = st;\n editor.focus();\n}\nfunction wikibar_editSelectAll(param){\n var editor = param.button.editor;\n editor.selectionStart = 0;\n editor.selectionEnd = editor.value.length;\n editor.scrollTop = 0;\n editor.focus();\n}\nfunction wikibar_doPreview(param){\n var theButton = param.button;\n var editor = param.button.editor;\n var wikibar = theButton.parentNode;\n if(!wikibar) { return; }\n title = theButton.tiddlerTitle;\n var editorWrapper = wikibar_resolveTiddlerEditorWrapper(editor);\n var tiddlerWrapper = editorWrapper.parentNode;\n var previewer = document.getElementById('previewer'+title);\n if(previewer){\n previewer.parentNode.removeChild(previewer);\n editorWrapper.style.display = 'block';\n visible=true;\n }else{\n previewer = document.createElement('div');\n previewer.id = 'previewer'+title;\n previewer.className = 'viewer previewer';\n previewer.style.height = (editor.offsetHeight) + 'px';\n wikify(editor.value, previewer);\n tiddlerWrapper.insertBefore(previewer, editorWrapper);\n editorWrapper.style.display = 'none';\n visible=false;\n }\n var pv=null;\n for(var i=0; i<wikibar.childNodes.length; i++){\n try{\n var btn = wikibar.childNodes[i];\n if(btn.toolItem.key == 'preview'){ pv=btn; }\n if(btn.toolItem.key != 'preview'){\n btn.style.display = visible ? '': 'none';\n }\n }catch(ex){}\n }\n if(!pv) { return; }\n if(visible){\n pv.innerHTML = '<font face=\s"verdana\s">&infin;</font>';\n pv.title = 'preview current tiddler';\n }\n else{\n pv.innerHTML = '<font face=\s"verdana\s">&larr;</font>';\n pv.title = 'back to editor';\n }\n}\nfunction wikibar_doListAddons(param){\n clearMessage();\n var title = param.button.tiddlerTitle;\n var wikibarButton = document.getElementById('wikibarButton'+title);\n var ok=0, fail=0;\n for(var i=0; i<wikibarButton.addons.length; i++){\n var addon=wikibarButton.addons[i];\n if(addon.ok){\n displayMessage('[ o ] '+addon.name);\n ok++;\n }\n else{\n displayMessage('[ x ] '+addon.name + ': ' + addon.error);\n fail++;\n }\n }\n displayMessage('---------------------------------');\n displayMessage(ok + ' ok ; ' + fail + ' failed');\n}\nfunction wikibar_getColorCode(param){\n var cbOnPickColor = function(colorCode, param){\n param.params = colorCode;\n param.button.toolItem.doMore(param);\n };\n wikibarColorTool.openColorPicker(param.button, cbOnPickColor, param);\n}\nfunction wikibar_getLinkUrl(param){\n var url= prompt('Please enter the link target', (this.param? this.param : ''));\n if (url && url.trim().length>0){\n param.params = url;\n this.doMore(param);\n }\n}\nfunction wikibar_getTableRowCol(param){\n var rc= prompt('Please enter (rows x cols) of the table', '2 x 3');\n if (!rc || (rc.trim()).length<=0){ return; }\n var arr = rc.toUpperCase().split('X');\n if(arr.length != 2) { return; }\n for(var i=0; i<arr.length; i++){\n if(isNaN(arr[i].trim())) { return; }\n }\n var rows = parseInt(arr[0].trim(), 10);\n var cols = parseInt(arr[1].trim(), 10);\n var txtTable='';\n for(var r=0; r<rows; r++){\n for(var c=0; c<=cols; c++){\n if(c===0){\n txtTable += '|';\n }else{\n txtTable += ' |';\n }\n }\n txtTable += '\sn';\n }\n if(txtTable.trim().length>0){\n param.params = txtTable.trim();\n this.doMore(param);\n }\n}\nfunction wikibar_getMacroParam(param){\n var p = prompt('Please enter the parameters of macro \s"' + this.key + '\s":' +\n '\snSyntax: ' + this.syntax +\n '\sn\snNote: '+\n '\sn%1,%2,... - parameter needed'+\n '\sn[%1] - optional parameter'+\n '\sn%N - more than one parameter(1~n)'+\n '\sn[%N] - any number of parameters(0~n)'+\n '\sn\snPS:'+\n '\sn1. Parameters should be seperated with space character'+\n '\sn2. Use \s" to wrap the parameter that includes space character, ex: \s"hello world\s"'+\n '\sn3. Input the word(null) for the optional parameter ignored',\n (this.param? this.param : '') );\n if(!p) { return; }\n p=p.readMacroParams();\n for(var i=0; i<p.length; i++){\n var s=p[i].trim();\n if(s.indexOf(' ')>0){ p[i]="'"+s+"'"; }\n if(s.toLowerCase()=='null'){ p[i]=null; }\n }\n param.params = p;\n this.doMore(param);\n}\nfunction wikibar_getMorePalette(unused){\n clearMessage();\n displayMessage('Get more color palettes(*.gpl) from ColorZilla Palettes site', 'http:\s/\s/www.iosart.com/firefox/colorzilla/palettes.html');\n displayMessage('Save it as a new tiddler with \s"ColorPalettes\s" tag');\n}\nfunction wikibar_createWikibar(title){\n var theWikibar = document.getElementById('wikibar' + title);\n if(theWikibar){\n if(theWikibar.hasChildNodes()){\n theWikibar.style.display = (theWikibar.style.display=='block'? 'none':'block');\n return;\n }\n }\n var tiddlerWrapper = document.getElementById('tiddler'+title);\n var theTextarea = wikibar_resolveTiddlerEditor(tiddlerWrapper);\n if(!theTextarea){\n clearMessage();\n displayMessage('WikiBar only works in tiddler edit mode now');\n return;\n }else{\n if(!theTextarea.id){ theTextarea.id = 'editor'+title; }\n if(!theTextarea.parentNode.id){ theTextarea.parentNode.id='editorWrapper'+title; }\n }\n if(theWikibar){\n theWikibar = document.getElementById('wikibar'+title);\n }else{\n var editorWrapper = wikibar_resolveTiddlerEditorWrapper(theTextarea);\n theWikibar = createTiddlyElement(tiddlerWrapper, 'div', 'wikibar'+title, 'toolbar');\n addClass(theWikibar, 'wikibar');\n var previewer = document.getElementById('previewer'+title);\n if(previewer){\n tiddlerWrapper.insertBefore(theWikibar, previewer);\n }else{\n tiddlerWrapper.insertBefore(theWikibar, editorWrapper);\n }\n }\n wikibar_createMenu(theWikibar,wikibarStore,title,theTextarea);\n if(config.options['chkWikibarSetEditorHeight'] && config.options['txtWikibarEditorRows']){\n theTextarea.rows = config.options['txtWikibarEditorRows'];\n }\n setStylesheet(\n '.wikibar{text-align:left;visibility:visible;margin:2px;padding:1px;}.previewer{overflow:auto;display:block;border:1px solid;}#colorPicker{position:absolute;display:none;z-index:10;margin:0px;padding:0px;}#colorPicker table{margin:0px;padding:0px;border:2px solid #000;border-spacing:0px;border-collapse:collapse;}#colorPicker td{margin:0px;padding:0px;border:1px solid;font-size:11px;text-align:center;cursor:auto;}#colorPicker .header{background-color:#fff;}#colorPicker .button{background-color:#fff;cursor:pointer;cursor:hand;}#colorPicker .button:hover{padding-top:3px;padding-bottom:3px;color:#fff;background-color:#136;}#colorPicker .cell{padding:4px;font-size:7px;cursor:crosshair;}#colorPicker .cell:hover{padding:10px;}.wikibarPopup{position:absolute;z-index:10;border:1px solid #014;color:#014;background-color:#cef;}.wikibarPopup table{margin:0;padding:0;border:0;border-spacing:0;border-collapse:collapse;}.wikibarPopup .button:hover{color:#eee;background-color:#014;}.wikibarPopup .disabled{color:#888;}.wikibarPopup .disabled:hover{color:#888;background-color:#cef;}.wikibarPopup tr .seperator hr{margin:0;padding:0;background-color:#cef;width:100%;border:0;border-top:1px dashed #014;}.wikibarPopup tr .icon{font-family:verdana;font-weight:bolder;}.wikibarPopup tr .marker{font-family:verdana;font-weight:bolder;}.wikibarPopup td{font-size:0.9em;padding:2px;}.wikibarPopup input{border:0;border-bottom:1px solid #014;margin:0;padding:0;font-family:arial;font-size:100%;background-color:#fff;}',\n 'WikiBarStyleSheet');\n}\nfunction wikibar_createMenu(place,toolset,title,editor){\n if(!wikibar_isValidMenuItem(toolset)){return;}\n if(!(toolset.TYPE=='MAIN_MENU' || toolset.TYPE=='MENU')){ return; }\n for(var key in toolset){\n if(key.substring(0,9)=='SEPERATOR'){\n wikibar_createMenuSeperator(place);\n continue;\n }\n if(key.substring(0,8)=='DYNAITEM'){\n var dynaTools = toolset[key](title,editor);\n if(dynaTools.TYPE && dynaTools.TYPE=='MENU'){\n wikibar_createMenuItem(place,dynaTools,null,editor,title);\n }else{\n dynaTools.TYPE = 'MENU';\n wikibar_createMenu(place, dynaTools, title, editor);\n }\n continue;\n }\n if((toolset[key].TYPE!='MENU' && toolset[key].TYPE!='MAIN_MENU') && !toolset[key].HANDLER){continue;}\n wikibar_createMenuItem(place,toolset,key,editor,title);\n }\n}\nfunction wikibar_createMenuItem(place,toolset,key,editor,title){\n if(!key){\n var tool = toolset;\n }else{\n tool = toolset[key];\n tool.key = key;\n }\n if(!wikibar_isValidMenuItem(tool)){return;}\n var toolIsOnMainMenu = (toolset.TYPE=='MAIN_MENU');\n var toolIsMenu = (tool.TYPE=='MENU');\n var theButton;\n if(toolIsOnMainMenu){\n theButton = createTiddlyButton(\n place,\n '',\n (tool.TOOLTIP? tool.TOOLTIP : ''),\n (toolIsMenu? wikibar_onClickMenuItem : wikibar_onClickItem),\n 'button');\n theButton.innerHTML = (tool.CAPTION? tool.CAPTION : key);\n theButton.isOnMainMenu = true;\n addClass(theButton, (toolIsMenu? 'menu' : 'item'));\n place.appendChild( document.createTextNode('\sn') );\n if(!toolIsMenu){\n if(config.options['chkWikibarPopmenuOnMouseOver']){\n theButton.onmouseover = function(e){ wikibarPopup.remove(); };\n }\n }\n }else{\n theButton=createTiddlyElement(place, 'tr',key,'button');\n theButton.title = (tool.TOOLTIP? tool.TOOLTIP : '');\n theButton.onclick = (toolIsMenu? wikibar_onClickMenuItem : wikibar_onClickItem);\n var tdL = createTiddlyElement(theButton, 'td','','marker');\n var td = createTiddlyElement(theButton, 'td');\n var tdR = createTiddlyElement(theButton, 'td','','marker');\n td.innerHTML = (tool.CAPTION? tool.CAPTION : key);\n if(toolIsMenu){\n tdR.innerHTML='&nbsp;&nbsp;&rsaquo;';\n }\n if(tool.SELECTED){\n tdL.innerHTML = '&radic; ';\n addClass(theButton, 'selected');\n }\n if(tool.DISABLED){\n addClass(theButton, 'disabled');\n }\n }\n theButton.tiddlerTitle = title;\n theButton.toolItem = tool;\n theButton.editor = editor;\n theButton.tabIndex = 999;\n if(toolIsMenu){\n if(config.options['chkWikibarPopmenuOnMouseOver']){\n theButton.onmouseover = wikibar_onClickMenuItem;\n }\n }\n}\nfunction wikibar_createMenuSeperator(place){\n if(place.id.substring(0,7)=='wikibar') { return; }\n var onclickSeperator=function(e){\n if(!e){ e = window.event; }\n e.cancelBubble = true;\n if (e.stopPropagation){ e.stopPropagation(); }\n return(false);\n };\n var theButton=createTiddlyElement(place,'tr','','seperator');\n var td = createTiddlyElement(theButton, 'td','','seperator');\n td.colSpan=3;\n theButton.onclick=onclickSeperator;\n td.innerHTML = '<hr>';\n}\nfunction wikibar_genWikibarAbout(){\n var toolset={};\n toolset.version = {\n CAPTION: '<center>WikiBar ' +\n config.macros.wikibar.major + '.' +\n config.macros.wikibar.minor + '.' +\n config.macros.wikibar.revision +\n (config.macros.wikibar.beta? ' beta '+config.macros.wikibar.beta : '') +\n '</center>',\n HANDLER: function(){}\n };\n toolset.SEPERATOR = {};\n toolset.author = {\n CAPTION: '<center>Arphen Lin<br>arphenlin@gmail.com</center>',\n TOOLTIP: 'send mail to the author',\n HANDLER: function(){ window.open('mailto:arphenlin@gmail.com'); }\n };\n toolset.website = {\n CAPTION: '<center>aiddlywiki.sourceforge.net</center>',\n TOOLTIP: 'go to the web site of WikiBar',\n HANDLER: function(){ window.open('http:\s/\s/aiddlywiki.sourceforge.net/'); }\n };\n return toolset;\n}\nfunction wikibar_genWikibarOptions(title, editor){\n var toolset={};\n toolset.popOnMouseOver = {\n CAPTION:'popup menu on mouse over',\n SELECTED: config.options['chkWikibarPopmenuOnMouseOver'],\n HANDLER: function(param){\n config.options['chkWikibarPopmenuOnMouseOver'] = !config.options['chkWikibarPopmenuOnMouseOver'];\n saveOptionCookie('chkWikibarPopmenuOnMouseOver');\n var title = param.button.tiddlerTitle;\n var wikibar = document.getElementById('wikibar'+title);\n if(wikibar){ wikibar.parentNode.removeChild(wikibar); }\n wikibar_createWikibar(title);\n }\n };\n toolset.setEditorSize = {\n CAPTION:'set editor height: <input id=\s"txtWikibarEditorRows\s" type=text size=1 MAXLENGTH=3 value=\s"' +\n (config.options['txtWikibarEditorRows']? config.options['txtWikibarEditorRows']:editor.rows) + '\s"> ok',\n HANDLER: function(param){\n var input = document.getElementById('txtWikibarEditorRows');\n if(input){\n var rows = parseInt(input.value, 10);\n if(!isNaN(rows)){\n var editor = param.button.editor;\n editor.rows = rows;\n }else{\n rows=config.maxEditRows;\n }\n config.options['txtWikibarEditorRows'] = rows;\n saveOptionCookie('txtWikibarEditorRows');\n config.maxEditRows = rows;\n }\n }\n };\n toolset.setEditorSizeOnLoadingWikibar = {\n CAPTION:'set editor height on loading wikibar',\n SELECTED: config.options['chkWikibarSetEditorHeight'],\n HANDLER: function(param){\n config.options['chkWikibarSetEditorHeight'] = !config.options['chkWikibarSetEditorHeight'];\n saveOptionCookie('chkWikibarSetEditorHeight');\n if(config.options['chkWikibarSetEditorHeight']){\n var rows = config.options['txtWikibarEditorRows'];\n if(!isNaN(rows)){ rows = 15; }\n var editor = param.button.editor;\n editor.rows = rows;\n config.options['txtWikibarEditorRows'] = rows;\n saveOptionCookie('txtWikibarEditorRows');\n }\n }\n };\n toolset.SEPERATOR = {};\n toolset.update = {\n CAPTION: 'check for updates',\n DISABLED: true,\n HANDLER: function(){}\n };\n return toolset;\n}\nfunction wikibar_genPaletteSelector(){\n try{\n var cpTiddlers = store.getTaggedTiddlers('ColorPalettes');\n if(!cpTiddlers) { return; }\n var palettes=[];\n palettes.push(wikibarColorTool.defaultPaletteName);\n for(var i=0; i<cpTiddlers.length; i++){\n palettes.push(cpTiddlers[i].title.trim());\n }\n var toolset={};\n for(i=0; i<palettes.length; i++){\n toolset[palettes[i]] = {\n TOOLTIP: palettes[i],\n SELECTED: (palettes[i]==wikibarColorTool.paletteName),\n HANDLER: wikibar_doSelectPalette\n };\n }\n return toolset;\n }catch(ex){ return null; }\n}\nfunction wikibar_onClickItem(e){\n if(!e){ e = window.event; }\n var theTarget = resolveTarget(e);\n if(theTarget.tagName=='INPUT'){\n e.cancelBubble = true;\n if (e.stopPropagation){ e.stopPropagation(); }\n return;\n }\n var theButton = wikibar_resolveTargetButton(theTarget);\n if(!theButton){ return(false); }\n var o = theButton.toolItem;\n if(!o) { return; }\n var param = {\n event: e,\n button: theButton\n };\n if(o.HANDLER){ o.HANDLER(param); }\n if(o.DISABLED){\n e.cancelBubble = true;\n if (e.stopPropagation){ e.stopPropagation(); }\n }\n return(false);\n}\nfunction wikibar_onClickMenuItem(e){\n if(!e){ e = window.event; }\n var theButton = wikibar_resolveTargetButton(resolveTarget(e));\n if(!theButton){ return(false); }\n e.cancelBubble = true;\n if (e.stopPropagation){ e.stopPropagation(); }\n var title = theButton.tiddlerTitle;\n var editor = theButton.editor;\n var tool = theButton.toolItem;\n if(!tool) { return; }\n var popup = wikibarPopup.create(this);\n if(popup){\n wikibar_createMenu(popup,tool,title,editor);\n if(!popup.hasChildNodes()){\n wikibarPopup.remove();\n }else{\n wikibarPopup.show(popup, false);\n }\n }\n return(false);\n}\nvar wikibarColorTool = {\n defaultPaletteName : 'default',\n defaultColumns : 16,\n defaultPalette : [\n '#FFF','#DDD','#CCC','#BBB','#AAA','#999','#666','#333','#111','#000','#FC0','#F90','#F60','#F30','#C30','#C03',\n '#9C0','#9D0','#9E0','#E90','#D90','#C90','#FC3','#FC6','#F96','#F63','#600','#900','#C00','#F00','#F36','#F03',\n '#CF0','#CF3','#330','#660','#990','#CC0','#FF0','#C93','#C63','#300','#933','#C33','#F33','#C36','#F69','#F06',\n '#9F0','#CF6','#9C3','#663','#993','#CC3','#FF3','#960','#930','#633','#C66','#F66','#903','#C39','#F6C','#F09',\n '#6F0','#9F6','#6C3','#690','#996','#CC6','#FF6','#963','#630','#966','#F99','#F39','#C06','#906','#F3C','#F0C',\n '#3F0','#6F3','#390','#6C0','#9F3','#CC9','#FF9','#C96','#C60','#C99','#F9C','#C69','#936','#603','#C09','#303',\n '#0C0','#3C0','#360','#693','#9C6','#CF9','#FFC','#FC9','#F93','#FCC','#C9C','#969','#939','#909','#636','#606',\n '#060','#3C3','#6C6','#0F0','#3F3','#6F6','#9F9','#CFC','#9CF','#FCF','#F9F','#F6F','#F3F','#F0F','#C6C','#C3C',\n '#030','#363','#090','#393','#696','#9C9','#CFF','#39F','#69C','#CCF','#C9F','#96C','#639','#306','#90C','#C0C',\n '#0F3','#0C3','#063','#396','#6C9','#9FC','#9CC','#06C','#369','#99F','#99C','#93F','#60C','#609','#C3F','#C0F',\n '#0F6','#3F6','#093','#0C6','#3F9','#9FF','#699','#036','#039','#66F','#66C','#669','#309','#93C','#C6F','#90F',\n '#0F9','#6F9','#3C6','#096','#6FF','#6CC','#366','#069','#36C','#33F','#33C','#339','#336','#63C','#96F','#60F',\n '#0FC','#6FC','#3C9','#3FF','#3CC','#399','#033','#39C','#69F','#00F','#00C','#009','#006','#003','#63F','#30F',\n '#0C9','#3FC','#0FF','#0CC','#099','#066','#3CF','#6CF','#09C','#36F','#0CF','#09F','#06F','#03F','#03C','#30C'\n ],\n colorPicker : null,\n pickColorHandler: null,\n userData: null\n};\nwikibarColorTool.paletteName = wikibarColorTool.defaultPaletteName;\nwikibarColorTool.columns = wikibarColorTool.defaultColumns;\nwikibarColorTool.palette = wikibarColorTool.defaultPalette;\nwikibarColorTool.onPickColor = function(e){\n if (!e){ e = window.event; }\n var theCell = resolveTarget(e);\n if(!theCell){ return(false); }\n color = theCell.bgColor.toLowerCase();\n if(!color) { return; }\n wikibarColorTool.displayColorPicker(false);\n if(wikibarColorTool.pickColorHandler){\n wikibarColorTool.pickColorHandler(color, wikibarColorTool.userData);\n }\n return(false);\n};\nwikibarColorTool.onMouseOver = function(e){\n if (!e){ e = window.event; }\n var theButton = resolveTarget(e);\n if(!theButton){ return(false); }\n if(!wikibarColorTool) { return; }\n color = theButton.bgColor.toUpperCase();\n if(!color) { return; }\n td=document.getElementById('colorPickerInfo');\n if(!td) { return; }\n td.bgColor = color;\n td.innerHTML = '<span style=\s"color:#000;\s">'+color+'</span>&nbsp;&nbsp;&nbsp;' +\n '<span style=\s"color:#fff;\s">'+color+'</span>';\n e.cancelBubble = true;\n if (e.stopPropagation){ e.stopPropagation(); }\n return(false);\n};\nwikibarColorTool.openColorPicker = function(theTarget, pickColorHandler, userData){\n wikibarColorTool.skipClickDocumentEvent = true;\n wikibarColorTool.pickColorHandler = pickColorHandler;\n wikibarColorTool.userData = userData;\n wikibarColorTool.moveColorPicker(theTarget);\n};\nwikibarColorTool.convert3to6HexColor = function(c){\n c=c.trim();\n var rx=/^\s#(\sd|[a-f])(\sd|[a-f])(\sd|[a-f])$/gi;\n return (rx.test(c)? c.replace(rx, '#$1$1$2$2$3$3') : c);\n};\nwikibarColorTool.numToHexColor = function (n){\n if(typeof(n)=='number' && (n>=0 && n<=255)) {\n s = n.toString(16).toLowerCase();\n return ((s.length==1)? '0'+s : s);\n }else{\n return null;\n }\n};\nwikibarColorTool.renderColorPalette = function(){\n if(wikibarColorTool.paletteName==wikibarColorTool.defaultPaletteName){\n wikibarColorTool.palette=wikibarColorTool.defaultPalette;\n wikibarColorTool.columns=wikibarColorTool.defaultColumns;\n return;\n }\n tiddlerText = (store.getTiddlerText(wikibarColorTool.paletteName, '')).trim();\n if(tiddlerText.length<=0) { return; }\n var cpContents = tiddlerText.split('\sn');\n var colors=[];\n columns = wikibarColorTool.defaultColumns;\n var tmpArray=null;\n errCount=0;\n for(var i=0; i<cpContents.length; i++){\n cpLine=cpContents[i].trim();\n if( (!cpLine) || (cpLine.length<=0) || (cpLine.charAt(0) == '#') ){ continue; }\n if(cpLine.substring(0,8).toLowerCase()=='columns:'){\n tmpArray = cpLine.split(':');\n try{\n columns = parseInt(tmpArray[1],10);\n }catch(ex){\n columns = wikibarColorTool.defaultColumns;\n }\n }else{\n tmpArray = cpLine.replace('\st', ' ').split(/[ ]{1,}/);\n try{\n color='';\n for(var j=0; j<3; j++){\n c=parseInt(tmpArray[j].trim(), 10);\n if(isNaN(c)){\n break;\n }else{\n c=wikibarColorTool.numToHexColor(c);\n if(!c) {break;}\n color+=c;\n }\n }\n if(color.length==6){\n colors.push('#'+color);\n } else {\n throw 'error';\n }\n }catch(ex){\n }\n }\n }\n if(colors.length>0){\n wikibarColorTool.palette = colors;\n wikibarColorTool.columns = columns;\n }else{\n throw 'renderColorPalette(): No color defined in the palette.';\n }\n};\nwikibarColorTool.displayColorPicker = function(visible){\n if(wikibarColorTool.colorPicker){\n wikibarColorTool.colorPicker.style.display = (visible? 'block' : 'none');\n }\n};\nwikibarColorTool.moveColorPicker = function(theTarget){\n if(!wikibarColorTool.colorPicker){\n wikibarColorTool.createColorPicker();\n }\n var cp = wikibarColorTool.colorPicker;\n var rootLeft = findPosX(theTarget);\n var rootTop = findPosY(theTarget);\n var popupLeft = rootLeft;\n var popupTop = rootTop;\n var popupWidth = cp.offsetWidth;\n var winWidth = findWindowWidth();\n if(popupLeft + popupWidth > winWidth){\n popupLeft = winWidth - popupWidth;\n }\n cp.style.left = popupLeft + 'px';\n cp.style.top = popupTop + 'px';\n wikibarColorTool.displayColorPicker(true);\n};\nwikibarColorTool.createColorPicker = function(unused, palette){\n if(palette){ wikibarColorTool.paletteName=palette; }\n wikibarColorTool.renderColorPalette();\n wikibarColorTool.colorPicker = document.createElement('div');\n wikibarColorTool.colorPicker.id = 'colorPicker';\n document.body.appendChild(wikibarColorTool.colorPicker);\n var theTable = document.createElement('table');\n wikibarColorTool.colorPicker.appendChild(theTable);\n var theTR = document.createElement('tr');\n theTable.appendChild(theTR);\n var theTD = document.createElement('td');\n theTD.className = 'header';\n theTD.colSpan = wikibarColorTool.columns;\n theTD.innerHTML = wikibarColorTool.paletteName;\n theTR.appendChild(theTD);\n for(var i=0; i<wikibarColorTool.palette.length; i++){\n if((i%wikibarColorTool.columns)===0){\n theTR = document.createElement('tr');\n theTable.appendChild(theTR);\n }\n theTD = document.createElement('td');\n theTD.className = 'cell';\n theTD.bgColor = wikibarColorTool.convert3to6HexColor(wikibarColorTool.palette[i]);\n theTD.onclick = wikibarColorTool.onPickColor;\n theTD.onmouseover = wikibarColorTool.onMouseOver;\n theTR.appendChild(theTD);\n }\n rest = wikibarColorTool.palette.length % wikibarColorTool.columns;\n if(rest>0){\n theTD = document.createElement('td');\n theTD.colSpan = wikibarColorTool.columns-rest;\n theTD.bgColor = '#000000';\n theTR.appendChild(theTD);\n }\n theTR = document.createElement('tr');\n theTable.appendChild(theTR);\n theTD = document.createElement('td');\n theTD.colSpan = wikibarColorTool.columns;\n theTD.id = 'colorPickerInfo';\n theTR.appendChild(theTD);\n};\nwikibarColorTool.onDocumentClick = function(e){\n if (!e){ e = window.event; }\n if(wikibarColorTool.skipClickDocumentEvent) {\n wikibarColorTool.skipClickDocumentEvent = false;\n return true;\n }\n if((!e.eventPhase) || e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET){\n wikibarColorTool.displayColorPicker(false);\n }\n return true;\n};\nfunction wikibar_doSelectPalette(param){\n clearMessage();\n var theButton = param.button;\n if(!theButton.toolItem.key) { return; }\n var palette = theButton.toolItem.key;\n var oldPaletteName = wikibarColorTool.paletteName;\n if(oldPaletteName != palette){\n try{\n wikibarColorTool.createColorPicker(theButton, palette);\n displayMessage('Palette \s"'+palette+'\s" ('+ wikibarColorTool.palette.length +' colors) is selected');\n }catch(ex){\n errMsg = ex;\n if(errMsg.substring(0,18)=='renderColorPalette'){\n displayMessage('Invalid palette \s"' + palette + '\s", please check it out!');\n wikibarColorTool.createColorPicker(theButton, oldPaletteName);\n }\n }\n }\n}\nvar wikibarPopup = {\n skipClickDocumentEvent: false,\n stack: []\n};\nwikibarPopup.resolveRootPopup = function(o){\n if(o.isOnMainMenu){ return null; }\n if(o.className.substring(0,12)=='wikibarPopup'){ return o;}\n return wikibarPopup.resolveRootPopup(o.parentNode);\n};\nwikibarPopup.create = function(root){\n for(var i=0; i<wikibarPopup.stack.length; i++){\n var p=wikibarPopup.stack[i];\n if(p.root==root){\n wikibarPopup.removeFrom(i+1);\n return null;\n }\n }\n var rootPopup = wikibarPopup.resolveRootPopup(root);\n if(!rootPopup){\n wikibarPopup.remove();\n }else{\n wikibarPopup.removeFromRootPopup(rootPopup);\n }\n var popup = createTiddlyElement(document.body,'div','wikibarPopup'+root.toolItem.key,'wikibarPopup');\n var pop = createTiddlyElement(popup,'table','','');\n wikibarPopup.stack.push({rootPopup: rootPopup, root: root, popup: popup});\n return pop;\n};\nwikibarPopup.show = function(unused,slowly){\n var curr = wikibarPopup.stack[wikibarPopup.stack.length-1];\n var overlayWidth = 1;\n var rootLeft, rootTop, rootWidth, rootHeight, popupLeft, popupTop, popupWidth;\n if(curr.rootPopup){\n rootLeft = findPosX(curr.rootPopup);\n rootTop = findPosY(curr.root);\n rootWidth = curr.rootPopup.offsetWidth;\n popupLeft = rootLeft + rootWidth - overlayWidth;\n popupTop = rootTop;\n }else{\n rootLeft = findPosX(curr.root);\n rootTop = findPosY(curr.root);\n rootHeight = curr.root.offsetHeight;\n popupLeft = rootLeft;\n popupTop = rootTop + rootHeight;\n }\n var winWidth = findWindowWidth();\n popupWidth = curr.popup.offsetWidth;\n if(popupLeft + popupWidth > winWidth){\n popupLeft = rootLeft - popupWidth + overlayWidth;\n }\n curr.popup.style.left = popupLeft + 'px';\n curr.popup.style.top = popupTop + 'px';\n curr.popup.style.display = 'block';\n addClass(curr.root, 'highlight');\n if(config.options.chkAnimate){\n anim.startAnimating(new Scroller(curr.popup,slowly));\n }else{\n window.scrollTo(0,ensureVisible(curr.popup));\n }\n};\nwikibarPopup.remove = function(){\n if(wikibarPopup.stack.length > 0){\n wikibarPopup.removeFrom(0);\n }\n};\nwikibarPopup.removeFrom = function(from){\n for(var t=wikibarPopup.stack.length-1; t>=from; t--){\n var p = wikibarPopup.stack[t];\n removeClass(p.root,'highlight');\n p.popup.parentNode.removeChild(p.popup);\n }\n wikibarPopup.stack = wikibarPopup.stack.slice(0,from);\n};\nwikibarPopup.removeFromRootPopup = function(from){\n for(var t=0; t<wikibarPopup.stack.length; t++){\n var p = wikibarPopup.stack[t];\n if(p.rootPopup==from){\n wikibarPopup.removeFrom(t);\n break;\n }\n }\n};\nwikibarPopup.onDocumentClick = function(e){\n if (!e){ e = window.event; }\n if(wikibarPopup.skipClickDocumentEvent){\n wikibarPopup.skipClickDocumentEvent=false;\n return true;\n }\n if((!e.eventPhase) || e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET){\n wikibarPopup.remove();\n }\n return true;\n};\nvar wikibarStore = {\n TYPE: 'MAIN_MENU',\n help:{\n TYPE:'MENU',\n CAPTION: '<font face=\s"verdana\s">?</font>',\n TOOLTIP: 'about WikiBar',\n options:{\n TYPE:'MENU',\n DYNAITEM: wikibar_genWikibarOptions\n },\n about:{\n TYPE:'MENU',\n DYNAITEM: wikibar_genWikibarAbout\n }\n },\n preview:{\n TOOLTIP: 'preview this tiddler',\n CAPTION: '<font face=\s"verdana\s">&infin;</font>',\n HANDLER: wikibar_doPreview\n },\n line:{\n TOOLTIP: 'horizontal line',\n CAPTION: '<font face=\s"verdana\s">&mdash;</font>',\n syntax: '\sn----\sn',\n HANDLER: wikibar_editFormatByCursor\n },\n crlf:{\n TOOLTIP: 'new line',\n CAPTION: '<font face=\s"verdana\s">&para;</font>',\n syntax: '\sn',\n HANDLER: wikibar_editFormatByCursor\n },\n selectAll:{\n TOOLTIP: 'select all',\n CAPTION: '<font face=\s"verdana\s">&sect;</font>',\n HANDLER: wikibar_editSelectAll\n },\n deleteSelected:{\n TOOLTIP: 'delete selected',\n CAPTION: '<font face=\s"verdana\s">&times;</font>',\n syntax: '',\n HANDLER: wikibar_editFormat\n },\n textFormat:{\n TYPE: 'MENU',\n CAPTION: 'text',\n TOOLTIP: 'text formatters',\n ignore:{\n TOOLTIP: 'ignore wiki word',\n CAPTION: 'ignore wikiWord',\n syntax: '~user_text',\n hint: 'wiki_word',\n HANDLER: wikibar_editFormatByWord\n },\n bolder:{\n TOOLTIP: 'bolder text',\n CAPTION: '<strong>bolder</strong>',\n syntax: "''user_text''",\n hint: 'bold_text',\n HANDLER: wikibar_editFormatByWord\n },\n italic:{\n TOOLTIP: 'italic text',\n CAPTION: '<em>italic</em>',\n syntax: '\s/\s/user_text\s/\s/',\n hint: 'italic_text',\n HANDLER: wikibar_editFormatByWord\n },\n underline:{\n TOOLTIP: 'underline text',\n CAPTION: '<u>underline</u>',\n syntax: '__user_text__',\n hint: 'underline_text',\n HANDLER: wikibar_editFormatByWord\n },\n strikethrough:{\n TOOLTIP: 'strikethrough text',\n CAPTION: '<strike>strikethrough</strike>',\n syntax: '==user_text==',\n hint: 'strikethrough_text',\n HANDLER: wikibar_editFormatByWord\n },\n superscript:{\n TOOLTIP: 'superscript text',\n CAPTION: 'X<sup>superscript</sup>',\n syntax: '^^user_text^^',\n hint: 'superscript_text',\n HANDLER: wikibar_editFormatByWord\n },\n subscript:{\n TOOLTIP: 'subscript text',\n CAPTION: 'X<sub>subscript</sub>',\n syntax: '~~user_text~~',\n hint: 'subscript_text',\n HANDLER: wikibar_editFormatByWord\n },\n comment:{\n TOOLTIP: 'comment text',\n CAPTION: 'comment text',\n syntax: '/%user_text%/',\n hint: 'comment_text',\n HANDLER: wikibar_editFormatByWord\n },\n monospaced:{\n TOOLTIP: 'monospaced text',\n CAPTION: '<code>monospaced</code>',\n syntax: '{{{user_text}}}',\n hint: 'monospaced_text',\n HANDLER: wikibar_editFormatByWord\n }\n },\n paragraph:{\n TYPE: 'MENU',\n TOOLTIP: 'paragarph formatters',\n list:{\n TYPE: 'MENU',\n TOOLTIP: 'list tools',\n bullet:{\n TOOLTIP: 'bullet point',\n syntax: '*user_text',\n hint: 'bullet_text',\n HANDLER: wikibar_editFormatByLine\n },\n numbered:{\n TOOLTIP: 'numbered list',\n syntax: '#user_text',\n hint: 'numbered_text',\n HANDLER: wikibar_editFormatByLine\n }\n },\n heading:{\n TYPE: 'MENU',\n heading1:{\n CAPTION:'<h1>Heading 1</h1>',\n TOOLTIP: 'Heading 1',\n syntax: '!user_text',\n hint: 'heading_1',\n HANDLER: wikibar_editFormatByLine\n },\n heading2:{\n CAPTION:'<h2>Heading 2<h2>',\n TOOLTIP: 'Heading 2',\n syntax: '!!user_text',\n hint: 'heading_2',\n HANDLER: wikibar_editFormatByLine\n },\n heading3:{\n CAPTION:'<h3>Heading 3</h3>',\n TOOLTIP: 'Heading 3',\n syntax: '!!!user_text',\n hint: 'heading_3',\n HANDLER: wikibar_editFormatByLine\n },\n heading4:{\n CAPTION:'<h4>Heading 4</h4>',\n TOOLTIP: 'Heading 4',\n syntax: '!!!!user_text',\n hint: 'heading_4',\n HANDLER: wikibar_editFormatByLine\n },\n heading5:{\n CAPTION:'<h5>Heading 5</h5>',\n TOOLTIP: 'Heading 5',\n syntax: '!!!!!user_text',\n hint: 'heading_5',\n HANDLER: wikibar_editFormatByLine\n }\n },\n comment:{\n TYPE: 'MENU',\n commentByLine:{\n CAPTION:'comment by line',\n TOOLTIP: 'line comment',\n syntax: '/%user_text%/',\n hint: 'comment_text',\n HANDLER: wikibar_editFormatByLine\n },\n commentByBlock:{\n CAPTION:'comment by block',\n TOOLTIP: 'block comment',\n syntax: '/%\snuser_text\sn%/',\n hint: 'comment_text',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n }\n },\n monospaced:{\n TYPE: 'MENU',\n monosByLine:{\n CAPTION: 'monospaced by line',\n TOOLTIP: 'line monospaced',\n syntax: '{{{\snuser_text\sn}}}',\n hint: 'monospaced_text',\n HANDLER: wikibar_editFormatByLine\n },\n monosByBlock:{\n CAPTION: 'monospaced by block',\n TOOLTIP: 'block monospaced',\n syntax: '{{{\snuser_text\sn}}}',\n hint: 'monospaced_text',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n }\n },\n quote:{\n TYPE: 'MENU',\n quoteByLine:{\n CAPTION: 'quote by line',\n TOOLTIP: 'line quote',\n syntax: '>user_text',\n hint: 'quote_text',\n HANDLER: wikibar_editFormatByLine\n },\n quoteByBlcok:{\n CAPTION: 'quote by block',\n TOOLTIP: 'block quote',\n syntax: '<<<\snuser_text\sn<<<',\n hint: 'quote_text',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n }\n },\n plugin:{\n TYPE: 'MENU',\n code:{\n CAPTION: 'code area',\n TOOLTIP: 'block monospaced for plugin',\n syntax: '\sn\s/\s/{{{\snuser_text\sn\s/\s/}}}\sn',\n hint: 'monospaced_plugin_code',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n },\n commentByLine:{\n CAPTION: 'comment by line',\n TOOLTIP: 'line comment',\n syntax: '\s/\s/user_text',\n hint: 'plugin_comment',\n HANDLER: wikibar_editFormatByLine\n },\n commentByBlock:{\n CAPTION: 'comment by block',\n TOOLTIP: 'block comment',\n syntax: '\s/\s***\snuser_text\sn***\s/',\n hint: 'plugin_comment',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n }\n },\n css:{\n TYPE: 'MENU',\n code:{\n CAPTION: 'code area',\n TOOLTIP: 'block monospaced for css',\n syntax: '\sn\snuser_text\sn\sn',\n hint: 'monospaced_css_code',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n },\n commentByLine:{\n CAPTION: 'comment by line',\n TOOLTIP: 'line comment',\n syntax: '',\n hint: 'css_comment',\n HANDLER: wikibar_editFormatByLine\n },\n commentByBlock:{\n CAPTION: 'comment by block',\n TOOLTIP: 'block comment',\n syntax: '',\n hint: 'css_comment',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n }\n }\n },\n color:{\n TYPE: 'MENU',\n TOOLTIP: 'color tools',\n highlight:{\n CAPTION:'highlight text',\n TOOLTIP: 'highlight text',\n syntax: '@@user_text@@',\n hint: 'highlight_text',\n HANDLER: wikibar_editFormatByWord\n },\n color:{\n CAPTION:'text color',\n TOOLTIP: 'text color',\n hint: 'your_text',\n syntax: '@@color(%1):user_text@@',\n HANDLER: wikibar_getColorCode,\n doMore: wikibar_editFormatByWord\n },\n bgcolor:{\n CAPTION:'background color',\n TOOLTIP: 'background color',\n hint: 'your_text',\n syntax: '@@bgcolor(%1):user_text@@',\n HANDLER: wikibar_getColorCode,\n doMore: wikibar_editFormatByWord\n },\n colorcode:{\n CAPTION:'color code',\n TOOLTIP: 'insert color code',\n syntax: '%1',\n HANDLER: wikibar_getColorCode,\n doMore: wikibar_editFormatByCursor\n },\n 'color palette':{\n TYPE:'MENU',\n DYNAITEM: wikibar_genPaletteSelector,\n SEPERATOR:{},\n morePalette:{\n CAPTION:'more palettes',\n TOOLTIP:'get more palettes',\n HANDLER: wikibar_getMorePalette\n }\n }\n },\n link:{\n TYPE: 'MENU',\n TOOLTIP: 'insert link',\n wiki:{\n CAPTION:'wiki link',\n TOOLTIP: 'wiki link',\n syntax: '[[user_text]]',\n hint: 'wiki_word',\n HANDLER: wikibar_editFormatByWord\n },\n pretty:{\n CAPTION: 'pretty link',\n TOOLTIP: 'pretty link',\n syntax: '[[user_text|%1]]',\n hint: 'pretty_word',\n param: 'PrettyLink Target',\n HANDLER: wikibar_getLinkUrl,\n doMore: wikibar_editFormatByWord\n },\n url:{\n TOOLTIP: 'url link',\n syntax: '[[user_text|%1]]',\n hint: 'your_text',\n param: 'http:\s/\s/...',\n HANDLER: wikibar_getLinkUrl,\n doMore: wikibar_editFormatByWord\n },\n image:{\n TOOLTIP: 'image link',\n syntax: '[img[user_text|%1]]',\n hint: 'alt_text',\n param: 'image/icon.jpg',\n HANDLER: wikibar_getLinkUrl,\n doMore: wikibar_editFormatByWord\n }\n },\n macro:{},\n more:{\n TYPE: 'MENU',\n TOOLTIP: 'more tools',\n table:{\n TYPE: 'MENU',\n TOOLTIP: 'table',\n table:{\n CAPTION:'create table',\n TOOLTIP: 'create a new table',\n syntax: '\sn%1\sn',\n HANDLER: wikibar_getTableRowCol,\n doMore: wikibar_editFormatByWord\n },\n header:{\n TOOLTIP: 'table header text',\n syntax: '|user_text|c',\n hint: 'table_header',\n HANDLER: wikibar_editFormatByWord\n },\n cell:{\n TOOLTIP: 'create a tabel cell',\n syntax: '|user_text|',\n hint: 'your_text',\n HANDLER: wikibar_editFormatByWord\n },\n columnHeader:{\n CAPTION:'column header',\n TOOLTIP: 'create a column header cell',\n syntax: '|!user_text|',\n hint: 'column_header',\n HANDLER: wikibar_editFormatByWord\n },\n cell:{\n TYPE: 'MENU',\n CAPTION: 'cell options',\n bgcolor:{\n CAPTION: 'background color',\n TOOLTIP: 'cell bgcolor',\n syntax: '|bgcolor(%1):user_text|',\n hint: 'your_text',\n HANDLER: wikibar_getColorCode,\n doMore: wikibar_editFormatByTableCell\n },\n alignLeft:{\n CAPTION: 'align left',\n TOOLTIP: 'left align cell text',\n syntax: '|user_text|',\n hint: 'your_text',\n HANDLER: wikibar_editFormatByTableCell\n },\n alignCenter:{\n CAPTION: 'align center',\n TOOLTIP: 'center align cell text',\n syntax: '| user_text |',\n hint: 'your_text',\n HANDLER: wikibar_editFormatByTableCell\n },\n alignRight:{\n CAPTION: 'align right',\n TOOLTIP: 'right align cell text',\n syntax: '| user_text|',\n hint: 'your_text',\n HANDLER: wikibar_editFormatByTableCell\n }\n }\n },\n html:{\n TYPE: 'MENU',\n html:{\n CAPTION: '&lt;html&gt;',\n TOOLTIP: 'html tag',\n syntax: '<html>\snuser_text\sn</html>',\n hint: 'html_content',\n byBlock: true,\n HANDLER: wikibar_editFormatByLine\n }\n }\n },\n addon:{\n TYPE: 'MENU',\n TOOLTIP:'3rd party tools',\n 'about addons':{\n TOOLTIP: 'list loaded addons',\n HANDLER: wikibar_doListAddons\n },\n SEPERATOR:{}\n }\n};\naddEvent(document, 'click', wikibarColorTool.onDocumentClick);\naddEvent(document, 'click', wikibarPopup.onDocumentClick);\nwikibar_install();\n//}}}\n\n\n