index.html 240 KB

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