| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802 |
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/lib/Class.coffee ---- */
- (function() {
- var Class,
- slice = [].slice;
- Class = (function() {
- function Class() {}
- Class.prototype.trace = true;
- Class.prototype.log = function() {
- var args;
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
- if (!this.trace) {
- return;
- }
- if (typeof console === 'undefined') {
- return;
- }
- args.unshift("[" + this.constructor.name + "]");
- console.log.apply(console, args);
- return this;
- };
- Class.prototype.logStart = function() {
- var args, name;
- name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- if (!this.trace) {
- return;
- }
- this.logtimers || (this.logtimers = {});
- this.logtimers[name] = +(new Date);
- if (args.length > 0) {
- this.log.apply(this, ["" + name].concat(slice.call(args), ["(started)"]));
- }
- return this;
- };
- Class.prototype.logEnd = function() {
- var args, ms, name;
- name = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- ms = +(new Date) - this.logtimers[name];
- this.log.apply(this, ["" + name].concat(slice.call(args), ["(Done in " + ms + "ms)"]));
- return this;
- };
- return Class;
- })();
- window.Class = Class;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/lib/Promise.coffee ---- */
- (function() {
- var Promise,
- slice = [].slice;
- Promise = (function() {
- Promise.when = function() {
- var args, fn, i, len, num_uncompleted, promise, task, task_id, tasks;
- tasks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
- num_uncompleted = tasks.length;
- args = new Array(num_uncompleted);
- promise = new Promise();
- fn = function(task_id) {
- return task.then(function() {
- args[task_id] = Array.prototype.slice.call(arguments);
- num_uncompleted--;
- if (num_uncompleted === 0) {
- return promise.complete.apply(promise, args);
- }
- });
- };
- for (task_id = i = 0, len = tasks.length; i < len; task_id = ++i) {
- task = tasks[task_id];
- fn(task_id);
- }
- return promise;
- };
- function Promise() {
- this.resolved = false;
- this.end_promise = null;
- this.result = null;
- this.callbacks = [];
- }
- Promise.prototype.resolve = function() {
- var back, callback, i, len, ref;
- if (this.resolved) {
- return false;
- }
- this.resolved = true;
- this.data = arguments;
- if (!arguments.length) {
- this.data = [true];
- }
- this.result = this.data[0];
- ref = this.callbacks;
- for (i = 0, len = ref.length; i < len; i++) {
- callback = ref[i];
- back = callback.apply(callback, this.data);
- }
- if (this.end_promise) {
- return this.end_promise.resolve(back);
- }
- };
- Promise.prototype.fail = function() {
- return this.resolve(false);
- };
- Promise.prototype.then = function(callback) {
- if (this.resolved === true) {
- callback.apply(callback, this.data);
- return;
- }
- this.callbacks.push(callback);
- return this.end_promise = new Promise();
- };
- return Promise;
- })();
- window.Promise = Promise;
- /*
- s = Date.now()
- log = (text) ->
- console.log Date.now()-s, Array.prototype.slice.call(arguments).join(", ")
-
- log "Started"
-
- cmd = (query) ->
- p = new Promise()
- setTimeout ( ->
- p.resolve query+" Result"
- ), 100
- return p
-
- back = cmd("SELECT * FROM message").then (res) ->
- log res
- return "Return from query"
- .then (res) ->
- log "Back then", res
-
- log "Query started", back
- */
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/lib/Property.coffee ---- */
- (function() {
- Function.prototype.property = function(prop, desc) {
- return Object.defineProperty(this.prototype, prop, desc);
- };
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/lib/Prototypes.coffee ---- */
- (function() {
- String.prototype.startsWith = function(s) {
- return this.slice(0, s.length) === s;
- };
- String.prototype.endsWith = function(s) {
- return s === '' || this.slice(-s.length) === s;
- };
- String.prototype.repeat = function(count) {
- return new Array(count + 1).join(this);
- };
- window.isEmpty = function(obj) {
- var key;
- for (key in obj) {
- return false;
- }
- return true;
- };
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/lib/maquette.js ---- */
- (function (root, factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['exports'], factory);
- } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
- // CommonJS
- factory(exports);
- } else {
- // Browser globals
- factory(root.maquette = {});
- }
- }(this, function (exports) {
- 'use strict';
- ;
- ;
- ;
- ;
- var NAMESPACE_W3 = 'http://www.w3.org/';
- var NAMESPACE_SVG = NAMESPACE_W3 + '2000/svg';
- var NAMESPACE_XLINK = NAMESPACE_W3 + '1999/xlink';
- // Utilities
- var emptyArray = [];
- var extend = function (base, overrides) {
- var result = {};
- Object.keys(base).forEach(function (key) {
- result[key] = base[key];
- });
- if (overrides) {
- Object.keys(overrides).forEach(function (key) {
- result[key] = overrides[key];
- });
- }
- return result;
- };
- // Hyperscript helper functions
- var same = function (vnode1, vnode2) {
- if (vnode1.vnodeSelector !== vnode2.vnodeSelector) {
- return false;
- }
- if (vnode1.properties && vnode2.properties) {
- if (vnode1.properties.key !== vnode2.properties.key) {
- return false;
- }
- return vnode1.properties.bind === vnode2.properties.bind;
- }
- return !vnode1.properties && !vnode2.properties;
- };
- var toTextVNode = function (data) {
- return {
- vnodeSelector: '',
- properties: undefined,
- children: undefined,
- text: data.toString(),
- domNode: null
- };
- };
- var appendChildren = function (parentSelector, insertions, main) {
- for (var i = 0; i < insertions.length; i++) {
- var item = insertions[i];
- if (Array.isArray(item)) {
- appendChildren(parentSelector, item, main);
- } else {
- if (item !== null && item !== undefined) {
- if (!item.hasOwnProperty('vnodeSelector')) {
- item = toTextVNode(item);
- }
- main.push(item);
- }
- }
- }
- };
- // Render helper functions
- var missingTransition = function () {
- throw new Error('Provide a transitions object to the projectionOptions to do animations');
- };
- var DEFAULT_PROJECTION_OPTIONS = {
- namespace: undefined,
- eventHandlerInterceptor: undefined,
- styleApplyer: function (domNode, styleName, value) {
- // Provides a hook to add vendor prefixes for browsers that still need it.
- domNode.style[styleName] = value;
- },
- transitions: {
- enter: missingTransition,
- exit: missingTransition
- }
- };
- var applyDefaultProjectionOptions = function (projectorOptions) {
- return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions);
- };
- var checkStyleValue = function (styleValue) {
- if (typeof styleValue !== 'string') {
- throw new Error('Style values must be strings');
- }
- };
- var setProperties = function (domNode, properties, projectionOptions) {
- if (!properties) {
- return;
- }
- var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor;
- var propNames = Object.keys(properties);
- var propCount = propNames.length;
- for (var i = 0; i < propCount; i++) {
- var propName = propNames[i];
- /* tslint:disable:no-var-keyword: edge case */
- var propValue = properties[propName];
- /* tslint:enable:no-var-keyword */
- if (propName === 'className') {
- throw new Error('Property "className" is not supported, use "class".');
- } else if (propName === 'class') {
- if (domNode.className) {
- // May happen if classes is specified before class
- domNode.className += ' ' + propValue;
- } else {
- domNode.className = propValue;
- }
- } else if (propName === 'classes') {
- // object with string keys and boolean values
- var classNames = Object.keys(propValue);
- var classNameCount = classNames.length;
- for (var j = 0; j < classNameCount; j++) {
- var className = classNames[j];
- if (propValue[className]) {
- domNode.classList.add(className);
- }
- }
- } else if (propName === 'styles') {
- // object with string keys and string (!) values
- var styleNames = Object.keys(propValue);
- var styleCount = styleNames.length;
- for (var j = 0; j < styleCount; j++) {
- var styleName = styleNames[j];
- var styleValue = propValue[styleName];
- if (styleValue) {
- checkStyleValue(styleValue);
- projectionOptions.styleApplyer(domNode, styleName, styleValue);
- }
- }
- } else if (propName === 'key') {
- continue;
- } else if (propValue === null || propValue === undefined) {
- continue;
- } else {
- var type = typeof propValue;
- if (type === 'function') {
- if (propName.lastIndexOf('on', 0) === 0) {
- if (eventHandlerInterceptor) {
- propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers
- }
- if (propName === 'oninput') {
- (function () {
- // record the evt.target.value, because IE and Edge sometimes do a requestAnimationFrame between changing value and running oninput
- var oldPropValue = propValue;
- propValue = function (evt) {
- evt.target['oninput-value'] = evt.target.value;
- // may be HTMLTextAreaElement as well
- oldPropValue.apply(this, [evt]);
- };
- }());
- }
- domNode[propName] = propValue;
- }
- } else if (type === 'string' && propName !== 'value' && propName !== 'innerHTML') {
- if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') {
- domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);
- } else {
- domNode.setAttribute(propName, propValue);
- }
- } else {
- domNode[propName] = propValue;
- }
- }
- }
- };
- var updateProperties = function (domNode, previousProperties, properties, projectionOptions) {
- if (!properties) {
- return;
- }
- var propertiesUpdated = false;
- var propNames = Object.keys(properties);
- var propCount = propNames.length;
- for (var i = 0; i < propCount; i++) {
- var propName = propNames[i];
- // assuming that properties will be nullified instead of missing is by design
- var propValue = properties[propName];
- var previousValue = previousProperties[propName];
- if (propName === 'class') {
- if (previousValue !== propValue) {
- throw new Error('"class" property may not be updated. Use the "classes" property for conditional css classes.');
- }
- } else if (propName === 'classes') {
- var classList = domNode.classList;
- var classNames = Object.keys(propValue);
- var classNameCount = classNames.length;
- for (var j = 0; j < classNameCount; j++) {
- var className = classNames[j];
- var on = !!propValue[className];
- var previousOn = !!previousValue[className];
- if (on === previousOn) {
- continue;
- }
- propertiesUpdated = true;
- if (on) {
- classList.add(className);
- } else {
- classList.remove(className);
- }
- }
- } else if (propName === 'styles') {
- var styleNames = Object.keys(propValue);
- var styleCount = styleNames.length;
- for (var j = 0; j < styleCount; j++) {
- var styleName = styleNames[j];
- var newStyleValue = propValue[styleName];
- var oldStyleValue = previousValue[styleName];
- if (newStyleValue === oldStyleValue) {
- continue;
- }
- propertiesUpdated = true;
- if (newStyleValue) {
- checkStyleValue(newStyleValue);
- projectionOptions.styleApplyer(domNode, styleName, newStyleValue);
- } else {
- projectionOptions.styleApplyer(domNode, styleName, '');
- }
- }
- } else {
- if (!propValue && typeof previousValue === 'string') {
- propValue = '';
- }
- if (propName === 'value') {
- if (domNode[propName] !== propValue && domNode['oninput-value'] !== propValue) {
- domNode[propName] = propValue;
- // Reset the value, even if the virtual DOM did not change
- domNode['oninput-value'] = undefined;
- }
- // else do not update the domNode, otherwise the cursor position would be changed
- if (propValue !== previousValue) {
- propertiesUpdated = true;
- }
- } else if (propValue !== previousValue) {
- var type = typeof propValue;
- if (type === 'function') {
- throw new Error('Functions may not be updated on subsequent renders (property: ' + propName + '). Hint: declare event handler functions outside the render() function.');
- }
- if (type === 'string' && propName !== 'innerHTML') {
- if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') {
- domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);
- } else {
- domNode.setAttribute(propName, propValue);
- }
- } else {
- if (domNode[propName] !== propValue) {
- domNode[propName] = propValue;
- }
- }
- propertiesUpdated = true;
- }
- }
- }
- return propertiesUpdated;
- };
- var findIndexOfChild = function (children, sameAs, start) {
- if (sameAs.vnodeSelector !== '') {
- // Never scan for text-nodes
- for (var i = start; i < children.length; i++) {
- if (same(children[i], sameAs)) {
- return i;
- }
- }
- }
- return -1;
- };
- var nodeAdded = function (vNode, transitions) {
- if (vNode.properties) {
- var enterAnimation = vNode.properties.enterAnimation;
- if (enterAnimation) {
- if (typeof enterAnimation === 'function') {
- enterAnimation(vNode.domNode, vNode.properties);
- } else {
- transitions.enter(vNode.domNode, vNode.properties, enterAnimation);
- }
- }
- }
- };
- var nodeToRemove = function (vNode, transitions) {
- var domNode = vNode.domNode;
- if (vNode.properties) {
- var exitAnimation = vNode.properties.exitAnimation;
- if (exitAnimation) {
- domNode.style.pointerEvents = 'none';
- var removeDomNode = function () {
- if (domNode.parentNode) {
- domNode.parentNode.removeChild(domNode);
- }
- };
- if (typeof exitAnimation === 'function') {
- exitAnimation(domNode, removeDomNode, vNode.properties);
- return;
- } else {
- transitions.exit(vNode.domNode, vNode.properties, exitAnimation, removeDomNode);
- return;
- }
- }
- }
- if (domNode.parentNode) {
- domNode.parentNode.removeChild(domNode);
- }
- };
- var checkDistinguishable = function (childNodes, indexToCheck, parentVNode, operation) {
- var childNode = childNodes[indexToCheck];
- if (childNode.vnodeSelector === '') {
- return; // Text nodes need not be distinguishable
- }
- var properties = childNode.properties;
- var key = properties ? properties.key === undefined ? properties.bind : properties.key : undefined;
- if (!key) {
- for (var i = 0; i < childNodes.length; i++) {
- if (i !== indexToCheck) {
- var node = childNodes[i];
- if (same(node, childNode)) {
- if (operation === 'added') {
- throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'added, but there is now more than one. You must add unique key properties to make them distinguishable.');
- } else {
- throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' + 'removed, but there were more than one. You must add unique key properties to make them distinguishable.');
- }
- }
- }
- }
- }
- };
- var createDom;
- var updateDom;
- var updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) {
- if (oldChildren === newChildren) {
- return false;
- }
- oldChildren = oldChildren || emptyArray;
- newChildren = newChildren || emptyArray;
- var oldChildrenLength = oldChildren.length;
- var newChildrenLength = newChildren.length;
- var transitions = projectionOptions.transitions;
- var oldIndex = 0;
- var newIndex = 0;
- var i;
- var textUpdated = false;
- while (newIndex < newChildrenLength) {
- var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : undefined;
- var newChild = newChildren[newIndex];
- if (oldChild !== undefined && same(oldChild, newChild)) {
- textUpdated = updateDom(oldChild, newChild, projectionOptions) || textUpdated;
- oldIndex++;
- } else {
- var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1);
- if (findOldIndex >= 0) {
- // Remove preceding missing children
- for (i = oldIndex; i < findOldIndex; i++) {
- nodeToRemove(oldChildren[i], transitions);
- checkDistinguishable(oldChildren, i, vnode, 'removed');
- }
- textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated;
- oldIndex = findOldIndex + 1;
- } else {
- // New child
- createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions);
- nodeAdded(newChild, transitions);
- checkDistinguishable(newChildren, newIndex, vnode, 'added');
- }
- }
- newIndex++;
- }
- if (oldChildrenLength > oldIndex) {
- // Remove child fragments
- for (i = oldIndex; i < oldChildrenLength; i++) {
- nodeToRemove(oldChildren[i], transitions);
- checkDistinguishable(oldChildren, i, vnode, 'removed');
- }
- }
- return textUpdated;
- };
- var addChildren = function (domNode, children, projectionOptions) {
- if (!children) {
- return;
- }
- for (var i = 0; i < children.length; i++) {
- createDom(children[i], domNode, undefined, projectionOptions);
- }
- };
- var initPropertiesAndChildren = function (domNode, vnode, projectionOptions) {
- addChildren(domNode, vnode.children, projectionOptions);
- // children before properties, needed for value property of <select>.
- if (vnode.text) {
- domNode.textContent = vnode.text;
- }
- setProperties(domNode, vnode.properties, projectionOptions);
- if (vnode.properties && vnode.properties.afterCreate) {
- vnode.properties.afterCreate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children);
- }
- };
- createDom = function (vnode, parentNode, insertBefore, projectionOptions) {
- var domNode, i, c, start = 0, type, found;
- var vnodeSelector = vnode.vnodeSelector;
- if (vnodeSelector === '') {
- domNode = vnode.domNode = document.createTextNode(vnode.text);
- if (insertBefore !== undefined) {
- parentNode.insertBefore(domNode, insertBefore);
- } else {
- parentNode.appendChild(domNode);
- }
- } else {
- for (i = 0; i <= vnodeSelector.length; ++i) {
- c = vnodeSelector.charAt(i);
- if (i === vnodeSelector.length || c === '.' || c === '#') {
- type = vnodeSelector.charAt(start - 1);
- found = vnodeSelector.slice(start, i);
- if (type === '.') {
- domNode.classList.add(found);
- } else if (type === '#') {
- domNode.id = found;
- } else {
- if (found === 'svg') {
- projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG });
- }
- if (projectionOptions.namespace !== undefined) {
- domNode = vnode.domNode = document.createElementNS(projectionOptions.namespace, found);
- } else {
- domNode = vnode.domNode = document.createElement(found);
- }
- if (insertBefore !== undefined) {
- parentNode.insertBefore(domNode, insertBefore);
- } else {
- parentNode.appendChild(domNode);
- }
- }
- start = i + 1;
- }
- }
- initPropertiesAndChildren(domNode, vnode, projectionOptions);
- }
- };
- updateDom = function (previous, vnode, projectionOptions) {
- var domNode = previous.domNode;
- var textUpdated = false;
- if (previous === vnode) {
- return false; // By contract, VNode objects may not be modified anymore after passing them to maquette
- }
- var updated = false;
- if (vnode.vnodeSelector === '') {
- if (vnode.text !== previous.text) {
- var newVNode = document.createTextNode(vnode.text);
- domNode.parentNode.replaceChild(newVNode, domNode);
- vnode.domNode = newVNode;
- textUpdated = true;
- return textUpdated;
- }
- } else {
- if (vnode.vnodeSelector.lastIndexOf('svg', 0) === 0) {
- projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG });
- }
- if (previous.text !== vnode.text) {
- updated = true;
- if (vnode.text === undefined) {
- domNode.removeChild(domNode.firstChild); // the only textnode presumably
- } else {
- domNode.textContent = vnode.text;
- }
- }
- updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated;
- updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated;
- if (vnode.properties && vnode.properties.afterUpdate) {
- vnode.properties.afterUpdate(domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children);
- }
- }
- if (updated && vnode.properties && vnode.properties.updateAnimation) {
- vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties);
- }
- vnode.domNode = previous.domNode;
- return textUpdated;
- };
- var createProjection = function (vnode, projectionOptions) {
- return {
- update: function (updatedVnode) {
- if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) {
- throw new Error('The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)');
- }
- updateDom(vnode, updatedVnode, projectionOptions);
- vnode = updatedVnode;
- },
- domNode: vnode.domNode
- };
- };
- ;
- // The other two parameters are not added here, because the Typescript compiler creates surrogate code for desctructuring 'children'.
- exports.h = function (selector) {
- var properties = arguments[1];
- if (typeof selector !== 'string') {
- throw new Error();
- }
- var childIndex = 1;
- if (properties && !properties.hasOwnProperty('vnodeSelector') && !Array.isArray(properties) && typeof properties === 'object') {
- childIndex = 2;
- } else {
- // Optional properties argument was omitted
- properties = undefined;
- }
- var text = undefined;
- var children = undefined;
- var argsLength = arguments.length;
- // Recognize a common special case where there is only a single text node
- if (argsLength === childIndex + 1) {
- var onlyChild = arguments[childIndex];
- if (typeof onlyChild === 'string') {
- text = onlyChild;
- } else if (onlyChild !== undefined && onlyChild.length === 1 && typeof onlyChild[0] === 'string') {
- text = onlyChild[0];
- }
- }
- if (text === undefined) {
- children = [];
- for (; childIndex < arguments.length; childIndex++) {
- var child = arguments[childIndex];
- if (child === null || child === undefined) {
- continue;
- } else if (Array.isArray(child)) {
- appendChildren(selector, child, children);
- } else if (child.hasOwnProperty('vnodeSelector')) {
- children.push(child);
- } else {
- children.push(toTextVNode(child));
- }
- }
- }
- return {
- vnodeSelector: selector,
- properties: properties,
- children: children,
- text: text === '' ? undefined : text,
- domNode: null
- };
- };
- /**
- * Contains simple low-level utility functions to manipulate the real DOM.
- */
- exports.dom = {
- /**
- * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in
- * its [[Projection.domNode|domNode]] property.
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
- * objects may only be rendered once.
- * @param projectionOptions - Options to be used to create and update the projection.
- * @returns The [[Projection]] which also contains the DOM Node that was created.
- */
- create: function (vnode, projectionOptions) {
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
- createDom(vnode, document.createElement('div'), undefined, projectionOptions);
- return createProjection(vnode, projectionOptions);
- },
- /**
- * Appends a new childnode to the DOM which is generated from a [[VNode]].
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
- * @param parentNode - The parent node for the new childNode.
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
- * objects may only be rendered once.
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
- * @returns The [[Projection]] that was created.
- */
- append: function (parentNode, vnode, projectionOptions) {
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
- createDom(vnode, parentNode, undefined, projectionOptions);
- return createProjection(vnode, projectionOptions);
- },
- /**
- * Inserts a new DOM node which is generated from a [[VNode]].
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
- * @param beforeNode - The node that the DOM Node is inserted before.
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.
- * NOTE: [[VNode]] objects may only be rendered once.
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
- * @returns The [[Projection]] that was created.
- */
- insertBefore: function (beforeNode, vnode, projectionOptions) {
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
- createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions);
- return createProjection(vnode, projectionOptions);
- },
- /**
- * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.
- * This means that the virtual DOM and the real DOM will have one overlapping element.
- * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
- * @param domNode - The existing element to adopt as the root of the new virtual DOM. Existing attributes and childnodes are preserved.
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects
- * may only be rendered once.
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
- * @returns The [[Projection]] that was created.
- */
- merge: function (element, vnode, projectionOptions) {
- projectionOptions = applyDefaultProjectionOptions(projectionOptions);
- vnode.domNode = element;
- initPropertiesAndChildren(element, vnode, projectionOptions);
- return createProjection(vnode, projectionOptions);
- }
- };
- /**
- * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.
- * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.
- * For more information, see [[CalculationCache]].
- *
- * @param <Result> The type of the value that is cached.
- */
- exports.createCache = function () {
- var cachedInputs = undefined;
- var cachedOutcome = undefined;
- var result = {
- invalidate: function () {
- cachedOutcome = undefined;
- cachedInputs = undefined;
- },
- result: function (inputs, calculation) {
- if (cachedInputs) {
- for (var i = 0; i < inputs.length; i++) {
- if (cachedInputs[i] !== inputs[i]) {
- cachedOutcome = undefined;
- }
- }
- }
- if (!cachedOutcome) {
- cachedOutcome = calculation();
- cachedInputs = inputs;
- }
- return cachedOutcome;
- }
- };
- return result;
- };
- /**
- * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects.
- * See {@link http://maquettejs.org/docs/arrays.html|Working with arrays}.
- *
- * @param <Source> The type of source items. A database-record for instance.
- * @param <Target> The type of target items. A [[Component]] for instance.
- * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number.
- * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical
- * to the `callback` argument in `Array.map(callback)`.
- * @param updateResult `function(source, target, index)` that updates a result to an updated source.
- */
- exports.createMapping = function (getSourceKey, createResult, updateResult) {
- var keys = [];
- var results = [];
- return {
- results: results,
- map: function (newSources) {
- var newKeys = newSources.map(getSourceKey);
- var oldTargets = results.slice();
- var oldIndex = 0;
- for (var i = 0; i < newSources.length; i++) {
- var source = newSources[i];
- var sourceKey = newKeys[i];
- if (sourceKey === keys[oldIndex]) {
- results[i] = oldTargets[oldIndex];
- updateResult(source, oldTargets[oldIndex], i);
- oldIndex++;
- } else {
- var found = false;
- for (var j = 1; j < keys.length; j++) {
- var searchIndex = (oldIndex + j) % keys.length;
- if (keys[searchIndex] === sourceKey) {
- results[i] = oldTargets[searchIndex];
- updateResult(newSources[i], oldTargets[searchIndex], i);
- oldIndex = searchIndex + 1;
- found = true;
- break;
- }
- }
- if (!found) {
- results[i] = createResult(source, i);
- }
- }
- }
- results.length = newSources.length;
- keys = newKeys;
- }
- };
- };
- /**
- * Creates a [[Projector]] instance using the provided projectionOptions.
- *
- * For more information, see [[Projector]].
- *
- * @param projectionOptions Options that influence how the DOM is rendered and updated.
- */
- exports.createProjector = function (projectorOptions) {
- var projector;
- var projectionOptions = applyDefaultProjectionOptions(projectorOptions);
- projectionOptions.eventHandlerInterceptor = function (propertyName, eventHandler, domNode, properties) {
- return function () {
- // intercept function calls (event handlers) to do a render afterwards.
- projector.scheduleRender();
- return eventHandler.apply(properties.bind || this, arguments);
- };
- };
- var renderCompleted = true;
- var scheduled;
- var stopped = false;
- var projections = [];
- var renderFunctions = [];
- // matches the projections array
- var doRender = function () {
- scheduled = undefined;
- if (!renderCompleted) {
- return; // The last render threw an error, it should be logged in the browser console.
- }
- renderCompleted = false;
- for (var i = 0; i < projections.length; i++) {
- var updatedVnode = renderFunctions[i]();
- projections[i].update(updatedVnode);
- }
- renderCompleted = true;
- };
- projector = {
- scheduleRender: function () {
- if (!scheduled && !stopped) {
- scheduled = requestAnimationFrame(doRender);
- }
- },
- stop: function () {
- if (scheduled) {
- cancelAnimationFrame(scheduled);
- scheduled = undefined;
- }
- stopped = true;
- },
- resume: function () {
- stopped = false;
- renderCompleted = true;
- projector.scheduleRender();
- },
- append: function (parentNode, renderMaquetteFunction) {
- projections.push(exports.dom.append(parentNode, renderMaquetteFunction(), projectionOptions));
- renderFunctions.push(renderMaquetteFunction);
- },
- insertBefore: function (beforeNode, renderMaquetteFunction) {
- projections.push(exports.dom.insertBefore(beforeNode, renderMaquetteFunction(), projectionOptions));
- renderFunctions.push(renderMaquetteFunction);
- },
- merge: function (domNode, renderMaquetteFunction) {
- projections.push(exports.dom.merge(domNode, renderMaquetteFunction(), projectionOptions));
- renderFunctions.push(renderMaquetteFunction);
- },
- replace: function (domNode, renderMaquetteFunction) {
- var vnode = renderMaquetteFunction();
- createDom(vnode, domNode.parentNode, domNode, projectionOptions);
- domNode.parentNode.removeChild(domNode);
- projections.push(createProjection(vnode, projectionOptions));
- renderFunctions.push(renderMaquetteFunction);
- },
- detach: function (renderMaquetteFunction) {
- for (var i = 0; i < renderFunctions.length; i++) {
- if (renderFunctions[i] === renderMaquetteFunction) {
- renderFunctions.splice(i, 1);
- return projections.splice(i, 1)[0];
- }
- }
- throw new Error('renderMaquetteFunction was not found');
- }
- };
- return projector;
- };
- }));
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/lib/marked.min.js ---- */
- /**
- * marked - a markdown parser
- * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
- * https://github.com/chjj/marked
- */
- (function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]="right"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]="center"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]="left"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].split(/ *\| */)}this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[2]==="="?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"hr"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"blockquote_start"});cap=cap[0].replace(/^ *> ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|\d+\.) +/,"");if(~item.indexOf("\n ")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp("^ {1,"+space+"}","gm"),""):item.replace(/^ {1,4}/gm,"")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script"||cap[1]==="style",text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]="right"}else if(/^ *:-+: *$/.test(item.align[i])){item.align[i]="center"}else if(/^ *:-+ *$/.test(item.align[i])){item.align[i]="left"}else{item.align[i]=null}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */)}this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:"paragraph",text:cap[1].charAt(cap[1].length-1)==="\n"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"text",text:cap[0]});continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return this.tokens};var inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};inline._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;inline._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^<a /i.test(cap[0])){this.inLink=true}else if(this.inLink&&/^<\/a>/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"<pre><code>"+(escaped?code:escape(code,true))+"\n</code></pre>"}return'<pre><code class="'+this.options.langPrefix+escape(lang,true)+'">'+(escaped?code:escape(code,true))+"\n</code></pre>\n"};Renderer.prototype.blockquote=function(quote){return"<blockquote>\n"+quote+"</blockquote>\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"<h"+level+' id="'+this.options.headerPrefix+raw.toLowerCase().replace(/[^\w]+/g,"-")+'">'+text+"</h"+level+">\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"</"+type+">\n"};Renderer.prototype.listitem=function(text){return"<li>"+text+"</li>\n"};Renderer.prototype.paragraph=function(text){return"<p>"+text+"</p>\n"};Renderer.prototype.table=function(header,body){return"<table>\n"+"<thead>\n"+header+"</thead>\n"+"<tbody>\n"+body+"</tbody>\n"+"</table>\n"};Renderer.prototype.tablerow=function(content){return"<tr>\n"+content+"</tr>\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"</"+type+">\n"};Renderer.prototype.strong=function(text){return"<strong>"+text+"</strong>"};Renderer.prototype.em=function(text){return"<em>"+text+"</em>"};Renderer.prototype.codespan=function(text){return"<code>"+text+"</code>"};Renderer.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"};Renderer.prototype.del=function(text){return"<del>"+text+"</del>"};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0){return""}}var out='<a href="'+href+'"';if(title){out+=' title="'+title+'"'}out+=">"+text+"</a>";return out};Renderer.prototype.image=function(href,title,text){var out='<img src="'+href+'" alt="'+text+'"';if(title){out+=' title="'+title+'"'}out+=this.options.xhtml?"/>":">";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i<this.token.header.length;i++){flags={header:true,align:this.token.align[i]};cell+=this.renderer.tablecell(this.inline.output(this.token.header[i]),{header:true,align:this.token.align[i]})}header+=this.renderer.tablerow(cell);for(i=0;i<this.token.cells.length;i++){row=this.token.cells[i];cell="";for(j=0;j<row.length;j++){cell+=this.renderer.tablecell(this.inline.output(row[j]),{header:false,align:this.token.align[j]})}body+=this.renderer.tablerow(cell)}return this.renderer.table(header,body)}case"blockquote_start":{var body="";while(this.next().type!=="blockquote_end"){body+=this.tok()}return this.renderer.blockquote(body)}case"list_start":{var body="",ordered=this.token.ordered;while(this.next().type!=="list_end"){body+=this.tok()}return this.renderer.list(body,ordered)}case"list_item_start":{var body="";while(this.next().type!=="list_item_end"){body+=this.token.type==="text"?this.parseText():this.tok()}return this.renderer.listitem(body)}case"loose_item_start":{var body="";while(this.next().type!=="list_item_end"){body+=this.tok()}return this.renderer.listitem(body)}case"html":{var html=!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;return this.renderer.html(html)}case"paragraph":{return this.renderer.paragraph(this.inline.output(this.token.text))}case"text":{return this.renderer.paragraph(this.parseText())}}};function escape(html,encode){return html.replace(!encode?/&(?!#?\w+;)/g:/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target){if(Object.prototype.hasOwnProperty.call(target,key)){obj[key]=target[key]}}}return obj}function marked(src,opt,callback){if(callback||typeof opt==="function"){if(!callback){callback=opt;opt=null}opt=merge({},marked.defaults,opt||{});var highlight=opt.highlight,tokens,pending,i=0;try{tokens=Lexer.lex(src,opt)}catch(e){return callback(e)}pending=tokens.length;var done=function(err){if(err){opt.highlight=highlight;return callback(err)}var out;try{out=Parser.parse(tokens,opt)}catch(e){err=e}opt.highlight=highlight;return err?callback(err):callback(null,out)};if(!highlight||highlight.length<3){return done()}delete opt.highlight;if(!pending)return done();for(;i<tokens.length;i++){(function(token){if(token.type!=="code"){return--pending||done()}return highlight(token.text,token.lang,function(err,code){if(err)return done(err);if(code==null||code===token.text){return--pending||done()}token.text=code;token.escaped=true;--pending||done()})})(tokens[i])}return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+="\nPlease report this to https://github.com/chjj/marked.";if((opt||marked.defaults).silent){return"<p>An error occured:</p><pre>"+escape(e.message+"",true)+"</pre>"}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}());
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageFiles/Bigfiles.coffee ---- */
- (function() {
- var Bigfiles,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- Bigfiles = (function(superClass) {
- extend(Bigfiles, superClass);
- function Bigfiles() {
- this.render = bind(this.render, this);
- this.getHref = bind(this.getHref, this);
- this.updateFiles = bind(this.updateFiles, this);
- this.files = new SiteFiles(this);
- this.files.mode = "bigfiles";
- this.files.limit = 100;
- this.files.update = this.updateFiles;
- this.row = {
- "address": "bigfiles"
- };
- }
- Bigfiles.prototype.updateFiles = function(cb) {
- var orderby;
- if (Page.server_info.rev < 3090) {
- return typeof cb === "function" ? cb() : void 0;
- }
- orderby = this.files.orderby + (this.files.orderby_desc ? " DESC" : "");
- return Page.cmd("optionalFileList", {
- address: "all",
- filter: "downloaded,bigfile",
- limit: this.files.limit + 1,
- orderby: orderby
- }, (function(_this) {
- return function(res) {
- var i, len, row;
- for (i = 0, len = res.length; i < len; i++) {
- row = res[i];
- row.site = Page.site_list.sites_byaddress[row.address];
- }
- _this.files.items = res.slice(0, +(_this.files.limit - 1) + 1 || 9e9);
- _this.files.loaded = true;
- _this.files.has_more = res.length > _this.files.limit;
- Page.projector.scheduleRender();
- return typeof cb === "function" ? cb() : void 0;
- };
- })(this));
- };
- Bigfiles.prototype.getHref = function(row) {
- return row.inner_path;
- };
- Bigfiles.prototype.render = function() {
- if (!this.files.items.length) {
- return [];
- }
- return h("div.Site", [h("div.title", [h("h3.name", "Bigfiles")]), this.files.render()]);
- };
- return Bigfiles;
- })(Class);
- window.Bigfiles = Bigfiles;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageFiles/PageFiles.coffee ---- */
- (function() {
- var PageFiles,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- PageFiles = (function(superClass) {
- extend(PageFiles, superClass);
- function PageFiles() {
- this.onSiteInfo = bind(this.onSiteInfo, this);
- this.render = bind(this.render, this);
- this.updateAllFiles = bind(this.updateAllFiles, this);
- this.updateOptionalStats = bind(this.updateOptionalStats, this);
- this.renderSelectbar = bind(this.renderSelectbar, this);
- this.renderTotalbar = bind(this.renderTotalbar, this);
- this.handleLimitInput = bind(this.handleLimitInput, this);
- this.handleTotalbarMenu = bind(this.handleTotalbarMenu, this);
- this.handleLimitSetClick = bind(this.handleLimitSetClick, this);
- this.handleLimitCancelClick = bind(this.handleLimitCancelClick, this);
- this.handleEditlimitClick = bind(this.handleEditlimitClick, this);
- this.handleTotalbarOut = bind(this.handleTotalbarOut, this);
- this.handleTotalbarOver = bind(this.handleTotalbarOver, this);
- this.handleSelectbarDelete = bind(this.handleSelectbarDelete, this);
- this.handleSelectbarUnpin = bind(this.handleSelectbarUnpin, this);
- this.handleSelectbarPin = bind(this.handleSelectbarPin, this);
- this.handleSelectbarCancel = bind(this.handleSelectbarCancel, this);
- this.checkSelectedFiles = bind(this.checkSelectedFiles, this);
- this.getSites = bind(this.getSites, this);
- this.need_update = true;
- this.updating_files = 0;
- this.optional_stats = {
- limit: "0",
- free: "0",
- used: "0"
- };
- this.updateOptionalStats();
- this.hover_totalbar = false;
- this.menu_totalbar = new Menu();
- this.editing_limit = false;
- this.limit = "";
- this.selected_files_num = 0;
- this.selected_files_size = 0;
- this.selected_files_pinned = 0;
- this.bigfiles = new Bigfiles();
- this.display_limit = 0;
- this;
- }
- PageFiles.prototype.getSites = function() {
- var address, back, bigfile_sites, file, i, len, name, ref, site;
- if (this.bigfiles.files.items.length > 0) {
- back = [];
- bigfile_sites = {};
- ref = this.bigfiles.files.items;
- for (i = 0, len = ref.length; i < len; i++) {
- file = ref[i];
- if (bigfile_sites[name = file.site.row.address] == null) {
- bigfile_sites[name] = {
- row: file.site.row,
- files: {
- items: [],
- selected: this.bigfiles.files.selected,
- update: this.bigfiles.files.update
- }
- };
- }
- bigfile_sites[file.site.row.address].files.items.push(file);
- }
- for (address in bigfile_sites) {
- site = bigfile_sites[address];
- back.push(site);
- }
- back = back.concat(Page.site_list.sites);
- return back;
- } else {
- return Page.site_list.sites;
- }
- };
- PageFiles.prototype.checkSelectedFiles = function() {
- var i, len, ref, results, site, site_file;
- this.selected_files_num = 0;
- this.selected_files_size = 0;
- this.selected_files_pinned = 0;
- ref = this.getSites();
- results = [];
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- results.push((function() {
- var j, len1, ref1, results1;
- ref1 = site.files.items;
- results1 = [];
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- site_file = ref1[j];
- if (!site.files.selected[site_file.inner_path]) {
- continue;
- }
- this.selected_files_num += 1;
- this.selected_files_size += site_file.size;
- results1.push(this.selected_files_pinned += site_file.is_pinned);
- }
- return results1;
- }).call(this));
- }
- return results;
- };
- PageFiles.prototype.handleSelectbarCancel = function() {
- var i, j, key, len, len1, ref, ref1, ref2, site, site_file, val;
- ref = this.getSites();
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- ref1 = site.files.items;
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- site_file = ref1[j];
- ref2 = site.files.selected;
- for (key in ref2) {
- val = ref2[key];
- delete site.files.selected[key];
- }
- }
- }
- this.checkSelectedFiles();
- Page.projector.scheduleRender();
- return false;
- };
- PageFiles.prototype.handleSelectbarPin = function() {
- var i, inner_paths, len, ref, site, site_file;
- ref = this.getSites();
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- inner_paths = (function() {
- var j, len1, ref1, results;
- ref1 = site.files.items;
- results = [];
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- site_file = ref1[j];
- if (site.files.selected[site_file.inner_path]) {
- results.push(site_file.inner_path);
- }
- }
- return results;
- })();
- if (inner_paths.length > 0) {
- (function(site) {
- return Page.cmd("optionalFilePin", [inner_paths, site.row.address], function() {
- return site.files.update();
- });
- })(site);
- }
- }
- return this.handleSelectbarCancel();
- };
- PageFiles.prototype.handleSelectbarUnpin = function() {
- var i, inner_paths, len, ref, site, site_file;
- ref = this.getSites();
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- inner_paths = (function() {
- var j, len1, ref1, results;
- ref1 = site.files.items;
- results = [];
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- site_file = ref1[j];
- if (site.files.selected[site_file.inner_path]) {
- results.push(site_file.inner_path);
- }
- }
- return results;
- })();
- if (inner_paths.length > 0) {
- (function(site) {
- return Page.cmd("optionalFileUnpin", [inner_paths, site.row.address], function() {
- return site.files.update();
- });
- })(site);
- }
- }
- return this.handleSelectbarCancel();
- };
- PageFiles.prototype.handleSelectbarDelete = function() {
- var i, inner_path, inner_paths, j, len, len1, ref, site, site_file;
- ref = this.getSites();
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- inner_paths = (function() {
- var j, len1, ref1, results;
- ref1 = site.files.items;
- results = [];
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- site_file = ref1[j];
- if (site.files.selected[site_file.inner_path]) {
- results.push(site_file.inner_path);
- }
- }
- return results;
- })();
- if (inner_paths.length > 0) {
- for (j = 0, len1 = inner_paths.length; j < len1; j++) {
- inner_path = inner_paths[j];
- Page.cmd("optionalFileDelete", [inner_path, site.row.address]);
- }
- site.files.update();
- }
- }
- Page.site_list.update();
- return this.handleSelectbarCancel();
- };
- PageFiles.prototype.handleTotalbarOver = function() {
- this.hover_totalbar = true;
- return Page.projector.scheduleRender();
- };
- PageFiles.prototype.handleTotalbarOut = function() {
- this.hover_totalbar = false;
- return Page.projector.scheduleRender();
- };
- PageFiles.prototype.handleEditlimitClick = function() {
- this.editing_limit = true;
- return false;
- };
- PageFiles.prototype.handleLimitCancelClick = function() {
- this.editing_limit = false;
- return false;
- };
- PageFiles.prototype.handleLimitSetClick = function() {
- var limit;
- if (this.limit.indexOf("M") > 0 || this.limit.indexOf("m") > 0) {
- limit = (parseFloat(this.limit) / 1024).toString();
- } else if (this.limit.indexOf("%") > 0) {
- limit = parseFloat(this.limit) + "%";
- } else {
- limit = parseFloat(this.limit).toString();
- }
- this.optional_stats.limit = limit;
- Page.cmd("optionalLimitSet", limit);
- this.editing_limit = false;
- return false;
- };
- PageFiles.prototype.handleTotalbarMenu = function() {
- this.menu_totalbar.items = [];
- this.menu_totalbar.items.push(["Edit optional files limit", this.handleEditlimitClick]);
- if (this.menu_totalbar.visible) {
- this.menu_totalbar.hide();
- } else {
- this.menu_totalbar.show();
- }
- return false;
- };
- PageFiles.prototype.handleLimitInput = function(e) {
- return this.limit = e.target.value;
- };
- PageFiles.prototype.renderTotalbar = function() {
- /*
- size_optional = 0
- optional_downloaded = 0
- for site in Page.site_list.sites
- size_optional += site.row.settings.size_optional
- optional_downloaded += site.row.settings.optional_downloaded
- */
- var limit, percent_limit, percent_optional_downloaded, percent_optional_used, total_space_limited;
- if (this.editing_limit && parseFloat(this.limit) > 0) {
- if (this.limit.indexOf("M") > 0 || this.limit.indexOf("m") > 0) {
- limit = (parseFloat(this.limit) / 1024) + "GB";
- } else {
- limit = this.limit;
- }
- } else {
- limit = this.optional_stats.limit;
- }
- if (limit.endsWith("%")) {
- limit = this.optional_stats.free * (parseFloat(limit) / 100);
- } else {
- limit = parseFloat(limit) * 1024 * 1024 * 1024;
- }
- if (this.optional_stats.free > limit * 1.8 && !this.hover_totalbar) {
- total_space_limited = limit * 1.8;
- } else {
- total_space_limited = this.optional_stats.free;
- }
- percent_optional_downloaded = (this.optional_stats.used / limit) * 100;
- percent_optional_used = percent_optional_downloaded * (limit / total_space_limited);
- percent_limit = (limit / total_space_limited) * 100;
- return h("div#PageFilesDashboard", {
- classes: {
- editing: this.editing_limit
- }
- }, [
- h("div.totalbar-edit", [
- h("span.title", "Optional files limit:"), h("input", {
- type: "text",
- value: this.limit,
- oninput: this.handleLimitInput
- }), h("a.set", {
- href: "#",
- onclick: this.handleLimitSetClick
- }, "Set"), h("a.cancel", {
- href: "#",
- onclick: this.handleLimitCancelClick
- }, "Cancel")
- ]), h("a.totalbar-title", {
- href: "#",
- title: "Space current used by optional files",
- onclick: this.handleTotalbarMenu
- }, "Used: " + (Text.formatSize(this.optional_stats.used)) + " / " + (Text.formatSize(limit)) + " (" + (Math.round(percent_optional_downloaded)) + "%)", h("div.icon-arrow-down")), this.menu_totalbar.render(), h("div.totalbar", {
- onmouseover: this.handleTotalbarOver,
- onmouseout: this.handleTotalbarOut
- }, h("div.totalbar-used", {
- style: "width: " + percent_optional_used + "%"
- }), h("div.totalbar-limitbar", {
- style: "width: " + percent_limit + "%"
- }), h("div.totalbar-limit", {
- style: "margin-left: " + percent_limit + "%"
- }, h("span", {
- title: "Space allowed to used by optional files"
- }, Text.formatSize(limit))), h("div.totalbar-hddfree", h("span", {
- title: "Total free space on your storage"
- }, [
- Text.formatSize(this.optional_stats.free), h("div.arrow", {
- style: this.optional_stats.free > total_space_limited ? "width: 10px" : "width: 0px"
- }, " \u25B6")
- ])))
- ]);
- };
- PageFiles.prototype.renderSelectbar = function() {
- return h("div.selectbar", {
- classes: {
- visible: this.selected_files_num > 0
- }
- }, [
- "Selected:", h("span.info", [h("span.num", this.selected_files_num + " files"), h("span.size", "(" + (Text.formatSize(this.selected_files_size)) + ")")]), h("div.actions", [
- this.selected_files_pinned > this.selected_files_num / 2 ? h("a.action.pin.unpin", {
- href: "#",
- onclick: this.handleSelectbarUnpin
- }, "UnPin") : h("a.action.pin", {
- href: "#",
- title: "Don't delete these files automatically",
- onclick: this.handleSelectbarPin
- }, "Pin"), h("a.action.delete", {
- href: "#",
- onclick: this.handleSelectbarDelete
- }, "Delete")
- ]), h("a.cancel.link", {
- href: "#",
- onclick: this.handleSelectbarCancel
- }, "Cancel")
- ]);
- };
- PageFiles.prototype.updateOptionalStats = function() {
- return Page.cmd("optionalLimitStats", [], (function(_this) {
- return function(res) {
- _this.limit = res.limit;
- if (!_this.limit.endsWith("%")) {
- _this.limit += " GB";
- }
- return _this.optional_stats = res;
- };
- })(this));
- };
- PageFiles.prototype.updateAllFiles = function() {
- var used;
- this.updating_files = 0;
- used = 0;
- Page.site_list.sites.map((function(_this) {
- return function(site) {
- if (!site.row.settings.size_optional) {
- return;
- }
- _this.updating_files += 1;
- used += site.row.settings.optional_downloaded;
- return site.files.update(function() {
- return _this.updating_files -= 1;
- });
- };
- })(this));
- this.updating_files += 1;
- return this.bigfiles.files.update((function(_this) {
- return function() {
- return _this.updating_files -= 1;
- };
- })(this));
- };
- PageFiles.prototype.render = function() {
- var site, sites, sites_connected, sites_favorited;
- if (Page.site_list.sites && !this.need_update && this.updating_files === 0 && document.body.className !== "loaded") {
- document.body.className = "loaded";
- }
- if (this.need_update && Page.site_list.sites.length) {
- this.updateAllFiles();
- this.need_update = false;
- }
- sites = (function() {
- var i, len, ref, results;
- ref = Page.site_list.sites;
- results = [];
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- if (site.row.settings.size_optional) {
- results.push(site);
- }
- }
- return results;
- })();
- sites_favorited = (function() {
- var i, len, results;
- results = [];
- for (i = 0, len = sites.length; i < len; i++) {
- site = sites[i];
- if (site.favorite) {
- results.push(site);
- }
- }
- return results;
- })();
- sites_connected = (function() {
- var i, len, results;
- results = [];
- for (i = 0, len = sites.length; i < len; i++) {
- site = sites[i];
- if (!site.favorite) {
- results.push(site);
- }
- }
- return results;
- })();
- if (sites.length > 0 && sites[0].files.loaded === false) {
- if (sites_favorited.length) {
- sites_favorited = [sites_favorited[0]];
- sites_connected = [];
- } else {
- sites_favorited = [];
- sites_connected = [sites_connected[0]];
- }
- }
- if (sites.length === 0) {
- document.body.className = "loaded";
- return h("div#PageFiles", this.renderSelectbar(), this.renderTotalbar(), h("div.empty", [h("h4", "Hello newcomer!"), h("small", "You have not downloaded any optional files yet")]));
- }
- if (this.display_limit < sites.length) {
- setTimeout(((function(_this) {
- return function() {
- _this.display_limit += 1;
- return Page.projector.scheduleRender();
- };
- })(this)), 1000);
- }
- return h("div#PageFiles", [
- this.renderSelectbar(), this.renderTotalbar(), this.bigfiles.render(), sites_favorited.slice(0, +this.display_limit + 1 || 9e9).map((function(_this) {
- return function(site) {
- return site.renderOptionalStats();
- };
- })(this)), sites_connected.slice(0, +this.display_limit + 1 || 9e9).map((function(_this) {
- return function(site) {
- return site.renderOptionalStats();
- };
- })(this))
- ]);
- };
- PageFiles.prototype.onSiteInfo = function(site_info) {
- var rate_limit, ref, ref1;
- if (((ref = site_info.event) != null ? ref[0] : void 0) === "peers_added") {
- return false;
- }
- if (site_info.tasks === 0 && ((ref1 = site_info.event) != null ? ref1[0] : void 0) === "file_done") {
- rate_limit = 1000;
- } else {
- rate_limit = 10000;
- }
- return RateLimit(rate_limit, (function(_this) {
- return function() {
- return _this.need_update = true;
- };
- })(this));
- };
- return PageFiles;
- })(Class);
- window.PageFiles = PageFiles;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageFiles/SiteFiles.coffee ---- */
- (function() {
- var SiteFiles,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- SiteFiles = (function(superClass) {
- extend(SiteFiles, superClass);
- function SiteFiles(site1) {
- this.site = site1;
- this.update = bind(this.update, this);
- this.render = bind(this.render, this);
- this.renderOrderRight = bind(this.renderOrderRight, this);
- this.renderOrder = bind(this.renderOrder, this);
- this.handleMoreClick = bind(this.handleMoreClick, this);
- this.handleOrderbyClick = bind(this.handleOrderbyClick, this);
- this.handleRowMouseenter = bind(this.handleRowMouseenter, this);
- this.handleSelectMousedown = bind(this.handleSelectMousedown, this);
- this.handleSelectEnd = bind(this.handleSelectEnd, this);
- this.handleSelectClick = bind(this.handleSelectClick, this);
- this.limit = 10;
- this.selected = {};
- this.items = [];
- this.loaded = false;
- this.orderby = "time_downloaded";
- this.mode = "site";
- this.mode = "single_site";
- this.orderby_desc = true;
- this.has_more = false;
- }
- SiteFiles.prototype.handleSelectClick = function(e) {
- return false;
- };
- SiteFiles.prototype.handleSelectEnd = function(e) {
- document.body.removeEventListener('mouseup', this.handleSelectEnd);
- return this.select_action = null;
- };
- SiteFiles.prototype.handleSelectMousedown = function(e) {
- var inner_path;
- inner_path = e.target.attributes.inner_path.value;
- if (this.selected[inner_path]) {
- delete this.selected[inner_path];
- this.select_action = "deselect";
- } else {
- this.selected[inner_path] = true;
- this.select_action = "select";
- }
- Page.page_files.checkSelectedFiles();
- document.body.addEventListener('mouseup', this.handleSelectEnd);
- e.stopPropagation();
- Page.projector.scheduleRender();
- return false;
- };
- SiteFiles.prototype.handleRowMouseenter = function(e) {
- var inner_path;
- if (e.buttons && this.select_action) {
- inner_path = e.target.attributes.inner_path.value;
- if (this.select_action === "select") {
- this.selected[inner_path] = true;
- } else {
- delete this.selected[inner_path];
- }
- Page.page_files.checkSelectedFiles();
- Page.projector.scheduleRender();
- }
- return false;
- };
- SiteFiles.prototype.handleOrderbyClick = function(e) {
- var orderby;
- orderby = e.currentTarget.attributes.orderby.value;
- if (this.orderby === orderby) {
- this.orderby_desc = !this.orderby_desc;
- }
- this.orderby = orderby;
- this.update();
- Page.projector.scheduleRender();
- return false;
- };
- SiteFiles.prototype.handleMoreClick = function() {
- this.limit += 15;
- this.update();
- return false;
- };
- SiteFiles.prototype.renderOrder = function(title, orderby) {
- return h("a.title.orderby", {
- href: "#" + orderby,
- orderby: orderby,
- onclick: this.handleOrderbyClick,
- classes: {
- selected: this.orderby === orderby,
- desc: this.orderby_desc
- }
- }, [title, h("div.icon.icon-arrow-down")]);
- };
- SiteFiles.prototype.renderOrderRight = function(title, orderby) {
- return h("a.title.orderby", {
- href: "#" + orderby,
- orderby: orderby,
- onclick: this.handleOrderbyClick,
- classes: {
- selected: this.orderby === orderby,
- desc: this.orderby_desc
- }
- }, [h("div.icon.icon-arrow-down"), title]);
- };
- SiteFiles.prototype.render = function() {
- var ref;
- if (!((ref = this.items) != null ? ref.length : void 0)) {
- return [];
- }
- return [
- h("div.files.files-" + this.mode, {
- exitAnimation: Animation.slideUpInout
- }, [
- h("div.tr.thead", [h("div.td.pre", "."), this.mode === "bigfiles" ? h("div.td.site", this.renderOrder("Site", "address")) : void 0, h("div.td.inner_path", this.renderOrder("Optional file", "is_pinned DESC, inner_path")), this.mode === "bigfiles" ? h("div.td.status", "Status") : void 0, h("div.td.size", this.renderOrderRight("Size", "size")), h("div.td.peer", this.renderOrder("Peers", "peer")), h("div.td.uploaded", this.renderOrder("Uploaded", "uploaded")), h("div.td.added", this.renderOrder("Finished", "time_downloaded"))]), h("div.tbody", this.items.map((function(_this) {
- return function(file) {
- var percent, profile_color, site;
- site = file.site || _this.site;
- if (file.peer >= 10) {
- profile_color = "#47d094";
- } else if (file.peer > 0) {
- profile_color = "#f5b800";
- } else {
- profile_color = "#d1d1d1";
- }
- if (_this.mode === "bigfiles") {
- if (file.pieces == null) {
- file.pieces = 0;
- }
- if (file.pieces_downloaded == null) {
- file.pieces_downloaded = 0;
- }
- if (file.pieces === 0 || file.pieces_downloaded === 0) {
- percent = 0;
- } else {
- percent = parseInt((file.pieces_downloaded / file.pieces) * 100);
- }
- }
- return h("div.tr", {
- key: file.inner_path,
- inner_path: file.inner_path,
- exitAnimation: Animation.slideUpInout,
- enterAnimation: Animation.slideDown,
- classes: {
- selected: _this.selected[file.inner_path]
- },
- onmouseenter: _this.handleRowMouseenter
- }, [
- h("div.td.pre", h("a.checkbox", {
- href: "#Select",
- onmousedown: _this.handleSelectMousedown,
- onclick: _this.handleSelectClick,
- inner_path: file.inner_path
- })), _this.mode === "bigfiles" ? h("div.td.site", h("a.link", {
- href: site.getHref()
- }, site.row.content.title)) : void 0, h("div.td.inner_path", h("a.title.link", {
- href: site.getHref(file),
- target: "_top"
- }, file.inner_path.replace(/.*\//, "")), file.is_pinned ? h("span.pinned", {
- exitAnimation: Animation.slideUpInout,
- enterAnimation: Animation.slideDown
- }, "Pinned") : void 0), _this.mode === "bigfiles" ? h("div.td.status", h("span.percent", {
- title: file.pieces_downloaded + " of " + file.pieces + " pieces downloaded",
- style: "box-shadow: inset " + (percent * 0.8) + "px 0px 0px #9ef5cf;"
- }, percent + "%")) : void 0, h("div.td.size", Text.formatSize(file.size)), h("div.td.peer", [
- h("div.icon.icon-profile", {
- style: "color: " + profile_color
- }), h("span.num", file.peer)
- ]), h("div.td.uploaded", h("div.uploaded-text", Text.formatSize(file.uploaded)), h("div.dots-container", [
- h("span.dots.dots-bg", {
- title: "Ratio: " + ((file.uploaded / file.size).toFixed(1))
- }, "\u2022\u2022\u2022\u2022\u2022"), h("span.dots.dots-fg", {
- title: "Ratio: " + ((file.uploaded / file.size).toFixed(1)),
- style: "width: " + (Math.min(5, file.uploaded / file.size) * 9) + "px"
- }, "\u2022\u2022\u2022\u2022\u2022")
- ])), h("div.td.added", file.time_downloaded ? Time.since(file.time_downloaded) : "n/a")
- ]);
- };
- })(this)))
- ]), this.has_more ? h("div.more-container", h("a.more", {
- href: "#More",
- onclick: this.handleMoreClick
- }, "More files...")) : void 0
- ];
- };
- SiteFiles.prototype.update = function(cb) {
- var orderby;
- orderby = this.orderby + (this.orderby_desc ? " DESC" : "");
- return Page.cmd("optionalFileList", {
- address: this.site.row.address,
- limit: this.limit + 1,
- orderby: orderby
- }, (function(_this) {
- return function(res) {
- _this.items = res.slice(0, +(_this.limit - 1) + 1 || 9e9);
- _this.loaded = true;
- _this.has_more = res.length > _this.limit;
- Page.projector.scheduleRender();
- return typeof cb === "function" ? cb() : void 0;
- };
- })(this));
- };
- return SiteFiles;
- })(Class);
- window.SiteFiles = SiteFiles;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageSites/Dashboard.coffee ---- */
- (function() {
- var Dashboard,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty,
- indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- Dashboard = (function(superClass) {
- extend(Dashboard, superClass);
- function Dashboard() {
- this.render = bind(this.render, this);
- this.handleTorBrowserwarningClick = bind(this.handleTorBrowserwarningClick, this);
- this.handleBrowserwarningClick = bind(this.handleBrowserwarningClick, this);
- this.handleNewversionClick = bind(this.handleNewversionClick, this);
- this.handleLogoutClick = bind(this.handleLogoutClick, this);
- this.handleDonateClick = bind(this.handleDonateClick, this);
- this.handleMultiuserClick = bind(this.handleMultiuserClick, this);
- this.handlePortRecheckClick = bind(this.handlePortRecheckClick, this);
- this.handlePortClick = bind(this.handlePortClick, this);
- this.handleDisableAlwaysTorClick = bind(this.handleDisableAlwaysTorClick, this);
- this.handleEnableAlwaysTorClick = bind(this.handleEnableAlwaysTorClick, this);
- this.handleTorClick = bind(this.handleTorClick, this);
- this.menu_newversion = new Menu();
- this.menu_tor = new Menu();
- this.menu_port = new Menu();
- this.menu_multiuser = new Menu();
- this.menu_donate = new Menu();
- this.menu_browserwarning = new Menu();
- this.menu_torbrowserwarning = new Menu();
- this.port_checking = false;
- this.has_web_gl = null;
- }
- Dashboard.prototype.isTorAlways = function() {
- return Page.server_info.fileserver_ip === "127.0.0.1";
- };
- Dashboard.prototype.hasWebGl = function() {
- var canvas, ctx;
- if (this.has_web_gl === null) {
- canvas = document.createElement('canvas');
- ctx = canvas.getContext("webgl");
- this.has_web_gl = ctx ? true : false;
- this.log("Webgl:", this.has_web_gl);
- }
- return this.has_web_gl;
- };
- Dashboard.prototype.getTorTitle = function() {
- var tor_title;
- tor_title = Page.server_info.tor_status.replace(/\((.*)\)/, "").trim();
- if (tor_title === "Disabled") {
- tor_title = _("Disabled");
- } else if (tor_title === "Error") {
- tor_title = _("Error");
- }
- return tor_title;
- };
- Dashboard.prototype.handleTorClick = function() {
- var ref;
- this.menu_tor.items = [];
- this.menu_tor.items.push(["Status: " + ((ref = Page.server_info) != null ? ref.tor_status : void 0), "http://zeronet.readthedocs.org/en/latest/faq/#how-to-make-zeronet-work-with-tor-under-linux"]);
- if (this.getTorTitle() !== "OK") {
- this.menu_tor.items.push(["How to make Tor connection work?", "http://zeronet.readthedocs.org/en/latest/faq/#how-to-make-zeronet-work-with-tor-under-linux"]);
- }
- this.menu_tor.items.push(["How to use ZeroNet in Tor Browser?", "http://zeronet.readthedocs.org/en/latest/faq/#how-to-use-zeronet-in-tor-browser"]);
- this.menu_tor.items.push(["---"]);
- if (this.isTorAlways()) {
- this.menu_tor.items.push(["Disable always Tor mode", this.handleDisableAlwaysTorClick]);
- } else {
- this.menu_tor.items.push(["Enable Tor for every connection (slower)", this.handleEnableAlwaysTorClick]);
- }
- this.menu_tor.toggle();
- return false;
- };
- Dashboard.prototype.handleEnableAlwaysTorClick = function() {
- return Page.cmd("configSet", ["tor", "always"], (function(_this) {
- return function(res) {
- return Page.cmd("wrapperNotification", ["done", "Tor always mode enabled, please restart your ZeroNet to make it work.<br>For your privacy switch to Tor browser and start a new profile by renaming the data directory."]);
- };
- })(this));
- };
- Dashboard.prototype.handleDisableAlwaysTorClick = function() {
- return Page.cmd("configSet", ["tor", null], (function(_this) {
- return function(res) {
- return Page.cmd("wrapperNotification", ["done", "Tor always mode disabled, please restart your ZeroNet."]);
- };
- })(this));
- };
- Dashboard.prototype.handlePortClick = function() {
- this.menu_port.items = [];
- if (Page.server_info.ip_external) {
- this.menu_port.items.push(["Nice! Your port " + Page.server_info.fileserver_port + " is opened.", "http://zeronet.readthedocs.org/en/latest/faq/#do-i-need-to-have-a-port-opened"]);
- } else if (this.isTorAlways()) {
- this.menu_port.items.push(["Good, your port is always closed when using ZeroNet in Tor always mode.", "http://zeronet.readthedocs.org/en/latest/faq/#do-i-need-to-have-a-port-opened"]);
- } else if (this.getTorTitle() === "OK") {
- this.menu_port.items.push(["Your port " + Page.server_info.fileserver_port + " is closed, but your Tor gateway is running well.", "http://zeronet.readthedocs.org/en/latest/faq/#do-i-need-to-have-a-port-opened"]);
- } else {
- this.menu_port.items.push(["Your port " + Page.server_info.fileserver_port + " is closed. You are still fine, but for faster experience try open it.", "http://zeronet.readthedocs.org/en/latest/faq/#do-i-need-to-have-a-port-opened"]);
- }
- this.menu_port.items.push(["---"]);
- this.menu_port.items.push(["Re-check opened port", this.handlePortRecheckClick]);
- this.menu_port.toggle();
- return false;
- };
- Dashboard.prototype.handlePortRecheckClick = function() {
- this.port_checking = true;
- return Page.cmd("serverPortcheck", [], (function(_this) {
- return function(res) {
- _this.port_checking = false;
- return Page.reloadServerInfo();
- };
- })(this));
- };
- Dashboard.prototype.handleMultiuserClick = function() {
- this.menu_multiuser.items = [];
- this.menu_multiuser.items.push([
- "Show your masterseed", (function() {
- return Page.cmd("userShowMasterSeed");
- })
- ]);
- this.menu_multiuser.items.push([
- "Logout", (function() {
- return Page.cmd("userLogout");
- })
- ]);
- this.menu_multiuser.toggle();
- return false;
- };
- Dashboard.prototype.handleDonateClick = function() {
- this.menu_donate.items = [];
- this.menu_donate.items.push(["Help to keep this project alive", "https://zeronet.readthedocs.org/en/latest/help_zeronet/donate/"]);
- this.menu_donate.toggle();
- return false;
- };
- Dashboard.prototype.handleLogoutClick = function() {
- return Page.cmd("uiLogout");
- };
- Dashboard.prototype.handleNewversionClick = function() {
- this.menu_newversion.items = [];
- this.menu_newversion.items.push([
- "Update and restart ZeroNet", (function() {
- Page.cmd("wrapperNotification", ["info", "Updating to latest version...<br>Please restart ZeroNet manually if it does not come back in the next few minutes.", 8000]);
- return Page.cmd("serverUpdate");
- })
- ]);
- this.menu_newversion.items.push(["Details of the update", Text.getSiteUrl("Blog.ZeroNetwork.bit")]);
- this.menu_newversion.toggle();
- return false;
- };
- Dashboard.prototype.handleBrowserwarningClick = function() {
- this.menu_browserwarning.items = [];
- this.menu_browserwarning.items.push(["Internet Explorer is not fully supported browser by ZeroNet, please consider switching to Chrome or Firefox", "http://browsehappy.com/"]);
- this.menu_browserwarning.toggle();
- return false;
- };
- Dashboard.prototype.handleTorBrowserwarningClick = function() {
- this.menu_torbrowserwarning.items = [];
- this.menu_torbrowserwarning.items.push(["To protect your anonymity you should use ZeroNet in the Tor browser.", "http://zeronet.readthedocs.io/en/latest/faq/#how-to-use-zeronet-in-tor-browser"]);
- this.menu_torbrowserwarning.toggle();
- return false;
- };
- Dashboard.prototype.render = function() {
- var tor_title;
- if (Page.server_info) {
- tor_title = this.getTorTitle();
- return h("div#Dashboard", navigator.userAgent.match(/(\b(MS)?IE\s+|Trident\/7.0)/) ? h("a.port.dashboard-item.browserwarning", {
- href: "http://browsehappy.com/",
- onmousedown: this.handleBrowserwarningClick,
- onclick: Page.returnFalse
- }, [h("span", "Unsupported browser")]) : void 0, this.menu_browserwarning.render(".menu-browserwarning"), this.isTorAlways() && (!navigator.userAgent.match(/(Firefox)/) || this.hasWebGl() || (navigator.serviceWorker != null)) ? h("a.port.dashboard-item.torbrowserwarning", {
- href: "http://zeronet.readthedocs.io/en/latest/faq/#how-to-use-zeronet-in-tor-browser",
- onmousedown: this.handleTorBrowserwarningClick,
- onclick: Page.returnFalse
- }, [h("span", "Your browser is not safe")]) : void 0, this.menu_torbrowserwarning.render(".menu-browserwarning"), parseFloat(Page.server_info.version.replace(".", "0")) < parseFloat(Page.latest_version.replace(".", "0")) ? h("a.newversion.dashboard-item", {
- href: "#Update",
- onmousedown: this.handleNewversionClick,
- onclick: Page.returnFalse
- }, "New ZeroNet version: " + Page.latest_version) : Page.server_info.rev < Page.latest_rev ? h("a.newversion.dashboard-item", {
- href: "#Update",
- onmousedown: this.handleNewversionClick,
- onclick: Page.returnFalse
- }, "New important fix: rev" + Page.latest_rev) : void 0, this.menu_newversion.render(".menu-newversion"), h("a.port.dashboard-item.donate", {
- "href": "#Donate",
- onmousedown: this.handleDonateClick,
- onclick: Page.returnFalse
- }, [h("div.icon-heart")]), this.menu_donate.render(".menu-donate"), Page.server_info.multiuser ? h("a.port.dashboard-item.multiuser", {
- href: "#Multiuser",
- onmousedown: this.handleMultiuserClick,
- onclick: Page.returnFalse
- }, [
- h("span", "User: "), h("span.status", {
- style: "color: " + (Text.toColor(Page.server_info.master_address))
- }, Page.server_info.master_address.slice(0, 5) + ".." + Page.server_info.master_address.slice(-4))
- ]) : void 0, Page.server_info.multiuser ? this.menu_multiuser.render(".menu-multiuser") : void 0, indexOf.call(Page.server_info.plugins, "UiPassword") >= 0 ? h("a.port.dashboard-item.logout", {
- href: "#Logout",
- onmousedown: this.handleLogoutClick,
- onclick: Page.returnFalse
- }, [h("span", "Logout")]) : void 0, h("a.port.dashboard-item.port", {
- href: "#Port",
- classes: {
- bounce: this.port_checking
- },
- onmousedown: this.handlePortClick,
- onclick: Page.returnFalse
- }, [h("span", "Port: "), this.port_checking ? h("span.status", "Checking") : Page.server_info.ip_external === null ? h("span.status", "Checking") : Page.server_info.ip_external === true ? h("span.status.status-ok", "Opened") : this.isTorAlways ? h("span.status.status-ok", "Closed") : tor_title === "OK" ? h("span.status.status-warning", "Closed") : h("span.status.status-bad", "Closed")]), this.menu_port.render(".menu-port"), h("a.tor.dashboard-item.tor", {
- href: "#Tor",
- onmousedown: this.handleTorClick,
- onclick: Page.returnFalse
- }, [h("span", "Tor: "), tor_title === "OK" ? this.isTorAlways() ? h("span.status.status-ok", "Always") : h("span.status.status-ok", "Available") : h("span.status.status-warning", tor_title)]), this.menu_tor.render(".menu-tor"));
- } else {
- return h("div#Dashboard");
- }
- };
- return Dashboard;
- })(Class);
- window.Dashboard = Dashboard;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageSites/FeedList.coffee ---- */
- (function() {
- var FeedList,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- FeedList = (function(superClass) {
- extend(FeedList, superClass);
- function FeedList() {
- this.onSiteInfo = bind(this.onSiteInfo, this);
- this.render = bind(this.render, this);
- this.getClass = bind(this.getClass, this);
- this.renderSearchStat = bind(this.renderSearchStat, this);
- this.renderWelcome = bind(this.renderWelcome, this);
- this.renderFeed = bind(this.renderFeed, this);
- this.exitAnimation = bind(this.exitAnimation, this);
- this.enterAnimation = bind(this.enterAnimation, this);
- this.handleSearchClear = bind(this.handleSearchClear, this);
- this.handleSearchInfoClick = bind(this.handleSearchInfoClick, this);
- this.handleFilterClick = bind(this.handleFilterClick, this);
- this.handleSearchKeyup = bind(this.handleSearchKeyup, this);
- this.handleSearchInput = bind(this.handleSearchInput, this);
- this.storeNodeSearch = bind(this.storeNodeSearch, this);
- this.search = bind(this.search, this);
- this.update = bind(this.update, this);
- this.displayRows = bind(this.displayRows, this);
- this.checkScroll = bind(this.checkScroll, this);
- this.feeds = null;
- this.searching = null;
- this.searching_text = null;
- this.searched = null;
- this.res = null;
- this.loading = false;
- this.filter = null;
- this.feed_types = {};
- this.need_update = false;
- this.updating = false;
- this.limit = 30;
- this.query_limit = 20;
- this.query_day_limit = 3;
- this.show_stats = false;
- this.feed_keys = {};
- Page.on_settings.then((function(_this) {
- return function() {
- _this.need_update = true;
- return document.body.onscroll = function() {
- return RateLimit(300, function() {
- return _this.checkScroll();
- });
- };
- };
- })(this));
- this;
- }
- FeedList.prototype.checkScroll = function() {
- var ref, scroll_top;
- scroll_top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
- if (scroll_top + window.innerHeight > document.getElementById("FeedList").clientHeight - 400 && !this.updating && ((ref = this.feeds) != null ? ref.length : void 0) > 5 && Page.mode === "Sites" && this.limit < 300) {
- this.limit += 30;
- this.query_limit += 30;
- this.query_day_limit += 5;
- this.log("checkScroll update");
- this.update();
- return true;
- } else {
- return false;
- }
- };
- FeedList.prototype.displayRows = function(rows, search) {
- var i, last_row, len, row, row_group;
- this.feeds = [];
- this.feed_keys = {};
- if (!rows) {
- return false;
- }
- rows.sort(function(a, b) {
- return a.date_added + (a.type === "mention" ? 1 : 0) - b.date_added - (b.type === "mention" ? 1 : 0);
- });
- row_group = {};
- last_row = {};
- this.feed_types = {};
- rows.reverse();
- for (i = 0, len = rows.length; i < len; i++) {
- row = rows[i];
- if (last_row.body === row.body && last_row.date_added === row.date_added) {
- continue;
- }
- if (row_group.type === row.type && row.url === row_group.url && row.site === row_group.site) {
- if (row_group.body_more == null) {
- row_group.body_more = [];
- row_group.body_more.push(row.body);
- } else if (row_group.body_more.length < 3) {
- row_group.body_more.push(row.body);
- } else {
- if (row_group.more == null) {
- row_group.more = 0;
- }
- row_group.more += 1;
- }
- row_group.feed_id = row.date_added;
- } else {
- if (row.feed_id == null) {
- row.feed_id = row.date_added;
- }
- row.key = row.site + row.type + row.title + row.feed_id;
- if (this.feed_keys[row.key]) {
- this.log("Duplicate feed key: " + row.key);
- } else {
- this.feeds.push(row);
- }
- this.feed_keys[row.key] = true;
- row_group = row;
- }
- this.feed_types[row.type] = true;
- last_row = row;
- }
- return Page.projector.scheduleRender();
- };
- FeedList.prototype.update = function(cb) {
- var params;
- if (this.searching || this.updating) {
- return false;
- }
- if (!Page.server_info || Page.server_info.rev < 1850) {
- params = [];
- } else {
- params = [this.query_limit, this.query_day_limit];
- }
- this.logStart("Updating feed");
- this.updating = true;
- return Page.cmd("feedQuery", params, (function(_this) {
- return function(res) {
- var rows;
- if (res.rows) {
- rows = res.rows;
- } else {
- rows = res;
- }
- _this.res = res;
- if (rows.length < 10 && _this.day_limit !== null) {
- _this.limit = 20;
- _this.day_limit = null;
- _this.updating = false;
- _this.update();
- return false;
- }
- _this.displayRows(rows);
- setTimeout(_this.checkScroll, 100);
- _this.logEnd("Updating feed");
- if (cb) {
- cb();
- }
- return _this.updating = false;
- };
- })(this));
- };
- FeedList.prototype.search = function(search, cb) {
- if (Page.server_info.rev < 1230) {
- this.displayRows([]);
- if (cb) {
- cb();
- }
- return;
- }
- this.log("Searching for", search);
- this.loading = true;
- return Page.cmd("feedSearch", search, (function(_this) {
- return function(res) {
- _this.loading = false;
- _this.displayRows(res["rows"], search);
- delete res["rows"];
- _this.res = res;
- _this.searched = search;
- if (cb) {
- return cb();
- }
- };
- })(this));
- };
- FeedList.prototype.storeNodeSearch = function(node) {
- return document.body.onkeypress = (function(_this) {
- return function(e) {
- var ref, ref1;
- if ((ref = e.charCode) === 0 || ref === 32) {
- return;
- }
- if (((ref1 = document.activeElement) != null ? ref1.tagName : void 0) !== "INPUT") {
- return node.focus();
- }
- };
- })(this);
- };
- FeedList.prototype.handleSearchInput = function(e) {
- var delay;
- if (this.searching && this.searching.length > 3) {
- delay = 100;
- } else if (this.searching) {
- delay = 300;
- } else {
- delay = 600;
- }
- this.searching = e.target.value;
- this.searching_text = this.searching.replace(/[^ ]+:.*$/, "").trim();
- if (Page.server_info.rev < 1230) {
- this.feeds = [];
- this.feed_keys = {};
- }
- if (e.target.value === "") {
- delay = 1;
- }
- clearInterval(this.input_timer);
- setTimeout((function(_this) {
- return function() {
- return _this.loading = true;
- };
- })(this));
- this.input_timer = setTimeout(((function(_this) {
- return function() {
- return RateLimitCb(delay, function(cb_done) {
- _this.loading = false;
- if (_this.searching) {
- return _this.search(_this.searching, function() {
- return cb_done();
- });
- } else {
- return _this.update(function() {
- cb_done();
- if (!_this.searching) {
- _this.searching = null;
- }
- return _this.searched = null;
- });
- }
- });
- };
- })(this)), delay);
- return false;
- };
- FeedList.prototype.handleSearchKeyup = function(e) {
- if (e.keyCode === 27) {
- e.target.value = "";
- this.handleSearchInput(e);
- }
- return false;
- };
- FeedList.prototype.handleFilterClick = function(e) {
- this.filter = e.target.getAttribute("href").replace("#", "");
- if (this.filter === "all") {
- this.filter = null;
- }
- return false;
- };
- FeedList.prototype.handleSearchInfoClick = function(e) {
- this.show_stats = !this.show_stats;
- return false;
- };
- FeedList.prototype.handleSearchClear = function(e) {
- e.target.value = "";
- this.handleSearchInput(e);
- return false;
- };
- FeedList.prototype.formatTitle = function(title) {
- if (this.searching_text && this.searching_text.length > 1) {
- return Text.highlight(title, this.searching_text);
- } else {
- if (title) {
- return title;
- } else {
- return "";
- }
- }
- };
- FeedList.prototype.formatBody = function(body, type) {
- var username_formatted, username_match;
- body = body.replace(/[\n\r]+/, "\n");
- if (type === "comment" || type === "mention") {
- username_match = body.match(/^(([a-zA-Z0-9\.]+)@[a-zA-Z0-9\.]+|@(.*?)):/);
- if (username_match) {
- if (username_match[2]) {
- username_formatted = username_match[2] + " › ";
- } else {
- username_formatted = username_match[3] + " › ";
- }
- body = body.replace(/> \[(.*?)\].*/g, "$1: ");
- body = body.replace(/^[ ]*>.*/gm, "");
- body = body.replace(username_match[0], "");
- } else {
- username_formatted = "";
- }
- body = body.replace(/\n/g, " ");
- body = body.trim();
- if (this.searching_text && this.searching_text.length > 1) {
- body = Text.highlight(body, this.searching_text);
- if (body[0].length > 60 && body.length > 1) {
- body[0] = "..." + body[0].slice(body[0].length - 50, +(body[0].length - 1) + 1 || 9e9);
- }
- return [h("b", Text.highlight(username_formatted, this.searching_text)), body];
- } else {
- body = body.slice(0, 201);
- return [h("b", [username_formatted]), body];
- }
- } else {
- body = body.replace(/\n/g, " ");
- if (this.searching_text && this.searching_text.length > 1) {
- body = Text.highlight(body, this.searching_text);
- if (body[0].length > 60) {
- body[0] = "..." + body[0].slice(body[0].length - 50, +(body[0].length - 1) + 1 || 9e9);
- }
- } else {
- body = body.slice(0, 201);
- }
- return body;
- }
- };
- FeedList.prototype.formatType = function(type, title) {
- if (type === "comment") {
- return "Comment on";
- } else if (type === "mention") {
- if (title) {
- return "You got mentioned in";
- } else {
- return "You got mentioned";
- }
- } else {
- return "";
- }
- };
- FeedList.prototype.enterAnimation = function(elem, props) {
- if (this.searching === null) {
- return Animation.slideDown.apply(this, arguments);
- } else {
- return null;
- }
- };
- FeedList.prototype.exitAnimation = function(elem, remove_func, props) {
- if (this.searching === null) {
- return Animation.slideUp.apply(this, arguments);
- } else {
- return remove_func();
- }
- };
- FeedList.prototype.renderFeed = function(feed) {
- var err, site, type_formatted;
- if (this.filter && feed.type !== this.filter) {
- return null;
- }
- try {
- site = Page.site_list.item_list.items_bykey[feed.site];
- type_formatted = this.formatType(feed.type, feed.title);
- return h("div.feed." + feed.type, {
- key: feed.key,
- enterAnimation: this.enterAnimation,
- exitAnimation: this.exitAnimation
- }, [
- h("div.details", [
- h("a.site", {
- href: site.getHref()
- }, [site.row.content.title]), h("div.added", [Time.since(feed.date_added)])
- ]), h("div.circle", {
- style: "border-color: " + (Text.toColor(feed.type + site.row.address, 60, 60))
- }), type_formatted ? h("span.type", type_formatted) : void 0, h("a.title", {
- href: site.getHref() + feed.url
- }, this.formatTitle(feed.title)), h("div.body", {
- key: feed.body,
- enterAnimation: this.enterAnimation,
- exitAnimation: this.exitAnimation
- }, this.formatBody(feed.body, feed.type)), feed.body_more ? feed.body_more.map((function(_this) {
- return function(body_more) {
- return h("div.body", {
- key: body_more,
- enterAnimation: _this.enterAnimation,
- exitAnimation: _this.exitAnimation
- }, _this.formatBody(body_more, feed.type));
- };
- })(this)) : void 0, feed.more > 0 ? h("a.more", {
- href: site.getHref() + feed.url
- }, ["+" + feed.more + " more"]) : void 0
- ]);
- } catch (error) {
- err = error;
- this.log(err);
- return h("div", {
- key: Time.timestamp()
- });
- }
- };
- FeedList.prototype.renderWelcome = function() {
- return h("div.welcome", [
- h("img", {
- src: "img/logo.svg",
- height: 150,
- onerror: "this.src='img/logo.png'; this.onerror=null;"
- }), h("h1", "Welcome to ZeroNet"), h("h2", "Let's build a decentralized Internet together!"), h("div.served", ["This site currently served by ", h("b.peers", Page.site_info["peers"] || "n/a"), " peers, without any central server."]), h("div.sites", [
- h("h3", "Some sites we created:"), h("a.site.site-zeroboard", {
- href: Text.getSiteUrl("Board.ZeroNetwork.bit")
- }, [h("div.title", ["ZeroBoard"]), h("div.description", ["Simple messaging board"]), h("div.visit", ["Activate \u2501"])]), h("a.site.site-zerotalk", {
- href: Text.getSiteUrl("Talk.ZeroNetwork.bit")
- }, [h("div.title", ["ZeroTalk"]), h("div.description", ["Reddit-like, decentralized forum"]), h("div.visit", ["Activate \u2501"])]), h("a.site.site-zeroblog", {
- href: Text.getSiteUrl("Blog.ZeroNetwork.bit")
- }, [h("div.title", ["ZeroBlog"]), h("div.description", ["Microblogging platform"]), h("div.visit", ["Activate \u2501"])]), h("a.site.site-zeromail", {
- href: Text.getSiteUrl("Mail.ZeroNetwork.bit")
- }, [h("div.title", ["ZeroMail"]), h("div.description", ["End-to-end encrypted mailing"]), h("div.visit", ["Activate \u2501"])]), h("a.site.site-zerome", {
- href: Text.getSiteUrl("Me.ZeroNetwork.bit")
- }, [h("div.title", ["ZeroMe"]), h("div.description", ["P2P social network"]), h("div.visit", ["Activate \u2501"])]), h("a.site.site-zerosites", {
- href: Text.getSiteUrl("Sites.ZeroNetwork.bit")
- }, [h("div.title", ["ZeroSites"]), h("div.description", ["Discover more sites"]), h("div.visit", ["Activate \u2501"])])
- ])
- ]);
- };
- FeedList.prototype.renderSearchStat = function(stat) {
- var site, total_taken;
- if (stat.taken === 0) {
- return null;
- }
- total_taken = this.res.taken;
- site = Page.site_list.item_list.items_bykey[stat.site];
- if (!site) {
- return [];
- }
- return h("tr", {
- key: stat.site + "_" + stat.feed_name,
- classes: {
- "slow": stat.taken > total_taken * 0.1,
- "extra-slow": stat.taken > total_taken * 0.3
- }
- }, [
- h("td.site", h("a.site", {
- href: site.getHref()
- }, [site.row.content.title])), h("td.feed_name", stat.feed_name), h("td.taken", (stat.taken != null ? stat.taken + "s" : "n/a "))
- ]);
- };
- FeedList.prototype.getClass = function() {
- if (this.searching !== null) {
- return "search";
- } else {
- return "newsfeed.limit-" + this.limit;
- }
- };
- FeedList.prototype.render = function() {
- var feed_type, ref;
- if (this.need_update) {
- RateLimitCb(5000, this.update);
- this.need_update = false;
- }
- if (this.feeds && Page.site_list.loaded && document.body.className !== "loaded" && !this.updating) {
- if (document.body.scrollTop > 500) {
- setTimeout((function() {
- return document.body.className = "loaded";
- }), 2000);
- } else {
- document.body.className = "loaded";
- }
- }
- return h("div#FeedList.FeedContainer", {
- classes: {
- faded: Page.mute_list.visible
- }
- }, this.feeds === null || !Page.site_list.loaded ? h("div.loading") : this.feeds.length > 0 || this.searching !== null ? [
- h("div.feeds-filters", [
- h("a.feeds-filter", {
- href: "#all",
- classes: {
- active: this.filter === null
- },
- onclick: this.handleFilterClick
- }, "All"), (function() {
- var results;
- results = [];
- for (feed_type in this.feed_types) {
- results.push(h("a.feeds-filter", {
- key: feed_type,
- href: "#" + feed_type,
- classes: {
- active: this.filter === feed_type
- },
- onclick: this.handleFilterClick
- }, feed_type));
- }
- return results;
- }).call(this)
- ]), h("div.feeds-line"), h("div.feeds-search", {
- classes: {
- "searching": this.searching,
- "searched": this.searched,
- "loading": this.loading
- }
- }, h("div.icon-magnifier"), this.loading ? h("div.loader", {
- enterAnimation: Animation.show,
- exitAnimation: Animation.hide
- }, h("div.arc")) : void 0, h("input", {
- type: "text",
- placeholder: "Search in connected sites",
- value: this.searching,
- onkeyup: this.handleSearchKeyup,
- oninput: this.handleSearchInput,
- afterCreate: this.storeNodeSearch
- }), this.searched && !this.loading ? h("a.search-clear.nolink", {
- href: "#clear",
- onclick: this.handleSearchClear,
- enterAnimation: Animation.show,
- exitAnimation: Animation.hide
- }, "\u00D7") : void 0, ((ref = this.res) != null ? ref.stats : void 0) ? h("a.search-info.nolink", {
- href: "#ShowStats",
- enterAnimation: Animation.show,
- exitAnimation: Animation.hide,
- onclick: this.handleSearchInfoClick
- }, (this.searching ? this.res.num + " results " : "") + ("from " + this.res.sites + " sites in " + (this.res.taken.toFixed(2)) + "s")) : void 0, this.show_stats ? h("div.search-info-stats", {
- enterAnimation: Animation.slideDown,
- exitAnimation: Animation.slideUp
- }, [h("table", [h("tr", h("th", "Site"), h("th", "Feed"), h("th.taken", "Taken")), this.res.stats.map(this.renderSearchStat)])]) : void 0, Page.server_info.rev < 1230 && this.searching ? h("div.search-noresult", {
- enterAnimation: Animation.show
- }, [
- "You need to ", h("a", {
- href: "#Update",
- onclick: Page.head.handleUpdateZeronetClick
- }, "update"), " your ZeroNet client to use the search feature!"
- ]) : this.feeds.length === 0 && this.searched ? h("div.search-noresult", {
- enterAnimation: Animation.show
- }, "No results for " + this.searched) : void 0), h("div.FeedList." + this.getClass(), {
- classes: {
- loading: this.loading
- }
- }, this.feeds.slice(0, +this.limit + 1 || 9e9).map(this.renderFeed))
- ] : this.renderWelcome());
- };
- FeedList.prototype.onSiteInfo = function(site_info) {
- var ref, ref1, ref2;
- if (((ref = site_info.event) != null ? ref[0] : void 0) === "file_done" && ((ref1 = site_info.event) != null ? ref1[1].endsWith(".json") : void 0) && !((ref2 = site_info.event) != null ? ref2[1].endsWith("content.json") : void 0)) {
- if (!this.searching) {
- return this.need_update = true;
- }
- }
- };
- return FeedList;
- })(Class);
- window.FeedList = FeedList;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageSites/MuteList.coffee ---- */
- (function() {
- var MuteList,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- MuteList = (function(superClass) {
- extend(MuteList, superClass);
- function MuteList() {
- this.show = bind(this.show, this);
- this.render = bind(this.render, this);
- this.handleMuteRemoveClick = bind(this.handleMuteRemoveClick, this);
- this.handleHideClick = bind(this.handleHideClick, this);
- this.update = bind(this.update, this);
- this.mutes = null;
- this.visible = false;
- Page.on_settings.then((function(_this) {
- return function() {
- return _this.need_update = true;
- };
- })(this));
- this;
- }
- MuteList.prototype.update = function() {
- this.need_update = false;
- return Page.cmd("MuteList", [], (function(_this) {
- return function(res) {
- var auth_address, mute;
- _this.mutes = [];
- for (auth_address in res) {
- mute = res[auth_address];
- mute.auth_address = auth_address;
- mute.site = Page.site_list.sites_byaddress[mute.source];
- _this.mutes.push(mute);
- }
- _this.mutes.sort(function(a, b) {
- return b.date_added - a.date_added;
- });
- return Page.projector.scheduleRender();
- };
- })(this));
- };
- MuteList.prototype.handleHideClick = function() {
- return this.visible = false;
- };
- MuteList.prototype.handleMuteRemoveClick = function(e) {
- var mute;
- mute = e.target.mute;
- if (mute.removed) {
- Page.cmd("muteAdd", [mute.auth_address, mute.cert_user_id, mute.reason]);
- } else {
- Page.cmd("muteRemove", mute.auth_address);
- }
- mute.removed = !mute.removed;
- return false;
- };
- MuteList.prototype.render = function() {
- var max_height;
- if (this.need_update) {
- this.update();
- }
- if (!this.mutes) {
- return h("div#MuteList", {
- classes: {
- visible: false
- }
- }, "Muted");
- }
- if (this.visible) {
- max_height = 100 + this.mutes.length * 70;
- } else {
- max_height = 0;
- }
- return h("div#MuteList", {
- classes: {
- visible: this.visible
- },
- style: "max-height: " + max_height + "px"
- }, [
- h("a.mute-hide", {
- href: "#Hide",
- onclick: this.handleHideClick
- }, "\u2039 Back to feed"), this.mutes.length === 0 ? h("div.mute-empty", "Your mute list is empty! :)") : [
- h("div.mute.mute-head", [
- h("div.mute-col", "Muted user"), h("div.mute-col", {
- style: "width: 66%"
- }, "Why?")
- ]), this.mutes.map((function(_this) {
- return function(mute) {
- return h("div.mute", {
- key: mute.auth_address,
- classes: {
- removed: mute.removed
- }
- }, [
- h("div.mute-col", [h("div.cert_user_id", mute.cert_user_id), h("div.auth_address", mute.auth_address)]), h("div.mute-col", {
- style: "width: 66%"
- }, [
- h("div.source", mute.site != null ? mute.site.row.content.title : mute.source), h("div.reason", {
- innerHTML: Text.renderMarked(mute.reason)
- }), h("div.date_added", " \u2500 " + Time.since(mute.date_added))
- ]), h("a.action", {
- href: "#Unmute",
- onclick: _this.handleMuteRemoveClick,
- mute: mute
- }, "×")
- ]);
- };
- })(this))
- ]
- ]);
- };
- MuteList.prototype.show = function() {
- this.visible = true;
- this.need_update = true;
- return Page.projector.scheduleRender();
- };
- return MuteList;
- })(Class);
- window.MuteList = MuteList;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageSites/Site.coffee ---- */
- (function() {
- var Site,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty,
- indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- Site = (function(superClass) {
- extend(Site, superClass);
- function Site(row, item_list) {
- this.item_list = item_list;
- this.renderOptionalStats = bind(this.renderOptionalStats, this);
- this.render = bind(this.render, this);
- this.handleLimitIncreaseClick = bind(this.handleLimitIncreaseClick, this);
- this.handleHelpsClick = bind(this.handleHelpsClick, this);
- this.handleHelpAllClick = bind(this.handleHelpAllClick, this);
- this.handleHelpClick = bind(this.handleHelpClick, this);
- this.handleSettingsClick = bind(this.handleSettingsClick, this);
- this.handleDeleteClick = bind(this.handleDeleteClick, this);
- this.handleCloneUpgradeClick = bind(this.handleCloneUpgradeClick, this);
- this.handleCloneClick = bind(this.handleCloneClick, this);
- this.handlePauseClick = bind(this.handlePauseClick, this);
- this.handleResumeClick = bind(this.handleResumeClick, this);
- this.handleCheckfilesClick = bind(this.handleCheckfilesClick, this);
- this.handleUpdateClick = bind(this.handleUpdateClick, this);
- this.handleUnfavoriteClick = bind(this.handleUnfavoriteClick, this);
- this.handleFavoriteClick = bind(this.handleFavoriteClick, this);
- this.deleted = false;
- this.show_errors = false;
- this.message_visible = false;
- this.message = null;
- this.message_class = "";
- this.message_collapsed = false;
- this.message_timer = null;
- this.favorite = Page.settings.favorite_sites[row.address];
- this.key = row.address;
- this.optional_helps = [];
- this.optional_helps_disabled = {};
- this.setRow(row);
- this.files = new SiteFiles(this);
- this.menu = new Menu();
- this.menu_helps = null;
- }
- Site.prototype.setRow = function(row) {
- var key, ref, ref1, ref2, val;
- if (((ref = row.event) != null ? ref[0] : void 0) === "updated" && row.content_updated !== false) {
- this.setMessage("Updated!", "done");
- } else if (((ref1 = row.event) != null ? ref1[0] : void 0) === "updating") {
- this.setMessage("Updating...");
- } else if (row.tasks > 0) {
- this.setMessage("Updating: " + (Math.max(row.tasks, row.bad_files)) + " left");
- } else if (row.bad_files > 0) {
- if (row.peers <= 1) {
- this.setMessage("No peers", "error");
- } else {
- this.setMessage(row.bad_files + " file update failed", "error");
- }
- } else if (row.content_updated === false) {
- if (row.peers <= 1) {
- this.setMessage("No peers", "error");
- } else {
- this.setMessage("Update failed", "error");
- }
- } else if (row.tasks === 0 && ((ref2 = this.row) != null ? ref2.tasks : void 0) > 0) {
- this.setMessage("Updated!", "done");
- }
- if (row.body == null) {
- row.body = "";
- }
- this.optional_helps = (function() {
- var ref3, results;
- ref3 = row.settings.optional_help;
- results = [];
- for (key in ref3) {
- val = ref3[key];
- results.push([key, val]);
- }
- return results;
- })();
- return this.row = row;
- };
- Site.prototype.setMessage = function(message, message_class) {
- this.message_class = message_class != null ? message_class : "";
- if (message) {
- this.message = message;
- this.message_visible = true;
- if (this.message_class === "error" && !this.show_errors) {
- this.message_collapsed = true;
- } else {
- this.message_collapsed = false;
- }
- } else {
- this.message_visible = false;
- }
- clearInterval(this.message_timer);
- if (this.message_class === "done") {
- this.message_timer = setTimeout(((function(_this) {
- return function() {
- return _this.setMessage("");
- };
- })(this)), 5000);
- }
- return Page.projector.scheduleRender();
- };
- Site.prototype.isWorking = function() {
- var ref;
- return this.row.tasks > 0 || ((ref = this.row.event) != null ? ref[0] : void 0) === "updating";
- };
- Site.prototype.handleFavoriteClick = function() {
- this.favorite = true;
- this.menu = new Menu();
- Page.settings.favorite_sites[this.row.address] = true;
- Page.saveSettings();
- Page.site_list.reorder();
- return false;
- };
- Site.prototype.handleUnfavoriteClick = function() {
- this.favorite = false;
- this.menu = new Menu();
- delete Page.settings.favorite_sites[this.row.address];
- Page.saveSettings();
- Page.site_list.reorder();
- return false;
- };
- Site.prototype.handleUpdateClick = function() {
- Page.cmd("siteUpdate", {
- "address": this.row.address
- });
- this.show_errors = true;
- return false;
- };
- Site.prototype.handleCheckfilesClick = function() {
- Page.cmd("siteUpdate", {
- "address": this.row.address,
- "check_files": true,
- since: 0
- });
- this.show_errors = true;
- return false;
- };
- Site.prototype.handleResumeClick = function() {
- Page.cmd("siteResume", {
- "address": this.row.address
- });
- return false;
- };
- Site.prototype.handlePauseClick = function() {
- Page.cmd("sitePause", {
- "address": this.row.address
- });
- return false;
- };
- Site.prototype.handleCloneClick = function() {
- Page.cmd("siteClone", {
- "address": this.row.address
- });
- return false;
- };
- Site.prototype.handleCloneUpgradeClick = function() {
- Page.cmd("wrapperConfirm", ["Are you sure?" + (" Any modifications you made on<br><b>" + this.row.content.title + "</b> site's js/css files will be lost."), "Upgrade"], (function(_this) {
- return function(confirmed) {
- return Page.cmd("siteClone", {
- "address": _this.row.content.cloned_from,
- "root_inner_path": _this.row.content.clone_root,
- "target_address": _this.row.address
- });
- };
- })(this));
- return false;
- };
- Site.prototype.handleDeleteClick = function() {
- if (this.row.settings.own) {
- Page.cmd("wrapperNotification", ["error", "Sorry, you can't delete your own site.<br>Please remove the directory manually."]);
- } else {
- if (Page.server_info.rev > 2060) {
- Page.cmd("wrapperConfirm", ["Are you sure?" + (" <b>" + this.row.content.title + "</b>"), ["Delete", "Blacklist"]], (function(_this) {
- return function(confirmed) {
- if (confirmed === 1) {
- Page.cmd("siteDelete", {
- "address": _this.row.address
- });
- _this.item_list.deleteItem(_this);
- return Page.projector.scheduleRender();
- } else if (confirmed === 2) {
- return Page.cmd("wrapperPrompt", ["Blacklist <b>" + _this.row.content.title + "</b>", "text", "Delete and Blacklist", "Reason"], function(reason) {
- Page.cmd("siteDelete", {
- "address": _this.row.address
- });
- Page.cmd("blacklistAdd", [_this.row.address, reason]);
- _this.item_list.deleteItem(_this);
- return Page.projector.scheduleRender();
- });
- }
- };
- })(this));
- } else {
- Page.cmd("wrapperConfirm", ["Are you sure?" + (" <b>" + this.row.content.title + "</b>"), "Delete"], (function(_this) {
- return function(confirmed) {
- if (confirmed) {
- Page.cmd("siteDelete", {
- "address": _this.row.address
- });
- _this.item_list.deleteItem(_this);
- return Page.projector.scheduleRender();
- }
- };
- })(this));
- }
- }
- return false;
- };
- Site.prototype.handleSettingsClick = function(e) {
- this.menu.items = [];
- if (this.favorite) {
- this.menu.items.push(["Unfavorite", this.handleUnfavoriteClick]);
- } else {
- this.menu.items.push(["Favorite", this.handleFavoriteClick]);
- }
- this.menu.items.push(["Update", this.handleUpdateClick]);
- this.menu.items.push(["Check files", this.handleCheckfilesClick]);
- if (this.row.settings.serving) {
- this.menu.items.push(["Pause", this.handlePauseClick]);
- } else {
- this.menu.items.push(["Resume", this.handleResumeClick]);
- }
- if (this.row.content.cloneable === true) {
- this.menu.items.push(["Clone", this.handleCloneClick]);
- }
- if (this.row.settings.own && this.row.content.cloned_from && Page.server_info.rev >= 2080) {
- this.menu.items.push(["---"]);
- this.menu.items.push(["Upgrade code", this.handleCloneUpgradeClick]);
- }
- this.menu.items.push(["---"]);
- this.menu.items.push(["Delete", this.handleDeleteClick]);
- if (this.menu.visible) {
- this.menu.hide();
- } else {
- this.menu.show();
- }
- return false;
- };
- Site.prototype.handleHelpClick = function(directory, title) {
- if (this.optional_helps_disabled[directory]) {
- Page.cmd("OptionalHelp", [directory, title, this.row.address]);
- delete this.optional_helps_disabled[directory];
- } else {
- Page.cmd("OptionalHelpRemove", [directory, this.row.address]);
- this.optional_helps_disabled[directory] = true;
- }
- return true;
- };
- Site.prototype.handleHelpAllClick = function() {
- if (this.row.settings.autodownloadoptional === true) {
- return Page.cmd("OptionalHelpAll", [false, this.row.address], (function(_this) {
- return function() {
- _this.row.settings.autodownloadoptional = false;
- return Page.projector.scheduleRender();
- };
- })(this));
- } else {
- return Page.cmd("OptionalHelpAll", [true, this.row.address], (function(_this) {
- return function() {
- _this.row.settings.autodownloadoptional = true;
- return Page.projector.scheduleRender();
- };
- })(this));
- }
- };
- Site.prototype.handleHelpsClick = function(e) {
- var directory, i, len, ref, ref1, title;
- if (e.target.classList.contains("menu-item")) {
- return;
- }
- if (!this.menu_helps) {
- this.menu_helps = new Menu();
- }
- this.menu_helps.items = [];
- this.menu_helps.items.push([
- "Help distribute all new files", this.handleHelpAllClick, ((function(_this) {
- return function() {
- return _this.row.settings.autodownloadoptional;
- };
- })(this))
- ]);
- if (this.optional_helps.length > 0) {
- this.menu_helps.items.push(["---"]);
- }
- ref = this.optional_helps;
- for (i = 0, len = ref.length; i < len; i++) {
- ref1 = ref[i], directory = ref1[0], title = ref1[1];
- this.menu_helps.items.push([
- title, ((function(_this) {
- return function() {
- return _this.handleHelpClick(directory, title);
- };
- })(this)), ((function(_this) {
- return function() {
- return !_this.optional_helps_disabled[directory];
- };
- })(this))
- ]);
- }
- this.menu_helps.toggle();
- return true;
- };
- Site.prototype.getHref = function(row) {
- var has_plugin, href, ref, ref1;
- has_plugin = (((ref = Page.server_info) != null ? ref.plugins : void 0) != null) && (indexOf.call(Page.server_info.plugins, "Zeroname") >= 0 || indexOf.call(Page.server_info.plugins, "Dnschain") >= 0 || indexOf.call(Page.server_info.plugins, "Zeroname-local") >= 0);
- if (has_plugin && ((ref1 = this.row.content) != null ? ref1.domain : void 0)) {
- href = Text.getSiteUrl(this.row.content.domain);
- } else {
- href = Text.getSiteUrl(this.row.address);
- }
- if (row != null ? row.inner_path : void 0) {
- return href + row.inner_path;
- } else {
- return href;
- }
- };
- Site.prototype.handleLimitIncreaseClick = function() {
- if (Page.server_info.rev < 3170) {
- return Page.cmd("wrapperNotification", ["info", "You need ZeroNet Rev3170 to use this command"]);
- }
- Page.cmd("as", [this.row.address, "siteSetLimit", this.row.need_limit], (function(_this) {
- return function(res) {
- if (res === "ok") {
- Page.cmd("wrapperNotification", ["done", "Site <b>" + _this.row.content.title + "</b> storage limit modified to <b>" + _this.row.need_limit + "MB</b>", 5000]);
- } else {
- Page.cmd("wrapperNotification", ["error", res.error]);
- }
- return Page.projector.scheduleRender();
- };
- })(this));
- return false;
- };
- Site.prototype.render = function() {
- var now, ref;
- now = Date.now() / 1000;
- return h("div.site", {
- key: this.key,
- "data-key": this.key,
- classes: {
- "modified-lastday": now - this.row.settings.modified < 60 * 60 * 24,
- "disabled": !this.row.settings.serving && !this.row.demo,
- "working": this.isWorking()
- }
- }, h("div.circle", {
- style: "color: " + (Text.toColor(this.row.address, 40, 50))
- }, ["\u2022"]), h("a.inner", {
- href: this.getHref(),
- title: ((ref = this.row.content.title) != null ? ref.length : void 0) > 20 ? this.row.content.title : void 0
- }, [
- h("span.title", [this.row.content.title]), h("div.details", [h("span.modified", [h("div.icon-clock"), Page.settings.sites_orderby === "size" ? h("span.value", [(this.row.settings.size / 1024 / 1024 + (this.row.settings.size_optional != null) / 1024 / 1024).toFixed(1), "MB"]) : h("span.value", [Time.since(this.row.settings.modified)])]), h("span.peers", [h("div.icon-profile"), h("span.value", [Math.max((this.row.settings.peers ? this.row.settings.peers : 0), this.row.peers)])])]), this.row.demo ? h("div.details.demo", "Activate \u00BB") : void 0, this.row.need_limit ? h("a.details.needaction", {
- href: "#Set+limit",
- onclick: this.handleLimitIncreaseClick
- }, "Set limit to " + this.row.need_limit + "MB") : void 0, h("div.message", {
- classes: {
- visible: this.message_visible,
- done: this.message_class === 'done',
- error: this.message_class === 'error',
- collapsed: this.message_collapsed
- }
- }, [this.message])
- ]), h("a.settings", {
- href: "#Settings",
- tabIndex: -1,
- onmousedown: this.handleSettingsClick,
- onclick: Page.returnFalse
- }, ["\u22EE"]), this.menu.render());
- };
- Site.prototype.renderCircle = function(value, max) {
- var dashoffset, stroke;
- if (value < 1) {
- dashoffset = 75 + (1 - value) * 75;
- } else {
- dashoffset = Math.max(0, 75 - ((value - 1) / 9) * 75);
- }
- stroke = "hsl(" + (Math.min(555, value * 50)) + ", 100%, 61%)";
- return h("div.circle", {
- title: "Upload/Download ratio",
- innerHTML: "<svg class=\"circle-svg\" width=\"30\" height=\"30\" viewPort=\"0 0 30 30\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle r=\"12\" cx=\"15\" cy=\"15\" fill=\"transparent\" class='circle-bg'></circle>\n <circle r=\"12\" cx=\"15\" cy=\"15\" fill=\"transparent\" class='circle-fg' style='stroke-dashoffset: " + dashoffset + "; stroke: " + stroke + "'></circle>\n</svg>"
- });
- };
- Site.prototype.renderOptionalStats = function() {
- var ratio, ratio_hue, row;
- row = this.row;
- ratio = (row.settings.bytes_sent / row.settings.bytes_recv).toFixed(1);
- if (ratio >= 100) {
- ratio = "\u221E";
- } else if (ratio >= 10) {
- ratio = (row.settings.bytes_sent / row.settings.bytes_recv).toFixed(0);
- }
- ratio_hue = Math.min(555, (row.settings.bytes_sent / row.settings.bytes_recv) * 50);
- return h("div.site", {
- key: this.key
- }, [
- h("div.title", [
- h("h3.name", h("a", {
- href: this.getHref()
- }, row.content.title)), h("div.size", {
- title: "Site size limit: " + (Text.formatSize(row.size_limit * 1024 * 1024))
- }, [
- "" + (Text.formatSize(row.settings.size)), h("div.bar", h("div.bar-active", {
- style: "width: " + (100 * (row.settings.size / (row.size_limit * 1024 * 1024))) + "%"
- }))
- ]), h("div.plus", "+"), h("div.size.size-optional", {
- title: "Optional files on site: " + (Text.formatSize(row.settings.size_optional))
- }, [
- "" + (Text.formatSize(row.settings.optional_downloaded)), h("span.size-title", "Optional"), h("div.bar", h("div.bar-active", {
- style: "width: " + (100 * (row.settings.optional_downloaded / row.settings.size_optional)) + "%"
- }))
- ]), h("a.helps", {
- href: "#",
- onmousedown: this.handleHelpsClick,
- onclick: Page.returnFalse
- }, h("div.icon-share"), this.row.settings.autodownloadoptional ? "\u2661" : this.optional_helps.length, h("div.icon-arrow-down"), this.menu_helps ? this.menu_helps.render() : void 0), this.renderCircle(parseFloat((row.settings.bytes_sent / row.settings.bytes_recv).toFixed(1)), 10), h("div.circle-value", {
- classes: {
- negative: ratio < 1
- },
- style: "color: hsl(" + ratio_hue + ", 70%, 60%)"
- }, ratio), h("div.transfers", [
- h("div.up", {
- "title": "Uploaded"
- }, "\u22F0 \u00A0" + (Text.formatSize(row.settings.bytes_sent))), h("div.down", {
- "title": "Downloaded"
- }, "\u22F1 \u00A0" + (Text.formatSize(row.settings.bytes_recv)))
- ])
- ]), this.files.render()
- ]);
- };
- return Site;
- })(Class);
- window.Site = Site;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageSites/SiteList.coffee ---- */
- (function() {
- var SiteList,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- SiteList = (function(superClass) {
- extend(SiteList, superClass);
- function SiteList() {
- this.onSiteInfo = bind(this.onSiteInfo, this);
- this.render = bind(this.render, this);
- this.handleFilterClear = bind(this.handleFilterClear, this);
- this.handleFilterKeyup = bind(this.handleFilterKeyup, this);
- this.handleFilterInput = bind(this.handleFilterInput, this);
- this.renderMergedSites = bind(this.renderMergedSites, this);
- this.reorder = bind(this.reorder, this);
- this.sortRows = bind(this.sortRows, this);
- this.reorderTimer = bind(this.reorderTimer, this);
- this.item_list = new ItemList(Site, "address");
- this.sites = this.item_list.items;
- this.sites_byaddress = this.item_list.items_bykey;
- this.inactive_demo_sites = null;
- this.loaded = false;
- this.schedule_reorder = false;
- this.merged_db = {};
- this.filtering = "";
- setInterval(this.reorderTimer, 10000);
- Page.on_settings.then((function(_this) {
- return function() {
- _this.update();
- return Page.cmd("channelJoinAllsite", {
- "channel": "siteChanged"
- });
- };
- })(this));
- }
- SiteList.prototype.reorderTimer = function() {
- if (!this.schedule_reorder) {
- return;
- }
- if (!document.querySelector('.left:hover') && !document.querySelector(".working") && !Page.mode === "Files") {
- this.reorder();
- return this.schedule_reorder = false;
- }
- };
- SiteList.prototype.sortRows = function(rows) {
- if (Page.settings.sites_orderby === "modified") {
- rows.sort(function(a, b) {
- return b.row.settings.modified - a.row.settings.modified;
- });
- } else if (Page.settings.sites_orderby === "addtime") {
- rows.sort(function(a, b) {
- return (b.row.settings.added || 0) - (a.row.settings.added || 0);
- });
- } else if (Page.settings.sites_orderby === "size") {
- rows.sort(function(a, b) {
- return b.row.settings.size - a.row.settings.size;
- });
- } else {
- rows.sort(function(a, b) {
- return Math.max(b.row.peers, b.row.settings.peers) - Math.max(a.row.peers, a.row.settings.peers);
- });
- }
- return rows;
- };
- SiteList.prototype.reorder = function() {
- this.sortRows(this.item_list.items);
- return Page.projector.scheduleRender();
- };
- SiteList.prototype.update = function() {
- Page.cmd("siteList", {}, (function(_this) {
- return function(site_rows) {
- var favorite_sites;
- favorite_sites = Page.settings.favorite_sites;
- _this.item_list.sync(site_rows);
- _this.sortRows(_this.item_list.items);
- if (_this.inactive_demo_sites === null) {
- _this.updateInactiveDemoSites();
- }
- Page.projector.scheduleRender();
- return _this.loaded = true;
- };
- })(this));
- return this;
- };
- SiteList.prototype.updateInactiveDemoSites = function() {
- var demo_site_rows, i, len, results, site_row;
- demo_site_rows = [
- {
- address: "1Gfey7wVXXg1rxk751TBTxLJwhddDNfcdp",
- demo: true,
- content: {
- title: "ZeroBoard",
- domain: "Board.ZeroNetwork.bit"
- },
- settings: {}
- }, {
- address: "1TaLkFrMwvbNsooF4ioKAY9EuxTBTjipT",
- demo: true,
- content: {
- title: "ZeroTalk",
- domain: "Talk.ZeroNetwork.bit"
- },
- settings: {}
- }, {
- address: "1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8",
- demo: true,
- content: {
- title: "ZeroBlog",
- domain: "Blog.ZeroNetwork.bit"
- },
- settings: {}
- }, {
- address: "1MaiL5gfBM1cyb4a8e3iiL8L5gXmoAJu27",
- demo: true,
- content: {
- title: "ZeroMail",
- domain: "Mail.ZeroNetwork.bit"
- },
- settings: {}
- }, {
- address: "1uPLoaDwKzP6MCGoVzw48r4pxawRBdmQc",
- demo: true,
- content: {
- title: "ZeroUp"
- },
- settings: {}
- }, {
- address: "1Gif7PqWTzVWDQ42Mo7np3zXmGAo3DXc7h",
- demo: true,
- content: {
- title: "GIF Time"
- },
- settings: {}
- }, {
- address: "1SiTEs2D3rCBxeMoLHXei2UYqFcxctdwB",
- demo: true,
- content: {
- title: "More @ ZeroSites",
- domain: "Sites.ZeroNetwork.bit"
- },
- settings: {}
- }
- ];
- if (Page.server_info.rev >= 1400) {
- demo_site_rows.push({
- address: "1MeFqFfFFGQfa1J3gJyYYUvb5Lksczq7nH",
- demo: true,
- content: {
- title: "ZeroMe",
- domain: "Me.ZeroNetwork.bit"
- },
- settings: {}
- });
- }
- this.inactive_demo_sites = [];
- results = [];
- for (i = 0, len = demo_site_rows.length; i < len; i++) {
- site_row = demo_site_rows[i];
- if (this.filtering && site.row.content.title.toLowerCase().indexOf(this.filtering.toLowerCase()) === -1) {
- continue;
- }
- if (!this.sites_byaddress[site_row.address]) {
- results.push(this.inactive_demo_sites.push(new Site(site_row)));
- } else {
- results.push(void 0);
- }
- }
- return results;
- };
- SiteList.prototype.renderMergedSites = function() {
- var back, i, len, merged_db, merged_sites, merged_type, name, ref, site;
- merged_db = {};
- ref = this.sites_merged;
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- if (!site.row.content.merged_type) {
- continue;
- }
- if (merged_db[name = site.row.content.merged_type] == null) {
- merged_db[name] = [];
- }
- merged_db[site.row.content.merged_type].push(site);
- }
- back = [];
- for (merged_type in merged_db) {
- merged_sites = merged_db[merged_type];
- back.push([
- h("h2.more", {
- key: "Merged: " + merged_type
- }, "Merged: " + merged_type), h("div.SiteList.merged.merged-" + merged_type, merged_sites.map(function(item) {
- return item.render();
- }))
- ]);
- }
- return back;
- };
- SiteList.prototype.handleFilterInput = function(e) {
- return this.filtering = e.target.value;
- };
- SiteList.prototype.handleFilterKeyup = function(e) {
- if (e.keyCode === 27) {
- e.target.value = "";
- this.handleFilterInput(e);
- }
- return false;
- };
- SiteList.prototype.handleFilterClear = function(e) {
- e.target.value = "";
- this.handleFilterInput(e);
- return false;
- };
- SiteList.prototype.render = function() {
- var filter_base, i, len, ref, ref1, site;
- if (!this.loaded) {
- return h("div#SiteList");
- }
- this.sites_needaction = [];
- this.sites_favorited = [];
- this.sites_owned = [];
- this.sites_connected = [];
- this.sites_merged = [];
- ref = this.sites;
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- if (this.filtering) {
- filter_base = site.row.content.title + site.row.content.merged_type + site.row.address;
- if (filter_base.toLowerCase().indexOf(this.filtering.toLowerCase()) === -1) {
- continue;
- }
- }
- if (site.row.settings.size * 1.2 > site.row.size_limit * 1024 * 1024) {
- site.row.need_limit = site.row.size_limit * 2;
- this.sites_needaction.push(site);
- } else if (site.favorite) {
- this.sites_favorited.push(site);
- } else if (site.row.content.merged_type) {
- this.sites_merged.push(site);
- } else if ((ref1 = site.row.settings) != null ? ref1.own : void 0) {
- this.sites_owned.push(site);
- } else {
- this.sites_connected.push(site);
- }
- }
- return h("div#SiteList", [
- this.sites.length > 20 ? h("input.site-filter", {
- placeholder: "Filter: Site name",
- spellcheck: false,
- oninput: this.handleFilterInput,
- onkeyup: this.handleFilterKeyup,
- value: this.filtering
- }) : void 0, this.filtering ? h("a.filter-clear", {
- href: "#clear",
- onclick: this.handleFilterClear
- }, "\u00D7") : void 0, this.sites_needaction.length > 0 ? h("h2.needaction", "Running out of size limit:") : void 0, h("div.SiteList.needaction", this.sites_needaction.map(function(item) {
- return item.render();
- })), this.sites_favorited.length > 0 ? h("h2.favorited", "Favorited sites:") : void 0, h("div.SiteList.favorited", this.sites_favorited.map(function(item) {
- return item.render();
- })), this.sites_owned.length > 0 ? h("h2.owned", "Owned sites:") : void 0, h("div.SiteList.owned", this.sites_owned.map(function(item) {
- return item.render();
- })), this.sites_connected.length > 0 ? h("h2.connected", "Connected sites:") : void 0, h("div.SiteList.connected", this.sites_connected.map(function(item) {
- return item.render();
- })), this.renderMergedSites(), this.inactive_demo_sites !== null && this.inactive_demo_sites.length > 0 ? [
- h("h2.more", {
- key: "More"
- }, "More sites:"), h("div.SiteList.more", this.inactive_demo_sites.map(function(item) {
- return item.render();
- }))
- ] : void 0
- ]);
- };
- SiteList.prototype.onSiteInfo = function(site_info) {
- var ref;
- if ((ref = this.item_list.items_bykey[site_info.address]) != null) {
- ref.setRow(site_info);
- }
- this.schedule_reorder = true;
- return Page.projector.scheduleRender();
- };
- return SiteList;
- })(Class);
- window.SiteList = SiteList;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageSites/Trigger.coffee ---- */
- (function() {
- var Trigger,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- Trigger = (function(superClass) {
- extend(Trigger, superClass);
- function Trigger() {
- this.render = bind(this.render, this);
- this.handleTitleClick = bind(this.handleTitleClick, this);
- this.active = false;
- }
- Trigger.prototype.handleTitleClick = function() {
- this.active = !this.active;
- if (this.active) {
- document.getElementById("left").classList.add("trigger-on");
- } else {
- document.getElementById("left").classList.remove("trigger-on");
- }
- return false;
- };
- Trigger.prototype.render = function() {
- return h("div.Trigger", {
- classes: {
- "active": this.active
- }
- }, [
- h("a.icon", {
- "href": "#Trigger",
- onclick: this.handleTitleClick,
- ontouchend: ""
- }, h("div.arrow-right"))
- ]);
- };
- return Trigger;
- })(Class);
- window.Trigger = Trigger;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/Chart.coffee ---- */
- (function() {
- var Chart,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- Chart = (function(superClass) {
- extend(Chart, superClass);
- function Chart() {
- this.render = bind(this.render, this);
- this.updateChart = bind(this.updateChart, this);
- this.update = bind(this.update, this);
- this.getTitle = bind(this.getTitle, this);
- this.initChart = bind(this.initChart, this);
- this.query = "";
- this.title = "";
- this.value = "";
- this.line_data = [];
- this.details = [];
- this.colorize = "cc00ff0a";
- this.chart_ctx = null;
- this.chart_type_name = null;
- this.need_update = false;
- }
- Chart.prototype.initChart = function(node) {
- this.chart_canvas = node;
- return this.chart_ctx = node.getContext("2d");
- };
- Chart.prototype.getTitle = function() {
- return this.title;
- };
- Chart.prototype.update = function() {
- var query_type_data, type_name;
- Page.cmd("chartDbQuery", this.getChartQuery(), (function(_this) {
- return function(res) {
- var j, len, row;
- _this.line_data = [];
- for (j = 0, len = res.length; j < len; j++) {
- row = res[j];
- _this.line_data.push(row.value);
- }
- _this.line_data.reverse();
- return _this.updateChart();
- };
- })(this));
- query_type_data = "SELECT * FROM data\nWHERE\n type_id IN :type_ids AND\n date_added = (SELECT date_added FROM data ORDER BY data_id DESC LIMIT 1)";
- return Page.cmd("chartDbQuery", [
- query_type_data, {
- type_ids: (function() {
- var j, len, ref, results;
- ref = this.type_names;
- results = [];
- for (j = 0, len = ref.length; j < len; j++) {
- type_name = ref[j];
- results.push(Page.page_stats.type_id_db[type_name]);
- }
- return results;
- }).call(this)
- }
- ], (function(_this) {
- return function(res) {
- var j, len, row, type_data;
- type_data = {};
- for (j = 0, len = res.length; j < len; j++) {
- row = res[j];
- type_data[Page.page_stats.type_name_db[row.type_id]] = row.value;
- }
- _this.details = typeof _this.formatDetails === "function" ? _this.formatDetails(type_data) : void 0;
- _this.value = typeof _this.formatValue === "function" ? _this.formatValue(type_data) : void 0;
- return Page.projector.scheduleRender();
- };
- })(this));
- };
- Chart.prototype.updateChart = function() {
- var data, data_max, data_min, gradient, i, j, len, line_y, ref, step, stroke;
- this.chart_ctx.clearRect(0, 0, this.chart_canvas.width, this.chart_canvas.height);
- stroke = this.chart_ctx.createLinearGradient(0, 0, 900, 0);
- stroke.addColorStop(0, this.chart_stroke[0]);
- stroke.addColorStop(1, this.chart_stroke[1]);
- this.chart_ctx.lineWidth = 4;
- this.chart_ctx.strokeStyle = stroke;
- this.chart_ctx.fillStyle = '#66666611';
- gradient = this.chart_ctx.createLinearGradient(0, 200, 0, 400);
- gradient.addColorStop(0, "#42324599");
- gradient.addColorStop(1, "#2C2E3700");
- this.chart_ctx.fillStyle = gradient;
- this.chart_ctx.beginPath();
- this.chart_ctx.moveTo(-10, 0);
- step = 900 / (this.line_data.length - 2);
- data_max = Math.max.apply(null, this.line_data);
- data_min = Math.min.apply(null, this.line_data);
- ref = this.line_data;
- for (i = j = 0, len = ref.length; j < len; i = ++j) {
- data = ref[i];
- line_y = 250 - ((data - data_min) / (data_max - data_min)) * 120;
- this.chart_ctx.lineTo((i - 1) * step, line_y);
- }
- this.chart_ctx.lineTo((i + 1) * step, line_y);
- this.chart_ctx.lineTo(i * step, 450);
- this.chart_ctx.lineTo(0, 450);
- this.chart_ctx.fill();
- this.chart_ctx.stroke();
- return this.chart_ctx.shadowBlur = 0;
- };
- Chart.prototype.render = function() {
- if (this.need_update) {
- this.update();
- this.need_update = false;
- }
- return h("div.Chart", {
- style: "background-image: radial-gradient(at 29% top, #eaaeda05, " + this.colorize + ")"
- }, [
- h("div.titles", [
- h("div.title", this.getTitle()), h("div.value", this.value), h("div.details", this.details.map((function(_this) {
- return function(detail) {
- return [
- detail, h("br", {
- key: detail
- })
- ];
- };
- })(this)))
- ]), h("canvas.canvas", {
- afterCreate: this.initChart,
- width: 900,
- height: 400
- })
- ]);
- };
- return Chart;
- })(Class);
- window.Chart = Chart;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/ChartBig.coffee ---- */
- (function() {
- var ChartBig,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- ChartBig = (function(superClass) {
- extend(ChartBig, superClass);
- function ChartBig() {
- this.render = bind(this.render, this);
- this.initChart = bind(this.initChart, this);
- this.storeCanvasNode = bind(this.storeCanvasNode, this);
- this.update = bind(this.update, this);
- var types;
- this.need_update = false;
- this.data = {};
- this.data_max = {};
- this.data_total = {};
- types = {};
- }
- ChartBig.prototype.update = function(cb) {
- var date_added_from, date_added_to, interval, query, query_group, query_select, step, type, type_ids;
- if (Page.params.interval === "1w") {
- interval = 60 * 60 * 24 * 7;
- step = 60 * 60;
- query_select = "MAX(date_added) AS date_added, type_id, SUM(value) AS value";
- query_group = "GROUP BY type_id, strftime('%Y-%m-%d %H', date_added, 'unixepoch', 'localtime')";
- } else {
- interval = 60 * 60 * 24;
- step = 60 * 5;
- query_select = "*";
- query_group = "";
- }
- if (Page.params.date_added_to) {
- date_added_to = (new Date(Page.params.date_added_to + " 23:59")).getTime() / 1000;
- date_added_from = date_added_to - interval;
- } else {
- date_added_to = Time.timestamp();
- date_added_from = Time.timestamp() - interval;
- }
- query = "SELECT " + query_select + " FROM data\nWHERE type_id IN :type_ids AND date_added >= :date_added_from AND date_added <= :date_added_to\n" + query_group + "\nORDER BY date_added";
- type_ids = (function() {
- var j, len, ref, results;
- ref = this.types;
- results = [];
- for (j = 0, len = ref.length; j < len; j++) {
- type = ref[j];
- results.push(Page.page_stats.type_id_db[type.name]);
- }
- return results;
- }).call(this);
- return Page.cmd("chartDbQuery", [
- query, {
- type_ids: type_ids,
- date_added_from: date_added_from,
- date_added_to: date_added_to
- }
- ], (function(_this) {
- return function(res) {
- var data_date_added, data_found, data_value, dataset, i, j, k, l, len, len1, len2, len3, len4, m, n, row, type_id, type_name;
- _this.logStart("Parse result");
- _this.data = {
- labels: []
- };
- _this.data_max = {};
- _this.data_total = {};
- for (j = 0, len = type_ids.length; j < len; j++) {
- type_id = type_ids[j];
- _this.data[type_id] = {};
- _this.data_max[Page.page_stats.type_name_db[type_id]] = 0;
- _this.data_total[Page.page_stats.type_name_db[type_id]] = 0;
- }
- for (k = 0, len1 = res.length; k < len1; k++) {
- row = res[k];
- type_name = Page.page_stats.type_name_db[row.type_id];
- _this.data[row.type_id][Math.ceil(row.date_added / step) * step] = row.value;
- _this.data_max[type_name] = Math.max(row.value, _this.data_max[type_name]);
- _this.data_total[type_name] += row.value;
- }
- _this.configuration.options.scales.yAxes[0].ticks.suggestedMax = Math.max(_this.data_max["file_bytes_sent"], _this.data_max["file_bytes_recv"]);
- _this.configuration.options.scales.yAxes[0].ticks.suggestedMin = 0 - _this.configuration.options.scales.yAxes[0].ticks.suggestedMax;
- _this.configuration.options.scales.yAxes[1].ticks.suggestedMax = Math.max(_this.data_max["request_num_sent"], _this.data_max["request_num_recv"]);
- _this.configuration.options.scales.yAxes[1].ticks.suggestedMin = 0 - _this.configuration.options.scales.yAxes[1].ticks.suggestedMax;
- for (i = l = 0, len2 = type_ids.length; l < len2; i = ++l) {
- type_id = type_ids[i];
- dataset = _this.configuration.data.datasets[_this.types[i].dataset_id];
- dataset.data.length = 0;
- dataset.data_i = 0;
- }
- _this.configuration.data.labels.length = 0;
- _this.configuration.data.labels_i = 0;
- data_date_added = Math.ceil(date_added_from / step) * step;
- while (data_date_added <= date_added_to) {
- if (!data_found) {
- for (i = m = 0, len3 = type_ids.length; m < len3; i = ++m) {
- type_id = type_ids[i];
- if (_this.data[type_id][data_date_added]) {
- data_found = true;
- break;
- }
- }
- if (!data_found) {
- data_date_added += step;
- continue;
- }
- }
- for (i = n = 0, len4 = type_ids.length; n < len4; i = ++n) {
- type_id = type_ids[i];
- data_value = _this.data[type_id][data_date_added];
- dataset = _this.configuration.data.datasets[_this.types[i].dataset_id];
- type = _this.types[i];
- if (type.negative) {
- data_value = 0 - data_value;
- }
- dataset.data[dataset.data_i] = data_value;
- dataset.data_i += 1;
- }
- _this.configuration.data.labels.push(data_date_added * 1000);
- _this.configuration.data.labels_i += 1;
- data_date_added += step;
- }
- _this.logEnd("Parse result", "labels: " + _this.configuration.data.labels.length);
- if (_this.chart) {
- _this.chart.update();
- } else {
- _this.initChart();
- }
- if (typeof cb === "function") {
- cb();
- }
- return Page.projector.scheduleRender();
- };
- })(this));
- };
- ChartBig.prototype.storeCanvasNode = function(node) {
- if (this.chart) {
- this.chart.clear();
- this.chart.destroy();
- this.chart = null;
- }
- node.parentNode.style.height = node.getBoundingClientRect().height + "px";
- this.ctx = node.getContext("2d");
- this.chart_node = node;
- return this.configuration != null ? this.configuration : this.configuration = this.getChartConfiguration();
- };
- ChartBig.prototype.initChart = function() {
- var timer_resize;
- this.log("initChart");
- this.chart = new Chart(this.ctx, this.configuration);
- setTimeout(((function(_this) {
- return function() {
- return _this.chart_node.parentNode.style.height = "";
- };
- })(this)), 100);
- timer_resize = null;
- return window.addEventListener("resize", (function(_this) {
- return function() {
- clearInterval(timer_resize);
- return setTimeout((function() {
- return _this.chart.resize();
- }), 300);
- };
- })(this));
- };
- ChartBig.prototype.testDataAddition = function() {
- var timer_i;
- timer_i = 0;
- return setInterval(((function(_this) {
- return function() {
- var data, dataset, i, j, k, len, len1, new_data, new_labels, type_id;
- new_labels = _this.configuration.data.labels.slice();
- new_data = _this.configuration.data.datasets[_this.types[0].dataset_id].data.slice();
- _this.configuration.data.labels = [];
- timer_i += 1;
- for (i = j = 0, len = type_ids.length; j < len; i = ++j) {
- type_id = type_ids[i];
- dataset = _this.configuration.data.datasets[_this.types[i].dataset_id];
- dataset.data.push(Math.round(Math.random() * 10));
- dataset.data.shift();
- }
- for (k = 0, len1 = new_data.length; k < len1; k++) {
- data = new_data[k];
- _this.configuration.data.datasets[_this.types[0].dataset_id].data.push(data);
- }
- _this.configuration.data.labels = new_labels;
- _this.configuration.data.labels.push(1000 * (Time.timestamp() + (timer_i * 60 * 5)));
- _this.configuration.data.labels.shift();
- return _this.chart.update();
- };
- })(this)), 5000);
- };
- ChartBig.prototype.createGradientStroke = function(stops) {
- var color, gradient, i, j, len;
- gradient = this.ctx.createLinearGradient(0, 0, 900, 0);
- for (i = j = 0, len = stops.length; j < len; i = ++j) {
- color = stops[i];
- gradient.addColorStop(i * (1 / (stops.length - 1)), color);
- }
- return gradient;
- };
- ChartBig.prototype.createGradientFill = function(stops, mode) {
- var color, gradient, i, j, len;
- if (mode == null) {
- mode = "normal";
- }
- if (mode === "lower") {
- gradient = this.ctx.createLinearGradient(0, 0, 0, 300);
- } else {
- gradient = this.ctx.createLinearGradient(0, 50, 0, 200);
- }
- for (i = j = 0, len = stops.length; j < len; i = ++j) {
- color = stops[i];
- gradient.addColorStop(i * (1 / (stops.length - 1)), color);
- }
- return gradient;
- };
- ChartBig.prototype.getChartConfiguration = function() {
- var configuration, gradient_fill, gradient_fill_down, gradient_fill_up, gradient_stroke, gradient_stroke_bgline_down, gradient_stroke_bgline_up, gradient_stroke_down, gradient_stroke_up;
- gradient_stroke = this.createGradientStroke(["#5A46DF", "#8F49AA", "#D64C57"]);
- gradient_stroke_bgline_up = this.createGradientStroke(["#EEAAFF11", "#EEAAFF33", "#2da3b366"]);
- gradient_stroke_bgline_down = this.createGradientStroke(["#EEAAFF11", "#EEAAFF33", "#80623f88"]);
- gradient_stroke_up = this.createGradientStroke(["#2b68d9", "#2f99be", "#1dfc59"]);
- gradient_stroke_down = this.createGradientStroke(["#bac735", "#c2a548", "#f1294b"]);
- gradient_fill = this.createGradientFill(["#50455DEE", "#26262C33"]);
- gradient_fill_up = this.createGradientFill(["#1dfc5922", "#2f373333"]);
- gradient_fill_down = this.createGradientFill(["#45353533", "#f1294b22"], "lower");
- configuration = {
- type: 'line',
- data: {
- labels: [],
- datasets: [
- {
- type: 'line',
- label: "Upload",
- borderColor: gradient_stroke_up,
- pointBorderColor: gradient_stroke_up,
- pointBackgroundColor: gradient_stroke_up,
- pointHoverBackgroundColor: gradient_stroke_up,
- pointHoverBorderColor: gradient_stroke_up,
- pointHoverRadius: 2,
- pointRadius: 0,
- steppedLine: true,
- fill: true,
- backgroundColor: gradient_fill_up,
- borderWidth: 1,
- lineTension: 0,
- data: []
- }, {
- type: 'line',
- label: "Download",
- borderColor: gradient_stroke_down,
- pointBorderColor: gradient_stroke_down,
- pointBackgroundColor: gradient_stroke_down,
- pointHoverBackgroundColor: gradient_stroke_down,
- pointHoverBorderColor: gradient_stroke_down,
- pointHoverRadius: 2,
- pointRadius: 0,
- steppedLine: true,
- fill: true,
- backgroundColor: gradient_fill_down,
- borderWidth: 1,
- lineTension: 0,
- data: []
- }, {
- type: 'line',
- label: 'Sent',
- borderColor: gradient_stroke_bgline_up,
- backgroundColor: "rgba(255,255,255,0.0)",
- pointRadius: 0,
- borderWidth: 1,
- pointHoverRadius: 2,
- pointHoverBackgroundColor: gradient_stroke_bgline_up,
- pointHoverBorderColor: gradient_stroke_bgline_up,
- fill: true,
- yAxisID: 'Request',
- steppedLine: true,
- lineTension: 0,
- data: []
- }, {
- type: 'line',
- label: 'Received',
- borderColor: gradient_stroke_bgline_down,
- backgroundColor: "rgba(255,255,255,0.0)",
- pointRadius: 0,
- borderWidth: 1,
- pointHoverRadius: 2,
- pointHoverBackgroundColor: gradient_stroke_bgline_down,
- pointHoverBorderColor: gradient_stroke_bgline_down,
- fill: true,
- yAxisID: 'Request',
- steppedLine: true,
- lineTension: 0,
- data: []
- }
- ]
- },
- options: {
- animation: {
- easing: "easeOutExpo",
- duration: 2000
- },
- legend: {
- display: false,
- position: "top",
- labels: {
- fontColor: 'white'
- }
- },
- title: {
- display: false
- },
- tooltips: {
- mode: "index",
- intersect: false,
- displayColors: false,
- xPadding: 10,
- yPadding: 10,
- cornerRadius: 0,
- caretPadding: 10,
- bodyFontColor: "rgba(255,255,255,0.6)",
- callbacks: {
- title: function(tootlip_items, data) {
- return Time.date(tootlip_items[0].xLabel, "long").replace(/:00$/, "");
- },
- label: function(tootlip_items, data) {
- if (data.datasets[tootlip_items.datasetIndex].yAxisID === "Request") {
- return data.datasets[tootlip_items.datasetIndex].label + ": " + Math.abs(tootlip_items.yLabel) + " requests";
- } else {
- return data.datasets[tootlip_items.datasetIndex].label + ": " + Text.formatSize(Math.abs(tootlip_items.yLabel));
- }
- }
- }
- },
- hover: {
- mode: "index",
- intersect: false
- },
- scales: {
- yAxes: [
- {
- id: 'Transfer',
- ticks: {
- fontColor: "rgba(100,110,132,1)",
- fontStyle: "bold",
- beginAtZero: true,
- suggestedMax: 30000000,
- suggestedMin: -30000000,
- display: true,
- padding: 30,
- callback: function(value) {
- return Text.formatSize(Math.abs(value));
- }
- },
- gridLines: {
- drawTicks: true,
- drawBorder: false,
- display: true,
- zeroLineColor: "rgba(255,255,255,0.1)",
- tickMarkLength: 20,
- zeroLineBorderDashOffset: 100,
- color: "rgba(255,255,255,0.05)"
- }
- }, {
- id: 'Request',
- position: "right",
- ticks: {
- beginAtZero: true,
- maxTicksLimit: 5,
- suggestedMax: 180,
- suggestedMin: -180,
- display: false
- },
- gridLines: {
- display: false,
- zeroLineColor: "rgba(255,255,255,0)",
- drawBorder: false
- }
- }
- ],
- xAxes: [
- {
- type: "time",
- gridLines: {
- color: "rgba(255,255,255,0.1)",
- display: false,
- offsetGridLines: true,
- drawBorder: false
- },
- ticks: {
- padding: 15,
- fontColor: "rgba(100,110,132,1)",
- fontStyle: "bold",
- callback: (function(_this) {
- return function(data_label, index) {
- var back, parts;
- if (_this.last_data_label == null) {
- _this.last_data_label = "None 00 00:00";
- }
- if (_this.last_data_label.match(/.* /)[0] === data_label.match(/.* /)[0]) {
- back = ["", data_label.replace(/.* /, "")];
- } else {
- parts = data_label.split(" ");
- if (parts.length !== 3) {
- return data_label;
- }
- back = [parts[0] + " " + parts[1], parts[2]];
- }
- _this.last_data_label = data_label;
- return back;
- };
- })(this)
- },
- time: {
- displayFormats: {
- 'second': 'MMM DD HH:mm',
- 'minute': 'MMM DD HH:mm',
- 'hour': 'MMM DD HH:mm',
- 'day': 'MMM DD HH:mm',
- 'week': 'MMM DD HH:mm',
- 'month': 'MMM DD HH:mm',
- 'quarter': 'MMM DD HH:mm',
- 'year': 'MMM DD HH:mm'
- }
- }
- }
- ]
- }
- }
- };
- return configuration;
- };
- ChartBig.prototype.render = function() {
- if (this.need_update) {
- this.update();
- this.need_update = false;
- }
- return h("div.ChartBig", [
- h("canvas." + Page.params.interval, {
- width: 1350,
- height: 450,
- afterCreate: this.storeCanvasNode,
- updateAnimation: Animation.show,
- mode: Page.params.interval
- })
- ]);
- };
- return ChartBig;
- })(Class);
- window.ChartBig = ChartBig;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/ChartLegend.coffee ---- */
- (function() {
- var ChartLegend,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- ChartLegend = (function(superClass) {
- extend(ChartLegend, superClass);
- function ChartLegend() {
- this.renderItem = bind(this.renderItem, this);
- this.items_left = [];
- this.items_right = [];
- }
- ChartLegend.prototype.renderItem = function(item) {
- var hidden, value;
- this.i += 1;
- if (item.dot == null) {
- item.dot = "\u25CF";
- }
- value = item.getValue();
- hidden = !value;
- if (item.post) {
- value += " " + item.post;
- }
- if (item.type === "ratio") {
- return h("div.legend-item", {
- classes: {
- hidden: hidden
- }
- }, [
- h("div.title", item.title), h("div.value", [
- h("span", {
- updateAnimation: Animation.show,
- delay: this.i * 0.1
- }, Math.round(value * 10) / 10), h("div.dots-container", [
- h("span.dots.dots-fg", {
- style: "width: " + (Math.min(value, 5) * 11.5) + "px; color: " + item.color
- }, item.dot.repeat(5)), h("span.dots.dots-bg", item.dot.repeat(5))
- ])
- ])
- ]);
- } else {
- return h("div.legend-item", {
- classes: {
- hidden: hidden
- }
- }, [
- h("div.title", [
- h("span.dot", {
- style: "color: " + item.color
- }, item.dot + " "), item.title
- ]), h("div.value", {
- updateAnimation: Animation.show,
- delay: this.i * 0.1
- }, value)
- ]);
- }
- };
- ChartLegend.prototype.render = function() {
- this.i = 0;
- return h("div.ChartLegend", h("div.legend-items.align-left", this.items_left.map(this.renderItem)), h("div.legend-items.align-right", this.items_right.map(this.renderItem)));
- };
- return ChartLegend;
- })(Class);
- window.ChartLegend = ChartLegend;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/ChartRadar.coffee ---- */
- (function() {
- var ChartRadar,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- ChartRadar = (function(superClass) {
- extend(ChartRadar, superClass);
- function ChartRadar(id) {
- this.id = id;
- this.render = bind(this.render, this);
- this.renderLabel = bind(this.renderLabel, this);
- this.handleLegendClick = bind(this.handleLegendClick, this);
- this.initChart = bind(this.initChart, this);
- this.formatLabel = bind(this.formatLabel, this);
- this.getChartConfiguration = bind(this.getChartConfiguration, this);
- this.initCanvas = bind(this.initCanvas, this);
- this.update = bind(this.update, this);
- this.configuration = {};
- this.site_stats = [];
- this.need_update = false;
- this.order_by = "site_bw";
- this.legends = [
- {
- id: "site_bw",
- title: "Transferred data (last 7 days)",
- color: "#608DECDD"
- }, {
- id: "site_size",
- title: "Site size",
- color: "#9C27B0DD"
- }
- ];
- }
- ChartRadar.prototype.update = function() {
- var query, type_ids, type_name;
- query = "SELECT type_id, site_id, SUM(value) AS sum, value\nFROM data\nWHERE type_id IN :type_ids AND date_added > " + (Time.timestamp() - 60 * 60 * 24 * 7) + "\nGROUP BY type_id, site_id";
- type_ids = (function() {
- var j, len, ref, results;
- ref = ["site_bytes_sent", "site_bytes_recv", "site_size"];
- results = [];
- for (j = 0, len = ref.length; j < len; j++) {
- type_name = ref[j];
- results.push(Page.page_stats.type_id_db[type_name]);
- }
- return results;
- })();
- return Page.cmd("chartDbQuery", [
- query, {
- type_ids: type_ids
- }
- ], (function(_this) {
- return function(res) {
- var address, data, i, j, k, len, len1, max_site_bw, max_site_size, ref, row, stat;
- _this.logStart("Parse result");
- data = {};
- for (j = 0, len = res.length; j < len; j++) {
- row = res[j];
- address = Page.page_stats.site_address_db[row.site_id];
- type_name = Page.page_stats.type_name_db[row.type_id];
- if (data[address] == null) {
- data[address] = {
- address: address,
- site: Page.site_list.sites_byaddress[address]
- };
- }
- if (type_name === "site_size") {
- data[address][type_name] = row.value;
- } else {
- data[address][type_name] = row.sum || 0;
- }
- }
- _this.site_stats = [];
- for (address in data) {
- stat = data[address];
- stat.site_bw = stat.site_bytes_sent + stat.site_bytes_recv;
- _this.site_stats.push(stat);
- }
- _this.site_stats.sort(function(a, b) {
- return b[_this.order_by] - a[_this.order_by];
- });
- if (_this.site_stats.length > 8) {
- _this.site_stats.length = 8;
- }
- max_site_bw = Math.max.apply(null, (function() {
- var k, len1, ref, results;
- ref = this.site_stats;
- results = [];
- for (k = 0, len1 = ref.length; k < len1; k++) {
- stat = ref[k];
- results.push(stat.site_bw);
- }
- return results;
- }).call(_this));
- max_site_size = Math.max.apply(null, (function() {
- var k, len1, ref, results;
- ref = this.site_stats;
- results = [];
- for (k = 0, len1 = ref.length; k < len1; k++) {
- stat = ref[k];
- results.push(stat.site_size);
- }
- return results;
- }).call(_this));
- ref = _this.site_stats;
- for (i = k = 0, len1 = ref.length; k < len1; i = ++k) {
- stat = ref[i];
- _this.configuration.data.labels[i] = stat.site.row.content.title;
- _this.configuration.data.datasets[0].data[i] = Math.log(1 + (stat.site_bw / max_site_bw) * 100);
- _this.configuration.data.datasets[1].data[i] = Math.log(1 + (stat.site_size / max_site_size) * 100);
- }
- _this.logEnd("Parse result", "sites: " + _this.site_stats.length);
- Page.projector.scheduleRender();
- if (_this.chart) {
- return _this.chart.update();
- } else {
- return _this.initChart();
- }
- };
- })(this));
- };
- ChartRadar.prototype.initCanvas = function(node) {
- if (this.chart) {
- this.chart.clear();
- this.chart.destroy();
- this.chart = null;
- }
- this.ctx = node.getContext("2d");
- return this.configuration = this.getChartConfiguration();
- };
- ChartRadar.prototype.getChartConfiguration = function() {
- var fill, fill2, shadowed;
- fill = this.ctx.createLinearGradient(0, 0, 900, 0);
- fill.addColorStop(0, "#608DECCC");
- fill.addColorStop(1, "#9C27B0CC");
- fill2 = this.ctx.createLinearGradient(0, 0, 900, 0);
- fill2.addColorStop(0, "#9C27B0DD");
- fill2.addColorStop(1, "#608DECDD");
- shadowed = {
- beforeDatasetsDraw: function(chart, options) {
- chart.ctx.shadowColor = 'rgba(0, 0, 0, 0.5)';
- return chart.ctx.shadowBlur = 40;
- },
- afterDatasetsDraw: function(chart, options) {
- chart.ctx.shadowColor = 'rgba(0, 0, 0, 0)';
- return chart.ctx.shadowBlur = 0;
- }
- };
- return {
- type: 'radar',
- data: {
- labels: [],
- datasets: [
- {
- label: "Transferred data",
- backgroundColor: fill,
- borderColor: "transparent",
- borderWidth: 0,
- pointBorderWidth: 0,
- pointRadius: 0,
- data: []
- }, {
- label: "Site size",
- backgroundColor: fill2,
- borderColor: "transparent",
- borderWidth: 0,
- pointBorderWidth: 0,
- pointRadius: 0,
- data: []
- }
- ]
- },
- options: {
- legend: {
- display: false,
- position: "bottom",
- labels: {
- padding: 5
- }
- },
- scale: {
- ticks: {
- display: false,
- maxTicksLimit: 5,
- beginAtZero: true
- },
- angleLines: {
- color: "#99999911"
- },
- gridLines: {
- color: "#99999911",
- tickMarkLength: 1
- },
- tooltips: {
- enabled: true
- },
- pointLabels: {
- fontColor: "rgba(200,210,232,1)",
- fontSize: 14,
- fontFamily: "Roboto",
- fontStyle: "lighter",
- padding: 10,
- callback: this.formatLabel
- }
- }
- },
- plugins: [shadowed]
- };
- };
- ChartRadar.prototype.formatLabel = function() {
- return [""];
- };
- ChartRadar.prototype.initChart = function() {
- var timer_resize;
- this.chart = new Chart(this.ctx, this.configuration);
- timer_resize = null;
- return window.addEventListener("resize", (function(_this) {
- return function() {
- _this.log("resize");
- clearInterval(timer_resize);
- return setTimeout((function() {
- return _this.chart.resize();
- }), 300);
- };
- })(this));
- };
- ChartRadar.prototype.handleLegendClick = function(e) {
- this.order_by = e.currentTarget.getAttribute("href").replace("#", "");
- this.update();
- return false;
- };
- ChartRadar.prototype.renderLabel = function(stat, i) {
- var left, r, top;
- if (i % (this.site_stats.length / 2) === 0) {
- r = 37;
- } else {
- r = 40;
- }
- left = 50 + r * Math.sin(2 * Math.PI * i / this.site_stats.length);
- top = 50 - r * Math.cos(2 * Math.PI * i / this.site_stats.length);
- return h("div.radar-label", {
- key: stat.address + i,
- style: "left: " + left + "%; top: " + top + "%",
- enterAnimation: Animation.show,
- exitAnimation: Animation.hide,
- delay: i * 0.05
- }, h("a.title", {
- href: stat.site.getHref()
- }, stat.site.row.content.title), " ", h("span.value", " (" + (Text.formatSize(stat[this.order_by]) || 'No data yet') + ")"));
- };
- ChartRadar.prototype.render = function() {
- var label_i;
- if (this.need_update) {
- this.update();
- this.need_update = false;
- }
- label_i = 0;
- return h("div.ChartRadar", [
- h("div.radar-container", [
- h("div.radar-labels", this.site_stats.map((function(_this) {
- return function(stat) {
- var label;
- label = _this.renderLabel(stat, label_i);
- label_i += 1;
- return label;
- };
- })(this))), h("div.canvas-container", h("canvas", {
- width: 600,
- height: 600,
- afterCreate: this.initCanvas
- }))
- ]), h("div.radar-legends", this.legends.map((function(_this) {
- return function(legend) {
- return h("a.radar-legend", {
- id: legend.id,
- classes: {
- active: _this.order_by === legend.id
- },
- onclick: _this.handleLegendClick,
- href: "#" + legend.id
- }, [
- h("div.legend-box", {
- style: "background-color: " + legend.color
- }), h("span.title", legend.title)
- ]);
- };
- })(this)))
- ]);
- };
- return ChartRadar;
- })(Class);
- window.ChartRadar = ChartRadar;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/ChartTimeline.coffee ---- */
- (function() {
- var ChartTimeline,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- ChartTimeline = (function(superClass) {
- extend(ChartTimeline, superClass);
- function ChartTimeline() {
- this.render = bind(this.render, this);
- this.update = bind(this.update, this);
- this.updateChart = bind(this.updateChart, this);
- this.initChart = bind(this.initChart, this);
- var i, j;
- this.items = [];
- for (i = j = 6; j >= 0; i = --j) {
- this.items.push({
- id: i,
- title: "\u200B",
- data: "\u200B",
- value: i,
- active: false
- });
- }
- this.active_id = 0;
- this.chart_ctx = null;
- this.need_update = false;
- this.line_data = null;
- }
- ChartTimeline.prototype.initChart = function(node) {
- this.chart_canvas = node;
- this.chart_ctx = node.getContext("2d");
- if (this.line_data) {
- return this.updateChart();
- }
- };
- ChartTimeline.prototype.updateChart = function() {
- var data, data_last_i, data_max, i, j, len, line_width, line_x, line_y, ref, val;
- this.chart_ctx.clearRect(0, 0, this.chart_canvas.width, this.chart_canvas.height);
- this.chart_ctx.lineWidth = 0;
- this.chart_ctx.fillStyle = '#EDC54B';
- this.chart_ctx.beginPath();
- this.chart_ctx.moveTo(-10, 0);
- data_max = Math.max.apply(null, this.line_data);
- data_last_i = ((function() {
- var j, len, ref, results;
- ref = this.line_data;
- results = [];
- for (i = j = 0, len = ref.length; j < len; i = ++j) {
- val = ref[i];
- if (val > 0) {
- results.push(i);
- }
- }
- return results;
- }).call(this)).pop();
- line_width = 1400 / this.line_data.length;
- ref = this.line_data;
- for (i = j = 0, len = ref.length; j < len; i = ++j) {
- data = ref[i];
- line_x = i * line_width;
- line_y = parseInt(101 - (data / data_max) * 100);
- this.chart_ctx.lineTo(line_x, line_y);
- if (i === data_last_i) {
- break;
- }
- }
- this.chart_ctx.lineTo(line_x, 120);
- this.chart_ctx.lineTo(0, 120);
- this.chart_ctx.fill();
- if (data_last_i > 36) {
- this.chart_ctx.beginPath();
- this.chart_ctx.lineWidth = 0;
- this.chart_ctx.strokeStyle = '#EDC54B';
- this.chart_ctx.setLineDash([0, 1, 1]);
- this.chart_ctx.moveTo(line_x, line_y);
- this.chart_ctx.lineTo(1500, line_y);
- return this.chart_ctx.stroke();
- }
- };
- ChartTimeline.prototype.update = function() {
- var c, data, date_added_from, date_added_to, day_total, group_steps, interval_step, query, step, type_id;
- query = "SELECT\nMAX(date_added) AS date_added, AVG(value) AS avg, SUM(value) AS sum\nFROM data\nWHERE type_id = :type_id AND date_added >= :date_added_from AND date_added <= :date_added_to\nGROUP BY strftime('%Y-%m-%d %H', date_added, 'unixepoch', 'localtime')\nORDER BY date_added DESC";
- if (Page.params.interval === "1w") {
- c = new Date();
- c.setDate(c.getDate() - (c.getDay() || 7) + 7);
- date_added_to = c.setHours(23, 59, 59, 0) / 1000;
- interval_step = 60 * 60 * 24 * 7;
- date_added_from = date_added_to - interval_step * 7;
- group_steps = 6;
- } else if (Page.params.interval === "1m") {
- c = new Date();
- c.setDate(30);
- date_added_to = c.setHours(23, 59, 59, 0) / 1000;
- interval_step = 60 * 60 * 24 * 30;
- date_added_from = date_added_to - interval_step * 30;
- group_steps = 24 * 3;
- } else {
- date_added_to = (new Date()).setHours(23, 59, 59, 0) / 1000;
- interval_step = 60 * 60 * 24;
- date_added_from = date_added_to - interval_step * 7;
- group_steps = 2;
- }
- step = 60 * 60;
- type_id = Page.page_stats.type_id_db["file_bytes_sent"];
- data = {};
- day_total = {};
- return Page.cmd("chartDbQuery", [
- query, {
- type_id: type_id,
- date_added_from: date_added_from,
- date_added_to: date_added_to
- }
- ], (function(_this) {
- return function(res) {
- var data_date_added, data_from, data_to, day_data, day_from, day_name, day_string, day_to, group_step_data, i, j, k, l, len, m, n, ref, row, x;
- _this.logStart("Parse result");
- _this.line_data = [];
- for (j = 0, len = res.length; j < len; j++) {
- row = res[j];
- data[Math.ceil(row.date_added / step) * step] = row.sum;
- day_string = Time.dateIso(row.date_added * 1000);
- if (day_total[day_string] == null) {
- day_total[day_string] = 0;
- }
- day_total[day_string] += row.sum;
- }
- data_date_added = Math.ceil(date_added_from / step) * step;
- while (data_date_added <= date_added_to) {
- group_step_data = 0;
- for (i = k = 0, ref = group_steps; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
- group_step_data += data[data_date_added] || 0;
- data_date_added += step;
- }
- _this.line_data.push(group_step_data);
- }
- _this.items = [];
- for (i = l = 7; l >= 1; i = --l) {
- data_from = date_added_to - i * interval_step + 1;
- data_to = data_from + interval_step - 1;
- if (Page.params.interval === "1w") {
- day_data = 0;
- for (x = m = 0; m <= 6; x = ++m) {
- day_data += day_total[Time.dateIso(data_from + (60 * 60 * 24 * x))] || 0;
- }
- day_from = Time.date(data_from, "day");
- day_to = Time.date(data_from + interval_step - 1, "day");
- day_to = day_to.replace(day_from.split(" ")[0], "");
- day_name = day_from + " - " + day_to;
- } else if (Page.params.interval === "1m") {
- day_data = 0;
- for (x = n = 0; n <= 30; x = ++n) {
- day_data += day_total[Time.dateIso(data_from + (60 * 60 * 24 * x))] || 0;
- }
- day_name = Time.date(data_from, "month");
- } else {
- day_data = day_total[Time.dateIso(data_from)];
- day_name = Time.weekDay(data_from);
- }
- _this.items.push({
- id: i,
- title: day_name,
- data: day_data,
- value: data_to
- });
- }
- _this.logEnd("Parse result", "data: " + _this.line_data.length);
- Page.projector.scheduleRender();
- return _this.updateChart();
- };
- })(this));
- };
- ChartTimeline.prototype.renderItem = function(item) {
- var classes, date_added_to;
- date_added_to = Time.dateIso(item.value);
- if (item.value >= Time.timestamp()) {
- date_added_to = "";
- }
- classes = {
- active: (Page.params.date_added_to || "") === date_added_to
- };
- return h("a.timeline-item", {
- key: item.title,
- enterAnimation: Animation.show,
- delay: item.id * 0.05,
- href: Page.createUrl("date_added_to", date_added_to),
- onclick: Page.handleLinkClick,
- classes: classes
- }, h("span.title", item.title), h("span.data", Text.formatSize(item.data) || "0 MB"));
- };
- ChartTimeline.prototype.render = function() {
- var ref;
- if (this.need_update) {
- this.update();
- this.need_update = false;
- }
- return h("div.ChartTimeline", [
- h("div.timeline-borders", this.items.map((function(_this) {
- return function(item) {
- var date_added_to;
- date_added_to = Time.dateIso(item.value);
- if (item.value >= Time.timestamp()) {
- date_added_to = "";
- }
- return h("div.timeline-border", {
- key: item.id,
- classes: {
- active: (Page.params.date_added_to || "") === date_added_to
- }
- });
- };
- })(this))), h("canvas.chart", {
- afterCreate: this.initChart,
- width: 1400,
- height: 100,
- data: (ref = this.line_data) != null ? ref.length : void 0,
- delay: 0.3,
- updateAnimation: Animation.show
- }), h("div.timeline-items", this.items.map((function(_this) {
- return function(item) {
- return _this.renderItem(item);
- };
- })(this)))
- ]);
- };
- return ChartTimeline;
- })(Class);
- window.ChartTimeline = ChartTimeline;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/ChartWorld.coffee ---- */
- (function() {
- var ChartWorld,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- ChartWorld = (function(superClass) {
- extend(ChartWorld, superClass);
- function ChartWorld() {
- this.render = bind(this.render, this);
- this.initCanvas = bind(this.initCanvas, this);
- this.drawPoints = bind(this.drawPoints, this);
- this.update = bind(this.update, this);
- this.points = [];
- this.need_update = false;
- }
- ChartWorld.prototype.update = function() {
- /*
- @points = [
- {lat: 0, lon: 0},
- {lat: 30, lon: 30},
- {lat: 33.137551, lon: 129.902344},
- {lat: 0.351560, lon: 115.136719},
- {lat: 40.178873, lon: -8.261719},
- {lat: 52.482780, lon: -0.878906},
- {lat: 47.040182, lon: 19.511719},
- {lat: 38.548165, lon: -76.113281},
- {lat: 40.446947, lon: -122.871094}
- {lat: -16.972741, lon: 46.582031}
- {lat: -35.173808, lon: 19.511719}
- {lat: -33.431441, lon: 116.542969}
- {lat: -45.336702, lon: 168.222656}
- {lat: -54.977614, lon: -67.412109}
- {lat: 8.928487, lon: -62.314453}
- {lat: 65.20515, lon: -14.670696}
- {lat: 64.90863, lon: -21.70194625}
- ]
- return false
- */
- return Page.cmd("chartGetPeerLocations", [], (function(_this) {
- return function(res) {
- var country, country_db, i, item, items, j, len, len1, name, num, num_others, point, ref, ref1;
- _this.points = res;
- country_db = {};
- items = Page.page_stats.country_list.items;
- items.length = 0;
- ref = _this.points;
- for (i = 0, len = ref.length; i < len; i++) {
- point = ref[i];
- if (country_db[name = point.country] == null) {
- country_db[name] = 0;
- }
- country_db[point.country] += 1;
- }
- for (country in country_db) {
- num = country_db[country];
- items.push({
- title: country,
- value: num
- });
- }
- items.sort(function(a, b) {
- return b.value - a.value;
- });
- if (items.length > 15) {
- num_others = 0;
- ref1 = items.slice(14);
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- item = ref1[j];
- num_others += item.value;
- }
- items.length = 14;
- items.push({
- title: "Other",
- value: num_others,
- type: "other"
- });
- }
- _this.drawPoints();
- return Page.projector.scheduleRender();
- };
- })(this));
- };
- ChartWorld.prototype.drawPoints = function() {
- var i, left, len, point, ref, results, top;
- this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
- ref = this.points;
- results = [];
- for (i = 0, len = ref.length; i < len; i++) {
- point = ref[i];
- left = (47 + (point.lon / 3.65)) * this.canvas.width / 100;
- top = (59 - (point.lat / 1.52)) * this.canvas.height / 100;
- results.push(this.ctx.fillRect(left, top, 2, 2));
- }
- return results;
- };
- ChartWorld.prototype.initCanvas = function(node) {
- this.canvas = node;
- this.ctx = node.getContext("2d");
- this.ctx.globalCompositeOperation = 'screen';
- this.ctx.fillStyle = '#30758e';
- return this.drawPoints();
- };
- ChartWorld.prototype.render = function() {
- if (this.need_update) {
- this.update();
- this.need_update = false;
- }
- return h("div.ChartWorld", [
- h("canvas.map-points", {
- width: 878,
- height: 371,
- afterCreate: this.initCanvas
- }), h("img.map", {
- src: "img/world.png"
- })
- ]);
- };
- return ChartWorld;
- })(Class);
- window.ChartWorld = ChartWorld;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/PageStats.coffee ---- */
- (function() {
- var PageStats,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- PageStats = (function(superClass) {
- extend(PageStats, superClass);
- function PageStats() {
- this.render = bind(this.render, this);
- this.loadChartjs = bind(this.loadChartjs, this);
- this.update = bind(this.update, this);
- this.handleChartjsLoad = bind(this.handleChartjsLoad, this);
- this.need_update = false;
- this.need_load_chartjs = true;
- this.chartjs_loaded = false;
- this.chart_timeline = new ChartTimeline();
- this.chart_big = new ChartBig();
- this.chart_big.types = [
- {
- name: "file_bytes_sent",
- dataset_id: 0
- }, {
- name: "file_bytes_recv",
- dataset_id: 1,
- negative: true
- }, {
- name: "request_num_sent",
- dataset_id: 2,
- negative: true
- }, {
- name: "request_num_recv",
- dataset_id: 3
- }
- ];
- this.chart_legend = new ChartLegend();
- this.chart_legend.items_left = [
- {
- title: "Upload",
- getValue: ((function(_this) {
- return function() {
- return Text.formatSize(_this.chart_big.data_total.file_bytes_sent);
- };
- })(this)),
- color: "#1dfc59"
- }, {
- title: "Download",
- getValue: ((function(_this) {
- return function() {
- return Text.formatSize(_this.chart_big.data_total.file_bytes_recv);
- };
- })(this)),
- color: "#c94d47"
- }, {
- title: "Ratio",
- getValue: ((function(_this) {
- return function() {
- return _this.chart_big.data_total.file_bytes_sent / _this.chart_big.data_total.file_bytes_recv;
- };
- })(this)),
- type: "ratio",
- color: "#16ffe9"
- }
- ];
- this.chart_legend.items_right = [
- {
- title: "Sent",
- getValue: ((function(_this) {
- return function() {
- return _this.chart_big.data_total.request_num_sent;
- };
- })(this)),
- post: "requests",
- dot: "\u2500",
- color: "#2da3b3"
- }, {
- title: "Received",
- getValue: ((function(_this) {
- return function() {
- return _this.chart_big.data_total.request_num_recv;
- };
- })(this)),
- post: "requests",
- dot: "\u2500",
- color: "#80623f"
- }
- ];
- this.chart_radar = new ChartRadar();
- this.chart_connections = new Chart();
- this.chart_connections.title = "Connections";
- this.chart_connections.type_names = ["peer", "peer_onion", "connection", "connection_onion", "connection_in", "connection_ping_avg", "connection_ping_min"];
- this.chart_connections.formatValue = function(type_data) {
- return type_data.connection + " of " + type_data.peer + " peers";
- };
- this.chart_connections.formatDetails = function(type_data) {
- var back;
- back = [];
- back.push("Onion: " + type_data.peer_onion + " peers (" + (type_data.connection_onion || 0) + " connections)");
- back.push("Incoming: " + (Math.round(type_data.connection_in / type_data.connection * 100)) + "%");
- back.push("Ping avg: " + type_data.connection_ping_avg + "ms (min: " + type_data.connection_ping_min + "ms)");
- return back;
- };
- this.chart_connections.chart_stroke = ["#608DECAA", "#D74C58FF"];
- this.chart_connections.getChartQuery = function() {
- return "SELECT * FROM data WHERE type_id = " + Page.page_stats.type_id_db['connection'] + " ORDER BY date_added DESC LIMIT 50";
- };
- this.chart_size = new Chart();
- this.chart_size.getTitle = function() {
- return h("a", {
- href: Page.createUrl("bigchart", "size"),
- onclick: Page.handleLinkClick
- }, "Total size");
- };
- this.chart_size.chart_stroke = ["#F99739AA", "#51B8F2"];
- this.chart_size.type_names = ["size", "size_optional", "optional_limit", "optional_used", "content"];
- this.chart_size.formatValue = function(type_data) {
- return Text.formatSize(type_data.size);
- };
- this.chart_size.formatDetails = function(type_data) {
- var back;
- back = [];
- back.push("Content sources: " + type_data.content + " files");
- back.push("Optional downloaded: " + (Text.formatSize(type_data.optional_used) || '0 MB') + " of " + (Text.formatSize(type_data.size_optional) || '0 MB') + " (limit: " + (Text.formatSize(type_data.optional_limit)) + ")");
- return back;
- };
- this.chart_size.getChartQuery = function() {
- return "SELECT CAST(value AS FLOAT) / 1024 / 1024 AS value FROM data WHERE type_id = " + Page.page_stats.type_id_db['size'] + " GROUP BY ROUND(date_added / 10000) ORDER BY date_added DESC LIMIT 50";
- };
- this.chart_world = new ChartWorld();
- this.country_list = new StatList();
- this.type_name_db = {};
- this.type_id_db = {};
- this.site_address_db = {};
- this.site_id_db = {};
- setInterval(((function(_this) {
- return function() {
- _this.need_update = true;
- return Page.projector.scheduleRender();
- };
- })(this)), 5 * 60 * 1000);
- }
- PageStats.prototype.handleChartjsLoad = function() {
- this.chartjs_loaded = true;
- return Page.projector.scheduleRender();
- };
- PageStats.prototype.update = function() {
- Page.cmd("chartDbQuery", "SELECT * FROM type", (function(_this) {
- return function(res) {
- var i, len, results, row;
- _this.type_id_db = {};
- _this.type_name_db = {};
- results = [];
- for (i = 0, len = res.length; i < len; i++) {
- row = res[i];
- _this.type_id_db[row.name] = row.type_id;
- results.push(_this.type_name_db[row.type_id] = row.name);
- }
- return results;
- };
- })(this));
- return Page.cmd("chartDbQuery", "SELECT * FROM site", (function(_this) {
- return function(res) {
- var i, len, row, sites;
- sites = {};
- _this.sites_by_id = {};
- for (i = 0, len = res.length; i < len; i++) {
- row = res[i];
- _this.site_id_db[row.address] = row.site_id;
- _this.site_address_db[row.site_id] = row.address;
- }
- _this.chart_big.need_update = true;
- _this.chart_timeline.need_update = true;
- _this.chart_connections.need_update = true;
- _this.chart_size.need_update = true;
- _this.chart_radar.need_update = true;
- _this.chart_world.need_update = true;
- return Page.projector.scheduleRender();
- };
- })(this));
- };
- PageStats.prototype.loadChartjs = function() {
- var e;
- e = document.createElement("script");
- e.type = "text/javascript";
- e.src = "chartjs/chart.bundle.min.js";
- e.onload = this.handleChartjsLoad;
- return document.body.appendChild(e);
- };
- PageStats.prototype.render = function() {
- var intervals, ref;
- if (((ref = Page.server_info) != null ? ref.rev : void 0) < 3220) {
- return h("div#PageStats", h("div.empty", [h("h4", "Need update"), h("small", "You have to update to ZeroNet version 0.6.1 to use this feature.")]));
- }
- if (this.need_update) {
- this.update();
- this.need_update = false;
- }
- if (!this.need_update && document.body.className !== "loaded") {
- setTimeout((function() {
- return document.body.className = "loaded";
- }), 1000);
- }
- if (this.need_load_chartjs) {
- setTimeout(this.loadChartjs, 500);
- this.need_load_chartjs = false;
- }
- intervals = ["1w", "1d"];
- return h("div#PageStats", [
- h("div.intervals", intervals.map((function(_this) {
- return function(interval) {
- var interval_param;
- if (interval === "1d") {
- interval_param = void 0;
- } else {
- interval_param = interval;
- }
- return h("a.interval", {
- href: Page.createUrl("interval", interval_param),
- onclick: Page.handleLinkClick,
- classes: {
- active: interval_param === Page.params.interval
- }
- }, interval);
- };
- })(this))), this.chart_timeline.render(), this.chartjs_loaded ? [this.chart_big.render(), this.chart_legend.render(), this.chart_radar.render(), h("div.Charts", [this.chart_connections.render(), this.chart_size.render()]), this.chart_world.render(), this.country_list.render()] : void 0
- ]);
- };
- return PageStats;
- })(Class);
- window.PageStats = PageStats;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/PageStats/StatList.coffee ---- */
- (function() {
- var StatList,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- StatList = (function(superClass) {
- extend(StatList, superClass);
- function StatList() {
- this.render = bind(this.render, this);
- this.renderItem = bind(this.renderItem, this);
- this.items = [];
- }
- StatList.prototype.renderItem = function(item) {
- return h("div.stat-list-item", {
- key: item.title,
- classes: {
- other: item.type === "other"
- }
- }, h("div.title", item.title), h("div.value", item.value + " peers"));
- };
- StatList.prototype.render = function() {
- return h("div.StatList", [h("h4", "Top country"), h("div.stat-list-items", this.items.map(this.renderItem))]);
- };
- return StatList;
- })(Class);
- window.StatList = StatList;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Animation.coffee ---- */
- (function() {
- var Animation;
- Animation = (function() {
- function Animation() {}
- Animation.prototype.slideDown = function(elem, props) {
- var cstyle, h, margin_bottom, margin_top, padding_bottom, padding_top, transition;
- if (elem.offsetTop > 1000) {
- return;
- }
- h = elem.offsetHeight;
- cstyle = window.getComputedStyle(elem);
- margin_top = cstyle.marginTop;
- margin_bottom = cstyle.marginBottom;
- padding_top = cstyle.paddingTop;
- padding_bottom = cstyle.paddingBottom;
- transition = cstyle.transition;
- elem.style.boxSizing = "border-box";
- elem.style.overflow = "hidden";
- elem.style.transform = "scale(0.6)";
- elem.style.opacity = "0";
- elem.style.height = "0px";
- elem.style.marginTop = "0px";
- elem.style.marginBottom = "0px";
- elem.style.paddingTop = "0px";
- elem.style.paddingBottom = "0px";
- elem.style.transition = "none";
- setTimeout((function() {
- elem.className += " animate-inout";
- elem.style.height = h + "px";
- elem.style.transform = "scale(1)";
- elem.style.opacity = "1";
- elem.style.marginTop = margin_top;
- elem.style.marginBottom = margin_bottom;
- elem.style.paddingTop = padding_top;
- return elem.style.paddingBottom = padding_bottom;
- }), 1);
- return elem.addEventListener("transitionend", function() {
- elem.classList.remove("animate-inout");
- elem.style.transition = elem.style.transform = elem.style.opacity = elem.style.height = null;
- elem.style.boxSizing = elem.style.marginTop = elem.style.marginBottom = null;
- elem.style.paddingTop = elem.style.paddingBottom = elem.style.overflow = null;
- return elem.removeEventListener("transitionend", arguments.callee, false);
- });
- };
- Animation.prototype.slideUp = function(elem, remove_func, props) {
- if (elem.offsetTop > 1000) {
- return remove_func();
- }
- elem.className += " animate-back";
- elem.style.boxSizing = "border-box";
- elem.style.height = elem.offsetHeight + "px";
- elem.style.overflow = "hidden";
- elem.style.transform = "scale(1)";
- elem.style.opacity = "1";
- elem.style.pointerEvents = "none";
- setTimeout((function() {
- elem.style.height = "0px";
- elem.style.marginTop = "0px";
- elem.style.marginBottom = "0px";
- elem.style.paddingTop = "0px";
- elem.style.paddingBottom = "0px";
- elem.style.transform = "scale(0.8)";
- elem.style.borderTopWidth = "0px";
- elem.style.borderBottomWidth = "0px";
- return elem.style.opacity = "0";
- }), 1);
- return elem.addEventListener("transitionend", function(e) {
- if (e.propertyName === "opacity" || e.elapsedTime >= 0.6) {
- elem.removeEventListener("transitionend", arguments.callee, false);
- return remove_func();
- }
- });
- };
- Animation.prototype.slideUpInout = function(elem, remove_func, props) {
- elem.className += " animate-inout";
- elem.style.boxSizing = "border-box";
- elem.style.height = elem.offsetHeight + "px";
- elem.style.overflow = "hidden";
- elem.style.transform = "scale(1)";
- elem.style.opacity = "1";
- elem.style.pointerEvents = "none";
- setTimeout((function() {
- elem.style.height = "0px";
- elem.style.marginTop = "0px";
- elem.style.marginBottom = "0px";
- elem.style.paddingTop = "0px";
- elem.style.paddingBottom = "0px";
- elem.style.transform = "scale(0.8)";
- elem.style.borderTopWidth = "0px";
- elem.style.borderBottomWidth = "0px";
- return elem.style.opacity = "0";
- }), 1);
- return elem.addEventListener("transitionend", function(e) {
- if (e.propertyName === "opacity" || e.elapsedTime >= 0.6) {
- elem.removeEventListener("transitionend", arguments.callee, false);
- return remove_func();
- }
- });
- };
- Animation.prototype.showRight = function(elem, props) {
- elem.className += " animate";
- elem.style.opacity = 0;
- elem.style.transform = "TranslateX(-20px) Scale(1.01)";
- setTimeout((function() {
- elem.style.opacity = 1;
- return elem.style.transform = "TranslateX(0px) Scale(1)";
- }), 1);
- return elem.addEventListener("transitionend", function() {
- elem.classList.remove("animate");
- return elem.style.transform = elem.style.opacity = null;
- });
- };
- Animation.prototype.show = function(elem, props) {
- var delay, ref;
- delay = ((ref = arguments[arguments.length - 2]) != null ? ref.delay : void 0) * 1000 || 1;
- elem.style.opacity = 0;
- setTimeout((function() {
- return elem.className += " animate";
- }), 1);
- setTimeout((function() {
- return elem.style.opacity = 1;
- }), delay);
- return elem.addEventListener("transitionend", function() {
- elem.classList.remove("animate");
- elem.style.opacity = null;
- return elem.removeEventListener("transitionend", arguments.callee, false);
- });
- };
- Animation.prototype.hide = function(elem, remove_func, props) {
- var delay, ref;
- delay = ((ref = arguments[arguments.length - 2]) != null ? ref.delay : void 0) * 1000 || 1;
- elem.className += " animate";
- setTimeout((function() {
- return elem.style.opacity = 0;
- }), delay);
- return elem.addEventListener("transitionend", function(e) {
- if (e.propertyName === "opacity") {
- return remove_func();
- }
- });
- };
- Animation.prototype.addVisibleClass = function(elem, props) {
- return setTimeout(function() {
- return elem.classList.add("visible");
- });
- };
- return Animation;
- })();
- window.Animation = new Animation();
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Dollar.coffee ---- */
- (function() {
- window.$ = function(selector) {
- if (selector.startsWith("#")) {
- return document.getElementById(selector.replace("#", ""));
- }
- };
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/ItemList.coffee ---- */
- (function() {
- var ItemList;
- ItemList = (function() {
- function ItemList(item_class1, key1) {
- this.item_class = item_class1;
- this.key = key1;
- this.items = [];
- this.items_bykey = {};
- }
- ItemList.prototype.sync = function(rows, item_class, key) {
- var current_obj, i, item, len, results, row;
- this.items.splice(0, this.items.length);
- results = [];
- for (i = 0, len = rows.length; i < len; i++) {
- row = rows[i];
- current_obj = this.items_bykey[row[this.key]];
- if (current_obj) {
- current_obj.row = row;
- results.push(this.items.push(current_obj));
- } else {
- item = new this.item_class(row, this);
- this.items_bykey[row[this.key]] = item;
- results.push(this.items.push(item));
- }
- }
- return results;
- };
- ItemList.prototype.deleteItem = function(item) {
- var index;
- index = this.items.indexOf(item);
- if (index > -1) {
- this.items.splice(index, 1);
- } else {
- console.log("Can't delete item", item);
- }
- return delete this.items_bykey[item.row[this.key]];
- };
- return ItemList;
- })();
- window.ItemList = ItemList;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Menu.coffee ---- */
- (function() {
- var Menu,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
- Menu = (function() {
- function Menu() {
- this.render = bind(this.render, this);
- this.renderItem = bind(this.renderItem, this);
- this.handleClick = bind(this.handleClick, this);
- this.storeNode = bind(this.storeNode, this);
- this.toggle = bind(this.toggle, this);
- this.hide = bind(this.hide, this);
- this.show = bind(this.show, this);
- this.visible = false;
- this.items = [];
- this.node = null;
- this.height = 0;
- }
- Menu.prototype.show = function() {
- var ref;
- if ((ref = window.visible_menu) != null) {
- ref.hide();
- }
- this.visible = true;
- return window.visible_menu = this;
- };
- Menu.prototype.hide = function() {
- return this.visible = false;
- };
- Menu.prototype.toggle = function() {
- if (this.visible) {
- this.hide();
- } else {
- this.show();
- }
- return Page.projector.scheduleRender();
- };
- Menu.prototype.addItem = function(title, cb, selected) {
- if (selected == null) {
- selected = false;
- }
- return this.items.push([title, cb, selected]);
- };
- Menu.prototype.storeNode = function(node) {
- this.node = node;
- if (this.visible) {
- node.className = node.className.replace("visible", "");
- setTimeout(((function(_this) {
- return function() {
- node.className += " visible";
- return node.style.maxHeight = _this.height + "px";
- };
- })(this)), 20);
- node.style.maxHeight = "none";
- this.height = node.offsetHeight;
- return node.style.maxHeight = "0px";
- }
- };
- Menu.prototype.handleClick = function(e) {
- var cb, i, item, keep_menu, len, ref, selected, title;
- keep_menu = false;
- ref = this.items;
- for (i = 0, len = ref.length; i < len; i++) {
- item = ref[i];
- title = item[0], cb = item[1], selected = item[2];
- if (title === e.target.textContent || e.target["data-title"] === title) {
- keep_menu = cb(item);
- break;
- }
- }
- if (keep_menu !== true && cb !== null) {
- this.hide();
- }
- return false;
- };
- Menu.prototype.renderItem = function(item) {
- var cb, href, onclick, selected, title;
- title = item[0], cb = item[1], selected = item[2];
- if (typeof selected === "function") {
- selected = selected();
- }
- if (title === "---") {
- return h("div.menu-item-separator");
- } else {
- if (typeof cb === "string") {
- href = cb;
- onclick = true;
- } else {
- href = "#" + title;
- onclick = this.handleClick;
- }
- return h("a.menu-item", {
- href: href,
- onclick: onclick,
- "data-title": title,
- key: title,
- classes: {
- "selected": selected,
- "noaction": cb === null
- }
- }, title);
- }
- };
- Menu.prototype.render = function(class_name) {
- var max_height;
- if (class_name == null) {
- class_name = "";
- }
- if (this.visible || this.node) {
- if (this.visible) {
- max_height = this.height;
- } else {
- max_height = 0;
- }
- return h("div.menu" + class_name, {
- classes: {
- "visible": this.visible
- },
- style: "max-height: " + max_height + "px",
- afterCreate: this.storeNode
- }, this.items.map(this.renderItem));
- }
- };
- return Menu;
- })();
- window.Menu = Menu;
- document.body.addEventListener("mouseup", function(e) {
- if (!window.visible_menu || !window.visible_menu.node) {
- return false;
- }
- if (e.target !== window.visible_menu.node.parentNode && e.target.parentNode !== window.visible_menu.node && e.target.parentNode !== window.visible_menu.node.parentNode && e.target.parentNode !== window.visible_menu.node && e.target.parentNode.parentNode !== window.visible_menu.node.parentNode) {
- window.visible_menu.hide();
- return Page.projector.scheduleRender();
- }
- });
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Prototypes.coffee ---- */
- (function() {
- String.prototype.startsWith = function(s) {
- return this.slice(0, s.length) === s;
- };
- String.prototype.endsWith = function(s) {
- return s === '' || this.slice(-s.length) === s;
- };
- String.prototype.repeat = function(count) {
- return new Array(count + 1).join(this);
- };
- window.isEmpty = function(obj) {
- var key;
- for (key in obj) {
- return false;
- }
- return true;
- };
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/RateLimit.coffee ---- */
- (function() {
- var call_after_interval, limits;
- limits = {};
- call_after_interval = {};
- window.RateLimit = function(interval, fn) {
- if (!limits[fn]) {
- call_after_interval[fn] = false;
- fn();
- return limits[fn] = setTimeout((function() {
- if (call_after_interval[fn]) {
- fn();
- }
- delete limits[fn];
- return delete call_after_interval[fn];
- }), interval);
- } else {
- return call_after_interval[fn] = true;
- }
- };
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/RateLimitCb.coffee ---- */
- (function() {
- var call_after_interval, calling, calling_iterval, last_time,
- slice = [].slice;
- last_time = {};
- calling = {};
- calling_iterval = {};
- call_after_interval = {};
- window.RateLimitCb = function(interval, fn, args) {
- var cb;
- if (args == null) {
- args = [];
- }
- cb = function() {
- var left;
- left = interval - (Date.now() - last_time[fn]);
- if (left <= 0) {
- delete last_time[fn];
- if (calling[fn]) {
- RateLimitCb(interval, fn, calling[fn]);
- }
- return delete calling[fn];
- } else {
- return setTimeout((function() {
- delete last_time[fn];
- if (calling[fn]) {
- RateLimitCb(interval, fn, calling[fn]);
- }
- return delete calling[fn];
- }), left);
- }
- };
- if (last_time[fn]) {
- return calling[fn] = args;
- } else {
- last_time[fn] = Date.now();
- return fn.apply(this, [cb].concat(slice.call(args)));
- }
- };
- window.RateLimit = function(interval, fn) {
- if (calling_iterval[fn] > interval) {
- clearInterval(calling[fn]);
- delete calling[fn];
- }
- if (!calling[fn]) {
- call_after_interval[fn] = false;
- fn();
- calling_iterval[fn] = interval;
- return calling[fn] = setTimeout((function() {
- if (call_after_interval[fn]) {
- fn();
- }
- delete calling[fn];
- return delete call_after_interval[fn];
- }), interval);
- } else {
- return call_after_interval[fn] = true;
- }
- };
- /*
- window.s = Date.now()
- window.load = (done, num) ->
- console.log "Loading #{num}...", Date.now()-window.s
- setTimeout (-> done()), 1000
-
- RateLimit 500, window.load, [0] # Called instantly
- RateLimit 500, window.load, [1]
- setTimeout (-> RateLimit 500, window.load, [300]), 300
- setTimeout (-> RateLimit 500, window.load, [600]), 600 # Called after 1000ms
- setTimeout (-> RateLimit 500, window.load, [1000]), 1000
- setTimeout (-> RateLimit 500, window.load, [1200]), 1200 # Called after 2000ms
- setTimeout (-> RateLimit 500, window.load, [3000]), 3000 # Called after 3000ms
- */
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Text.coffee ---- */
- (function() {
- var MarkedRenderer, Text,
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty,
- indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- MarkedRenderer = (function(superClass) {
- extend(MarkedRenderer, superClass);
- function MarkedRenderer() {
- return MarkedRenderer.__super__.constructor.apply(this, arguments);
- }
- MarkedRenderer.prototype.image = function(href, title, text) {
- return "<code></code>";
- };
- return MarkedRenderer;
- })(marked.Renderer);
- Text = (function() {
- function Text() {}
- Text.prototype.toColor = function(text, saturation, lightness) {
- var hash, i, j, ref;
- if (saturation == null) {
- saturation = 30;
- }
- if (lightness == null) {
- lightness = 50;
- }
- hash = 0;
- for (i = j = 0, ref = text.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
- hash += text.charCodeAt(i) * i;
- hash = hash % 1777;
- }
- return "hsl(" + (hash % 360) + ("," + saturation + "%," + lightness + "%)");
- };
- Text.prototype.renderMarked = function(text, options) {
- if (options == null) {
- options = {};
- }
- options["gfm"] = true;
- options["breaks"] = true;
- options["sanitize"] = true;
- options["renderer"] = marked_renderer;
- text = marked(text, options);
- return this.fixHtmlLinks(text);
- };
- Text.prototype.emailLinks = function(text) {
- return text.replace(/([a-zA-Z0-9]+)@zeroid.bit/g, "<a href='?to=$1' onclick='return Page.message_create.show(\"$1\")'>$1@zeroid.bit</a>");
- };
- Text.prototype.fixHtmlLinks = function(text) {
- if (window.is_proxy) {
- return text.replace(/href="http:\/\/(127.0.0.1|localhost):43110/g, 'href="http://zero');
- } else {
- return text.replace(/href="http:\/\/(127.0.0.1|localhost):43110/g, 'href="');
- }
- };
- Text.prototype.fixLink = function(link) {
- var back;
- if (window.is_proxy) {
- back = link.replace(/http:\/\/(127.0.0.1|localhost):43110/, 'http://zero');
- return back.replace(/http:\/\/zero\/([^\/]+\.bit)/, "http://$1");
- } else {
- return link.replace(/http:\/\/(127.0.0.1|localhost):43110/, '');
- }
- };
- Text.prototype.toUrl = function(text) {
- return text.replace(/[^A-Za-z0-9]/g, "+").replace(/[+]+/g, "+").replace(/[+]+$/, "");
- };
- Text.prototype.getSiteUrl = function(address) {
- if (window.is_proxy) {
- if (indexOf.call(address, ".") >= 0) {
- return "http://" + address + "/";
- } else {
- return "http://zero/" + address + "/";
- }
- } else {
- return "/" + address + "/";
- }
- };
- Text.prototype.fixReply = function(text) {
- return text.replace(/(>.*\n)([^\n>])/gm, "$1\n$2");
- };
- Text.prototype.toBitcoinAddress = function(text) {
- return text.replace(/[^A-Za-z0-9]/g, "");
- };
- Text.prototype.jsonEncode = function(obj) {
- return unescape(encodeURIComponent(JSON.stringify(obj)));
- };
- Text.prototype.jsonDecode = function(obj) {
- return JSON.parse(decodeURIComponent(escape(obj)));
- };
- Text.prototype.fileEncode = function(obj) {
- if (typeof obj === "string") {
- return btoa(unescape(encodeURIComponent(obj)));
- } else {
- return btoa(unescape(encodeURIComponent(JSON.stringify(obj, void 0, '\t'))));
- }
- };
- Text.prototype.utf8Encode = function(s) {
- return unescape(encodeURIComponent(s));
- };
- Text.prototype.utf8Decode = function(s) {
- return decodeURIComponent(escape(s));
- };
- Text.prototype.distance = function(s1, s2) {
- var char, extra_parts, j, key, len, match, next_find, next_find_i, val;
- s1 = s1.toLocaleLowerCase();
- s2 = s2.toLocaleLowerCase();
- next_find_i = 0;
- next_find = s2[0];
- match = true;
- extra_parts = {};
- for (j = 0, len = s1.length; j < len; j++) {
- char = s1[j];
- if (char !== next_find) {
- if (extra_parts[next_find_i]) {
- extra_parts[next_find_i] += char;
- } else {
- extra_parts[next_find_i] = char;
- }
- } else {
- next_find_i++;
- next_find = s2[next_find_i];
- }
- }
- if (extra_parts[next_find_i]) {
- extra_parts[next_find_i] = "";
- }
- extra_parts = (function() {
- var results;
- results = [];
- for (key in extra_parts) {
- val = extra_parts[key];
- results.push(val);
- }
- return results;
- })();
- if (next_find_i >= s2.length) {
- return extra_parts.length + extra_parts.join("").length;
- } else {
- return false;
- }
- };
- Text.prototype.parseQuery = function(query) {
- var j, key, len, params, part, parts, ref, val;
- params = {};
- parts = query.split('&');
- for (j = 0, len = parts.length; j < len; j++) {
- part = parts[j];
- ref = part.split("="), key = ref[0], val = ref[1];
- if (val) {
- params[decodeURIComponent(key)] = decodeURIComponent(val);
- } else {
- params["url"] = decodeURIComponent(key);
- }
- }
- return params;
- };
- Text.prototype.encodeQuery = function(params) {
- var back, key, val;
- back = [];
- if (params.url) {
- back.push(params.url);
- }
- for (key in params) {
- val = params[key];
- if (!val || key === "url") {
- continue;
- }
- back.push((encodeURIComponent(key)) + "=" + (encodeURIComponent(val)));
- }
- return back.join("&");
- };
- Text.prototype.highlight = function(text, search) {
- var back, i, j, len, part, parts;
- if (!text) {
- return [""];
- }
- parts = text.split(RegExp(search, "i"));
- back = [];
- for (i = j = 0, len = parts.length; j < len; i = ++j) {
- part = parts[i];
- back.push(part);
- if (i < parts.length - 1) {
- back.push(h("span.highlight", {
- key: i
- }, search));
- }
- }
- return back;
- };
- Text.prototype.formatSize = function(size) {
- var size_mb;
- if (!parseInt(size)) {
- return "";
- }
- size_mb = size / 1024 / 1024;
- if (size_mb >= 1000) {
- return (size_mb / 1024).toFixed(1) + " GB";
- } else if (size_mb >= 100) {
- return size_mb.toFixed(0) + " MB";
- } else if (size / 1024 >= 1000) {
- return size_mb.toFixed(2) + " MB";
- } else {
- return (size / 1024).toFixed(2) + " KB";
- }
- };
- return Text;
- })();
- window.marked_renderer = new MarkedRenderer();
- window.is_proxy = document.location.host === "zero" || window.location.pathname === "/";
- window.Text = new Text();
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Time.coffee ---- */
- (function() {
- var Time;
- Time = (function() {
- function Time() {}
- Time.prototype.since = function(timestamp) {
- var back, minutes, now, secs;
- now = +(new Date) / 1000;
- if (timestamp > 1000000000000) {
- timestamp = timestamp / 1000;
- }
- secs = now - timestamp;
- if (secs < 60) {
- back = "Just now";
- } else if (secs < 60 * 60) {
- minutes = Math.round(secs / 60);
- back = "" + minutes + " minutes ago";
- } else if (secs < 60 * 60 * 24) {
- back = (Math.round(secs / 60 / 60)) + " hours ago";
- } else if (secs < 60 * 60 * 24 * 3) {
- back = (Math.round(secs / 60 / 60 / 24)) + " days ago";
- } else {
- back = "on " + this.date(timestamp);
- }
- back = back.replace(/^1 ([a-z]+)s/, "1 $1");
- return back;
- };
- Time.prototype.dateIso = function(timestamp) {
- var tzoffset;
- if (timestamp == null) {
- timestamp = null;
- }
- if (!timestamp) {
- timestamp = window.Time.timestamp();
- }
- if (timestamp > 1000000000000) {
- timestamp = timestamp / 1000;
- }
- tzoffset = (new Date()).getTimezoneOffset() * 60;
- return (new Date((timestamp - tzoffset) * 1000)).toISOString().split("T")[0];
- };
- Time.prototype.date = function(timestamp, format) {
- var display, parts;
- if (timestamp == null) {
- timestamp = null;
- }
- if (format == null) {
- format = "short";
- }
- if (!timestamp) {
- timestamp = window.Time.timestamp();
- }
- if (timestamp > 1000000000000) {
- timestamp = timestamp / 1000;
- }
- parts = (new Date(timestamp * 1000)).toString().split(" ");
- if (format === "short") {
- display = parts.slice(1, 4);
- } else if (format === "day") {
- display = parts.slice(1, 3);
- } else if (format === "month") {
- display = [parts[1], parts[3]];
- } else if (format === "long") {
- display = parts.slice(1, 5);
- }
- return display.join(" ").replace(/( [0-9]{4})/, ",$1");
- };
- Time.prototype.weekDay = function(timestamp) {
- if (timestamp > 1000000000000) {
- timestamp = timestamp / 1000;
- }
- return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][(new Date(timestamp * 1000)).getDay()];
- };
- Time.prototype.timestamp = function(date) {
- if (date == null) {
- date = "";
- }
- if (date === "now" || date === "") {
- return parseInt(+(new Date) / 1000);
- } else {
- return parseInt(Date.parse(date) / 1000);
- }
- };
- return Time;
- })();
- window.Time = new Time;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/Translate.coffee ---- */
- (function() {
- window._ = function(s) {
- return s;
- };
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/utils/ZeroFrame.coffee ---- */
- (function() {
- var ZeroFrame,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- ZeroFrame = (function(superClass) {
- extend(ZeroFrame, superClass);
- function ZeroFrame(url) {
- this.onCloseWebsocket = bind(this.onCloseWebsocket, this);
- this.onOpenWebsocket = bind(this.onOpenWebsocket, this);
- this.onRequest = bind(this.onRequest, this);
- this.onMessage = bind(this.onMessage, this);
- this.url = url;
- this.waiting_cb = {};
- this.wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1");
- this.connect();
- this.next_message_id = 1;
- this.history_state = {};
- this.init();
- }
- ZeroFrame.prototype.init = function() {
- return this;
- };
- ZeroFrame.prototype.connect = function() {
- this.target = window.parent;
- window.addEventListener("message", this.onMessage, false);
- this.cmd("innerReady");
- window.addEventListener("beforeunload", (function(_this) {
- return function(e) {
- _this.log("save scrollTop", window.pageYOffset);
- _this.history_state["scrollTop"] = window.pageYOffset;
- return _this.cmd("wrapperReplaceState", [_this.history_state, null]);
- };
- })(this));
- return this.cmd("wrapperGetState", [], (function(_this) {
- return function(state) {
- if (state != null) {
- _this.history_state = state;
- }
- _this.log("restore scrollTop", state, window.pageYOffset);
- if (window.pageYOffset === 0 && state) {
- return window.scroll(window.pageXOffset, state.scrollTop);
- }
- };
- })(this));
- };
- ZeroFrame.prototype.onMessage = function(e) {
- var cmd, message;
- message = e.data;
- cmd = message.cmd;
- if (cmd === "response") {
- if (this.waiting_cb[message.to] != null) {
- return this.waiting_cb[message.to](message.result);
- } else {
- return this.log("Websocket callback not found:", message);
- }
- } else if (cmd === "wrapperReady") {
- return this.cmd("innerReady");
- } else if (cmd === "ping") {
- return this.response(message.id, "pong");
- } else if (cmd === "wrapperOpenedWebsocket") {
- return this.onOpenWebsocket();
- } else if (cmd === "wrapperClosedWebsocket") {
- return this.onCloseWebsocket();
- } else {
- return this.onRequest(cmd, message.params);
- }
- };
- ZeroFrame.prototype.onRequest = function(cmd, message) {
- return this.log("Unknown request", message);
- };
- ZeroFrame.prototype.response = function(to, result) {
- return this.send({
- "cmd": "response",
- "to": to,
- "result": result
- });
- };
- ZeroFrame.prototype.cmd = function(cmd, params, cb) {
- if (params == null) {
- params = {};
- }
- if (cb == null) {
- cb = null;
- }
- return this.send({
- "cmd": cmd,
- "params": params
- }, cb);
- };
- ZeroFrame.prototype.send = function(message, cb) {
- if (cb == null) {
- cb = null;
- }
- message.wrapper_nonce = this.wrapper_nonce;
- message.id = this.next_message_id;
- this.next_message_id += 1;
- this.target.postMessage(message, "*");
- if (cb) {
- return this.waiting_cb[message.id] = cb;
- }
- };
- ZeroFrame.prototype.onOpenWebsocket = function() {
- return this.log("Websocket open");
- };
- ZeroFrame.prototype.onCloseWebsocket = function() {
- return this.log("Websocket close");
- };
- return ZeroFrame;
- })(Class);
- window.ZeroFrame = ZeroFrame;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/Head.coffee ---- */
- (function() {
- var Head,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty,
- indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- Head = (function(superClass) {
- extend(Head, superClass);
- function Head() {
- this.render = bind(this.render, this);
- this.handleModeClick = bind(this.handleModeClick, this);
- this.handleShutdownZeronetClick = bind(this.handleShutdownZeronetClick, this);
- this.handleUpdateZeronetClick = bind(this.handleUpdateZeronetClick, this);
- this.handleManageMutesClick = bind(this.handleManageMutesClick, this);
- this.handleTorClick = bind(this.handleTorClick, this);
- this.handleOrderbyClick = bind(this.handleOrderbyClick, this);
- this.handleUpdateAllClick = bind(this.handleUpdateAllClick, this);
- this.handleSettingsClick = bind(this.handleSettingsClick, this);
- this.handleBackupClick = bind(this.handleBackupClick, this);
- this.handleCreateSiteClick = bind(this.handleCreateSiteClick, this);
- this.renderMenuLanguage = bind(this.renderMenuLanguage, this);
- this.handleLanguageClick = bind(this.handleLanguageClick, this);
- this.menu_settings = new Menu();
- }
- Head.prototype.formatUpdateInfo = function() {
- if (parseFloat(Page.server_info.version.replace(".", "0")) < parseFloat(Page.latest_version.replace(".", "0"))) {
- return "New version available!";
- } else {
- return "Up to date!";
- }
- };
- Head.prototype.handleLanguageClick = function(e) {
- var lang;
- if (Page.server_info.rev < 1750) {
- return Page.cmd("wrapperNotification", ["info", "You need ZeroNet 0.5.1 to change the interface's language"]);
- }
- lang = e.target.hash.replace("#", "");
- Page.cmd("configSet", ["language", lang], function() {
- Page.server_info.language = lang;
- return top.location = "?Home";
- });
- return false;
- };
- Head.prototype.renderMenuLanguage = function() {
- var lang, langs, ref;
- langs = ["da", "de", "en", "es", "fr", "hu", "it", "nl", "pl", "pt", "pt-br", "ru", "sk", "tr", "uk", "zh", "zh-tw"];
- if (Page.server_info.language && (ref = Page.server_info.language, indexOf.call(langs, ref) < 0)) {
- langs.push(Page.server_info.language);
- }
- return h("div.menu-radio", h("div", "Language: "), (function() {
- var i, len, results;
- results = [];
- for (i = 0, len = langs.length; i < len; i++) {
- lang = langs[i];
- results.push([
- h("a", {
- href: "#" + lang,
- onclick: this.handleLanguageClick,
- classes: {
- selected: Page.server_info.language === lang,
- long: lang.length > 2
- }
- }, lang), " "
- ]);
- }
- return results;
- }).call(this));
- };
- Head.prototype.handleCreateSiteClick = function() {
- if (Page.server_info.rev < 1770) {
- return Page.cmd("wrapperNotification", ["info", "You need to update your ZeroNet client to use this feature"]);
- }
- return Page.cmd("siteClone", [Page.site_info.address, "template-new"]);
- };
- Head.prototype.handleBackupClick = function() {
- if (Page.server_info.rev < 2165) {
- return Page.cmd("wrapperNotification", ["info", "You need to update your ZeroNet client to use this feature"]);
- }
- Page.cmd("serverShowdirectory", "backup");
- return Page.cmd("wrapperNotification", ["info", "Backup <b>users.json</b> file to keep your identity safe."]);
- };
- Head.prototype.handleSettingsClick = function() {
- var base, orderby;
- if ((base = Page.settings).sites_orderby == null) {
- base.sites_orderby = "peers";
- }
- orderby = Page.settings.sites_orderby;
- this.menu_settings.items = [];
- this.menu_settings.items.push(["Update all sites", this.handleUpdateAllClick]);
- this.menu_settings.items.push(["---"]);
- this.menu_settings.items.push([
- "Order sites by peers", ((function(_this) {
- return function() {
- return _this.handleOrderbyClick("peers");
- };
- })(this)), orderby === "peers"
- ]);
- this.menu_settings.items.push([
- "Order sites by update time", ((function(_this) {
- return function() {
- return _this.handleOrderbyClick("modified");
- };
- })(this)), orderby === "modified"
- ]);
- this.menu_settings.items.push([
- "Order sites by add time", ((function(_this) {
- return function() {
- return _this.handleOrderbyClick("addtime");
- };
- })(this)), orderby === "addtime"
- ]);
- this.menu_settings.items.push([
- "Order sites by size", ((function(_this) {
- return function() {
- return _this.handleOrderbyClick("size");
- };
- })(this)), orderby === "size"
- ]);
- this.menu_settings.items.push(["---"]);
- this.menu_settings.items.push([this.renderMenuLanguage(), null]);
- this.menu_settings.items.push(["---"]);
- this.menu_settings.items.push(["Create new, empty site", this.handleCreateSiteClick]);
- this.menu_settings.items.push(["---"]);
- this.menu_settings.items.push([[h("span.emoji", "\uD83D\uDD07 "), "Manage muted users"], this.handleManageMutesClick]);
- this.menu_settings.items.push(["Show data directory", this.handleBackupClick]);
- this.menu_settings.items.push(["Version " + Page.server_info.version + " (rev" + Page.server_info.rev + "): " + (this.formatUpdateInfo()), this.handleUpdateZeronetClick]);
- this.menu_settings.items.push(["Shut down ZeroNet", this.handleShutdownZeronetClick]);
- if (this.menu_settings.visible) {
- this.menu_settings.hide();
- } else {
- this.menu_settings.show();
- }
- return false;
- };
- Head.prototype.handleUpdateAllClick = function() {
- var i, len, ref, results, site;
- ref = Page.site_list.sites;
- results = [];
- for (i = 0, len = ref.length; i < len; i++) {
- site = ref[i];
- if (site.row.settings.serving) {
- results.push(Page.cmd("siteUpdate", {
- "address": site.row.address
- }));
- } else {
- results.push(void 0);
- }
- }
- return results;
- };
- Head.prototype.handleOrderbyClick = function(orderby) {
- Page.settings.sites_orderby = orderby;
- Page.site_list.reorder();
- return Page.saveSettings();
- };
- Head.prototype.handleTorClick = function() {
- return true;
- };
- Head.prototype.handleManageMutesClick = function() {
- if (Page.server_info.rev < 1880) {
- return Page.cmd("wrapperNotification", ["info", "You need ZeroNet 0.5.2 to use this feature."]);
- }
- Page.projector.replace($("#MuteList"), Page.mute_list.render);
- return Page.mute_list.show();
- };
- Head.prototype.handleUpdateZeronetClick = function() {
- Page.cmd("wrapperConfirm", ["Update to latest development version?", "Update ZeroNet " + Page.latest_version], (function(_this) {
- return function() {
- Page.cmd("wrapperNotification", ["info", "Updating to latest version...<br>Please restart ZeroNet manually if it does not come back in the next few minutes.", 8000]);
- Page.cmd("serverUpdate");
- return _this.log("Updating...");
- };
- })(this));
- return false;
- };
- Head.prototype.handleShutdownZeronetClick = function() {
- return Page.cmd("wrapperConfirm", ["Are you sure?", "Shut down ZeroNet"], (function(_this) {
- return function() {
- return Page.cmd("serverShutdown");
- };
- })(this));
- };
- Head.prototype.handleModeClick = function(e) {
- if (Page.server_info.rev < 1700) {
- Page.cmd("wrapperNotification", ["info", "This feature requires ZeroNet version 0.5.0"]);
- } else {
- Page.handleLinkClick(e);
- }
- return false;
- };
- Head.prototype.render = function() {
- return h("div#Head", h("a.settings", {
- href: "#Settings",
- onmousedown: this.handleSettingsClick,
- onclick: Page.returnFalse
- }, ["\u22EE"]), this.menu_settings.render(), h("a.logo", {
- href: "?Home"
- }, [
- h("img", {
- src: 'img/logo.svg',
- width: 40,
- height: 40,
- onerror: "this.src='img/logo.png'; this.onerror=null;"
- }), h("span", ["Hello ZeroNet_"])
- ]), h("div.modes", [
- h("a.mode.sites", {
- href: "?",
- classes: {
- active: Page.mode === "Sites"
- },
- onclick: Page.handleLinkClick
- }, _("Sites")), h("a.mode.files", {
- href: "?Files",
- classes: {
- active: Page.mode === "Files"
- },
- onclick: Page.handleLinkClick
- }, _("Files")), h("a.mode.stats", {
- href: "?Stats",
- classes: {
- active: Page.mode === "Stats"
- },
- onclick: Page.handleLinkClick
- }, _("Stats"))
- ]));
- };
- return Head;
- })(Class);
- window.Head = Head;
- }).call(this);
- /* ---- /1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/js/ZeroHello.coffee ---- */
- (function() {
- var ZeroHello,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
- hasProp = {}.hasOwnProperty;
- window.h = maquette.h;
- ZeroHello = (function(superClass) {
- extend(ZeroHello, superClass);
- function ZeroHello() {
- this.reloadServerInfo = bind(this.reloadServerInfo, this);
- this.reloadSiteInfo = bind(this.reloadSiteInfo, this);
- this.onOpenWebsocket = bind(this.onOpenWebsocket, this);
- this.handleLinkClick = bind(this.handleLinkClick, this);
- return ZeroHello.__super__.constructor.apply(this, arguments);
- }
- ZeroHello.prototype.init = function() {
- this.params = {};
- this.site_info = null;
- this.server_info = null;
- this.address = null;
- this.on_site_info = new Promise();
- this.on_settings = new Promise();
- this.on_loaded = new Promise();
- this.settings = null;
- this.latest_version = "0.6.2";
- this.latest_rev = 3351;
- this.mode = "Sites";
- this.change_timer = null;
- return document.body.id = "Body" + this.mode;
- };
- ZeroHello.prototype.addRenderer = function(node, renderer) {
- this.projector.replace(node, renderer);
- return this.renderers.push(renderer);
- };
- ZeroHello.prototype.detachRenderers = function() {
- var i, len, ref, renderer;
- ref = this.renderers;
- for (i = 0, len = ref.length; i < len; i++) {
- renderer = ref[i];
- this.projector.detach(renderer);
- }
- return this.renderers = [];
- };
- ZeroHello.prototype.setProjectorMode = function(mode) {
- this.log("setProjectorMode", mode);
- if (this.mode === mode) {
- return;
- }
- this.detachRenderers();
- if (mode === "Files") {
- this.addRenderer($("#PageFiles"), this.page_files.render);
- this.page_files.need_update = true;
- } else if (mode === "Stats") {
- this.addRenderer($("#PageStats"), this.page_stats.render);
- this.page_stats.need_update = true;
- } else {
- mode = "Sites";
- this.addRenderer($("#FeedList"), this.feed_list.render);
- this.addRenderer($("#SiteList"), this.site_list.render);
- }
- this.mode = mode;
- return setTimeout((function() {
- document.body.id = "Body" + mode;
- if (this.change_timer) {
- clearInterval(this.change_timer);
- }
- document.body.classList.add("changing");
- return this.change_timer = setTimeout((function() {
- return document.body.classList.remove("changing");
- }), 400);
- }), 60);
- };
- ZeroHello.prototype.createProjector = function() {
- var url;
- this.projector = maquette.createProjector();
- this.projectors = {};
- this.renderers = [];
- this.site_list = new SiteList();
- this.feed_list = new FeedList();
- this.page_files = new PageFiles();
- this.page_stats = new PageStats();
- this.head = new Head();
- this.dashboard = new Dashboard();
- this.mute_list = new MuteList();
- this.trigger = new Trigger();
- if (base.href.indexOf("?") === -1) {
- this.route("");
- } else {
- url = base.href.replace(/.*?\?/, "");
- this.route(url);
- this.history_state["url"] = url;
- }
- this.loadSettings();
- this.on_site_info.then((function(_this) {
- return function() {
- _this.projector.replace($("#Head"), _this.head.render);
- _this.projector.replace($("#Dashboard"), _this.dashboard.render);
- _this.projector.merge($("#Trigger"), _this.trigger.render);
- return _this.setProjectorMode(_this.mode);
- };
- })(this));
- return setInterval((function() {
- return Page.projector.scheduleRender();
- }), 60 * 1000);
- };
- ZeroHello.prototype.route = function(query) {
- this.params = Text.parseQuery(query);
- this.log("Route", this.params);
- this.setProjectorMode(this.params.url);
- if (this.mode === "Stats") {
- this.page_stats.need_update = true;
- } else if (this.mode === "Files") {
- this.page_files.need_update = true;
- }
- return this.projector.scheduleRender();
- };
- ZeroHello.prototype.createUrl = function(key, val) {
- var params, vals;
- params = JSON.parse(JSON.stringify(this.params));
- if (typeof key === "Object") {
- vals = key;
- for (key in keys) {
- val = keys[key];
- params[key] = val;
- }
- } else {
- params[key] = val;
- }
- return "?" + Text.encodeQuery(params);
- };
- ZeroHello.prototype.setUrl = function(url, mode) {
- if (mode == null) {
- mode = "replace";
- }
- url = url.replace(/.*?\?/, "");
- this.log("setUrl", this.history_state["url"], "->", url);
- if (this.history_state["url"] === url) {
- return false;
- }
- this.history_state["url"] = url;
- if (mode === "replace") {
- this.cmd("wrapperReplaceState", [this.history_state, "", url]);
- } else {
- this.cmd("wrapperPushState", [this.history_state, "", url]);
- }
- this.route(url);
- return false;
- };
- ZeroHello.prototype.handleLinkClick = function(e) {
- if (e.which === 2) {
- return true;
- } else {
- this.log("save scrollTop", window.pageYOffset);
- this.history_state["scrollTop"] = window.pageYOffset;
- this.cmd("wrapperReplaceState", [this.history_state, null]);
- window.scroll(window.pageXOffset, 0);
- this.history_state["scrollTop"] = 0;
- this.setUrl(e.currentTarget.search);
- return false;
- }
- };
- ZeroHello.prototype.loadSettings = function() {
- return this.on_site_info.then((function(_this) {
- return function() {
- return _this.cmd("userGetSettings", [], function(res) {
- var base1, base2;
- if (!res || res.error) {
- return _this.loadLocalStorage();
- } else {
- _this.settings = res;
- if ((base1 = _this.settings).sites_orderby == null) {
- base1.sites_orderby = "peers";
- }
- if ((base2 = _this.settings).favorite_sites == null) {
- base2.favorite_sites = {};
- }
- return _this.on_settings.resolve(_this.settings);
- }
- });
- };
- })(this));
- };
- ZeroHello.prototype.loadLocalStorage = function() {
- return this.cmd("wrapperGetLocalStorage", [], (function(_this) {
- return function(settings) {
- var base1, base2;
- _this.settings = settings;
- _this.log("Loaded localstorage");
- if (_this.settings == null) {
- _this.settings = {};
- }
- if ((base1 = _this.settings).sites_orderby == null) {
- base1.sites_orderby = "peers";
- }
- if ((base2 = _this.settings).favorite_sites == null) {
- base2.favorite_sites = {};
- }
- return _this.on_settings.resolve(_this.settings);
- };
- })(this));
- };
- ZeroHello.prototype.saveSettings = function(cb) {
- if (this.settings) {
- if (Page.server_info.rev > 2140) {
- return this.cmd("userSetSettings", [this.settings], (function(_this) {
- return function(res) {
- if (cb) {
- return cb(res);
- }
- };
- })(this));
- } else {
- return this.cmd("wrapperSetLocalStorage", this.settings, (function(_this) {
- return function(res) {
- if (cb) {
- return cb(res);
- }
- };
- })(this));
- }
- }
- };
- ZeroHello.prototype.onOpenWebsocket = function(e) {
- this.reloadSiteInfo();
- return this.reloadServerInfo();
- };
- ZeroHello.prototype.reloadSiteInfo = function() {
- return this.cmd("siteInfo", {}, (function(_this) {
- return function(site_info) {
- _this.address = site_info.address;
- return _this.setSiteInfo(site_info);
- };
- })(this));
- };
- ZeroHello.prototype.reloadServerInfo = function() {
- return this.cmd("serverInfo", {}, (function(_this) {
- return function(server_info) {
- return _this.setServerInfo(server_info);
- };
- })(this));
- };
- ZeroHello.prototype.onRequest = function(cmd, params) {
- if (cmd === "setSiteInfo") {
- return this.setSiteInfo(params);
- } else if (cmd === "setServerInfo") {
- return this.setServerInfo(params);
- } else {
- return this.log("Unknown command", params);
- }
- };
- ZeroHello.prototype.setSiteInfo = function(site_info) {
- if (site_info.address === this.address) {
- this.site_info = site_info;
- }
- this.site_list.onSiteInfo(site_info);
- this.feed_list.onSiteInfo(site_info);
- this.page_files.onSiteInfo(site_info);
- return this.on_site_info.resolve();
- };
- ZeroHello.prototype.setServerInfo = function(server_info) {
- this.server_info = server_info;
- return this.projector.scheduleRender();
- };
- ZeroHello.prototype.returnFalse = function() {
- return false;
- };
- return ZeroHello;
- })(ZeroFrame);
- window.Page = new ZeroHello();
- window.Page.createProjector();
- }).call(this);
|