index.html 240 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <script>
  5. var version = {major: 2, minor: 1, revision: 3, date: new Date("Nov 3, 2006"), extensions: {}};
  6. </script>
  7. <!--
  8. TiddlyWiki 2.1.3 by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
  9. Copyright (c) Osmosoft Limited 2004-2006
  10. Redistribution and use in source and binary forms, with or without modification,
  11. are permitted provided that the following conditions are met:
  12. Redistributions of source code must retain the above copyright notice, this
  13. list of conditions and the following disclaimer.
  14. Redistributions in binary form must reproduce the above copyright notice, this
  15. list of conditions and the following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. Neither the name of the Osmosoft Limited nor the names of its contributors may be
  18. used to endorse or promote products derived from this software without specific
  19. prior written permission.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  21. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  22. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  23. SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  25. TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  26. BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  28. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  29. DAMAGE.
  30. -->
  31. <meta charset="utf-8"/>
  32. <!--PRE-HEAD-START-->
  33. <!--{{{-->
  34. <link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>
  35. <!--}}}-->
  36. <!--PRE-HEAD-END-->
  37. <title> axTLS Embedded SSL - changes, notes and errata </title>
  38. <script>
  39. // ---------------------------------------------------------------------------------
  40. // Configuration repository
  41. // ---------------------------------------------------------------------------------
  42. // Miscellaneous options
  43. var config = {
  44. numRssItems: 20, // Number of items in the RSS feed
  45. animFast: 0.12, // Speed for animations (lower == slower)
  46. animSlow: 0.01, // Speed for EasterEgg animations
  47. cascadeFast: 20, // Speed for cascade animations (higher == slower)
  48. cascadeSlow: 60, // Speed for EasterEgg cascade animations
  49. cascadeDepth: 5, // Depth of cascade animation
  50. displayStartupTime: false // Whether to display startup time
  51. };
  52. // Messages
  53. config.messages = {
  54. messageClose: {},
  55. dates: {}
  56. };
  57. // Options that can be set in the options panel and/or cookies
  58. config.options = {
  59. chkRegExpSearch: false,
  60. chkCaseSensitiveSearch: false,
  61. chkAnimate: true,
  62. chkSaveBackups: true,
  63. chkAutoSave: false,
  64. chkGenerateAnRssFeed: false,
  65. chkSaveEmptyTemplate: false,
  66. chkOpenInNewWindow: true,
  67. chkToggleLinks: false,
  68. chkHttpReadOnly: true,
  69. chkForceMinorUpdate: false,
  70. chkConfirmDelete: true,
  71. chkInsertTabs: false,
  72. txtBackupFolder: "",
  73. txtMainTab: "tabTimeline",
  74. txtMoreTab: "moreTabAll",
  75. txtMaxEditRows: "30"
  76. };
  77. // List of notification functions to be called when certain tiddlers are changed or deleted
  78. config.notifyTiddlers = [
  79. {name: "StyleSheetLayout", notify: refreshStyles},
  80. {name: "StyleSheetColors", notify: refreshStyles},
  81. {name: "StyleSheet", notify: refreshStyles},
  82. {name: "StyleSheetPrint", notify: refreshStyles},
  83. {name: "PageTemplate", notify: refreshPageTemplate},
  84. {name: "SiteTitle", notify: refreshPageTitle},
  85. {name: "SiteSubtitle", notify: refreshPageTitle},
  86. {name: "ColorPalette", notify: refreshColorPalette},
  87. {name: null, notify: refreshDisplay}
  88. ];
  89. // Default tiddler templates
  90. var DEFAULT_VIEW_TEMPLATE = 1;
  91. var DEFAULT_EDIT_TEMPLATE = 2;
  92. config.tiddlerTemplates = {
  93. 1: "ViewTemplate",
  94. 2: "EditTemplate"
  95. };
  96. // More messages (rather a legacy layout that shouldn't really be like this)
  97. config.views = {
  98. wikified: {
  99. tag: {}
  100. },
  101. editor: {
  102. tagChooser: {}
  103. }
  104. };
  105. // Macros; each has a 'handler' member that is inserted later
  106. config.macros = {
  107. today: {},
  108. version: {},
  109. search: {sizeTextbox: 15},
  110. tiddler: {},
  111. tag: {},
  112. tags: {},
  113. tagging: {},
  114. timeline: {},
  115. allTags: {},
  116. list: {
  117. all: {},
  118. missing: {},
  119. orphans: {},
  120. shadowed: {}
  121. },
  122. closeAll: {},
  123. permaview: {},
  124. saveChanges: {},
  125. slider: {},
  126. option: {},
  127. newTiddler: {},
  128. newJournal: {},
  129. sparkline: {},
  130. tabs: {},
  131. gradient: {},
  132. message: {},
  133. view: {},
  134. edit: {},
  135. tagChooser: {},
  136. toolbar: {},
  137. br: {},
  138. plugins: {},
  139. refreshDisplay: {},
  140. importTiddlers: {}
  141. };
  142. // Commands supported by the toolbar macro
  143. config.commands = {
  144. closeTiddler: {},
  145. closeOthers: {},
  146. editTiddler: {},
  147. saveTiddler: {hideReadOnly: true},
  148. cancelTiddler: {},
  149. deleteTiddler: {hideReadOnly: true},
  150. permalink: {},
  151. references: {},
  152. jump: {}
  153. };
  154. // Browser detection... In a very few places, there's nothing else for it but to
  155. // know what browser we're using.
  156. config.userAgent = navigator.userAgent.toLowerCase();
  157. config.browser = {
  158. isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1,
  159. ieVersion: /MSIE (\d.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0"
  160. isSafari: config.userAgent.indexOf("applewebkit") != -1,
  161. isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")),
  162. firefoxDate: /Gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD"
  163. isOpera: config.userAgent.indexOf("opera") != -1,
  164. isLinux: config.userAgent.indexOf("linux") != -1,
  165. isUnix: config.userAgent.indexOf("x11") != -1,
  166. isMac: config.userAgent.indexOf("mac") != -1,
  167. isWindows: config.userAgent.indexOf("win") != -1
  168. };
  169. // Basic regular expressions
  170. config.textPrimitives = {
  171. upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]",
  172. lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]",
  173. anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]",
  174. anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]"
  175. };
  176. if(config.browser.isBadSafari)
  177. config.textPrimitives = {
  178. upperLetter: "[A-Z\u00c0-\u00de]",
  179. lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]",
  180. anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]",
  181. anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]"
  182. }
  183. config.textPrimitives.sliceSeparator = "::";
  184. config.textPrimitives.urlPattern = "[a-z]{3,8}:[^\\s:'\"][^\\s'\"]*(?:/|\\b)";
  185. config.textPrimitives.unWikiLink = "~";
  186. config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" +
  187. config.textPrimitives.lowerLetter + "+" +
  188. config.textPrimitives.upperLetter +
  189. config.textPrimitives.anyLetter + "*)|(?:" +
  190. config.textPrimitives.upperLetter + "{2,}" +
  191. config.textPrimitives.lowerLetter + "+))";
  192. config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)";
  193. config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg");
  194. config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]";
  195. config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
  196. config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" +
  197. config.textPrimitives.brackettedLink + ")|(?:" +
  198. config.textPrimitives.urlPattern + ")","mg");
  199. config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" +
  200. config.textPrimitives.titledBrackettedLink + ")|(?:" +
  201. config.textPrimitives.brackettedLink + ")|(?:" +
  202. config.textPrimitives.urlPattern + ")","mg");
  203. // ---------------------------------------------------------------------------------
  204. // Shadow tiddlers
  205. // ---------------------------------------------------------------------------------
  206. config.shadowTiddlers = {
  207. ColorPalette: "Background: #fff\n" +
  208. "Foreground: #000\n" +
  209. "PrimaryPale: #8cf\n" +
  210. "PrimaryLight: #18f\n" +
  211. "PrimaryMid: #04b\n" +
  212. "PrimaryDark: #014\n" +
  213. "SecondaryPale: #ffc\n" +
  214. "SecondaryLight: #fe8\n" +
  215. "SecondaryMid: #db4\n" +
  216. "SecondaryDark: #841\n" +
  217. "TertiaryPale: #eee\n" +
  218. "TertiaryLight: #ccc\n" +
  219. "TertiaryMid: #999\n" +
  220. "TertiaryDark: #666\n" +
  221. "Error: #f88\n",
  222. StyleSheet: "",
  223. StyleSheetColors: "/*{{{*/\nbody {\n background: [[ColorPalette::Background]];\n color: [[ColorPalette::Foreground]];\n}\n\na{\n color: [[ColorPalette::PrimaryMid]];\n}\n\na:hover{\n background: [[ColorPalette::PrimaryMid]];\n color: [[ColorPalette::Background]];\n}\n\na img{\n border: 0;\n}\n\nh1,h2,h3,h4,h5 {\n color: [[ColorPalette::SecondaryDark]];\n background: [[ColorPalette::PrimaryPale]];\n}\n\n.button {\n color: [[ColorPalette::PrimaryDark]];\n border: 1px solid [[ColorPalette::Background]];\n}\n\n.button:hover {\n color: [[ColorPalette::PrimaryDark]];\n background: [[ColorPalette::SecondaryLight]];\n border-color: [[ColorPalette::SecondaryMid]];\n}\n\n.button:active {\n color: [[ColorPalette::Background]];\n background: [[ColorPalette::SecondaryMid]];\n border: 1px solid [[ColorPalette::SecondaryDark]];\n}\n\n.header {\n background: [[ColorPalette::PrimaryMid]];\n}\n\n.headerShadow {\n color: [[ColorPalette::Foreground]];\n}\n\n.headerShadow a {\n font-weight: normal;\n color: [[ColorPalette::Foreground]];\n}\n\n.headerForeground {\n color: [[ColorPalette::Background]];\n}\n\n.headerForeground a {\n font-weight: normal;\n color: [[ColorPalette::PrimaryPale]];\n}\n\n.tabSelected{\n color: [[ColorPalette::PrimaryDark]];\n background: [[ColorPalette::TertiaryPale]];\n border-left: 1px solid [[ColorPalette::TertiaryLight]];\n border-top: 1px solid [[ColorPalette::TertiaryLight]];\n border-right: 1px solid [[ColorPalette::TertiaryLight]];\n}\n\n.tabUnselected {\n color: [[ColorPalette::Background]];\n background: [[ColorPalette::TertiaryMid]];\n}\n\n.tabContents {\n color: [[ColorPalette::PrimaryDark]];\n background: [[ColorPalette::TertiaryPale]];\n border: 1px solid [[ColorPalette::TertiaryLight]];\n}\n\n.tabContents .button {\n border: 0;}\n\n#sidebar {\n}\n\n#sidebarOptions input {\n border: 1px solid [[ColorPalette::PrimaryMid]];\n}\n\n#sidebarOptions .sliderPanel {\n background: [[ColorPalette::PrimaryPale]];\n}\n\n#sidebarOptions .sliderPanel a {\n border: none;\n color: [[ColorPalette::PrimaryMid]];\n}\n\n#sidebarOptions .sliderPanel a:hover {\n color: [[ColorPalette::Background]];\n background: [[ColorPalette::PrimaryMid]];\n}\n\n#sidebarOptions .sliderPanel a:active {\n color: [[ColorPalette::PrimaryMid]];\n background: [[ColorPalette::Background]];\n}\n\n.wizard {\n background: [[ColorPalette::SecondaryLight]];\n border-top: 1px solid [[ColorPalette::SecondaryMid]];\n border-left: 1px solid [[ColorPalette::SecondaryMid]];\n}\n\n.wizard h1 {\n color: [[ColorPalette::SecondaryDark]];\n}\n\n.wizard h2 {\n color: [[ColorPalette::Foreground]];\n}\n\n.wizardStep {\n background: [[ColorPalette::Background]];\n border-top: 1px solid [[ColorPalette::SecondaryMid]];\n border-bottom: 1px solid [[ColorPalette::SecondaryMid]];\n border-left: 1px solid [[ColorPalette::SecondaryMid]];\n}\n\n.wizard .button {\n color: [[ColorPalette::Background]];\n background: [[ColorPalette::PrimaryMid]];\n border-top: 1px solid [[ColorPalette::PrimaryLight]];\n border-right: 1px solid [[ColorPalette::PrimaryDark]];\n border-bottom: 1px solid [[ColorPalette::PrimaryDark]];\n border-left: 1px solid [[ColorPalette::PrimaryLight]];\n}\n\n.wizard .button:hover {\n color: [[ColorPalette::PrimaryLight]];\n background: [[ColorPalette::PrimaryDark]];\n border-color: [[ColorPalette::PrimaryLight]];\n}\n\n.wizard .button:active {\n color: [[ColorPalette::Background]];\n background: [[ColorPalette::PrimaryMid]];\n border-top: 1px solid [[ColorPalette::PrimaryLight]];\n border-right: 1px solid [[ColorPalette::PrimaryDark]];\n border-bottom: 1px solid [[ColorPalette::PrimaryDark]];\n border-left: 1px solid [[ColorPalette::PrimaryLight]];\n}\n\n#messageArea {\n border: 1px solid [[ColorPalette::SecondaryDark]];\n background: [[ColorPalette::SecondaryMid]];\n color: [[ColorPalette::PrimaryDark]];\n}\n\n#messageArea .button {\n padding: 0.2em 0.2em 0.2em 0.2em;\n color: [[ColorPalette::PrimaryDark]];\n background: [[ColorPalette::Background]];\n}\n\n.popup {\n background: [[ColorPalette::PrimaryLight]];\n border: 1px solid [[ColorPalette::PrimaryMid]];\n}\n\n.popup hr {\n color: [[ColorPalette::PrimaryDark]];\n background: [[ColorPalette::PrimaryDark]];\n border-bottom: 1px;\n}\n\n.listBreak div{\n border-bottom: 1px solid [[ColorPalette::PrimaryDark]];\n}\n\n.popup li.disabled {\n color: [[ColorPalette::PrimaryMid]];\n}\n\n.popup li a, .popup li a:visited {\n color: [[ColorPalette::TertiaryPale]];\n border: none;\n}\n\n.popup li a:hover {\n background: [[ColorPalette::PrimaryDark]];\n color: [[ColorPalette::Background]];\n border: none;\n}\n\n.tiddler .defaultCommand {\n font-weight: bold;\n}\n\n.shadow .title {\n color: [[ColorPalette::TertiaryDark]];\n}\n\n.title {\n color: [[ColorPalette::SecondaryDark]];\n}\n\n.subtitle {\n color: [[ColorPalette::TertiaryDark]];\n}\n\n.toolbar {\n color: [[ColorPalette::PrimaryMid]];\n}\n\n.tagging, .tagged {\n border: 1px solid [[ColorPalette::TertiaryPale]];\n background-color: [[ColorPalette::TertiaryPale]];\n}\n\n.selected .tagging, .selected .tagged {\n background-color: [[ColorPalette::TertiaryLight]];\n border: 1px solid [[ColorPalette::TertiaryMid]];\n}\n\n.tagging .listTitle, .tagged .listTitle {\n color: [[ColorPalette::PrimaryDark]];\n}\n\n.tagging .button, .tagged .button {\n border: none;\n}\n\n.footer {\n color: [[ColorPalette::TertiaryLight]];\n}\n\n.selected .footer {\n color: [[ColorPalette::TertiaryMid]];\n}\n\n.sparkline {\n background: [[ColorPalette::PrimaryPale]];\n border: 0;\n}\n\n.sparktick {\n background: [[ColorPalette::PrimaryDark]];\n}\n\n.error, .errorButton {\n color: [[ColorPalette::Foreground]];\n background: [[ColorPalette::Error]];\n}\n\n.warning {\n color: [[ColorPalette::Foreground]];\n background: [[ColorPalette::SecondaryPale]];\n}\n\n.cascade {\n background: [[ColorPalette::TertiaryPale]];\n color: [[ColorPalette::TertiaryMid]];\n border: 1px solid [[ColorPalette::TertiaryMid]];\n}\n\n.imageLink, #displayArea .imageLink {\n background: transparent;\n}\n\n.viewer .listTitle {list-style-type: none; margin-left: -2em;}\n\n.viewer .button {\n border: 1px solid [[ColorPalette::SecondaryMid]];\n}\n\n.viewer blockquote {\n border-left: 3px solid [[ColorPalette::TertiaryDark]];\n}\n\n.viewer table {\n border: 2px solid [[ColorPalette::TertiaryDark]];\n}\n\n.viewer th, thead td {\n background: [[ColorPalette::SecondaryMid]];\n border: 1px solid [[ColorPalette::TertiaryDark]];\n color: [[ColorPalette::Background]];\n}\n\n.viewer td, .viewer tr {\n border: 1px solid [[ColorPalette::TertiaryDark]];\n}\n\n.viewer pre {\n border: 1px solid [[ColorPalette::SecondaryLight]];\n background: [[ColorPalette::SecondaryPale]];\n}\n\n.viewer code {\n color: [[ColorPalette::SecondaryDark]];\n}\n\n.viewer hr {\n border: 0;\n border-top: dashed 1px [[ColorPalette::TertiaryDark]];\n color: [[ColorPalette::TertiaryDark]];\n}\n\n.highlight, .marked {\n background: [[ColorPalette::SecondaryLight]];\n}\n\n.editor input {\n border: 1px solid [[ColorPalette::PrimaryMid]];\n}\n\n.editor textarea {\n border: 1px solid [[ColorPalette::PrimaryMid]];\n width: 100%;\n}\n\n.editorFooter {\n color: [[ColorPalette::TertiaryMid]];\n}\n\n/*}}}*/",
  224. StyleSheetLayout: "/*{{{*/\n* html .tiddler {\n height: 1%;\n}\n\nbody {\n font-size: .75em;\n font-family: arial,helvetica;\n margin: 0;\n padding: 0;\n}\n\nh1,h2,h3,h4,h5 {\n font-weight: bold;\n text-decoration: none;\n padding-left: 0.4em;\n}\n\nh1 {font-size: 1.35em;}\nh2 {font-size: 1.25em;}\nh3 {font-size: 1.1em;}\nh4 {font-size: 1em;}\nh5 {font-size: .9em;}\n\nhr {\n height: 1px;\n}\n\na{\n text-decoration: none;\n}\n\ndt {font-weight: bold;}\n\nol { list-style-type: decimal }\nol ol { list-style-type: lower-alpha }\nol ol ol { list-style-type: lower-roman }\nol ol ol ol { list-style-type: decimal }\nol ol ol ol ol { list-style-type: lower-alpha }\nol ol ol ol ol ol { list-style-type: lower-roman }\nol ol ol ol ol ol ol { list-style-type: decimal }\n\n.txtOptionInput {\n width: 11em;\n}\n\n#contentWrapper .chkOptionInput {\n border: 0;\n}\n\n.externalLink {\n text-decoration: underline;\n}\n\n.indent {margin-left:3em;}\n.outdent {margin-left:3em; text-indent:-3em;}\ncode.escaped {white-space:nowrap;}\n\n.tiddlyLinkExisting {\n font-weight: bold;\n}\n\n.tiddlyLinkNonExisting {\n font-style: italic;\n}\n\n/* the 'a' is required for IE, otherwise it renders the whole tiddler a bold */\na.tiddlyLinkNonExisting.shadow {\n font-weight: bold;\n}\n\n#mainMenu .tiddlyLinkExisting, \n#mainMenu .tiddlyLinkNonExisting,\n#sidebarTabs .tiddlyLinkNonExisting{\n font-weight: normal;\n font-style: normal;\n}\n\n#sidebarTabs .tiddlyLinkExisting {\n font-weight: bold;\n font-style: normal;\n}\n\n.header {\n position: relative;\n}\n\n.header a:hover {\n background: transparent;\n}\n\n.headerShadow {\n position: relative;\n padding: 4.5em 0em 1em 1em;\n left: -1px;\n top: -1px;\n}\n\n.headerForeground {\n position: absolute;\n padding: 4.5em 0em 1em 1em;\n left: 0px;\n top: 0px;\n}\n\n.siteTitle {\n font-size: 3em;\n}\n\n.siteSubtitle {\n font-size: 1.2em;\n}\n\n#mainMenu {\n position: absolute;\n left: 0;\n width: 10em;\n text-align: right;\n line-height: 1.6em;\n padding: 1.5em 0.5em 0.5em 0.5em;\n font-size: 1.1em;\n}\n\n#sidebar {\n position: absolute;\n right: 3px;\n width: 16em;\n font-size: .9em;\n}\n\n#sidebarOptions {\n padding-top: 0.3em;\n}\n\n#sidebarOptions a {\n margin: 0em 0.2em;\n padding: 0.2em 0.3em;\n display: block;\n}\n\n#sidebarOptions input {\n margin: 0.4em 0.5em;\n}\n\n#sidebarOptions .sliderPanel {\n margin-left: 1em;\n padding: 0.5em;\n font-size: .85em;\n}\n\n#sidebarOptions .sliderPanel a {\n font-weight: bold;\n display: inline;\n padding: 0;\n}\n\n#sidebarOptions .sliderPanel input {\n margin: 0 0 .3em 0;\n}\n\n#sidebarTabs .tabContents {\n width: 15em;\n overflow: hidden;\n}\n\n.wizard {\n padding: 0.1em 0em 0em 2em;\n}\n\n.wizard h1 {\n font-size: 2em;\n font-weight: bold;\n background: none;\n padding: 0em 0em 0em 0em;\n margin: 0.4em 0em 0.2em 0em;\n}\n\n.wizard h2 {\n font-size: 1.2em;\n font-weight: bold;\n background: none;\n padding: 0em 0em 0em 0em;\n margin: 0.2em 0em 0.2em 0em;\n}\n\n.wizardStep {\n padding: 1em 1em 1em 1em;\n}\n\n.wizard .button {\n margin: 0.5em 0em 0em 0em;\n font-size: 1.2em;\n}\n\n#messageArea {\nposition:absolute; top:0; right:0; margin: 0.5em; padding: 0.5em;\n}\n\n*[id='messageArea'] {\nposition:fixed !important; z-index:99;}\n\n.messageToolbar {\ndisplay: block;\ntext-align: right;\n}\n\n#messageArea a{\n text-decoration: underline;\n}\n\n.popup {\n font-size: .9em;\n padding: 0.2em;\n list-style: none;\n margin: 0;\n}\n\n.popup hr {\n display: block;\n height: 1px;\n width: auto;\n padding: 0;\n margin: 0.2em 0em;\n}\n\n.listBreak {\n font-size: 1px;\n line-height: 1px;\n}\n\n.listBreak div {\n margin: 2px 0;\n}\n\n.popup li.disabled {\n padding: 0.2em;\n}\n\n.popup li a{\n display: block;\n padding: 0.2em;\n}\n\n.tabset {\n padding: 1em 0em 0em 0.5em;\n}\n\n.tab {\n margin: 0em 0em 0em 0.25em;\n padding: 2px;\n}\n\n.tabContents {\n padding: 0.5em;\n}\n\n.tabContents ul, .tabContents ol {\n margin: 0;\n padding: 0;\n}\n\n.txtMainTab .tabContents li {\n list-style: none;\n}\n\n.tabContents li.listLink {\n margin-left: .75em;\n}\n\n#displayArea {\n margin: 1em 17em 0em 14em;\n}\n\n\n.toolbar {\n text-align: right;\n font-size: .9em;\n visibility: hidden;\n}\n\n.selected .toolbar {\n visibility: visible;\n}\n\n.tiddler {\n padding: 1em 1em 0em 1em;\n}\n\n.missing .viewer,.missing .title {\n font-style: italic;\n}\n\n.title {\n font-size: 1.6em;\n font-weight: bold;\n}\n\n.missing .subtitle {\n display: none;\n}\n\n.subtitle {\n font-size: 1.1em;\n}\n\n.tiddler .button {\n padding: 0.2em 0.4em;\n}\n\n.tagging {\nmargin: 0.5em 0.5em 0.5em 0;\nfloat: left;\ndisplay: none;\n}\n\n.isTag .tagging {\ndisplay: block;\n}\n\n.tagged {\nmargin: 0.5em;\nfloat: right;\n}\n\n.tagging, .tagged {\nfont-size: 0.9em;\npadding: 0.25em;\n}\n\n.tagging ul, .tagged ul {\nlist-style: none;margin: 0.25em;\npadding: 0;\n}\n\n.tagClear {\nclear: both;\n}\n\n.footer {\n font-size: .9em;\n}\n\n.footer li {\ndisplay: inline;\n}\n\n* html .viewer pre {\n width: 99%;\n padding: 0 0 1em 0;\n}\n\n.viewer {\n line-height: 1.4em;\n padding-top: 0.5em;\n}\n\n.viewer .button {\n margin: 0em 0.25em;\n padding: 0em 0.25em;\n}\n\n.viewer blockquote {\n line-height: 1.5em;\n padding-left: 0.8em;\n margin-left: 2.5em;\n}\n\n.viewer ul, .viewer ol{\n margin-left: 0.5em;\n padding-left: 1.5em;\n}\n\n.viewer table {\n border-collapse: collapse;\n margin: 0.8em 1.0em;\n}\n\n.viewer th, .viewer td, .viewer tr,.viewer caption{\n padding: 3px;\n}\n\n.viewer table.listView {\n font-size: 0.85em;\n margin: 0.8em 1.0em;\n}\n\n.viewer table.listView th, .viewer table.listView td, .viewer table.listView tr {\n padding: 0px 3px 0px 3px;\n}\n\n.viewer pre {\n padding: 0.5em;\n margin-left: 0.5em;\n font-size: 1.2em;\n line-height: 1.4em;\n overflow: auto;\n}\n\n.viewer code {\n font-size: 1.2em;\n line-height: 1.4em;\n}\n\n.editor {\nfont-size: 1.1em;\n}\n\n.editor input, .editor textarea {\n display: block;\n width: 100%;\n font: inherit;\n}\n\n.editorFooter {\n padding: 0.25em 0em;\n font-size: .9em;\n}\n\n.editorFooter .button {\npadding-top: 0px; padding-bottom: 0px;}\n\n.fieldsetFix {border: 0;\npadding: 0;\nmargin: 1px 0px 1px 0px;\n}\n\n.sparkline {\n line-height: 1em;\n}\n\n.sparktick {\n outline: 0;\n}\n\n.zoomer {\n font-size: 1.1em;\n position: absolute;\n padding: 1em;\n}\n\n.cascade {\n font-size: 1.1em;\n position: absolute;\n overflow: hidden;\n}\n/*}}}*/",
  225. StyleSheetPrint: "/*{{{*/\n@media print {\n#mainMenu, #sidebar, #messageArea, .toolbar {display: none ! important;}\n#displayArea {margin: 1em 1em 0em 1em;}\n/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */\nnoscript {display:none;}\n}\n/*}}}*/",
  226. PageTemplate: "<!--{{{-->\n<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>\n<div class='headerShadow'>\n<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;\n<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>\n</div>\n<div class='headerForeground'>\n<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;\n<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>\n</div>\n</div>\n<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>\n<div id='sidebar'>\n<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>\n<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>\n</div>\n<div id='displayArea'>\n<div id='messageArea'></div>\n<div id='tiddlerDisplay'></div>\n</div>\n<!--}}}-->",
  227. ViewTemplate: "<!--{{{-->\n<div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler permalink references jump'></div>\n<div class='title' macro='view title'></div>\n<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date [[DD MMM YYYY]]'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date [[DD MMM YYYY]]'></span>)</div>\n<div class='tagging' macro='tagging'></div>\n<div class='tagged' macro='tags'></div>\n<div class='viewer' macro='view text wikified'></div>\n<div class='tagClear'></div>\n<!--}}}-->",
  228. EditTemplate: "<!--{{{-->\n<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>\n<div class='title' macro='view title'></div>\n<div class='editor' macro='edit title'></div>\n<div class='editor' macro='edit text'></div>\n<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>\n<!--}}}-->",
  229. MarkupPreHead: "<!--{{{-->\n<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>\n<!--}}}-->",
  230. MarkupPostHead: "",
  231. MarkupPreBody: "",
  232. MarkupPostBody: ""
  233. };
  234. // ---------------------------------------------------------------------------------
  235. // Translateable strings
  236. // ---------------------------------------------------------------------------------
  237. // Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone
  238. merge(config.options,{
  239. txtUserName: "YourName"});
  240. merge(config.messages,{
  241. customConfigError: "Problems were encountered loading plugins. See PluginManager for details",
  242. pluginError: "Error: %0",
  243. pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag",
  244. pluginForced: "Executed because forced via 'systemConfigForce' tag",
  245. pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki",
  246. nothingSelected: "Nothing is selected. You must select one or more items first",
  247. savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#DownloadSoftware for details",
  248. subtitleUnknown: "(unknown)",
  249. undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
  250. shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value",
  251. tiddlerLinkTooltip: "%0 - %1, %2",
  252. externalLinkTooltip: "External link to %0",
  253. noTags: "There are no tagged tiddlers",
  254. notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
  255. cantSaveError: "It's not possible to save changes. This could be because your browser doesn't support saving (instead, use FireFox if you can), or because the pathname to your TiddlyWiki file contains illegal characters",
  256. invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
  257. backupSaved: "Backup saved",
  258. backupFailed: "Failed to save backup file",
  259. rssSaved: "RSS feed saved",
  260. rssFailed: "Failed to save RSS feed file",
  261. emptySaved: "Empty template saved",
  262. emptyFailed: "Failed to save empty template file",
  263. mainSaved: "Main TiddlyWiki file saved",
  264. mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
  265. macroError: "Error in macro <<%0>>",
  266. macroErrorDetails: "Error while executing macro <<%0>>:\n%1",
  267. missingMacro: "No such macro",
  268. overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
  269. unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
  270. confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------",
  271. saveInstructions: "SaveChanges",
  272. unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'",
  273. tiddlerSaveError: "Error when saving tiddler '%0'",
  274. tiddlerLoadError: "Error when loading tiddler '%0'",
  275. wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.",
  276. invalidFieldName: "Invalid field name %0",
  277. fieldCannotBeChanged: "Field '%0' cannot be changed"});
  278. merge(config.messages.messageClose,{
  279. text: "close",
  280. tooltip: "close this message area"});
  281. config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
  282. config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
  283. config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  284. config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
  285. merge(config.views.wikified.tag,{
  286. labelNoTags: "no tags",
  287. labelTags: "tags: ",
  288. openTag: "Open tag '%0'",
  289. tooltip: "Show tiddlers tagged with '%0'",
  290. openAllText: "Open all",
  291. openAllTooltip: "Open all of these tiddlers",
  292. popupNone: "No other tiddlers tagged with '%0'"});
  293. merge(config.views.wikified,{
  294. defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it",
  295. defaultModifier: "(missing)",
  296. shadowModifier: "(built-in shadow tiddler)",
  297. createdPrompt: "created"});
  298. merge(config.views.editor,{
  299. tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
  300. defaultText: "Type the text for '%0'"});
  301. merge(config.views.editor.tagChooser,{
  302. text: "tags",
  303. tooltip: "Choose existing tags to add to this tiddler",
  304. popupNone: "There are no tags defined",
  305. tagTooltip: "Add the tag '%0'"});
  306. merge(config.macros.search,{
  307. label: "search",
  308. prompt: "Search this TiddlyWiki",
  309. accessKey: "F",
  310. successMsg: "%0 tiddlers found matching %1",
  311. failureMsg: "No tiddlers found matching %0"});
  312. merge(config.macros.tagging,{
  313. label: "tagging: ",
  314. labelNotTag: "not tagging",
  315. tooltip: "List of tiddlers tagged with '%0'"});
  316. merge(config.macros.timeline,{
  317. dateFormat: "DD MMM YYYY"});
  318. merge(config.macros.allTags,{
  319. tooltip: "Show tiddlers tagged with '%0'",
  320. noTags: "There are no tagged tiddlers"});
  321. config.macros.list.all.prompt = "All tiddlers in alphabetical order";
  322. config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined";
  323. config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers";
  324. config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents";
  325. merge(config.macros.closeAll,{
  326. label: "close all",
  327. prompt: "Close all displayed tiddlers (except any that are being edited)"});
  328. merge(config.macros.permaview,{
  329. label: "permaview",
  330. prompt: "Link to an URL that retrieves all the currently displayed tiddlers"});
  331. merge(config.macros.saveChanges,{
  332. label: "save changes",
  333. prompt: "Save all tiddlers to create a new TiddlyWiki",
  334. accessKey: "S"});
  335. merge(config.macros.newTiddler,{
  336. label: "new tiddler",
  337. prompt: "Create a new tiddler",
  338. title: "New Tiddler",
  339. accessKey: "N"});
  340. merge(config.macros.newJournal,{
  341. label: "new journal",
  342. prompt: "Create a new tiddler from the current date and time",
  343. accessKey: "J"});
  344. merge(config.macros.plugins,{
  345. skippedText: "(This plugin has not been executed because it was added since startup)",
  346. noPluginText: "There are no plugins installed",
  347. confirmDeleteText: "Are you sure you want to delete these tiddlers:\n\n%0",
  348. listViewTemplate : {
  349. columns: [
  350. {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
  351. {name: 'Title', field: 'title', tiddlerLink: 'title', title: "Title", type: 'TiddlerLink'},
  352. {name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'},
  353. {name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'},
  354. {name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
  355. {name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
  356. {name: 'Log', field: 'log', title: "Log", type: 'StringList'}
  357. ],
  358. rowClasses: [
  359. {className: 'error', field: 'error'},
  360. {className: 'warning', field: 'warning'}
  361. ],
  362. actions: [
  363. {caption: "More actions...", name: ''},
  364. {caption: "Remove systemConfig tag", name: 'remove'},
  365. {caption: "Delete these tiddlers forever", name: 'delete'}
  366. ]}
  367. });
  368. merge(config.macros.refreshDisplay,{
  369. label: "refresh",
  370. prompt: "Redraw the entire TiddlyWiki display"
  371. });
  372. merge(config.macros.importTiddlers,{
  373. readOnlyWarning: "You cannot import tiddlers into a read-only TiddlyWiki. Try opening the TiddlyWiki file from a file:// URL",
  374. defaultPath: "http://www.tiddlywiki.com/index.html",
  375. fetchLabel: "fetch",
  376. fetchPrompt: "Fetch the tiddlywiki file",
  377. fetchError: "There were problems fetching the tiddlywiki file",
  378. confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0",
  379. wizardTitle: "Import tiddlers from another TiddlyWiki file",
  380. step1: "Step 1: Locate the TiddlyWiki file",
  381. step1prompt: "Enter the URL or pathname here: ",
  382. step1promptFile: "...or browse for a file: ",
  383. step1promptFeeds: "...or select a pre-defined feed: ",
  384. step1feedPrompt: "Choose...",
  385. step2: "Step 2: Loading TiddlyWiki file",
  386. step2Text: "Please wait while the file is loaded from: %0",
  387. step3: "Step 3: Choose the tiddlers to import",
  388. step4: "%0 tiddler(s) imported",
  389. step5: "Done",
  390. listViewTemplate: {
  391. columns: [
  392. {name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
  393. {name: 'Title', field: 'title', title: "Title", type: 'String'},
  394. {name: 'Snippet', field: 'text', title: "Snippet", type: 'String'},
  395. {name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
  396. ],
  397. rowClasses: [
  398. ],
  399. actions: [
  400. {caption: "More actions...", name: ''},
  401. {caption: "Import these tiddlers", name: 'import'}
  402. ]}
  403. });
  404. merge(config.commands.closeTiddler,{
  405. text: "close",
  406. tooltip: "Close this tiddler"});
  407. merge(config.commands.closeOthers,{
  408. text: "close others",
  409. tooltip: "Close all other tiddlers"});
  410. merge(config.commands.editTiddler,{
  411. text: "edit",
  412. tooltip: "Edit this tiddler",
  413. readOnlyText: "view",
  414. readOnlyTooltip: "View the source of this tiddler"});
  415. merge(config.commands.saveTiddler,{
  416. text: "done",
  417. tooltip: "Save changes to this tiddler"});
  418. merge(config.commands.cancelTiddler,{
  419. text: "cancel",
  420. tooltip: "Undo changes to this tiddler",
  421. warning: "Are you sure you want to abandon your changes to '%0'?",
  422. readOnlyText: "done",
  423. readOnlyTooltip: "View this tiddler normally"});
  424. merge(config.commands.deleteTiddler,{
  425. text: "delete",
  426. tooltip: "Delete this tiddler",
  427. warning: "Are you sure you want to delete '%0'?"});
  428. merge(config.commands.permalink,{
  429. text: "permalink",
  430. tooltip: "Permalink for this tiddler"});
  431. merge(config.commands.references,{
  432. text: "references",
  433. tooltip: "Show tiddlers that link to this one",
  434. popupNone: "No references"});
  435. merge(config.commands.jump,{
  436. text: "jump",
  437. tooltip: "Jump to another open tiddler"});
  438. merge(config.shadowTiddlers,{
  439. DefaultTiddlers: "GettingStarted",
  440. MainMenu: "GettingStarted",
  441. SiteTitle: "My TiddlyWiki",
  442. SiteSubtitle: "a reusable non-linear personal web notebook",
  443. SiteUrl: "http://www.tiddlywiki.com/",
  444. GettingStarted: "To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:\n* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)\n* MainMenu: The menu (usually on the left)\n* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened\nYou'll also need to enter your username for signing your edits: <<option txtUserName>>",
  445. SideBarOptions: "<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal 'DD MMM YYYY'>><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel 'options »' 'Change TiddlyWiki advanced options'>>",
  446. OptionsPanel: "These InterfaceOptions for customising TiddlyWiki are saved in your browser\n\nYour username for signing your edits. Write it as a WikiWord (eg JoeBloggs)\n\n<<option txtUserName>>\n<<option chkSaveBackups>> SaveBackups\n<<option chkAutoSave>> AutoSave\n<<option chkRegExpSearch>> RegExpSearch\n<<option chkCaseSensitiveSearch>> CaseSensitiveSearch\n<<option chkAnimate>> EnableAnimations\n\n----\nAdvancedOptions\nPluginManager\nImportTiddlers",
  447. AdvancedOptions: "<<option chkGenerateAnRssFeed>> GenerateAnRssFeed\n<<option chkOpenInNewWindow>> OpenLinksInNewWindow\n<<option chkSaveEmptyTemplate>> SaveEmptyTemplate\n<<option chkToggleLinks>> Clicking on links to tiddlers that are already open causes them to close\n^^(override with Control or other modifier key)^^\n<<option chkHttpReadOnly>> HideEditingFeatures when viewed over HTTP\n<<option chkForceMinorUpdate>> Treat edits as MinorChanges by preserving date and time\n^^(override with Shift key when clicking 'done' or by pressing Ctrl-Shift-Enter^^\n<<option chkConfirmDelete>> ConfirmBeforeDeleting\nMaximum number of lines in a tiddler edit box: <<option txtMaxEditRows>>\nFolder name for backup files: <<option txtBackupFolder>>\n<<option chkInsertTabs>> Use tab key to insert tab characters instead of jumping to next field",
  448. SideBarTabs: "<<tabs txtMainTab Timeline Timeline TabTimeline All 'All tiddlers' TabAll Tags 'All tags' TabTags More 'More lists' TabMore>>",
  449. TabTimeline: "<<timeline>>",
  450. TabAll: "<<list all>>",
  451. TabTags: "<<allTags>>",
  452. TabMore: "<<tabs txtMoreTab Missing 'Missing tiddlers' TabMoreMissing Orphans 'Orphaned tiddlers' TabMoreOrphans Shadowed 'Shadowed tiddlers' TabMoreShadowed>>",
  453. TabMoreMissing: "<<list missing>>",
  454. TabMoreOrphans: "<<list orphans>>",
  455. TabMoreShadowed: "<<list shadowed>>",
  456. PluginManager: "<<plugins>>",
  457. ImportTiddlers: "<<importTiddlers>>"});
  458. // ---------------------------------------------------------------------------------
  459. // Main
  460. // ---------------------------------------------------------------------------------
  461. var params = null; // Command line parameters
  462. var store = null; // TiddlyWiki storage
  463. var story = null; // Main story
  464. var formatter = null; // Default formatters for the wikifier
  465. config.parsers = {}; // Hashmap of alternative parsers for the wikifier
  466. var anim = new Animator(); // Animation engine
  467. var readOnly = false; // Whether we're in readonly mode
  468. var highlightHack = null; // Embarrassing hack department...
  469. var hadConfirmExit = false; // Don't warn more than once
  470. var safeMode = false; // Disable all plugins and cookies
  471. var installedPlugins = []; // Information filled in when plugins are executed
  472. var startingUp = false; // Whether we're in the process of starting up
  473. var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins()
  474. // Whether to use the JavaSaver applet
  475. var useJavaSaver = config.browser.isSafari || config.browser.isOpera;
  476. // Starting up
  477. function main()
  478. {
  479. var now, then = new Date();
  480. startingUp = true;
  481. window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();};
  482. params = getParameters();
  483. if(params)
  484. params = params.parseParams("open",null,false);
  485. store = new TiddlyWiki();
  486. invokeParamifier(params,"oninit");
  487. story = new Story("tiddlerDisplay","tiddler");
  488. addEvent(document,"click",Popup.onDocumentClick);
  489. saveTest();
  490. loadOptionsCookie();
  491. for(var s=0; s<config.notifyTiddlers.length; s++)
  492. store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify);
  493. store.loadFromDiv("storeArea","store",true);
  494. invokeParamifier(params,"onload");
  495. var pluginProblem = loadPlugins();
  496. formatter = new Formatter(config.formatters);
  497. readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;
  498. invokeParamifier(params,"onconfig");
  499. store.notifyAll();
  500. restart();
  501. if(pluginProblem)
  502. {
  503. story.displayTiddler(null,"PluginManager");
  504. displayMessage(config.messages.customConfigError);
  505. }
  506. now = new Date();
  507. if(config.displayStartupTime)
  508. displayMessage("TiddlyWiki startup in " + (now-then)/1000 + " seconds");
  509. startingUp = false;
  510. }
  511. // Restarting
  512. function restart()
  513. {
  514. invokeParamifier(params,"onstart");
  515. if(story.isEmpty())
  516. {
  517. var defaultParams = store.getTiddlerText("DefaultTiddlers").parseParams("open",null,false);
  518. invokeParamifier(defaultParams,"onstart");
  519. }
  520. window.scrollTo(0,0);
  521. }
  522. function saveTest()
  523. {
  524. var saveTest = document.getElementById("saveTest");
  525. if(saveTest.hasChildNodes())
  526. alert(config.messages.savedSnapshotError);
  527. saveTest.appendChild(document.createTextNode("savetest"));
  528. }
  529. function loadPlugins()
  530. {
  531. if(safeMode)
  532. return false;
  533. var configTiddlers = store.getTaggedTiddlers("systemConfig");
  534. installedPlugins = [];
  535. var hadProblem = false;
  536. for(var t=0; t<configTiddlers.length; t++)
  537. {
  538. tiddler = configTiddlers[t];
  539. pluginInfo = getPluginInfo(tiddler);
  540. if(isPluginExecutable(pluginInfo))
  541. {
  542. pluginInfo.executed = true;
  543. pluginInfo.error = false;
  544. try
  545. {
  546. if(tiddler.text && tiddler.text != "")
  547. window.eval(tiddler.text);
  548. }
  549. catch(e)
  550. {
  551. pluginInfo.log.push(config.messages.pluginError.format([exceptionText(e)]));
  552. pluginInfo.error = true;
  553. hadProblem = true;
  554. }
  555. }
  556. else
  557. pluginInfo.warning = true;
  558. installedPlugins.push(pluginInfo);
  559. }
  560. return hadProblem;
  561. }
  562. function getPluginInfo(tiddler)
  563. {
  564. var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","CoreVersion","Date","Source","Author","License","Browsers"]);
  565. p.tiddler = tiddler;
  566. p.title = tiddler.title;
  567. p.log = [];
  568. return p;
  569. }
  570. // Check that a particular plugin is valid for execution
  571. function isPluginExecutable(plugin)
  572. {
  573. if(plugin.tiddler.isTagged("systemConfigDisable"))
  574. return verifyTail(plugin,false,config.messages.pluginDisabled);
  575. if(plugin.tiddler.isTagged("systemConfigForce"))
  576. return verifyTail(plugin,true,config.messages.pluginForced);
  577. if(plugin["CoreVersion"])
  578. {
  579. var coreVersion = plugin["CoreVersion"].split(".");
  580. var w = parseInt(coreVersion[0]) - version.major;
  581. if(w == 0 && coreVersion[1])
  582. w = parseInt(coreVersion[1]) - version.minor;
  583. if(w == 0 && coreVersion[2])
  584. w = parseInt(coreVersion[2]) - version.revision;
  585. if(w > 0)
  586. return verifyTail(plugin,false,config.messages.pluginVersionError);
  587. }
  588. return true;
  589. }
  590. function verifyTail(plugin,result,message)
  591. {
  592. plugin.log.push(message);
  593. return result;
  594. }
  595. function invokeMacro(place,macro,params,wikifier,tiddler)
  596. {
  597. try
  598. {
  599. var m = config.macros[macro];
  600. if(m && m.handler)
  601. m.handler(place,macro,params.readMacroParams(),wikifier,params,tiddler);
  602. else
  603. createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro]));
  604. }
  605. catch(ex)
  606. {
  607. createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()]));
  608. }
  609. }
  610. // ---------------------------------------------------------------------------------
  611. // Paramifiers
  612. // ---------------------------------------------------------------------------------
  613. function getParameters()
  614. {
  615. var p = null;
  616. if(window.location.hash)
  617. {
  618. p = decodeURI(window.location.hash.substr(1));
  619. if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111")
  620. p = convertUTF8ToUnicode(p);
  621. }
  622. return p;
  623. }
  624. function invokeParamifier(params,handler)
  625. {
  626. if(!params || params.length == undefined || params.length <= 1)
  627. return;
  628. for(var t=1; t<params.length; t++)
  629. {
  630. var p = config.paramifiers[params[t].name];
  631. if(p && p[handler] instanceof Function)
  632. p[handler](params[t].value);
  633. }
  634. }
  635. config.paramifiers = {};
  636. config.paramifiers.start = {
  637. oninit: function(v) {
  638. safeMode = v.toLowerCase() == "safe";
  639. }
  640. };
  641. config.paramifiers.open = {
  642. onstart: function(v) {
  643. story.displayTiddler("bottom",v,null,false,false);
  644. }
  645. };
  646. config.paramifiers.story = {
  647. onstart: function(v) {
  648. var list = store.getTiddlerText(v,"").parseParams("open",null,false);
  649. invokeParamifier(list,"onstart");
  650. }
  651. };
  652. config.paramifiers.search = {
  653. onstart: function(v) {
  654. story.search(v,false,false);
  655. }
  656. };
  657. config.paramifiers.searchRegExp = {
  658. onstart: function(v) {
  659. story.prototype.search(v,false,true);
  660. }
  661. };
  662. config.paramifiers.tag = {
  663. onstart: function(v) {
  664. var tagged = store.getTaggedTiddlers(v,"title");
  665. for(var t=0; t<tagged.length; t++)
  666. story.displayTiddler("bottom",tagged[t].title,null,false,false);
  667. }
  668. };
  669. config.paramifiers.newTiddler = {
  670. onstart: function(v) {
  671. if(!readOnly)
  672. {
  673. story.displayTiddler(null,v,DEFAULT_EDIT_TEMPLATE);
  674. story.focusTiddler(v,"text");
  675. }
  676. }
  677. };
  678. config.paramifiers.newJournal = {
  679. onstart: function(v) {
  680. if(!readOnly)
  681. {
  682. var now = new Date();
  683. var title = now.formatString(v.trim());
  684. story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
  685. story.focusTiddler(title,"text");
  686. }
  687. }
  688. };
  689. // ---------------------------------------------------------------------------------
  690. // Formatter helpers
  691. // ---------------------------------------------------------------------------------
  692. function Formatter(formatters)
  693. {
  694. this.formatters = [];
  695. var pattern = [];
  696. for(var n=0; n<formatters.length; n++)
  697. {
  698. pattern.push("(" + formatters[n].match + ")");
  699. this.formatters.push(formatters[n]);
  700. }
  701. this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
  702. }
  703. config.formatterHelpers = {
  704. createElementAndWikify: function(w)
  705. {
  706. w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
  707. },
  708. inlineCssHelper: function(w)
  709. {
  710. var styles = [];
  711. config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
  712. var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
  713. while(lookaheadMatch && lookaheadMatch.index == w.nextMatch)
  714. {
  715. var s,v;
  716. if(lookaheadMatch[1])
  717. {
  718. s = lookaheadMatch[1].unDash();
  719. v = lookaheadMatch[2];
  720. }
  721. else
  722. {
  723. s = lookaheadMatch[3].unDash();
  724. v = lookaheadMatch[4];
  725. }
  726. if (s=="bgcolor")
  727. s = "backgroundColor";
  728. styles.push({style: s, value: v});
  729. w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
  730. config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
  731. lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
  732. }
  733. return styles;
  734. },
  735. applyCssHelper: function(e,styles)
  736. {
  737. for(var t=0; t< styles.length; t++)
  738. {
  739. try
  740. {
  741. e.style[styles[t].style] = styles[t].value;
  742. }
  743. catch (ex)
  744. {
  745. }
  746. }
  747. },
  748. enclosedTextHelper: function(w)
  749. {
  750. this.lookaheadRegExp.lastIndex = w.matchStart;
  751. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  752. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  753. {
  754. var text = lookaheadMatch[1];
  755. if(config.browser.isIE)
  756. text = text.replace(/\n/g,"\r");
  757. createTiddlyElement(w.output,this.element,null,null,text);
  758. w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
  759. }
  760. },
  761. isExternalLink: function(link)
  762. {
  763. if(store.tiddlerExists(link) || store.isShadowTiddler(link))
  764. {
  765. //# Definitely not an external link
  766. return false;
  767. }
  768. var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
  769. if(urlRegExp.exec(link))
  770. {
  771. // Definitely an external link
  772. return true;
  773. }
  774. if (link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1)
  775. {
  776. //# Link contains . / or \ so is probably an external link
  777. return true;
  778. }
  779. //# Otherwise assume it is not an external link
  780. return false;
  781. }
  782. };
  783. // ---------------------------------------------------------------------------------
  784. // Standard formatters
  785. // ---------------------------------------------------------------------------------
  786. config.formatters = [
  787. {
  788. name: "table",
  789. match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
  790. lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
  791. rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
  792. cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
  793. cellTermRegExp: /((?:\x20*)\|)/mg,
  794. rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
  795. handler: function(w)
  796. {
  797. var table = createTiddlyElement(w.output,"table");
  798. var prevColumns = [];
  799. var currRowType = null;
  800. var rowContainer;
  801. var rowCount = 0;
  802. w.nextMatch = w.matchStart;
  803. this.lookaheadRegExp.lastIndex = w.nextMatch;
  804. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  805. while(lookaheadMatch && lookaheadMatch.index == w.nextMatch)
  806. {
  807. var nextRowType = lookaheadMatch[2];
  808. if(nextRowType == "k")
  809. {
  810. table.className = lookaheadMatch[1];
  811. w.nextMatch += lookaheadMatch[0].length+1;
  812. }
  813. else
  814. {
  815. if(nextRowType != currRowType)
  816. {
  817. rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]);
  818. currRowType = nextRowType;
  819. }
  820. if(currRowType == "c")
  821. {
  822. // Caption
  823. w.nextMatch++;
  824. if(rowContainer != table.firstChild)
  825. table.insertBefore(rowContainer,table.firstChild);
  826. rowContainer.setAttribute("align",rowCount == 0?"top":"bottom");
  827. w.subWikifyTerm(rowContainer,this.rowTermRegExp);
  828. }
  829. else
  830. {
  831. this.rowHandler(w,createTiddlyElement(rowContainer,"tr",null,(rowCount&1)?"oddRow":"evenRow"),prevColumns);
  832. rowCount++;
  833. }
  834. }
  835. this.lookaheadRegExp.lastIndex = w.nextMatch;
  836. lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  837. }
  838. },
  839. rowHandler: function(w,e,prevColumns)
  840. {
  841. var col = 0;
  842. var colSpanCount = 1;
  843. var prevCell = null;
  844. this.cellRegExp.lastIndex = w.nextMatch;
  845. var cellMatch = this.cellRegExp.exec(w.source);
  846. while(cellMatch && cellMatch.index == w.nextMatch)
  847. {
  848. if(cellMatch[1] == "~")
  849. {
  850. // Rowspan
  851. var last = prevColumns[col];
  852. if(last)
  853. {
  854. last.rowSpanCount++;
  855. last.element.setAttribute("rowspan",last.rowSpanCount);
  856. last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE
  857. last.element.valign = "center";
  858. }
  859. w.nextMatch = this.cellRegExp.lastIndex-1;
  860. }
  861. else if(cellMatch[1] == ">")
  862. {
  863. // Colspan
  864. colSpanCount++;
  865. w.nextMatch = this.cellRegExp.lastIndex-1;
  866. }
  867. else if(cellMatch[2])
  868. {
  869. // End of row
  870. if(prevCell && colSpanCount > 1)
  871. {
  872. prevCell.setAttribute("colspan",colSpanCount);
  873. prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE
  874. }
  875. w.nextMatch = this.cellRegExp.lastIndex;
  876. break;
  877. }
  878. else
  879. {
  880. // Cell
  881. w.nextMatch++;
  882. var styles = config.formatterHelpers.inlineCssHelper(w);
  883. var spaceLeft = false;
  884. var chr = w.source.substr(w.nextMatch,1);
  885. while(chr == " ")
  886. {
  887. spaceLeft = true;
  888. w.nextMatch++;
  889. chr = w.source.substr(w.nextMatch,1);
  890. }
  891. var cell;
  892. if(chr == "!")
  893. {
  894. cell = createTiddlyElement(e,"th");
  895. w.nextMatch++;
  896. }
  897. else
  898. cell = createTiddlyElement(e,"td");
  899. prevCell = cell;
  900. prevColumns[col] = {rowSpanCount:1, element:cell};
  901. if(colSpanCount > 1)
  902. {
  903. cell.setAttribute("colspan",colSpanCount);
  904. cell.setAttribute("colSpan",colSpanCount); // Needed for IE
  905. colSpanCount = 1;
  906. }
  907. config.formatterHelpers.applyCssHelper(cell,styles);
  908. w.subWikifyTerm(cell,this.cellTermRegExp);
  909. if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
  910. cell.align = spaceLeft ? "center" : "left";
  911. else if(spaceLeft)
  912. cell.align = "right";
  913. w.nextMatch--;
  914. }
  915. col++;
  916. this.cellRegExp.lastIndex = w.nextMatch;
  917. cellMatch = this.cellRegExp.exec(w.source);
  918. }
  919. }
  920. },
  921. {
  922. name: "heading",
  923. match: "^!{1,5}",
  924. termRegExp: /(\n)/mg,
  925. handler: function(w)
  926. {
  927. w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp);
  928. }
  929. },
  930. {
  931. name: "list",
  932. match: "^(?:(?:(?:\\*)|(?:#)|(?:;)|(?::))+)",
  933. lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
  934. termRegExp: /(\n)/mg,
  935. handler: function(w)
  936. {
  937. var placeStack = [w.output];
  938. var currLevel = 0, currType = null;
  939. var listLevel, listType, itemType;
  940. w.nextMatch = w.matchStart;
  941. this.lookaheadRegExp.lastIndex = w.nextMatch;
  942. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  943. while(lookaheadMatch && lookaheadMatch.index == w.nextMatch)
  944. {
  945. if(lookaheadMatch[1])
  946. {
  947. listType = "ul";
  948. itemType = "li";
  949. }
  950. else if(lookaheadMatch[2])
  951. {
  952. listType = "ol";
  953. itemType = "li";
  954. }
  955. else if(lookaheadMatch[3])
  956. {
  957. listType = "dl";
  958. itemType = "dt";
  959. }
  960. else if(lookaheadMatch[4])
  961. {
  962. listType = "dl";
  963. itemType = "dd";
  964. }
  965. listLevel = lookaheadMatch[0].length;
  966. w.nextMatch += lookaheadMatch[0].length;
  967. if(listLevel > currLevel)
  968. {
  969. for(var t=currLevel; t<listLevel; t++)
  970. placeStack.push(createTiddlyElement(placeStack[placeStack.length-1],listType));
  971. }
  972. else if(listLevel < currLevel)
  973. {
  974. for(var t=currLevel; t>listLevel; t--)
  975. placeStack.pop();
  976. }
  977. else if(listLevel == currLevel && listType != currType)
  978. {
  979. placeStack.pop();
  980. placeStack.push(createTiddlyElement(placeStack[placeStack.length-1],listType));
  981. }
  982. currLevel = listLevel;
  983. currType = listType;
  984. var e = createTiddlyElement(placeStack[placeStack.length-1],itemType);
  985. w.subWikifyTerm(e,this.termRegExp);
  986. this.lookaheadRegExp.lastIndex = w.nextMatch;
  987. lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  988. }
  989. }
  990. },
  991. {
  992. name: "quoteByBlock",
  993. match: "^<<<\\n",
  994. termRegExp: /(^<<<(\n|$))/mg,
  995. element: "blockquote",
  996. handler: config.formatterHelpers.createElementAndWikify
  997. },
  998. {
  999. name: "quoteByLine",
  1000. match: "^>+",
  1001. lookaheadRegExp: /^>+/mg,
  1002. termRegExp: /(\n)/mg,
  1003. element: "blockquote",
  1004. handler: function(w)
  1005. {
  1006. var placeStack = [w.output];
  1007. var currLevel = 0;
  1008. var newLevel = w.matchLength;
  1009. var t;
  1010. do {
  1011. if(newLevel > currLevel)
  1012. {
  1013. for(t=currLevel; t<newLevel; t++)
  1014. placeStack.push(createTiddlyElement(placeStack[placeStack.length-1],this.element));
  1015. }
  1016. else if(newLevel < currLevel)
  1017. {
  1018. for(t=currLevel; t>newLevel; t--)
  1019. placeStack.pop();
  1020. }
  1021. currLevel = newLevel;
  1022. w.subWikifyTerm(placeStack[placeStack.length-1],this.termRegExp);
  1023. createTiddlyElement(placeStack[placeStack.length-1],"br");
  1024. this.lookaheadRegExp.lastIndex = w.nextMatch;
  1025. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  1026. var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
  1027. if(matched)
  1028. {
  1029. newLevel = lookaheadMatch[0].length;
  1030. w.nextMatch += lookaheadMatch[0].length;
  1031. }
  1032. } while(matched);
  1033. }
  1034. },
  1035. {
  1036. name: "rule",
  1037. match: "^----+$\\n?",
  1038. handler: function(w)
  1039. {
  1040. createTiddlyElement(w.output,"hr");
  1041. }
  1042. },
  1043. {
  1044. name: "monospacedByLine",
  1045. match: "^\\{\\{\\{\\n",
  1046. lookaheadRegExp: /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/mg,
  1047. element: "pre",
  1048. handler: config.formatterHelpers.enclosedTextHelper
  1049. },
  1050. {
  1051. name: "monospacedByLineForCSS",
  1052. match: "^/\\*[\\{]{3}\\*/\\n",
  1053. lookaheadRegExp: /\/\*[\{]{3}\*\/\n*((?:^[^\n]*\n)+?)(\n*^\/\*[\}]{3}\*\/$\n?)/mg,
  1054. element: "pre",
  1055. handler: config.formatterHelpers.enclosedTextHelper
  1056. },
  1057. {
  1058. name: "monospacedByLineForPlugin",
  1059. match: "^//\\{\\{\\{\\n",
  1060. lookaheadRegExp: /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\/\/\}\}\}$\n?)/mg,
  1061. element: "pre",
  1062. handler: config.formatterHelpers.enclosedTextHelper
  1063. },
  1064. {
  1065. name: "monospacedByLineForTemplate",
  1066. match: "^<!--[\\{]{3}-->\\n",
  1067. lookaheadRegExp: /<!--[\{]{3}-->\n*((?:^[^\n]*\n)+?)(\n*^<!--[\}]{3}-->$\n?)/mg,
  1068. element: "pre",
  1069. handler: config.formatterHelpers.enclosedTextHelper
  1070. },
  1071. {
  1072. name: "wikifyCommentForPlugin",
  1073. match: "^/\\*\\*\\*\\n",
  1074. termRegExp: /(^\*\*\*\/\n)/mg,
  1075. handler: function(w)
  1076. {
  1077. w.subWikifyTerm(w.output,this.termRegExp);
  1078. }
  1079. },
  1080. {
  1081. name: "wikifyCommentForTemplate",
  1082. match: "^<!---\\n",
  1083. termRegExp: /(^--->\n)/mg,
  1084. handler: function(w)
  1085. {
  1086. w.subWikifyTerm(w.output,this.termRegExp);
  1087. }
  1088. },
  1089. {
  1090. name: "macro",
  1091. match: "<<",
  1092. lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
  1093. handler: function(w)
  1094. {
  1095. this.lookaheadRegExp.lastIndex = w.matchStart;
  1096. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  1097. if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1])
  1098. {
  1099. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1100. invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
  1101. }
  1102. }
  1103. },
  1104. {
  1105. name: "prettyLink",
  1106. match: "\\[\\[",
  1107. lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg,
  1108. handler: function(w)
  1109. {
  1110. this.lookaheadRegExp.lastIndex = w.matchStart;
  1111. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  1112. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  1113. {
  1114. var e;
  1115. var text = lookaheadMatch[1];
  1116. if(lookaheadMatch[3])
  1117. {
  1118. // Pretty bracketted link
  1119. var link = lookaheadMatch[3];
  1120. e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link))
  1121. ? createExternalLink(w.output,link)
  1122. : createTiddlyLink(w.output,link,false,null,w.isStatic);
  1123. }
  1124. else
  1125. {
  1126. // Simple bracketted link
  1127. e = createTiddlyLink(w.output,text,false,null,w.isStatic);
  1128. }
  1129. createTiddlyText(e,text);
  1130. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1131. }
  1132. }
  1133. },
  1134. {
  1135. name: "unWikiLink",
  1136. match: config.textPrimitives.unWikiLink+config.textPrimitives.wikiLink,
  1137. handler: function(w)
  1138. {
  1139. w.outputText(w.output,w.matchStart+1,w.nextMatch);
  1140. }
  1141. },
  1142. {
  1143. name: "wikiLink",
  1144. match: config.textPrimitives.wikiLink,
  1145. handler: function(w)
  1146. {
  1147. if(w.matchStart > 0)
  1148. {
  1149. var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg");
  1150. preRegExp.lastIndex = w.matchStart-1;
  1151. var preMatch = preRegExp.exec(w.source);
  1152. if(preMatch.index == w.matchStart-1)
  1153. {
  1154. w.outputText(w.output,w.matchStart,w.nextMatch);
  1155. return;
  1156. }
  1157. }
  1158. if(w.autoLinkWikiWords == true || store.isShadowTiddler(w.matchText))
  1159. {
  1160. var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic);
  1161. w.outputText(link,w.matchStart,w.nextMatch);
  1162. }
  1163. else
  1164. {
  1165. w.outputText(w.output,w.matchStart,w.nextMatch);
  1166. }
  1167. }
  1168. },
  1169. {
  1170. name: "urlLink",
  1171. match: config.textPrimitives.urlPattern,
  1172. handler: function(w)
  1173. {
  1174. w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
  1175. }
  1176. },
  1177. {
  1178. name: "image",
  1179. match: "\\[[<>]?[Ii][Mm][Gg]\\[",
  1180. lookaheadRegExp: /\[(<?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
  1181. handler: function(w)
  1182. {
  1183. this.lookaheadRegExp.lastIndex = w.matchStart;
  1184. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  1185. if(lookaheadMatch && lookaheadMatch.index == w.matchStart) // Simple bracketted link
  1186. {
  1187. var e = w.output;
  1188. if(lookaheadMatch[5])
  1189. {
  1190. var link = lookaheadMatch[5];
  1191. e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic);
  1192. addClass(e,"imageLink");
  1193. }
  1194. var img = createTiddlyElement(e,"img");
  1195. if(lookaheadMatch[1])
  1196. img.align = "left";
  1197. else if(lookaheadMatch[2])
  1198. img.align = "right";
  1199. if(lookaheadMatch[3])
  1200. img.title = lookaheadMatch[3];
  1201. img.src = lookaheadMatch[4];
  1202. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1203. }
  1204. }
  1205. },
  1206. {
  1207. name: "html",
  1208. match: "<[Hh][Tt][Mm][Ll]>",
  1209. lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg,
  1210. handler: function(w)
  1211. {
  1212. this.lookaheadRegExp.lastIndex = w.matchStart;
  1213. var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
  1214. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  1215. {
  1216. createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1];
  1217. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1218. }
  1219. }
  1220. },
  1221. {
  1222. name: "commentByBlock",
  1223. match: "/%",
  1224. lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg,
  1225. handler: function(w)
  1226. {
  1227. this.lookaheadRegExp.lastIndex = w.matchStart;
  1228. var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
  1229. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  1230. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1231. }
  1232. },
  1233. {
  1234. name: "boldByChar",
  1235. match: "''",
  1236. termRegExp: /('')/mg,
  1237. element: "strong",
  1238. handler: config.formatterHelpers.createElementAndWikify
  1239. },
  1240. {
  1241. name: "italicByChar",
  1242. match: "//",
  1243. termRegExp: /(\/\/)/mg,
  1244. element: "em",
  1245. handler: config.formatterHelpers.createElementAndWikify
  1246. },
  1247. {
  1248. name: "underlineByChar",
  1249. match: "__",
  1250. termRegExp: /(__)/mg,
  1251. element: "u",
  1252. handler: config.formatterHelpers.createElementAndWikify
  1253. },
  1254. {
  1255. name: "strikeByChar",
  1256. match: "--(?!\\s|$)",
  1257. termRegExp: /((?!\s)--|(?=\n\n))/mg,
  1258. element: "strike",
  1259. handler: config.formatterHelpers.createElementAndWikify
  1260. },
  1261. {
  1262. name: "superscriptByChar",
  1263. match: "\\^\\^",
  1264. termRegExp: /(\^\^)/mg,
  1265. element: "sup",
  1266. handler: config.formatterHelpers.createElementAndWikify
  1267. },
  1268. {
  1269. name: "subscriptByChar",
  1270. match: "~~",
  1271. termRegExp: /(~~)/mg,
  1272. element: "sub",
  1273. handler: config.formatterHelpers.createElementAndWikify
  1274. },
  1275. {
  1276. name: "monospacedByChar",
  1277. match: "\\{\\{\\{",
  1278. lookaheadRegExp: /\{\{\{((?:.|\n)*?)\}\}\}/mg,
  1279. handler: function(w)
  1280. {
  1281. this.lookaheadRegExp.lastIndex = w.matchStart;
  1282. var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
  1283. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  1284. {
  1285. createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]);
  1286. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1287. }
  1288. }
  1289. },
  1290. {
  1291. name: "styleByChar",
  1292. match: "@@",
  1293. termRegExp: /(@@)/mg,
  1294. handler: function(w)
  1295. {
  1296. var e = createTiddlyElement(w.output,"span");
  1297. var styles = config.formatterHelpers.inlineCssHelper(w);
  1298. if(styles.length == 0)
  1299. e.className = "marked";
  1300. else
  1301. config.formatterHelpers.applyCssHelper(e,styles);
  1302. w.subWikifyTerm(e,this.termRegExp);
  1303. }
  1304. },
  1305. {
  1306. name: "lineBreak",
  1307. match: "\\n|<br ?/?>",
  1308. handler: function(w)
  1309. {
  1310. createTiddlyElement(w.output,"br");
  1311. }
  1312. },
  1313. {
  1314. name: "rawText",
  1315. match: "\\\"{3}|<nowiki>",
  1316. lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg,
  1317. handler: function(w)
  1318. {
  1319. this.lookaheadRegExp.lastIndex = w.matchStart;
  1320. var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
  1321. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  1322. {
  1323. createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]);
  1324. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1325. }
  1326. }
  1327. },
  1328. {
  1329. name: "mdash",
  1330. match: "--",
  1331. handler: function(w)
  1332. {
  1333. createTiddlyElement(w.output,"span").innerHTML = "&mdash;";
  1334. }
  1335. },
  1336. {
  1337. name: "htmlEntitiesEncoding",
  1338. match: "(?:(?:&#?[a-zA-Z0-9]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9a-fA-F]|1D[c-fC-F][0-9a-fA-F]|20[d-fD-F][0-9a-fA-F]|FE2[0-9a-fA-F])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[a-zA-Z0-9]{2,8};)",
  1339. handler: function(w)
  1340. {
  1341. createTiddlyElement(w.output,"span").innerHTML = w.matchText;
  1342. }
  1343. },
  1344. {
  1345. name: "customClasses",
  1346. match: "\\{\\{",
  1347. termRegExp: /(\}\}\})/mg,
  1348. lookaheadRegExp: /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg,
  1349. handler: function(w)
  1350. {
  1351. this.lookaheadRegExp.lastIndex = w.matchStart;
  1352. var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
  1353. if(lookaheadMatch)
  1354. {
  1355. var e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]);
  1356. w.nextMatch = this.lookaheadRegExp.lastIndex;
  1357. w.subWikifyTerm(e,this.termRegExp);
  1358. }
  1359. }
  1360. }
  1361. ];
  1362. // ---------------------------------------------------------------------------------
  1363. // Wikifier
  1364. // ---------------------------------------------------------------------------------
  1365. function getParser(tiddler)
  1366. {
  1367. var f = formatter;
  1368. if(tiddler!=null)
  1369. {
  1370. for(var i in config.parsers)
  1371. {
  1372. if(tiddler.isTagged(config.parsers[i].formatTag))
  1373. {
  1374. f = config.parsers[i];
  1375. break;
  1376. }
  1377. }
  1378. }
  1379. return f;
  1380. }
  1381. function wikify(source,output,highlightRegExp,tiddler)
  1382. {
  1383. if(source && source != "")
  1384. {
  1385. var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
  1386. wikifier.subWikifyUnterm(output);
  1387. }
  1388. }
  1389. function wikifyStatic(source,highlightRegExp,tiddler)
  1390. {
  1391. var e = createTiddlyElement(document.body,"div");
  1392. e.style.display = "none";
  1393. var html = "";
  1394. if(source && source != "")
  1395. {
  1396. var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
  1397. wikifier.isStatic = true;
  1398. wikifier.subWikifyUnterm(e);
  1399. html = e.innerHTML;
  1400. e.parentNode.removeChild(e);
  1401. }
  1402. return html;
  1403. }
  1404. // Wikify a named tiddler to plain text
  1405. function wikifyPlain(title)
  1406. {
  1407. if(store.tiddlerExists(title) || store.isShadowTiddler(title))
  1408. {
  1409. var wikifier = new Wikifier(store.getTiddlerText(title),formatter,null,store.getTiddler(title));
  1410. return wikifier.wikifyPlain();
  1411. }
  1412. else
  1413. return "";
  1414. }
  1415. // Highlight plain text into an element
  1416. function highlightify(source,output,highlightRegExp)
  1417. {
  1418. if(source && source != "")
  1419. {
  1420. var wikifier = new Wikifier(source,formatter,highlightRegExp);
  1421. wikifier.outputText(output,0,source.length);
  1422. }
  1423. }
  1424. // Construct a wikifier object
  1425. // source - source string that's going to be wikified
  1426. // formatter - Formatter() object containing the list of formatters to be used
  1427. // highlightRegExp - regular expression of the text string to highlight
  1428. // tiddler - reference to the tiddler that's taken to be the container for this wikification
  1429. function Wikifier(source,formatter,highlightRegExp,tiddler)
  1430. {
  1431. this.source = source;
  1432. this.output = null;
  1433. this.formatter = formatter;
  1434. this.nextMatch = 0;
  1435. this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true;
  1436. this.highlightRegExp = highlightRegExp;
  1437. this.highlightMatch = null;
  1438. this.isStatic = false;
  1439. if(highlightRegExp)
  1440. {
  1441. highlightRegExp.lastIndex = 0;
  1442. this.highlightMatch = highlightRegExp.exec(source);
  1443. }
  1444. this.tiddler = tiddler;
  1445. }
  1446. Wikifier.prototype.wikifyPlain = function()
  1447. {
  1448. var e = createTiddlyElement(document.body,"div");
  1449. e.style.display = "none";
  1450. this.subWikify(e);
  1451. var text = getPlainText(e);
  1452. e.parentNode.removeChild(e);
  1453. return text;
  1454. }
  1455. Wikifier.prototype.subWikify = function(output,terminator)
  1456. {
  1457. // Handle the terminated and unterminated cases separately
  1458. if (terminator)
  1459. this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
  1460. else
  1461. this.subWikifyUnterm(output);
  1462. }
  1463. Wikifier.prototype.subWikifyUnterm = function(output)
  1464. {
  1465. // subWikify() can be indirectly recursive, so we need to save the old output pointer
  1466. var oldOutput = this.output;
  1467. this.output = output;
  1468. // Get the first match
  1469. this.formatter.formatterRegExp.lastIndex = this.nextMatch;
  1470. var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
  1471. while(formatterMatch)
  1472. {
  1473. // Output any text before the match
  1474. if(formatterMatch.index > this.nextMatch)
  1475. this.outputText(this.output,this.nextMatch,formatterMatch.index);
  1476. // Set the match parameters for the handler
  1477. this.matchStart = formatterMatch.index;
  1478. this.matchLength = formatterMatch[0].length;
  1479. this.matchText = formatterMatch[0];
  1480. this.nextMatch = this.formatter.formatterRegExp.lastIndex;
  1481. // Figure out which formatter matched and call its handler
  1482. for(var t=1; t<formatterMatch.length; t++)
  1483. {
  1484. if(formatterMatch[t])
  1485. {
  1486. this.formatter.formatters[t-1].handler(this);
  1487. this.formatter.formatterRegExp.lastIndex = this.nextMatch;
  1488. break;
  1489. }
  1490. }
  1491. // Get the next match
  1492. formatterMatch = this.formatter.formatterRegExp.exec(this.source);
  1493. }
  1494. // Output any text after the last match
  1495. if(this.nextMatch < this.source.length)
  1496. {
  1497. this.outputText(this.output,this.nextMatch,this.source.length);
  1498. this.nextMatch = this.source.length;
  1499. }
  1500. // Restore the output pointer
  1501. this.output = oldOutput;
  1502. }
  1503. Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
  1504. {
  1505. // subWikify() can be indirectly recursive, so we need to save the old output pointer
  1506. var oldOutput = this.output;
  1507. this.output = output;
  1508. // Get the first matches for the formatter and terminator RegExps
  1509. terminatorRegExp.lastIndex = this.nextMatch;
  1510. var terminatorMatch = terminatorRegExp.exec(this.source);
  1511. this.formatter.formatterRegExp.lastIndex = this.nextMatch;
  1512. var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
  1513. while(terminatorMatch || formatterMatch)
  1514. {
  1515. // Check for a terminator match before the next formatter match
  1516. if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index))
  1517. {
  1518. // Output any text before the match
  1519. if(terminatorMatch.index > this.nextMatch)
  1520. this.outputText(this.output,this.nextMatch,terminatorMatch.index);
  1521. // Set the match parameters
  1522. this.matchText = terminatorMatch[1];
  1523. this.matchLength = terminatorMatch[1].length;
  1524. this.matchStart = terminatorMatch.index;
  1525. this.nextMatch = this.matchStart + this.matchLength;
  1526. // Restore the output pointer
  1527. this.output = oldOutput;
  1528. return;
  1529. }
  1530. // It must be a formatter match; output any text before the match
  1531. if(formatterMatch.index > this.nextMatch)
  1532. this.outputText(this.output,this.nextMatch,formatterMatch.index);
  1533. // Set the match parameters
  1534. this.matchStart = formatterMatch.index;
  1535. this.matchLength = formatterMatch[0].length;
  1536. this.matchText = formatterMatch[0];
  1537. this.nextMatch = this.formatter.formatterRegExp.lastIndex;
  1538. // Figure out which formatter matched and call its handler
  1539. for(var t=1; t<formatterMatch.length; t++)
  1540. {
  1541. if(formatterMatch[t])
  1542. {
  1543. this.formatter.formatters[t-1].handler(this);
  1544. this.formatter.formatterRegExp.lastIndex = this.nextMatch;
  1545. break;
  1546. }
  1547. }
  1548. // Get the next match
  1549. terminatorRegExp.lastIndex = this.nextMatch;
  1550. terminatorMatch = terminatorRegExp.exec(this.source);
  1551. formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
  1552. }
  1553. // Output any text after the last match
  1554. if(this.nextMatch < this.source.length)
  1555. {
  1556. this.outputText(this.output,this.nextMatch,this.source.length);
  1557. this.nextMatch = this.source.length;
  1558. }
  1559. // Restore the output pointer
  1560. this.output = oldOutput;
  1561. }
  1562. Wikifier.prototype.outputText = function(place,startPos,endPos)
  1563. {
  1564. // Check for highlights
  1565. while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos))
  1566. {
  1567. // Deal with any plain text before the highlight
  1568. if(this.highlightMatch.index > startPos)
  1569. {
  1570. createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
  1571. startPos = this.highlightMatch.index;
  1572. }
  1573. // Deal with the highlight
  1574. var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
  1575. var theHighlight = createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
  1576. startPos = highlightEnd;
  1577. // Nudge along to the next highlight if we're done with this one
  1578. if(startPos >= this.highlightRegExp.lastIndex)
  1579. this.highlightMatch = this.highlightRegExp.exec(this.source);
  1580. }
  1581. // Do the unhighlighted text left over
  1582. if(startPos < endPos)
  1583. {
  1584. createTiddlyText(place,this.source.substring(startPos,endPos));
  1585. }
  1586. }
  1587. // ---------------------------------------------------------------------------------
  1588. // Macro definitions
  1589. // ---------------------------------------------------------------------------------
  1590. config.macros.today.handler = function(place,macroName,params)
  1591. {
  1592. var now = new Date();
  1593. var text;
  1594. if(params[0])
  1595. text = now.formatString(params[0].trim());
  1596. else
  1597. text = now.toLocaleString();
  1598. createTiddlyElement(place,"span",null,null,text);
  1599. }
  1600. config.macros.version.handler = function(place)
  1601. {
  1602. createTiddlyElement(place,"span",null,null,version.major + "." + version.minor + "." + version.revision + (version.beta ? " (beta " + version.beta + ")" : ""));
  1603. }
  1604. config.macros.list.handler = function(place,macroName,params)
  1605. {
  1606. var type = params[0] ? params[0] : "all";
  1607. var theList = document.createElement("ul");
  1608. place.appendChild(theList);
  1609. if(this[type].prompt)
  1610. createTiddlyElement(theList,"li",null,"listTitle",this[type].prompt);
  1611. var results;
  1612. if(this[type].handler)
  1613. results = this[type].handler(params);
  1614. for(var t = 0; t < results.length; t++)
  1615. {
  1616. var theListItem = document.createElement("li")
  1617. theList.appendChild(theListItem);
  1618. if(typeof results[t] == "string")
  1619. createTiddlyLink(theListItem,results[t],true);
  1620. else
  1621. createTiddlyLink(theListItem,results[t].title,true);
  1622. }
  1623. }
  1624. config.macros.list.all.handler = function(params)
  1625. {
  1626. return store.reverseLookup("tags","excludeLists",false,"title");
  1627. }
  1628. config.macros.list.missing.handler = function(params)
  1629. {
  1630. return store.getMissingLinks();
  1631. }
  1632. config.macros.list.orphans.handler = function(params)
  1633. {
  1634. return store.getOrphans();
  1635. }
  1636. config.macros.list.shadowed.handler = function(params)
  1637. {
  1638. return store.getShadowed();
  1639. }
  1640. config.macros.allTags.handler = function(place,macroName,params)
  1641. {
  1642. var tags = store.getTags();
  1643. var theDateList = createTiddlyElement(place,"ul");
  1644. if(tags.length == 0)
  1645. createTiddlyElement(theDateList,"li",null,"listTitle",this.noTags);
  1646. for(var t=0; t<tags.length; t++)
  1647. {
  1648. var theListItem =createTiddlyElement(theDateList,"li");
  1649. var theTag = createTiddlyButton(theListItem,tags[t][0] + " (" + tags[t][1] + ")",this.tooltip.format([tags[t][0]]),onClickTag);
  1650. theTag.setAttribute("tag",tags[t][0]);
  1651. }
  1652. }
  1653. config.macros.timeline.handler = function(place,macroName,params)
  1654. {
  1655. var field = params[0] ? params[0] : "modified";
  1656. var tiddlers = store.reverseLookup("tags","excludeLists",false,field);
  1657. var lastDay = "";
  1658. var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1])) : 0;
  1659. for(var t=tiddlers.length-1; t>=last; t--)
  1660. {
  1661. var tiddler = tiddlers[t];
  1662. var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);
  1663. if(theDay != lastDay)
  1664. {
  1665. var theDateList = document.createElement("ul");
  1666. place.appendChild(theDateList);
  1667. createTiddlyElement(theDateList,"li",null,"listTitle",tiddler[field].formatString(this.dateFormat));
  1668. lastDay = theDay;
  1669. }
  1670. var theDateListItem = createTiddlyElement(theDateList,"li",null,"listLink");
  1671. theDateListItem.appendChild(createTiddlyLink(place,tiddler.title,true));
  1672. }
  1673. }
  1674. config.macros.search.handler = function(place,macroName,params)
  1675. {
  1676. var searchTimeout = null;
  1677. var btn = createTiddlyButton(place,this.label,this.prompt,this.onClick);
  1678. var txt = createTiddlyElement(place,"input",null,"txtOptionInput");
  1679. if(params[0])
  1680. txt.value = params[0];
  1681. txt.onkeyup = this.onKeyPress;
  1682. txt.onfocus = this.onFocus;
  1683. txt.setAttribute("size",this.sizeTextbox);
  1684. txt.setAttribute("accessKey",this.accessKey);
  1685. txt.setAttribute("autocomplete","off");
  1686. txt.setAttribute("lastSearchText","");
  1687. if(config.browser.isSafari)
  1688. {
  1689. txt.setAttribute("type","search");
  1690. txt.setAttribute("results","5");
  1691. }
  1692. else
  1693. txt.setAttribute("type","text");
  1694. }
  1695. // Global because there's only ever one outstanding incremental search timer
  1696. config.macros.search.timeout = null;
  1697. config.macros.search.doSearch = function(txt)
  1698. {
  1699. if(txt.value.length > 0)
  1700. {
  1701. story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);
  1702. txt.setAttribute("lastSearchText",txt.value);
  1703. }
  1704. }
  1705. config.macros.search.onClick = function(e)
  1706. {
  1707. config.macros.search.doSearch(this.nextSibling);
  1708. return false;
  1709. }
  1710. config.macros.search.onKeyPress = function(e)
  1711. {
  1712. if(!e) var e = window.event;
  1713. switch(e.keyCode)
  1714. {
  1715. case 13: // Ctrl-Enter
  1716. case 10: // Ctrl-Enter on IE PC
  1717. config.macros.search.doSearch(this);
  1718. break;
  1719. case 27: // Escape
  1720. this.value = "";
  1721. clearMessage();
  1722. break;
  1723. }
  1724. if(this.value.length > 2)
  1725. {
  1726. if(this.value != this.getAttribute("lastSearchText"))
  1727. {
  1728. if(config.macros.search.timeout)
  1729. clearTimeout(config.macros.search.timeout);
  1730. var txt = this;
  1731. config.macros.search.timeout = setTimeout(function() {config.macros.search.doSearch(txt);},500);
  1732. }
  1733. }
  1734. else
  1735. {
  1736. if(config.macros.search.timeout)
  1737. clearTimeout(config.macros.search.timeout);
  1738. }
  1739. }
  1740. config.macros.search.onFocus = function(e)
  1741. {
  1742. this.select();
  1743. }
  1744. config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  1745. {
  1746. params = paramString.parseParams("name",null,true,false,true);
  1747. var names = params[0]["name"];
  1748. var tiddlerName = names[0];
  1749. var className = names[1] ? names[1] : null;
  1750. var args = params[0]["with"];
  1751. var wrapper = createTiddlyElement(place,"span",null,className);
  1752. if(!args)
  1753. {
  1754. wrapper.setAttribute("refresh","content");
  1755. wrapper.setAttribute("tiddler",tiddlerName);
  1756. }
  1757. var text = store.getTiddlerText(tiddlerName);
  1758. if(text)
  1759. {
  1760. var stack = config.macros.tiddler.tiddlerStack;
  1761. if(stack.indexOf(tiddlerName) !== -1)
  1762. return;
  1763. stack.push(tiddlerName);
  1764. try
  1765. {
  1766. var n = args ? Math.min(args.length,9) : 0;
  1767. for(var i=0; i<n; i++)
  1768. {
  1769. var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
  1770. text = text.replace(placeholderRE,args[i]);
  1771. }
  1772. config.macros.tiddler.renderText(wrapper,text,tiddlerName,params);
  1773. }
  1774. finally
  1775. {
  1776. stack.pop();
  1777. }
  1778. }
  1779. }
  1780. config.macros.tiddler.renderText = function(place,text,tiddlerName,params)
  1781. {
  1782. wikify(text,place,null,store.getTiddler(tiddlerName));
  1783. }
  1784. config.macros.tiddler.tiddlerStack = [];
  1785. config.macros.tag.handler = function(place,macroName,params)
  1786. {
  1787. createTagButton(place,params[0]);
  1788. }
  1789. config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  1790. {
  1791. params = paramString.parseParams("anon",null,true,false,false);
  1792. var theList = createTiddlyElement(place,"ul");
  1793. var title = getParam(params,"anon","");
  1794. if(title && store.tiddlerExists(title))
  1795. tiddler = store.getTiddler(title);
  1796. var sep = getParam(params,"sep"," ");
  1797. var lingo = config.views.wikified.tag;
  1798. var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags;
  1799. createTiddlyElement(theList,"li",null,"listTitle",prompt.format([tiddler.title]));
  1800. for(var t=0; t<tiddler.tags.length; t++)
  1801. {
  1802. createTagButton(createTiddlyElement(theList,"li"),tiddler.tags[t],tiddler.title);
  1803. if(t<tiddler.tags.length-1)
  1804. createTiddlyText(theList,sep);
  1805. }
  1806. }
  1807. config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  1808. {
  1809. params = paramString.parseParams("anon",null,true,false,false);
  1810. var theList = createTiddlyElement(place,"ul");
  1811. var title = getParam(params,"anon","");
  1812. if(title == "" && tiddler instanceof Tiddler)
  1813. title = tiddler.title;
  1814. var sep = getParam(params,"sep"," ");
  1815. theList.setAttribute("title",this.tooltip.format([title]));
  1816. var tagged = store.getTaggedTiddlers(title);
  1817. var prompt = tagged.length == 0 ? this.labelNotTag : this.label;
  1818. createTiddlyElement(theList,"li",null,"listTitle",prompt.format([title,tagged.length]));
  1819. for(var t=0; t<tagged.length; t++)
  1820. {
  1821. createTiddlyLink(createTiddlyElement(theList,"li"),tagged[t].title,true);
  1822. if(t<tagged.length-1)
  1823. createTiddlyText(theList,sep);
  1824. }
  1825. }
  1826. config.macros.closeAll.handler = function(place)
  1827. {
  1828. createTiddlyButton(place,this.label,this.prompt,this.onClick);
  1829. }
  1830. config.macros.closeAll.onClick = function(e)
  1831. {
  1832. story.closeAllTiddlers();
  1833. return false;
  1834. }
  1835. config.macros.permaview.handler = function(place)
  1836. {
  1837. createTiddlyButton(place,this.label,this.prompt,this.onClick);
  1838. }
  1839. config.macros.permaview.onClick = function(e)
  1840. {
  1841. story.permaView();
  1842. return false;
  1843. }
  1844. config.macros.saveChanges.handler = function(place)
  1845. {
  1846. if(!readOnly)
  1847. createTiddlyButton(place,this.label,this.prompt,this.onClick,null,null,this.accessKey);
  1848. }
  1849. config.macros.saveChanges.onClick = function(e)
  1850. {
  1851. saveChanges();
  1852. return false;
  1853. }
  1854. config.macros.slider.onClickSlider = function(e)
  1855. {
  1856. if(!e) var e = window.event;
  1857. var n = this.nextSibling;
  1858. var cookie = n.getAttribute("cookie");
  1859. var isOpen = n.style.display != "none";
  1860. if(anim && config.options.chkAnimate)
  1861. anim.startAnimating(new Slider(n,!isOpen,e.shiftKey || e.altKey,"none"));
  1862. else
  1863. n.style.display = isOpen ? "none" : "block";
  1864. config.options[cookie] = !isOpen;
  1865. saveOptionCookie(cookie);
  1866. return false;
  1867. }
  1868. config.macros.slider.createSlider = function(place,cookie,title,tooltip)
  1869. {
  1870. var cookie = cookie ? cookie : "";
  1871. var btn = createTiddlyButton(place,title,tooltip,this.onClickSlider);
  1872. var panel = createTiddlyElement(null,"div",null,"sliderPanel");
  1873. panel.setAttribute("cookie",cookie);
  1874. panel.style.display = config.options[cookie] ? "block" : "none";
  1875. place.appendChild(panel);
  1876. return panel;
  1877. }
  1878. config.macros.slider.handler = function(place,macroName,params)
  1879. {
  1880. var panel = this.createSlider(place,params[0],params[2],params[3]);
  1881. var text = store.getTiddlerText(params[1]);
  1882. panel.setAttribute("refresh", "content");
  1883. panel.setAttribute("tiddler", params[1]);
  1884. if(text)
  1885. wikify(text,panel,null,store.getTiddler(params[1]));
  1886. }
  1887. config.macros.option.onChangeOption = function(e)
  1888. {
  1889. var opt = this.getAttribute("option");
  1890. var elementType,valueField;
  1891. if(opt)
  1892. {
  1893. switch(opt.substr(0,3))
  1894. {
  1895. case "txt":
  1896. elementType = "input";
  1897. valueField = "value";
  1898. break;
  1899. case "chk":
  1900. elementType = "input";
  1901. valueField = "checked";
  1902. break;
  1903. }
  1904. config.options[opt] = this[valueField];
  1905. saveOptionCookie(opt);
  1906. var nodes = document.getElementsByTagName(elementType);
  1907. for(var t=0; t<nodes.length; t++)
  1908. {
  1909. var optNode = nodes[t].getAttribute("option");
  1910. if(opt == optNode)
  1911. nodes[t][valueField] = this[valueField];
  1912. }
  1913. }
  1914. return(true);
  1915. }
  1916. config.macros.option.handler = function(place,macroName,params)
  1917. {
  1918. var opt = params[0];
  1919. if(config.options[opt] == undefined)
  1920. return;
  1921. var c;
  1922. switch(opt.substr(0,3))
  1923. {
  1924. case "txt":
  1925. c = document.createElement("input");
  1926. c.onkeyup = this.onChangeOption;
  1927. c.setAttribute("option",opt);
  1928. c.className = "txtOptionInput";
  1929. place.appendChild(c);
  1930. c.value = config.options[opt];
  1931. break;
  1932. case "chk":
  1933. c = document.createElement("input");
  1934. c.setAttribute("type","checkbox");
  1935. c.onclick = this.onChangeOption;
  1936. c.setAttribute("option",opt);
  1937. c.className = "chkOptionInput";
  1938. place.appendChild(c);
  1939. c.checked = config.options[opt];
  1940. break;
  1941. }
  1942. }
  1943. config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal)
  1944. {
  1945. var tags = [];
  1946. for(var t=1; t<params.length; t++)
  1947. if((params[t].name == "anon" && t != 1) || (params[t].name == "tag"))
  1948. tags.push(params[t].value);
  1949. label = getParam(params,"label",label);
  1950. prompt = getParam(params,"prompt",prompt);
  1951. accessKey = getParam(params,"accessKey",accessKey);
  1952. newFocus = getParam(params,"focus",newFocus);
  1953. var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey);
  1954. btn.setAttribute("newTitle",title);
  1955. btn.setAttribute("isJournal",isJournal);
  1956. btn.setAttribute("params",tags.join("|"));
  1957. btn.setAttribute("newFocus",newFocus);
  1958. btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE));
  1959. var text = getParam(params,"text");
  1960. if(text !== undefined)
  1961. btn.setAttribute("newText",text);
  1962. return btn;
  1963. }
  1964. config.macros.newTiddler.onClickNewTiddler = function()
  1965. {
  1966. var title = this.getAttribute("newTitle");
  1967. if(this.getAttribute("isJournal"))
  1968. {
  1969. var now = new Date();
  1970. title = now.formatString(title.trim());
  1971. }
  1972. var params = this.getAttribute("params").split("|");
  1973. var focus = this.getAttribute("newFocus");
  1974. var template = this.getAttribute("newTemplate");
  1975. story.displayTiddler(null,title,template);
  1976. var text = this.getAttribute("newText");
  1977. if(typeof text == "string")
  1978. story.getTiddlerField(title,"text").value = text.format([title]);
  1979. for(var t=0;t<params.length;t++)
  1980. story.setTiddlerTag(title,params[t],+1);
  1981. story.focusTiddler(title,focus);
  1982. return false;
  1983. }
  1984. config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  1985. {
  1986. if(!readOnly)
  1987. {
  1988. params = paramString.parseParams("anon",null,true,false,false);
  1989. var title = params[1] && params[1].name == "anon" ? params[1].value : this.title;
  1990. title = getParam(params,"title",title);
  1991. this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false);
  1992. }
  1993. }
  1994. config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  1995. {
  1996. if(!readOnly)
  1997. {
  1998. params = paramString.parseParams("anon",null,true,false,false);
  1999. var title = params[1] && params[1].name == "anon" ? params[1].value : "";
  2000. title = getParam(params,"title",title);
  2001. config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true);
  2002. }
  2003. }
  2004. config.macros.sparkline.handler = function(place,macroName,params)
  2005. {
  2006. var data = [];
  2007. var min = 0;
  2008. var max = 0;
  2009. for(var t=0; t<params.length; t++)
  2010. {
  2011. var v = parseInt(params[t]);
  2012. if(v < min)
  2013. min = v;
  2014. if(v > max)
  2015. max = v;
  2016. data.push(v);
  2017. }
  2018. if(data.length < 1)
  2019. return;
  2020. var box = createTiddlyElement(place,"span",null,"sparkline",String.fromCharCode(160));
  2021. box.title = data.join(",");
  2022. var w = box.offsetWidth;
  2023. var h = box.offsetHeight;
  2024. box.style.paddingRight = (data.length * 2 - w) + "px";
  2025. box.style.position = "relative";
  2026. for(var d=0; d<data.length; d++)
  2027. {
  2028. var tick = document.createElement("img");
  2029. tick.border = 0;
  2030. tick.className = "sparktick";
  2031. tick.style.position = "absolute";
  2032. tick.src = "data:image/gif,GIF89a%01%00%01%00%91%FF%00%FF%FF%FF%00%00%00%C0%C0%C0%00%00%00!%F9%04%01%00%00%02%00%2C%00%00%00%00%01%00%01%00%40%02%02T%01%00%3B";
  2033. tick.style.left = d*2 + "px";
  2034. tick.style.width = "2px";
  2035. var v = Math.floor(((data[d] - min)/(max-min)) * h);
  2036. tick.style.top = (h-v) + "px";
  2037. tick.style.height = v + "px";
  2038. box.appendChild(tick);
  2039. }
  2040. }
  2041. config.macros.tabs.handler = function(place,macroName,params)
  2042. {
  2043. var cookie = params[0];
  2044. var numTabs = (params.length-1)/3;
  2045. var wrapper = createTiddlyElement(null,"div",null,cookie);
  2046. var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
  2047. tabset.setAttribute("cookie",cookie);
  2048. var validTab = false;
  2049. for(var t=0; t<numTabs; t++)
  2050. {
  2051. var label = params[t*3+1];
  2052. var prompt = params[t*3+2];
  2053. var content = params[t*3+3];
  2054. var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
  2055. tab.setAttribute("tab",label);
  2056. tab.setAttribute("content",content);
  2057. tab.title = prompt;
  2058. if(config.options[cookie] == label)
  2059. validTab = true;
  2060. }
  2061. if(!validTab)
  2062. config.options[cookie] = params[1];
  2063. place.appendChild(wrapper);
  2064. this.switchTab(tabset,config.options[cookie]);
  2065. }
  2066. config.macros.tabs.onClickTab = function(e)
  2067. {
  2068. config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
  2069. return false;
  2070. }
  2071. config.macros.tabs.switchTab = function(tabset,tab)
  2072. {
  2073. var cookie = tabset.getAttribute("cookie");
  2074. var theTab = null
  2075. var nodes = tabset.childNodes;
  2076. for(var t=0; t<nodes.length; t++)
  2077. if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab)
  2078. {
  2079. theTab = nodes[t];
  2080. theTab.className = "tab tabSelected";
  2081. }
  2082. else
  2083. nodes[t].className = "tab tabUnselected"
  2084. if(theTab)
  2085. {
  2086. if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
  2087. tabset.parentNode.removeChild(tabset.nextSibling);
  2088. var tabContent = createTiddlyElement(null,"div",null,"tabContents");
  2089. tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
  2090. var contentTitle = theTab.getAttribute("content");
  2091. wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
  2092. if(cookie)
  2093. {
  2094. config.options[cookie] = tab;
  2095. saveOptionCookie(cookie);
  2096. }
  2097. }
  2098. }
  2099. // <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >>
  2100. config.macros.gradient.handler = function(place,macroName,params,wikifier)
  2101. {
  2102. var terminator = ">>";
  2103. var panel;
  2104. if(wikifier)
  2105. panel = createTiddlyElement(place,"div",null,"gradient");
  2106. else
  2107. panel = place;
  2108. panel.style.position = "relative";
  2109. panel.style.overflow = "hidden";
  2110. panel.style.zIndex = "0";
  2111. var t;
  2112. if(wikifier)
  2113. {
  2114. var styles = config.formatterHelpers.inlineCssHelper(wikifier);
  2115. config.formatterHelpers.applyCssHelper(panel,styles);
  2116. }
  2117. var colours = [];
  2118. for(t=1; t<params.length; t++)
  2119. {
  2120. var c = new RGB(params[t]);
  2121. if(c)
  2122. colours.push(c);
  2123. }
  2124. drawGradient(panel,params[0] != "vert",colours);
  2125. if(wikifier)
  2126. wikifier.subWikify(panel,terminator);
  2127. if(document.all)
  2128. {
  2129. panel.style.height = "100%";
  2130. panel.style.width = "100%";
  2131. }
  2132. }
  2133. config.macros.message.handler = function(place,macroName,params)
  2134. {
  2135. if(params[0])
  2136. {
  2137. var m = config;
  2138. var p = params[0].split(".");
  2139. for(var t=0; t<p.length; t++)
  2140. {
  2141. if(p[t] in m)
  2142. m = m[p[t]];
  2143. else
  2144. break;
  2145. }
  2146. createTiddlyText(place,m.toString().format(params.splice(1)));
  2147. }
  2148. }
  2149. config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  2150. {
  2151. if((tiddler instanceof Tiddler) && params[0])
  2152. {
  2153. var value = store.getValue(tiddler,params[0]);
  2154. if(value != undefined)
  2155. switch(params[1])
  2156. {
  2157. case undefined:
  2158. highlightify(value,place,highlightHack);
  2159. break;
  2160. case "link":
  2161. createTiddlyLink(place,value,true);
  2162. break;
  2163. case "wikified":
  2164. wikify(value,place,highlightHack,tiddler);
  2165. break;
  2166. case "date":
  2167. value = Date.convertFromYYYYMMDDHHMM(value);
  2168. if(params[2])
  2169. createTiddlyText(place,value.formatString(params[2]));
  2170. else
  2171. createTiddlyText(place,value);
  2172. break;
  2173. }
  2174. }
  2175. }
  2176. config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  2177. {
  2178. var field = params[0];
  2179. if((tiddler instanceof Tiddler) && field)
  2180. {
  2181. story.setDirty(tiddler.title,true);
  2182. if(field != "text")
  2183. {
  2184. var e = createTiddlyElement(null,"input");
  2185. if(tiddler.isReadOnly())
  2186. e.setAttribute("readOnly","readOnly");
  2187. e.setAttribute("edit",field);
  2188. e.setAttribute("type","text");
  2189. var v = store.getValue(tiddler,field);
  2190. if(!v)
  2191. v = "";
  2192. e.value = v;
  2193. e.setAttribute("size","40");
  2194. e.setAttribute("autocomplete","off");
  2195. place.appendChild(e);
  2196. }
  2197. else
  2198. {
  2199. var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix");
  2200. var wrapper2 = createTiddlyElement(wrapper1,"div");
  2201. var e = createTiddlyElement(wrapper2,"textarea");
  2202. if(tiddler.isReadOnly())
  2203. e.setAttribute("readOnly","readOnly");
  2204. var v = store.getValue(tiddler,field);
  2205. if(!v)
  2206. v = "";
  2207. e.value = v;
  2208. var rows = 10;
  2209. var lines = v.match(/\n/mg);
  2210. var maxLines = Math.max(parseInt(config.options.txtMaxEditRows),5);
  2211. if(lines != null && lines.length > rows)
  2212. rows = lines.length + 5;
  2213. rows = Math.min(rows,maxLines);
  2214. e.setAttribute("rows",rows);
  2215. e.setAttribute("edit",field);
  2216. place.appendChild(wrapper1);
  2217. }
  2218. }
  2219. }
  2220. config.macros.tagChooser.onClick = function(e)
  2221. {
  2222. if(!e) var e = window.event;
  2223. var lingo = config.views.editor.tagChooser;
  2224. var popup = Popup.create(this);
  2225. var tags = store.getTags();
  2226. if(tags.length == 0)
  2227. createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone);
  2228. for(var t=0; t<tags.length; t++)
  2229. {
  2230. var theTag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick);
  2231. theTag.setAttribute("tag",tags[t][0]);
  2232. theTag.setAttribute("tiddler", this.getAttribute("tiddler"));
  2233. }
  2234. Popup.show(popup,false);
  2235. e.cancelBubble = true;
  2236. if(e.stopPropagation) e.stopPropagation();
  2237. return(false);
  2238. }
  2239. config.macros.tagChooser.onTagClick = function(e)
  2240. {
  2241. if(!e) var e = window.event;
  2242. var tag = this.getAttribute("tag");
  2243. var title = this.getAttribute("tiddler");
  2244. if(!readOnly)
  2245. story.setTiddlerTag(title,tag,0);
  2246. return(false);
  2247. }
  2248. config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  2249. {
  2250. if(tiddler instanceof Tiddler)
  2251. {
  2252. var title = tiddler.title;
  2253. var lingo = config.views.editor.tagChooser;
  2254. var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick);
  2255. btn.setAttribute("tiddler", title);
  2256. }
  2257. }
  2258. // Create a toolbar command button
  2259. // place - parent DOM element
  2260. // command - reference to config.commands[] member -or- name of member
  2261. // tiddler - reference to tiddler that toolbar applies to
  2262. // theClass - the class to give the button
  2263. config.macros.toolbar.createCommand = function(place,commandName,tiddler,theClass)
  2264. {
  2265. if(typeof commandName != "string")
  2266. {
  2267. var c = null;
  2268. for(var t in config.commands)
  2269. if(config.commands[t] == commandName)
  2270. c = t;
  2271. commandName = c;
  2272. }
  2273. if((tiddler instanceof Tiddler) && (typeof commandName == "string"))
  2274. {
  2275. var title = tiddler.title;
  2276. var command = config.commands[commandName];
  2277. var ro = tiddler.isReadOnly();
  2278. var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title);
  2279. var text = ro && command.readOnlyText ? command.readOnlyText : command.text;
  2280. var tooltip = ro && command.readOnlyTooltip ? command.readOnlyTooltip : command.tooltip;
  2281. if((!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow))
  2282. {
  2283. var btn = createTiddlyButton(null,text,tooltip,this.onClickCommand);
  2284. btn.setAttribute("commandName", commandName);
  2285. btn.setAttribute("tiddler", title);
  2286. if(theClass)
  2287. addClass(btn,theClass);
  2288. place.appendChild(btn);
  2289. }
  2290. }
  2291. }
  2292. config.macros.toolbar.onClickCommand = function(e)
  2293. {
  2294. if(!e) var e = window.event;
  2295. var command = config.commands[this.getAttribute("commandName")];
  2296. return command.handler(e,this,this.getAttribute("tiddler"));
  2297. }
  2298. // Invoke the first command encountered from a given place that is tagged with a specified class
  2299. config.macros.toolbar.invokeCommand = function(place,theClass,event)
  2300. {
  2301. var children = place.getElementsByTagName("a")
  2302. for(var t=0; t<children.length; t++)
  2303. {
  2304. var c = children[t];
  2305. if(hasClass(c,theClass) && c.getAttribute && c.getAttribute("commandName"))
  2306. {
  2307. if(c.onclick instanceof Function)
  2308. c.onclick.call(c,event);
  2309. break;
  2310. }
  2311. }
  2312. }
  2313. config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  2314. {
  2315. for(var t=0; t<params.length; t++)
  2316. {
  2317. var c = params[t];
  2318. var theClass = "";
  2319. switch(c.substr(0,1))
  2320. {
  2321. case "+":
  2322. theClass = "defaultCommand";
  2323. c = c.substr(1);
  2324. break;
  2325. case "-":
  2326. theClass = "cancelCommand";
  2327. c = c.substr(1);
  2328. break;
  2329. }
  2330. if(c in config.commands)
  2331. this.createCommand(place,c,tiddler,theClass);
  2332. }
  2333. }
  2334. config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  2335. {
  2336. var e = createTiddlyElement(place,"div");
  2337. e.setAttribute("refresh","macro");
  2338. e.setAttribute("macroName","plugins");
  2339. e.setAttribute("params",paramString);
  2340. this.refresh(e,paramString);
  2341. }
  2342. config.macros.plugins.refresh = function(place,params)
  2343. {
  2344. var selectedRows = [];
  2345. ListView.forEachSelector(place,function(e,rowName) {
  2346. if(e.checked)
  2347. selectedRows.push(e.getAttribute("rowName"));
  2348. });
  2349. removeChildren(place);
  2350. params = params.parseParams("anon");
  2351. var plugins = installedPlugins.slice(0);
  2352. var t,tiddler,p;
  2353. var configTiddlers = store.getTaggedTiddlers("systemConfig");
  2354. for(t=0; t<configTiddlers.length; t++)
  2355. {
  2356. tiddler = configTiddlers[t];
  2357. if(plugins.findByField("title",tiddler.title) == null)
  2358. {
  2359. p = getPluginInfo(tiddler);
  2360. p.executed = false;
  2361. p.log.splice(0,0,this.skippedText);
  2362. plugins.push(p);
  2363. }
  2364. }
  2365. for(t=0; t<plugins.length; t++)
  2366. {
  2367. var p = plugins[t];
  2368. p.forced = p.tiddler.isTagged("systemConfigForce");
  2369. p.disabled = p.tiddler.isTagged("systemConfigDisable");
  2370. p.Selected = selectedRows.indexOf(plugins[t].title) != -1;
  2371. }
  2372. if(plugins.length == 0)
  2373. createTiddlyElement(place,"em",null,null,this.noPluginText);
  2374. else
  2375. ListView.create(place,plugins,this.listViewTemplate,this.onSelectCommand);
  2376. }
  2377. config.macros.plugins.onSelectCommand = function(command,rowNames)
  2378. {
  2379. var t;
  2380. switch(command)
  2381. {
  2382. case "remove":
  2383. for(t=0; t<rowNames.length; t++)
  2384. store.setTiddlerTag(rowNames[t],false,"systemConfig");
  2385. break;
  2386. case "delete":
  2387. if(rowNames.length > 0 && confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")])))
  2388. {
  2389. for(t=0; t<rowNames.length; t++)
  2390. {
  2391. store.removeTiddler(rowNames[t]);
  2392. story.closeTiddler(rowNames[t],true,false);
  2393. }
  2394. }
  2395. break;
  2396. }
  2397. if(config.options.chkAutoSave)
  2398. saveChanges(true);
  2399. }
  2400. config.macros.refreshDisplay.handler = function(place)
  2401. {
  2402. createTiddlyButton(place,this.label,this.prompt,this.onClick);
  2403. }
  2404. config.macros.refreshDisplay.onClick = function(e)
  2405. {
  2406. refreshAll();
  2407. return false;
  2408. }
  2409. config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
  2410. {
  2411. if(readOnly)
  2412. {
  2413. createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning);
  2414. return;
  2415. }
  2416. var importer = createTiddlyElement(null,"div",null,"importTiddler wizard");
  2417. createTiddlyElement(importer,"h1",null,null,this.wizardTitle);
  2418. createTiddlyElement(importer,"h2",null,"step1",this.step1);
  2419. var step = createTiddlyElement(importer,"div",null,"wizardStep");
  2420. createTiddlyText(step,this.step1prompt);
  2421. var input = createTiddlyElement(null,"input",null,"txtOptionInput");
  2422. input.type = "text";
  2423. input.size = 50;
  2424. step.appendChild(input);
  2425. importer.inputBox = input;
  2426. createTiddlyElement(step,"br");
  2427. createTiddlyText(step,this.step1promptFile);
  2428. var fileInput = createTiddlyElement(null,"input",null,"txtOptionInput");
  2429. fileInput.type = "file";
  2430. fileInput.size = 50;
  2431. fileInput.onchange = this.onBrowseChange;
  2432. fileInput.onkeyup = this.onBrowseChange;
  2433. step.appendChild(fileInput);
  2434. createTiddlyElement(step,"br");
  2435. createTiddlyText(step,this.step1promptFeeds);
  2436. var feeds = this.getFeeds([{caption: this.step1feedPrompt, name: ""}]);
  2437. createTiddlyDropDown(step,this.onFeedChange,feeds);
  2438. createTiddlyElement(step,"br");
  2439. createTiddlyButton(step,this.fetchLabel,this.fetchPrompt,this.onFetch,null,null,null);
  2440. place.appendChild(importer);
  2441. }
  2442. config.macros.importTiddlers.getFeeds = function(feeds)
  2443. {
  2444. var tagged = store.getTaggedTiddlers("contentPublisher","title");
  2445. for(var t=0; t<tagged.length; t++)
  2446. feeds.push({caption: tagged[t].title, name: store.getTiddlerSlice(tagged[t].title,"URL")});
  2447. return feeds;
  2448. }
  2449. config.macros.importTiddlers.onFeedChange = function(e)
  2450. {
  2451. var importer = findRelated(this,"importTiddler","className","parentNode");
  2452. importer.inputBox.value = this.value;
  2453. this.selectedIndex = 0;
  2454. }
  2455. config.macros.importTiddlers.onBrowseChange = function(e)
  2456. {
  2457. var importer = findRelated(this,"importTiddler","className","parentNode");
  2458. importer.inputBox.value = "file://" + this.value;
  2459. }
  2460. config.macros.importTiddlers.onFetch = function(e)
  2461. {
  2462. var importer = findRelated(this,"importTiddler","className","parentNode");
  2463. var url = importer.inputBox.value;
  2464. var cutoff = findRelated(importer.firstChild,"step2","className","nextSibling");
  2465. while(cutoff)
  2466. {
  2467. var temp = cutoff.nextSibling;
  2468. cutoff.parentNode.removeChild(cutoff);
  2469. cutoff = temp;
  2470. }
  2471. createTiddlyElement(importer,"h2",null,"step2",config.macros.importTiddlers.step2);
  2472. var step = createTiddlyElement(importer,"div",null,"wizardStep",config.macros.importTiddlers.step2Text.format([url]));
  2473. loadRemoteFile(url,config.macros.importTiddlers.onLoad,importer);
  2474. }
  2475. config.macros.importTiddlers.onLoad = function(status,params,responseText,url,xhr)
  2476. {
  2477. if(!status)
  2478. {
  2479. displayMessage(this.fetchError);
  2480. return;
  2481. }
  2482. var importer = params;
  2483. // Check that the tiddler we're in hasn't been closed - doesn't work on IE
  2484. // var p = importer;
  2485. // while(p.parentNode)
  2486. // p = p.parentNode;
  2487. // if(!(p instanceof HTMLDocument))
  2488. // return;
  2489. // Crack out the content - (should be refactored)
  2490. var posOpeningDiv = responseText.indexOf(startSaveArea);
  2491. var limitClosingDiv = responseText.indexOf("<!--POST-BODY-START--"+">");
  2492. var posClosingDiv = responseText.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? responseText.length : limitClosingDiv);
  2493. if((posOpeningDiv == -1) || (posClosingDiv == -1))
  2494. {
  2495. alert(config.messages.invalidFileError.format([url]));
  2496. return;
  2497. }
  2498. var content = "<html><body>" + responseText.substring(posOpeningDiv,posClosingDiv + endSaveArea.length) + "</body></html>";
  2499. // Create the iframe
  2500. var iframe = document.createElement("iframe");
  2501. iframe.style.display = "none";
  2502. importer.insertBefore(iframe,importer.firstChild);
  2503. var doc = iframe.document;
  2504. if(iframe.contentDocument)
  2505. doc = iframe.contentDocument; // For NS6
  2506. else if(iframe.contentWindow)
  2507. doc = iframe.contentWindow.document; // For IE5.5 and IE6
  2508. // Put the content in the iframe
  2509. doc.open();
  2510. doc.writeln(content);
  2511. doc.close();
  2512. // Load the content into a TiddlyWiki() object
  2513. var storeArea = doc.getElementById("storeArea");
  2514. var importStore = new TiddlyWiki();
  2515. importStore.loadFromDiv(storeArea,"store");
  2516. // Get rid of the iframe
  2517. iframe.parentNode.removeChild(iframe);
  2518. // Extract data for the listview
  2519. var tiddlers = [];
  2520. importStore.forEachTiddler(function(title,tiddler)
  2521. {
  2522. var t = {};
  2523. t.title = title;
  2524. t.modified = tiddler.modified;
  2525. t.modifier = tiddler.modifier;
  2526. t.text = tiddler.text.substr(0,50);
  2527. t.tags = tiddler.tags;
  2528. tiddlers.push(t);
  2529. });
  2530. // Display the listview
  2531. createTiddlyElement(importer,"h2",null,"step3",config.macros.importTiddlers.step3);
  2532. var step = createTiddlyElement(importer,"div",null,"wizardStep");
  2533. ListView.create(step,tiddlers,config.macros.importTiddlers.listViewTemplate,config.macros.importTiddlers.onSelectCommand);
  2534. // Save the importer
  2535. importer.store = importStore;
  2536. }
  2537. config.macros.importTiddlers.onSelectCommand = function(listView,command,rowNames)
  2538. {
  2539. var importer = findRelated(listView,"importTiddler","className","parentNode");
  2540. switch(command)
  2541. {
  2542. case "import":
  2543. config.macros.importTiddlers.doImport(importer,rowNames);
  2544. break;
  2545. }
  2546. if(config.options.chkAutoSave)
  2547. saveChanges(true);
  2548. }
  2549. config.macros.importTiddlers.doImport = function(importer,rowNames)
  2550. {
  2551. var theStore = importer.store;
  2552. var overwrite = new Array();
  2553. var t;
  2554. for(t=0; t<rowNames.length; t++)
  2555. {
  2556. if(store.tiddlerExists(rowNames[t]))
  2557. overwrite.push(rowNames[t]);
  2558. }
  2559. if(overwrite.length > 0)
  2560. if(!confirm(this.confirmOverwriteText.format([overwrite.join(", ")])))
  2561. return;
  2562. for(t=0; t<rowNames.length; t++)
  2563. {
  2564. var inbound = theStore.fetchTiddler(rowNames[t]);
  2565. store.saveTiddler(inbound.title, inbound.title, inbound.text, inbound.modifier, inbound.modified, inbound.tags);
  2566. store.fetchTiddler(inbound.title).created = inbound.created;
  2567. store.notify(rowNames[t],false);
  2568. }
  2569. store.notifyAll();
  2570. store.setDirty(true);
  2571. createTiddlyElement(importer,"h2",null,"step4",this.step4.format([rowNames.length]));
  2572. var step = createTiddlyElement(importer,"div",null,"wizardStep");
  2573. for(t=0; t<rowNames.length; t++)
  2574. {
  2575. createTiddlyLink(step,rowNames[t],true);
  2576. createTiddlyElement(step,"br");
  2577. }
  2578. createTiddlyElement(importer,"h2",null,"step5",this.step5);
  2579. }
  2580. // ---------------------------------------------------------------------------------
  2581. // Menu and toolbar commands
  2582. // ---------------------------------------------------------------------------------
  2583. config.commands.closeTiddler.handler = function(event,src,title)
  2584. {
  2585. story.closeTiddler(title,true,event.shiftKey || event.altKey);
  2586. return false;
  2587. }
  2588. config.commands.closeOthers.handler = function(event,src,title)
  2589. {
  2590. story.closeAllTiddlers(title);
  2591. return false;
  2592. }
  2593. config.commands.editTiddler.handler = function(event,src,title)
  2594. {
  2595. clearMessage();
  2596. story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
  2597. story.focusTiddler(title,"text");
  2598. return false;
  2599. }
  2600. config.commands.saveTiddler.handler = function(event,src,title)
  2601. {
  2602. var newTitle = story.saveTiddler(title,event.shiftKey);
  2603. if(newTitle)
  2604. story.displayTiddler(null,newTitle);
  2605. return false;
  2606. }
  2607. config.commands.cancelTiddler.handler = function(event,src,title)
  2608. {
  2609. if(story.hasChanges(title) && !readOnly)
  2610. if(!confirm(this.warning.format([title])))
  2611. return false;
  2612. story.setDirty(title,false);
  2613. story.displayTiddler(null,title);
  2614. return false;
  2615. }
  2616. config.commands.deleteTiddler.handler = function(event,src,title)
  2617. {
  2618. var deleteIt = true;
  2619. if (config.options.chkConfirmDelete)
  2620. deleteIt = confirm(this.warning.format([title]));
  2621. if (deleteIt)
  2622. {
  2623. store.removeTiddler(title);
  2624. story.closeTiddler(title,true,event.shiftKey || event.altKey);
  2625. if(config.options.chkAutoSave)
  2626. saveChanges();
  2627. }
  2628. return false;
  2629. }
  2630. config.commands.permalink.handler = function(event,src,title)
  2631. {
  2632. var t = encodeURIComponent(String.encodeTiddlyLink(title));
  2633. if(window.location.hash != t)
  2634. window.location.hash = t;
  2635. return false;
  2636. }
  2637. config.commands.references.handler = function(event,src,title)
  2638. {
  2639. var popup = Popup.create(src);
  2640. if(popup)
  2641. {
  2642. var references = store.getReferringTiddlers(title);
  2643. var c = false;
  2644. for(var r=0; r<references.length; r++)
  2645. if(references[r].title != title && !references[r].isTagged("excludeLists"))
  2646. {
  2647. createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true);
  2648. c = true;
  2649. }
  2650. if(!c)
  2651. createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),this.popupNone);
  2652. }
  2653. Popup.show(popup,false);
  2654. event.cancelBubble = true;
  2655. if (event.stopPropagation) event.stopPropagation();
  2656. return false;
  2657. }
  2658. config.commands.jump.handler = function(event,src,title)
  2659. {
  2660. var popup = Popup.create(src);
  2661. if(popup)
  2662. {
  2663. story.forEachTiddler(function(title,element) {
  2664. createTiddlyLink(createTiddlyElement(popup,"li"),title,true);
  2665. });
  2666. }
  2667. Popup.show(popup,false);
  2668. event.cancelBubble = true;
  2669. if (event.stopPropagation) event.stopPropagation();
  2670. return false;
  2671. }
  2672. // ---------------------------------------------------------------------------------
  2673. // Tiddler() object
  2674. // ---------------------------------------------------------------------------------
  2675. function Tiddler()
  2676. {
  2677. this.title = null;
  2678. this.text = null;
  2679. this.modifier = null;
  2680. this.modified = new Date();
  2681. this.created = new Date();
  2682. this.links = [];
  2683. this.linksUpdated = false;
  2684. this.tags = [];
  2685. return this;
  2686. }
  2687. Tiddler.prototype.getLinks = function()
  2688. {
  2689. if(this.linksUpdated==false)
  2690. this.changed();
  2691. return this.links;
  2692. }
  2693. // Format the text for storage in an RSS item
  2694. Tiddler.prototype.saveToRss = function(url)
  2695. {
  2696. var s = [];
  2697. s.push("<item>");
  2698. s.push("<title" + ">" + this.title.htmlEncode() + "</title" + ">");
  2699. s.push("<description>" + wikifyStatic(this.text,null,this).htmlEncode() + "</description>");
  2700. for(var t=0; t<this.tags.length; t++)
  2701. s.push("<category>" + this.tags[t] + "</category>");
  2702. s.push("<link>" + url + "#" + encodeURIComponent(String.encodeTiddlyLink(this.title)) + "</link>");
  2703. s.push("<pubDate>" + this.modified.toGMTString() + "</pubDate>");
  2704. s.push("</item>");
  2705. return(s.join("\n"));
  2706. }
  2707. // Change the text and other attributes of a tiddler
  2708. Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields)
  2709. {
  2710. this.assign(title,text,modifier,modified,tags,created,fields);
  2711. this.changed();
  2712. return this;
  2713. }
  2714. // Change the text and other attributes of a tiddler without triggered a tiddler.changed() call
  2715. Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields)
  2716. {
  2717. if(title != undefined)
  2718. this.title = title;
  2719. if(text != undefined)
  2720. this.text = text;
  2721. if(modifier != undefined)
  2722. this.modifier = modifier;
  2723. if(modified != undefined)
  2724. this.modified = modified;
  2725. if(created != undefined)
  2726. this.created = created;
  2727. if(fields != undefined)
  2728. this.fields = fields;
  2729. if(tags != undefined)
  2730. this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
  2731. else if(this.tags == undefined)
  2732. this.tags = [];
  2733. return this;
  2734. }
  2735. // Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
  2736. Tiddler.prototype.getTags = function()
  2737. {
  2738. return String.encodeTiddlyLinkList(this.tags);
  2739. }
  2740. // Test if a tiddler carries a tag
  2741. Tiddler.prototype.isTagged = function(tag)
  2742. {
  2743. return this.tags.indexOf(tag) != -1;
  2744. }
  2745. // Static method to convert "\n" to newlines, "\s" to "\"
  2746. Tiddler.unescapeLineBreaks = function(text)
  2747. {
  2748. return text ? text.unescapeLineBreaks() : "";
  2749. }
  2750. // Convert newlines to "\n", "\" to "\s"
  2751. Tiddler.prototype.escapeLineBreaks = function()
  2752. {
  2753. return this.text.escapeLineBreaks();
  2754. }
  2755. // Updates the secondary information (like links[] array) after a change to a tiddler
  2756. Tiddler.prototype.changed = function()
  2757. {
  2758. this.links = [];
  2759. var t = this.autoLinkWikiWords() ? 0 : 1;
  2760. var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp;
  2761. tiddlerLinkRegExp.lastIndex = 0;
  2762. var formatMatch = tiddlerLinkRegExp.exec(this.text);
  2763. while(formatMatch)
  2764. {
  2765. if(t==0 && formatMatch[1] && formatMatch[1] != this.title) // wikiWordLink
  2766. {
  2767. if(formatMatch.index > 0)
  2768. {
  2769. var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg");
  2770. preRegExp.lastIndex = formatMatch.index-1;
  2771. var preMatch = preRegExp.exec(this.text);
  2772. if(preMatch.index != formatMatch.index-1)
  2773. this.links.pushUnique(formatMatch[1]);
  2774. }
  2775. else
  2776. this.links.pushUnique(formatMatch[1]);
  2777. }
  2778. else if(formatMatch[2-t] && (store.tiddlerExists(formatMatch[3-t]) || store.isShadowTiddler(formatMatch[3-t]))) // titledBrackettedLink
  2779. this.links.pushUnique(formatMatch[3-t]);
  2780. else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink
  2781. this.links.pushUnique(formatMatch[4-t]);
  2782. // Do not add link if match urlPattern (formatMatch[5-t])
  2783. formatMatch = tiddlerLinkRegExp.exec(this.text);
  2784. }
  2785. this.linksUpdated = true;
  2786. return;
  2787. }
  2788. Tiddler.prototype.getSubtitle = function()
  2789. {
  2790. var theModifier = this.modifier;
  2791. if(!theModifier)
  2792. theModifier = config.messages.subtitleUnknown;
  2793. var theModified = this.modified;
  2794. if(theModified)
  2795. theModified = theModified.toLocaleString();
  2796. else
  2797. theModified = config.messages.subtitleUnknown;
  2798. return(config.messages.tiddlerLinkTooltip.format([this.title,theModifier,theModified]));
  2799. }
  2800. Tiddler.prototype.isReadOnly = function()
  2801. {
  2802. return readOnly;
  2803. }
  2804. Tiddler.prototype.autoLinkWikiWords = function()
  2805. {
  2806. return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing"));
  2807. }
  2808. Tiddler.prototype.generateFingerprint = function()
  2809. {
  2810. return "0x" + Crypto.hexSha1Str(this.text);
  2811. }
  2812. // ---------------------------------------------------------------------------------
  2813. // TiddlyWiki() object contains Tiddler()s
  2814. // ---------------------------------------------------------------------------------
  2815. function TiddlyWiki()
  2816. {
  2817. var tiddlers = {}; // Hashmap by name of tiddlers
  2818. this.tiddlersUpdated = false;
  2819. this.namedNotifications = []; // Array of {name:,notify:} of notification functions
  2820. this.notificationLevel = 0;
  2821. this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
  2822. this.clear = function() {
  2823. tiddlers = {};
  2824. this.setDirty(false);
  2825. };
  2826. this.fetchTiddler = function(title) {
  2827. return tiddlers[title];
  2828. };
  2829. this.deleteTiddler = function(title) {
  2830. delete this.slices[title];
  2831. delete tiddlers[title];
  2832. };
  2833. this.addTiddler = function(tiddler) {
  2834. delete this.slices[tiddler.title];
  2835. tiddlers[tiddler.title] = tiddler;
  2836. };
  2837. this.forEachTiddler = function(callback) {
  2838. for(var t in tiddlers)
  2839. {
  2840. var tiddler = tiddlers[t];
  2841. if(tiddler instanceof Tiddler)
  2842. callback.call(this,t,tiddler);
  2843. }
  2844. };
  2845. }
  2846. // Set the dirty flag
  2847. TiddlyWiki.prototype.setDirty = function(dirty)
  2848. {
  2849. this.dirty = dirty;
  2850. }
  2851. TiddlyWiki.prototype.isDirty = function()
  2852. {
  2853. return this.dirty;
  2854. }
  2855. TiddlyWiki.prototype.suspendNotifications = function()
  2856. {
  2857. this.notificationLevel--;
  2858. }
  2859. TiddlyWiki.prototype.resumeNotifications = function()
  2860. {
  2861. this.notificationLevel++;
  2862. }
  2863. // Invoke the notification handlers for a particular tiddler
  2864. TiddlyWiki.prototype.notify = function(title,doBlanket)
  2865. {
  2866. if(!this.notificationLevel)
  2867. for(var t=0; t<this.namedNotifications.length; t++)
  2868. {
  2869. var n = this.namedNotifications[t];
  2870. if((n.name == null && doBlanket) || (n.name == title))
  2871. n.notify(title);
  2872. }
  2873. }
  2874. // Invoke the notification handlers for all tiddlers
  2875. TiddlyWiki.prototype.notifyAll = function()
  2876. {
  2877. if(!this.notificationLevel)
  2878. for(var t=0; t<this.namedNotifications.length; t++)
  2879. {
  2880. var n = this.namedNotifications[t];
  2881. if(n.name)
  2882. n.notify(n.name);
  2883. }
  2884. }
  2885. // Add a notification handler to a tiddler
  2886. TiddlyWiki.prototype.addNotification = function(title,fn)
  2887. {
  2888. for (var i=0; i<this.namedNotifications.length; i++)
  2889. if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
  2890. return this;
  2891. this.namedNotifications.push({name: title, notify: fn});
  2892. return this;
  2893. }
  2894. TiddlyWiki.prototype.removeTiddler = function(title)
  2895. {
  2896. var tiddler = this.fetchTiddler(title);
  2897. if(tiddler)
  2898. {
  2899. this.deleteTiddler(title);
  2900. this.notify(title,true);
  2901. this.setDirty(true);
  2902. }
  2903. }
  2904. TiddlyWiki.prototype.tiddlerExists = function(title)
  2905. {
  2906. var t = this.fetchTiddler(title);
  2907. return (t != undefined);
  2908. }
  2909. TiddlyWiki.prototype.isShadowTiddler = function(title)
  2910. {
  2911. return typeof config.shadowTiddlers[title] == "string";
  2912. }
  2913. TiddlyWiki.prototype.getTiddler = function(title)
  2914. {
  2915. var t = this.fetchTiddler(title);
  2916. if(t != undefined)
  2917. return t;
  2918. else
  2919. return null;
  2920. }
  2921. TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
  2922. {
  2923. var tiddler = this.fetchTiddler(title);
  2924. if(tiddler)
  2925. return tiddler.text;
  2926. if(!title)
  2927. return defaultText;
  2928. var pos = title.indexOf(config.textPrimitives.sliceSeparator);
  2929. if(pos != -1)
  2930. {
  2931. var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
  2932. if(slice)
  2933. return slice;
  2934. }
  2935. if(this.isShadowTiddler(title))
  2936. return config.shadowTiddlers[title];
  2937. if(defaultText != undefined)
  2938. return defaultText;
  2939. return null;
  2940. }
  2941. TiddlyWiki.prototype.slicesRE = /(?:[\'\/]*~?(\w+)[\'\/]*\:[\'\/]*\s*(.*?)\s*$)|(?:\|[\'\/]*~?(\w+)\:?[\'\/]*\|\s*(.*?)\s*\|)/gm
  2942. // @internal
  2943. TiddlyWiki.prototype.calcAllSlices = function(title)
  2944. {
  2945. var slices = {};
  2946. var text = this.getTiddlerText(title,"");
  2947. this.slicesRE.lastIndex = 0;
  2948. do
  2949. {
  2950. var m = this.slicesRE.exec(text);
  2951. if (m)
  2952. {
  2953. if (m[1])
  2954. slices[m[1]] = m[2];
  2955. else
  2956. slices[m[3]] = m[4];
  2957. }
  2958. }
  2959. while(m);
  2960. return slices;
  2961. }
  2962. // Returns the slice of text of the given name
  2963. //#
  2964. //# A text slice is a substring in the tiddler's text that is defined
  2965. //# either like this
  2966. //# aName: textSlice
  2967. //# or
  2968. //# |aName:| textSlice |
  2969. //# or
  2970. //# |aName| textSlice |
  2971. //#
  2972. //# In the text the name (or name:) may be decorated with '' or //. I.e.
  2973. //# this would also a possible text slice:
  2974. //#
  2975. //# |''aName:''| textSlice |
  2976. //#
  2977. //# @param name should only contain "word characters" (i.e. "a-ZA-Z_0-9")
  2978. //# @return [may be undefined] the (trimmed) text of the specified slice.
  2979. TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName)
  2980. {
  2981. var slices = this.slices[title];
  2982. if (!slices) {
  2983. slices = this.calcAllSlices(title);
  2984. this.slices[title] = slices;
  2985. }
  2986. return slices[sliceName];
  2987. }
  2988. // Build an hashmap of the specified named slices of a tiddler
  2989. TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames)
  2990. {
  2991. var r = {};
  2992. for(var t=0; t<sliceNames.length; t++)
  2993. {
  2994. var slice = this.getTiddlerSlice(title,sliceNames[t]);
  2995. if(slice)
  2996. r[sliceNames[t]] = slice;
  2997. }
  2998. return r;
  2999. }
  3000. TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth)
  3001. {
  3002. var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
  3003. var text = this.getTiddlerText(title,null);
  3004. if(text == null)
  3005. return defaultText;
  3006. var textOut = [];
  3007. var lastPos = 0;
  3008. do {
  3009. var match = bracketRegExp.exec(text);
  3010. if(match)
  3011. {
  3012. textOut.push(text.substr(lastPos,match.index-lastPos));
  3013. if(match[1])
  3014. {
  3015. if(depth <= 0)
  3016. textOut.push(match[1]);
  3017. else
  3018. textOut.push(this.getRecursiveTiddlerText(match[1],"[[" + match[1] + "]]",depth-1));
  3019. }
  3020. lastPos = match.index + match[0].length;
  3021. }
  3022. else
  3023. textOut.push(text.substr(lastPos));
  3024. } while(match);
  3025. return(textOut.join(""));
  3026. }
  3027. TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag)
  3028. {
  3029. var tiddler = this.fetchTiddler(title);
  3030. if(tiddler)
  3031. {
  3032. var t = tiddler.tags.indexOf(tag);
  3033. if(t != -1)
  3034. tiddler.tags.splice(t,1);
  3035. if(status)
  3036. tiddler.tags.push(tag);
  3037. tiddler.changed();
  3038. this.notify(title,true);
  3039. this.setDirty(true);
  3040. }
  3041. }
  3042. TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields)
  3043. {
  3044. var tiddler = this.fetchTiddler(title);
  3045. var created;
  3046. if(tiddler)
  3047. {
  3048. created = tiddler.created; // Preserve created date
  3049. this.deleteTiddler(title);
  3050. }
  3051. else
  3052. {
  3053. tiddler = new Tiddler();
  3054. created = modified;
  3055. }
  3056. tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields);
  3057. this.addTiddler(tiddler);
  3058. if(title != newTitle)
  3059. this.notify(title,true);
  3060. this.notify(newTitle,true);
  3061. this.setDirty(true);
  3062. return tiddler;
  3063. }
  3064. TiddlyWiki.prototype.createTiddler = function(title)
  3065. {
  3066. var tiddler = this.fetchTiddler(title);
  3067. if(!tiddler)
  3068. {
  3069. tiddler = new Tiddler();
  3070. tiddler.title = title;
  3071. this.addTiddler(tiddler);
  3072. this.setDirty(true);
  3073. }
  3074. return tiddler;
  3075. }
  3076. // Load contents of a tiddlywiki from an HTML DIV
  3077. TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate)
  3078. {
  3079. this.idPrefix = idPrefix;
  3080. var storeElem = (typeof src == "string") ? document.getElementById(src) : src;
  3081. var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes);
  3082. this.setDirty(false);
  3083. if(!noUpdate)
  3084. {
  3085. for(var i = 0;i<tiddlers.length; i++)
  3086. tiddlers[i].changed();
  3087. }
  3088. }
  3089. TiddlyWiki.prototype.updateTiddlers = function()
  3090. {
  3091. this.tiddlersUpdated = true;
  3092. this.forEachTiddler(function(title,tiddler) {
  3093. tiddler.changed();
  3094. });
  3095. }
  3096. // Return all tiddlers formatted as an HTML string
  3097. TiddlyWiki.prototype.allTiddlersAsHtml = function()
  3098. {
  3099. return store.getSaver().externalize(store);
  3100. }
  3101. // Return an array of tiddlers matching a search regular expression
  3102. TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag)
  3103. {
  3104. var candidates = this.reverseLookup("tags",excludeTag,false);
  3105. var results = [];
  3106. for(var t=0; t<candidates.length; t++)
  3107. {
  3108. if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
  3109. results.push(candidates[t]);
  3110. }
  3111. if(!sortField)
  3112. sortField = "title";
  3113. results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
  3114. return results;
  3115. }
  3116. // Return an array of all the tags in use. Each member of the array is another array where [0] is the name of the tag and [1] is the number of occurances
  3117. TiddlyWiki.prototype.getTags = function()
  3118. {
  3119. var results = [];
  3120. this.forEachTiddler(function(title,tiddler) {
  3121. for(var g=0; g<tiddler.tags.length; g++)
  3122. {
  3123. var tag = tiddler.tags[g];
  3124. var f = false;
  3125. for(var c=0; c<results.length; c++)
  3126. if(results[c][0] == tag)
  3127. {
  3128. f = true;
  3129. results[c][1]++;
  3130. }
  3131. if(!f)
  3132. results.push([tag,1]);
  3133. }
  3134. });
  3135. results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
  3136. return results;
  3137. }
  3138. // Return an array of the tiddlers that are tagged with a given tag
  3139. TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
  3140. {
  3141. return this.reverseLookup("tags",tag,true,sortField);
  3142. }
  3143. // Return an array of the tiddlers that link to a given tiddler
  3144. TiddlyWiki.prototype.getReferringTiddlers = function(title,unusedParameter,sortField)
  3145. {
  3146. if(!this.tiddlersUpdated)
  3147. this.updateTiddlers();
  3148. return this.reverseLookup("links",title,true,sortField);
  3149. }
  3150. // Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
  3151. // lookupMatch == true to match tiddlers, false to exclude tiddlers
  3152. TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
  3153. {
  3154. var results = [];
  3155. this.forEachTiddler(function(title,tiddler) {
  3156. var f = !lookupMatch;
  3157. for(var lookup=0; lookup<tiddler[lookupField].length; lookup++)
  3158. if(tiddler[lookupField][lookup] == lookupValue)
  3159. f = lookupMatch;
  3160. if(f)
  3161. results.push(tiddler);
  3162. });
  3163. if(!sortField)
  3164. sortField = "title";
  3165. results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
  3166. return results;
  3167. }
  3168. // Return the tiddlers as a sorted array
  3169. TiddlyWiki.prototype.getTiddlers = function(field,excludeTag)
  3170. {
  3171. var results = [];
  3172. this.forEachTiddler(function(title,tiddler) {
  3173. if(excludeTag == undefined || !tiddler.isTagged(excludeTag))
  3174. results.push(tiddler);
  3175. });
  3176. if(field)
  3177. results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);});
  3178. return results;
  3179. }
  3180. // Return array of names of tiddlers that are referred to but not defined
  3181. TiddlyWiki.prototype.getMissingLinks = function(sortField)
  3182. {
  3183. if(!this.tiddlersUpdated)
  3184. this.updateTiddlers();
  3185. var results = [];
  3186. this.forEachTiddler(function (title,tiddler) {
  3187. for(var n=0; n<tiddler.links.length;n++)
  3188. {
  3189. var link = tiddler.links[n];
  3190. if(this.fetchTiddler(link) == null && !this.isShadowTiddler(link))
  3191. results.pushUnique(link);
  3192. }
  3193. });
  3194. results.sort();
  3195. return results;
  3196. }
  3197. // Return an array of names of tiddlers that are defined but not referred to
  3198. TiddlyWiki.prototype.getOrphans = function()
  3199. {
  3200. var results = [];
  3201. this.forEachTiddler(function (title,tiddler) {
  3202. if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists"))
  3203. results.push(title);
  3204. });
  3205. results.sort();
  3206. return results;
  3207. }
  3208. // Return an array of names of all the shadow tiddlers
  3209. TiddlyWiki.prototype.getShadowed = function()
  3210. {
  3211. var results = [];
  3212. for(var t in config.shadowTiddlers)
  3213. if(typeof config.shadowTiddlers[t] == "string")
  3214. results.push(t);
  3215. results.sort();
  3216. return results;
  3217. }
  3218. // Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist
  3219. TiddlyWiki.prototype.resolveTiddler = function(tiddler)
  3220. {
  3221. var t = (typeof tiddler == 'string') ? this.getTiddler(tiddler) : tiddler;
  3222. return t instanceof Tiddler ? t : null;
  3223. }
  3224. TiddlyWiki.prototype.getLoader = function()
  3225. {
  3226. if (!this.loader)
  3227. this.loader = new TW21Loader();
  3228. return this.loader;
  3229. }
  3230. TiddlyWiki.prototype.getSaver = function()
  3231. {
  3232. if (!this.saver)
  3233. this.saver = new TW21Saver();
  3234. return this.saver;
  3235. }
  3236. // Returns true if path is a valid field name (path),
  3237. // i.e. a sequence of identifiers, separated by '.'
  3238. TiddlyWiki.isValidFieldName = function (name) {
  3239. var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name);
  3240. return match && (match[0] == name);
  3241. }
  3242. // Throws an exception when name is not a valid field name.
  3243. TiddlyWiki.checkFieldName = function(name) {
  3244. if (!TiddlyWiki.isValidFieldName(name))
  3245. throw config.messages.invalidFieldName.format([name]);
  3246. }
  3247. function StringFieldAccess(n, readOnly) {
  3248. this.set = readOnly
  3249. ? function(t,v) {if (v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);}
  3250. : function(t,v) {if (v != t[n]) {t[n] = v; return true;}};
  3251. this.get = function(t) {return t[n];};
  3252. }
  3253. function DateFieldAccess(n) {
  3254. this.set = function(t,v) {
  3255. var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v);
  3256. if (d != t[n]) {
  3257. t[n] = d; return true;
  3258. }
  3259. };
  3260. this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();}
  3261. }
  3262. function LinksFieldAccess(n) {
  3263. this.set = function(t,v) {
  3264. var s = (typeof v == "string") ? v.readBracketedList() : v;
  3265. if (s.toString() != t[n].toString()) {
  3266. t[n] = s; return true;
  3267. }
  3268. };
  3269. this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);}
  3270. }
  3271. TiddlyWiki.standardFieldAccess = {
  3272. // The set functions return true when setting the data has changed the value.
  3273. "title": new StringFieldAccess("title", true),
  3274. // Handle the "tiddler" field name as the title
  3275. "tiddler": new StringFieldAccess("title", true),
  3276. "text": new StringFieldAccess("text"),
  3277. "modifier": new StringFieldAccess("modifier"),
  3278. "modified": new DateFieldAccess("modified"),
  3279. "created": new DateFieldAccess("created"),
  3280. "tags": new LinksFieldAccess("tags")
  3281. };
  3282. TiddlyWiki.isStandardField = function(name) {
  3283. return TiddlyWiki.standardFieldAccess[name] != undefined;
  3284. }
  3285. // Sets the value of the given field of the tiddler to the value.
  3286. // Setting an ExtendedField's value to null or undefined removes the field.
  3287. // Setting a namespace to undefined removes all fields of that namespace.
  3288. // The fieldName is case-insensitive.
  3289. // All values will be converted to a string value.
  3290. TiddlyWiki.prototype.setValue = function(tiddler, fieldName, value) {
  3291. TiddlyWiki.checkFieldName(fieldName);
  3292. var t = this.resolveTiddler(tiddler);
  3293. if (!t)
  3294. return;
  3295. fieldName = fieldName.toLowerCase();
  3296. var isRemove = (value === undefined) || (value === null);
  3297. if (!t.fields)
  3298. t.fields = {};
  3299. var accessor = TiddlyWiki.standardFieldAccess[fieldName];
  3300. if (accessor) {
  3301. if (isRemove)
  3302. // don't remove StandardFields
  3303. return;
  3304. var h = TiddlyWiki.standardFieldAccess[fieldName];
  3305. if (!h.set(t, value))
  3306. return;
  3307. } else {
  3308. var oldValue = t.fields[fieldName];
  3309. if (isRemove) {
  3310. if (oldValue !== undefined) {
  3311. // deletes a single field
  3312. delete t.fields[fieldName];
  3313. } else {
  3314. // no concrete value is defined for the fieldName
  3315. // so we guess this is a namespace path.
  3316. // delete all fields in a namespace
  3317. var re = new RegExp('^'+fieldName+'\\.');
  3318. var dirty = false;
  3319. for (var n in t.fields) {
  3320. if (n.match(re)) {
  3321. delete t.fields[n];
  3322. dirty = true;
  3323. }
  3324. }
  3325. if (!dirty)
  3326. return
  3327. }
  3328. } else {
  3329. // the "normal" set case. value is defined (not null/undefined)
  3330. // For convenience provide a nicer conversion Date->String
  3331. value = value instanceof Date
  3332. ? value.convertToYYYYMMDDHHMMSSMMM()
  3333. : String(value);
  3334. if (oldValue == value)
  3335. return;
  3336. t.fields[fieldName] = value;
  3337. }
  3338. }
  3339. // When we are here the tiddler/store really was changed.
  3340. this.notify(t.title,true);
  3341. if (!fieldName.match(/^temp\./))
  3342. this.setDirty(true);
  3343. }
  3344. // Returns the value of the given field of the tiddler.
  3345. // The fieldName is case-insensitive.
  3346. // Will only return String values (or undefined).
  3347. TiddlyWiki.prototype.getValue = function(tiddler, fieldName) {
  3348. var t = this.resolveTiddler(tiddler);
  3349. if (!t)
  3350. return undefined;
  3351. fieldName = fieldName.toLowerCase();
  3352. var accessor = TiddlyWiki.standardFieldAccess[fieldName];
  3353. if (accessor) {
  3354. return accessor.get(t);
  3355. }
  3356. return t.fields ? t.fields[fieldName] : undefined;
  3357. }
  3358. // Calls the callback function for every field in the tiddler.
  3359. //
  3360. // When callback function returns a non-false value the iteration stops
  3361. // and that value is returned.
  3362. //
  3363. // The order of the fields is not defined.
  3364. //
  3365. // @param callback a function(tiddler, fieldName, value).
  3366. //
  3367. TiddlyWiki.prototype.forEachField = function(tiddler, callback, onlyExtendedFields) {
  3368. var t = this.resolveTiddler(tiddler);
  3369. if (!t)
  3370. return undefined;
  3371. if (t.fields) {
  3372. for (var n in t.fields) {
  3373. var result = callback(t, n, t.fields[n]);
  3374. if (result)
  3375. return result;
  3376. }
  3377. }
  3378. if (onlyExtendedFields)
  3379. return undefined;
  3380. for (var n in TiddlyWiki.standardFieldAccess) {
  3381. if (n == "tiddler")
  3382. // even though the "title" field can also be referenced through the name "tiddler"
  3383. // we only visit this field once.
  3384. continue;
  3385. var result = callback(t, n, TiddlyWiki.standardFieldAccess[n].get(t));
  3386. if (result)
  3387. return result;
  3388. }
  3389. return undefined;
  3390. };
  3391. // ---------------------------------------------------------------------------------
  3392. // Story functions
  3393. // ---------------------------------------------------------------------------------
  3394. // A story is a HTML div containing a sequence of tiddlers that can be manipulated
  3395. // container - id of containing element
  3396. // idPrefix - string prefix prepended to title to make ids for tiddlers in this story
  3397. function Story(container,idPrefix)
  3398. {
  3399. this.container = container;
  3400. this.idPrefix = idPrefix;
  3401. this.highlightRegExp = null;
  3402. }
  3403. // Iterate through all the tiddlers in a story
  3404. // fn - callback function to be called for each tiddler. Arguments are:
  3405. // tiddler - reference to Tiddler object
  3406. // element - reference to tiddler display element
  3407. Story.prototype.forEachTiddler = function(fn)
  3408. {
  3409. var place = document.getElementById(this.container);
  3410. if(!place)
  3411. return;
  3412. var e = place.firstChild;
  3413. while(e)
  3414. {
  3415. var n = e.nextSibling;
  3416. var title = e.getAttribute("tiddler");
  3417. fn.call(this,title,e);
  3418. e = n;
  3419. }
  3420. }
  3421. // Display several tiddlers given their titles in an array. Parameters same as displayTiddler(), except:
  3422. // titles - array of string titles
  3423. Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,slowly)
  3424. {
  3425. for(var t = titles.length-1;t>=0;t--)
  3426. this.displayTiddler(srcElement,titles[t],template,animate,slowly);
  3427. }
  3428. // Display a given tiddler with a given template. If the tiddler is already displayed but with a different
  3429. // template, it is switched to the specified template
  3430. // srcElement - reference to element from which this one is being opened -or-
  3431. // special positions "top", "bottom"
  3432. // title - title of tiddler to display
  3433. // template - the name of the tiddler containing the template -or-
  3434. // one of the constants DEFAULT_VIEW_TEMPLATE and DEFAULT_EDIT_TEMPLATE -or-
  3435. // null or undefined to indicate the current template if there is one, DEFAULT_VIEW_TEMPLATE if not
  3436. // animate - whether to perform animations
  3437. // slowly - whether to perform animations in slomo
  3438. Story.prototype.displayTiddler = function(srcElement,title,template,animate,slowly)
  3439. {
  3440. var place = document.getElementById(this.container);
  3441. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3442. if(tiddlerElem)
  3443. this.refreshTiddler(title,template);
  3444. else
  3445. {
  3446. var before = this.positionTiddler(srcElement);
  3447. tiddlerElem = this.createTiddler(place,before,title,template);
  3448. }
  3449. if(srcElement && typeof srcElement !== "string")
  3450. {
  3451. if(anim && config.options.chkAnimate && (animate == undefined || animate == true))
  3452. anim.startAnimating(new Cascade(title,srcElement,tiddlerElem,slowly),new Scroller(tiddlerElem,slowly));
  3453. else
  3454. window.scrollTo(0,ensureVisible(tiddlerElem));
  3455. }
  3456. }
  3457. // Figure out the appropriate position for a newly opened tiddler
  3458. // srcElement - reference to the element containing the link to the tiddler -or-
  3459. // special positions "top", "bottom"
  3460. // returns - reference to the tiddler that the new one should appear before (null for the bottom of the story)
  3461. Story.prototype.positionTiddler = function(srcElement)
  3462. {
  3463. var place = document.getElementById(this.container);
  3464. var before;
  3465. if(typeof srcElement == "string")
  3466. {
  3467. switch(srcElement)
  3468. {
  3469. case "top":
  3470. before = place.firstChild;
  3471. break;
  3472. case "bottom":
  3473. before = null;
  3474. break;
  3475. }
  3476. }
  3477. else
  3478. {
  3479. var after = this.findContainingTiddler(srcElement);
  3480. if(after == null)
  3481. before = place.firstChild;
  3482. else if(after.nextSibling)
  3483. before = after.nextSibling;
  3484. else
  3485. before = null;
  3486. }
  3487. return before;
  3488. }
  3489. // Create a tiddler frame at the appropriate place in a story column
  3490. // place - reference to parent element
  3491. // before - null, or reference to element before which to insert new tiddler
  3492. // title - title of new tiddler
  3493. // template - the name of the tiddler containing the template or one of the constants DEFAULT_VIEW_TEMPLATE and DEFAULT_EDIT_TEMPLATE
  3494. Story.prototype.createTiddler = function(place,before,title,template)
  3495. {
  3496. var tiddlerElem = createTiddlyElement(null,"div",this.idPrefix + title,"tiddler");
  3497. tiddlerElem.setAttribute("refresh","tiddler");
  3498. place.insertBefore(tiddlerElem,before);
  3499. this.refreshTiddler(title,template);
  3500. return tiddlerElem;
  3501. }
  3502. // Overridable for choosing the name of the template to apply for a tiddler
  3503. Story.prototype.chooseTemplateForTiddler = function(title,template)
  3504. {
  3505. if(!template)
  3506. template = DEFAULT_VIEW_TEMPLATE;
  3507. if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE)
  3508. template = config.tiddlerTemplates[template];
  3509. return template;
  3510. }
  3511. // Overridable for extracting the text of a template from a tiddler
  3512. Story.prototype.getTemplateForTiddler = function(title,template,tiddler)
  3513. {
  3514. return store.getRecursiveTiddlerText(template,null,10);
  3515. }
  3516. // Apply a template to an existing tiddler if it is not already displayed using that template
  3517. // title - title of tiddler to update
  3518. // template - the name of the tiddler containing the template or one of the constants DEFAULT_VIEW_TEMPLATE and DEFAULT_EDIT_TEMPLATE
  3519. // force - if true, forces the refresh even if the template hasn't changedd
  3520. Story.prototype.refreshTiddler = function(title,template,force)
  3521. {
  3522. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3523. if(tiddlerElem)
  3524. {
  3525. if(tiddlerElem.getAttribute("dirty") == "true" && !force)
  3526. return tiddlerElem;
  3527. template = this.chooseTemplateForTiddler(title,template);
  3528. var currTemplate = tiddlerElem.getAttribute("template");
  3529. if((template != currTemplate) || force)
  3530. {
  3531. var tiddler = store.getTiddler(title);
  3532. if(!tiddler)
  3533. {
  3534. tiddler = new Tiddler();
  3535. if(store.isShadowTiddler(title))
  3536. tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,[],version.date);
  3537. else
  3538. {
  3539. var text = template=="EditTemplate"
  3540. ? config.views.editor.defaultText.format([title])
  3541. : config.views.wikified.defaultText.format([title]);
  3542. tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date);
  3543. }
  3544. }
  3545. tiddlerElem.setAttribute("tags",tiddler.tags.join(" "));
  3546. tiddlerElem.setAttribute("tiddler",title);
  3547. tiddlerElem.setAttribute("template",template);
  3548. var me = this;
  3549. tiddlerElem.onmouseover = this.onTiddlerMouseOver;
  3550. tiddlerElem.onmouseout = this.onTiddlerMouseOut;
  3551. tiddlerElem.ondblclick = this.onTiddlerDblClick;
  3552. tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress;
  3553. var html = this.getTemplateForTiddler(title,template,tiddler);
  3554. tiddlerElem.innerHTML = html;
  3555. applyHtmlMacros(tiddlerElem,tiddler);
  3556. if(store.getTaggedTiddlers(title).length > 0)
  3557. addClass(tiddlerElem,"isTag");
  3558. else
  3559. removeClass(tiddlerElem,"isTag");
  3560. if(!store.tiddlerExists(title))
  3561. {
  3562. if(store.isShadowTiddler(title))
  3563. addClass(tiddlerElem,"shadow");
  3564. else
  3565. addClass(tiddlerElem,"missing");
  3566. }
  3567. else
  3568. {
  3569. removeClass(tiddlerElem,"shadow");
  3570. removeClass(tiddlerElem,"missing");
  3571. }
  3572. }
  3573. }
  3574. return tiddlerElem;
  3575. }
  3576. // Refresh all tiddlers in the Story
  3577. Story.prototype.refreshAllTiddlers = function()
  3578. {
  3579. var place = document.getElementById(this.container);
  3580. var e = place.firstChild;
  3581. if(!e)
  3582. return;
  3583. this.refreshTiddler(e.getAttribute("tiddler"),e.getAttribute("template"),true);
  3584. while((e = e.nextSibling) != null)
  3585. this.refreshTiddler(e.getAttribute("tiddler"),e.getAttribute("template"),true);
  3586. }
  3587. // Default tiddler onmouseover/out event handlers
  3588. Story.prototype.onTiddlerMouseOver = function(e)
  3589. {
  3590. if(window.addClass instanceof Function)
  3591. addClass(this,"selected");
  3592. }
  3593. Story.prototype.onTiddlerMouseOut = function(e)
  3594. {
  3595. if(window.removeClass instanceof Function)
  3596. removeClass(this,"selected");
  3597. }
  3598. // Default tiddler ondblclick event handler
  3599. Story.prototype.onTiddlerDblClick = function(e)
  3600. {
  3601. if(!e) var e = window.event;
  3602. var theTarget = resolveTarget(e);
  3603. if(theTarget && theTarget.nodeName.toLowerCase() != "input" && theTarget.nodeName.toLowerCase() != "textarea")
  3604. {
  3605. if(document.selection && document.selection.empty)
  3606. document.selection.empty();
  3607. config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
  3608. e.cancelBubble = true;
  3609. if (e.stopPropagation) e.stopPropagation();
  3610. return true;
  3611. }
  3612. else
  3613. return false;
  3614. }
  3615. Story.prototype.onTiddlerKeyPress = function(e)
  3616. {
  3617. if(!e) var e = window.event;
  3618. clearMessage();
  3619. var consume = false;
  3620. var title = this.getAttribute("tiddler");
  3621. var target = resolveTarget(e);
  3622. switch(e.keyCode)
  3623. {
  3624. case 9: // Tab
  3625. if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea")
  3626. {
  3627. replaceSelection(target,String.fromCharCode(9));
  3628. consume = true;
  3629. }
  3630. if(config.isOpera)
  3631. {
  3632. target.onblur = function()
  3633. {
  3634. this.focus();
  3635. this.onblur = null;
  3636. }
  3637. }
  3638. break;
  3639. case 13: // Ctrl-Enter
  3640. case 10: // Ctrl-Enter on IE PC
  3641. case 77: // Ctrl-Enter is "M" on some platforms
  3642. if(e.ctrlKey)
  3643. {
  3644. blurElement(this);
  3645. config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
  3646. consume = true;
  3647. }
  3648. break;
  3649. case 27: // Escape
  3650. blurElement(this);
  3651. config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
  3652. consume = true;
  3653. break;
  3654. }
  3655. e.cancelBubble = consume;
  3656. if(consume)
  3657. {
  3658. if(e.stopPropagation) e.stopPropagation(); // Stop Propagation
  3659. e.returnValue = true; // Cancel The Event in IE
  3660. if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz
  3661. }
  3662. return(!consume);
  3663. };
  3664. // Returns the specified field (input or textarea element) in a tiddler, otherwise the first edit field it finds
  3665. // or null if it found no edit field at all
  3666. Story.prototype.getTiddlerField = function(title,field)
  3667. {
  3668. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3669. var e = null;
  3670. if(tiddlerElem != null)
  3671. {
  3672. var children = tiddlerElem.getElementsByTagName("*");
  3673. for (var t=0; t<children.length; t++)
  3674. {
  3675. var c = children[t];
  3676. if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea")
  3677. {
  3678. if(!e)
  3679. e = c;
  3680. if(c.getAttribute("edit") == field)
  3681. e = c;
  3682. }
  3683. }
  3684. }
  3685. return e;
  3686. }
  3687. // Focus a specified tiddler. Attempts to focus the specified field, otherwise the first edit field it finds
  3688. Story.prototype.focusTiddler = function(title,field)
  3689. {
  3690. var e = this.getTiddlerField(title,field);
  3691. if(e)
  3692. {
  3693. e.focus();
  3694. e.select();
  3695. }
  3696. }
  3697. // Ensures that a specified tiddler does not have the focus
  3698. Story.prototype.blurTiddler = function(title)
  3699. {
  3700. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3701. if(tiddlerElem != null && tiddlerElem.focus && tiddlerElem.blur)
  3702. {
  3703. tiddlerElem.focus();
  3704. tiddlerElem.blur();
  3705. }
  3706. }
  3707. // Adds a specified value to the edit controls (if any) of a particular
  3708. // array-formatted field of a particular tiddler (eg "tags")
  3709. // title - name of tiddler
  3710. // tag - value of field, without any [[brackets]]
  3711. // mode - +1 to add the tag, -1 to remove it, 0 to toggle it
  3712. // field - name of field (eg "tags")
  3713. Story.prototype.setTiddlerField = function(title,tag,mode,field)
  3714. {
  3715. var c = story.getTiddlerField(title,field);
  3716. var tags = c.value.readBracketedList();
  3717. tags.setItem(tag,mode);
  3718. c.value = String.encodeTiddlyLinkList(tags);
  3719. }
  3720. // The same as setTiddlerField but preset to the "tags" field
  3721. Story.prototype.setTiddlerTag = function(title,tag,mode)
  3722. {
  3723. Story.prototype.setTiddlerField(title,tag,mode,"tags");
  3724. }
  3725. // Close a specified tiddler
  3726. // title - name of tiddler to close
  3727. // animate - whether to perform animations
  3728. // slowly - whether to perform animations in slomo
  3729. Story.prototype.closeTiddler = function(title,animate,slowly)
  3730. {
  3731. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3732. if(tiddlerElem != null)
  3733. {
  3734. clearMessage();
  3735. this.scrubTiddler(tiddlerElem);
  3736. if(anim && config.options.chkAnimate && animate)
  3737. anim.startAnimating(new Slider(tiddlerElem,false,slowly,"all"));
  3738. else
  3739. tiddlerElem.parentNode.removeChild(tiddlerElem);
  3740. }
  3741. }
  3742. // Scrub IDs from a tiddler. This is so that the 'ghost' of a tiddler while it is being closed
  3743. // does not interfere with things
  3744. // tiddler - reference to the tiddler element
  3745. Story.prototype.scrubTiddler = function(tiddlerElem)
  3746. {
  3747. tiddlerElem.id = null;
  3748. }
  3749. // Set the 'dirty' flag of a tiddler
  3750. // title - title of tiddler to change
  3751. // dirty - new boolean status of flag
  3752. Story.prototype.setDirty = function(title,dirty)
  3753. {
  3754. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3755. if(tiddlerElem != null)
  3756. tiddlerElem.setAttribute("dirty",dirty ? "true" : "false");
  3757. }
  3758. // Is a particular tiddler dirty (with unsaved changes)?
  3759. Story.prototype.isDirty = function(title)
  3760. {
  3761. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3762. if(tiddlerElem != null)
  3763. return tiddlerElem.getAttribute("dirty") == "true";
  3764. return null;
  3765. }
  3766. // Determine whether any open tiddler are dirty
  3767. Story.prototype.areAnyDirty = function()
  3768. {
  3769. var r = false;
  3770. this.forEachTiddler(function(title,element) {
  3771. if(this.isDirty(title))
  3772. r = true;
  3773. });
  3774. return r;
  3775. }
  3776. // Close all tiddlers in the story
  3777. Story.prototype.closeAllTiddlers = function(exclude)
  3778. {
  3779. clearMessage();
  3780. this.forEachTiddler(function(title,element) {
  3781. if((title != exclude) && element.getAttribute("dirty") != "true")
  3782. this.closeTiddler(title);
  3783. });
  3784. window.scrollTo(0,0);
  3785. }
  3786. // Check if there are any tiddlers in the story
  3787. Story.prototype.isEmpty = function()
  3788. {
  3789. var place = document.getElementById(this.container);
  3790. return(place && place.firstChild == null);
  3791. }
  3792. // Perform a search and display the result
  3793. // text - text to search for
  3794. // useCaseSensitive - true for case sensitive matching
  3795. // useRegExp - true to interpret text as a RegExp
  3796. Story.prototype.search = function(text,useCaseSensitive,useRegExp)
  3797. {
  3798. this.closeAllTiddlers();
  3799. highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img");
  3800. var matches = store.search(highlightHack,"title","excludeSearch");
  3801. var titles = [];
  3802. for(var t=matches.length-1; t>=0; t--)
  3803. titles.push(matches[t].title);
  3804. this.displayTiddlers(null,titles);
  3805. highlightHack = null;
  3806. var q = useRegExp ? "/" : "'";
  3807. if(matches.length > 0)
  3808. displayMessage(config.macros.search.successMsg.format([titles.length.toString(),q + text + q]));
  3809. else
  3810. displayMessage(config.macros.search.failureMsg.format([q + text + q]));
  3811. }
  3812. // Determine if the specified element is within a tiddler in this story
  3813. // e - reference to an element
  3814. // returns: reference to a tiddler element or null if none
  3815. Story.prototype.findContainingTiddler = function(e)
  3816. {
  3817. while(e && !hasClass(e,"tiddler"))
  3818. e = e.parentNode;
  3819. return(e);
  3820. }
  3821. // Gather any saveable fields from a tiddler element
  3822. // e - reference to an element to scan recursively
  3823. // fields - object to contain gathered field values
  3824. Story.prototype.gatherSaveFields = function(e,fields)
  3825. {
  3826. if(e && e.getAttribute)
  3827. {
  3828. var f = e.getAttribute("edit");
  3829. if(f)
  3830. fields[f] = e.value.replace(/\r/mg,"");;
  3831. if(e.hasChildNodes())
  3832. {
  3833. var c = e.childNodes;
  3834. for(var t=0; t<c.length; t++)
  3835. this.gatherSaveFields(c[t],fields)
  3836. }
  3837. }
  3838. }
  3839. // Determine whether a tiddler has any edit fields, and if so if their values have been changed
  3840. // title - name of tiddler
  3841. Story.prototype.hasChanges = function(title)
  3842. {
  3843. var e = document.getElementById(this.idPrefix + title);
  3844. if(e != null)
  3845. {
  3846. var fields = {};
  3847. this.gatherSaveFields(e,fields);
  3848. var tiddler = store.fetchTiddler(title);
  3849. if (!tiddler)
  3850. return false;
  3851. for(var n in fields)
  3852. if (store.getValue(title,n) != fields[n])
  3853. return true;
  3854. }
  3855. return false;
  3856. }
  3857. // Save any open edit fields of a tiddler and updates the display as necessary
  3858. // title - name of tiddler
  3859. // minorUpdate - true if the modified date shouldn't be updated
  3860. // returns: title of saved tiddler, or null if not saved
  3861. Story.prototype.saveTiddler = function(title,minorUpdate)
  3862. {
  3863. var tiddlerElem = document.getElementById(this.idPrefix + title);
  3864. if(tiddlerElem != null)
  3865. {
  3866. var fields = {};
  3867. this.gatherSaveFields(tiddlerElem,fields);
  3868. var newTitle = fields.title ? fields.title : title;
  3869. if(store.tiddlerExists(newTitle) && newTitle != title)
  3870. {
  3871. if(confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
  3872. this.closeTiddler(newTitle,false,false);
  3873. else
  3874. return null;
  3875. }
  3876. tiddlerElem.id = this.idPrefix + newTitle;
  3877. tiddlerElem.setAttribute("tiddler",newTitle);
  3878. tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE);
  3879. tiddlerElem.setAttribute("dirty","false");
  3880. if(config.options.chkForceMinorUpdate)
  3881. minorUpdate = !minorUpdate;
  3882. var newDate = new Date();
  3883. store.saveTiddler(title,newTitle,fields.text,config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags);
  3884. for (var n in fields)
  3885. if (!TiddlyWiki.isStandardField(n))
  3886. store.setValue(newTitle,n,fields[n]);
  3887. if(config.options.chkAutoSave)
  3888. saveChanges();
  3889. return newTitle;
  3890. }
  3891. return null;
  3892. }
  3893. Story.prototype.permaView = function()
  3894. {
  3895. var links = [];
  3896. this.forEachTiddler(function(title,element) {
  3897. links.push(String.encodeTiddlyLink(title));
  3898. });
  3899. var t = encodeURIComponent(links.join(" "));
  3900. if(t == "")
  3901. t = "#";
  3902. if(window.location.hash != t)
  3903. window.location.hash = t;
  3904. }
  3905. // ---------------------------------------------------------------------------------
  3906. // Message area
  3907. // ---------------------------------------------------------------------------------
  3908. function getMessageDiv()
  3909. {
  3910. var msgArea = document.getElementById("messageArea");
  3911. if(!msgArea)
  3912. return null;
  3913. if(!msgArea.hasChildNodes())
  3914. createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"),
  3915. config.messages.messageClose.text,
  3916. config.messages.messageClose.tooltip,
  3917. clearMessage);
  3918. msgArea.style.display = "block";
  3919. return createTiddlyElement(msgArea,"div");
  3920. }
  3921. function displayMessage(text,linkText)
  3922. {
  3923. var e = getMessageDiv();
  3924. if(!e)
  3925. {
  3926. alert(text);
  3927. return;
  3928. }
  3929. if(linkText)
  3930. {
  3931. var link = createTiddlyElement(e,"a",null,null,text);
  3932. link.href = linkText;
  3933. link.target = "_blank";
  3934. }
  3935. else
  3936. e.appendChild(document.createTextNode(text));
  3937. }
  3938. function clearMessage()
  3939. {
  3940. var msgArea = document.getElementById("messageArea");
  3941. if(msgArea)
  3942. {
  3943. removeChildren(msgArea);
  3944. msgArea.style.display = "none";
  3945. }
  3946. return false;
  3947. }
  3948. // ---------------------------------------------------------------------------------
  3949. // Refresh mechanism
  3950. // ---------------------------------------------------------------------------------
  3951. config.refreshers = {
  3952. link: function(e,changeList)
  3953. {
  3954. var title = e.getAttribute("tiddlyLink");
  3955. refreshTiddlyLink(e,title);
  3956. return true;
  3957. },
  3958. tiddler: function(e,changeList)
  3959. {
  3960. var title = e.getAttribute("tiddler");
  3961. var template = e.getAttribute("template");
  3962. if(changeList && changeList.indexOf(title) != -1 && !story.isDirty(title))
  3963. story.refreshTiddler(title,template,true);
  3964. else
  3965. refreshElements(e,changeList);
  3966. return true;
  3967. },
  3968. content: function(e,changeList)
  3969. {
  3970. var title = e.getAttribute("tiddler");
  3971. var force = e.getAttribute("force");
  3972. if(force != null || changeList == null || changeList.indexOf(title) != -1)
  3973. {
  3974. removeChildren(e);
  3975. wikify(store.getTiddlerText(title,title),e);
  3976. return true;
  3977. }
  3978. else
  3979. return false;
  3980. },
  3981. macro: function(e,changeList)
  3982. {
  3983. var macro = e.getAttribute("macroName");
  3984. var params = e.getAttribute("params");
  3985. if(macro)
  3986. macro = config.macros[macro];
  3987. if(macro && macro.refresh)
  3988. macro.refresh(e,params);
  3989. return true;
  3990. }
  3991. };
  3992. function refreshElements(root,changeList)
  3993. {
  3994. var nodes = root.childNodes;
  3995. for(var c=0; c<nodes.length; c++)
  3996. {
  3997. var e = nodes[c],type;
  3998. if(e.getAttribute)
  3999. type = e.getAttribute("refresh");
  4000. else
  4001. type = null;
  4002. var refresher = config.refreshers[type];
  4003. var refreshed = false;
  4004. if(refresher != undefined)
  4005. refreshed = refresher(e,changeList);
  4006. if(e.hasChildNodes() && !refreshed)
  4007. refreshElements(e,changeList);
  4008. }
  4009. }
  4010. function applyHtmlMacros(root,tiddler)
  4011. {
  4012. var e = root.firstChild;
  4013. while(e)
  4014. {
  4015. var nextChild = e.nextSibling;
  4016. if(e.getAttribute)
  4017. {
  4018. var macro = e.getAttribute("macro");
  4019. if(macro)
  4020. {
  4021. var params = "";
  4022. var p = macro.indexOf(" ");
  4023. if(p != -1)
  4024. {
  4025. params = macro.substr(p+1);
  4026. macro = macro.substr(0,p);
  4027. }
  4028. invokeMacro(e,macro,params,null,tiddler);
  4029. }
  4030. }
  4031. if(e.hasChildNodes())
  4032. applyHtmlMacros(e,tiddler);
  4033. e = nextChild;
  4034. }
  4035. }
  4036. function refreshPageTemplate(title)
  4037. {
  4038. var stash = createTiddlyElement(document.body,"div");
  4039. stash.style.display = "none";
  4040. var display = document.getElementById("tiddlerDisplay");
  4041. var nodes,t;
  4042. if(display)
  4043. {
  4044. nodes = display.childNodes;
  4045. for(t=nodes.length-1; t>=0; t--)
  4046. stash.appendChild(nodes[t]);
  4047. }
  4048. var wrapper = document.getElementById("contentWrapper");
  4049. if(!title)
  4050. title = "PageTemplate";
  4051. var html = store.getRecursiveTiddlerText(title,null,10);
  4052. wrapper.innerHTML = html;
  4053. applyHtmlMacros(wrapper);
  4054. refreshElements(wrapper);
  4055. display = document.getElementById("tiddlerDisplay");
  4056. removeChildren(display);
  4057. if(!display)
  4058. display = createTiddlyElement(wrapper,"div","tiddlerDisplay");
  4059. nodes = stash.childNodes;
  4060. for(t=nodes.length-1; t>=0; t--)
  4061. display.appendChild(nodes[t]);
  4062. stash.parentNode.removeChild(stash);
  4063. }
  4064. function refreshDisplay(hint)
  4065. {
  4066. var e = document.getElementById("contentWrapper");
  4067. if(typeof hint == "string")
  4068. hint = [hint];
  4069. refreshElements(e,hint);
  4070. }
  4071. function refreshPageTitle()
  4072. {
  4073. document.title = wikifyPlain("SiteTitle") + " - " + wikifyPlain("SiteSubtitle");
  4074. }
  4075. function refreshStyles(title)
  4076. {
  4077. setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title);
  4078. }
  4079. function refreshColorPalette(title)
  4080. {
  4081. if(!startingUp)
  4082. refreshAll();
  4083. }
  4084. function refreshAll()
  4085. {
  4086. refreshPageTemplate();
  4087. refreshDisplay();
  4088. refreshStyles("StyleSheetLayout");
  4089. refreshStyles("StyleSheetColors");
  4090. refreshStyles("StyleSheet");
  4091. refreshStyles("StyleSheetPrint");
  4092. }
  4093. // ---------------------------------------------------------------------------------
  4094. // Options cookie stuff
  4095. // ---------------------------------------------------------------------------------
  4096. function loadOptionsCookie()
  4097. {
  4098. if(safeMode)
  4099. return;
  4100. var cookies = document.cookie.split(";");
  4101. for(var c=0; c<cookies.length; c++)
  4102. {
  4103. var p = cookies[c].indexOf("=");
  4104. if(p != -1)
  4105. {
  4106. var name = cookies[c].substr(0,p).trim();
  4107. var value = cookies[c].substr(p+1).trim();
  4108. switch(name.substr(0,3))
  4109. {
  4110. case "txt":
  4111. config.options[name] = unescape(value);
  4112. break;
  4113. case "chk":
  4114. config.options[name] = value == "true";
  4115. break;
  4116. }
  4117. }
  4118. }
  4119. }
  4120. function saveOptionCookie(name)
  4121. {
  4122. if(safeMode)
  4123. return;
  4124. var c = name + "=";
  4125. switch(name.substr(0,3))
  4126. {
  4127. case "txt":
  4128. c += escape(config.options[name].toString());
  4129. break;
  4130. case "chk":
  4131. c += config.options[name] ? "true" : "false";
  4132. break;
  4133. }
  4134. c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/";
  4135. document.cookie = c;
  4136. }
  4137. // ---------------------------------------------------------------------------------
  4138. // Saving
  4139. // ---------------------------------------------------------------------------------
  4140. var saveUsingSafari = false;
  4141. var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it
  4142. var endSaveArea = '</d' + 'iv>';
  4143. // If there are unsaved changes, force the user to confirm before exitting
  4144. function confirmExit()
  4145. {
  4146. hadConfirmExit = true;
  4147. if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty()))
  4148. return config.messages.confirmExit;
  4149. }
  4150. // Give the user a chance to save changes before exitting
  4151. function checkUnsavedChanges()
  4152. {
  4153. if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false)
  4154. {
  4155. if(confirm(config.messages.unsavedChangesWarning))
  4156. saveChanges();
  4157. }
  4158. }
  4159. function updateMarkupBlock(s,blockName,tiddlerName)
  4160. {
  4161. return s.replaceChunk(
  4162. "<!--%0-START-->".format([blockName]),
  4163. "<!--%0-END-->".format([blockName]),
  4164. "\n" + store.getRecursiveTiddlerText(tiddlerName,"") + "\n");
  4165. }
  4166. // Save this tiddlywiki with the pending changes
  4167. function saveChanges(onlyIfDirty)
  4168. {
  4169. if(onlyIfDirty && !store.isDirty())
  4170. return;
  4171. clearMessage();
  4172. // Get the URL of the document
  4173. var originalPath = document.location.toString();
  4174. // Check we were loaded from a file URL
  4175. if(originalPath.substr(0,5) != "file:")
  4176. {
  4177. alert(config.messages.notFileUrlError);
  4178. if(store.tiddlerExists(config.messages.saveInstructions))
  4179. story.displayTiddler(null,config.messages.saveInstructions);
  4180. return;
  4181. }
  4182. var localPath = getLocalPath(originalPath);
  4183. // Load the original file
  4184. var original = loadFile(localPath);
  4185. if(original == null)
  4186. {
  4187. alert(config.messages.cantSaveError);
  4188. if(store.tiddlerExists(config.messages.saveInstructions))
  4189. story.displayTiddler(null,config.messages.saveInstructions);
  4190. return;
  4191. }
  4192. // Locate the storeArea div's
  4193. var posOpeningDiv = original.indexOf(startSaveArea);
  4194. var limitClosingDiv = original.indexOf("<!--POST-BODY-START--"+">");
  4195. var posClosingDiv = original.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? original.length : limitClosingDiv);
  4196. if((posOpeningDiv == -1) || (posClosingDiv == -1))
  4197. {
  4198. alert(config.messages.invalidFileError.format([localPath]));
  4199. return;
  4200. }
  4201. // Save the backup
  4202. if(config.options.chkSaveBackups)
  4203. {
  4204. var backupPath = getBackupPath(localPath);
  4205. var backup = saveFile(backupPath,original);
  4206. if(backup)
  4207. displayMessage(config.messages.backupSaved,"file://" + backupPath);
  4208. else
  4209. alert(config.messages.backupFailed);
  4210. }
  4211. // Save Rss
  4212. if(config.options.chkGenerateAnRssFeed)
  4213. {
  4214. var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
  4215. var rssSave = saveFile(rssPath,convertUnicodeToUTF8(generateRss()));
  4216. if(rssSave)
  4217. displayMessage(config.messages.rssSaved,"file://" + rssPath);
  4218. else
  4219. alert(config.messages.rssFailed);
  4220. }
  4221. // Save empty template
  4222. if(config.options.chkSaveEmptyTemplate)
  4223. {
  4224. var emptyPath,p;
  4225. if((p = localPath.lastIndexOf("/")) != -1)
  4226. emptyPath = localPath.substr(0,p) + "/empty.html";
  4227. else if((p = localPath.lastIndexOf("\\")) != -1)
  4228. emptyPath = localPath.substr(0,p) + "\\empty.html";
  4229. else
  4230. emptyPath = localPath + ".empty.html";
  4231. var empty = original.substr(0,posOpeningDiv + startSaveArea.length) + original.substr(posClosingDiv);
  4232. var emptySave = saveFile(emptyPath,empty);
  4233. if(emptySave)
  4234. displayMessage(config.messages.emptySaved,"file://" + emptyPath);
  4235. else
  4236. alert(config.messages.emptyFailed);
  4237. }
  4238. var save;
  4239. try
  4240. {
  4241. // Save new file
  4242. var revised = original.substr(0,posOpeningDiv + startSaveArea.length) + "\n" +
  4243. convertUnicodeToUTF8(store.allTiddlersAsHtml()) + "\n" +
  4244. original.substr(posClosingDiv);
  4245. var newSiteTitle = convertUnicodeToUTF8((wikifyPlain("SiteTitle") + " - " + wikifyPlain("SiteSubtitle")).htmlEncode());
  4246. revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
  4247. revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
  4248. revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
  4249. revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
  4250. revised = updateMarkupBlock(revised,"POST-BODY","MarkupPostBody");
  4251. save = saveFile(localPath,revised);
  4252. }
  4253. catch (e)
  4254. {
  4255. showException(e);
  4256. }
  4257. if(save)
  4258. {
  4259. displayMessage(config.messages.mainSaved,"file://" + localPath);
  4260. store.setDirty(false);
  4261. }
  4262. else
  4263. alert(config.messages.mainFailed);
  4264. }
  4265. function getLocalPath(originalPath)
  4266. {
  4267. // Remove any location or query part of the URL
  4268. var argPos = originalPath.indexOf("?");
  4269. if(argPos != -1)
  4270. originalPath = originalPath.substr(0,argPos);
  4271. var hashPos = originalPath.indexOf("#");
  4272. if(hashPos != -1)
  4273. originalPath = originalPath.substr(0,hashPos);
  4274. // Convert file://localhost/ to file:///
  4275. if(originalPath.indexOf("file://localhost/") == 0)
  4276. originalPath = "file://" + originalPath.substr(16);
  4277. // Convert to a native file format assuming
  4278. // "file:///x:/path/path/path..." - pc local file --> "x:\path\path\path..."
  4279. // "file://///server/share/path/path/path..." - FireFox pc network file --> "\\server\share\path\path\path..."
  4280. // "file:///path/path/path..." - mac/unix local file --> "/path/path/path..."
  4281. // "file://server/share/path/path/path..." - pc network file --> "\\server\share\path\path\path..."
  4282. var localPath;
  4283. if(originalPath.charAt(9) == ":") // pc local file
  4284. localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
  4285. else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
  4286. localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
  4287. else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
  4288. localPath = unescape(originalPath.substr(7));
  4289. else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
  4290. localPath = unescape(originalPath.substr(5));
  4291. else // pc network file
  4292. localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
  4293. return localPath;
  4294. }
  4295. function getBackupPath(localPath)
  4296. {
  4297. var backSlash = true;
  4298. var dirPathPos = localPath.lastIndexOf("\\");
  4299. if(dirPathPos == -1)
  4300. {
  4301. dirPathPos = localPath.lastIndexOf("/");
  4302. backSlash = false;
  4303. }
  4304. var backupFolder = config.options.txtBackupFolder;
  4305. if(!backupFolder || backupFolder == "")
  4306. backupFolder = ".";
  4307. var backupPath = localPath.substr(0,dirPathPos) + (backSlash ? "\\" : "/") + backupFolder + localPath.substr(dirPathPos);
  4308. backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + "." + (new Date()).convertToYYYYMMDDHHMMSSMMM() + ".html";
  4309. return backupPath;
  4310. }
  4311. function generateRss()
  4312. {
  4313. var s = [];
  4314. var d = new Date();
  4315. var u = store.getTiddlerText("SiteUrl");
  4316. // Assemble the header
  4317. s.push("<" + "?xml version=\"1.0\"?" + ">");
  4318. s.push("<rss version=\"2.0\">");
  4319. s.push("<channel>");
  4320. s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">");
  4321. if(u)
  4322. s.push("<link>" + u.htmlEncode() + "</link>");
  4323. s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");
  4324. s.push("<language>en-us</language>");
  4325. s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
  4326. s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
  4327. s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
  4328. s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
  4329. s.push("<generator>TiddlyWiki " + version.major + "." + version.minor + "." + version.revision + "</generator>");
  4330. // The body
  4331. var tiddlers = store.getTiddlers("modified","excludeLists");
  4332. var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
  4333. for (var t=tiddlers.length-1; t>=n; t--)
  4334. s.push(tiddlers[t].saveToRss(u));
  4335. // And footer
  4336. s.push("</channel>");
  4337. s.push("</rss>");
  4338. // Save it all
  4339. return s.join("\n");
  4340. }
  4341. // UTF-8 encoding rules:
  4342. // 0x0000 - 0x007F: 0xxxxxxx
  4343. // 0x0080 - 0x07FF: 110xxxxx 10xxxxxx
  4344. // 0x0800 - 0xFFFF: 1110xxxx 10xxxxxx 10xxxxxx
  4345. function convertUTF8ToUnicode(u)
  4346. {
  4347. if(window.netscape == undefined)
  4348. return manualConvertUTF8ToUnicode(u);
  4349. else
  4350. return mozConvertUTF8ToUnicode(u);
  4351. }
  4352. function manualConvertUTF8ToUnicode(utf)
  4353. {
  4354. var uni = utf;
  4355. var src = 0;
  4356. var dst = 0;
  4357. var b1, b2, b3;
  4358. var c;
  4359. while(src < utf.length)
  4360. {
  4361. b1 = utf.charCodeAt(src++);
  4362. if(b1 < 0x80)
  4363. dst++;
  4364. else if(b1 < 0xE0)
  4365. {
  4366. b2 = utf.charCodeAt(src++);
  4367. c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F));
  4368. uni = uni.substring(0,dst++).concat(c,utf.substr(src));
  4369. }
  4370. else
  4371. {
  4372. b2 = utf.charCodeAt(src++);
  4373. b3 = utf.charCodeAt(src++);
  4374. c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F));
  4375. uni = uni.substring(0,dst++).concat(c,utf.substr(src));
  4376. }
  4377. }
  4378. return(uni);
  4379. }
  4380. function mozConvertUTF8ToUnicode(u)
  4381. {
  4382. try
  4383. {
  4384. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  4385. var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
  4386. converter.charset = "UTF-8";
  4387. }
  4388. catch(e)
  4389. {
  4390. return manualConvertUTF8ToUnicode(u);
  4391. } // fallback
  4392. var s = converter.ConvertToUnicode(u);
  4393. var fin = converter.Finish();
  4394. return (fin.length > 0) ? s+fin : s;
  4395. }
  4396. function convertUnicodeToUTF8(s)
  4397. {
  4398. if(window.netscape == undefined)
  4399. return manualConvertUnicodeToUTF8(s);
  4400. else
  4401. return mozConvertUnicodeToUTF8(s);
  4402. }
  4403. function manualConvertUnicodeToUTF8(s)
  4404. {
  4405. var re = /[^\u0000-\u007F]/g ;
  4406. return s.replace(re, function($0) {return("&#" + $0.charCodeAt(0).toString() + ";");})
  4407. }
  4408. function mozConvertUnicodeToUTF8(s)
  4409. {
  4410. try
  4411. {
  4412. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  4413. var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
  4414. converter.charset = "UTF-8";
  4415. }
  4416. catch(e)
  4417. {
  4418. return manualConvertUnicodeToUTF8(s);
  4419. } // fallback
  4420. var u = converter.ConvertFromUnicode(s);
  4421. var fin = converter.Finish();
  4422. if(fin.length > 0)
  4423. return u + fin;
  4424. else
  4425. return u;
  4426. }
  4427. function saveFile(fileUrl, content)
  4428. {
  4429. var r = null;
  4430. if((r == null) || (r == false))
  4431. r = mozillaSaveFile(fileUrl, content);
  4432. if((r == null) || (r == false))
  4433. r = ieSaveFile(fileUrl, content);
  4434. if((r == null) || (r == false))
  4435. r = javaSaveFile(fileUrl, content);
  4436. return(r);
  4437. }
  4438. function loadFile(fileUrl)
  4439. {
  4440. var r = null;
  4441. if((r == null) || (r == false))
  4442. r = mozillaLoadFile(fileUrl);
  4443. if((r == null) || (r == false))
  4444. r = ieLoadFile(fileUrl);
  4445. if((r == null) || (r == false))
  4446. r = javaLoadFile(fileUrl);
  4447. return(r);
  4448. }
  4449. // Returns null if it can't do it, false if there's an error, true if it saved OK
  4450. function ieSaveFile(filePath, content)
  4451. {
  4452. try
  4453. {
  4454. var fso = new ActiveXObject("Scripting.FileSystemObject");
  4455. }
  4456. catch(e)
  4457. {
  4458. //alert("Exception while attempting to save\n\n" + e.toString());
  4459. return(null);
  4460. }
  4461. var file = fso.OpenTextFile(filePath,2,-1,0);
  4462. file.Write(content);
  4463. file.Close();
  4464. return(true);
  4465. }
  4466. // Returns null if it can't do it, false if there's an error, or a string of the content if successful
  4467. function ieLoadFile(filePath)
  4468. {
  4469. try
  4470. {
  4471. var fso = new ActiveXObject("Scripting.FileSystemObject");
  4472. var file = fso.OpenTextFile(filePath,1);
  4473. var content = file.ReadAll();
  4474. file.Close();
  4475. }
  4476. catch(e)
  4477. {
  4478. //alert("Exception while attempting to load\n\n" + e.toString());
  4479. return(null);
  4480. }
  4481. return(content);
  4482. }
  4483. // Returns null if it can't do it, false if there's an error, true if it saved OK
  4484. function mozillaSaveFile(filePath, content)
  4485. {
  4486. if(window.Components)
  4487. try
  4488. {
  4489. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  4490. var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  4491. file.initWithPath(filePath);
  4492. if (!file.exists())
  4493. file.create(0, 0664);
  4494. var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
  4495. out.init(file, 0x20 | 0x02, 00004,null);
  4496. out.write(content, content.length);
  4497. out.flush();
  4498. out.close();
  4499. return(true);
  4500. }
  4501. catch(e)
  4502. {
  4503. //alert("Exception while attempting to save\n\n" + e);
  4504. return(false);
  4505. }
  4506. return(null);
  4507. }
  4508. // Returns null if it can't do it, false if there's an error, or a string of the content if successful
  4509. function mozillaLoadFile(filePath)
  4510. {
  4511. if(window.Components)
  4512. try
  4513. {
  4514. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  4515. var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  4516. file.initWithPath(filePath);
  4517. if (!file.exists())
  4518. return(null);
  4519. var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
  4520. inputStream.init(file, 0x01, 00004, null);
  4521. var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
  4522. sInputStream.init(inputStream);
  4523. return(sInputStream.read(sInputStream.available()));
  4524. }
  4525. catch(e)
  4526. {
  4527. //alert("Exception while attempting to load\n\n" + e);
  4528. return(false);
  4529. }
  4530. return(null);
  4531. }
  4532. function javaUrlToFilename(url)
  4533. {
  4534. var f = "//localhost";
  4535. if(url.indexOf(f) == 0)
  4536. return url.substring(f.length);
  4537. var i = url.indexOf(":");
  4538. if(i > 0)
  4539. return url.substring(i-1);
  4540. return url;
  4541. }
  4542. function javaSaveFile(filePath, content)
  4543. {
  4544. try
  4545. {
  4546. if(document.applets["TiddlySaver"])
  4547. return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content);
  4548. }
  4549. catch(e)
  4550. {
  4551. }
  4552. try
  4553. {
  4554. var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath)));
  4555. s.print(content);
  4556. s.close();
  4557. }
  4558. catch(e)
  4559. {
  4560. return null;
  4561. }
  4562. return true;
  4563. }
  4564. function javaLoadFile(filePath)
  4565. {
  4566. try
  4567. {
  4568. if(document.applets["TiddlySaver"])
  4569. return String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8"));
  4570. }
  4571. catch(e)
  4572. {
  4573. }
  4574. var content = [];
  4575. try
  4576. {
  4577. var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath)));
  4578. var line;
  4579. while ((line = r.readLine()) != null)
  4580. content.push(new String(line));
  4581. r.close();
  4582. }
  4583. catch(e)
  4584. {
  4585. return null;
  4586. }
  4587. return content.join("\n");
  4588. }
  4589. // ---------------------------------------------------------------------------------
  4590. // Remote HTTP requests
  4591. // ---------------------------------------------------------------------------------
  4592. // Load a file over http
  4593. // url - the source url
  4594. // callback - function to call when there's a response
  4595. // params - parameter object that gets passed to the callback for storing it's state
  4596. // Return value is the underlying XMLHttpRequest object, or 'null' if there was an error
  4597. // Callback function is called like this:
  4598. // callback(status,params,responseText,xhr)
  4599. // status - true if OK, false if error
  4600. // params - the parameter object provided to loadRemoteFile()
  4601. // responseText - the text of the file
  4602. // xhr - the underlying XMLHttpRequest object
  4603. function loadRemoteFile(url,callback,params)
  4604. {
  4605. // Get an xhr object
  4606. var x;
  4607. try
  4608. {
  4609. x = new XMLHttpRequest(); // Modern
  4610. }
  4611. catch(e)
  4612. {
  4613. try
  4614. {
  4615. x = new ActiveXObject("Msxml2.XMLHTTP"); // IE 6
  4616. }
  4617. catch (e)
  4618. {
  4619. return null;
  4620. }
  4621. }
  4622. // Install callback
  4623. x.onreadystatechange = function()
  4624. {
  4625. if (x.readyState == 4)
  4626. {
  4627. if ((x.status == 0 || x.status == 200) && callback)
  4628. {
  4629. callback(true,params,x.responseText,url,x);
  4630. }
  4631. else
  4632. callback(false,params,null,url,x);
  4633. }
  4634. }
  4635. // Send request
  4636. if(window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1)
  4637. window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
  4638. try
  4639. {
  4640. url = url + (url.indexOf("?") < 0 ? "?" : "&") + "nocache=" + Math.random();
  4641. x.open("GET",url,true);
  4642. if (x.overrideMimeType)
  4643. x.overrideMimeType("text/html");
  4644. x.send(null);
  4645. }
  4646. catch (e)
  4647. {
  4648. alert("Error in send " + e);
  4649. return null;
  4650. }
  4651. return x;
  4652. }
  4653. // ---------------------------------------------------------------------------------
  4654. // TiddlyWiki-specific utility functions
  4655. // ---------------------------------------------------------------------------------
  4656. function createTiddlyButton(theParent,theText,theTooltip,theAction,theClass,theId,theAccessKey)
  4657. {
  4658. var theButton = document.createElement("a");
  4659. if(theAction)
  4660. {
  4661. theButton.onclick = theAction;
  4662. theButton.setAttribute("href","javascript:;");
  4663. }
  4664. if(theTooltip)
  4665. theButton.setAttribute("title",theTooltip);
  4666. if(theText)
  4667. theButton.appendChild(document.createTextNode(theText));
  4668. if(theClass)
  4669. theButton.className = theClass;
  4670. else
  4671. theButton.className = "button";
  4672. if(theId)
  4673. theButton.id = theId;
  4674. if(theParent)
  4675. theParent.appendChild(theButton);
  4676. if(theAccessKey)
  4677. theButton.setAttribute("accessKey",theAccessKey);
  4678. return(theButton);
  4679. }
  4680. function createTiddlyLink(place,title,includeText,theClass,isStatic)
  4681. {
  4682. var text = includeText ? title : null;
  4683. var i = getTiddlyLinkInfo(title,theClass)
  4684. var btn;
  4685. if(isStatic)
  4686. btn = createExternalLink(place,"#" + title);
  4687. else
  4688. btn = createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
  4689. btn.setAttribute("refresh","link");
  4690. btn.setAttribute("tiddlyLink",title);
  4691. return(btn);
  4692. }
  4693. function refreshTiddlyLink(e,title)
  4694. {
  4695. var i = getTiddlyLinkInfo(title,e.className);
  4696. e.className = i.classes;
  4697. e.title = i.subTitle;
  4698. }
  4699. function getTiddlyLinkInfo(title,currClasses)
  4700. {
  4701. var classes = currClasses ? currClasses.split(" ") : [];
  4702. classes.pushUnique("tiddlyLink");
  4703. var tiddler = store.fetchTiddler(title);
  4704. var subTitle;
  4705. if(tiddler)
  4706. {
  4707. subTitle = tiddler.getSubtitle();
  4708. classes.pushUnique("tiddlyLinkExisting");
  4709. classes.remove("tiddlyLinkNonExisting");
  4710. classes.remove("shadow");
  4711. }
  4712. else
  4713. {
  4714. classes.remove("tiddlyLinkExisting");
  4715. classes.pushUnique("tiddlyLinkNonExisting");
  4716. if(store.isShadowTiddler(title))
  4717. {
  4718. subTitle = config.messages.shadowedTiddlerToolTip.format([title]);
  4719. classes.pushUnique("shadow");
  4720. }
  4721. else
  4722. {
  4723. subTitle = config.messages.undefinedTiddlerToolTip.format([title]);
  4724. classes.remove("shadow");
  4725. }
  4726. }
  4727. return {classes: classes.join(" "), subTitle: subTitle};
  4728. }
  4729. function createExternalLink(place,url)
  4730. {
  4731. var theLink = document.createElement("a");
  4732. theLink.className = "externalLink";
  4733. theLink.href = url;
  4734. theLink.title = config.messages.externalLinkTooltip.format([url]);
  4735. if(config.options.chkOpenInNewWindow)
  4736. theLink.target = "_blank";
  4737. place.appendChild(theLink);
  4738. return(theLink);
  4739. }
  4740. // Event handler for clicking on a tiddly link
  4741. function onClickTiddlerLink(e)
  4742. {
  4743. if (!e) var e = window.event;
  4744. var theTarget = resolveTarget(e);
  4745. var theLink = theTarget;
  4746. var title = null;
  4747. do {
  4748. title = theLink.getAttribute("tiddlyLink");
  4749. theLink = theLink.parentNode;
  4750. } while(title == null && theLink != null);
  4751. if(title)
  4752. {
  4753. var toggling = e.metaKey || e.ctrlKey;
  4754. if(config.options.chkToggleLinks)
  4755. toggling = !toggling;
  4756. var opening;
  4757. if(toggling && document.getElementById("tiddler" + title))
  4758. story.closeTiddler(title,true,e.shiftKey || e.altKey);
  4759. else
  4760. story.displayTiddler(theTarget,title,null,true,e.shiftKey || e.altKey);
  4761. }
  4762. clearMessage();
  4763. return(false);
  4764. }
  4765. // Create a button for a tag with a popup listing all the tiddlers that it tags
  4766. function createTagButton(place,tag,excludeTiddler)
  4767. {
  4768. var theTag = createTiddlyButton(place,tag,config.views.wikified.tag.tooltip.format([tag]),onClickTag);
  4769. theTag.setAttribute("tag",tag);
  4770. if(excludeTiddler)
  4771. theTag.setAttribute("tiddler",excludeTiddler);
  4772. return(theTag);
  4773. }
  4774. // Event handler for clicking on a tiddler tag
  4775. function onClickTag(e)
  4776. {
  4777. if (!e) var e = window.event;
  4778. var theTarget = resolveTarget(e);
  4779. var popup = Popup.create(this);
  4780. var tag = this.getAttribute("tag");
  4781. var title = this.getAttribute("tiddler");
  4782. if(popup && tag)
  4783. {
  4784. var tagged = store.getTaggedTiddlers(tag);
  4785. var titles = [];
  4786. var li,r;
  4787. for(r=0;r<tagged.length;r++)
  4788. if(tagged[r].title != title)
  4789. titles.push(tagged[r].title);
  4790. var lingo = config.views.wikified.tag;
  4791. if(titles.length > 0)
  4792. {
  4793. var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);
  4794. openAll.setAttribute("tag",tag);
  4795. createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
  4796. for(r=0; r<titles.length; r++)
  4797. {
  4798. createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);
  4799. }
  4800. }
  4801. else
  4802. createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag]));
  4803. createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
  4804. var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);
  4805. createTiddlyText(h,lingo.openTag.format([tag]));
  4806. }
  4807. Popup.show(popup,false);
  4808. e.cancelBubble = true;
  4809. if (e.stopPropagation) e.stopPropagation();
  4810. return(false);
  4811. }
  4812. // Event handler for 'open all' on a tiddler popup
  4813. function onClickTagOpenAll(e)
  4814. {
  4815. if (!e) var e = window.event;
  4816. var tag = this.getAttribute("tag");
  4817. var tagged = store.getTaggedTiddlers(tag);
  4818. var titles = [];
  4819. for(var t=0; t<tagged.length; t++)
  4820. titles.push(tagged[t].title);
  4821. story.displayTiddlers(this,titles);
  4822. return(false);
  4823. }
  4824. function onClickError(e)
  4825. {
  4826. if (!e) var e = window.event;
  4827. var popup = Popup.create(this);
  4828. var lines = this.getAttribute("errorText").split("\n");
  4829. for(var t=0; t<lines.length; t++)
  4830. createTiddlyElement(popup,"li",null,null,lines[t]);
  4831. Popup.show(popup,false);
  4832. e.cancelBubble = true;
  4833. if (e.stopPropagation) e.stopPropagation();
  4834. return false;
  4835. }
  4836. function createTiddlyDropDown(place,onchange,options)
  4837. {
  4838. var sel = createTiddlyElement(place,"select");
  4839. sel.onchange = onchange;
  4840. for(var t=0; t<options.length; t++)
  4841. {
  4842. var e = createTiddlyElement(sel,"option",null,null,options[t].caption);
  4843. e.value = options[t].name;
  4844. }
  4845. }
  4846. function createTiddlyError(place,title,text)
  4847. {
  4848. var btn = createTiddlyButton(place,title,null,onClickError,"errorButton");
  4849. if (text) btn.setAttribute("errorText",text);
  4850. }
  4851. function merge(dst,src,preserveExisting)
  4852. {
  4853. for (p in src)
  4854. if (!preserveExisting || dst[p] === undefined)
  4855. dst[p] = src[p];
  4856. return dst;
  4857. }
  4858. // Returns a string containing the description of an exception, optionally prepended by a message
  4859. function exceptionText(e, message)
  4860. {
  4861. var s = e.description ? e.description : e.toString();
  4862. return message ? "%0:\n%1".format([message, s]) : s;
  4863. }
  4864. // Displays an alert of an exception description with optional message
  4865. function showException(e, message)
  4866. {
  4867. alert(exceptionText(e, message));
  4868. }
  4869. // ---------------------------------------------------------------------------------
  4870. // Animation engine
  4871. // ---------------------------------------------------------------------------------
  4872. function Animator()
  4873. {
  4874. this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
  4875. this.timerID = 0; // ID of the timer used for animating
  4876. this.animations = []; // List of animations in progress
  4877. return this;
  4878. }
  4879. // Start animation engine
  4880. Animator.prototype.startAnimating = function() // Variable number of arguments
  4881. {
  4882. for(var t=0; t<arguments.length; t++)
  4883. this.animations.push(arguments[t]);
  4884. if(this.running == 0)
  4885. {
  4886. var me = this;
  4887. this.timerID = window.setInterval(function() {me.doAnimate(me);},5);
  4888. }
  4889. this.running += arguments.length;
  4890. }
  4891. // Perform an animation engine tick, calling each of the known animation modules
  4892. Animator.prototype.doAnimate = function(me)
  4893. {
  4894. var a = 0;
  4895. while(a < me.animations.length)
  4896. {
  4897. var animation = me.animations[a];
  4898. if(animation.tick())
  4899. a++;
  4900. else
  4901. {
  4902. me.animations.splice(a,1);
  4903. if(--me.running == 0)
  4904. window.clearInterval(me.timerID);
  4905. }
  4906. }
  4907. }
  4908. // Map a 0..1 value to 0..1, but slow down at the start and end
  4909. Animator.slowInSlowOut = function(progress)
  4910. {
  4911. return(1-((Math.cos(progress * Math.PI)+1)/2));
  4912. }
  4913. // ---------------------------------------------------------------------------------
  4914. // Cascade animation
  4915. // ---------------------------------------------------------------------------------
  4916. function Cascade(text,startElement,targetElement,slowly)
  4917. {
  4918. var winWidth = findWindowWidth();
  4919. var winHeight = findWindowHeight();
  4920. this.elements = [];
  4921. this.startElement = startElement;
  4922. this.startLeft = findPosX(this.startElement);
  4923. this.startTop = findPosY(this.startElement);
  4924. this.startWidth = Math.min(this.startElement.offsetWidth,winWidth);
  4925. this.startHeight = Math.min(this.startElement.offsetHeight,winHeight);
  4926. this.targetElement = targetElement;
  4927. targetElement.style.position = "relative";
  4928. targetElement.style.zIndex = 2;
  4929. this.targetLeft = findPosX(this.targetElement);
  4930. this.targetTop = findPosY(this.targetElement);
  4931. this.targetWidth = Math.min(this.targetElement.offsetWidth,winWidth);
  4932. this.targetHeight = Math.min(this.targetElement.offsetHeight,winHeight);
  4933. this.progress = -1;
  4934. this.steps = slowly ? config.cascadeSlow : config.cascadeFast;
  4935. this.text = text;
  4936. this.tick();
  4937. return this;
  4938. }
  4939. Cascade.prototype.tick = function()
  4940. {
  4941. this.progress++;
  4942. if(this.progress >= this.steps)
  4943. {
  4944. while(this.elements.length > 0)
  4945. this.removeTail();
  4946. this.targetElement.style.position = "static";
  4947. this.targetElement.style.zIndex = "";
  4948. return false;
  4949. }
  4950. else
  4951. {
  4952. if(this.elements.length > 0 && this.progress > config.cascadeDepth)
  4953. this.removeTail();
  4954. if(this.progress < (this.steps - config.cascadeDepth))
  4955. {
  4956. var f = Animator.slowInSlowOut(this.progress/(this.steps - config.cascadeDepth - 1));
  4957. var e = createTiddlyElement(document.body,"div",null,"cascade",this.text);
  4958. e.style.zIndex = 1;
  4959. e.style.left = this.startLeft + (this.targetLeft-this.startLeft) * f + "px";
  4960. e.style.top = this.startTop + (this.targetTop-this.startTop) * f + "px";
  4961. e.style.width = this.startWidth + (this.targetWidth-this.startWidth) * f + "px";
  4962. e.style.height = this.startHeight + (this.targetHeight-this.startHeight) * f + "px";
  4963. e.style.display = "block";
  4964. this.elements.push(e);
  4965. }
  4966. return true;
  4967. }
  4968. }
  4969. Cascade.prototype.removeTail = function()
  4970. {
  4971. var e = this.elements[0];
  4972. e.parentNode.removeChild(e);
  4973. this.elements.shift();
  4974. }
  4975. // ---------------------------------------------------------------------------------
  4976. // Scroller animation
  4977. // ---------------------------------------------------------------------------------
  4978. function Scroller(targetElement,slowly)
  4979. {
  4980. this.targetElement = targetElement;
  4981. this.startScroll = findScrollY();
  4982. this.targetScroll = ensureVisible(targetElement);
  4983. this.progress = 0;
  4984. this.step = slowly ? config.animSlow : config.animFast;
  4985. return this;
  4986. }
  4987. Scroller.prototype.tick = function()
  4988. {
  4989. this.progress += this.step;
  4990. if(this.progress > 1)
  4991. {
  4992. window.scrollTo(0,this.targetScroll);
  4993. return false;
  4994. }
  4995. else
  4996. {
  4997. var f = Animator.slowInSlowOut(this.progress);
  4998. window.scrollTo(0,this.startScroll + (this.targetScroll-this.startScroll) * f);
  4999. return true;
  5000. }
  5001. }
  5002. // ---------------------------------------------------------------------------------
  5003. // Slider animation
  5004. // ---------------------------------------------------------------------------------
  5005. // deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element]
  5006. function Slider(element,opening,slowly,deleteMode)
  5007. {
  5008. this.element = element;
  5009. element.style.display = "block";
  5010. this.deleteMode = deleteMode;
  5011. this.element.style.height = "auto";
  5012. this.realHeight = element.offsetHeight;
  5013. this.opening = opening;
  5014. this.step = slowly ? config.animSlow : config.animFast;
  5015. if(opening)
  5016. {
  5017. this.progress = 0;
  5018. element.style.height = "0px";
  5019. element.style.display = "block";
  5020. }
  5021. else
  5022. {
  5023. this.progress = 1;
  5024. this.step = -this.step;
  5025. }
  5026. element.style.overflow = "hidden";
  5027. return this;
  5028. }
  5029. Slider.prototype.stop = function()
  5030. {
  5031. if(this.opening)
  5032. {
  5033. this.element.style.height = "auto";
  5034. this.element.style.opacity = 1;
  5035. this.element.style.filter = "alpha(opacity:100)";
  5036. }
  5037. else
  5038. {
  5039. switch(this.deleteMode)
  5040. {
  5041. case "none":
  5042. this.element.style.display = "none";
  5043. break;
  5044. case "all":
  5045. this.element.parentNode.removeChild(this.element);
  5046. break;
  5047. case "children":
  5048. removeChildren(this.element);
  5049. break;
  5050. }
  5051. }
  5052. }
  5053. Slider.prototype.tick = function()
  5054. {
  5055. this.progress += this.step;
  5056. if(this.progress < 0 || this.progress > 1)
  5057. {
  5058. this.stop();
  5059. return false;
  5060. }
  5061. else
  5062. {
  5063. var f = Animator.slowInSlowOut(this.progress);
  5064. var h = this.realHeight * f;
  5065. this.element.style.height = h + "px";
  5066. this.element.style.opacity = f;
  5067. this.element.style.filter = "alpha(opacity:" + f * 100 +")";
  5068. return true;
  5069. }
  5070. }
  5071. // ---------------------------------------------------------------------------------
  5072. // Popup menu
  5073. // ---------------------------------------------------------------------------------
  5074. var Popup = {
  5075. stack: [] // Array of objects with members root: and popup:
  5076. };
  5077. Popup.create = function(root)
  5078. {
  5079. Popup.remove();
  5080. var popup = createTiddlyElement(document.body,"ol","popup","popup");
  5081. Popup.stack.push({root: root, popup: popup});
  5082. return popup;
  5083. }
  5084. Popup.onDocumentClick = function(e)
  5085. {
  5086. if (!e) var e = window.event;
  5087. var target = resolveTarget(e);
  5088. if(e.eventPhase == undefined)
  5089. Popup.remove();
  5090. else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET)
  5091. Popup.remove();
  5092. return true;
  5093. }
  5094. Popup.show = function(unused,slowly)
  5095. {
  5096. var curr = Popup.stack[Popup.stack.length-1];
  5097. var rootLeft = findPosX(curr.root);
  5098. var rootTop = findPosY(curr.root);
  5099. var rootHeight = curr.root.offsetHeight;
  5100. var popupLeft = rootLeft;
  5101. var popupTop = rootTop + rootHeight;
  5102. var popupWidth = curr.popup.offsetWidth;
  5103. var winWidth = findWindowWidth();
  5104. if(popupLeft + popupWidth > winWidth)
  5105. popupLeft = winWidth - popupWidth;
  5106. curr.popup.style.left = popupLeft + "px";
  5107. curr.popup.style.top = popupTop + "px";
  5108. curr.popup.style.display = "block";
  5109. addClass(curr.root,"highlight");
  5110. if(anim && config.options.chkAnimate)
  5111. anim.startAnimating(new Scroller(curr.popup,slowly));
  5112. else
  5113. window.scrollTo(0,ensureVisible(curr.popup));
  5114. }
  5115. Popup.remove = function()
  5116. {
  5117. if(Popup.stack.length > 0)
  5118. {
  5119. Popup.removeFrom(0);
  5120. }
  5121. }
  5122. Popup.removeFrom = function(from)
  5123. {
  5124. for(var t=Popup.stack.length-1; t>=from; t--)
  5125. {
  5126. var p = Popup.stack[t];
  5127. removeClass(p.root,"highlight");
  5128. p.popup.parentNode.removeChild(p.popup);
  5129. }
  5130. Popup.stack = Popup.stack.slice(0,from);
  5131. }
  5132. // ---------------------------------------------------------------------------------
  5133. // ListView gadget
  5134. // ---------------------------------------------------------------------------------
  5135. var ListView = {};
  5136. // Create a listview
  5137. // place - where in the DOM tree to insert the listview
  5138. // listObject - array of objects to be included in the listview
  5139. // listTemplate - template for the listview
  5140. // callback - callback for a command being selected
  5141. // className - optional classname for the <table> element
  5142. ListView.create = function(place,listObject,listTemplate,callback,className)
  5143. {
  5144. var table = createTiddlyElement(place,"table",null,className ? className : "listView");
  5145. var thead = createTiddlyElement(table,"thead");
  5146. var r = createTiddlyElement(thead,"tr");
  5147. for(var t=0; t<listTemplate.columns.length; t++)
  5148. {
  5149. var columnTemplate = listTemplate.columns[t];
  5150. var c = createTiddlyElement(r,"th");
  5151. var colType = ListView.columnTypes[columnTemplate.type];
  5152. if(colType && colType.createHeader)
  5153. colType.createHeader(c,columnTemplate,t);
  5154. }
  5155. var tbody = createTiddlyElement(table,"tbody");
  5156. for(var rc=0; rc<listObject.length; rc++)
  5157. {
  5158. rowObject = listObject[rc];
  5159. r = createTiddlyElement(tbody,"tr");
  5160. for(var c=0; c<listTemplate.rowClasses.length; c++)
  5161. {
  5162. if(rowObject[listTemplate.rowClasses[c].field])
  5163. addClass(r,listTemplate.rowClasses[c].className);
  5164. }
  5165. rowObject.rowElement = rowObject;
  5166. rowObject.colElements = {};
  5167. for(var cc=0; cc<listTemplate.columns.length; cc++)
  5168. {
  5169. var c = createTiddlyElement(r,"td");
  5170. var columnTemplate = listTemplate.columns[cc];
  5171. var field = columnTemplate.field;
  5172. var colType = ListView.columnTypes[columnTemplate.type];
  5173. if(colType && colType.createItem)
  5174. colType.createItem(c,rowObject,field,columnTemplate,cc,rc);
  5175. rowObject.colElements[field] = c;
  5176. }
  5177. }
  5178. if(callback && listTemplate.actions)
  5179. createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions);
  5180. if(callback && listTemplate.buttons)
  5181. {
  5182. for(t=0; t<listTemplate.buttons.length; t++)
  5183. {
  5184. var a = listTemplate.buttons[t];
  5185. if(a && a.name != "")
  5186. createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection));
  5187. }
  5188. }
  5189. return table;
  5190. }
  5191. ListView.getCommandHandler = function(callback,name,allowEmptySelection)
  5192. {
  5193. return function(e)
  5194. {
  5195. var view = findRelated(this,"TABLE",null,"previousSibling");
  5196. var tiddlers = [];
  5197. ListView.forEachSelector(view,function(e,rowName) {
  5198. if(e.checked)
  5199. tiddlers.push(rowName);
  5200. });
  5201. if(tiddlers.length == 0 && !allowEmptySelection)
  5202. alert(config.messages.nothingSelected);
  5203. else
  5204. {
  5205. if(this.nodeName.toLowerCase() == "select")
  5206. {
  5207. callback(view,this.value,tiddlers);
  5208. this.selectedIndex = 0;
  5209. }
  5210. else
  5211. callback(view,name,tiddlers);
  5212. }
  5213. };
  5214. }
  5215. // Invoke a callback for each selector checkbox in the listview
  5216. // view - <table> element of listView
  5217. // callback(checkboxElement,rowName)
  5218. // where
  5219. // checkboxElement - DOM element of checkbox
  5220. // rowName - name of this row as assigned by the column template
  5221. // result: true if at least one selector was checked
  5222. ListView.forEachSelector = function(view,callback)
  5223. {
  5224. var checkboxes = view.getElementsByTagName("input");
  5225. var hadOne = false;
  5226. for(var t=0; t<checkboxes.length; t++)
  5227. {
  5228. var cb = checkboxes[t];
  5229. if(cb.getAttribute("type") == "checkbox")
  5230. {
  5231. var rn = cb.getAttribute("rowName");
  5232. if(rn)
  5233. {
  5234. callback(cb,rn);
  5235. hadOne = true;
  5236. }
  5237. }
  5238. }
  5239. return hadOne;
  5240. }
  5241. ListView.columnTypes = {};
  5242. ListView.columnTypes.String = {
  5243. createHeader: function(place,columnTemplate,col)
  5244. {
  5245. createTiddlyText(place,columnTemplate.title);
  5246. },
  5247. createItem: function(place,listObject,field,columnTemplate,col,row)
  5248. {
  5249. var v = listObject[field];
  5250. if(v != undefined)
  5251. createTiddlyText(place,v);
  5252. }
  5253. };
  5254. ListView.columnTypes.Date = {
  5255. createHeader: ListView.columnTypes.String.createHeader,
  5256. createItem: function(place,listObject,field,columnTemplate,col,row)
  5257. {
  5258. var v = listObject[field];
  5259. if(v != undefined)
  5260. createTiddlyText(place,v.formatString(columnTemplate.dateFormat));
  5261. }
  5262. };
  5263. ListView.columnTypes.StringList = {
  5264. createHeader: ListView.columnTypes.String.createHeader,
  5265. createItem: function(place,listObject,field,columnTemplate,col,row)
  5266. {
  5267. var v = listObject[field];
  5268. if(v != undefined)
  5269. {
  5270. for(var t=0; t<v.length; t++)
  5271. {
  5272. createTiddlyText(place,v[t]);
  5273. createTiddlyElement(place,"br");
  5274. }
  5275. }
  5276. }
  5277. };
  5278. ListView.columnTypes.Selector = {
  5279. createHeader: function(place,columnTemplate,col)
  5280. {
  5281. createTiddlyCheckbox(place,null,false,this.onHeaderChange);
  5282. },
  5283. createItem: function(place,listObject,field,columnTemplate,col,row)
  5284. {
  5285. var e = createTiddlyCheckbox(place,null,listObject[field],null);
  5286. e.setAttribute("rowName",listObject[columnTemplate.rowName]);
  5287. },
  5288. onHeaderChange: function(e)
  5289. {
  5290. var state = this.checked;
  5291. var view = findRelated(this,"TABLE");
  5292. if(!view)
  5293. return;
  5294. ListView.forEachSelector(view,function(e,rowName) {
  5295. e.checked = state;
  5296. });
  5297. }
  5298. };
  5299. ListView.columnTypes.Tags = {
  5300. createHeader: ListView.columnTypes.String.createHeader,
  5301. createItem: function(place,listObject,field,columnTemplate,col,row)
  5302. {
  5303. var tags = listObject[field];
  5304. createTiddlyText(place,String.encodeTiddlyLinkList(tags));
  5305. }
  5306. };
  5307. ListView.columnTypes.Boolean = {
  5308. createHeader: ListView.columnTypes.String.createHeader,
  5309. createItem: function(place,listObject,field,columnTemplate,col,row)
  5310. {
  5311. if(listObject[field] == true)
  5312. createTiddlyText(place,columnTemplate.trueText);
  5313. if(listObject[field] == false)
  5314. createTiddlyText(place,columnTemplate.falseText);
  5315. }
  5316. };
  5317. ListView.columnTypes.TagCheckbox = {
  5318. createHeader: ListView.columnTypes.String.createHeader,
  5319. createItem: function(place,listObject,field,columnTemplate,col,row)
  5320. {
  5321. var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange);
  5322. e.setAttribute("tiddler",listObject.title);
  5323. e.setAttribute("tag",columnTemplate.tag);
  5324. },
  5325. onChange : function(e)
  5326. {
  5327. var tag = this.getAttribute("tag");
  5328. var tiddler = this.getAttribute("tiddler");
  5329. store.setTiddlerTag(tiddler,this.checked,tag);
  5330. }
  5331. };
  5332. ListView.columnTypes.TiddlerLink = {
  5333. createHeader: ListView.columnTypes.String.createHeader,
  5334. createItem: function(place,listObject,field,columnTemplate,col,row)
  5335. {
  5336. var v = listObject[field];
  5337. if(v != undefined)
  5338. {
  5339. var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null);
  5340. createTiddlyText(link,listObject[field]);
  5341. }
  5342. }
  5343. };
  5344. // ---------------------------------------------------------------------------------
  5345. // Augmented methods for the JavaScript Number(), Array(), String() and Date() objects
  5346. // ---------------------------------------------------------------------------------
  5347. // Clamp a number to a range
  5348. Number.prototype.clamp = function(min,max)
  5349. {
  5350. var c = this;
  5351. if(c < min)
  5352. c = min;
  5353. if(c > max)
  5354. c = max;
  5355. return c;
  5356. }
  5357. // Add indexOf function if browser does not support it
  5358. if(!Array.indexOf) {
  5359. Array.prototype.indexOf = function(item,from)
  5360. {
  5361. if(!from)
  5362. from = 0;
  5363. for(var i=from; i<this.length; i++)
  5364. if(this[i] === item)
  5365. return i;
  5366. return -1;
  5367. }}
  5368. // Find an entry in a given field of the members of an array
  5369. Array.prototype.findByField = function(field,value)
  5370. {
  5371. for(var t=0; t<this.length; t++)
  5372. if(this[t][field] == value)
  5373. return t;
  5374. return null;
  5375. }
  5376. // Return whether an entry exists in an array
  5377. Array.prototype.contains = function(item)
  5378. {
  5379. return this.indexOf(item) != -1;
  5380. };
  5381. // Adds, removes or toggles a particular value within an array
  5382. // value - value to add
  5383. // mode - +1 to add value, -1 to remove value, 0 to toggle it
  5384. Array.prototype.setItem = function(value,mode)
  5385. {
  5386. var p = this.indexOf(value);
  5387. if(mode == 0)
  5388. mode = (p == -1) ? +1 : -1;
  5389. if(mode == +1)
  5390. {
  5391. if(p == -1)
  5392. this.push(value);
  5393. }
  5394. else if(mode == -1)
  5395. {
  5396. if(p != -1)
  5397. this.splice(p,1);
  5398. }
  5399. }
  5400. // Return whether one of a list of values exists in an array
  5401. Array.prototype.containsAny = function(items)
  5402. {
  5403. for(var i=0; i<items.length; i++)
  5404. if (this.indexOf(items[i]) != -1)
  5405. return true;
  5406. return false;
  5407. };
  5408. // Return whether all of a list of values exists in an array
  5409. Array.prototype.containsAll = function(items)
  5410. {
  5411. for (var i = 0; i<items.length; i++)
  5412. if (this.indexOf(items[i]) == -1)
  5413. return false;
  5414. return true;
  5415. };
  5416. // Push a new value into an array only if it is not already present in the array. If the optional unique parameter is false, it reverts to a normal push
  5417. Array.prototype.pushUnique = function(item,unique)
  5418. {
  5419. if(unique != undefined && unique == false)
  5420. this.push(item);
  5421. else
  5422. {
  5423. if(this.indexOf(item) == -1)
  5424. this.push(item);
  5425. }
  5426. }
  5427. Array.prototype.remove = function(item)
  5428. {
  5429. var p = this.indexOf(item);
  5430. if(p != -1)
  5431. this.splice(p,1);
  5432. }
  5433. // Get characters from the right end of a string
  5434. String.prototype.right = function(n)
  5435. {
  5436. if(n < this.length)
  5437. return this.slice(this.length-n);
  5438. else
  5439. return this;
  5440. }
  5441. // Trim whitespace from both ends of a string
  5442. String.prototype.trim = function()
  5443. {
  5444. return this.replace(/^\s*|\s*$/g,"");
  5445. }
  5446. // Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor")
  5447. String.prototype.unDash = function()
  5448. {
  5449. var s = this.split("-");
  5450. if(s.length > 1)
  5451. for(var t=1; t<s.length; t++)
  5452. s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1);
  5453. return s.join("");
  5454. }
  5455. // Substitute substrings from an array into a format string that includes '%1'-type specifiers
  5456. String.prototype.format = function(substrings)
  5457. {
  5458. var subRegExp = /(?:%(\d+))/mg;
  5459. var currPos = 0;
  5460. var r = [];
  5461. do {
  5462. var match = subRegExp.exec(this);
  5463. if(match && match[1])
  5464. {
  5465. if(match.index > currPos)
  5466. r.push(this.substring(currPos,match.index));
  5467. r.push(substrings[parseInt(match[1])]);
  5468. currPos = subRegExp.lastIndex;
  5469. }
  5470. } while(match);
  5471. if(currPos < this.length)
  5472. r.push(this.substring(currPos,this.length));
  5473. return r.join("");
  5474. }
  5475. // Escape any special RegExp characters with that character preceded by a backslash
  5476. String.prototype.escapeRegExp = function()
  5477. {
  5478. var s = "\\^$*+?()=!|,{}[].";
  5479. var c = this;
  5480. for(var t=0; t<s.length; t++)
  5481. c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1));
  5482. return c;
  5483. }
  5484. // Convert "\" to "\s", newlines to "\n" (and remove carriage returns)
  5485. String.prototype.escapeLineBreaks = function()
  5486. {
  5487. return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,"");
  5488. }
  5489. // Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns)
  5490. String.prototype.unescapeLineBreaks = function()
  5491. {
  5492. return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,"");
  5493. }
  5494. // Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;"
  5495. String.prototype.htmlEncode = function()
  5496. {
  5497. return(this.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;"));
  5498. }
  5499. // Convert "&lt;" to <, "&gt;" to >, "&quot;" to " and "&amp;" to & (& handled last for security reasons)
  5500. String.prototype.htmlDecode = function()
  5501. {
  5502. return(this.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&"));
  5503. }
  5504. // Parse a space-separated string of name:value parameters where:
  5505. // - the name or the value can be optional (in which case separate defaults are used instead)
  5506. // - in case of ambiguity, a lone word is taken to be a value
  5507. // - if 'cascadeDefaults' is set to true, then the defaults are modified by updated by each specified name or value
  5508. // - name prefixes are not allowed if the 'noNames' parameter is true
  5509. // - if both the name and value are present they must be separated by a colon
  5510. // - the name and the value may both be quoted with single- or double-quotes, double-square brackets
  5511. // - names or values quoted with {{double-curly braces}} are evaluated as a JavaScript expression
  5512. // - as long as the 'allowEval' parameter is true
  5513. // The result is an array of objects:
  5514. // result[0] = object with a member for each parameter name, value of that member being an array of values
  5515. // result[1..n] = one object for each parameter, with 'name' and 'value' members
  5516. String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults)
  5517. {
  5518. var parseToken = function(match,p)
  5519. {
  5520. var n;
  5521. if(match[p]) // Double quoted
  5522. n = match[p];
  5523. else if(match[p+1]) // Single quoted
  5524. n = match[p+1];
  5525. else if(match[p+2]) // Double-square-bracket quoted
  5526. n = match[p+2];
  5527. else if(match[p+3]) // Double-brace quoted
  5528. try
  5529. {
  5530. n = match[p+3];
  5531. if(allowEval)
  5532. n = window.eval(n);
  5533. }
  5534. catch(e)
  5535. {
  5536. throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(e);
  5537. }
  5538. else if(match[p+4]) // Unquoted
  5539. n = match[p+4];
  5540. else if(match[p+5]) // empty quote
  5541. n = "";
  5542. return n;
  5543. };
  5544. var r = [{}];
  5545. var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
  5546. var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
  5547. var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
  5548. var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
  5549. var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
  5550. var emptyQuote = "((?:\"\")|(?:''))";
  5551. var skipSpace = "(?:\\s*)";
  5552. var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
  5553. var re = noNames
  5554. ? new RegExp(token,"mg")
  5555. : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
  5556. var params = [];
  5557. do {
  5558. var match = re.exec(this);
  5559. if(match)
  5560. {
  5561. var n = parseToken(match,1);
  5562. if(noNames)
  5563. r.push({name: "", value: n});
  5564. else
  5565. {
  5566. var v = parseToken(match,8);
  5567. if(v == null && defaultName)
  5568. {
  5569. v = n;
  5570. n = defaultName;
  5571. }
  5572. else if(v == null && defaultValue)
  5573. v = defaultValue;
  5574. r.push({name: n, value: v});
  5575. if(cascadeDefaults)
  5576. {
  5577. defaultName = n;
  5578. defaultValue = v;
  5579. }
  5580. }
  5581. }
  5582. } while(match);
  5583. // Summarise parameters into first element
  5584. for(var t=1; t<r.length; t++)
  5585. {
  5586. if(r[0][r[t].name])
  5587. r[0][r[t].name].push(r[t].value);
  5588. else
  5589. r[0][r[t].name] = [r[t].value];
  5590. }
  5591. return r;
  5592. }
  5593. // Process a string list of macro parameters into an array. Parameters can be quoted with "", '',
  5594. // [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in
  5595. // an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name.
  5596. String.prototype.readMacroParams = function()
  5597. {
  5598. var p = this.parseParams("list",null,true,true);
  5599. var n = [];
  5600. for(var t=1; t<p.length; t++)
  5601. n.push(p[t].value);
  5602. return n;
  5603. }
  5604. // Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]]
  5605. String.prototype.readBracketedList = function(unique)
  5606. {
  5607. var p = this.parseParams("list",null,false,true);
  5608. var n = [];
  5609. for(var t=1; t<p.length; t++)
  5610. n.pushUnique(p[t].value,unique);
  5611. return n;
  5612. }
  5613. // Returns array with start and end index of chunk between given start and end marker, or undefined.
  5614. String.prototype.getChunkRange = function(start,end)
  5615. {
  5616. var s = this.indexOf(start);
  5617. if(s != -1)
  5618. {
  5619. s += start.length;
  5620. var e = this.indexOf(end,s);
  5621. if(e != -1)
  5622. return [s, e];
  5623. }
  5624. }
  5625. // Replace a chunk of a string given start and end markers
  5626. String.prototype.replaceChunk = function(start,end,sub)
  5627. {
  5628. var r = this.getChunkRange(start,end);
  5629. return r
  5630. ? this.substring(0,r[0]) + sub + this.substring(r[1])
  5631. : this;
  5632. }
  5633. // Returns a chunk of a string between start and end markers, or undefined
  5634. String.prototype.getChunk = function(start,end)
  5635. {
  5636. var r = this.getChunkRange(start,end);
  5637. if (r)
  5638. return this.substring(r[0],r[1]);
  5639. }
  5640. // Static method to bracket a string with double square brackets if it contains a space
  5641. String.encodeTiddlyLink = function(title)
  5642. {
  5643. if(title.indexOf(" ") == -1)
  5644. return(title);
  5645. else
  5646. return("[[" + title + "]]");
  5647. }
  5648. // Static method to encodeTiddlyLink for every item in an array and join them with spaces
  5649. String.encodeTiddlyLinkList = function(list)
  5650. {
  5651. if(list)
  5652. {
  5653. var results = [];
  5654. for(var t=0; t<list.length; t++)
  5655. results.push(String.encodeTiddlyLink(list[t]));
  5656. return results.join(" ");
  5657. }
  5658. else
  5659. return "";
  5660. }
  5661. // Static method to left-pad a string with 0s to a certain width
  5662. String.zeroPad = function(n,d)
  5663. {
  5664. var s = n.toString();
  5665. if(s.length < d)
  5666. s = "000000000000000000000000000".substr(0,d-s.length) + s;
  5667. return(s);
  5668. }
  5669. String.prototype.startsWith = function(prefix)
  5670. {
  5671. return !prefix || this.substring(0,prefix.length) == prefix;
  5672. }
  5673. // Returns the first value of the given named parameter.
  5674. //#
  5675. //# @param params
  5676. //# as returned by parseParams or null/undefined
  5677. //# @return [may be null/undefined]
  5678. //#
  5679. function getParam(params, name, defaultValue) {
  5680. if (!params)
  5681. return defaultValue;
  5682. var p = params[0][name];
  5683. return p ? p[0] : defaultValue;
  5684. }
  5685. // Returns the first value of the given boolean named parameter.
  5686. //#
  5687. //# @param params
  5688. //# as returned by parseParams or null/undefined
  5689. //#
  5690. function getFlag(params, name, defaultValue) {
  5691. return !!getParam(params, name, defaultValue);
  5692. }
  5693. // Substitute date components into a string
  5694. Date.prototype.formatString = function(template)
  5695. {
  5696. var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
  5697. t = t.replace(/hh12/g,this.getHours12());
  5698. t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2));
  5699. t = t.replace(/hh/g,this.getHours());
  5700. t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
  5701. t = t.replace(/mm/g,this.getMinutes());
  5702. t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
  5703. t = t.replace(/ss/g,this.getSeconds());
  5704. t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase());
  5705. t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase());
  5706. t = t.replace(/wYYYY/g,this.getYearForWeekNo());
  5707. t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
  5708. t = t.replace(/YYYY/g,this.getFullYear());
  5709. t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
  5710. t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]);
  5711. t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]);
  5712. t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
  5713. t = t.replace(/MM/g,this.getMonth()+1);
  5714. t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
  5715. t = t.replace(/WW/g,this.getWeek());
  5716. t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]);
  5717. t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]);
  5718. t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2));
  5719. t = t.replace(/DDth/g,this.getDate()+this.daySuffix());
  5720. t = t.replace(/DD/g,this.getDate());
  5721. return t;
  5722. }
  5723. Date.prototype.getWeek = function()
  5724. {
  5725. var dt = new Date(this.getTime());
  5726. var d = dt.getDay();
  5727. if (d==0) d=7;// JavaScript Sun=0, ISO Sun=7
  5728. dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo
  5729. var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);
  5730. return Math.floor(n/7)+1;
  5731. }
  5732. Date.prototype.getYearForWeekNo = function()
  5733. {
  5734. var dt = new Date(this.getTime());
  5735. var d = dt.getDay();
  5736. if (d==0) d=7;// JavaScript Sun=0, ISO Sun=7
  5737. dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week
  5738. return dt.getFullYear();
  5739. }
  5740. Date.prototype.getHours12 = function()
  5741. {
  5742. var h = this.getHours();
  5743. return h > 12 ? h-12 : ( h > 0 ? h : 12 );
  5744. }
  5745. Date.prototype.getAmPm = function()
  5746. {
  5747. return this.getHours() >= 12 ? "pm" : "am";
  5748. }
  5749. Date.prototype.daySuffix = function()
  5750. {
  5751. var num = this.getDate();
  5752. if (num >= 11 && num <= 13) return "th";
  5753. else if (num.toString().substr(-1)=="1") return "st";
  5754. else if (num.toString().substr(-1)=="2") return "nd";
  5755. else if (num.toString().substr(-1)=="3") return "rd";
  5756. return "th";
  5757. }
  5758. // Convert a date to local YYYYMMDDHHMM string format
  5759. Date.prototype.convertToLocalYYYYMMDDHHMM = function()
  5760. {
  5761. 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));
  5762. }
  5763. // Convert a date to UTC YYYYMMDDHHMM string format
  5764. Date.prototype.convertToYYYYMMDDHHMM = function()
  5765. {
  5766. return(String.zeroPad(this.getUTCFullYear(),4) + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2));
  5767. }
  5768. // Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
  5769. Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
  5770. {
  5771. return(String.zeroPad(this.getUTCFullYear(),4) + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),4));
  5772. }
  5773. // Static method to create a date from a UTC YYYYMMDDHHMM format string
  5774. Date.convertFromYYYYMMDDHHMM = function(d)
  5775. {
  5776. var theDate = new Date(Date.UTC(parseInt(d.substr(0,4),10),
  5777. parseInt(d.substr(4,2),10)-1,
  5778. parseInt(d.substr(6,2),10),
  5779. parseInt(d.substr(8,2),10),
  5780. parseInt(d.substr(10,2),10),0,0));
  5781. return(theDate);
  5782. }
  5783. // ---------------------------------------------------------------------------------
  5784. // Crypto functions and associated conversion routines
  5785. // ---------------------------------------------------------------------------------
  5786. // Crypto "namespace"
  5787. function Crypto() {}
  5788. // Convert a string to an array of big-endian 32-bit words
  5789. Crypto.strToBe32s = function(str)
  5790. {
  5791. var be = Array();
  5792. var len = Math.floor(str.length/4);
  5793. var i, j;
  5794. for(i=0, j=0; i<len; i++, j+=4)
  5795. {
  5796. be[i] = ((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
  5797. }
  5798. while (j<str.length)
  5799. {
  5800. be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
  5801. j++;
  5802. }
  5803. return be;
  5804. }
  5805. // Convert an array of big-endian 32-bit words to a string
  5806. Crypto.be32sToStr = function(be)
  5807. {
  5808. var str = "";
  5809. for(var i=0;i<be.length*32;i+=8)
  5810. str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
  5811. return str;
  5812. }
  5813. // Convert an array of big-endian 32-bit words to a hex string
  5814. Crypto.be32sToHex = function(be)
  5815. {
  5816. var hex = "0123456789ABCDEF";
  5817. var str = "";
  5818. for(var i=0;i<be.length*4;i++)
  5819. str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
  5820. return str;
  5821. }
  5822. // Return, in hex, the SHA-1 hash of a string
  5823. Crypto.hexSha1Str = function(str)
  5824. {
  5825. return Crypto.be32sToHex(Crypto.sha1Str(str));
  5826. }
  5827. // Return the SHA-1 hash of a string
  5828. Crypto.sha1Str = function(str)
  5829. {
  5830. return Crypto.sha1(Crypto.strToBe32s(str),str.length);
  5831. }
  5832. // Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
  5833. Crypto.sha1 = function(x,blen)
  5834. {
  5835. // Add 32-bit integers, wrapping at 32 bits
  5836. //# Uses 16-bit operations internally to work around bugs in some JavaScript interpreters.
  5837. add32 = function(a,b)
  5838. {
  5839. var lsw = (a&0xFFFF)+(b&0xFFFF);
  5840. var msw = (a>>16)+(b>>16)+(lsw>>16);
  5841. return (msw<<16)|(lsw&0xFFFF);
  5842. };
  5843. // Add five 32-bit integers, wrapping at 32 bits
  5844. //# Uses 16-bit operations internally to work around bugs in some JavaScript interpreters.
  5845. add32x5 = function(a,b,c,d,e)
  5846. {
  5847. var lsw = (a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
  5848. var msw = (a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
  5849. return (msw<<16)|(lsw&0xFFFF);
  5850. };
  5851. // Bitwise rotate left a 32-bit integer by 1 bit
  5852. rol32 = function(n)
  5853. {
  5854. return (n>>>31)|(n<<1);
  5855. };
  5856. var len = blen*8;
  5857. // Append padding so length in bits is 448 mod 512
  5858. x[len>>5] |= 0x80 << (24-len%32);
  5859. // Append length
  5860. x[((len+64>>9)<<4)+15] = len;
  5861. var w = Array(80);
  5862. var k1 = 0x5A827999;
  5863. var k2 = 0x6ED9EBA1;
  5864. var k3 = 0x8F1BBCDC;
  5865. var k4 = 0xCA62C1D6;
  5866. var h0 = 0x67452301;
  5867. var h1 = 0xEFCDAB89;
  5868. var h2 = 0x98BADCFE;
  5869. var h3 = 0x10325476;
  5870. var h4 = 0xC3D2E1F0;
  5871. for(var i=0;i<x.length;i+=16)
  5872. {
  5873. var j,t;
  5874. var a = h0;
  5875. var b = h1;
  5876. var c = h2;
  5877. var d = h3;
  5878. var e = h4;
  5879. for(j = 0;j<16;j++)
  5880. {
  5881. w[j] = x[i+j];
  5882. t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
  5883. e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
  5884. }
  5885. for(j=16;j<20;j++)
  5886. {
  5887. w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
  5888. t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
  5889. e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
  5890. }
  5891. for(j=20;j<40;j++)
  5892. {
  5893. w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
  5894. t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k2);
  5895. e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
  5896. }
  5897. for(j=40;j<60;j++)
  5898. {
  5899. w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
  5900. t = add32x5(e,(a>>>27)|(a<<5),(b&c)|(d&(b|c)),w[j],k3);
  5901. e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
  5902. }
  5903. for(j=60;j<80;j++)
  5904. {
  5905. w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
  5906. t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k4);
  5907. e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
  5908. }
  5909. h0 = add32(h0,a);
  5910. h1 = add32(h1,b);
  5911. h2 = add32(h2,c);
  5912. h3 = add32(h3,d);
  5913. h4 = add32(h4,e);
  5914. }
  5915. return Array(h0,h1,h2,h3,h4);
  5916. }
  5917. // ---------------------------------------------------------------------------------
  5918. // RGB colour object
  5919. // ---------------------------------------------------------------------------------
  5920. // Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values
  5921. function RGB(r,g,b)
  5922. {
  5923. this.r = 0;
  5924. this.g = 0;
  5925. this.b = 0;
  5926. if(typeof r == "string")
  5927. {
  5928. if(r.substr(0,1) == "#")
  5929. {
  5930. if(r.length == 7)
  5931. {
  5932. this.r = parseInt(r.substr(1,2),16)/255;
  5933. this.g = parseInt(r.substr(3,2),16)/255;
  5934. this.b = parseInt(r.substr(5,2),16)/255;
  5935. }
  5936. else
  5937. {
  5938. this.r = parseInt(r.substr(1,1),16)/15;
  5939. this.g = parseInt(r.substr(2,1),16)/15;
  5940. this.b = parseInt(r.substr(3,1),16)/15;
  5941. }
  5942. }
  5943. else
  5944. {
  5945. var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/ ;
  5946. var c = r.match(rgbPattern);
  5947. if (c)
  5948. {
  5949. this.r = parseInt(c[1],10)/255;
  5950. this.g = parseInt(c[2],10)/255;
  5951. this.b = parseInt(c[3],10)/255;
  5952. }
  5953. }
  5954. }
  5955. else
  5956. {
  5957. this.r = r;
  5958. this.g = g;
  5959. this.b = b;
  5960. }
  5961. return this;
  5962. }
  5963. // Mixes this colour with another in a specified proportion
  5964. // c = other colour to mix
  5965. // f = 0..1 where 0 is this colour and 1 is the new colour
  5966. // Returns an RGB object
  5967. RGB.prototype.mix = function(c,f)
  5968. {
  5969. return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f);
  5970. }
  5971. // Return an rgb colour as a #rrggbb format hex string
  5972. RGB.prototype.toString = function()
  5973. {
  5974. var r = this.r.clamp(0,1);
  5975. var g = this.g.clamp(0,1);
  5976. var b = this.b.clamp(0,1);
  5977. return("#" + ("0" + Math.floor(r * 255).toString(16)).right(2) +
  5978. ("0" + Math.floor(g * 255).toString(16)).right(2) +
  5979. ("0" + Math.floor(b * 255).toString(16)).right(2));
  5980. }
  5981. // ---------------------------------------------------------------------------------
  5982. // DOM utilities - many derived from www.quirksmode.org
  5983. // ---------------------------------------------------------------------------------
  5984. function drawGradient(place,horiz,colours)
  5985. {
  5986. for(var t=0; t<= 100; t+=2)
  5987. {
  5988. var bar = document.createElement("div");
  5989. place.appendChild(bar);
  5990. bar.style.position = "absolute";
  5991. bar.style.left = horiz ? t + "%" : 0;
  5992. bar.style.top = horiz ? 0 : t + "%";
  5993. bar.style.width = horiz ? (101-t) + "%" : "100%";
  5994. bar.style.height = horiz ? "100%" : (101-t) + "%";
  5995. bar.style.zIndex = -1;
  5996. var f = t/100;
  5997. var p = f*(colours.length-1);
  5998. bar.style.backgroundColor = colours[Math.floor(p)].mix(colours[Math.ceil(p)],p-Math.floor(p)).toString();
  5999. }
  6000. }
  6001. function createTiddlyText(theParent,theText)
  6002. {
  6003. return theParent.appendChild(document.createTextNode(theText));
  6004. }
  6005. function createTiddlyCheckbox(theParent,caption,checked,onChange)
  6006. {
  6007. var cb = document.createElement("input");
  6008. cb.setAttribute("type","checkbox");
  6009. cb.onclick = onChange;
  6010. theParent.appendChild(cb);
  6011. cb.checked = checked;
  6012. cb.className = "chkOptionInput";
  6013. if(caption)
  6014. wikify(caption,theParent);
  6015. return cb;
  6016. }
  6017. function createTiddlyElement(theParent,theElement,theID,theClass,theText)
  6018. {
  6019. var e = document.createElement(theElement);
  6020. if(theClass != null)
  6021. e.className = theClass;
  6022. if(theID != null)
  6023. e.setAttribute("id",theID);
  6024. if(theText != null)
  6025. e.appendChild(document.createTextNode(theText));
  6026. if(theParent != null)
  6027. theParent.appendChild(e);
  6028. return(e);
  6029. }
  6030. // Add an event handler
  6031. // Thanks to John Resig, via QuirksMode
  6032. function addEvent(obj,type,fn)
  6033. {
  6034. if(obj.attachEvent)
  6035. {
  6036. obj['e'+type+fn] = fn;
  6037. obj[type+fn] = function(){obj['e'+type+fn](window.event);}
  6038. obj.attachEvent('on'+type,obj[type+fn]);
  6039. }
  6040. else
  6041. obj.addEventListener(type,fn,false);
  6042. }
  6043. // Remove an event handler
  6044. // Thanks to John Resig, via QuirksMode
  6045. function removeEvent(obj,type,fn)
  6046. {
  6047. if(obj.detachEvent)
  6048. {
  6049. obj.detachEvent('on'+type,obj[type+fn]);
  6050. obj[type+fn] = null;
  6051. }
  6052. else
  6053. obj.removeEventListener(type,fn,false);
  6054. }
  6055. function addClass(e,theClass)
  6056. {
  6057. var currClass = e.className.split(" ");
  6058. if(currClass.indexOf(theClass) == -1)
  6059. e.className += " " + theClass;
  6060. }
  6061. function removeClass(e,theClass)
  6062. {
  6063. var currClass = e.className.split(" ");
  6064. var i = currClass.indexOf(theClass);
  6065. while(i != -1)
  6066. {
  6067. currClass.splice(i,1);
  6068. i = currClass.indexOf(theClass);
  6069. }
  6070. e.className = currClass.join(" ");
  6071. }
  6072. function hasClass(e,theClass)
  6073. {
  6074. if(e.className)
  6075. {
  6076. if(e.className.split(" ").indexOf(theClass) != -1)
  6077. return true;
  6078. }
  6079. return false;
  6080. }
  6081. // Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode)
  6082. function findRelated(e,value,name,relative)
  6083. {
  6084. name = name ? name : "tagName";
  6085. relative = relative ? relative : "parentNode";
  6086. if(name == "className")
  6087. {
  6088. while(e && !hasClass(e,value))
  6089. {
  6090. e = e[relative];
  6091. }
  6092. }
  6093. else
  6094. {
  6095. while(e && e[name] != value)
  6096. {
  6097. e = e[relative];
  6098. }
  6099. }
  6100. return e;
  6101. }
  6102. // Resolve the target object of an event
  6103. function resolveTarget(e)
  6104. {
  6105. var obj;
  6106. if (e.target)
  6107. obj = e.target;
  6108. else if (e.srcElement)
  6109. obj = e.srcElement;
  6110. if (obj.nodeType == 3) // defeat Safari bug
  6111. obj = obj.parentNode;
  6112. return(obj);
  6113. }
  6114. // Return the content of an element as plain text with no formatting
  6115. function getPlainText(e)
  6116. {
  6117. var text = "";
  6118. if(e.innerText)
  6119. text = e.innerText;
  6120. else if(e.textContent)
  6121. text = e.textContent;
  6122. return text;
  6123. }
  6124. // Get the scroll position for window.scrollTo necessary to scroll a given element into view
  6125. function ensureVisible(e)
  6126. {
  6127. var posTop = findPosY(e);
  6128. var posBot = posTop + e.offsetHeight;
  6129. var winTop = findScrollY();
  6130. var winHeight = findWindowHeight();
  6131. var winBot = winTop + winHeight;
  6132. if(posTop < winTop)
  6133. return(posTop);
  6134. else if(posBot > winBot)
  6135. {
  6136. if(e.offsetHeight < winHeight)
  6137. return(posTop - (winHeight - e.offsetHeight));
  6138. else
  6139. return(posTop);
  6140. }
  6141. else
  6142. return(winTop);
  6143. }
  6144. // Get the current width of the display window
  6145. function findWindowWidth()
  6146. {
  6147. return(window.innerWidth ? window.innerWidth : document.documentElement.clientWidth);
  6148. }
  6149. // Get the current height of the display window
  6150. function findWindowHeight()
  6151. {
  6152. return(window.innerHeight ? window.innerHeight : document.documentElement.clientHeight);
  6153. }
  6154. // Get the current horizontal page scroll position
  6155. function findScrollX()
  6156. {
  6157. return(window.scrollX ? window.scrollX : document.documentElement.scrollLeft);
  6158. }
  6159. // Get the current vertical page scroll position
  6160. function findScrollY()
  6161. {
  6162. return(window.scrollY ? window.scrollY : document.documentElement.scrollTop);
  6163. }
  6164. function findPosX(obj)
  6165. {
  6166. var curleft = 0;
  6167. while (obj.offsetParent)
  6168. {
  6169. curleft += obj.offsetLeft;
  6170. obj = obj.offsetParent;
  6171. }
  6172. return curleft;
  6173. }
  6174. function findPosY(obj)
  6175. {
  6176. var curtop = 0;
  6177. while (obj.offsetParent)
  6178. {
  6179. curtop += obj.offsetTop;
  6180. obj = obj.offsetParent;
  6181. }
  6182. return curtop;
  6183. }
  6184. // Blur a particular element
  6185. function blurElement(e)
  6186. {
  6187. if(e != null && e.focus && e.blur)
  6188. {
  6189. e.focus();
  6190. e.blur();
  6191. }
  6192. }
  6193. // Create a non-breaking space
  6194. function insertSpacer(place)
  6195. {
  6196. var e = document.createTextNode(String.fromCharCode(160));
  6197. if(place)
  6198. place.appendChild(e);
  6199. return e;
  6200. }
  6201. // Remove all children of a node
  6202. function removeChildren(e)
  6203. {
  6204. while(e.hasChildNodes())
  6205. e.removeChild(e.firstChild);
  6206. }
  6207. // Add a stylesheet, replacing any previous custom stylesheet
  6208. function setStylesheet(s,id)
  6209. {
  6210. if(!id)
  6211. id = "customStyleSheet";
  6212. var n = document.getElementById(id);
  6213. if(document.createStyleSheet) // Test for IE's non-standard createStyleSheet method
  6214. {
  6215. if(n)
  6216. n.parentNode.removeChild(n);
  6217. // This failed without the &nbsp;
  6218. document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd","&nbsp;<style id='" + id + "'>" + s + "</style>");
  6219. }
  6220. else
  6221. {
  6222. if(n)
  6223. n.replaceChild(document.createTextNode(s),n.firstChild);
  6224. else
  6225. {
  6226. var n = document.createElement("style");
  6227. n.type = "text/css";
  6228. n.id = id;
  6229. n.appendChild(document.createTextNode(s));
  6230. document.getElementsByTagName("head")[0].appendChild(n);
  6231. }
  6232. }
  6233. }
  6234. // Replace the current selection of a textarea or text input and scroll it into view
  6235. function replaceSelection(e,text)
  6236. {
  6237. if (e.setSelectionRange)
  6238. {
  6239. var oldpos = e.selectionStart + 1;
  6240. e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionStart);
  6241. e.setSelectionRange( oldpos, oldpos);
  6242. var linecount = e.value.split('\n').length;
  6243. var thisline = e.value.substr(0,e.selectionStart).split('\n').length-1;
  6244. e.scrollTop = Math.floor((thisline-e.rows/2)*e.scrollHeight/linecount);
  6245. }
  6246. else if (document.selection)
  6247. {
  6248. var range = document.selection.createRange();
  6249. if (range.parentElement() == e)
  6250. {
  6251. var isCollapsed = range.text == "";
  6252. range.text = text;
  6253. if (!isCollapsed)
  6254. {
  6255. range.moveStart('character', -text.length);
  6256. range.select();
  6257. }
  6258. }
  6259. }
  6260. }
  6261. // Returns the text of the given (text) node, possibly merging subsequent text nodes
  6262. function getNodeText(e)
  6263. {
  6264. var t = "";
  6265. while (e && e.nodeName == "#text")
  6266. {
  6267. t += e.nodeValue;
  6268. e = e.nextSibling;
  6269. }
  6270. return t;
  6271. }
  6272. //# -------------------------
  6273. //# LoaderBase: A (abstract) storage loader that loads the tiddlers from a list of HTML elements.
  6274. //# The format of the elements is defined by subclasses of this loader through the internalizeTiddler implementation.
  6275. //# Subclasses must implement:
  6276. //# function getTitle(store, e)
  6277. //#
  6278. //# store must implement:
  6279. //# function createTiddler(title).
  6280. //#
  6281. function LoaderBase()
  6282. {
  6283. }
  6284. LoaderBase.prototype.loadTiddler = function(store,e,tiddlers)
  6285. {
  6286. var title = this.getTitle(store, e);
  6287. if (title)
  6288. {
  6289. var tiddler = store.createTiddler(title);
  6290. this.internalizeTiddler(store, tiddler, title, e);
  6291. tiddlers.push(tiddler);
  6292. }
  6293. }
  6294. LoaderBase.prototype.loadTiddlers = function(store,nodes)
  6295. {
  6296. var tiddlers = [];
  6297. for (var t = 0; t < nodes.length; t++)
  6298. {
  6299. try
  6300. {
  6301. this.loadTiddler(store, nodes[t], tiddlers);
  6302. }
  6303. catch(e)
  6304. {
  6305. showException(e, config.messages.tiddlerLoadError.format([this.getTitle(store, nodes[t])]));
  6306. }
  6307. }
  6308. return tiddlers;
  6309. }
  6310. //# -------------------------
  6311. //# SaverBase: a (abstract) storage saver that externalizes all tiddlers into a string,
  6312. //# with every tiddler individually externalized (using this.externalizeTiddler) and joined with newlines
  6313. //# Subclasses must implement:
  6314. //# function externalizeTiddler(store, tiddler)
  6315. //#
  6316. //# store must implement:
  6317. //# function getTiddlers(sortByFieldName)
  6318. //#
  6319. function SaverBase()
  6320. {
  6321. }
  6322. SaverBase.prototype.externalize = function(store)
  6323. {
  6324. var results = [];
  6325. var tiddlers = store.getTiddlers("title");
  6326. for (var t = 0; t < tiddlers.length; t++)
  6327. results.push(this.externalizeTiddler(store, tiddlers[t]));
  6328. return results.join("\n");
  6329. }
  6330. //--------------------------------
  6331. // TW21Loader (inherits from LoaderBase)
  6332. function TW21Loader() {};
  6333. TW21Loader.prototype = new LoaderBase();
  6334. TW21Loader.prototype.getTitle = function(store, e) {
  6335. var title = null;
  6336. if(e.getAttribute)
  6337. title = e.getAttribute("tiddler");
  6338. if(!title && e.id) {
  6339. var lenPrefix = store.idPrefix.length;
  6340. if (e.id.substr(0,lenPrefix) == store.idPrefix)
  6341. title = e.id.substr(lenPrefix);
  6342. }
  6343. return title;
  6344. }
  6345. TW21Loader.prototype.internalizeTiddler = function(store, tiddler, title, data) {
  6346. var text = getNodeText(data.firstChild).unescapeLineBreaks();
  6347. var modifier = data.getAttribute("modifier");
  6348. var modified = Date.convertFromYYYYMMDDHHMM(data.getAttribute("modified"));
  6349. var c = data.getAttribute("created");
  6350. var created = c ? Date.convertFromYYYYMMDDHHMM(c) : modified;
  6351. var tags = data.getAttribute("tags");
  6352. var fields = {};
  6353. var attrs = data.attributes;
  6354. for(var i = attrs.length-1; i >= 0; i--) {
  6355. var name = attrs[i].name;
  6356. if (attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
  6357. fields[name] = attrs[i].value.unescapeLineBreaks();
  6358. }
  6359. }
  6360. tiddler.assign(title,text,modifier,modified,tags,created, fields);
  6361. return tiddler;
  6362. };
  6363. //--------------------------------
  6364. // TW21Saver (inherits from SaverBase)
  6365. function TW21Saver() {};
  6366. TW21Saver.prototype = new SaverBase();
  6367. TW21Saver.prototype.externalizeTiddler = function(store, tiddler)
  6368. {
  6369. try {
  6370. var extendedFieldAttributes = "";
  6371. store.forEachField(tiddler,
  6372. function(tiddler, fieldName, value) {
  6373. // don't store stuff from the temp namespace
  6374. if (!fieldName.match(/^temp\./))
  6375. extendedFieldAttributes += ' %0="%1"'.format([fieldName, value.escapeLineBreaks().htmlEncode()]);
  6376. }, true);
  6377. return '<div tiddler="%0" modifier="%1" modified="%2" created="%3" tags="%4"%6>%5</div>'.format([
  6378. tiddler.title.htmlEncode(),
  6379. tiddler.modifier.htmlEncode(),
  6380. tiddler.modified.convertToYYYYMMDDHHMM(),
  6381. tiddler.created.convertToYYYYMMDDHHMM(),
  6382. tiddler.getTags().htmlEncode(),
  6383. tiddler.escapeLineBreaks().htmlEncode(),
  6384. extendedFieldAttributes
  6385. ]);
  6386. } catch (e) {
  6387. throw exceptionText(e, config.messages.tiddlerSaveError.format([tiddler.title]));
  6388. }
  6389. }
  6390. // ---------------------------------------------------------------------------------
  6391. // Deprecated code
  6392. // ---------------------------------------------------------------------------------
  6393. // @Deprecated: Use createElementAndWikify and this.termRegExp instead
  6394. config.formatterHelpers.charFormatHelper = function(w)
  6395. {
  6396. w.subWikify(createTiddlyElement(w.output,this.element),this.terminator);
  6397. }
  6398. // @Deprecated: Use enclosedTextHelper and this.lookaheadRegExp instead
  6399. config.formatterHelpers.monospacedByLineHelper = function(w)
  6400. {
  6401. var lookaheadRegExp = new RegExp(this.lookahead,"mg");
  6402. lookaheadRegExp.lastIndex = w.matchStart;
  6403. var lookaheadMatch = lookaheadRegExp.exec(w.source);
  6404. if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
  6405. {
  6406. var text = lookaheadMatch[1];
  6407. if(config.browser.isIE)
  6408. text = text.replace(/\n/g,"\r");
  6409. createTiddlyElement(w.output,"pre",null,null,text);
  6410. w.nextMatch = lookaheadRegExp.lastIndex;
  6411. }
  6412. }
  6413. // @Deprecated: Use <br> or <br /> instead of <<br>>
  6414. config.macros.br.handler = function(place)
  6415. {
  6416. createTiddlyElement(place,"br");
  6417. }
  6418. // Find an entry in an array. Returns the array index or null
  6419. // @Deprecated: Use indexOf instead
  6420. Array.prototype.find = function(item)
  6421. {
  6422. var i = this.indexOf(item);
  6423. return i == -1 ? null : i;
  6424. }
  6425. // Load a tiddler from an HTML DIV. The caller should make sure to later call Tiddler.changed()
  6426. // @Deprecated: Use store.getLoader().internalizeTiddler instead
  6427. Tiddler.prototype.loadFromDiv = function(divRef,title)
  6428. {
  6429. return store.getLoader().internalizeTiddler(store,this,title,divRef);
  6430. }
  6431. // Format the text for storage in an HTML DIV
  6432. // @Deprecated Use store.getSaver().externalizeTiddler instead.
  6433. Tiddler.prototype.saveToDiv = function()
  6434. {
  6435. return store.getSaver().externalizeTiddler(store,this);
  6436. }
  6437. // @Deprecated: Use store.allTiddlersAsHtml() instead
  6438. function allTiddlersAsHtml()
  6439. {
  6440. return store.allTiddlersAsHtml();
  6441. }
  6442. // @Deprecated: Use refreshPageTemplate instead
  6443. function applyPageTemplate(title)
  6444. {
  6445. refreshPageTemplate(title);
  6446. }
  6447. // @Deprecated: Use story.displayTiddlers instead
  6448. function displayTiddlers(srcElement,titles,template,unused1,unused2,animate,slowly)
  6449. {
  6450. story.displayTiddlers(srcElement,titles,template,animate,slowly);
  6451. }
  6452. // @Deprecated: Use story.displayTiddler instead
  6453. function displayTiddler(srcElement,title,template,unused1,unused2,animate,slowly)
  6454. {
  6455. story.displayTiddler(srcElement,title,template,animate,slowly);
  6456. }
  6457. // @Deprecated: Use functions on right hand side directly instead
  6458. var createTiddlerPopup = Popup.create;
  6459. var scrollToTiddlerPopup = Popup.show;
  6460. var hideTiddlerPopup = Popup.remove;
  6461. // @Deprecated: Use right hand side directly instead
  6462. var regexpBackSlashEn = new RegExp("\\\\n","mg");
  6463. var regexpBackSlash = new RegExp("\\\\","mg");
  6464. var regexpBackSlashEss = new RegExp("\\\\s","mg");
  6465. var regexpNewLine = new RegExp("\n","mg");
  6466. var regexpCarriageReturn = new RegExp("\r","mg");
  6467. // ---------------------------------------------------------------------------------
  6468. // End of scripts
  6469. merge(config.shadowTiddlers,{SiteTitle:'DevFire'});
  6470. merge(config.shadowTiddlers,{MainMenu:"PageTemplate\nStyleSheet\nMainMenu\nDefaultTiddlers"});
  6471. merge(config.shadowTiddlers,{SiteSubtitle:"a theme for ~TiddlyWiki"});
  6472. merge(config.shadowTiddlers,{DefaultTiddlers:"LorumIpsum"});
  6473. merge(config.shadowTiddlers,{LorumIpsum:"Aenean eros arcu, condimentum nec, dapibus ut, tincidunt sit amet, urna. Quisque viverra, eros sed imperdiet iaculis, est risus facilisis quam, id malesuada arcu nulla luctus urna. Nullam et est. Vestibulum velit sem, faucibus cursus, dapibus vestibulum, pellentesque et, urna. Donec luctus. Donec lectus. Aliquam eget eros facilisis tortor feugiat sollicitudin. Integer lobortis vulputate sapien. Sed iaculis erat ac nunc. Etiam eu enim. Mauris ipsum urna, rhoncus at, bibendum sit amet, euismod eget, dolor. Mauris fermentum quam vitae ligula. Vestibulum in libero feugiat justo dictum consectetuer. Vestibulum euismod purus eget elit. Nunc sed massa porta elit bibendum posuere. Nunc pulvinar justo sit amet odio. In sed est. Phasellus ornare elementum nulla. Nulla ipsum neque, cursus a, viverra a, imperdiet at, enim. Quisque facilisis, diam sed accumsan suscipit, odio arcu hendrerit dolor, quis aliquet massa nulla nec sem.\n!heading 1\n!!heading 2\n!!!heading3\n----\n<<tag button>>\nThis is a link to a [[StyleSheet]] tiddler.\n\n> This is a blockquote\n> This is a blockquote\n> This is a blockquote\n|>|>| !This is a header |h\n|column1|column2|column3|\n|row2| row2 |row2|\n|column1|column2|column3|\n|row2| row2 |row2|\n|column1|column2|column3|\n|row2| row2 |row2|"});
  6474. // ---------------------------------------------------------------------------------
  6475. </script>
  6476. <style>
  6477. #saveTest {
  6478. display: none;
  6479. }
  6480. .zoomer {
  6481. display: none;
  6482. }
  6483. #messageArea {
  6484. display: none;
  6485. }
  6486. #copyright {
  6487. display: none;
  6488. }
  6489. .popup {
  6490. position: absolute;
  6491. }
  6492. #storeArea {
  6493. display: none;
  6494. margin: 4em 10em 3em;
  6495. }
  6496. #storeArea div {
  6497. padding: 0.5em;
  6498. margin: 1em 0em 0em 0em;
  6499. border-color: #f0f0f0 #606060 #404040 #d0d0d0;
  6500. border-style: solid;
  6501. border-width: 2px;
  6502. overflow: auto;
  6503. }
  6504. #javascriptWarning {
  6505. width: 100%;
  6506. text-align: center;
  6507. font-weight: bold;
  6508. background-color: #dd1100;
  6509. color: #fff;
  6510. padding:1em 0em;
  6511. }
  6512. </style>
  6513. <!--POST-HEAD-START-->
  6514. <!--POST-HEAD-END-->
  6515. </head>
  6516. <body onload="main();" onunload="if(window.checkUnsavedChanges) checkUnsavedChanges();">
  6517. <!--PRE-BODY-START-->
  6518. <!--PRE-BODY-END-->
  6519. <script>
  6520. if (useJavaSaver)
  6521. document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>");
  6522. </script>
  6523. <div id="copyright">
  6524. Welcome to TiddlyWiki by Jeremy Ruston, Copyright &copy; 2006 Osmosoft Limited
  6525. </div>
  6526. <noscript>
  6527. <div id="javascriptWarning">This page requires JavaScript to function properly</div>
  6528. </noscript>
  6529. <div id="saveTest"></div>
  6530. <div id="contentWrapper"></div>
  6531. <div id="contentStash"></div>
  6532. <div id="storeArea">
  6533. <div tiddler="(built-in shadow tiddler)" modifier="CameronRich" modified="200702240024" created="200702240024" tags="">changes, notes and errata</div>
  6534. <div tiddler="Cam" modifier="YourName" modified="200804011313" created="200804011313" tags="">Type the text for 'YourName'</div>
  6535. <div tiddler="Changelog" modifier="YourName" modified="200901301233" created="200702240022" tags="">@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.1@@\n\n!!__SSL Library__\n* Certificate verification now works for Firefox.\n* Extended the openssl API.\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.2.0@@\n\n!!__SSL Library__\n* A self-signed certificate will be verified as ok provided that that it is on the certificate authority list.\n* Certificates are not verified when added as certificate authorities (since self-signed and expired certificates can be added to browsers etc)\n\n@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.9@@\n\n!!__SSL Library__\n* Now support MS IIS resource kit certificates (thanks to Carsten Sørensen).\n* Fixed a memory leak when freeing more than one CA certificate.\n* The bigint library had a problem with squaring which affected classical reduction (thanks to Manuel Klimek).\n\n!!__axhttpd__\n* Brought back setuid()/setgid() as an option.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.8@@\n\n!!__SSL Library__\n* Now using a BSD style license.\n* Self-signed certificates can now be automatically generated (the keys still need to be provided).\n* A new API call //ssl_x509_create()// can be used to programatically create the certificate.\n* Certificate/keys can be loaded automatically given a file location.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.7@@\n\n!!__SSL Library__\n\n* Variable sized session id's is now better handled for session caching. It has meant a new API call //ssl_get_session_id_size()// and a change to //ssl_client_new()// to define the session id size.\n* Muliple records with a single header are now better supported (thanks to Hervé Sibert).\n* ~MD2 added for Verisign root cert verification (thanks to Byron Rakitzis).\n* The ~MD5/~SHA1 digests are calculated incrementally to reduce memory (thanks to Byron Rakitzis).\n* The bigint cache is now cleared regularly to reduce memory.\n\n!!__axhttpd__\n\n* Improved the POST handling (thanks to Christian Melki).\n* CSS files now work properly.\n* Lua's CGI launcher location is configurable.\n* //vfork()// is now used for CGI for performance reasons.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.6@@\n\n!!__SSL Library__\n\n* ~RC4 speed improvements\n* Lua samples/bindings now work properly\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.5@@\n\n!!__SSL Library__\n\n* Session id's can now be variable lengths in server hello messages.\n* 0 length client certificates are now supported.\n* ssl_version() now returns just the version and not the date.\n* ssl_write() was not sending complete packets under load.\n\n!!__axhttpd__\n\n* Completely updated the CGI code.\n* Lua now integrated - Lua scripts and Lua Pages now run.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.4@@\n\n!!__SSL Library__\n\n* Fixed a Win32 crypto library issue with non-Administrator users\n* Removed compiler warnings that showed up in ~FC6.\n* GNU TLS certificates are now accepted.\n* Separated the send/receive headers for HMAC calculations.\n* Fixed a compilation problem with swig/perl/~FC6.\n* Fixed an issue with loading PEM CA certificates.\n\n!!__axhttpd__\n\n* Made //setuid()/setgid()// call an mconf option.\n* Made //chroot()// an mconf option. Default to //chdir()// instead.\n* Removed optional permissions checking.\n\n!@@bgcolor(#ff0000):color(#ffffff):Changes for 1.1.1@@\n\n!!__SSL Library__\n\n* AES should now work on 16bit processors (there was an alignment problem).\n* Various freed objects are cleared before freeing.\n* Header files now installed in ///usr/local/include/axTLS//.\n* -DCYGWIN replaced with -~DCONFIG_PLATFORM_CYGWIN (and the same for Solaris).\n* removed &quot;-noextern&quot; option in Swig. Fixed some other warnings in Win32.\n* SSLCTX changed to ~SSL_CTX (to be consistent with openssl). SSLCTX still exists for backwards compatibility.\n* malloc() and friends call abort() on failure.\n* Fixed a memory leak in directory listings.\n* Added openssl() compatibility functions.\n* Fixed Cygwin 'make install' issue.\n\n!!__axhttpd__\n\n* main.c now becomes axhttpd.c.\n* Header file issue fixed (in mime_types.c).\n* //chroot()// now used for better security.\n* Basic authentication implemented (via .htpasswd).\n* SSL access/denial protection implemented (via .htaccess).\n* Directory access protection implemented (via .htaccess).\n* Can now have more than one CGI file extension in mconf.\n* &quot;~If-Modified-Since&quot; request now handled properly.\n* Performance tweaks to remove //ssl_find()//.</div>
  6536. <div tiddler="DefaultTiddlers" modifier="CameronRich" modified="200702240019" created="200702240019" tags="">[[Read Me]]</div>
  6537. <div tiddler="License" modifier="YourName" modified="200804011309" created="200702240022" tags="">axTLS uses a BSD style license:\n\nCopyright (c) 2008, Cameron Rich All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer. Redistributions in binary\nform must reproduce the above copyright notice, this list of conditions and\nthe following disclaimer in the documentation and/or other materials\nprovided with the distribution. Neither the name of the axTLS Project nor\nthe names of its contributors may be used to endorse or promote products\nderived from this software without specific prior written permission. \n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGE.</div>
  6538. <div tiddler="MainMenu" modifier="CameronRich" modified="200702250353" created="200702240021" tags="">[[Read Me]] \n[[Changelog]]\n[[axhttpd]]\n[[License]]</div>
  6539. <div tiddler="PageTemplate" modifier="YourName" modified="200701122313" created="200701122350" tags="DevFireTheme">&lt;div class='header' macro='gradient vert #390108 #900'&gt;\n&lt;div class='headerShadow'&gt;\n&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;\n&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;\n&lt;/div&gt;\n&lt;div class='headerForeground'&gt;\n&lt;span class='siteTitle' refresh='content' tiddler='SiteTitle'&gt;&lt;/span&gt;&amp;nbsp;\n&lt;span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'&gt;&lt;/span&gt;\n&lt;/div&gt;\n&lt;/div&gt;\n&lt;div id='mainMenu'&gt;\n&lt;div refresh='content' tiddler='MainMenu'&gt;&lt;/div&gt;\n&lt;/div&gt;\n&lt;div id='sidebar'&gt;\n&lt;div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'&gt;&lt;/div&gt;\n&lt;div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'&gt;&lt;/div&gt;\n&lt;/div&gt;\n&lt;div id='displayArea'&gt;\n&lt;div id='messageArea'&gt;&lt;/div&gt;\n&lt;div id='tiddlerDisplay'&gt;&lt;/div&gt;\n&lt;/div&gt;</div>
  6540. <div tiddler="Read Me" modifier="YourName" modified="200804011313" created="200702240020" tags="">!@@bgcolor(#ff0000):color(#ffffff):axTLS Quick Start Guide@@\n\nThis is a guide to get a small SSL web-server up and running quickly.\n\n!!__Introduction__\n\nThe axTLS project is an SSL client/server library using the ~TLSv1 protocol. It is designed to be small and fast, and is suited to embedded projects. A web server is included.\n\nThe basic web server + SSL library is around 60-70kB and is configurable for features or size.\n\n!!__Compilation__\n\nAll platforms require GNU make. This means on Win32 that Cygwin needs to be installed with &quot;make&quot; and various developer options selected.\n\nConfiguration now uses a tool called &quot;mconf&quot; which gives a nice way to configure options (similar to what is used in ~BusyBox and the Linux kernel).\n\nYou should be able to compile axTLS simply by extracting it, change into the extracted directory and typing:\n\n{{indent{{{{&gt; make}}}\n\nSelect your platform type, save the configuration, exit, and then type &quot;make&quot; again.\n\nIf all goes well, you should end up with an executable called &quot;axhttpd&quot; (or axhttpd.exe) in the //_stage// directory.\n\nTo play with all the various axTLS options, type:\n\n{{indent{{{{&gt; make menuconfig}}}\n\nSave the new configuration and rebuild.\n\n!!__Running it__\n\nTo run it, go to the //_stage// directory, and type (as superuser):\n\n{{indent{{{{&gt; axhttpd}}}\n\nNote: you may have to set your ~LD_LIBRARY_PATH - e.g. go to //_stage// and type //export ~LD_LIBRARY_PATH=`pwd`//\n\nAnd then point your browser at https://127.0.0.1 And you should see a this html page with a padlock appearing on your browser. or type http://127.0.0.1 to see the same page unencrypted.\n\n!!__The axssl utilities__\n\nThe axssl suite of tools are the SSL test tools in the various language bindings. They are:\n\n* axssl - C sample\n* axssl.csharp - C# sample\n* axssl.vbnet - VB.NET sample\n* axtls.jar - Java sample\n* axssl.pl - Perl sample\n* axssl.lua - Lua sample\n\nAll the tools have identical command-line parameters. e.g. to run something interesting:\n\n{{indent{{{{&gt; axssl s_server -verify -CAfile ../ssl/test/axTLS.ca_x509}}}\n\nand\n\n{{indent{{{{&gt; axssl s_client -cert ../ssl/test/axTLS.x509_1024 -key ../ssl/test/axTLS.key_1024 -reconnect}}}\n\n!!!!C#\n\nIf building under Linux or other non-Win32 platforms, Mono must be installed and the executable is run as:\n\n{{indent{{{{&gt; mono axssl.csharp.exe ...}}}\n\n!!!!Java\n\nThe java version is run as:\n\n{{indent{{{{&gt; java -jar axtls.jar &lt;options&gt;}}}\n\n!!!!Perl\n\n{{indent{{{{&gt; [perl] ./axssl.pl &lt;options&gt;}}}\n\nIf running under Win32, be sure to use the correct version of Perl (i.e. ~ActiveState's version works ok).\n\n!!!!Lua\n\n{{indent{{{{&gt; [lua] ./axssl.lua &lt;options&gt;}}}\n\n!__Known Issues__\n\n* Firefox doesn't handle legacy ~SSLv2 at all well. Disabling ~SSLv2 still initiates a ~SSLv23 handshake (v1.5). And continuous pressing of the &quot;Reload&quot; page instigates a change to ~SSLv3 for some reason (even though the TLS 1.0 option is selected). This will cause a &quot;Firefox and &lt;server&gt; cannot communicate securely because they have no common encryption algorithms&quot; (v1.5), or &quot;Firefox can't connect to &lt;server&gt; because the site uses a security protocol which isn't enabled&quot; (v2.0). See bugzilla issues 343543 and 359484 (Comment #7). It's all broken (hopefully fixed soon).\n* Perl/Java bindings don't work on 64 bit Linux machines. I can't even compile the latest version of Perl on an ~AMD64 box (using ~FC3).\n* Java 1.4 or better is required for the Java interfaces.\n* Processes that fork can't use session resumption unless some form of IPC is used.\n* Ensure libperl.so and libaxtls.so are in the shared library path when running with the perl bindings. A way to do this is with:\n\n{{indent{{{{&gt; export LD_LIBRARY_PATH=`perl -e 'use Config; print $Config{archlib};'`/CORE:.}}}\n* The lua sample requires the luabit library from http://luaforge.net/projects/bit.\n\n!!!!Win32 issues\n\n* Be careful about doing .NET executions on network drives - .NET complains with security exceptions on the binary. //TODO: Add a manifest file to prevent this.//\n* CGI has been removed from Win32 - it needs a lot more work to get it right.\n* The default Microsoft .NET SDK is v2.0.50727. Download from: http://msdn.microsoft.com/netframework/downloads/updates/default.aspx.\n\n!!!!Solaris issues\n\n* mconf doesn't work well - some manual tweaking is required for string values.\n* GNU make is required and needs to be in $PATH.\n* To get swig's library dependencies to work (and for the C library to be found), I needed to type:\n\n{{indent{{{{&gt; export LD_LIBRARY_PATH=/usr/local/gcc-3.3.1/lib:.}}}\n\n!!!!Cygwin issues\n\n* The bindings all compile but don't run under Cygwin with the exception of Perl. This is due to win32 executables being incompatible with Cygwin libraries.\n\n</div>
  6541. <div tiddler="SiteSubtitle" modifier="CameronRich" modified="200702240025" created="200702240025" tags="">changes, notes and errata</div>
  6542. <div tiddler="SiteTitle" modifier="CameronRich" modified="200702240023" created="200702240023" tags="">axTLS Embedded SSL</div>
  6543. <div tiddler="SiteUrl" modifier="CameronRich" modified="200702240025" created="200702240025" tags="">http://axtls.cerocclub.com.au</div>
  6544. <div tiddler="StyleSheet" modifier="CameronRich" modified="200702250600" created="200701122350" tags="DevFireTheme">/***\nhttp://tiddlystyles.com/#theme:DevFire\nAuthor: Clint Checketts\n***/\n\n/*{{{*/\nbody {\nbackground: #000;\n}\n/*}}}*/\n/***\n!Link styles /% ============================================================= %/\n***/\n/*{{{*/\na,\na.button,\n#mainMenu a.button,\n#sidebarOptions .sliderPanel a{\n color: #ffbf00;\n border: 0;\n background: transparent;\n}\n\na:hover,\na.button:hover,\n#mainMenu a.button:hover,\n#sidebarOptions .sliderPanel a:hover\n#sidebarOptions .sliderPanel a:active{\n color: #ff7f00;\n border: 0;\n border-bottom: #ff7f00 1px dashed;\n background: transparent;\n text-decoration: none;\n}\n\n#displayArea .button.highlight{\n color: #ffbf00;\n background: #4c4c4c;\n}\n/*}}}*/\n/***\n!Header styles /% ============================================================= %/\n***/\n/*{{{*/\n.header{\n border-bottom: 2px solid #ffbf00;\n color: #fff;\n}\n\n.headerForeground a {\n color: #fff;\n}\n\n.header a:hover {\n border-bottom: 1px dashed #fff;\n}\n/*}}}*/\n/***\n!Main menu styles /% ============================================================= %/\n***/\n/*{{{*/\n#mainMenu {color: #fff;}\n#mainMenu h1{\n font-size: 1.1em;\n}\n#mainMenu li,#mainMenu ul{\n list-style: none;\n margin: 0;\n padding: 0;\n}\n/*}}}*/\n/***\n!Sidebar styles /% ============================================================= %/\n***/\n/*{{{*/\n#sidebar {\n right: 0;\n color: #fff;\n border: 2px solid #ffbf00;\n border-width: 0 0 2px 2px;\n}\n#sidebarOptions {\n background-color: #4c4c4c;\n padding: 0;\n}\n\n#sidebarOptions a{\n margin: 0;\n color: #ffbf00;\n border: 0;\n}\n#sidebarOptions a:hover {\n color: #4c4c4c;\n background-color: #ffbf00;\n\n}\n\n#sidebarOptions a:active {\n color: #ffbf00;\n background-color: transparent;\n}\n\n#sidebarOptions .sliderPanel {\n background-color: #333;\n margin: 0;\n}\n\n#sidebarTabs {background-color: #4c4c4c;}\n#sidebarTabs .tabSelected {\n padding: 3px 3px;\n cursor: default;\n color: #ffbf00;\n background-color: #666;\n}\n#sidebarTabs .tabUnselected {\n color: #ffbf00;\n background-color: #5f5f5f;\n padding: 0 4px;\n}\n\n#sidebarTabs .tabUnselected:hover,\n#sidebarTabs .tabContents {\n background-color: #666;\n}\n\n.listTitle{color: #FFF;}\n#sidebarTabs .tabContents a{\n color: #ffbf00;\n}\n\n#sidebarTabs .tabContents a:hover{\n color: #ff7f00;\n background: transparent;\n}\n\n#sidebarTabs .txtMoreTab .tabSelected,\n#sidebarTabs .txtMoreTab .tab:hover,\n#sidebarTabs .txtMoreTab .tabContents{\n color: #ffbf00;\n background: #4c4c4c;\n}\n\n#sidebarTabs .txtMoreTab .tabUnselected {\n color: #ffbf00;\n background: #5f5f5f;\n}\n\n.tab.tabSelected, .tab.tabSelected:hover{color: #ffbf00; border: 0; background-color: #4c4c4c;cursor:default;}\n.tab.tabUnselected {background-color: #666;}\n.tab.tabUnselected:hover{color:#ffbf00; border: 0;background-color: #4c4c4c;}\n.tabContents {\n background-color: #4c4c4c;\n border: 0;\n}\n.tabContents .tabContents{background: #666;}\n.tabContents .tabSelected{background: #666;}\n.tabContents .tabUnselected{background: #5f5f5f;}\n.tabContents .tab:hover{background: #666;}\n/*}}}*/\n/***\n!Message area styles /% ============================================================= %/\n***/\n/*{{{*/\n#messageArea {background-color: #666; color: #fff; border: 2px solid #ffbf00;}\n#messageArea a:link, #messageArea a:visited {color: #ffbf00; text-decoration:none;}\n#messageArea a:hover {color: #ff7f00;}\n#messageArea a:active {color: #ff7f00;}\n#messageArea .messageToolbar a{\n border: 1px solid #ffbf00;\n background: #4c4c4c;\n}\n/*}}}*/\n/***\n!Popup styles /% ============================================================= %/\n***/\n/*{{{*/\n.popup {color: #fff; background-color: #4c4c4c; border: 1px solid #ffbf00;}\n.popup li.disabled{color: #fff;}\n.popup a {color: #ffbf00; }\n.popup a:hover { background: transparent; color: #ff7f00; border: 0;}\n.popup hr {color: #ffbf00; background: #ffbf00;}\n/*}}}*/\n/***\n!Tiddler Display styles /% ============================================================= %/\n***/\n/*{{{*/\n.title{color: #fff;}\nh1, h2, h3, h4, h5 {\n color: #fff;\n background-color: transparent;\n border-bottom: 1px solid #333;\n}\n\n.subtitle{\n color: #666;\n}\n\n.viewer {color: #fff; }\n\n.viewer table{background: #666; color: #fff;}\n\n.viewer th {background-color: #996; color: #fff;}\n\n.viewer pre, .viewer code {color: #ddd; background-color: #4c4c4c; border: 1px solid #ffbf00;}\n\n.viewer hr {color: #666;}\n\n.tiddler .button {color: #4c4c4c;}\n.tiddler .button:hover { color: #ffbf00; background-color: #4c4c4c;}\n.tiddler .button:active {color: #ffbf00; background-color: #4c4c4c;}\n\n.toolbar {\n color: #4c4c4c;\n}\n\n.toolbar a.button,\n.toolbar a.button:hover,\n.toolbar a.button:active,\n.editorFooter a{\n border: 0;\n}\n\n.footer {\n color: #ddd;\n}\n\n.selected .footer {\n color: #888;\n}\n\n.highlight, .marked {\n color: #000;\n background-color: #ffe72f;\n}\n.editorFooter {\n color: #aaa;\n}\n\n.tab{\n-moz-border-radius-topleft: 3px;\n-moz-border-radius-topright: 3px;\n}\n\n.tagging,\n.tagged{\n background: #4c4c4c;\n border: 1px solid #4c4c4c; \n}\n\n.selected .tagging,\n.selected .tagged{\n background-color: #333;\n border: 1px solid #ffbf00;\n}\n\n.tagging .listTitle,\n.tagged .listTitle{\n color: #fff;\n}\n\n.tagging .button,\n.tagged .button{\n color: #ffbf00;\n border: 0;\n padding: 0;\n}\n\n.tagging .button:hover,\n.tagged .button:hover{\nbackground: transparent;\n}\n\n.selected .isTag .tagging.simple,\n.selected .tagged.simple,\n.isTag .tagging.simple,\n.tagged.simple {\n float: none;\n display: inline;\n border: 0;\n background: transparent;\n color: #fff;\n margin: 0;\n}\n\n.cascade {\n background: #4c4c4c;\n color: #ddd;\n border: 1px solid #ffbf00;\n}\n/*}}}*/</div>
  6545. <div tiddler="axhttpd" modifier="YourName" modified="200804011308" created="200702242231" tags="">axhttpd is a small embedded web server using the axTLS library. It is based originally on the web server written by Doug Currie which is at http://www.hcsw.org/awhttpd.\n\n!@@bgcolor(#ff0000):color(#ffffff):axhttpd Features@@ \n\n!!__Basic Authentication__\n\nBasic Authentication uses a password file called &quot;.htpasswd&quot;, in the directory to be protected. This file is formatted as the familiar colon-separated username/encrypted-password pair, records delimited by newlines. The protection does not carry over to subdirectories. The utility program htpasswd is included to help manually edit .htpasswd files.\n\nThe encryption of this password uses a proprietary algorithm due to the dependency of many crypt libraries on DES. An example is in [[/test_dir/no_http|https://127.0.0.1/test_dir/no_http]] (username 'abcd', password is '1234').\n\n//Note: This is an mconf enabled configuration option.//\n\n!!__SSL Protection__\n\nDirectories/files can be accessed using the 'http' or 'https' uri prefix. If normal http access for a directory needs to be disabled, then put &quot;~SSLRequireSSL&quot; into a '.htaccess' file in the directory to be protected. \n\nConversely, use &quot;~SSLDenySSL&quot; to deny access to directories via SSL.\n\nAn example is in [[/test_dir/no_http|http://127.0.0.1/test_dir/no_http]] and [[/test_dir/no_ssl|https://127.0.0.1/test_dir/no_ssl]].\n\nEntire directories can be denied access with a &quot;Deny all&quot; directive (regardless of SSL or authentication). An example is in [[/test_dir/bin|http://127.0.0.1/test_dir/bin]]\n\n!!__CGI__\n\nMost of the CGI 1.1 variables are now placed into the script environment and should work as normal.\n\n!!__Lua and Lua Pages__\n\nThis is a small scripting language gaining popularity in embedded applications due to its small footprint and fast speed.\n\nLua has been incorporated into the build, so simply select it and it will automatically install. Try pointing your browser at [[test_main.html]|http://127.0.0.1/lua/test_main.html]] to see an example of Lua Pages.\n\n//Note: This is an mconf enabled configuration option.//\n\n!!__Directory Listing__\n\nAn mconf option. Allow the files in directories to be displayed. An example is in [[/test_dir|http://127.0.0.1/test_dir]]\n\n!!__Other Features__\n\n* Timeout - HTTP 1.1 allows for persistent connections. This is the time allowed for this connection in seconds.\n* Daemon - Puts the process in daemon mode. \n* SSL session cache size - The size of the session cache (a heavily loaded server should maintain many sessions). A session will save on expensive SSL handshaking.\n\n</div>
  6546. </div>
  6547. <!--POST-BODY-START-->
  6548. <!--POST-BODY-END-->
  6549. </body>
  6550. </html>