您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

UI.bundle.js 246KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569
  1. !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.UI=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. var UI = {};
  3. var VideoLayout = require("./videolayout/VideoLayout.js");
  4. var AudioLevels = require("./audio_levels/AudioLevels.js");
  5. var Prezi = require("./prezi/Prezi.js");
  6. var Etherpad = require("./etherpad/Etherpad.js");
  7. var Chat = require("./side_pannels/chat/Chat.js");
  8. var Toolbar = require("./toolbars/Toolbar");
  9. var ToolbarToggler = require("./toolbars/ToolbarToggler");
  10. var BottomToolbar = require("./toolbars/BottomToolbar");
  11. var ContactList = require("./side_pannels/contactlist/ContactList");
  12. var Avatar = require("./avatar/Avatar");
  13. var EventEmitter = require("events");
  14. var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
  15. var Settings = require("./side_pannels/settings/Settings");
  16. var PanelToggler = require("./side_pannels/SidePanelToggler");
  17. var RoomNameGenerator = require("./welcome_page/RoomnameGenerator");
  18. UI.messageHandler = require("./util/MessageHandler");
  19. var messageHandler = UI.messageHandler;
  20. var Authentication = require("./authentication/Authentication");
  21. var UIUtil = require("./util/UIUtil");
  22. var NicknameHandler = require("./util/NicknameHandler");
  23. var eventEmitter = new EventEmitter();
  24. var roomName = null;
  25. function setupPrezi()
  26. {
  27. $("#reloadPresentationLink").click(function()
  28. {
  29. Prezi.reloadPresentation();
  30. });
  31. }
  32. function setupChat()
  33. {
  34. Chat.init();
  35. $("#toggle_smileys").click(function() {
  36. Chat.toggleSmileys();
  37. });
  38. }
  39. function setupToolbars() {
  40. Toolbar.init(UI);
  41. Toolbar.setupButtonsFromConfig();
  42. BottomToolbar.init();
  43. }
  44. function streamHandler(stream) {
  45. switch (stream.type)
  46. {
  47. case "audio":
  48. VideoLayout.changeLocalAudio(stream);
  49. break;
  50. case "video":
  51. VideoLayout.changeLocalVideo(stream);
  52. break;
  53. case "stream":
  54. VideoLayout.changeLocalStream(stream);
  55. break;
  56. }
  57. }
  58. function onDisposeConference(unload) {
  59. Toolbar.showAuthenticateButton(false);
  60. };
  61. function onDisplayNameChanged(jid, displayName) {
  62. ContactList.onDisplayNameChange(jid, displayName);
  63. SettingsMenu.onDisplayNameChange(jid, displayName);
  64. VideoLayout.onDisplayNameChanged(jid, displayName);
  65. }
  66. function registerListeners() {
  67. RTC.addStreamListener(streamHandler, StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);
  68. RTC.addStreamListener(streamHandler, StreamEventTypes.EVENT_TYPE_LOCAL_CHANGED);
  69. RTC.addStreamListener(function (stream) {
  70. VideoLayout.onRemoteStreamAdded(stream);
  71. }, StreamEventTypes.EVENT_TYPE_REMOTE_CREATED);
  72. RTC.addListener(RTCEvents.LASTN_CHANGED, onLastNChanged);
  73. RTC.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (resourceJid) {
  74. VideoLayout.onDominantSpeakerChanged(resourceJid);
  75. });
  76. RTC.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
  77. function (lastNEndpoints, endpointsEnteringLastN, stream) {
  78. VideoLayout.onLastNEndpointsChanged(lastNEndpoints,
  79. endpointsEnteringLastN, stream);
  80. });
  81. RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGED,
  82. function (endpointSimulcastLayers) {
  83. VideoLayout.onSimulcastLayersChanged(endpointSimulcastLayers);
  84. });
  85. RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGING,
  86. function (endpointSimulcastLayers) {
  87. VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
  88. });
  89. VideoLayout.init(eventEmitter);
  90. statistics.addAudioLevelListener(function(jid, audioLevel)
  91. {
  92. var resourceJid;
  93. if(jid === statistics.LOCAL_JID)
  94. {
  95. resourceJid = AudioLevels.LOCAL_LEVEL;
  96. if(RTC.localAudio.isMuted())
  97. {
  98. audioLevel = 0;
  99. }
  100. }
  101. else
  102. {
  103. resourceJid = Strophe.getResourceFromJid(jid);
  104. }
  105. AudioLevels.updateAudioLevel(resourceJid, audioLevel,
  106. UI.getLargeVideoState().userResourceJid);
  107. });
  108. desktopsharing.addListener(function () {
  109. ToolbarToggler.showDesktopSharingButton();
  110. }, DesktopSharingEventTypes.INIT);
  111. desktopsharing.addListener(
  112. Toolbar.changeDesktopSharingButtonState,
  113. DesktopSharingEventTypes.SWITCHING_DONE);
  114. xmpp.addListener(XMPPEvents.DISPOSE_CONFERENCE, onDisposeConference);
  115. xmpp.addListener(XMPPEvents.KICKED, function () {
  116. messageHandler.openMessageDialog("Session Terminated",
  117. "Ouch! You have been kicked out of the meet!");
  118. });
  119. xmpp.addListener(XMPPEvents.BRIDGE_DOWN, function () {
  120. messageHandler.showError("Error",
  121. "Jitsi Videobridge is currently unavailable. Please try again later!");
  122. });
  123. xmpp.addListener(XMPPEvents.USER_ID_CHANGED, Avatar.setUserAvatar);
  124. xmpp.addListener(XMPPEvents.CHANGED_STREAMS, function (jid, changedStreams) {
  125. for(stream in changedStreams)
  126. {
  127. // might need to update the direction if participant just went from sendrecv to recvonly
  128. if (stream.type === 'video' || stream.type === 'screen') {
  129. var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video');
  130. switch (stream.direction) {
  131. case 'sendrecv':
  132. el.show();
  133. break;
  134. case 'recvonly':
  135. el.hide();
  136. // FIXME: Check if we have to change large video
  137. //VideoLayout.updateLargeVideo(el);
  138. break;
  139. }
  140. }
  141. }
  142. });
  143. xmpp.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, onDisplayNameChanged);
  144. xmpp.addListener(XMPPEvents.MUC_JOINED, onMucJoined);
  145. xmpp.addListener(XMPPEvents.LOCALROLE_CHANGED, onLocalRoleChange);
  146. xmpp.addListener(XMPPEvents.MUC_ENTER, onMucEntered);
  147. xmpp.addListener(XMPPEvents.MUC_ROLE_CHANGED, onMucRoleChanged);
  148. xmpp.addListener(XMPPEvents.PRESENCE_STATUS, onMucPresenceStatus);
  149. xmpp.addListener(XMPPEvents.SUBJECT_CHANGED, chatSetSubject);
  150. xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, updateChatConversation);
  151. xmpp.addListener(XMPPEvents.MUC_LEFT, onMucLeft);
  152. xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, onPasswordReqiured);
  153. xmpp.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, chatAddError);
  154. xmpp.addListener(XMPPEvents.ETHERPAD, initEtherpad);
  155. connectionquality.addListener(CQEvents.LOCALSTATS_UPDATED,
  156. VideoLayout.updateLocalConnectionStats);
  157. connectionquality.addListener(CQEvents.REMOTESTATS_UPDATED,
  158. VideoLayout.updateConnectionStats);
  159. connectionquality.addListener(CQEvents.STOP,
  160. VideoLayout.onStatsStop);
  161. xmpp.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, onAuthenticationRequired);
  162. }
  163. function bindEvents()
  164. {
  165. /**
  166. * Resizes and repositions videos in full screen mode.
  167. */
  168. $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
  169. function () {
  170. VideoLayout.resizeLargeVideoContainer();
  171. VideoLayout.positionLarge();
  172. }
  173. );
  174. $(window).resize(function () {
  175. VideoLayout.resizeLargeVideoContainer();
  176. VideoLayout.positionLarge();
  177. });
  178. }
  179. UI.start = function () {
  180. document.title = interfaceConfig.APP_NAME;
  181. if(config.enableWelcomePage && window.location.pathname == "/" &&
  182. (!window.localStorage.welcomePageDisabled || window.localStorage.welcomePageDisabled == "false"))
  183. {
  184. $("#videoconference_page").hide();
  185. var setupWelcomePage = require("./welcome_page/WelcomePage");
  186. setupWelcomePage();
  187. return;
  188. }
  189. if (interfaceConfig.SHOW_JITSI_WATERMARK) {
  190. var leftWatermarkDiv
  191. = $("#largeVideoContainer div[class='watermark leftwatermark']");
  192. leftWatermarkDiv.css({display: 'block'});
  193. leftWatermarkDiv.parent().get(0).href
  194. = interfaceConfig.JITSI_WATERMARK_LINK;
  195. }
  196. if (interfaceConfig.SHOW_BRAND_WATERMARK) {
  197. var rightWatermarkDiv
  198. = $("#largeVideoContainer div[class='watermark rightwatermark']");
  199. rightWatermarkDiv.css({display: 'block'});
  200. rightWatermarkDiv.parent().get(0).href
  201. = interfaceConfig.BRAND_WATERMARK_LINK;
  202. rightWatermarkDiv.get(0).style.backgroundImage
  203. = "url(images/rightwatermark.png)";
  204. }
  205. if (interfaceConfig.SHOW_POWERED_BY) {
  206. $("#largeVideoContainer>a[class='poweredby']").css({display: 'block'});
  207. }
  208. $("#welcome_page").hide();
  209. VideoLayout.resizeLargeVideoContainer();
  210. $("#videospace").mousemove(function () {
  211. return ToolbarToggler.showToolbar();
  212. });
  213. // Set the defaults for prompt dialogs.
  214. jQuery.prompt.setDefaults({persistent: false});
  215. NicknameHandler.init(eventEmitter);
  216. registerListeners();
  217. bindEvents();
  218. setupPrezi();
  219. setupToolbars();
  220. setupChat();
  221. document.title = interfaceConfig.APP_NAME;
  222. $("#downloadlog").click(function (event) {
  223. dump(event.target);
  224. });
  225. if(config.enableWelcomePage && window.location.pathname == "/" &&
  226. (!window.localStorage.welcomePageDisabled || window.localStorage.welcomePageDisabled == "false"))
  227. {
  228. $("#videoconference_page").hide();
  229. var setupWelcomePage = require("./welcome_page/WelcomePage");
  230. setupWelcomePage();
  231. return;
  232. }
  233. $("#welcome_page").hide();
  234. document.getElementById('largeVideo').volume = 0;
  235. if (!$('#settings').is(':visible')) {
  236. console.log('init');
  237. init();
  238. } else {
  239. loginInfo.onsubmit = function (e) {
  240. if (e.preventDefault) e.preventDefault();
  241. $('#settings').hide();
  242. init();
  243. };
  244. }
  245. toastr.options = {
  246. "closeButton": true,
  247. "debug": false,
  248. "positionClass": "notification-bottom-right",
  249. "onclick": null,
  250. "showDuration": "300",
  251. "hideDuration": "1000",
  252. "timeOut": "2000",
  253. "extendedTimeOut": "1000",
  254. "showEasing": "swing",
  255. "hideEasing": "linear",
  256. "showMethod": "fadeIn",
  257. "hideMethod": "fadeOut",
  258. "reposition": function() {
  259. if(PanelToggler.isVisible()) {
  260. $("#toast-container").addClass("notification-bottom-right-center");
  261. } else {
  262. $("#toast-container").removeClass("notification-bottom-right-center");
  263. }
  264. },
  265. "newestOnTop": false
  266. };
  267. $('#settingsmenu>input').keyup(function(event){
  268. if(event.keyCode === 13) {//enter
  269. SettingsMenu.update();
  270. }
  271. });
  272. $("#updateSettings").click(function () {
  273. SettingsMenu.update();
  274. });
  275. };
  276. UI.toggleSmileys = function () {
  277. Chat.toggleSmileys();
  278. };
  279. function chatAddError(errorMessage, originalText)
  280. {
  281. return Chat.chatAddError(errorMessage, originalText);
  282. };
  283. function chatSetSubject(text)
  284. {
  285. return Chat.chatSetSubject(text);
  286. };
  287. function updateChatConversation(from, displayName, message) {
  288. return Chat.updateChatConversation(from, displayName, message);
  289. };
  290. function onMucJoined(jid, info) {
  291. Toolbar.updateRoomUrl(window.location.href);
  292. document.getElementById('localNick').appendChild(
  293. document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
  294. );
  295. var settings = Settings.getSettings();
  296. // Add myself to the contact list.
  297. ContactList.addContact(jid, settings.email || settings.uid);
  298. // Once we've joined the muc show the toolbar
  299. ToolbarToggler.showToolbar();
  300. // Show authenticate button if needed
  301. Toolbar.showAuthenticateButton(
  302. xmpp.isExternalAuthEnabled() && !xmpp.isModerator());
  303. var displayName = !config.displayJids
  304. ? info.displayName : Strophe.getResourceFromJid(jid);
  305. if (displayName)
  306. onDisplayNameChanged('localVideoContainer', displayName + ' (me)');
  307. }
  308. function initEtherpad(name) {
  309. Etherpad.init(name);
  310. };
  311. function onMucLeft(jid) {
  312. console.log('left.muc', jid);
  313. var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
  314. '>.displayname').html();
  315. messageHandler.notify(displayName || 'Somebody',
  316. 'disconnected',
  317. 'disconnected');
  318. // Need to call this with a slight delay, otherwise the element couldn't be
  319. // found for some reason.
  320. // XXX(gp) it works fine without the timeout for me (with Chrome 38).
  321. window.setTimeout(function () {
  322. var container = document.getElementById(
  323. 'participant_' + Strophe.getResourceFromJid(jid));
  324. if (container) {
  325. ContactList.removeContact(jid);
  326. VideoLayout.removeConnectionIndicator(jid);
  327. // hide here, wait for video to close before removing
  328. $(container).hide();
  329. VideoLayout.resizeThumbnails();
  330. }
  331. }, 10);
  332. VideoLayout.participantLeft(jid);
  333. };
  334. function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
  335. {
  336. console.info("My role changed, new role: " + info.role);
  337. onModeratorStatusChanged(isModerator);
  338. VideoLayout.showModeratorIndicator();
  339. Toolbar.showAuthenticateButton(
  340. isExternalAuthEnabled && !isModerator);
  341. if (isModerator) {
  342. Authentication.closeAuthenticationWindow();
  343. messageHandler.notify(
  344. 'Me', 'connected', 'Moderator rights granted !');
  345. }
  346. }
  347. function onModeratorStatusChanged(isModerator) {
  348. Toolbar.showSipCallButton(isModerator);
  349. Toolbar.showRecordingButton(
  350. isModerator); //&&
  351. // FIXME:
  352. // Recording visible if
  353. // there are at least 2(+ 1 focus) participants
  354. //Object.keys(connection.emuc.members).length >= 3);
  355. if (isModerator && config.etherpad_base) {
  356. Etherpad.init();
  357. }
  358. };
  359. function onPasswordReqiured(callback) {
  360. // password is required
  361. Toolbar.lockLockButton();
  362. messageHandler.openTwoButtonDialog(null,
  363. '<h2>Password required</h2>' +
  364. '<input id="lockKey" type="text" placeholder="password" autofocus>',
  365. true,
  366. "Ok",
  367. function (e, v, m, f) {},
  368. function (event) {
  369. document.getElementById('lockKey').focus();
  370. },
  371. function (e, v, m, f) {
  372. if (v) {
  373. var lockKey = document.getElementById('lockKey');
  374. if (lockKey.value !== null) {
  375. Toolbar.setSharedKey(lockKey.value);
  376. callback(lockKey.value);
  377. }
  378. }
  379. }
  380. );
  381. }
  382. function onMucEntered(jid, id, displayName) {
  383. messageHandler.notify(displayName || 'Somebody',
  384. 'connected',
  385. 'connected');
  386. // Add Peer's container
  387. VideoLayout.ensurePeerContainerExists(jid,id);
  388. }
  389. function onMucPresenceStatus( jid, info) {
  390. VideoLayout.setPresenceStatus(
  391. 'participant_' + Strophe.getResourceFromJid(jid), info.status);
  392. }
  393. function onMucRoleChanged(role, displayName) {
  394. VideoLayout.showModeratorIndicator();
  395. if (role === 'moderator') {
  396. var displayName = displayName;
  397. if (!displayName) {
  398. displayName = 'Somebody';
  399. }
  400. messageHandler.notify(
  401. displayName,
  402. 'connected',
  403. 'Moderator rights granted to ' + displayName + '!');
  404. }
  405. }
  406. function onAuthenticationRequired(intervalCallback) {
  407. Authentication.openAuthenticationDialog(
  408. roomName, intervalCallback, function () {
  409. Toolbar.authenticateClicked();
  410. });
  411. };
  412. function onLastNChanged(oldValue, newValue) {
  413. if (config.muteLocalVideoIfNotInLastN) {
  414. setVideoMute(!newValue, { 'byUser': false });
  415. }
  416. }
  417. UI.getSettings = function () {
  418. return Settings.getSettings();
  419. };
  420. UI.toggleFilmStrip = function () {
  421. return BottomToolbar.toggleFilmStrip();
  422. };
  423. UI.toggleChat = function () {
  424. return BottomToolbar.toggleChat();
  425. };
  426. UI.toggleContactList = function () {
  427. return BottomToolbar.toggleContactList();
  428. };
  429. UI.setRecordingButtonState = function (state) {
  430. Toolbar.setRecordingButtonState(state);
  431. };
  432. UI.inputDisplayNameHandler = function (value) {
  433. VideoLayout.inputDisplayNameHandler(value);
  434. };
  435. UI.getLargeVideoState = function()
  436. {
  437. return VideoLayout.getLargeVideoState();
  438. };
  439. UI.showLocalAudioIndicator = function (mute) {
  440. VideoLayout.showLocalAudioIndicator(mute);
  441. };
  442. UI.generateRoomName = function() {
  443. if(roomName)
  444. return roomName;
  445. var roomnode = null;
  446. var path = window.location.pathname;
  447. // determinde the room node from the url
  448. // TODO: just the roomnode or the whole bare jid?
  449. if (config.getroomnode && typeof config.getroomnode === 'function') {
  450. // custom function might be responsible for doing the pushstate
  451. roomnode = config.getroomnode(path);
  452. } else {
  453. /* fall back to default strategy
  454. * this is making assumptions about how the URL->room mapping happens.
  455. * It currently assumes deployment at root, with a rewrite like the
  456. * following one (for nginx):
  457. location ~ ^/([a-zA-Z0-9]+)$ {
  458. rewrite ^/(.*)$ / break;
  459. }
  460. */
  461. if (path.length > 1) {
  462. roomnode = path.substr(1).toLowerCase();
  463. } else {
  464. var word = RoomNameGenerator.generateRoomWithoutSeparator();
  465. roomnode = word.toLowerCase();
  466. window.history.pushState('VideoChat',
  467. 'Room: ' + word, window.location.pathname + word);
  468. }
  469. }
  470. roomName = roomnode + '@' + config.hosts.muc;
  471. return roomName;
  472. };
  473. UI.connectionIndicatorShowMore = function(id)
  474. {
  475. return VideoLayout.connectionIndicators[id].showMore();
  476. };
  477. UI.showToolbar = function () {
  478. return ToolbarToggler.showToolbar();
  479. };
  480. UI.dockToolbar = function (isDock) {
  481. return ToolbarToggler.dockToolbar(isDock);
  482. };
  483. UI.getCreadentials = function () {
  484. return {
  485. bosh: document.getElementById('boshURL').value,
  486. password: document.getElementById('password').value,
  487. jid: document.getElementById('jid').value
  488. };
  489. };
  490. UI.disableConnect = function () {
  491. document.getElementById('connect').disabled = true;
  492. };
  493. UI.showLoginPopup = function(callback)
  494. {
  495. console.log('password is required');
  496. UI.messageHandler.openTwoButtonDialog(null,
  497. '<h2>Password required</h2>' +
  498. '<input id="passwordrequired.username" type="text" placeholder="user@domain.net" autofocus>' +
  499. '<input id="passwordrequired.password" type="password" placeholder="user password">',
  500. true,
  501. "Ok",
  502. function (e, v, m, f) {
  503. if (v) {
  504. var username = document.getElementById('passwordrequired.username');
  505. var password = document.getElementById('passwordrequired.password');
  506. if (username.value !== null && password.value != null) {
  507. callback(username.value, password.value);
  508. }
  509. }
  510. },
  511. function (event) {
  512. document.getElementById('passwordrequired.username').focus();
  513. }
  514. );
  515. }
  516. UI.checkForNicknameAndJoin = function () {
  517. Authentication.closeAuthenticationDialog();
  518. Authentication.stopInterval();
  519. var nick = null;
  520. if (config.useNicks) {
  521. nick = window.prompt('Your nickname (optional)');
  522. }
  523. xmpp.joinRoom(roomName, config.useNicks, nick);
  524. }
  525. function dump(elem, filename) {
  526. elem = elem.parentNode;
  527. elem.download = filename || 'meetlog.json';
  528. elem.href = 'data:application/json;charset=utf-8,\n';
  529. var data = xmpp.populateData();
  530. var metadata = {};
  531. metadata.time = new Date();
  532. metadata.url = window.location.href;
  533. metadata.ua = navigator.userAgent;
  534. var log = xmpp.getLogger();
  535. if (log) {
  536. metadata.xmpp = log;
  537. }
  538. data.metadata = metadata;
  539. elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
  540. return false;
  541. }
  542. UI.getRoomName = function () {
  543. return roomName;
  544. }
  545. /**
  546. * Mutes/unmutes the local video.
  547. *
  548. * @param mute <tt>true</tt> to mute the local video; otherwise, <tt>false</tt>
  549. * @param options an object which specifies optional arguments such as the
  550. * <tt>boolean</tt> key <tt>byUser</tt> with default value <tt>true</tt> which
  551. * specifies whether the method was initiated in response to a user command (in
  552. * contrast to an automatic decision taken by the application logic)
  553. */
  554. function setVideoMute(mute, options) {
  555. xmpp.setVideoMute(
  556. mute,
  557. function (mute) {
  558. var video = $('#video');
  559. var communicativeClass = "icon-camera";
  560. var muteClass = "icon-camera icon-camera-disabled";
  561. if (mute) {
  562. video.removeClass(communicativeClass);
  563. video.addClass(muteClass);
  564. } else {
  565. video.removeClass(muteClass);
  566. video.addClass(communicativeClass);
  567. }
  568. },
  569. options);
  570. }
  571. /**
  572. * Mutes/unmutes the local video.
  573. */
  574. UI.toggleVideo = function () {
  575. UIUtil.buttonClick("#video", "icon-camera icon-camera-disabled");
  576. setVideoMute(!RTC.localVideo.isMuted());
  577. };
  578. /**
  579. * Mutes / unmutes audio for the local participant.
  580. */
  581. UI.toggleAudio = function() {
  582. UI.setAudioMuted(!RTC.localAudio.isMuted());
  583. };
  584. /**
  585. * Sets muted audio state for the local participant.
  586. */
  587. UI.setAudioMuted = function (mute) {
  588. if(!xmpp.setAudioMute(mute, function () {
  589. UI.showLocalAudioIndicator(mute);
  590. UIUtil.buttonClick("#mute", "icon-microphone icon-mic-disabled");
  591. }))
  592. {
  593. // We still click the button.
  594. UIUtil.buttonClick("#mute", "icon-microphone icon-mic-disabled");
  595. return;
  596. }
  597. }
  598. UI.addListener = function (type, listener) {
  599. eventEmitter.on(type, listener);
  600. }
  601. UI.clickOnVideo = function (videoNumber) {
  602. var remoteVideos = $(".videocontainer:not(#mixedstream)");
  603. if (remoteVideos.length > videoNumber) {
  604. remoteVideos[videoNumber].click();
  605. }
  606. }
  607. module.exports = UI;
  608. },{"./audio_levels/AudioLevels.js":2,"./authentication/Authentication":4,"./avatar/Avatar":5,"./etherpad/Etherpad.js":6,"./prezi/Prezi.js":7,"./side_pannels/SidePanelToggler":9,"./side_pannels/chat/Chat.js":10,"./side_pannels/contactlist/ContactList":14,"./side_pannels/settings/Settings":15,"./side_pannels/settings/SettingsMenu":16,"./toolbars/BottomToolbar":17,"./toolbars/Toolbar":18,"./toolbars/ToolbarToggler":19,"./util/MessageHandler":21,"./util/NicknameHandler":22,"./util/UIUtil":23,"./videolayout/VideoLayout.js":25,"./welcome_page/RoomnameGenerator":26,"./welcome_page/WelcomePage":27,"events":28}],2:[function(require,module,exports){
  609. var CanvasUtil = require("./CanvasUtils");
  610. /**
  611. * The audio Levels plugin.
  612. */
  613. var AudioLevels = (function(my) {
  614. var audioLevelCanvasCache = {};
  615. my.LOCAL_LEVEL = 'local';
  616. /**
  617. * Updates the audio level canvas for the given peerJid. If the canvas
  618. * didn't exist we create it.
  619. */
  620. my.updateAudioLevelCanvas = function (peerJid, VideoLayout) {
  621. var resourceJid = null;
  622. var videoSpanId = null;
  623. if (!peerJid)
  624. videoSpanId = 'localVideoContainer';
  625. else {
  626. resourceJid = Strophe.getResourceFromJid(peerJid);
  627. videoSpanId = 'participant_' + resourceJid;
  628. }
  629. var videoSpan = document.getElementById(videoSpanId);
  630. if (!videoSpan) {
  631. if (resourceJid)
  632. console.error("No video element for jid", resourceJid);
  633. else
  634. console.error("No video element for local video.");
  635. return;
  636. }
  637. var audioLevelCanvas = $('#' + videoSpanId + '>canvas');
  638. var videoSpaceWidth = $('#remoteVideos').width();
  639. var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);
  640. var thumbnailWidth = thumbnailSize[0];
  641. var thumbnailHeight = thumbnailSize[1];
  642. if (!audioLevelCanvas || audioLevelCanvas.length === 0) {
  643. audioLevelCanvas = document.createElement('canvas');
  644. audioLevelCanvas.className = "audiolevel";
  645. audioLevelCanvas.style.bottom = "-" + interfaceConfig.CANVAS_EXTRA/2 + "px";
  646. audioLevelCanvas.style.left = "-" + interfaceConfig.CANVAS_EXTRA/2 + "px";
  647. resizeAudioLevelCanvas( audioLevelCanvas,
  648. thumbnailWidth,
  649. thumbnailHeight);
  650. videoSpan.appendChild(audioLevelCanvas);
  651. } else {
  652. audioLevelCanvas = audioLevelCanvas.get(0);
  653. resizeAudioLevelCanvas( audioLevelCanvas,
  654. thumbnailWidth,
  655. thumbnailHeight);
  656. }
  657. };
  658. /**
  659. * Updates the audio level UI for the given resourceJid.
  660. *
  661. * @param resourceJid the resource jid indicating the video element for
  662. * which we draw the audio level
  663. * @param audioLevel the newAudio level to render
  664. */
  665. my.updateAudioLevel = function (resourceJid, audioLevel, largeVideoResourceJid) {
  666. drawAudioLevelCanvas(resourceJid, audioLevel);
  667. var videoSpanId = getVideoSpanId(resourceJid);
  668. var audioLevelCanvas = $('#' + videoSpanId + '>canvas').get(0);
  669. if (!audioLevelCanvas)
  670. return;
  671. var drawContext = audioLevelCanvas.getContext('2d');
  672. var canvasCache = audioLevelCanvasCache[resourceJid];
  673. drawContext.clearRect (0, 0,
  674. audioLevelCanvas.width, audioLevelCanvas.height);
  675. drawContext.drawImage(canvasCache, 0, 0);
  676. if(resourceJid === AudioLevels.LOCAL_LEVEL) {
  677. if(!xmpp.myJid()) {
  678. return;
  679. }
  680. resourceJid = xmpp.myResource();
  681. }
  682. if(resourceJid === largeVideoResourceJid) {
  683. AudioLevels.updateActiveSpeakerAudioLevel(audioLevel);
  684. }
  685. };
  686. my.updateActiveSpeakerAudioLevel = function(audioLevel) {
  687. var drawContext = $('#activeSpeakerAudioLevel')[0].getContext('2d');
  688. var r = interfaceConfig.ACTIVE_SPEAKER_AVATAR_SIZE / 2;
  689. var center = (interfaceConfig.ACTIVE_SPEAKER_AVATAR_SIZE + r) / 2;
  690. // Save the previous state of the context.
  691. drawContext.save();
  692. drawContext.clearRect(0, 0, 300, 300);
  693. // Draw a circle.
  694. drawContext.arc(center, center, r, 0, 2 * Math.PI);
  695. // Add a shadow around the circle
  696. drawContext.shadowColor = interfaceConfig.SHADOW_COLOR;
  697. drawContext.shadowBlur = getShadowLevel(audioLevel);
  698. drawContext.shadowOffsetX = 0;
  699. drawContext.shadowOffsetY = 0;
  700. // Fill the shape.
  701. drawContext.fill();
  702. drawContext.save();
  703. drawContext.restore();
  704. drawContext.arc(center, center, r, 0, 2 * Math.PI);
  705. drawContext.clip();
  706. drawContext.clearRect(0, 0, 277, 200);
  707. // Restore the previous context state.
  708. drawContext.restore();
  709. };
  710. /**
  711. * Resizes the given audio level canvas to match the given thumbnail size.
  712. */
  713. function resizeAudioLevelCanvas(audioLevelCanvas,
  714. thumbnailWidth,
  715. thumbnailHeight) {
  716. audioLevelCanvas.width = thumbnailWidth + interfaceConfig.CANVAS_EXTRA;
  717. audioLevelCanvas.height = thumbnailHeight + interfaceConfig.CANVAS_EXTRA;
  718. }
  719. /**
  720. * Draws the audio level canvas into the cached canvas object.
  721. *
  722. * @param resourceJid the resource jid indicating the video element for
  723. * which we draw the audio level
  724. * @param audioLevel the newAudio level to render
  725. */
  726. function drawAudioLevelCanvas(resourceJid, audioLevel) {
  727. if (!audioLevelCanvasCache[resourceJid]) {
  728. var videoSpanId = getVideoSpanId(resourceJid);
  729. var audioLevelCanvasOrig = $('#' + videoSpanId + '>canvas').get(0);
  730. /*
  731. * FIXME Testing has shown that audioLevelCanvasOrig may not exist.
  732. * In such a case, the method CanvasUtil.cloneCanvas may throw an
  733. * error. Since audio levels are frequently updated, the errors have
  734. * been observed to pile into the console, strain the CPU.
  735. */
  736. if (audioLevelCanvasOrig)
  737. {
  738. audioLevelCanvasCache[resourceJid]
  739. = CanvasUtil.cloneCanvas(audioLevelCanvasOrig);
  740. }
  741. }
  742. var canvas = audioLevelCanvasCache[resourceJid];
  743. if (!canvas)
  744. return;
  745. var drawContext = canvas.getContext('2d');
  746. drawContext.clearRect(0, 0, canvas.width, canvas.height);
  747. var shadowLevel = getShadowLevel(audioLevel);
  748. if (shadowLevel > 0)
  749. // drawContext, x, y, w, h, r, shadowColor, shadowLevel
  750. CanvasUtil.drawRoundRectGlow( drawContext,
  751. interfaceConfig.CANVAS_EXTRA/2, interfaceConfig.CANVAS_EXTRA/2,
  752. canvas.width - interfaceConfig.CANVAS_EXTRA,
  753. canvas.height - interfaceConfig.CANVAS_EXTRA,
  754. interfaceConfig.CANVAS_RADIUS,
  755. interfaceConfig.SHADOW_COLOR,
  756. shadowLevel);
  757. }
  758. /**
  759. * Returns the shadow/glow level for the given audio level.
  760. *
  761. * @param audioLevel the audio level from which we determine the shadow
  762. * level
  763. */
  764. function getShadowLevel (audioLevel) {
  765. var shadowLevel = 0;
  766. if (audioLevel <= 0.3) {
  767. shadowLevel = Math.round(interfaceConfig.CANVAS_EXTRA/2*(audioLevel/0.3));
  768. }
  769. else if (audioLevel <= 0.6) {
  770. shadowLevel = Math.round(interfaceConfig.CANVAS_EXTRA/2*((audioLevel - 0.3) / 0.3));
  771. }
  772. else {
  773. shadowLevel = Math.round(interfaceConfig.CANVAS_EXTRA/2*((audioLevel - 0.6) / 0.4));
  774. }
  775. return shadowLevel;
  776. }
  777. /**
  778. * Returns the video span id corresponding to the given resourceJid or local
  779. * user.
  780. */
  781. function getVideoSpanId(resourceJid) {
  782. var videoSpanId = null;
  783. if (resourceJid === AudioLevels.LOCAL_LEVEL
  784. || (xmpp.myResource() && resourceJid
  785. === xmpp.myResource()))
  786. videoSpanId = 'localVideoContainer';
  787. else
  788. videoSpanId = 'participant_' + resourceJid;
  789. return videoSpanId;
  790. }
  791. /**
  792. * Indicates that the remote video has been resized.
  793. */
  794. $(document).bind('remotevideo.resized', function (event, width, height) {
  795. var resized = false;
  796. $('#remoteVideos>span>canvas').each(function() {
  797. var canvas = $(this).get(0);
  798. if (canvas.width !== width + interfaceConfig.CANVAS_EXTRA) {
  799. canvas.width = width + interfaceConfig.CANVAS_EXTRA;
  800. resized = true;
  801. }
  802. if (canvas.heigh !== height + interfaceConfig.CANVAS_EXTRA) {
  803. canvas.height = height + interfaceConfig.CANVAS_EXTRA;
  804. resized = true;
  805. }
  806. });
  807. if (resized)
  808. Object.keys(audioLevelCanvasCache).forEach(function (resourceJid) {
  809. audioLevelCanvasCache[resourceJid].width
  810. = width + interfaceConfig.CANVAS_EXTRA;
  811. audioLevelCanvasCache[resourceJid].height
  812. = height + interfaceConfig.CANVAS_EXTRA;
  813. });
  814. });
  815. return my;
  816. })(AudioLevels || {});
  817. module.exports = AudioLevels;
  818. },{"./CanvasUtils":3}],3:[function(require,module,exports){
  819. /**
  820. * Utility class for drawing canvas shapes.
  821. */
  822. var CanvasUtil = (function(my) {
  823. /**
  824. * Draws a round rectangle with a glow. The glowWidth indicates the depth
  825. * of the glow.
  826. *
  827. * @param drawContext the context of the canvas to draw to
  828. * @param x the x coordinate of the round rectangle
  829. * @param y the y coordinate of the round rectangle
  830. * @param w the width of the round rectangle
  831. * @param h the height of the round rectangle
  832. * @param glowColor the color of the glow
  833. * @param glowWidth the width of the glow
  834. */
  835. my.drawRoundRectGlow
  836. = function(drawContext, x, y, w, h, r, glowColor, glowWidth) {
  837. // Save the previous state of the context.
  838. drawContext.save();
  839. if (w < 2 * r) r = w / 2;
  840. if (h < 2 * r) r = h / 2;
  841. // Draw a round rectangle.
  842. drawContext.beginPath();
  843. drawContext.moveTo(x+r, y);
  844. drawContext.arcTo(x+w, y, x+w, y+h, r);
  845. drawContext.arcTo(x+w, y+h, x, y+h, r);
  846. drawContext.arcTo(x, y+h, x, y, r);
  847. drawContext.arcTo(x, y, x+w, y, r);
  848. drawContext.closePath();
  849. // Add a shadow around the rectangle
  850. drawContext.shadowColor = glowColor;
  851. drawContext.shadowBlur = glowWidth;
  852. drawContext.shadowOffsetX = 0;
  853. drawContext.shadowOffsetY = 0;
  854. // Fill the shape.
  855. drawContext.fill();
  856. drawContext.save();
  857. drawContext.restore();
  858. // 1) Uncomment this line to use Composite Operation, which is doing the
  859. // same as the clip function below and is also antialiasing the round
  860. // border, but is said to be less fast performance wise.
  861. // drawContext.globalCompositeOperation='destination-out';
  862. drawContext.beginPath();
  863. drawContext.moveTo(x+r, y);
  864. drawContext.arcTo(x+w, y, x+w, y+h, r);
  865. drawContext.arcTo(x+w, y+h, x, y+h, r);
  866. drawContext.arcTo(x, y+h, x, y, r);
  867. drawContext.arcTo(x, y, x+w, y, r);
  868. drawContext.closePath();
  869. // 2) Uncomment this line to use Composite Operation, which is doing the
  870. // same as the clip function below and is also antialiasing the round
  871. // border, but is said to be less fast performance wise.
  872. // drawContext.fill();
  873. // Comment these two lines if choosing to do the same with composite
  874. // operation above 1 and 2.
  875. drawContext.clip();
  876. drawContext.clearRect(0, 0, 277, 200);
  877. // Restore the previous context state.
  878. drawContext.restore();
  879. };
  880. /**
  881. * Clones the given canvas.
  882. *
  883. * @return the new cloned canvas.
  884. */
  885. my.cloneCanvas = function (oldCanvas) {
  886. /*
  887. * FIXME Testing has shown that oldCanvas may not exist. In such a case,
  888. * the method CanvasUtil.cloneCanvas may throw an error. Since audio
  889. * levels are frequently updated, the errors have been observed to pile
  890. * into the console, strain the CPU.
  891. */
  892. if (!oldCanvas)
  893. return oldCanvas;
  894. //create a new canvas
  895. var newCanvas = document.createElement('canvas');
  896. var context = newCanvas.getContext('2d');
  897. //set dimensions
  898. newCanvas.width = oldCanvas.width;
  899. newCanvas.height = oldCanvas.height;
  900. //apply the old canvas to the new one
  901. context.drawImage(oldCanvas, 0, 0);
  902. //return the new canvas
  903. return newCanvas;
  904. };
  905. return my;
  906. })(CanvasUtil || {});
  907. module.exports = CanvasUtil;
  908. },{}],4:[function(require,module,exports){
  909. /* Initial "authentication required" dialog */
  910. var authDialog = null;
  911. /* Loop retry ID that wits for other user to create the room */
  912. var authRetryId = null;
  913. var authenticationWindow = null;
  914. var Authentication = {
  915. openAuthenticationDialog: function (roomName, intervalCallback, callback) {
  916. // This is the loop that will wait for the room to be created by
  917. // someone else. 'auth_required.moderator' will bring us back here.
  918. authRetryId = window.setTimeout(intervalCallback , 5000);
  919. // Show prompt only if it's not open
  920. if (authDialog !== null) {
  921. return;
  922. }
  923. // extract room name from 'room@muc.server.net'
  924. var room = roomName.substr(0, roomName.indexOf('@'));
  925. authDialog = messageHandler.openDialog(
  926. 'Stop',
  927. 'Authentication is required to create room:<br/><b>' + room +
  928. '</b></br> You can either authenticate to create the room or ' +
  929. 'just wait for someone else to do so.',
  930. true,
  931. {
  932. Authenticate: 'authNow'
  933. },
  934. function (onSubmitEvent, submitValue) {
  935. // Do not close the dialog yet
  936. onSubmitEvent.preventDefault();
  937. // Open login popup
  938. if (submitValue === 'authNow') {
  939. callback();
  940. }
  941. }
  942. );
  943. },
  944. closeAuthenticationWindow:function () {
  945. if (authenticationWindow) {
  946. authenticationWindow.close();
  947. authenticationWindow = null;
  948. }
  949. },
  950. focusAuthenticationWindow: function () {
  951. // If auth window exists just bring it to the front
  952. if (authenticationWindow) {
  953. authenticationWindow.focus();
  954. return;
  955. }
  956. },
  957. closeAuthenticationDialog: function () {
  958. // Close authentication dialog if opened
  959. if (authDialog) {
  960. UI.messageHandler.closeDialog();
  961. authDialog = null;
  962. }
  963. },
  964. createAuthenticationWindow: function (callback, url) {
  965. authenticationWindow = messageHandler.openCenteredPopup(
  966. url, 910, 660,
  967. // On closed
  968. function () {
  969. // Close authentication dialog if opened
  970. if (authDialog) {
  971. messageHandler.closeDialog();
  972. authDialog = null;
  973. }
  974. callback();
  975. authenticationWindow = null;
  976. });
  977. return authenticationWindow;
  978. },
  979. stopInterval: function () {
  980. // Clear retry interval, so that we don't call 'doJoinAfterFocus' twice
  981. if (authRetryId) {
  982. window.clearTimeout(authRetryId);
  983. authRetryId = null;
  984. }
  985. }
  986. };
  987. module.exports = Authentication;
  988. },{}],5:[function(require,module,exports){
  989. var Settings = require("../side_pannels/settings/Settings");
  990. var users = {};
  991. var activeSpeakerJid;
  992. function setVisibility(selector, show) {
  993. if (selector && selector.length > 0) {
  994. selector.css("visibility", show ? "visible" : "hidden");
  995. }
  996. }
  997. function isUserMuted(jid) {
  998. // XXX(gp) we may want to rename this method to something like
  999. // isUserStreaming, for example.
  1000. if (jid && jid != xmpp.myJid()) {
  1001. var resource = Strophe.getResourceFromJid(jid);
  1002. if (!require("../videolayout/VideoLayout").isInLastN(resource)) {
  1003. return true;
  1004. }
  1005. }
  1006. if (!RTC.remoteStreams[jid] || !RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
  1007. return null;
  1008. }
  1009. return RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE].muted;
  1010. }
  1011. function getGravatarUrl(id, size) {
  1012. if(id === xmpp.myJid() || !id) {
  1013. id = Settings.getSettings().uid;
  1014. }
  1015. return 'https://www.gravatar.com/avatar/' +
  1016. MD5.hexdigest(id.trim().toLowerCase()) +
  1017. "?d=wavatar&size=" + (size || "30");
  1018. }
  1019. var Avatar = {
  1020. /**
  1021. * Sets the user's avatar in the settings menu(if local user), contact list
  1022. * and thumbnail
  1023. * @param jid jid of the user
  1024. * @param id email or userID to be used as a hash
  1025. */
  1026. setUserAvatar: function (jid, id) {
  1027. if (id) {
  1028. if (users[jid] === id) {
  1029. return;
  1030. }
  1031. users[jid] = id;
  1032. }
  1033. var thumbUrl = getGravatarUrl(users[jid] || jid, 100);
  1034. var contactListUrl = getGravatarUrl(users[jid] || jid);
  1035. var resourceJid = Strophe.getResourceFromJid(jid);
  1036. var thumbnail = $('#participant_' + resourceJid);
  1037. var avatar = $('#avatar_' + resourceJid);
  1038. // set the avatar in the settings menu if it is local user and get the
  1039. // local video container
  1040. if (jid === xmpp.myJid()) {
  1041. $('#avatar').get(0).src = thumbUrl;
  1042. thumbnail = $('#localVideoContainer');
  1043. }
  1044. // set the avatar in the contact list
  1045. var contact = $('#' + resourceJid + '>img');
  1046. if (contact && contact.length > 0) {
  1047. contact.get(0).src = contactListUrl;
  1048. }
  1049. // set the avatar in the thumbnail
  1050. if (avatar && avatar.length > 0) {
  1051. avatar[0].src = thumbUrl;
  1052. } else {
  1053. if (thumbnail && thumbnail.length > 0) {
  1054. avatar = document.createElement('img');
  1055. avatar.id = 'avatar_' + resourceJid;
  1056. avatar.className = 'userAvatar';
  1057. avatar.src = thumbUrl;
  1058. thumbnail.append(avatar);
  1059. }
  1060. }
  1061. //if the user is the current active speaker - update the active speaker
  1062. // avatar
  1063. if (jid === activeSpeakerJid) {
  1064. this.updateActiveSpeakerAvatarSrc(jid);
  1065. }
  1066. },
  1067. /**
  1068. * Hides or shows the user's avatar
  1069. * @param jid jid of the user
  1070. * @param show whether we should show the avatar or not
  1071. * video because there is no dominant speaker and no focused speaker
  1072. */
  1073. showUserAvatar: function (jid, show) {
  1074. if (users[jid]) {
  1075. var resourceJid = Strophe.getResourceFromJid(jid);
  1076. var video = $('#participant_' + resourceJid + '>video');
  1077. var avatar = $('#avatar_' + resourceJid);
  1078. if (jid === xmpp.myJid()) {
  1079. video = $('#localVideoWrapper>video');
  1080. }
  1081. if (show === undefined || show === null) {
  1082. show = isUserMuted(jid);
  1083. }
  1084. //if the user is the currently focused, the dominant speaker or if
  1085. //there is no focused and no dominant speaker and the large video is
  1086. //currently shown
  1087. if (activeSpeakerJid === jid && require("../videolayout/VideoLayout").isLargeVideoOnTop()) {
  1088. setVisibility($("#largeVideo"), !show);
  1089. setVisibility($('#activeSpeaker'), show);
  1090. setVisibility(avatar, false);
  1091. setVisibility(video, false);
  1092. } else {
  1093. if (video && video.length > 0) {
  1094. setVisibility(video, !show);
  1095. setVisibility(avatar, show);
  1096. }
  1097. }
  1098. }
  1099. },
  1100. /**
  1101. * Updates the src of the active speaker avatar
  1102. * @param jid of the current active speaker
  1103. */
  1104. updateActiveSpeakerAvatarSrc: function (jid) {
  1105. if (!jid) {
  1106. jid = xmpp.findJidFromResource(
  1107. require("../videolayout/VideoLayout").getLargeVideoState().userResourceJid);
  1108. }
  1109. var avatar = $("#activeSpeakerAvatar")[0];
  1110. var url = getGravatarUrl(users[jid],
  1111. interfaceConfig.ACTIVE_SPEAKER_AVATAR_SIZE);
  1112. if (jid === activeSpeakerJid && avatar.src === url) {
  1113. return;
  1114. }
  1115. activeSpeakerJid = jid;
  1116. var isMuted = isUserMuted(jid);
  1117. if (jid && isMuted !== null) {
  1118. avatar.src = url;
  1119. setVisibility($("#largeVideo"), !isMuted);
  1120. Avatar.showUserAvatar(jid, isMuted);
  1121. }
  1122. }
  1123. };
  1124. module.exports = Avatar;
  1125. },{"../side_pannels/settings/Settings":15,"../videolayout/VideoLayout":25}],6:[function(require,module,exports){
  1126. /* global $, config, dockToolbar,
  1127. setLargeVideoVisible, Util */
  1128. var VideoLayout = require("../videolayout/VideoLayout");
  1129. var Prezi = require("../prezi/Prezi");
  1130. var UIUtil = require("../util/UIUtil");
  1131. var etherpadName = null;
  1132. var etherpadIFrame = null;
  1133. var domain = null;
  1134. var options = "?showControls=true&showChat=false&showLineNumbers=true&useMonospaceFont=false";
  1135. /**
  1136. * Resizes the etherpad.
  1137. */
  1138. function resize() {
  1139. if ($('#etherpad>iframe').length) {
  1140. var remoteVideos = $('#remoteVideos');
  1141. var availableHeight
  1142. = window.innerHeight - remoteVideos.outerHeight();
  1143. var availableWidth = UIUtil.getAvailableVideoWidth();
  1144. $('#etherpad>iframe').width(availableWidth);
  1145. $('#etherpad>iframe').height(availableHeight);
  1146. }
  1147. }
  1148. /**
  1149. * Shares the Etherpad name with other participants.
  1150. */
  1151. function shareEtherpad() {
  1152. xmpp.addToPresence("etherpad", etherpadName);
  1153. }
  1154. /**
  1155. * Creates the Etherpad button and adds it to the toolbar.
  1156. */
  1157. function enableEtherpadButton() {
  1158. if (!$('#etherpadButton').is(":visible"))
  1159. $('#etherpadButton').css({display: 'inline-block'});
  1160. }
  1161. /**
  1162. * Creates the IFrame for the etherpad.
  1163. */
  1164. function createIFrame() {
  1165. etherpadIFrame = document.createElement('iframe');
  1166. etherpadIFrame.src = domain + etherpadName + options;
  1167. etherpadIFrame.frameBorder = 0;
  1168. etherpadIFrame.scrolling = "no";
  1169. etherpadIFrame.width = $('#largeVideoContainer').width() || 640;
  1170. etherpadIFrame.height = $('#largeVideoContainer').height() || 480;
  1171. etherpadIFrame.setAttribute('style', 'visibility: hidden;');
  1172. document.getElementById('etherpad').appendChild(etherpadIFrame);
  1173. etherpadIFrame.onload = function() {
  1174. document.domain = document.domain;
  1175. bubbleIframeMouseMove(etherpadIFrame);
  1176. setTimeout(function() {
  1177. // the iframes inside of the etherpad are
  1178. // not yet loaded when the etherpad iframe is loaded
  1179. var outer = etherpadIFrame.
  1180. contentDocument.getElementsByName("ace_outer")[0];
  1181. bubbleIframeMouseMove(outer);
  1182. var inner = outer.
  1183. contentDocument.getElementsByName("ace_inner")[0];
  1184. bubbleIframeMouseMove(inner);
  1185. }, 2000);
  1186. };
  1187. }
  1188. function bubbleIframeMouseMove(iframe){
  1189. var existingOnMouseMove = iframe.contentWindow.onmousemove;
  1190. iframe.contentWindow.onmousemove = function(e){
  1191. if(existingOnMouseMove) existingOnMouseMove(e);
  1192. var evt = document.createEvent("MouseEvents");
  1193. var boundingClientRect = iframe.getBoundingClientRect();
  1194. evt.initMouseEvent(
  1195. "mousemove",
  1196. true, // bubbles
  1197. false, // not cancelable
  1198. window,
  1199. e.detail,
  1200. e.screenX,
  1201. e.screenY,
  1202. e.clientX + boundingClientRect.left,
  1203. e.clientY + boundingClientRect.top,
  1204. e.ctrlKey,
  1205. e.altKey,
  1206. e.shiftKey,
  1207. e.metaKey,
  1208. e.button,
  1209. null // no related element
  1210. );
  1211. iframe.dispatchEvent(evt);
  1212. };
  1213. }
  1214. /**
  1215. * On video selected event.
  1216. */
  1217. $(document).bind('video.selected', function (event, isPresentation) {
  1218. if (config.etherpad_base && etherpadIFrame && etherpadIFrame.style.visibility !== 'hidden')
  1219. Etherpad.toggleEtherpad(isPresentation);
  1220. });
  1221. var Etherpad = {
  1222. /**
  1223. * Initializes the etherpad.
  1224. */
  1225. init: function (name) {
  1226. if (config.etherpad_base && !etherpadName) {
  1227. domain = config.etherpad_base;
  1228. if (!name) {
  1229. // In case we're the focus we generate the name.
  1230. etherpadName = Math.random().toString(36).substring(7) +
  1231. '_' + (new Date().getTime()).toString();
  1232. shareEtherpad();
  1233. }
  1234. else
  1235. etherpadName = name;
  1236. enableEtherpadButton();
  1237. /**
  1238. * Resizes the etherpad, when the window is resized.
  1239. */
  1240. $(window).resize(function () {
  1241. resize();
  1242. });
  1243. }
  1244. },
  1245. /**
  1246. * Opens/hides the Etherpad.
  1247. */
  1248. toggleEtherpad: function (isPresentation) {
  1249. if (!etherpadIFrame)
  1250. createIFrame();
  1251. var largeVideo = null;
  1252. if (Prezi.isPresentationVisible())
  1253. largeVideo = $('#presentation>iframe');
  1254. else
  1255. largeVideo = $('#largeVideo');
  1256. if ($('#etherpad>iframe').css('visibility') === 'hidden') {
  1257. $('#activeSpeaker').css('visibility', 'hidden');
  1258. largeVideo.fadeOut(300, function () {
  1259. if (Prezi.isPresentationVisible()) {
  1260. largeVideo.css({opacity: '0'});
  1261. } else {
  1262. VideoLayout.setLargeVideoVisible(false);
  1263. }
  1264. });
  1265. $('#etherpad>iframe').fadeIn(300, function () {
  1266. document.body.style.background = '#eeeeee';
  1267. $('#etherpad>iframe').css({visibility: 'visible'});
  1268. $('#etherpad').css({zIndex: 2});
  1269. });
  1270. }
  1271. else if ($('#etherpad>iframe')) {
  1272. $('#etherpad>iframe').fadeOut(300, function () {
  1273. $('#etherpad>iframe').css({visibility: 'hidden'});
  1274. $('#etherpad').css({zIndex: 0});
  1275. document.body.style.background = 'black';
  1276. });
  1277. if (!isPresentation) {
  1278. $('#largeVideo').fadeIn(300, function () {
  1279. VideoLayout.setLargeVideoVisible(true);
  1280. });
  1281. }
  1282. }
  1283. resize();
  1284. },
  1285. isVisible: function() {
  1286. var etherpadIframe = $('#etherpad>iframe');
  1287. return etherpadIframe && etherpadIframe.is(':visible');
  1288. }
  1289. };
  1290. module.exports = Etherpad;
  1291. },{"../prezi/Prezi":7,"../util/UIUtil":23,"../videolayout/VideoLayout":25}],7:[function(require,module,exports){
  1292. var ToolbarToggler = require("../toolbars/ToolbarToggler");
  1293. var UIUtil = require("../util/UIUtil");
  1294. var VideoLayout = require("../videolayout/VideoLayout");
  1295. var messageHandler = require("../util/MessageHandler");
  1296. var PreziPlayer = require("./PreziPlayer");
  1297. var preziPlayer = null;
  1298. var Prezi = {
  1299. /**
  1300. * Reloads the current presentation.
  1301. */
  1302. reloadPresentation: function() {
  1303. var iframe = document.getElementById(preziPlayer.options.preziId);
  1304. iframe.src = iframe.src;
  1305. },
  1306. /**
  1307. * Returns <tt>true</tt> if the presentation is visible, <tt>false</tt> -
  1308. * otherwise.
  1309. */
  1310. isPresentationVisible: function () {
  1311. return ($('#presentation>iframe') != null
  1312. && $('#presentation>iframe').css('opacity') == 1);
  1313. },
  1314. /**
  1315. * Opens the Prezi dialog, from which the user could choose a presentation
  1316. * to load.
  1317. */
  1318. openPreziDialog: function() {
  1319. var myprezi = xmpp.getPrezi();
  1320. if (myprezi) {
  1321. messageHandler.openTwoButtonDialog("Remove Prezi",
  1322. "Are you sure you would like to remove your Prezi?",
  1323. false,
  1324. "Remove",
  1325. function(e,v,m,f) {
  1326. if(v) {
  1327. xmpp.removePreziFromPresence();
  1328. }
  1329. }
  1330. );
  1331. }
  1332. else if (preziPlayer != null) {
  1333. messageHandler.openTwoButtonDialog("Share a Prezi",
  1334. "Another participant is already sharing a Prezi." +
  1335. "This conference allows only one Prezi at a time.",
  1336. false,
  1337. "Ok",
  1338. function(e,v,m,f) {
  1339. $.prompt.close();
  1340. }
  1341. );
  1342. }
  1343. else {
  1344. var openPreziState = {
  1345. state0: {
  1346. html: '<h2>Share a Prezi</h2>' +
  1347. '<input id="preziUrl" type="text" ' +
  1348. 'placeholder="e.g. ' +
  1349. 'http://prezi.com/wz7vhjycl7e6/my-prezi" autofocus>',
  1350. persistent: false,
  1351. buttons: { "Share": true , "Cancel": false},
  1352. defaultButton: 1,
  1353. submit: function(e,v,m,f){
  1354. e.preventDefault();
  1355. if(v)
  1356. {
  1357. var preziUrl = document.getElementById('preziUrl');
  1358. if (preziUrl.value)
  1359. {
  1360. var urlValue
  1361. = encodeURI(UIUtil.escapeHtml(preziUrl.value));
  1362. if (urlValue.indexOf('http://prezi.com/') != 0
  1363. && urlValue.indexOf('https://prezi.com/') != 0)
  1364. {
  1365. $.prompt.goToState('state1');
  1366. return false;
  1367. }
  1368. else {
  1369. var presIdTmp = urlValue.substring(
  1370. urlValue.indexOf("prezi.com/") + 10);
  1371. if (!isAlphanumeric(presIdTmp)
  1372. || presIdTmp.indexOf('/') < 2) {
  1373. $.prompt.goToState('state1');
  1374. return false;
  1375. }
  1376. else {
  1377. xmpp.addToPresence("prezi", urlValue);
  1378. $.prompt.close();
  1379. }
  1380. }
  1381. }
  1382. }
  1383. else
  1384. $.prompt.close();
  1385. }
  1386. },
  1387. state1: {
  1388. html: '<h2>Share a Prezi</h2>' +
  1389. 'Please provide a correct prezi link.',
  1390. persistent: false,
  1391. buttons: { "Back": true, "Cancel": false },
  1392. defaultButton: 1,
  1393. submit:function(e,v,m,f) {
  1394. e.preventDefault();
  1395. if(v==0)
  1396. $.prompt.close();
  1397. else
  1398. $.prompt.goToState('state0');
  1399. }
  1400. }
  1401. };
  1402. var focusPreziUrl = function(e) {
  1403. document.getElementById('preziUrl').focus();
  1404. };
  1405. messageHandler.openDialogWithStates(openPreziState, focusPreziUrl, focusPreziUrl);
  1406. }
  1407. }
  1408. };
  1409. /**
  1410. * A new presentation has been added.
  1411. *
  1412. * @param event the event indicating the add of a presentation
  1413. * @param jid the jid from which the presentation was added
  1414. * @param presUrl url of the presentation
  1415. * @param currentSlide the current slide to which we should move
  1416. */
  1417. function presentationAdded(event, jid, presUrl, currentSlide) {
  1418. console.log("presentation added", presUrl);
  1419. var presId = getPresentationId(presUrl);
  1420. var elementId = 'participant_'
  1421. + Strophe.getResourceFromJid(jid)
  1422. + '_' + presId;
  1423. // We explicitly don't specify the peer jid here, because we don't want
  1424. // this video to be dealt with as a peer related one (for example we
  1425. // don't want to show a mute/kick menu for this one, etc.).
  1426. VideoLayout.addRemoteVideoContainer(null, elementId);
  1427. VideoLayout.resizeThumbnails();
  1428. var controlsEnabled = false;
  1429. if (jid === xmpp.myJid())
  1430. controlsEnabled = true;
  1431. setPresentationVisible(true);
  1432. $('#largeVideoContainer').hover(
  1433. function (event) {
  1434. if (Prezi.isPresentationVisible()) {
  1435. var reloadButtonRight = window.innerWidth
  1436. - $('#presentation>iframe').offset().left
  1437. - $('#presentation>iframe').width();
  1438. $('#reloadPresentation').css({ right: reloadButtonRight,
  1439. display:'inline-block'});
  1440. }
  1441. },
  1442. function (event) {
  1443. if (!Prezi.isPresentationVisible())
  1444. $('#reloadPresentation').css({display:'none'});
  1445. else {
  1446. var e = event.toElement || event.relatedTarget;
  1447. if (e && e.id != 'reloadPresentation' && e.id != 'header')
  1448. $('#reloadPresentation').css({display:'none'});
  1449. }
  1450. });
  1451. preziPlayer = new PreziPlayer(
  1452. 'presentation',
  1453. {preziId: presId,
  1454. width: getPresentationWidth(),
  1455. height: getPresentationHeihgt(),
  1456. controls: controlsEnabled,
  1457. debug: true
  1458. });
  1459. $('#presentation>iframe').attr('id', preziPlayer.options.preziId);
  1460. preziPlayer.on(PreziPlayer.EVENT_STATUS, function(event) {
  1461. console.log("prezi status", event.value);
  1462. if (event.value == PreziPlayer.STATUS_CONTENT_READY) {
  1463. if (jid != xmpp.myJid())
  1464. preziPlayer.flyToStep(currentSlide);
  1465. }
  1466. });
  1467. preziPlayer.on(PreziPlayer.EVENT_CURRENT_STEP, function(event) {
  1468. console.log("event value", event.value);
  1469. xmpp.addToPresence("preziSlide", event.value);
  1470. });
  1471. $("#" + elementId).css( 'background-image',
  1472. 'url(../images/avatarprezi.png)');
  1473. $("#" + elementId).click(
  1474. function () {
  1475. setPresentationVisible(true);
  1476. }
  1477. );
  1478. };
  1479. /**
  1480. * A presentation has been removed.
  1481. *
  1482. * @param event the event indicating the remove of a presentation
  1483. * @param jid the jid for which the presentation was removed
  1484. * @param the url of the presentation
  1485. */
  1486. function presentationRemoved(event, jid, presUrl) {
  1487. console.log('presentation removed', presUrl);
  1488. var presId = getPresentationId(presUrl);
  1489. setPresentationVisible(false);
  1490. $('#participant_'
  1491. + Strophe.getResourceFromJid(jid)
  1492. + '_' + presId).remove();
  1493. $('#presentation>iframe').remove();
  1494. if (preziPlayer != null) {
  1495. preziPlayer.destroy();
  1496. preziPlayer = null;
  1497. }
  1498. };
  1499. /**
  1500. * Indicates if the given string is an alphanumeric string.
  1501. * Note that some special characters are also allowed (-, _ , /, &, ?, =, ;) for the
  1502. * purpose of checking URIs.
  1503. */
  1504. function isAlphanumeric(unsafeText) {
  1505. var regex = /^[a-z0-9-_\/&\?=;]+$/i;
  1506. return regex.test(unsafeText);
  1507. }
  1508. /**
  1509. * Returns the presentation id from the given url.
  1510. */
  1511. function getPresentationId (presUrl) {
  1512. var presIdTmp = presUrl.substring(presUrl.indexOf("prezi.com/") + 10);
  1513. return presIdTmp.substring(0, presIdTmp.indexOf('/'));
  1514. }
  1515. /**
  1516. * Returns the presentation width.
  1517. */
  1518. function getPresentationWidth() {
  1519. var availableWidth = UIUtil.getAvailableVideoWidth();
  1520. var availableHeight = getPresentationHeihgt();
  1521. var aspectRatio = 16.0 / 9.0;
  1522. if (availableHeight < availableWidth / aspectRatio) {
  1523. availableWidth = Math.floor(availableHeight * aspectRatio);
  1524. }
  1525. return availableWidth;
  1526. }
  1527. /**
  1528. * Returns the presentation height.
  1529. */
  1530. function getPresentationHeihgt() {
  1531. var remoteVideos = $('#remoteVideos');
  1532. return window.innerHeight - remoteVideos.outerHeight();
  1533. }
  1534. /**
  1535. * Resizes the presentation iframe.
  1536. */
  1537. function resize() {
  1538. if ($('#presentation>iframe')) {
  1539. $('#presentation>iframe').width(getPresentationWidth());
  1540. $('#presentation>iframe').height(getPresentationHeihgt());
  1541. }
  1542. }
  1543. /**
  1544. * Shows/hides a presentation.
  1545. */
  1546. function setPresentationVisible(visible) {
  1547. var prezi = $('#presentation>iframe');
  1548. if (visible) {
  1549. // Trigger the video.selected event to indicate a change in the
  1550. // large video.
  1551. $(document).trigger("video.selected", [true]);
  1552. $('#largeVideo').fadeOut(300);
  1553. prezi.fadeIn(300, function() {
  1554. prezi.css({opacity:'1'});
  1555. ToolbarToggler.dockToolbar(true);
  1556. VideoLayout.setLargeVideoVisible(false);
  1557. });
  1558. $('#activeSpeaker').css('visibility', 'hidden');
  1559. }
  1560. else {
  1561. if (prezi.css('opacity') == '1') {
  1562. prezi.fadeOut(300, function () {
  1563. prezi.css({opacity:'0'});
  1564. $('#reloadPresentation').css({display:'none'});
  1565. $('#largeVideo').fadeIn(300, function() {
  1566. VideoLayout.setLargeVideoVisible(true);
  1567. ToolbarToggler.dockToolbar(false);
  1568. });
  1569. });
  1570. }
  1571. }
  1572. }
  1573. /**
  1574. * Presentation has been removed.
  1575. */
  1576. $(document).bind('presentationremoved.muc', presentationRemoved);
  1577. /**
  1578. * Presentation has been added.
  1579. */
  1580. $(document).bind('presentationadded.muc', presentationAdded);
  1581. /*
  1582. * Indicates presentation slide change.
  1583. */
  1584. $(document).bind('gotoslide.muc', function (event, jid, presUrl, current) {
  1585. if (preziPlayer && preziPlayer.getCurrentStep() != current) {
  1586. preziPlayer.flyToStep(current);
  1587. var animationStepsArray = preziPlayer.getAnimationCountOnSteps();
  1588. for (var i = 0; i < parseInt(animationStepsArray[current]); i++) {
  1589. preziPlayer.flyToStep(current, i);
  1590. }
  1591. }
  1592. });
  1593. /**
  1594. * On video selected event.
  1595. */
  1596. $(document).bind('video.selected', function (event, isPresentation) {
  1597. if (!isPresentation && $('#presentation>iframe')) {
  1598. setPresentationVisible(false);
  1599. }
  1600. });
  1601. $(window).resize(function () {
  1602. resize();
  1603. });
  1604. module.exports = Prezi;
  1605. },{"../toolbars/ToolbarToggler":19,"../util/MessageHandler":21,"../util/UIUtil":23,"../videolayout/VideoLayout":25,"./PreziPlayer":8}],8:[function(require,module,exports){
  1606. (function() {
  1607. "use strict";
  1608. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  1609. window.PreziPlayer = (function() {
  1610. PreziPlayer.API_VERSION = 1;
  1611. PreziPlayer.CURRENT_STEP = 'currentStep';
  1612. PreziPlayer.CURRENT_ANIMATION_STEP = 'currentAnimationStep';
  1613. PreziPlayer.CURRENT_OBJECT = 'currentObject';
  1614. PreziPlayer.STATUS_LOADING = 'loading';
  1615. PreziPlayer.STATUS_READY = 'ready';
  1616. PreziPlayer.STATUS_CONTENT_READY = 'contentready';
  1617. PreziPlayer.EVENT_CURRENT_STEP = "currentStepChange";
  1618. PreziPlayer.EVENT_CURRENT_ANIMATION_STEP = "currentAnimationStepChange";
  1619. PreziPlayer.EVENT_CURRENT_OBJECT = "currentObjectChange";
  1620. PreziPlayer.EVENT_STATUS = "statusChange";
  1621. PreziPlayer.EVENT_PLAYING = "isAutoPlayingChange";
  1622. PreziPlayer.EVENT_IS_MOVING = "isMovingChange";
  1623. PreziPlayer.domain = "https://prezi.com";
  1624. PreziPlayer.path = "/player/";
  1625. PreziPlayer.players = {};
  1626. PreziPlayer.binded_methods = ['changesHandler'];
  1627. PreziPlayer.createMultiplePlayers = function(optionArray){
  1628. for(var i=0; i<optionArray.length; i++) {
  1629. var optionSet = optionArray[i];
  1630. new PreziPlayer(optionSet.id, optionSet);
  1631. };
  1632. };
  1633. PreziPlayer.messageReceived = function(event){
  1634. var message, item, player;
  1635. try {
  1636. message = JSON.parse(event.data);
  1637. } catch (e) {}
  1638. if (message.id && (player = PreziPlayer.players[message.id])){
  1639. if (player.options.debug === true) {
  1640. if (console && console.log) console.log('received', message);
  1641. }
  1642. if (message.type === "changes"){
  1643. player.changesHandler(message);
  1644. }
  1645. for (var i=0; i<player.callbacks.length; i++) {
  1646. item = player.callbacks[i];
  1647. if (item && message.type === item.event){
  1648. item.callback(message);
  1649. }
  1650. }
  1651. }
  1652. };
  1653. function PreziPlayer(id, options) {
  1654. var params, paramString = "", _this = this;
  1655. if (PreziPlayer.players[id]){
  1656. PreziPlayer.players[id].destroy();
  1657. }
  1658. for(var i=0; i<PreziPlayer.binded_methods.length; i++) {
  1659. var method_name = PreziPlayer.binded_methods[i];
  1660. _this[method_name] = __bind(_this[method_name], _this);
  1661. };
  1662. options = options || {};
  1663. this.options = options;
  1664. this.values = {'status': PreziPlayer.STATUS_LOADING};
  1665. this.values[PreziPlayer.CURRENT_STEP] = 0;
  1666. this.values[PreziPlayer.CURRENT_ANIMATION_STEP] = 0;
  1667. this.values[PreziPlayer.CURRENT_OBJECT] = null;
  1668. this.callbacks = [];
  1669. this.id = id;
  1670. this.embedTo = document.getElementById(id);
  1671. if (!this.embedTo) {
  1672. throw "The element id is not available.";
  1673. }
  1674. this.iframe = document.createElement('iframe');
  1675. params = [
  1676. { name: 'oid', value: options.preziId },
  1677. { name: 'explorable', value: options.explorable ? 1 : 0 },
  1678. { name: 'controls', value: options.controls ? 1 : 0 }
  1679. ];
  1680. for(var i=0; i<params.length; i++) {
  1681. var param = params[i];
  1682. paramString += (i===0 ? "?" : "&") + param.name + "=" + param.value;
  1683. };
  1684. this.iframe.src = PreziPlayer.domain + PreziPlayer.path + paramString;
  1685. this.iframe.frameBorder = 0;
  1686. this.iframe.scrolling = "no";
  1687. this.iframe.width = options.width || 640;
  1688. this.iframe.height = options.height || 480;
  1689. this.embedTo.innerHTML = '';
  1690. // JITSI: IN CASE SOMETHING GOES WRONG.
  1691. try {
  1692. this.embedTo.appendChild(this.iframe);
  1693. }
  1694. catch (err) {
  1695. console.log("CATCH ERROR");
  1696. }
  1697. // JITSI: Increase interval from 200 to 500, which fixes prezi
  1698. // crashes for us.
  1699. this.initPollInterval = setInterval(function(){
  1700. _this.sendMessage({'action': 'init'});
  1701. }, 500);
  1702. PreziPlayer.players[id] = this;
  1703. }
  1704. PreziPlayer.prototype.changesHandler = function(message) {
  1705. var key, value, j, item;
  1706. if (this.initPollInterval) {
  1707. clearInterval(this.initPollInterval);
  1708. this.initPollInterval = false;
  1709. }
  1710. for (key in message.data) {
  1711. if (message.data.hasOwnProperty(key)){
  1712. value = message.data[key];
  1713. this.values[key] = value;
  1714. for (j=0; j<this.callbacks.length; j++) {
  1715. item = this.callbacks[j];
  1716. if (item && item.event === key + "Change"){
  1717. item.callback({type: item.event, value: value});
  1718. }
  1719. }
  1720. }
  1721. }
  1722. };
  1723. PreziPlayer.prototype.destroy = function() {
  1724. if (this.initPollInterval) {
  1725. clearInterval(this.initPollInterval);
  1726. this.initPollInterval = false;
  1727. }
  1728. this.embedTo.innerHTML = '';
  1729. };
  1730. PreziPlayer.prototype.sendMessage = function(message) {
  1731. if (this.options.debug === true) {
  1732. if (console && console.log) console.log('sent', message);
  1733. }
  1734. message.version = PreziPlayer.API_VERSION;
  1735. message.id = this.id;
  1736. return this.iframe.contentWindow.postMessage(JSON.stringify(message), '*');
  1737. };
  1738. PreziPlayer.prototype.nextStep = /* nextStep is DEPRECATED */
  1739. PreziPlayer.prototype.flyToNextStep = function() {
  1740. return this.sendMessage({
  1741. 'action': 'present',
  1742. 'data': ['moveToNextStep']
  1743. });
  1744. };
  1745. PreziPlayer.prototype.previousStep = /* previousStep is DEPRECATED */
  1746. PreziPlayer.prototype.flyToPreviousStep = function() {
  1747. return this.sendMessage({
  1748. 'action': 'present',
  1749. 'data': ['moveToPrevStep']
  1750. });
  1751. };
  1752. PreziPlayer.prototype.toStep = /* toStep is DEPRECATED */
  1753. PreziPlayer.prototype.flyToStep = function(step, animation_step) {
  1754. var obj = this;
  1755. // check animation_step
  1756. if (animation_step > 0 &&
  1757. obj.values.animationCountOnSteps &&
  1758. obj.values.animationCountOnSteps[step] <= animation_step) {
  1759. animation_step = obj.values.animationCountOnSteps[step];
  1760. }
  1761. // jump to animation steps by calling flyToNextStep()
  1762. function doAnimationSteps() {
  1763. if (obj.values.isMoving == true) {
  1764. setTimeout(doAnimationSteps, 100); // wait until the flight ends
  1765. return;
  1766. }
  1767. while (animation_step-- > 0) {
  1768. obj.flyToNextStep(); // do the animation steps
  1769. }
  1770. }
  1771. setTimeout(doAnimationSteps, 200); // 200ms is the internal "reporting" time
  1772. // jump to the step
  1773. return this.sendMessage({
  1774. 'action': 'present',
  1775. 'data': ['moveToStep', step]
  1776. });
  1777. };
  1778. PreziPlayer.prototype.toObject = /* toObject is DEPRECATED */
  1779. PreziPlayer.prototype.flyToObject = function(objectId) {
  1780. return this.sendMessage({
  1781. 'action': 'present',
  1782. 'data': ['moveToObject', objectId]
  1783. });
  1784. };
  1785. PreziPlayer.prototype.play = function(defaultDelay) {
  1786. return this.sendMessage({
  1787. 'action': 'present',
  1788. 'data': ['startAutoPlay', defaultDelay]
  1789. });
  1790. };
  1791. PreziPlayer.prototype.stop = function() {
  1792. return this.sendMessage({
  1793. 'action': 'present',
  1794. 'data': ['stopAutoPlay']
  1795. });
  1796. };
  1797. PreziPlayer.prototype.pause = function(defaultDelay) {
  1798. return this.sendMessage({
  1799. 'action': 'present',
  1800. 'data': ['pauseAutoPlay', defaultDelay]
  1801. });
  1802. };
  1803. PreziPlayer.prototype.getCurrentStep = function() {
  1804. return this.values.currentStep;
  1805. };
  1806. PreziPlayer.prototype.getCurrentAnimationStep = function() {
  1807. return this.values.currentAnimationStep;
  1808. };
  1809. PreziPlayer.prototype.getCurrentObject = function() {
  1810. return this.values.currentObject;
  1811. };
  1812. PreziPlayer.prototype.getStatus = function() {
  1813. return this.values.status;
  1814. };
  1815. PreziPlayer.prototype.isPlaying = function() {
  1816. return this.values.isAutoPlaying;
  1817. };
  1818. PreziPlayer.prototype.getStepCount = function() {
  1819. return this.values.stepCount;
  1820. };
  1821. PreziPlayer.prototype.getAnimationCountOnSteps = function() {
  1822. return this.values.animationCountOnSteps;
  1823. };
  1824. PreziPlayer.prototype.getTitle = function() {
  1825. return this.values.title;
  1826. };
  1827. PreziPlayer.prototype.setDimensions = function(dims) {
  1828. for (var parameter in dims) {
  1829. this.iframe[parameter] = dims[parameter];
  1830. }
  1831. }
  1832. PreziPlayer.prototype.getDimensions = function() {
  1833. return {
  1834. width: parseInt(this.iframe.width, 10),
  1835. height: parseInt(this.iframe.height, 10)
  1836. }
  1837. }
  1838. PreziPlayer.prototype.on = function(event, callback) {
  1839. this.callbacks.push({
  1840. event: event,
  1841. callback: callback
  1842. });
  1843. };
  1844. PreziPlayer.prototype.off = function(event, callback) {
  1845. var j, item;
  1846. if (event === undefined) {
  1847. this.callbacks = [];
  1848. }
  1849. j = this.callbacks.length;
  1850. while (j--) {
  1851. item = this.callbacks[j];
  1852. if (item && item.event === event && (callback === undefined || item.callback === callback)){
  1853. this.callbacks.splice(j, 1);
  1854. }
  1855. }
  1856. };
  1857. if (window.addEventListener) {
  1858. window.addEventListener('message', PreziPlayer.messageReceived, false);
  1859. } else {
  1860. window.attachEvent('onmessage', PreziPlayer.messageReceived);
  1861. }
  1862. return PreziPlayer;
  1863. })();
  1864. })();
  1865. module.exports = PreziPlayer;
  1866. },{}],9:[function(require,module,exports){
  1867. var Chat = require("./chat/Chat");
  1868. var ContactList = require("./contactlist/ContactList");
  1869. var Settings = require("./settings/Settings");
  1870. var SettingsMenu = require("./settings/SettingsMenu");
  1871. var VideoLayout = require("../videolayout/VideoLayout");
  1872. var ToolbarToggler = require("../toolbars/ToolbarToggler");
  1873. var UIUtil = require("../util/UIUtil");
  1874. /**
  1875. * Toggler for the chat, contact list, settings menu, etc..
  1876. */
  1877. var PanelToggler = (function(my) {
  1878. var currentlyOpen = null;
  1879. var buttons = {
  1880. '#chatspace': '#chatBottomButton',
  1881. '#contactlist': '#contactListButton',
  1882. '#settingsmenu': '#settingsButton'
  1883. };
  1884. /**
  1885. * Resizes the video area
  1886. * @param isClosing whether the side panel is going to be closed or is going to open / remain opened
  1887. * @param completeFunction a function to be called when the video space is resized
  1888. */
  1889. var resizeVideoArea = function(isClosing, completeFunction) {
  1890. var videospace = $('#videospace');
  1891. var panelSize = isClosing ? [0, 0] : PanelToggler.getPanelSize();
  1892. var videospaceWidth = window.innerWidth - panelSize[0];
  1893. var videospaceHeight = window.innerHeight;
  1894. var videoSize
  1895. = VideoLayout.getVideoSize(null, null, videospaceWidth, videospaceHeight);
  1896. var videoWidth = videoSize[0];
  1897. var videoHeight = videoSize[1];
  1898. var videoPosition = VideoLayout.getVideoPosition(videoWidth,
  1899. videoHeight,
  1900. videospaceWidth,
  1901. videospaceHeight);
  1902. var horizontalIndent = videoPosition[0];
  1903. var verticalIndent = videoPosition[1];
  1904. var thumbnailSize = VideoLayout.calculateThumbnailSize(videospaceWidth);
  1905. var thumbnailsWidth = thumbnailSize[0];
  1906. var thumbnailsHeight = thumbnailSize[1];
  1907. //for chat
  1908. videospace.animate({
  1909. right: panelSize[0],
  1910. width: videospaceWidth,
  1911. height: videospaceHeight
  1912. },
  1913. {
  1914. queue: false,
  1915. duration: 500,
  1916. complete: completeFunction
  1917. });
  1918. $('#remoteVideos').animate({
  1919. height: thumbnailsHeight
  1920. },
  1921. {
  1922. queue: false,
  1923. duration: 500
  1924. });
  1925. $('#remoteVideos>span').animate({
  1926. height: thumbnailsHeight,
  1927. width: thumbnailsWidth
  1928. },
  1929. {
  1930. queue: false,
  1931. duration: 500,
  1932. complete: function () {
  1933. $(document).trigger(
  1934. "remotevideo.resized",
  1935. [thumbnailsWidth,
  1936. thumbnailsHeight]);
  1937. }
  1938. });
  1939. $('#largeVideoContainer').animate({
  1940. width: videospaceWidth,
  1941. height: videospaceHeight
  1942. },
  1943. {
  1944. queue: false,
  1945. duration: 500
  1946. });
  1947. $('#largeVideo').animate({
  1948. width: videoWidth,
  1949. height: videoHeight,
  1950. top: verticalIndent,
  1951. bottom: verticalIndent,
  1952. left: horizontalIndent,
  1953. right: horizontalIndent
  1954. },
  1955. {
  1956. queue: false,
  1957. duration: 500
  1958. });
  1959. };
  1960. /**
  1961. * Toggles the windows in the side panel
  1962. * @param object the window that should be shown
  1963. * @param selector the selector for the element containing the panel
  1964. * @param onOpenComplete function to be called when the panel is opened
  1965. * @param onOpen function to be called if the window is going to be opened
  1966. * @param onClose function to be called if the window is going to be closed
  1967. */
  1968. var toggle = function(object, selector, onOpenComplete, onOpen, onClose) {
  1969. UIUtil.buttonClick(buttons[selector], "active");
  1970. if (object.isVisible()) {
  1971. $("#toast-container").animate({
  1972. right: '5px'
  1973. },
  1974. {
  1975. queue: false,
  1976. duration: 500
  1977. });
  1978. $(selector).hide("slide", {
  1979. direction: "right",
  1980. queue: false,
  1981. duration: 500
  1982. });
  1983. if(typeof onClose === "function") {
  1984. onClose();
  1985. }
  1986. currentlyOpen = null;
  1987. }
  1988. else {
  1989. // Undock the toolbar when the chat is shown and if we're in a
  1990. // video mode.
  1991. if (VideoLayout.isLargeVideoVisible()) {
  1992. ToolbarToggler.dockToolbar(false);
  1993. }
  1994. if(currentlyOpen) {
  1995. var current = $(currentlyOpen);
  1996. UIUtil.buttonClick(buttons[currentlyOpen], "active");
  1997. current.css('z-index', 4);
  1998. setTimeout(function () {
  1999. current.css('display', 'none');
  2000. current.css('z-index', 5);
  2001. }, 500);
  2002. }
  2003. $("#toast-container").animate({
  2004. right: (PanelToggler.getPanelSize()[0] + 5) + 'px'
  2005. },
  2006. {
  2007. queue: false,
  2008. duration: 500
  2009. });
  2010. $(selector).show("slide", {
  2011. direction: "right",
  2012. queue: false,
  2013. duration: 500,
  2014. complete: onOpenComplete
  2015. });
  2016. if(typeof onOpen === "function") {
  2017. onOpen();
  2018. }
  2019. currentlyOpen = selector;
  2020. }
  2021. };
  2022. /**
  2023. * Opens / closes the chat area.
  2024. */
  2025. my.toggleChat = function() {
  2026. var chatCompleteFunction = Chat.isVisible() ?
  2027. function() {} : function () {
  2028. Chat.scrollChatToBottom();
  2029. $('#chatspace').trigger('shown');
  2030. };
  2031. resizeVideoArea(Chat.isVisible(), chatCompleteFunction);
  2032. toggle(Chat,
  2033. '#chatspace',
  2034. function () {
  2035. // Request the focus in the nickname field or the chat input field.
  2036. if ($('#nickname').css('visibility') === 'visible') {
  2037. $('#nickinput').focus();
  2038. } else {
  2039. $('#usermsg').focus();
  2040. }
  2041. },
  2042. null,
  2043. Chat.resizeChat,
  2044. null);
  2045. };
  2046. /**
  2047. * Opens / closes the contact list area.
  2048. */
  2049. my.toggleContactList = function () {
  2050. var completeFunction = ContactList.isVisible() ?
  2051. function() {} : function () { $('#contactlist').trigger('shown');};
  2052. resizeVideoArea(ContactList.isVisible(), completeFunction);
  2053. toggle(ContactList,
  2054. '#contactlist',
  2055. null,
  2056. function() {
  2057. ContactList.setVisualNotification(false);
  2058. },
  2059. null);
  2060. };
  2061. /**
  2062. * Opens / closes the settings menu
  2063. */
  2064. my.toggleSettingsMenu = function() {
  2065. resizeVideoArea(SettingsMenu.isVisible(), function (){});
  2066. toggle(SettingsMenu,
  2067. '#settingsmenu',
  2068. null,
  2069. function() {
  2070. var settings = Settings.getSettings();
  2071. $('#setDisplayName').get(0).value = settings.displayName;
  2072. $('#setEmail').get(0).value = settings.email;
  2073. },
  2074. null);
  2075. };
  2076. /**
  2077. * Returns the size of the side panel.
  2078. */
  2079. my.getPanelSize = function () {
  2080. var availableHeight = window.innerHeight;
  2081. var availableWidth = window.innerWidth;
  2082. var panelWidth = 200;
  2083. if (availableWidth * 0.2 < 200) {
  2084. panelWidth = availableWidth * 0.2;
  2085. }
  2086. return [panelWidth, availableHeight];
  2087. };
  2088. my.isVisible = function() {
  2089. return (Chat.isVisible() || ContactList.isVisible() || SettingsMenu.isVisible());
  2090. };
  2091. return my;
  2092. }(PanelToggler || {}));
  2093. module.exports = PanelToggler;
  2094. },{"../toolbars/ToolbarToggler":19,"../util/UIUtil":23,"../videolayout/VideoLayout":25,"./chat/Chat":10,"./contactlist/ContactList":14,"./settings/Settings":15,"./settings/SettingsMenu":16}],10:[function(require,module,exports){
  2095. /* global $, Util, nickname:true, showToolbar */
  2096. var Replacement = require("./Replacement");
  2097. var CommandsProcessor = require("./Commands");
  2098. var ToolbarToggler = require("../../toolbars/ToolbarToggler");
  2099. var smileys = require("./smileys.json").smileys;
  2100. var NicknameHandler = require("../../util/NicknameHandler");
  2101. var UIUtil = require("../../util/UIUtil");
  2102. var notificationInterval = false;
  2103. var unreadMessages = 0;
  2104. /**
  2105. * Shows/hides a visual notification, indicating that a message has arrived.
  2106. */
  2107. function setVisualNotification(show) {
  2108. var unreadMsgElement = document.getElementById('unreadMessages');
  2109. var unreadMsgBottomElement
  2110. = document.getElementById('bottomUnreadMessages');
  2111. var glower = $('#chatButton');
  2112. var bottomGlower = $('#chatBottomButton');
  2113. if (unreadMessages) {
  2114. unreadMsgElement.innerHTML = unreadMessages.toString();
  2115. unreadMsgBottomElement.innerHTML = unreadMessages.toString();
  2116. ToolbarToggler.dockToolbar(true);
  2117. var chatButtonElement
  2118. = document.getElementById('chatButton').parentNode;
  2119. var leftIndent = (UIUtil.getTextWidth(chatButtonElement) -
  2120. UIUtil.getTextWidth(unreadMsgElement)) / 2;
  2121. var topIndent = (UIUtil.getTextHeight(chatButtonElement) -
  2122. UIUtil.getTextHeight(unreadMsgElement)) / 2 - 3;
  2123. unreadMsgElement.setAttribute(
  2124. 'style',
  2125. 'top:' + topIndent +
  2126. '; left:' + leftIndent + ';');
  2127. var chatBottomButtonElement
  2128. = document.getElementById('chatBottomButton').parentNode;
  2129. var bottomLeftIndent = (UIUtil.getTextWidth(chatBottomButtonElement) -
  2130. UIUtil.getTextWidth(unreadMsgBottomElement)) / 2;
  2131. var bottomTopIndent = (UIUtil.getTextHeight(chatBottomButtonElement) -
  2132. UIUtil.getTextHeight(unreadMsgBottomElement)) / 2 - 2;
  2133. unreadMsgBottomElement.setAttribute(
  2134. 'style',
  2135. 'top:' + bottomTopIndent +
  2136. '; left:' + bottomLeftIndent + ';');
  2137. if (!glower.hasClass('icon-chat-simple')) {
  2138. glower.removeClass('icon-chat');
  2139. glower.addClass('icon-chat-simple');
  2140. }
  2141. }
  2142. else {
  2143. unreadMsgElement.innerHTML = '';
  2144. unreadMsgBottomElement.innerHTML = '';
  2145. glower.removeClass('icon-chat-simple');
  2146. glower.addClass('icon-chat');
  2147. }
  2148. if (show && !notificationInterval) {
  2149. notificationInterval = window.setInterval(function () {
  2150. glower.toggleClass('active');
  2151. bottomGlower.toggleClass('active glowing');
  2152. }, 800);
  2153. }
  2154. else if (!show && notificationInterval) {
  2155. window.clearInterval(notificationInterval);
  2156. notificationInterval = false;
  2157. glower.removeClass('active');
  2158. bottomGlower.removeClass('glowing');
  2159. bottomGlower.addClass('active');
  2160. }
  2161. }
  2162. /**
  2163. * Returns the current time in the format it is shown to the user
  2164. * @returns {string}
  2165. */
  2166. function getCurrentTime() {
  2167. var now = new Date();
  2168. var hour = now.getHours();
  2169. var minute = now.getMinutes();
  2170. var second = now.getSeconds();
  2171. if(hour.toString().length === 1) {
  2172. hour = '0'+hour;
  2173. }
  2174. if(minute.toString().length === 1) {
  2175. minute = '0'+minute;
  2176. }
  2177. if(second.toString().length === 1) {
  2178. second = '0'+second;
  2179. }
  2180. return hour+':'+minute+':'+second;
  2181. }
  2182. function toggleSmileys()
  2183. {
  2184. var smileys = $('#smileysContainer');
  2185. if(!smileys.is(':visible')) {
  2186. smileys.show("slide", { direction: "down", duration: 300});
  2187. } else {
  2188. smileys.hide("slide", { direction: "down", duration: 300});
  2189. }
  2190. $('#usermsg').focus();
  2191. }
  2192. function addClickFunction(smiley, number) {
  2193. smiley.onclick = function addSmileyToMessage() {
  2194. var usermsg = $('#usermsg');
  2195. var message = usermsg.val();
  2196. message += smileys['smiley' + number];
  2197. usermsg.val(message);
  2198. usermsg.get(0).setSelectionRange(message.length, message.length);
  2199. toggleSmileys();
  2200. usermsg.focus();
  2201. };
  2202. }
  2203. /**
  2204. * Adds the smileys container to the chat
  2205. */
  2206. function addSmileys() {
  2207. var smileysContainer = document.createElement('div');
  2208. smileysContainer.id = 'smileysContainer';
  2209. for(var i = 1; i <= 21; i++) {
  2210. var smileyContainer = document.createElement('div');
  2211. smileyContainer.id = 'smiley' + i;
  2212. smileyContainer.className = 'smileyContainer';
  2213. var smiley = document.createElement('img');
  2214. smiley.src = 'images/smileys/smiley' + i + '.svg';
  2215. smiley.className = 'smiley';
  2216. addClickFunction(smiley, i);
  2217. smileyContainer.appendChild(smiley);
  2218. smileysContainer.appendChild(smileyContainer);
  2219. }
  2220. $("#chatspace").append(smileysContainer);
  2221. }
  2222. /**
  2223. * Resizes the chat conversation.
  2224. */
  2225. function resizeChatConversation() {
  2226. var msgareaHeight = $('#usermsg').outerHeight();
  2227. var chatspace = $('#chatspace');
  2228. var width = chatspace.width();
  2229. var chat = $('#chatconversation');
  2230. var smileys = $('#smileysarea');
  2231. smileys.height(msgareaHeight);
  2232. $("#smileys").css('bottom', (msgareaHeight - 26) / 2);
  2233. $('#smileysContainer').css('bottom', msgareaHeight);
  2234. chat.width(width - 10);
  2235. chat.height(window.innerHeight - 15 - msgareaHeight);
  2236. }
  2237. /**
  2238. * Chat related user interface.
  2239. */
  2240. var Chat = (function (my) {
  2241. /**
  2242. * Initializes chat related interface.
  2243. */
  2244. my.init = function () {
  2245. if(NicknameHandler.getNickname())
  2246. Chat.setChatConversationMode(true);
  2247. NicknameHandler.addListener(UIEvents.NICKNAME_CHANGED,
  2248. function (nickname) {
  2249. Chat.setChatConversationMode(true);
  2250. });
  2251. $('#nickinput').keydown(function (event) {
  2252. if (event.keyCode === 13) {
  2253. event.preventDefault();
  2254. var val = UIUtil.escapeHtml(this.value);
  2255. this.value = '';
  2256. if (!NicknameHandler.getNickname()) {
  2257. NicknameHandler.setNickname(val);
  2258. return;
  2259. }
  2260. }
  2261. });
  2262. $('#usermsg').keydown(function (event) {
  2263. if (event.keyCode === 13) {
  2264. event.preventDefault();
  2265. var value = this.value;
  2266. $('#usermsg').val('').trigger('autosize.resize');
  2267. this.focus();
  2268. var command = new CommandsProcessor(value);
  2269. if(command.isCommand())
  2270. {
  2271. command.processCommand();
  2272. }
  2273. else
  2274. {
  2275. var message = UIUtil.escapeHtml(value);
  2276. xmpp.sendChatMessage(message, NicknameHandler.getNickname());
  2277. }
  2278. }
  2279. });
  2280. var onTextAreaResize = function () {
  2281. resizeChatConversation();
  2282. Chat.scrollChatToBottom();
  2283. };
  2284. $('#usermsg').autosize({callback: onTextAreaResize});
  2285. $("#chatspace").bind("shown",
  2286. function () {
  2287. unreadMessages = 0;
  2288. setVisualNotification(false);
  2289. });
  2290. addSmileys();
  2291. };
  2292. /**
  2293. * Appends the given message to the chat conversation.
  2294. */
  2295. my.updateChatConversation = function (from, displayName, message) {
  2296. var divClassName = '';
  2297. if (xmpp.myJid() === from) {
  2298. divClassName = "localuser";
  2299. }
  2300. else {
  2301. divClassName = "remoteuser";
  2302. if (!Chat.isVisible()) {
  2303. unreadMessages++;
  2304. UIUtil.playSoundNotification('chatNotification');
  2305. setVisualNotification(true);
  2306. }
  2307. }
  2308. // replace links and smileys
  2309. // Strophe already escapes special symbols on sending,
  2310. // so we escape here only tags to avoid double &amp;
  2311. var escMessage = message.replace(/</g, '&lt;').
  2312. replace(/>/g, '&gt;').replace(/\n/g, '<br/>');
  2313. var escDisplayName = UIUtil.escapeHtml(displayName);
  2314. message = Replacement.processReplacements(escMessage);
  2315. var messageContainer =
  2316. '<div class="chatmessage">'+
  2317. '<img src="../images/chatArrow.svg" class="chatArrow">' +
  2318. '<div class="username ' + divClassName +'">' + escDisplayName +
  2319. '</div>' + '<div class="timestamp">' + getCurrentTime() +
  2320. '</div>' + '<div class="usermessage">' + message + '</div>' +
  2321. '</div>';
  2322. $('#chatconversation').append(messageContainer);
  2323. $('#chatconversation').animate(
  2324. { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
  2325. };
  2326. /**
  2327. * Appends error message to the conversation
  2328. * @param errorMessage the received error message.
  2329. * @param originalText the original message.
  2330. */
  2331. my.chatAddError = function(errorMessage, originalText)
  2332. {
  2333. errorMessage = UIUtil.escapeHtml(errorMessage);
  2334. originalText = UIUtil.escapeHtml(originalText);
  2335. $('#chatconversation').append(
  2336. '<div class="errorMessage"><b>Error: </b>' + 'Your message' +
  2337. (originalText? (' \"'+ originalText + '\"') : "") +
  2338. ' was not sent.' +
  2339. (errorMessage? (' Reason: ' + errorMessage) : '') + '</div>');
  2340. $('#chatconversation').animate(
  2341. { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
  2342. };
  2343. /**
  2344. * Sets the subject to the UI
  2345. * @param subject the subject
  2346. */
  2347. my.chatSetSubject = function(subject)
  2348. {
  2349. if(subject)
  2350. subject = subject.trim();
  2351. $('#subject').html(Replacement.linkify(UIUtil.escapeHtml(subject)));
  2352. if(subject === "")
  2353. {
  2354. $("#subject").css({display: "none"});
  2355. }
  2356. else
  2357. {
  2358. $("#subject").css({display: "block"});
  2359. }
  2360. };
  2361. /**
  2362. * Sets the chat conversation mode.
  2363. */
  2364. my.setChatConversationMode = function (isConversationMode) {
  2365. if (isConversationMode) {
  2366. $('#nickname').css({visibility: 'hidden'});
  2367. $('#chatconversation').css({visibility: 'visible'});
  2368. $('#usermsg').css({visibility: 'visible'});
  2369. $('#smileysarea').css({visibility: 'visible'});
  2370. $('#usermsg').focus();
  2371. }
  2372. };
  2373. /**
  2374. * Resizes the chat area.
  2375. */
  2376. my.resizeChat = function () {
  2377. var chatSize = require("../SidePanelToggler").getPanelSize();
  2378. $('#chatspace').width(chatSize[0]);
  2379. $('#chatspace').height(chatSize[1]);
  2380. resizeChatConversation();
  2381. };
  2382. /**
  2383. * Indicates if the chat is currently visible.
  2384. */
  2385. my.isVisible = function () {
  2386. return $('#chatspace').is(":visible");
  2387. };
  2388. /**
  2389. * Shows and hides the window with the smileys
  2390. */
  2391. my.toggleSmileys = toggleSmileys;
  2392. /**
  2393. * Scrolls chat to the bottom.
  2394. */
  2395. my.scrollChatToBottom = function() {
  2396. setTimeout(function () {
  2397. $('#chatconversation').scrollTop(
  2398. $('#chatconversation')[0].scrollHeight);
  2399. }, 5);
  2400. };
  2401. return my;
  2402. }(Chat || {}));
  2403. module.exports = Chat;
  2404. },{"../../toolbars/ToolbarToggler":19,"../../util/NicknameHandler":22,"../../util/UIUtil":23,"../SidePanelToggler":9,"./Commands":11,"./Replacement":12,"./smileys.json":13}],11:[function(require,module,exports){
  2405. var UIUtil = require("../../util/UIUtil");
  2406. /**
  2407. * List with supported commands. The keys are the names of the commands and
  2408. * the value is the function that processes the message.
  2409. * @type {{String: function}}
  2410. */
  2411. var commands = {
  2412. "topic" : processTopic
  2413. };
  2414. /**
  2415. * Extracts the command from the message.
  2416. * @param message the received message
  2417. * @returns {string} the command
  2418. */
  2419. function getCommand(message)
  2420. {
  2421. if(message)
  2422. {
  2423. for(var command in commands)
  2424. {
  2425. if(message.indexOf("/" + command) == 0)
  2426. return command;
  2427. }
  2428. }
  2429. return "";
  2430. };
  2431. /**
  2432. * Processes the data for topic command.
  2433. * @param commandArguments the arguments of the topic command.
  2434. */
  2435. function processTopic(commandArguments)
  2436. {
  2437. var topic = UIUtil.escapeHtml(commandArguments);
  2438. xmpp.setSubject(topic);
  2439. }
  2440. /**
  2441. * Constructs new CommandProccessor instance from a message that
  2442. * handles commands received via chat messages.
  2443. * @param message the message
  2444. * @constructor
  2445. */
  2446. function CommandsProcessor(message)
  2447. {
  2448. var command = getCommand(message);
  2449. /**
  2450. * Returns the name of the command.
  2451. * @returns {String} the command
  2452. */
  2453. this.getCommand = function()
  2454. {
  2455. return command;
  2456. };
  2457. var messageArgument = message.substr(command.length + 2);
  2458. /**
  2459. * Returns the arguments of the command.
  2460. * @returns {string}
  2461. */
  2462. this.getArgument = function()
  2463. {
  2464. return messageArgument;
  2465. };
  2466. }
  2467. /**
  2468. * Checks whether this instance is valid command or not.
  2469. * @returns {boolean}
  2470. */
  2471. CommandsProcessor.prototype.isCommand = function()
  2472. {
  2473. if(this.getCommand())
  2474. return true;
  2475. return false;
  2476. };
  2477. /**
  2478. * Processes the command.
  2479. */
  2480. CommandsProcessor.prototype.processCommand = function()
  2481. {
  2482. if(!this.isCommand())
  2483. return;
  2484. commands[this.getCommand()](this.getArgument());
  2485. };
  2486. module.exports = CommandsProcessor;
  2487. },{"../../util/UIUtil":23}],12:[function(require,module,exports){
  2488. var Smileys = require("./smileys.json");
  2489. /**
  2490. * Processes links and smileys in "body"
  2491. */
  2492. function processReplacements(body)
  2493. {
  2494. //make links clickable
  2495. body = linkify(body);
  2496. //add smileys
  2497. body = smilify(body);
  2498. return body;
  2499. }
  2500. /**
  2501. * Finds and replaces all links in the links in "body"
  2502. * with their <a href=""></a>
  2503. */
  2504. function linkify(inputText)
  2505. {
  2506. var replacedText, replacePattern1, replacePattern2, replacePattern3;
  2507. //URLs starting with http://, https://, or ftp://
  2508. replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
  2509. replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1</a>');
  2510. //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
  2511. replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
  2512. replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');
  2513. //Change email addresses to mailto:: links.
  2514. replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
  2515. replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
  2516. return replacedText;
  2517. }
  2518. /**
  2519. * Replaces common smiley strings with images
  2520. */
  2521. function smilify(body)
  2522. {
  2523. if(!body) {
  2524. return body;
  2525. }
  2526. var regexs = Smileys["regexs"];
  2527. for(var smiley in regexs) {
  2528. if(regexs.hasOwnProperty(smiley)) {
  2529. body = body.replace(regexs[smiley],
  2530. '<img class="smiley" src="images/smileys/' + smiley + '.svg">');
  2531. }
  2532. }
  2533. return body;
  2534. }
  2535. module.exports = {
  2536. processReplacements: processReplacements,
  2537. linkify: linkify
  2538. };
  2539. },{"./smileys.json":13}],13:[function(require,module,exports){
  2540. module.exports={
  2541. "smileys": {
  2542. "smiley1": ":)",
  2543. "smiley2": ":(",
  2544. "smiley3": ":D",
  2545. "smiley4": "(y)",
  2546. "smiley5": " :P",
  2547. "smiley6": "(wave)",
  2548. "smiley7": "(blush)",
  2549. "smiley8": "(chuckle)",
  2550. "smiley9": "(shocked)",
  2551. "smiley10": ":*",
  2552. "smiley11": "(n)",
  2553. "smiley12": "(search)",
  2554. "smiley13": " <3",
  2555. "smiley14": "(oops)",
  2556. "smiley15": "(angry)",
  2557. "smiley16": "(angel)",
  2558. "smiley17": "(sick)",
  2559. "smiley18": ";(",
  2560. "smiley19": "(bomb)",
  2561. "smiley20": "(clap)",
  2562. "smiley21": " ;)"
  2563. },
  2564. "regexs": {
  2565. "smiley2": /(:-\(\(|:-\(|:\(\(|:\(|\(sad\))/gi,
  2566. "smiley3": /(:-\)\)|:\)\)|\(lol\)|:-D|:D)/gi,
  2567. "smiley1": /(:-\)|:\))/gi,
  2568. "smiley4": /(\(y\)|\(Y\)|\(ok\))/gi,
  2569. "smiley5": /(:-P|:P|:-p|:p)/gi,
  2570. "smiley6": /(\(wave\))/gi,
  2571. "smiley7": /(\(blush\))/gi,
  2572. "smiley8": /(\(chuckle\))/gi,
  2573. "smiley9": /(:-0|\(shocked\))/gi,
  2574. "smiley10": /(:-\*|:\*|\(kiss\))/gi,
  2575. "smiley11": /(\(n\))/gi,
  2576. "smiley12": /(\(search\))/g,
  2577. "smiley13": /(<3|&lt;3|&amp;lt;3|\(L\)|\(l\)|\(H\)|\(h\))/gi,
  2578. "smiley14": /(\(oops\))/gi,
  2579. "smiley15": /(\(angry\))/gi,
  2580. "smiley16": /(\(angel\))/gi,
  2581. "smiley17": /(\(sick\))/gi,
  2582. "smiley18": /(;-\(\(|;\(\(|;-\(|;\(|:"\(|:"-\(|:~-\(|:~\(|\(upset\))/gi,
  2583. "smiley19": /(\(bomb\))/gi,
  2584. "smiley20": /(\(clap\))/gi,
  2585. "smiley21": /(;-\)|;\)|;-\)\)|;\)\)|;-D|;D|\(wink\))/gi
  2586. }
  2587. }
  2588. },{}],14:[function(require,module,exports){
  2589. var numberOfContacts = 0;
  2590. var notificationInterval;
  2591. /**
  2592. * Updates the number of participants in the contact list button and sets
  2593. * the glow
  2594. * @param delta indicates whether a new user has joined (1) or someone has
  2595. * left(-1)
  2596. */
  2597. function updateNumberOfParticipants(delta) {
  2598. //when the user is alone we don't show the number of participants
  2599. if(numberOfContacts === 0) {
  2600. $("#numberOfParticipants").text('');
  2601. numberOfContacts += delta;
  2602. } else if(numberOfContacts !== 0 && !ContactList.isVisible()) {
  2603. ContactList.setVisualNotification(true);
  2604. numberOfContacts += delta;
  2605. $("#numberOfParticipants").text(numberOfContacts);
  2606. }
  2607. }
  2608. /**
  2609. * Creates the avatar element.
  2610. *
  2611. * @return the newly created avatar element
  2612. */
  2613. function createAvatar(id) {
  2614. var avatar = document.createElement('img');
  2615. avatar.className = "icon-avatar avatar";
  2616. avatar.src = "https://www.gravatar.com/avatar/" + id + "?d=wavatar&size=30";
  2617. return avatar;
  2618. }
  2619. /**
  2620. * Creates the display name paragraph.
  2621. *
  2622. * @param displayName the display name to set
  2623. */
  2624. function createDisplayNameParagraph(displayName) {
  2625. var p = document.createElement('p');
  2626. p.innerText = displayName;
  2627. return p;
  2628. }
  2629. function stopGlowing(glower) {
  2630. window.clearInterval(notificationInterval);
  2631. notificationInterval = false;
  2632. glower.removeClass('glowing');
  2633. if (!ContactList.isVisible()) {
  2634. glower.removeClass('active');
  2635. }
  2636. }
  2637. /**
  2638. * Contact list.
  2639. */
  2640. var ContactList = {
  2641. /**
  2642. * Indicates if the chat is currently visible.
  2643. *
  2644. * @return <tt>true</tt> if the chat is currently visible, <tt>false</tt> -
  2645. * otherwise
  2646. */
  2647. isVisible: function () {
  2648. return $('#contactlist').is(":visible");
  2649. },
  2650. /**
  2651. * Adds a contact for the given peerJid if such doesn't yet exist.
  2652. *
  2653. * @param peerJid the peerJid corresponding to the contact
  2654. * @param id the user's email or userId used to get the user's avatar
  2655. */
  2656. ensureAddContact: function (peerJid, id) {
  2657. var resourceJid = Strophe.getResourceFromJid(peerJid);
  2658. var contact = $('#contactlist>ul>li[id="' + resourceJid + '"]');
  2659. if (!contact || contact.length <= 0)
  2660. ContactList.addContact(peerJid, id);
  2661. },
  2662. /**
  2663. * Adds a contact for the given peer jid.
  2664. *
  2665. * @param peerJid the jid of the contact to add
  2666. * @param id the email or userId of the user
  2667. */
  2668. addContact: function (peerJid, id) {
  2669. var resourceJid = Strophe.getResourceFromJid(peerJid);
  2670. var contactlist = $('#contactlist>ul');
  2671. var newContact = document.createElement('li');
  2672. newContact.id = resourceJid;
  2673. newContact.className = "clickable";
  2674. newContact.onclick = function (event) {
  2675. if (event.currentTarget.className === "clickable") {
  2676. $(ContactList).trigger('contactclicked', [peerJid]);
  2677. }
  2678. };
  2679. newContact.appendChild(createAvatar(id));
  2680. newContact.appendChild(createDisplayNameParagraph("Participant"));
  2681. var clElement = contactlist.get(0);
  2682. if (resourceJid === xmpp.myResource()
  2683. && $('#contactlist>ul .title')[0].nextSibling.nextSibling) {
  2684. clElement.insertBefore(newContact,
  2685. $('#contactlist>ul .title')[0].nextSibling.nextSibling);
  2686. }
  2687. else {
  2688. clElement.appendChild(newContact);
  2689. }
  2690. updateNumberOfParticipants(1);
  2691. },
  2692. /**
  2693. * Removes a contact for the given peer jid.
  2694. *
  2695. * @param peerJid the peerJid corresponding to the contact to remove
  2696. */
  2697. removeContact: function (peerJid) {
  2698. var resourceJid = Strophe.getResourceFromJid(peerJid);
  2699. var contact = $('#contactlist>ul>li[id="' + resourceJid + '"]');
  2700. if (contact && contact.length > 0) {
  2701. var contactlist = $('#contactlist>ul');
  2702. contactlist.get(0).removeChild(contact.get(0));
  2703. updateNumberOfParticipants(-1);
  2704. }
  2705. },
  2706. setVisualNotification: function (show, stopGlowingIn) {
  2707. var glower = $('#contactListButton');
  2708. if (show && !notificationInterval) {
  2709. notificationInterval = window.setInterval(function () {
  2710. glower.toggleClass('active glowing');
  2711. }, 800);
  2712. }
  2713. else if (!show && notificationInterval) {
  2714. stopGlowing(glower);
  2715. }
  2716. if (stopGlowingIn) {
  2717. setTimeout(function () {
  2718. stopGlowing(glower);
  2719. }, stopGlowingIn);
  2720. }
  2721. },
  2722. setClickable: function (resourceJid, isClickable) {
  2723. var contact = $('#contactlist>ul>li[id="' + resourceJid + '"]');
  2724. if (isClickable) {
  2725. contact.addClass('clickable');
  2726. } else {
  2727. contact.removeClass('clickable');
  2728. }
  2729. },
  2730. onDisplayNameChange: function (peerJid, displayName) {
  2731. if (peerJid === 'localVideoContainer')
  2732. peerJid = xmpp.myJid();
  2733. var resourceJid = Strophe.getResourceFromJid(peerJid);
  2734. var contactName = $('#contactlist #' + resourceJid + '>p');
  2735. if (contactName && displayName && displayName.length > 0)
  2736. contactName.html(displayName);
  2737. }
  2738. };
  2739. module.exports = ContactList;
  2740. },{}],15:[function(require,module,exports){
  2741. var email = '';
  2742. var displayName = '';
  2743. var userId;
  2744. function supportsLocalStorage() {
  2745. try {
  2746. return 'localStorage' in window && window.localStorage !== null;
  2747. } catch (e) {
  2748. console.log("localstorage is not supported");
  2749. return false;
  2750. }
  2751. }
  2752. function generateUniqueId() {
  2753. function _p8() {
  2754. return (Math.random().toString(16)+"000000000").substr(2,8);
  2755. }
  2756. return _p8() + _p8() + _p8() + _p8();
  2757. }
  2758. if(supportsLocalStorage()) {
  2759. if(!window.localStorage.jitsiMeetId) {
  2760. window.localStorage.jitsiMeetId = generateUniqueId();
  2761. console.log("generated id", window.localStorage.jitsiMeetId);
  2762. }
  2763. userId = window.localStorage.jitsiMeetId || '';
  2764. email = window.localStorage.email || '';
  2765. displayName = window.localStorage.displayname || '';
  2766. } else {
  2767. console.log("local storage is not supported");
  2768. userId = generateUniqueId();
  2769. }
  2770. var Settings =
  2771. {
  2772. setDisplayName: function (newDisplayName) {
  2773. displayName = newDisplayName;
  2774. window.localStorage.displayname = displayName;
  2775. return displayName;
  2776. },
  2777. setEmail: function(newEmail)
  2778. {
  2779. email = newEmail;
  2780. window.localStorage.email = newEmail;
  2781. return email;
  2782. },
  2783. getSettings: function () {
  2784. return {
  2785. email: email,
  2786. displayName: displayName,
  2787. uid: userId
  2788. };
  2789. }
  2790. };
  2791. module.exports = Settings;
  2792. },{}],16:[function(require,module,exports){
  2793. var Avatar = require("../../avatar/Avatar");
  2794. var Settings = require("./Settings");
  2795. var UIUtil = require("../../util/UIUtil");
  2796. var SettingsMenu = {
  2797. update: function() {
  2798. var newDisplayName = UIUtil.escapeHtml($('#setDisplayName').get(0).value);
  2799. var newEmail = UIUtil.escapeHtml($('#setEmail').get(0).value);
  2800. if(newDisplayName) {
  2801. var displayName = Settings.setDisplayName(newDisplayName);
  2802. xmpp.addToPresence("displayName", displayName, true);
  2803. }
  2804. xmpp.addToPresence("email", newEmail);
  2805. var email = Settings.setEmail(newEmail);
  2806. Avatar.setUserAvatar(xmpp.myJid(), email);
  2807. },
  2808. isVisible: function() {
  2809. return $('#settingsmenu').is(':visible');
  2810. },
  2811. setDisplayName: function(newDisplayName) {
  2812. var displayName = Settings.setDisplayName(newDisplayName);
  2813. $('#setDisplayName').get(0).value = displayName;
  2814. },
  2815. onDisplayNameChange: function(peerJid, newDisplayName) {
  2816. if(peerJid === 'localVideoContainer' ||
  2817. peerJid === xmpp.myJid()) {
  2818. this.setDisplayName(newDisplayName);
  2819. }
  2820. }
  2821. };
  2822. module.exports = SettingsMenu;
  2823. },{"../../avatar/Avatar":5,"../../util/UIUtil":23,"./Settings":15}],17:[function(require,module,exports){
  2824. var PanelToggler = require("../side_pannels/SidePanelToggler");
  2825. var buttonHandlers = {
  2826. "bottom_toolbar_contact_list": function () {
  2827. BottomToolbar.toggleContactList();
  2828. },
  2829. "bottom_toolbar_film_strip": function () {
  2830. BottomToolbar.toggleFilmStrip();
  2831. },
  2832. "bottom_toolbar_chat": function () {
  2833. BottomToolbar.toggleChat();
  2834. }
  2835. };
  2836. var BottomToolbar = (function (my) {
  2837. my.init = function () {
  2838. for(var k in buttonHandlers)
  2839. $("#" + k).click(buttonHandlers[k]);
  2840. };
  2841. my.toggleChat = function() {
  2842. PanelToggler.toggleChat();
  2843. };
  2844. my.toggleContactList = function() {
  2845. PanelToggler.toggleContactList();
  2846. };
  2847. my.toggleFilmStrip = function() {
  2848. var filmstrip = $("#remoteVideos");
  2849. filmstrip.toggleClass("hidden");
  2850. };
  2851. $(document).bind("remotevideo.resized", function (event, width, height) {
  2852. var bottom = (height - $('#bottomToolbar').outerHeight())/2 + 18;
  2853. $('#bottomToolbar').css({bottom: bottom + 'px'});
  2854. });
  2855. return my;
  2856. }(BottomToolbar || {}));
  2857. module.exports = BottomToolbar;
  2858. },{"../side_pannels/SidePanelToggler":9}],18:[function(require,module,exports){
  2859. /* global $, buttonClick, config, lockRoom,
  2860. setSharedKey, Util */
  2861. var messageHandler = require("../util/MessageHandler");
  2862. var BottomToolbar = require("./BottomToolbar");
  2863. var Prezi = require("../prezi/Prezi");
  2864. var Etherpad = require("../etherpad/Etherpad");
  2865. var PanelToggler = require("../side_pannels/SidePanelToggler");
  2866. var Authentication = require("../authentication/Authentication");
  2867. var UIUtil = require("../util/UIUtil");
  2868. var roomUrl = null;
  2869. var sharedKey = '';
  2870. var UI = null;
  2871. var buttonHandlers =
  2872. {
  2873. "toolbar_button_mute": function () {
  2874. return UI.toggleAudio();
  2875. },
  2876. "toolbar_button_camera": function () {
  2877. return UI.toggleVideo();
  2878. },
  2879. "toolbar_button_authentication": function () {
  2880. return Toolbar.authenticateClicked();
  2881. },
  2882. "toolbar_button_record": function () {
  2883. return toggleRecording();
  2884. },
  2885. "toolbar_button_security": function () {
  2886. return Toolbar.openLockDialog();
  2887. },
  2888. "toolbar_button_link": function () {
  2889. return Toolbar.openLinkDialog();
  2890. },
  2891. "toolbar_button_chat": function () {
  2892. return BottomToolbar.toggleChat();
  2893. },
  2894. "toolbar_button_prezi": function () {
  2895. return Prezi.openPreziDialog();
  2896. },
  2897. "toolbar_button_etherpad": function () {
  2898. return Etherpad.toggleEtherpad(0);
  2899. },
  2900. "toolbar_button_desktopsharing": function () {
  2901. return desktopsharing.toggleScreenSharing();
  2902. },
  2903. "toolbar_button_fullScreen": function()
  2904. {
  2905. UIUtil.buttonClick("#fullScreen", "icon-full-screen icon-exit-full-screen");
  2906. return Toolbar.toggleFullScreen();
  2907. },
  2908. "toolbar_button_sip": function () {
  2909. return callSipButtonClicked();
  2910. },
  2911. "toolbar_button_settings": function () {
  2912. PanelToggler.toggleSettingsMenu();
  2913. },
  2914. "toolbar_button_hangup": function () {
  2915. return hangup();
  2916. }
  2917. };
  2918. function hangup() {
  2919. xmpp.disposeConference();
  2920. if(config.enableWelcomePage)
  2921. {
  2922. setTimeout(function()
  2923. {
  2924. window.localStorage.welcomePageDisabled = false;
  2925. window.location.pathname = "/";
  2926. }, 10000);
  2927. }
  2928. UI.messageHandler.openDialog(
  2929. "Session Terminated",
  2930. "You hung up the call",
  2931. true,
  2932. { "Join again": true },
  2933. function(event, value, message, formVals)
  2934. {
  2935. window.location.reload();
  2936. return false;
  2937. }
  2938. );
  2939. }
  2940. /**
  2941. * Starts or stops the recording for the conference.
  2942. */
  2943. function toggleRecording() {
  2944. xmpp.toggleRecording(function (callback) {
  2945. UI.messageHandler.openTwoButtonDialog(null,
  2946. '<h2>Enter recording token</h2>' +
  2947. '<input id="recordingToken" type="text" ' +
  2948. 'placeholder="token" autofocus>',
  2949. false,
  2950. "Save",
  2951. function (e, v, m, f) {
  2952. if (v) {
  2953. var token = document.getElementById('recordingToken');
  2954. if (token.value) {
  2955. callback(UIUtil.escapeHtml(token.value));
  2956. }
  2957. }
  2958. },
  2959. function (event) {
  2960. document.getElementById('recordingToken').focus();
  2961. },
  2962. function () {
  2963. }
  2964. );
  2965. }, Toolbar.setRecordingButtonState, Toolbar.setRecordingButtonState);
  2966. }
  2967. /**
  2968. * Locks / unlocks the room.
  2969. */
  2970. function lockRoom(lock) {
  2971. var currentSharedKey = '';
  2972. if (lock)
  2973. currentSharedKey = sharedKey;
  2974. xmpp.lockRoom(currentSharedKey, function (res) {
  2975. // password is required
  2976. if (sharedKey)
  2977. {
  2978. console.log('set room password');
  2979. Toolbar.lockLockButton();
  2980. }
  2981. else
  2982. {
  2983. console.log('removed room password');
  2984. Toolbar.unlockLockButton();
  2985. }
  2986. }, function (err) {
  2987. console.warn('setting password failed', err);
  2988. messageHandler.showError('Lock failed',
  2989. 'Failed to lock conference.',
  2990. err);
  2991. Toolbar.setSharedKey('');
  2992. }, function () {
  2993. console.warn('room passwords not supported');
  2994. messageHandler.showError('Warning',
  2995. 'Room passwords are currently not supported.');
  2996. Toolbar.setSharedKey('');
  2997. });
  2998. };
  2999. /**
  3000. * Invite participants to conference.
  3001. */
  3002. function inviteParticipants() {
  3003. if (roomUrl === null)
  3004. return;
  3005. var sharedKeyText = "";
  3006. if (sharedKey && sharedKey.length > 0) {
  3007. sharedKeyText =
  3008. "This conference is password protected. Please use the " +
  3009. "following pin when joining:%0D%0A%0D%0A" +
  3010. sharedKey + "%0D%0A%0D%0A";
  3011. }
  3012. var conferenceName = roomUrl.substring(roomUrl.lastIndexOf('/') + 1);
  3013. var subject = "Invitation to a " + interfaceConfig.APP_NAME + " (" + conferenceName + ")";
  3014. var body = "Hey there, I%27d like to invite you to a " + interfaceConfig.APP_NAME +
  3015. " conference I%27ve just set up.%0D%0A%0D%0A" +
  3016. "Please click on the following link in order" +
  3017. " to join the conference.%0D%0A%0D%0A" +
  3018. roomUrl +
  3019. "%0D%0A%0D%0A" +
  3020. sharedKeyText +
  3021. "Note that " + interfaceConfig.APP_NAME + " is currently" +
  3022. " only supported by Chromium," +
  3023. " Google Chrome and Opera, so you need" +
  3024. " to be using one of these browsers.%0D%0A%0D%0A" +
  3025. "Talk to you in a sec!";
  3026. if (window.localStorage.displayname) {
  3027. body += "%0D%0A%0D%0A" + window.localStorage.displayname;
  3028. }
  3029. if (interfaceConfig.INVITATION_POWERED_BY) {
  3030. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  3031. }
  3032. window.open("mailto:?subject=" + subject + "&body=" + body, '_blank');
  3033. }
  3034. function callSipButtonClicked()
  3035. {
  3036. var defaultNumber
  3037. = config.defaultSipNumber ? config.defaultSipNumber : '';
  3038. messageHandler.openTwoButtonDialog(null,
  3039. '<h2>Enter SIP number</h2>' +
  3040. '<input id="sipNumber" type="text"' +
  3041. ' value="' + defaultNumber + '" autofocus>',
  3042. false,
  3043. "Dial",
  3044. function (e, v, m, f) {
  3045. if (v) {
  3046. var numberInput = document.getElementById('sipNumber');
  3047. if (numberInput.value) {
  3048. xmpp.dial(numberInput.value, 'fromnumber',
  3049. UI.getRoomName(), sharedKey);
  3050. }
  3051. }
  3052. },
  3053. function (event) {
  3054. document.getElementById('sipNumber').focus();
  3055. }
  3056. );
  3057. }
  3058. var Toolbar = (function (my) {
  3059. my.init = function (ui) {
  3060. for(var k in buttonHandlers)
  3061. $("#" + k).click(buttonHandlers[k]);
  3062. UI = ui;
  3063. }
  3064. /**
  3065. * Sets shared key
  3066. * @param sKey the shared key
  3067. */
  3068. my.setSharedKey = function (sKey) {
  3069. sharedKey = sKey;
  3070. };
  3071. my.authenticateClicked = function () {
  3072. Authentication.focusAuthenticationWindow();
  3073. // Get authentication URL
  3074. xmpp.getAuthUrl(UI.getRoomName(), function (url) {
  3075. // Open popup with authentication URL
  3076. var authenticationWindow = Authentication.createAuthenticationWindow(function () {
  3077. // On popup closed - retry room allocation
  3078. xmpp.allocateConferenceFocus(UI.getRoomName(), UI.checkForNicknameAndJoin);
  3079. }, url);
  3080. if (!authenticationWindow) {
  3081. Toolbar.showAuthenticateButton(true);
  3082. messageHandler.openMessageDialog(
  3083. null, "Your browser is blocking popup windows from this site." +
  3084. " Please enable popups in your browser security settings" +
  3085. " and try again.");
  3086. }
  3087. });
  3088. };
  3089. /**
  3090. * Updates the room invite url.
  3091. */
  3092. my.updateRoomUrl = function (newRoomUrl) {
  3093. roomUrl = newRoomUrl;
  3094. // If the invite dialog has been already opened we update the information.
  3095. var inviteLink = document.getElementById('inviteLinkRef');
  3096. if (inviteLink) {
  3097. inviteLink.value = roomUrl;
  3098. inviteLink.select();
  3099. document.getElementById('jqi_state0_buttonInvite').disabled = false;
  3100. }
  3101. };
  3102. /**
  3103. * Disables and enables some of the buttons.
  3104. */
  3105. my.setupButtonsFromConfig = function () {
  3106. if (config.disablePrezi)
  3107. {
  3108. $("#prezi_button").css({display: "none"});
  3109. }
  3110. };
  3111. /**
  3112. * Opens the lock room dialog.
  3113. */
  3114. my.openLockDialog = function () {
  3115. // Only the focus is able to set a shared key.
  3116. if (!xmpp.isModerator()) {
  3117. if (sharedKey) {
  3118. messageHandler.openMessageDialog(null,
  3119. "This conversation is currently protected by" +
  3120. " a password. Only the owner of the conference" +
  3121. " could set a password.",
  3122. false,
  3123. "Password");
  3124. } else {
  3125. messageHandler.openMessageDialog(null,
  3126. "This conversation isn't currently protected by" +
  3127. " a password. Only the owner of the conference" +
  3128. " could set a password.",
  3129. false,
  3130. "Password");
  3131. }
  3132. } else {
  3133. if (sharedKey) {
  3134. messageHandler.openTwoButtonDialog(null,
  3135. "Are you sure you would like to remove your password?",
  3136. false,
  3137. "Remove",
  3138. function (e, v) {
  3139. if (v) {
  3140. Toolbar.setSharedKey('');
  3141. lockRoom(false);
  3142. }
  3143. });
  3144. } else {
  3145. messageHandler.openTwoButtonDialog(null,
  3146. '<h2>Set a password to lock your room</h2>' +
  3147. '<input id="lockKey" type="text"' +
  3148. 'placeholder="your password" autofocus>',
  3149. false,
  3150. "Save",
  3151. function (e, v) {
  3152. if (v) {
  3153. var lockKey = document.getElementById('lockKey');
  3154. if (lockKey.value) {
  3155. Toolbar.setSharedKey(UIUtil.escapeHtml(lockKey.value));
  3156. lockRoom(true);
  3157. }
  3158. }
  3159. },
  3160. function () {
  3161. document.getElementById('lockKey').focus();
  3162. }
  3163. );
  3164. }
  3165. }
  3166. };
  3167. /**
  3168. * Opens the invite link dialog.
  3169. */
  3170. my.openLinkDialog = function () {
  3171. var inviteLink;
  3172. if (roomUrl === null) {
  3173. inviteLink = "Your conference is currently being created...";
  3174. } else {
  3175. inviteLink = encodeURI(roomUrl);
  3176. }
  3177. messageHandler.openTwoButtonDialog(
  3178. "Share this link with everyone you want to invite",
  3179. '<input id="inviteLinkRef" type="text" value="' +
  3180. inviteLink + '" onclick="this.select();" readonly>',
  3181. false,
  3182. "Invite",
  3183. function (e, v) {
  3184. if (v) {
  3185. if (roomUrl) {
  3186. inviteParticipants();
  3187. }
  3188. }
  3189. },
  3190. function () {
  3191. if (roomUrl) {
  3192. document.getElementById('inviteLinkRef').select();
  3193. } else {
  3194. document.getElementById('jqi_state0_buttonInvite')
  3195. .disabled = true;
  3196. }
  3197. }
  3198. );
  3199. };
  3200. /**
  3201. * Opens the settings dialog.
  3202. */
  3203. my.openSettingsDialog = function () {
  3204. messageHandler.openTwoButtonDialog(
  3205. '<h2>Configure your conference</h2>' +
  3206. '<input type="checkbox" id="initMuted">' +
  3207. 'Participants join muted<br/>' +
  3208. '<input type="checkbox" id="requireNicknames">' +
  3209. 'Require nicknames<br/><br/>' +
  3210. 'Set a password to lock your room:' +
  3211. '<input id="lockKey" type="text" placeholder="your password"' +
  3212. 'autofocus>',
  3213. null,
  3214. false,
  3215. "Save",
  3216. function () {
  3217. document.getElementById('lockKey').focus();
  3218. },
  3219. function (e, v) {
  3220. if (v) {
  3221. if ($('#initMuted').is(":checked")) {
  3222. // it is checked
  3223. }
  3224. if ($('#requireNicknames').is(":checked")) {
  3225. // it is checked
  3226. }
  3227. /*
  3228. var lockKey = document.getElementById('lockKey');
  3229. if (lockKey.value) {
  3230. setSharedKey(lockKey.value);
  3231. lockRoom(true);
  3232. }
  3233. */
  3234. }
  3235. }
  3236. );
  3237. };
  3238. /**
  3239. * Toggles the application in and out of full screen mode
  3240. * (a.k.a. presentation mode in Chrome).
  3241. */
  3242. my.toggleFullScreen = function () {
  3243. var fsElement = document.documentElement;
  3244. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  3245. //Enter Full Screen
  3246. if (fsElement.mozRequestFullScreen) {
  3247. fsElement.mozRequestFullScreen();
  3248. }
  3249. else {
  3250. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  3251. }
  3252. } else {
  3253. //Exit Full Screen
  3254. if (document.mozCancelFullScreen) {
  3255. document.mozCancelFullScreen();
  3256. } else {
  3257. document.webkitCancelFullScreen();
  3258. }
  3259. }
  3260. };
  3261. /**
  3262. * Unlocks the lock button state.
  3263. */
  3264. my.unlockLockButton = function () {
  3265. if ($("#lockIcon").hasClass("icon-security-locked"))
  3266. UIUtil.buttonClick("#lockIcon", "icon-security icon-security-locked");
  3267. };
  3268. /**
  3269. * Updates the lock button state to locked.
  3270. */
  3271. my.lockLockButton = function () {
  3272. if ($("#lockIcon").hasClass("icon-security"))
  3273. UIUtil.buttonClick("#lockIcon", "icon-security icon-security-locked");
  3274. };
  3275. /**
  3276. * Shows or hides authentication button
  3277. * @param show <tt>true</tt> to show or <tt>false</tt> to hide
  3278. */
  3279. my.showAuthenticateButton = function (show) {
  3280. if (show) {
  3281. $('#authentication').css({display: "inline"});
  3282. }
  3283. else {
  3284. $('#authentication').css({display: "none"});
  3285. }
  3286. };
  3287. // Shows or hides the 'recording' button.
  3288. my.showRecordingButton = function (show) {
  3289. if (!config.enableRecording) {
  3290. return;
  3291. }
  3292. if (show) {
  3293. $('#recording').css({display: "inline"});
  3294. }
  3295. else {
  3296. $('#recording').css({display: "none"});
  3297. }
  3298. };
  3299. // Sets the state of the recording button
  3300. my.setRecordingButtonState = function (isRecording) {
  3301. if (isRecording) {
  3302. $('#recordButton').removeClass("icon-recEnable");
  3303. $('#recordButton').addClass("icon-recEnable active");
  3304. } else {
  3305. $('#recordButton').removeClass("icon-recEnable active");
  3306. $('#recordButton').addClass("icon-recEnable");
  3307. }
  3308. };
  3309. // Shows or hides SIP calls button
  3310. my.showSipCallButton = function (show) {
  3311. if (xmpp.isSipGatewayEnabled() && show) {
  3312. $('#sipCallButton').css({display: "inline"});
  3313. } else {
  3314. $('#sipCallButton').css({display: "none"});
  3315. }
  3316. };
  3317. /**
  3318. * Sets the state of the button. The button has blue glow if desktop
  3319. * streaming is active.
  3320. * @param active the state of the desktop streaming.
  3321. */
  3322. my.changeDesktopSharingButtonState = function (active) {
  3323. var button = $("#desktopsharing > a");
  3324. if (active)
  3325. {
  3326. button.addClass("glow");
  3327. }
  3328. else
  3329. {
  3330. button.removeClass("glow");
  3331. }
  3332. };
  3333. return my;
  3334. }(Toolbar || {}));
  3335. module.exports = Toolbar;
  3336. },{"../authentication/Authentication":4,"../etherpad/Etherpad":6,"../prezi/Prezi":7,"../side_pannels/SidePanelToggler":9,"../util/MessageHandler":21,"../util/UIUtil":23,"./BottomToolbar":17}],19:[function(require,module,exports){
  3337. /* global $, interfaceConfig, Moderator, DesktopStreaming.showDesktopSharingButton */
  3338. var toolbarTimeoutObject,
  3339. toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  3340. function showDesktopSharingButton() {
  3341. if (desktopsharing.isDesktopSharingEnabled()) {
  3342. $('#desktopsharing').css({display: "inline"});
  3343. } else {
  3344. $('#desktopsharing').css({display: "none"});
  3345. }
  3346. }
  3347. /**
  3348. * Hides the toolbar.
  3349. */
  3350. function hideToolbar() {
  3351. var header = $("#header"),
  3352. bottomToolbar = $("#bottomToolbar");
  3353. var isToolbarHover = false;
  3354. header.find('*').each(function () {
  3355. var id = $(this).attr('id');
  3356. if ($("#" + id + ":hover").length > 0) {
  3357. isToolbarHover = true;
  3358. }
  3359. });
  3360. if ($("#bottomToolbar:hover").length > 0) {
  3361. isToolbarHover = true;
  3362. }
  3363. clearTimeout(toolbarTimeoutObject);
  3364. toolbarTimeoutObject = null;
  3365. if (!isToolbarHover) {
  3366. header.hide("slide", { direction: "up", duration: 300});
  3367. $('#subject').animate({top: "-=40"}, 300);
  3368. if ($("#remoteVideos").hasClass("hidden")) {
  3369. bottomToolbar.hide(
  3370. "slide", {direction: "right", duration: 300});
  3371. }
  3372. }
  3373. else {
  3374. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  3375. }
  3376. }
  3377. var ToolbarToggler = {
  3378. /**
  3379. * Shows the main toolbar.
  3380. */
  3381. showToolbar: function () {
  3382. var header = $("#header"),
  3383. bottomToolbar = $("#bottomToolbar");
  3384. if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
  3385. header.show("slide", { direction: "up", duration: 300});
  3386. $('#subject').animate({top: "+=40"}, 300);
  3387. if (!bottomToolbar.is(":visible")) {
  3388. bottomToolbar.show(
  3389. "slide", {direction: "right", duration: 300});
  3390. }
  3391. if (toolbarTimeoutObject) {
  3392. clearTimeout(toolbarTimeoutObject);
  3393. toolbarTimeoutObject = null;
  3394. }
  3395. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  3396. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  3397. }
  3398. if (xmpp.isModerator())
  3399. {
  3400. // TODO: Enable settings functionality.
  3401. // Need to uncomment the settings button in index.html.
  3402. // $('#settingsButton').css({visibility:"visible"});
  3403. }
  3404. // Show/hide desktop sharing button
  3405. showDesktopSharingButton();
  3406. },
  3407. /**
  3408. * Docks/undocks the toolbar.
  3409. *
  3410. * @param isDock indicates what operation to perform
  3411. */
  3412. dockToolbar: function (isDock) {
  3413. if (isDock) {
  3414. // First make sure the toolbar is shown.
  3415. if (!$('#header').is(':visible')) {
  3416. this.showToolbar();
  3417. }
  3418. // Then clear the time out, to dock the toolbar.
  3419. if (toolbarTimeoutObject) {
  3420. clearTimeout(toolbarTimeoutObject);
  3421. toolbarTimeoutObject = null;
  3422. }
  3423. }
  3424. else {
  3425. if (!$('#header').is(':visible')) {
  3426. this.showToolbar();
  3427. }
  3428. else {
  3429. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  3430. }
  3431. }
  3432. },
  3433. showDesktopSharingButton: showDesktopSharingButton
  3434. };
  3435. module.exports = ToolbarToggler;
  3436. },{}],20:[function(require,module,exports){
  3437. var JitsiPopover = (function () {
  3438. /**
  3439. * Constructs new JitsiPopover and attaches it to the element
  3440. * @param element jquery selector
  3441. * @param options the options for the popover.
  3442. * @constructor
  3443. */
  3444. function JitsiPopover(element, options)
  3445. {
  3446. this.options = {
  3447. skin: "white",
  3448. content: ""
  3449. };
  3450. if(options)
  3451. {
  3452. if(options.skin)
  3453. this.options.skin = options.skin;
  3454. if(options.content)
  3455. this.options.content = options.content;
  3456. }
  3457. this.elementIsHovered = false;
  3458. this.popoverIsHovered = false;
  3459. this.popoverShown = false;
  3460. element.data("jitsi_popover", this);
  3461. this.element = element;
  3462. this.template = ' <div class="jitsipopover ' + this.options.skin +
  3463. '"><div class="arrow"></div><div class="jitsipopover-content"></div>' +
  3464. '<div class="jitsiPopupmenuPadding"></div></div>';
  3465. var self = this;
  3466. this.element.on("mouseenter", function () {
  3467. self.elementIsHovered = true;
  3468. self.show();
  3469. }).on("mouseleave", function () {
  3470. self.elementIsHovered = false;
  3471. setTimeout(function () {
  3472. self.hide();
  3473. }, 10);
  3474. });
  3475. }
  3476. /**
  3477. * Shows the popover
  3478. */
  3479. JitsiPopover.prototype.show = function () {
  3480. this.createPopover();
  3481. this.popoverShown = true;
  3482. };
  3483. /**
  3484. * Hides the popover
  3485. */
  3486. JitsiPopover.prototype.hide = function () {
  3487. if(!this.elementIsHovered && !this.popoverIsHovered && this.popoverShown)
  3488. {
  3489. this.forceHide();
  3490. }
  3491. };
  3492. /**
  3493. * Hides the popover
  3494. */
  3495. JitsiPopover.prototype.forceHide = function () {
  3496. $(".jitsipopover").remove();
  3497. this.popoverShown = false;
  3498. };
  3499. /**
  3500. * Creates the popover html
  3501. */
  3502. JitsiPopover.prototype.createPopover = function () {
  3503. $("body").append(this.template);
  3504. $(".jitsipopover > .jitsipopover-content").html(this.options.content);
  3505. var self = this;
  3506. $(".jitsipopover").on("mouseenter", function () {
  3507. self.popoverIsHovered = true;
  3508. }).on("mouseleave", function () {
  3509. self.popoverIsHovered = false;
  3510. self.hide();
  3511. });
  3512. this.refreshPosition();
  3513. };
  3514. /**
  3515. * Refreshes the position of the popover
  3516. */
  3517. JitsiPopover.prototype.refreshPosition = function () {
  3518. $(".jitsipopover").position({
  3519. my: "bottom",
  3520. at: "top",
  3521. collision: "fit",
  3522. of: this.element,
  3523. using: function (position, elements) {
  3524. var calcLeft = elements.target.left - elements.element.left + elements.target.width/2;
  3525. $(".jitsipopover").css({top: position.top, left: position.left, display: "table"});
  3526. $(".jitsipopover > .arrow").css({left: calcLeft});
  3527. $(".jitsipopover > .jitsiPopupmenuPadding").css({left: calcLeft - 50});
  3528. }
  3529. });
  3530. };
  3531. /**
  3532. * Updates the content of popover.
  3533. * @param content new content
  3534. */
  3535. JitsiPopover.prototype.updateContent = function (content) {
  3536. this.options.content = content;
  3537. if(!this.popoverShown)
  3538. return;
  3539. $(".jitsipopover").remove();
  3540. this.createPopover();
  3541. };
  3542. return JitsiPopover;
  3543. })();
  3544. module.exports = JitsiPopover;
  3545. },{}],21:[function(require,module,exports){
  3546. /* global $, jQuery */
  3547. var messageHandler = (function(my) {
  3548. /**
  3549. * Shows a message to the user.
  3550. *
  3551. * @param titleString the title of the message
  3552. * @param messageString the text of the message
  3553. */
  3554. my.openMessageDialog = function(titleString, messageString) {
  3555. $.prompt(messageString,
  3556. {
  3557. title: titleString,
  3558. persistent: false
  3559. }
  3560. );
  3561. };
  3562. /**
  3563. * Shows a message to the user with two buttons: first is given as a parameter and the second is Cancel.
  3564. *
  3565. * @param titleString the title of the message
  3566. * @param msgString the text of the message
  3567. * @param persistent boolean value which determines whether the message is persistent or not
  3568. * @param leftButton the fist button's text
  3569. * @param submitFunction function to be called on submit
  3570. * @param loadedFunction function to be called after the prompt is fully loaded
  3571. * @param closeFunction function to be called after the prompt is closed
  3572. */
  3573. my.openTwoButtonDialog = function(titleString, msgString, persistent, leftButton,
  3574. submitFunction, loadedFunction, closeFunction) {
  3575. var buttons = {};
  3576. buttons[leftButton] = true;
  3577. buttons.Cancel = false;
  3578. $.prompt(msgString, {
  3579. title: titleString,
  3580. persistent: false,
  3581. buttons: buttons,
  3582. defaultButton: 1,
  3583. loaded: loadedFunction,
  3584. submit: submitFunction,
  3585. close: closeFunction
  3586. });
  3587. };
  3588. /**
  3589. * Shows a message to the user with two buttons: first is given as a parameter and the second is Cancel.
  3590. *
  3591. * @param titleString the title of the message
  3592. * @param msgString the text of the message
  3593. * @param persistent boolean value which determines whether the message is persistent or not
  3594. * @param buttons object with the buttons. The keys must be the name of the button and value is the value
  3595. * that will be passed to submitFunction
  3596. * @param submitFunction function to be called on submit
  3597. * @param loadedFunction function to be called after the prompt is fully loaded
  3598. */
  3599. my.openDialog = function (titleString, msgString, persistent, buttons,
  3600. submitFunction, loadedFunction) {
  3601. var args = {
  3602. title: titleString,
  3603. persistent: persistent,
  3604. buttons: buttons,
  3605. defaultButton: 1,
  3606. loaded: loadedFunction,
  3607. submit: submitFunction
  3608. };
  3609. if (persistent) {
  3610. args.closeText = '';
  3611. }
  3612. return $.prompt(msgString, args);
  3613. };
  3614. /**
  3615. * Closes currently opened dialog.
  3616. */
  3617. my.closeDialog = function () {
  3618. $.prompt.close();
  3619. };
  3620. /**
  3621. * Shows a dialog with different states to the user.
  3622. *
  3623. * @param statesObject object containing all the states of the dialog
  3624. * @param loadedFunction function to be called after the prompt is fully loaded
  3625. * @param stateChangedFunction function to be called when the state of the dialog is changed
  3626. */
  3627. my.openDialogWithStates = function(statesObject, loadedFunction, stateChangedFunction) {
  3628. var myPrompt = $.prompt(statesObject);
  3629. myPrompt.on('impromptu:loaded', loadedFunction);
  3630. myPrompt.on('impromptu:statechanged', stateChangedFunction);
  3631. };
  3632. /**
  3633. * Opens new popup window for given <tt>url</tt> centered over current
  3634. * window.
  3635. *
  3636. * @param url the URL to be displayed in the popup window
  3637. * @param w the width of the popup window
  3638. * @param h the height of the popup window
  3639. * @param onPopupClosed optional callback function called when popup window
  3640. * has been closed.
  3641. *
  3642. * @returns popup window object if opened successfully or undefined
  3643. * in case we failed to open it(popup blocked)
  3644. */
  3645. my.openCenteredPopup = function (url, w, h, onPopupClosed) {
  3646. var l = window.screenX + (window.innerWidth / 2) - (w / 2);
  3647. var t = window.screenY + (window.innerHeight / 2) - (h / 2);
  3648. var popup = window.open(
  3649. url, '_blank',
  3650. 'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + '');
  3651. if (popup && onPopupClosed) {
  3652. var pollTimer = window.setInterval(function () {
  3653. if (popup.closed !== false) {
  3654. window.clearInterval(pollTimer);
  3655. onPopupClosed();
  3656. }
  3657. }, 200);
  3658. }
  3659. return popup;
  3660. };
  3661. /**
  3662. * Shows a dialog prompting the user to send an error report.
  3663. *
  3664. * @param titleString the title of the message
  3665. * @param msgString the text of the message
  3666. * @param error the error that is being reported
  3667. */
  3668. my.openReportDialog = function(titleString, msgString, error) {
  3669. my.openMessageDialog(titleString, msgString);
  3670. console.log(error);
  3671. //FIXME send the error to the server
  3672. };
  3673. /**
  3674. * Shows an error dialog to the user.
  3675. * @param title the title of the message
  3676. * @param message the text of the messafe
  3677. */
  3678. my.showError = function(title, message) {
  3679. if(!(title || message)) {
  3680. title = title || "Oops!";
  3681. message = message || "There was some kind of error";
  3682. }
  3683. messageHandler.openMessageDialog(title, message);
  3684. };
  3685. my.notify = function(displayName, cls, message) {
  3686. toastr.info(
  3687. '<span class="nickname">' +
  3688. displayName +
  3689. '</span><br>' +
  3690. '<span class=' + cls + '>' +
  3691. message +
  3692. '</span>');
  3693. };
  3694. return my;
  3695. }(messageHandler || {}));
  3696. module.exports = messageHandler;
  3697. },{}],22:[function(require,module,exports){
  3698. var nickname = null;
  3699. var eventEmitter = null;
  3700. var NickanameHandler = {
  3701. init: function (emitter) {
  3702. eventEmitter = emitter;
  3703. var storedDisplayName = window.localStorage.displayname;
  3704. if (storedDisplayName) {
  3705. nickname = storedDisplayName;
  3706. }
  3707. },
  3708. setNickname: function (newNickname) {
  3709. if (!newNickname || nickname === newNickname)
  3710. return;
  3711. nickname = newNickname;
  3712. window.localStorage.displayname = nickname;
  3713. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newNickname);
  3714. },
  3715. getNickname: function () {
  3716. return nickname;
  3717. },
  3718. addListener: function (type, listener) {
  3719. eventEmitter.on(type, listener);
  3720. }
  3721. };
  3722. module.exports = NickanameHandler;
  3723. },{}],23:[function(require,module,exports){
  3724. /**
  3725. * Created by hristo on 12/22/14.
  3726. */
  3727. module.exports = {
  3728. /**
  3729. * Returns the available video width.
  3730. */
  3731. getAvailableVideoWidth: function () {
  3732. var PanelToggler = require("../side_pannels/SidePanelToggler");
  3733. var rightPanelWidth
  3734. = PanelToggler.isVisible() ? PanelToggler.getPanelSize()[0] : 0;
  3735. return window.innerWidth - rightPanelWidth;
  3736. },
  3737. /**
  3738. * Changes the style class of the element given by id.
  3739. */
  3740. buttonClick: function(id, classname) {
  3741. $(id).toggleClass(classname); // add the class to the clicked element
  3742. },
  3743. /**
  3744. * Returns the text width for the given element.
  3745. *
  3746. * @param el the element
  3747. */
  3748. getTextWidth: function (el) {
  3749. return (el.clientWidth + 1);
  3750. },
  3751. /**
  3752. * Returns the text height for the given element.
  3753. *
  3754. * @param el the element
  3755. */
  3756. getTextHeight: function (el) {
  3757. return (el.clientHeight + 1);
  3758. },
  3759. /**
  3760. * Plays the sound given by id.
  3761. *
  3762. * @param id the identifier of the audio element.
  3763. */
  3764. playSoundNotification: function (id) {
  3765. document.getElementById(id).play();
  3766. },
  3767. /**
  3768. * Escapes the given text.
  3769. */
  3770. escapeHtml: function (unsafeText) {
  3771. return $('<div/>').text(unsafeText).html();
  3772. },
  3773. imageToGrayScale: function (canvas) {
  3774. var context = canvas.getContext('2d');
  3775. var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
  3776. var pixels = imgData.data;
  3777. for (var i = 0, n = pixels.length; i < n; i += 4) {
  3778. var grayscale
  3779. = pixels[i] * .3 + pixels[i+1] * .59 + pixels[i+2] * .11;
  3780. pixels[i ] = grayscale; // red
  3781. pixels[i+1] = grayscale; // green
  3782. pixels[i+2] = grayscale; // blue
  3783. // pixels[i+3] is alpha
  3784. }
  3785. // redraw the image in black & white
  3786. context.putImageData(imgData, 0, 0);
  3787. },
  3788. setTooltip: function (element, tooltipText, position) {
  3789. element.setAttribute("data-content", tooltipText);
  3790. element.setAttribute("data-toggle", "popover");
  3791. element.setAttribute("data-placement", position);
  3792. element.setAttribute("data-html", true);
  3793. element.setAttribute("data-container", "body");
  3794. }
  3795. };
  3796. },{"../side_pannels/SidePanelToggler":9}],24:[function(require,module,exports){
  3797. var JitsiPopover = require("../util/JitsiPopover");
  3798. /**
  3799. * Constructs new connection indicator.
  3800. * @param videoContainer the video container associated with the indicator.
  3801. * @constructor
  3802. */
  3803. function ConnectionIndicator(videoContainer, jid, VideoLayout)
  3804. {
  3805. this.videoContainer = videoContainer;
  3806. this.bandwidth = null;
  3807. this.packetLoss = null;
  3808. this.bitrate = null;
  3809. this.showMoreValue = false;
  3810. this.resolution = null;
  3811. this.transport = [];
  3812. this.popover = null;
  3813. this.jid = jid;
  3814. this.create();
  3815. this.videoLayout = VideoLayout;
  3816. }
  3817. /**
  3818. * Values for the connection quality
  3819. * @type {{98: string,
  3820. * 81: string,
  3821. * 64: string,
  3822. * 47: string,
  3823. * 30: string,
  3824. * 0: string}}
  3825. */
  3826. ConnectionIndicator.connectionQualityValues = {
  3827. 98: "18px", //full
  3828. 81: "15px",//4 bars
  3829. 64: "11px",//3 bars
  3830. 47: "7px",//2 bars
  3831. 30: "3px",//1 bar
  3832. 0: "0px"//empty
  3833. };
  3834. ConnectionIndicator.getIP = function(value)
  3835. {
  3836. return value.substring(0, value.lastIndexOf(":"));
  3837. };
  3838. ConnectionIndicator.getPort = function(value)
  3839. {
  3840. return value.substring(value.lastIndexOf(":") + 1, value.length);
  3841. };
  3842. ConnectionIndicator.getStringFromArray = function (array) {
  3843. var res = "";
  3844. for(var i = 0; i < array.length; i++)
  3845. {
  3846. res += (i === 0? "" : ", ") + array[i];
  3847. }
  3848. return res;
  3849. };
  3850. /**
  3851. * Generates the html content.
  3852. * @returns {string} the html content.
  3853. */
  3854. ConnectionIndicator.prototype.generateText = function () {
  3855. var downloadBitrate, uploadBitrate, packetLoss, resolution, i;
  3856. if(this.bitrate === null)
  3857. {
  3858. downloadBitrate = "N/A";
  3859. uploadBitrate = "N/A";
  3860. }
  3861. else
  3862. {
  3863. downloadBitrate =
  3864. this.bitrate.download? this.bitrate.download + " Kbps" : "N/A";
  3865. uploadBitrate =
  3866. this.bitrate.upload? this.bitrate.upload + " Kbps" : "N/A";
  3867. }
  3868. if(this.packetLoss === null)
  3869. {
  3870. packetLoss = "N/A";
  3871. }
  3872. else
  3873. {
  3874. packetLoss = "<span class='jitsipopover_green'>&darr;</span>" +
  3875. (this.packetLoss.download !== null? this.packetLoss.download : "N/A") +
  3876. "% <span class='jitsipopover_orange'>&uarr;</span>" +
  3877. (this.packetLoss.upload !== null? this.packetLoss.upload : "N/A") + "%";
  3878. }
  3879. var resolutionValue = null;
  3880. if(this.resolution && this.jid != null)
  3881. {
  3882. var keys = Object.keys(this.resolution);
  3883. if(keys.length == 1)
  3884. {
  3885. for(var ssrc in this.resolution)
  3886. {
  3887. resolutionValue = this.resolution[ssrc];
  3888. }
  3889. }
  3890. else if(keys.length > 1)
  3891. {
  3892. var displayedSsrc = simulcast.getReceivingSSRC(this.jid);
  3893. resolutionValue = this.resolution[displayedSsrc];
  3894. }
  3895. }
  3896. if(this.jid === null)
  3897. {
  3898. resolution = "";
  3899. if(this.resolution === null || !Object.keys(this.resolution) ||
  3900. Object.keys(this.resolution).length === 0)
  3901. {
  3902. resolution = "N/A";
  3903. }
  3904. else
  3905. for(i in this.resolution)
  3906. {
  3907. resolutionValue = this.resolution[i];
  3908. if(resolutionValue)
  3909. {
  3910. if(resolutionValue.height &&
  3911. resolutionValue.width)
  3912. {
  3913. resolution += (resolution === ""? "" : ", ") +
  3914. resolutionValue.width + "x" +
  3915. resolutionValue.height;
  3916. }
  3917. }
  3918. }
  3919. }
  3920. else if(!resolutionValue ||
  3921. !resolutionValue.height ||
  3922. !resolutionValue.width)
  3923. {
  3924. resolution = "N/A";
  3925. }
  3926. else
  3927. {
  3928. resolution = resolutionValue.width + "x" + resolutionValue.height;
  3929. }
  3930. var result = "<table style='width:100%'>" +
  3931. "<tr>" +
  3932. "<td><span class='jitsipopover_blue'>Bitrate:</span></td>" +
  3933. "<td><span class='jitsipopover_green'>&darr;</span>" +
  3934. downloadBitrate + " <span class='jitsipopover_orange'>&uarr;</span>" +
  3935. uploadBitrate + "</td>" +
  3936. "</tr><tr>" +
  3937. "<td><span class='jitsipopover_blue'>Packet loss: </span></td>" +
  3938. "<td>" + packetLoss + "</td>" +
  3939. "</tr><tr>" +
  3940. "<td><span class='jitsipopover_blue'>Resolution:</span></td>" +
  3941. "<td>" + resolution + "</td></tr></table>";
  3942. if(this.videoContainer.id == "localVideoContainer")
  3943. result += "<div class=\"jitsipopover_showmore\" " +
  3944. "onclick = \"UI.connectionIndicatorShowMore('" +
  3945. this.videoContainer.id + "')\">" +
  3946. (this.showMoreValue? "Show less" : "Show More") + "</div><br />";
  3947. if(this.showMoreValue)
  3948. {
  3949. var downloadBandwidth, uploadBandwidth, transport;
  3950. if(this.bandwidth === null)
  3951. {
  3952. downloadBandwidth = "N/A";
  3953. uploadBandwidth = "N/A";
  3954. }
  3955. else
  3956. {
  3957. downloadBandwidth = this.bandwidth.download?
  3958. this.bandwidth.download + " Kbps" :
  3959. "N/A";
  3960. uploadBandwidth = this.bandwidth.upload?
  3961. this.bandwidth.upload + " Kbps" :
  3962. "N/A";
  3963. }
  3964. if(!this.transport || this.transport.length === 0)
  3965. {
  3966. transport = "<tr>" +
  3967. "<td><span class='jitsipopover_blue'>Address:</span></td>" +
  3968. "<td> N/A</td></tr>";
  3969. }
  3970. else
  3971. {
  3972. var data = {remoteIP: [], localIP:[], remotePort:[], localPort:[]};
  3973. for(i = 0; i < this.transport.length; i++)
  3974. {
  3975. var ip = ConnectionIndicator.getIP(this.transport[i].ip);
  3976. var port = ConnectionIndicator.getPort(this.transport[i].ip);
  3977. var localIP =
  3978. ConnectionIndicator.getIP(this.transport[i].localip);
  3979. var localPort =
  3980. ConnectionIndicator.getPort(this.transport[i].localip);
  3981. if(data.remoteIP.indexOf(ip) == -1)
  3982. {
  3983. data.remoteIP.push(ip);
  3984. }
  3985. if(data.remotePort.indexOf(port) == -1)
  3986. {
  3987. data.remotePort.push(port);
  3988. }
  3989. if(data.localIP.indexOf(localIP) == -1)
  3990. {
  3991. data.localIP.push(localIP);
  3992. }
  3993. if(data.localPort.indexOf(localPort) == -1)
  3994. {
  3995. data.localPort.push(localPort);
  3996. }
  3997. }
  3998. var localTransport =
  3999. "<tr><td><span class='jitsipopover_blue'>Local address" +
  4000. (data.localIP.length > 1? "es" : "") + ": </span></td><td> " +
  4001. ConnectionIndicator.getStringFromArray(data.localIP) +
  4002. "</td></tr>";
  4003. transport =
  4004. "<tr><td><span class='jitsipopover_blue'>Remote address"+
  4005. (data.remoteIP.length > 1? "es" : "") + ":</span></td><td> " +
  4006. ConnectionIndicator.getStringFromArray(data.remoteIP) +
  4007. "</td></tr>";
  4008. if(this.transport.length > 1)
  4009. {
  4010. transport += "<tr>" +
  4011. "<td>" +
  4012. "<span class='jitsipopover_blue'>Remote ports:</span>" +
  4013. "</td><td>";
  4014. localTransport += "<tr>" +
  4015. "<td>" +
  4016. "<span class='jitsipopover_blue'>Local ports:</span>" +
  4017. "</td><td>";
  4018. }
  4019. else
  4020. {
  4021. transport +=
  4022. "<tr>" +
  4023. "<td>" +
  4024. "<span class='jitsipopover_blue'>Remote port:</span>" +
  4025. "</td><td>";
  4026. localTransport +=
  4027. "<tr>" +
  4028. "<td>" +
  4029. "<span class='jitsipopover_blue'>Local port:</span>" +
  4030. "</td><td>";
  4031. }
  4032. transport +=
  4033. ConnectionIndicator.getStringFromArray(data.remotePort);
  4034. localTransport +=
  4035. ConnectionIndicator.getStringFromArray(data.localPort);
  4036. transport += "</td></tr>";
  4037. transport += localTransport + "</td></tr>";
  4038. transport +="<tr>" +
  4039. "<td><span class='jitsipopover_blue'>Transport:</span></td>" +
  4040. "<td>" + this.transport[0].type + "</td></tr>";
  4041. }
  4042. result += "<table style='width:100%'>" +
  4043. "<tr>" +
  4044. "<td>" +
  4045. "<span class='jitsipopover_blue'>Estimated bandwidth:</span>" +
  4046. "</td><td>" +
  4047. "<span class='jitsipopover_green'>&darr;</span>" +
  4048. downloadBandwidth +
  4049. " <span class='jitsipopover_orange'>&uarr;</span>" +
  4050. uploadBandwidth + "</td></tr>";
  4051. result += transport + "</table>";
  4052. }
  4053. return result;
  4054. };
  4055. /**
  4056. * Shows or hide the additional information.
  4057. */
  4058. ConnectionIndicator.prototype.showMore = function () {
  4059. this.showMoreValue = !this.showMoreValue;
  4060. this.updatePopoverData();
  4061. };
  4062. function createIcon(classes)
  4063. {
  4064. var icon = document.createElement("span");
  4065. for(var i in classes)
  4066. {
  4067. icon.classList.add(classes[i]);
  4068. }
  4069. icon.appendChild(
  4070. document.createElement("i")).classList.add("icon-connection");
  4071. return icon;
  4072. }
  4073. /**
  4074. * Creates the indicator
  4075. */
  4076. ConnectionIndicator.prototype.create = function () {
  4077. this.connectionIndicatorContainer = document.createElement("div");
  4078. this.connectionIndicatorContainer.className = "connectionindicator";
  4079. this.connectionIndicatorContainer.style.display = "none";
  4080. this.videoContainer.appendChild(this.connectionIndicatorContainer);
  4081. this.popover = new JitsiPopover(
  4082. $("#" + this.videoContainer.id + " > .connectionindicator"),
  4083. {content: "<div class=\"connection_info\">Come back here for " +
  4084. "connection information once the conference starts</div>",
  4085. skin: "black"});
  4086. this.emptyIcon = this.connectionIndicatorContainer.appendChild(
  4087. createIcon(["connection", "connection_empty"]));
  4088. this.fullIcon = this.connectionIndicatorContainer.appendChild(
  4089. createIcon(["connection", "connection_full"]));
  4090. };
  4091. /**
  4092. * Removes the indicator
  4093. */
  4094. ConnectionIndicator.prototype.remove = function()
  4095. {
  4096. this.connectionIndicatorContainer.remove();
  4097. this.popover.forceHide();
  4098. };
  4099. /**
  4100. * Updates the data of the indicator
  4101. * @param percent the percent of connection quality
  4102. * @param object the statistics data.
  4103. */
  4104. ConnectionIndicator.prototype.updateConnectionQuality =
  4105. function (percent, object) {
  4106. if(percent === null)
  4107. {
  4108. this.connectionIndicatorContainer.style.display = "none";
  4109. this.popover.forceHide();
  4110. return;
  4111. }
  4112. else
  4113. {
  4114. if(this.connectionIndicatorContainer.style.display == "none") {
  4115. this.connectionIndicatorContainer.style.display = "block";
  4116. this.videoLayout.updateMutePosition(this.videoContainer.id);
  4117. }
  4118. }
  4119. this.bandwidth = object.bandwidth;
  4120. this.bitrate = object.bitrate;
  4121. this.packetLoss = object.packetLoss;
  4122. this.transport = object.transport;
  4123. if(object.resolution)
  4124. {
  4125. this.resolution = object.resolution;
  4126. }
  4127. for(var quality in ConnectionIndicator.connectionQualityValues)
  4128. {
  4129. if(percent >= quality)
  4130. {
  4131. this.fullIcon.style.width =
  4132. ConnectionIndicator.connectionQualityValues[quality];
  4133. }
  4134. }
  4135. this.updatePopoverData();
  4136. };
  4137. /**
  4138. * Updates the resolution
  4139. * @param resolution the new resolution
  4140. */
  4141. ConnectionIndicator.prototype.updateResolution = function (resolution) {
  4142. this.resolution = resolution;
  4143. this.updatePopoverData();
  4144. };
  4145. /**
  4146. * Updates the content of the popover
  4147. */
  4148. ConnectionIndicator.prototype.updatePopoverData = function () {
  4149. this.popover.updateContent(
  4150. "<div class=\"connection_info\">" + this.generateText() + "</div>");
  4151. };
  4152. /**
  4153. * Hides the popover
  4154. */
  4155. ConnectionIndicator.prototype.hide = function () {
  4156. this.popover.forceHide();
  4157. };
  4158. /**
  4159. * Hides the indicator
  4160. */
  4161. ConnectionIndicator.prototype.hideIndicator = function () {
  4162. this.connectionIndicatorContainer.style.display = "none";
  4163. if(this.popover)
  4164. this.popover.forceHide();
  4165. };
  4166. module.exports = ConnectionIndicator;
  4167. },{"../util/JitsiPopover":20}],25:[function(require,module,exports){
  4168. var AudioLevels = require("../audio_levels/AudioLevels");
  4169. var Avatar = require("../avatar/Avatar");
  4170. var Chat = require("../side_pannels/chat/Chat");
  4171. var ContactList = require("../side_pannels/contactlist/ContactList");
  4172. var UIUtil = require("../util/UIUtil");
  4173. var ConnectionIndicator = require("./ConnectionIndicator");
  4174. var NicknameHandler = require("../util/NicknameHandler");
  4175. var currentDominantSpeaker = null;
  4176. var lastNCount = config.channelLastN;
  4177. var localLastNCount = config.channelLastN;
  4178. var localLastNSet = [];
  4179. var lastNEndpointsCache = [];
  4180. var lastNPickupJid = null;
  4181. var largeVideoState = {
  4182. updateInProgress: false,
  4183. newSrc: ''
  4184. };
  4185. var eventEmitter = null;
  4186. /**
  4187. * Currently focused video "src"(displayed in large video).
  4188. * @type {String}
  4189. */
  4190. var focusedVideoInfo = null;
  4191. /**
  4192. * Indicates if we have muted our audio before the conference has started.
  4193. * @type {boolean}
  4194. */
  4195. var preMuted = false;
  4196. var mutedAudios = {};
  4197. var flipXLocalVideo = true;
  4198. var currentVideoWidth = null;
  4199. var currentVideoHeight = null;
  4200. var localVideoSrc = null;
  4201. function videoactive( videoelem) {
  4202. if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
  4203. // ignore mixedmslabela0 and v0
  4204. videoelem.show();
  4205. VideoLayout.resizeThumbnails();
  4206. var videoParent = videoelem.parent();
  4207. var parentResourceJid = null;
  4208. if (videoParent)
  4209. parentResourceJid
  4210. = VideoLayout.getPeerContainerResourceJid(videoParent[0]);
  4211. // Update the large video to the last added video only if there's no
  4212. // current dominant, focused speaker or prezi playing or update it to
  4213. // the current dominant speaker.
  4214. if ((!focusedVideoInfo &&
  4215. !VideoLayout.getDominantSpeakerResourceJid() &&
  4216. !require("../prezi/Prezi").isPresentationVisible()) ||
  4217. (parentResourceJid &&
  4218. VideoLayout.getDominantSpeakerResourceJid() === parentResourceJid)) {
  4219. VideoLayout.updateLargeVideo(
  4220. RTC.getVideoSrc(videoelem[0]),
  4221. 1,
  4222. parentResourceJid);
  4223. }
  4224. VideoLayout.showModeratorIndicator();
  4225. }
  4226. }
  4227. function waitForRemoteVideo(selector, ssrc, stream, jid) {
  4228. // XXX(gp) so, every call to this function is *always* preceded by a call
  4229. // to the RTC.attachMediaStream() function but that call is *not* followed
  4230. // by an update to the videoSrcToSsrc map!
  4231. //
  4232. // The above way of doing things results in video SRCs that don't correspond
  4233. // to any SSRC for a short period of time (to be more precise, for as long
  4234. // the waitForRemoteVideo takes to complete). This causes problems (see
  4235. // bellow).
  4236. //
  4237. // I'm wondering why we need to do that; i.e. why call RTC.attachMediaStream()
  4238. // a second time in here and only then update the videoSrcToSsrc map? Why
  4239. // not simply update the videoSrcToSsrc map when the RTC.attachMediaStream()
  4240. // is called the first time? I actually do that in the lastN changed event
  4241. // handler because the "orphan" video SRC is causing troubles there. The
  4242. // purpose of this method would then be to fire the "videoactive.jingle".
  4243. //
  4244. // Food for though I guess :-)
  4245. if (selector.removed || !selector.parent().is(":visible")) {
  4246. console.warn("Media removed before had started", selector);
  4247. return;
  4248. }
  4249. if (stream.id === 'mixedmslabel') return;
  4250. if (selector[0].currentTime > 0) {
  4251. var videoStream = simulcast.getReceivingVideoStream(stream);
  4252. RTC.attachMediaStream(selector, videoStream); // FIXME: why do i have to do this for FF?
  4253. videoactive(selector);
  4254. } else {
  4255. setTimeout(function () {
  4256. waitForRemoteVideo(selector, ssrc, stream, jid);
  4257. }, 250);
  4258. }
  4259. }
  4260. /**
  4261. * Returns an array of the video horizontal and vertical indents,
  4262. * so that if fits its parent.
  4263. *
  4264. * @return an array with 2 elements, the horizontal indent and the vertical
  4265. * indent
  4266. */
  4267. function getCameraVideoPosition(videoWidth,
  4268. videoHeight,
  4269. videoSpaceWidth,
  4270. videoSpaceHeight) {
  4271. // Parent height isn't completely calculated when we position the video in
  4272. // full screen mode and this is why we use the screen height in this case.
  4273. // Need to think it further at some point and implement it properly.
  4274. var isFullScreen = document.fullScreen ||
  4275. document.mozFullScreen ||
  4276. document.webkitIsFullScreen;
  4277. if (isFullScreen)
  4278. videoSpaceHeight = window.innerHeight;
  4279. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  4280. var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
  4281. return [horizontalIndent, verticalIndent];
  4282. }
  4283. /**
  4284. * Returns an array of the video horizontal and vertical indents.
  4285. * Centers horizontally and top aligns vertically.
  4286. *
  4287. * @return an array with 2 elements, the horizontal indent and the vertical
  4288. * indent
  4289. */
  4290. function getDesktopVideoPosition(videoWidth,
  4291. videoHeight,
  4292. videoSpaceWidth,
  4293. videoSpaceHeight) {
  4294. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  4295. var verticalIndent = 0;// Top aligned
  4296. return [horizontalIndent, verticalIndent];
  4297. }
  4298. /**
  4299. * Returns an array of the video dimensions, so that it covers the screen.
  4300. * It leaves no empty areas, but some parts of the video might not be visible.
  4301. *
  4302. * @return an array with 2 elements, the video width and the video height
  4303. */
  4304. function getCameraVideoSize(videoWidth,
  4305. videoHeight,
  4306. videoSpaceWidth,
  4307. videoSpaceHeight) {
  4308. if (!videoWidth)
  4309. videoWidth = currentVideoWidth;
  4310. if (!videoHeight)
  4311. videoHeight = currentVideoHeight;
  4312. var aspectRatio = videoWidth / videoHeight;
  4313. var availableWidth = Math.max(videoWidth, videoSpaceWidth);
  4314. var availableHeight = Math.max(videoHeight, videoSpaceHeight);
  4315. if (availableWidth / aspectRatio < videoSpaceHeight) {
  4316. availableHeight = videoSpaceHeight;
  4317. availableWidth = availableHeight * aspectRatio;
  4318. }
  4319. if (availableHeight * aspectRatio < videoSpaceWidth) {
  4320. availableWidth = videoSpaceWidth;
  4321. availableHeight = availableWidth / aspectRatio;
  4322. }
  4323. return [availableWidth, availableHeight];
  4324. }
  4325. /**
  4326. * Sets the display name for the given video span id.
  4327. */
  4328. function setDisplayName(videoSpanId, displayName) {
  4329. var nameSpan = $('#' + videoSpanId + '>span.displayname');
  4330. var defaultLocalDisplayName = interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME;
  4331. // If we already have a display name for this video.
  4332. if (nameSpan.length > 0) {
  4333. var nameSpanElement = nameSpan.get(0);
  4334. if (nameSpanElement.id === 'localDisplayName' &&
  4335. $('#localDisplayName').text() !== displayName) {
  4336. if (displayName && displayName.length > 0)
  4337. $('#localDisplayName').html(displayName + ' (me)');
  4338. else
  4339. $('#localDisplayName').text(defaultLocalDisplayName);
  4340. } else {
  4341. if (displayName && displayName.length > 0)
  4342. $('#' + videoSpanId + '_name').html(displayName);
  4343. else
  4344. $('#' + videoSpanId + '_name').text(interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME);
  4345. }
  4346. } else {
  4347. var editButton = null;
  4348. nameSpan = document.createElement('span');
  4349. nameSpan.className = 'displayname';
  4350. $('#' + videoSpanId)[0].appendChild(nameSpan);
  4351. if (videoSpanId === 'localVideoContainer') {
  4352. editButton = createEditDisplayNameButton();
  4353. nameSpan.innerText = defaultLocalDisplayName;
  4354. }
  4355. else {
  4356. nameSpan.innerText = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
  4357. }
  4358. if (displayName && displayName.length > 0) {
  4359. nameSpan.innerText = displayName;
  4360. }
  4361. if (!editButton) {
  4362. nameSpan.id = videoSpanId + '_name';
  4363. } else {
  4364. nameSpan.id = 'localDisplayName';
  4365. $('#' + videoSpanId)[0].appendChild(editButton);
  4366. var editableText = document.createElement('input');
  4367. editableText.className = 'displayname';
  4368. editableText.type = 'text';
  4369. editableText.id = 'editDisplayName';
  4370. if (displayName && displayName.length) {
  4371. editableText.value
  4372. = displayName.substring(0, displayName.indexOf(' (me)'));
  4373. }
  4374. editableText.setAttribute('style', 'display:none;');
  4375. editableText.setAttribute('placeholder', 'ex. Jane Pink');
  4376. $('#' + videoSpanId)[0].appendChild(editableText);
  4377. $('#localVideoContainer .displayname')
  4378. .bind("click", function (e) {
  4379. e.preventDefault();
  4380. e.stopPropagation();
  4381. $('#localDisplayName').hide();
  4382. $('#editDisplayName').show();
  4383. $('#editDisplayName').focus();
  4384. $('#editDisplayName').select();
  4385. $('#editDisplayName').one("focusout", function (e) {
  4386. VideoLayout.inputDisplayNameHandler(this.value);
  4387. });
  4388. $('#editDisplayName').on('keydown', function (e) {
  4389. if (e.keyCode === 13) {
  4390. e.preventDefault();
  4391. VideoLayout.inputDisplayNameHandler(this.value);
  4392. }
  4393. });
  4394. });
  4395. }
  4396. }
  4397. }
  4398. /**
  4399. * Gets the selector of video thumbnail container for the user identified by
  4400. * given <tt>userJid</tt>
  4401. * @param resourceJid user's Jid for whom we want to get the video container.
  4402. */
  4403. function getParticipantContainer(resourceJid)
  4404. {
  4405. if (!resourceJid)
  4406. return null;
  4407. if (resourceJid === xmpp.myResource())
  4408. return $("#localVideoContainer");
  4409. else
  4410. return $("#participant_" + resourceJid);
  4411. }
  4412. /**
  4413. * Sets the size and position of the given video element.
  4414. *
  4415. * @param video the video element to position
  4416. * @param width the desired video width
  4417. * @param height the desired video height
  4418. * @param horizontalIndent the left and right indent
  4419. * @param verticalIndent the top and bottom indent
  4420. */
  4421. function positionVideo(video,
  4422. width,
  4423. height,
  4424. horizontalIndent,
  4425. verticalIndent) {
  4426. video.width(width);
  4427. video.height(height);
  4428. video.css({ top: verticalIndent + 'px',
  4429. bottom: verticalIndent + 'px',
  4430. left: horizontalIndent + 'px',
  4431. right: horizontalIndent + 'px'});
  4432. }
  4433. /**
  4434. * Adds the remote video menu element for the given <tt>jid</tt> in the
  4435. * given <tt>parentElement</tt>.
  4436. *
  4437. * @param jid the jid indicating the video for which we're adding a menu.
  4438. * @param parentElement the parent element where this menu will be added
  4439. */
  4440. function addRemoteVideoMenu(jid, parentElement) {
  4441. var spanElement = document.createElement('span');
  4442. spanElement.className = 'remotevideomenu';
  4443. parentElement.appendChild(spanElement);
  4444. var menuElement = document.createElement('i');
  4445. menuElement.className = 'fa fa-angle-down';
  4446. menuElement.title = 'Remote user controls';
  4447. spanElement.appendChild(menuElement);
  4448. // <ul class="popupmenu">
  4449. // <li><a href="#">Mute</a></li>
  4450. // <li><a href="#">Eject</a></li>
  4451. // </ul>
  4452. var popupmenuElement = document.createElement('ul');
  4453. popupmenuElement.className = 'popupmenu';
  4454. popupmenuElement.id
  4455. = 'remote_popupmenu_' + Strophe.getResourceFromJid(jid);
  4456. spanElement.appendChild(popupmenuElement);
  4457. var muteMenuItem = document.createElement('li');
  4458. var muteLinkItem = document.createElement('a');
  4459. var mutedIndicator = "<i class='icon-mic-disabled'></i>";
  4460. if (!mutedAudios[jid]) {
  4461. muteLinkItem.innerHTML = mutedIndicator + 'Mute';
  4462. muteLinkItem.className = 'mutelink';
  4463. }
  4464. else {
  4465. muteLinkItem.innerHTML = mutedIndicator + ' Muted';
  4466. muteLinkItem.className = 'mutelink disabled';
  4467. }
  4468. muteLinkItem.onclick = function(){
  4469. if ($(this).attr('disabled') != undefined) {
  4470. event.preventDefault();
  4471. }
  4472. var isMute = mutedAudios[jid] == true;
  4473. xmpp.setMute(jid, !isMute);
  4474. popupmenuElement.setAttribute('style', 'display:none;');
  4475. if (isMute) {
  4476. this.innerHTML = mutedIndicator + ' Muted';
  4477. this.className = 'mutelink disabled';
  4478. }
  4479. else {
  4480. this.innerHTML = mutedIndicator + ' Mute';
  4481. this.className = 'mutelink';
  4482. }
  4483. };
  4484. muteMenuItem.appendChild(muteLinkItem);
  4485. popupmenuElement.appendChild(muteMenuItem);
  4486. var ejectIndicator = "<i class='fa fa-eject'></i>";
  4487. var ejectMenuItem = document.createElement('li');
  4488. var ejectLinkItem = document.createElement('a');
  4489. ejectLinkItem.innerHTML = ejectIndicator + ' Kick out';
  4490. ejectLinkItem.onclick = function(){
  4491. xmpp.eject(jid);
  4492. popupmenuElement.setAttribute('style', 'display:none;');
  4493. };
  4494. ejectMenuItem.appendChild(ejectLinkItem);
  4495. popupmenuElement.appendChild(ejectMenuItem);
  4496. var paddingSpan = document.createElement('span');
  4497. paddingSpan.className = 'popupmenuPadding';
  4498. popupmenuElement.appendChild(paddingSpan);
  4499. }
  4500. /**
  4501. * Removes remote video menu element from video element identified by
  4502. * given <tt>videoElementId</tt>.
  4503. *
  4504. * @param videoElementId the id of local or remote video element.
  4505. */
  4506. function removeRemoteVideoMenu(videoElementId) {
  4507. var menuSpan = $('#' + videoElementId + '>span.remotevideomenu');
  4508. if (menuSpan.length) {
  4509. menuSpan.remove();
  4510. }
  4511. }
  4512. /**
  4513. * Updates the data for the indicator
  4514. * @param id the id of the indicator
  4515. * @param percent the percent for connection quality
  4516. * @param object the data
  4517. */
  4518. function updateStatsIndicator(id, percent, object) {
  4519. if(VideoLayout.connectionIndicators[id])
  4520. VideoLayout.connectionIndicators[id].updateConnectionQuality(percent, object);
  4521. }
  4522. /**
  4523. * Returns an array of the video dimensions, so that it keeps it's aspect
  4524. * ratio and fits available area with it's larger dimension. This method
  4525. * ensures that whole video will be visible and can leave empty areas.
  4526. *
  4527. * @return an array with 2 elements, the video width and the video height
  4528. */
  4529. function getDesktopVideoSize(videoWidth,
  4530. videoHeight,
  4531. videoSpaceWidth,
  4532. videoSpaceHeight) {
  4533. if (!videoWidth)
  4534. videoWidth = currentVideoWidth;
  4535. if (!videoHeight)
  4536. videoHeight = currentVideoHeight;
  4537. var aspectRatio = videoWidth / videoHeight;
  4538. var availableWidth = Math.max(videoWidth, videoSpaceWidth);
  4539. var availableHeight = Math.max(videoHeight, videoSpaceHeight);
  4540. videoSpaceHeight -= $('#remoteVideos').outerHeight();
  4541. if (availableWidth / aspectRatio >= videoSpaceHeight)
  4542. {
  4543. availableHeight = videoSpaceHeight;
  4544. availableWidth = availableHeight * aspectRatio;
  4545. }
  4546. if (availableHeight * aspectRatio >= videoSpaceWidth)
  4547. {
  4548. availableWidth = videoSpaceWidth;
  4549. availableHeight = availableWidth / aspectRatio;
  4550. }
  4551. return [availableWidth, availableHeight];
  4552. }
  4553. /**
  4554. * Creates the edit display name button.
  4555. *
  4556. * @returns the edit button
  4557. */
  4558. function createEditDisplayNameButton() {
  4559. var editButton = document.createElement('a');
  4560. editButton.className = 'displayname';
  4561. UIUtil.setTooltip(editButton,
  4562. 'Click to edit your<br/>display name',
  4563. "top");
  4564. editButton.innerHTML = '<i class="fa fa-pencil"></i>';
  4565. return editButton;
  4566. }
  4567. /**
  4568. * Creates the element indicating the moderator(owner) of the conference.
  4569. *
  4570. * @param parentElement the parent element where the owner indicator will
  4571. * be added
  4572. */
  4573. function createModeratorIndicatorElement(parentElement) {
  4574. var moderatorIndicator = document.createElement('i');
  4575. moderatorIndicator.className = 'fa fa-star';
  4576. parentElement.appendChild(moderatorIndicator);
  4577. UIUtil.setTooltip(parentElement,
  4578. "The owner of<br/>this conference",
  4579. "top");
  4580. }
  4581. var VideoLayout = (function (my) {
  4582. my.connectionIndicators = {};
  4583. // By default we use camera
  4584. my.getVideoSize = getCameraVideoSize;
  4585. my.getVideoPosition = getCameraVideoPosition;
  4586. my.init = function (emitter) {
  4587. // Listen for large video size updates
  4588. document.getElementById('largeVideo')
  4589. .addEventListener('loadedmetadata', function (e) {
  4590. currentVideoWidth = this.videoWidth;
  4591. currentVideoHeight = this.videoHeight;
  4592. VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
  4593. });
  4594. eventEmitter = emitter;
  4595. };
  4596. my.isInLastN = function(resource) {
  4597. return lastNCount < 0 // lastN is disabled, return true
  4598. || (lastNCount > 0 && lastNEndpointsCache.length == 0) // lastNEndpoints cache not built yet, return true
  4599. || (lastNEndpointsCache && lastNEndpointsCache.indexOf(resource) !== -1);
  4600. };
  4601. my.changeLocalStream = function (stream) {
  4602. VideoLayout.changeLocalVideo(stream);
  4603. };
  4604. my.changeLocalAudio = function(stream) {
  4605. RTC.attachMediaStream($('#localAudio'), stream.getOriginalStream());
  4606. document.getElementById('localAudio').autoplay = true;
  4607. document.getElementById('localAudio').volume = 0;
  4608. if (preMuted) {
  4609. if(!UI.setAudioMuted(true))
  4610. {
  4611. preMuted = mute;
  4612. }
  4613. preMuted = false;
  4614. }
  4615. };
  4616. my.changeLocalVideo = function(stream) {
  4617. var flipX = true;
  4618. if(stream.videoType == "screen")
  4619. flipX = false;
  4620. var localVideo = document.createElement('video');
  4621. localVideo.id = 'localVideo_' +
  4622. RTC.getStreamID(stream.getOriginalStream());
  4623. localVideo.autoplay = true;
  4624. localVideo.volume = 0; // is it required if audio is separated ?
  4625. localVideo.oncontextmenu = function () { return false; };
  4626. var localVideoContainer = document.getElementById('localVideoWrapper');
  4627. localVideoContainer.appendChild(localVideo);
  4628. // Set default display name.
  4629. setDisplayName('localVideoContainer');
  4630. if(!VideoLayout.connectionIndicators["localVideoContainer"]) {
  4631. VideoLayout.connectionIndicators["localVideoContainer"]
  4632. = new ConnectionIndicator($("#localVideoContainer")[0], null, VideoLayout);
  4633. }
  4634. AudioLevels.updateAudioLevelCanvas(null, VideoLayout);
  4635. var localVideoSelector = $('#' + localVideo.id);
  4636. // Add click handler to both video and video wrapper elements in case
  4637. // there's no video.
  4638. localVideoSelector.click(function (event) {
  4639. event.stopPropagation();
  4640. VideoLayout.handleVideoThumbClicked(
  4641. RTC.getVideoSrc(localVideo),
  4642. false,
  4643. xmpp.myResource());
  4644. });
  4645. $('#localVideoContainer').click(function (event) {
  4646. event.stopPropagation();
  4647. VideoLayout.handleVideoThumbClicked(
  4648. RTC.getVideoSrc(localVideo),
  4649. false,
  4650. xmpp.myResource());
  4651. });
  4652. // Add hover handler
  4653. $('#localVideoContainer').hover(
  4654. function() {
  4655. VideoLayout.showDisplayName('localVideoContainer', true);
  4656. },
  4657. function() {
  4658. if (!VideoLayout.isLargeVideoVisible()
  4659. || RTC.getVideoSrc(localVideo) !== RTC.getVideoSrc($('#largeVideo')[0]))
  4660. VideoLayout.showDisplayName('localVideoContainer', false);
  4661. }
  4662. );
  4663. // Add stream ended handler
  4664. stream.getOriginalStream().onended = function () {
  4665. localVideoContainer.removeChild(localVideo);
  4666. VideoLayout.updateRemovedVideo(RTC.getVideoSrc(localVideo));
  4667. };
  4668. // Flip video x axis if needed
  4669. flipXLocalVideo = flipX;
  4670. if (flipX) {
  4671. localVideoSelector.addClass("flipVideoX");
  4672. }
  4673. // Attach WebRTC stream
  4674. var videoStream = simulcast.getLocalVideoStream();
  4675. RTC.attachMediaStream(localVideoSelector, videoStream);
  4676. localVideoSrc = RTC.getVideoSrc(localVideo);
  4677. var myResourceJid = xmpp.myResource();
  4678. VideoLayout.updateLargeVideo(localVideoSrc, 0,
  4679. myResourceJid);
  4680. };
  4681. /**
  4682. * Checks if removed video is currently displayed and tries to display
  4683. * another one instead.
  4684. * @param removedVideoSrc src stream identifier of the video.
  4685. */
  4686. my.updateRemovedVideo = function(removedVideoSrc) {
  4687. if (removedVideoSrc === RTC.getVideoSrc($('#largeVideo')[0])) {
  4688. // this is currently displayed as large
  4689. // pick the last visible video in the row
  4690. // if nobody else is left, this picks the local video
  4691. var pick
  4692. = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video')
  4693. .get(0);
  4694. if (!pick) {
  4695. console.info("Last visible video no longer exists");
  4696. pick = $('#remoteVideos>span[id!="mixedstream"]>video').get(0);
  4697. if (!pick || !RTC.getVideoSrc(pick)) {
  4698. // Try local video
  4699. console.info("Fallback to local video...");
  4700. pick = $('#remoteVideos>span>span>video').get(0);
  4701. }
  4702. }
  4703. // mute if localvideo
  4704. if (pick) {
  4705. var container = pick.parentNode;
  4706. var jid = null;
  4707. if(container)
  4708. {
  4709. if(container.id == "localVideoWrapper")
  4710. {
  4711. jid = xmpp.myResource();
  4712. }
  4713. else
  4714. {
  4715. jid = VideoLayout.getPeerContainerResourceJid(container);
  4716. }
  4717. }
  4718. VideoLayout.updateLargeVideo(RTC.getVideoSrc(pick), pick.volume, jid);
  4719. } else {
  4720. console.warn("Failed to elect large video");
  4721. }
  4722. }
  4723. };
  4724. my.onRemoteStreamAdded = function (stream) {
  4725. var container;
  4726. var remotes = document.getElementById('remoteVideos');
  4727. if (stream.peerjid) {
  4728. VideoLayout.ensurePeerContainerExists(stream.peerjid);
  4729. container = document.getElementById(
  4730. 'participant_' + Strophe.getResourceFromJid(stream.peerjid));
  4731. } else {
  4732. var id = stream.getOriginalStream().id;
  4733. if (id !== 'mixedmslabel'
  4734. // FIXME: default stream is added always with new focus
  4735. // (to be investigated)
  4736. && id !== 'default') {
  4737. console.error('can not associate stream',
  4738. id,
  4739. 'with a participant');
  4740. // We don't want to add it here since it will cause troubles
  4741. return;
  4742. }
  4743. // FIXME: for the mixed ms we dont need a video -- currently
  4744. container = document.createElement('span');
  4745. container.id = 'mixedstream';
  4746. container.className = 'videocontainer';
  4747. remotes.appendChild(container);
  4748. UIUtil.playSoundNotification('userJoined');
  4749. }
  4750. if (container) {
  4751. VideoLayout.addRemoteStreamElement( container,
  4752. stream.sid,
  4753. stream.getOriginalStream(),
  4754. stream.peerjid,
  4755. stream.ssrc);
  4756. }
  4757. }
  4758. my.getLargeVideoState = function () {
  4759. return largeVideoState;
  4760. };
  4761. /**
  4762. * Updates the large video with the given new video source.
  4763. */
  4764. my.updateLargeVideo = function(newSrc, vol, resourceJid) {
  4765. console.log('hover in', newSrc);
  4766. if (RTC.getVideoSrc($('#largeVideo')[0]) !== newSrc) {
  4767. $('#activeSpeaker').css('visibility', 'hidden');
  4768. // Due to the simulcast the localVideoSrc may have changed when the
  4769. // fadeOut event triggers. In that case the getJidFromVideoSrc and
  4770. // isVideoSrcDesktop methods will not function correctly.
  4771. //
  4772. // Also, again due to the simulcast, the updateLargeVideo method can
  4773. // be called multiple times almost simultaneously. Therefore, we
  4774. // store the state here and update only once.
  4775. largeVideoState.newSrc = newSrc;
  4776. largeVideoState.isVisible = $('#largeVideo').is(':visible');
  4777. largeVideoState.isDesktop = RTC.isVideoSrcDesktop(resourceJid);
  4778. if(largeVideoState.userResourceJid) {
  4779. largeVideoState.oldResourceJid = largeVideoState.userResourceJid;
  4780. } else {
  4781. largeVideoState.oldResourceJid = null;
  4782. }
  4783. largeVideoState.userResourceJid = resourceJid;
  4784. // Screen stream is already rotated
  4785. largeVideoState.flipX = (newSrc === localVideoSrc) && flipXLocalVideo;
  4786. var userChanged = false;
  4787. if (largeVideoState.oldResourceJid !== largeVideoState.userResourceJid) {
  4788. userChanged = true;
  4789. // we want the notification to trigger even if userJid is undefined,
  4790. // or null.
  4791. eventEmitter.emit(UIEvents.SELECTED_ENDPOINT,
  4792. largeVideoState.userResourceJid);
  4793. }
  4794. if (!largeVideoState.updateInProgress) {
  4795. largeVideoState.updateInProgress = true;
  4796. var doUpdate = function () {
  4797. Avatar.updateActiveSpeakerAvatarSrc(
  4798. xmpp.findJidFromResource(
  4799. largeVideoState.userResourceJid));
  4800. if (!userChanged && largeVideoState.preload &&
  4801. largeVideoState.preload !== null &&
  4802. RTC.getVideoSrc($(largeVideoState.preload)[0]) === newSrc)
  4803. {
  4804. console.info('Switching to preloaded video');
  4805. var attributes = $('#largeVideo').prop("attributes");
  4806. // loop through largeVideo attributes and apply them on
  4807. // preload.
  4808. $.each(attributes, function () {
  4809. if (this.name !== 'id' && this.name !== 'src') {
  4810. largeVideoState.preload.attr(this.name, this.value);
  4811. }
  4812. });
  4813. largeVideoState.preload.appendTo($('#largeVideoContainer'));
  4814. $('#largeVideo').attr('id', 'previousLargeVideo');
  4815. largeVideoState.preload.attr('id', 'largeVideo');
  4816. $('#previousLargeVideo').remove();
  4817. largeVideoState.preload.on('loadedmetadata', function (e) {
  4818. currentVideoWidth = this.videoWidth;
  4819. currentVideoHeight = this.videoHeight;
  4820. VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
  4821. });
  4822. largeVideoState.preload = null;
  4823. largeVideoState.preload_ssrc = 0;
  4824. } else {
  4825. RTC.setVideoSrc($('#largeVideo')[0], largeVideoState.newSrc);
  4826. }
  4827. var videoTransform = document.getElementById('largeVideo')
  4828. .style.webkitTransform;
  4829. if (largeVideoState.flipX && videoTransform !== 'scaleX(-1)') {
  4830. document.getElementById('largeVideo').style.webkitTransform
  4831. = "scaleX(-1)";
  4832. }
  4833. else if (!largeVideoState.flipX && videoTransform === 'scaleX(-1)') {
  4834. document.getElementById('largeVideo').style.webkitTransform
  4835. = "none";
  4836. }
  4837. // Change the way we'll be measuring and positioning large video
  4838. VideoLayout.getVideoSize = largeVideoState.isDesktop
  4839. ? getDesktopVideoSize
  4840. : getCameraVideoSize;
  4841. VideoLayout.getVideoPosition = largeVideoState.isDesktop
  4842. ? getDesktopVideoPosition
  4843. : getCameraVideoPosition;
  4844. // Only if the large video is currently visible.
  4845. // Disable previous dominant speaker video.
  4846. if (largeVideoState.oldResourceJid) {
  4847. VideoLayout.enableDominantSpeaker(
  4848. largeVideoState.oldResourceJid,
  4849. false);
  4850. }
  4851. // Enable new dominant speaker in the remote videos section.
  4852. if (largeVideoState.userResourceJid) {
  4853. VideoLayout.enableDominantSpeaker(
  4854. largeVideoState.userResourceJid,
  4855. true);
  4856. }
  4857. if (userChanged && largeVideoState.isVisible) {
  4858. // using "this" should be ok because we're called
  4859. // from within the fadeOut event.
  4860. $(this).fadeIn(300);
  4861. }
  4862. if(userChanged) {
  4863. Avatar.showUserAvatar(
  4864. xmpp.findJidFromResource(
  4865. largeVideoState.oldResourceJid));
  4866. }
  4867. largeVideoState.updateInProgress = false;
  4868. };
  4869. if (userChanged) {
  4870. $('#largeVideo').fadeOut(300, doUpdate);
  4871. } else {
  4872. doUpdate();
  4873. }
  4874. }
  4875. } else {
  4876. Avatar.showUserAvatar(
  4877. xmpp.findJidFromResource(
  4878. largeVideoState.userResourceJid));
  4879. }
  4880. };
  4881. my.handleVideoThumbClicked = function(videoSrc,
  4882. noPinnedEndpointChangedEvent,
  4883. resourceJid) {
  4884. // Restore style for previously focused video
  4885. var oldContainer = null;
  4886. if(focusedVideoInfo) {
  4887. var focusResourceJid = focusedVideoInfo.resourceJid;
  4888. oldContainer = getParticipantContainer(focusResourceJid);
  4889. }
  4890. if (oldContainer) {
  4891. oldContainer.removeClass("videoContainerFocused");
  4892. }
  4893. // Unlock current focused.
  4894. if (focusedVideoInfo && focusedVideoInfo.src === videoSrc)
  4895. {
  4896. focusedVideoInfo = null;
  4897. var dominantSpeakerVideo = null;
  4898. // Enable the currently set dominant speaker.
  4899. if (currentDominantSpeaker) {
  4900. dominantSpeakerVideo
  4901. = $('#participant_' + currentDominantSpeaker + '>video')
  4902. .get(0);
  4903. if (dominantSpeakerVideo) {
  4904. VideoLayout.updateLargeVideo(
  4905. RTC.getVideoSrc(dominantSpeakerVideo),
  4906. 1,
  4907. currentDominantSpeaker);
  4908. }
  4909. }
  4910. if (!noPinnedEndpointChangedEvent) {
  4911. eventEmitter.emit(UIEvents.PINNED_ENDPOINT);
  4912. }
  4913. return;
  4914. }
  4915. // Lock new video
  4916. focusedVideoInfo = {
  4917. src: videoSrc,
  4918. resourceJid: resourceJid
  4919. };
  4920. // Update focused/pinned interface.
  4921. if (resourceJid)
  4922. {
  4923. var container = getParticipantContainer(resourceJid);
  4924. container.addClass("videoContainerFocused");
  4925. if (!noPinnedEndpointChangedEvent) {
  4926. eventEmitter.emit(UIEvents.PINNED_ENDPOINT, resourceJid);
  4927. }
  4928. }
  4929. if ($('#largeVideo').attr('src') === videoSrc &&
  4930. VideoLayout.isLargeVideoOnTop()) {
  4931. return;
  4932. }
  4933. // Triggers a "video.selected" event. The "false" parameter indicates
  4934. // this isn't a prezi.
  4935. $(document).trigger("video.selected", [false]);
  4936. VideoLayout.updateLargeVideo(videoSrc, 1, resourceJid);
  4937. $('audio').each(function (idx, el) {
  4938. if (el.id.indexOf('mixedmslabel') !== -1) {
  4939. el.volume = 0;
  4940. el.volume = 1;
  4941. }
  4942. });
  4943. };
  4944. /**
  4945. * Positions the large video.
  4946. *
  4947. * @param videoWidth the stream video width
  4948. * @param videoHeight the stream video height
  4949. */
  4950. my.positionLarge = function (videoWidth, videoHeight) {
  4951. var videoSpaceWidth = $('#videospace').width();
  4952. var videoSpaceHeight = window.innerHeight;
  4953. var videoSize = VideoLayout.getVideoSize(videoWidth,
  4954. videoHeight,
  4955. videoSpaceWidth,
  4956. videoSpaceHeight);
  4957. var largeVideoWidth = videoSize[0];
  4958. var largeVideoHeight = videoSize[1];
  4959. var videoPosition = VideoLayout.getVideoPosition(largeVideoWidth,
  4960. largeVideoHeight,
  4961. videoSpaceWidth,
  4962. videoSpaceHeight);
  4963. var horizontalIndent = videoPosition[0];
  4964. var verticalIndent = videoPosition[1];
  4965. positionVideo($('#largeVideo'),
  4966. largeVideoWidth,
  4967. largeVideoHeight,
  4968. horizontalIndent, verticalIndent);
  4969. };
  4970. /**
  4971. * Shows/hides the large video.
  4972. */
  4973. my.setLargeVideoVisible = function(isVisible) {
  4974. var resourceJid = largeVideoState.userResourceJid;
  4975. if (isVisible) {
  4976. $('#largeVideo').css({visibility: 'visible'});
  4977. $('.watermark').css({visibility: 'visible'});
  4978. VideoLayout.enableDominantSpeaker(resourceJid, true);
  4979. }
  4980. else {
  4981. $('#largeVideo').css({visibility: 'hidden'});
  4982. $('#activeSpeaker').css('visibility', 'hidden');
  4983. $('.watermark').css({visibility: 'hidden'});
  4984. VideoLayout.enableDominantSpeaker(resourceJid, false);
  4985. if(focusedVideoInfo) {
  4986. var focusResourceJid = focusedVideoInfo.resourceJid;
  4987. var oldContainer = getParticipantContainer(focusResourceJid);
  4988. if (oldContainer && oldContainer.length > 0) {
  4989. oldContainer.removeClass("videoContainerFocused");
  4990. }
  4991. focusedVideoInfo = null;
  4992. if(focusResourceJid) {
  4993. Avatar.showUserAvatar(
  4994. xmpp.findJidFromResource(focusResourceJid));
  4995. }
  4996. }
  4997. }
  4998. };
  4999. /**
  5000. * Indicates if the large video is currently visible.
  5001. *
  5002. * @return <tt>true</tt> if visible, <tt>false</tt> - otherwise
  5003. */
  5004. my.isLargeVideoVisible = function() {
  5005. return $('#largeVideo').is(':visible');
  5006. };
  5007. my.isLargeVideoOnTop = function () {
  5008. var Etherpad = require("../etherpad/Etherpad");
  5009. var Prezi = require("../prezi/Prezi");
  5010. return !Prezi.isPresentationVisible() && !Etherpad.isVisible();
  5011. };
  5012. /**
  5013. * Checks if container for participant identified by given peerJid exists
  5014. * in the document and creates it eventually.
  5015. *
  5016. * @param peerJid peer Jid to check.
  5017. * @param userId user email or id for setting the avatar
  5018. *
  5019. * @return Returns <tt>true</tt> if the peer container exists,
  5020. * <tt>false</tt> - otherwise
  5021. */
  5022. my.ensurePeerContainerExists = function(peerJid, userId) {
  5023. ContactList.ensureAddContact(peerJid, userId);
  5024. var resourceJid = Strophe.getResourceFromJid(peerJid);
  5025. var videoSpanId = 'participant_' + resourceJid;
  5026. if (!$('#' + videoSpanId).length) {
  5027. var container =
  5028. VideoLayout.addRemoteVideoContainer(peerJid, videoSpanId, userId);
  5029. Avatar.setUserAvatar(peerJid, userId);
  5030. // Set default display name.
  5031. setDisplayName(videoSpanId);
  5032. VideoLayout.connectionIndicators[videoSpanId] =
  5033. new ConnectionIndicator(container, peerJid, VideoLayout);
  5034. var nickfield = document.createElement('span');
  5035. nickfield.className = "nick";
  5036. nickfield.appendChild(document.createTextNode(resourceJid));
  5037. container.appendChild(nickfield);
  5038. // In case this is not currently in the last n we don't show it.
  5039. if (localLastNCount
  5040. && localLastNCount > 0
  5041. && $('#remoteVideos>span').length >= localLastNCount + 2) {
  5042. showPeerContainer(resourceJid, 'hide');
  5043. }
  5044. else
  5045. VideoLayout.resizeThumbnails();
  5046. }
  5047. };
  5048. my.addRemoteVideoContainer = function(peerJid, spanId) {
  5049. var container = document.createElement('span');
  5050. container.id = spanId;
  5051. container.className = 'videocontainer';
  5052. var remotes = document.getElementById('remoteVideos');
  5053. // If the peerJid is null then this video span couldn't be directly
  5054. // associated with a participant (this could happen in the case of prezi).
  5055. if (xmpp.isModerator() && peerJid !== null)
  5056. addRemoteVideoMenu(peerJid, container);
  5057. remotes.appendChild(container);
  5058. AudioLevels.updateAudioLevelCanvas(peerJid, VideoLayout);
  5059. return container;
  5060. };
  5061. /**
  5062. * Creates an audio or video stream element.
  5063. */
  5064. my.createStreamElement = function (sid, stream) {
  5065. var isVideo = stream.getVideoTracks().length > 0;
  5066. var element = isVideo
  5067. ? document.createElement('video')
  5068. : document.createElement('audio');
  5069. var id = (isVideo ? 'remoteVideo_' : 'remoteAudio_')
  5070. + sid + '_' + RTC.getStreamID(stream);
  5071. element.id = id;
  5072. element.autoplay = true;
  5073. element.oncontextmenu = function () { return false; };
  5074. return element;
  5075. };
  5076. my.addRemoteStreamElement
  5077. = function (container, sid, stream, peerJid, thessrc) {
  5078. var newElementId = null;
  5079. var isVideo = stream.getVideoTracks().length > 0;
  5080. if (container) {
  5081. var streamElement = VideoLayout.createStreamElement(sid, stream);
  5082. newElementId = streamElement.id;
  5083. container.appendChild(streamElement);
  5084. var sel = $('#' + newElementId);
  5085. sel.hide();
  5086. // If the container is currently visible we attach the stream.
  5087. if (!isVideo
  5088. || (container.offsetParent !== null && isVideo)) {
  5089. var videoStream = simulcast.getReceivingVideoStream(stream);
  5090. RTC.attachMediaStream(sel, videoStream);
  5091. if (isVideo)
  5092. waitForRemoteVideo(sel, thessrc, stream, peerJid);
  5093. }
  5094. stream.onended = function () {
  5095. console.log('stream ended', this);
  5096. VideoLayout.removeRemoteStreamElement(
  5097. stream, isVideo, container);
  5098. // NOTE(gp) it seems that under certain circumstances, the
  5099. // onended event is not fired and thus the contact list is not
  5100. // updated.
  5101. //
  5102. // The onended event of a stream should be fired when the SSRCs
  5103. // corresponding to that stream are removed from the SDP; but
  5104. // this doesn't seem to always be the case, resulting in ghost
  5105. // contacts.
  5106. //
  5107. // In an attempt to fix the ghost contacts problem, I'm moving
  5108. // the removeContact() method call in app.js, inside the
  5109. // 'muc.left' event handler.
  5110. //if (peerJid)
  5111. // ContactList.removeContact(peerJid);
  5112. };
  5113. // Add click handler.
  5114. container.onclick = function (event) {
  5115. /*
  5116. * FIXME It turns out that videoThumb may not exist (if there is
  5117. * no actual video).
  5118. */
  5119. var videoThumb = $('#' + container.id + '>video').get(0);
  5120. if (videoThumb) {
  5121. VideoLayout.handleVideoThumbClicked(
  5122. RTC.getVideoSrc(videoThumb),
  5123. false,
  5124. Strophe.getResourceFromJid(peerJid));
  5125. }
  5126. event.stopPropagation();
  5127. event.preventDefault();
  5128. return false;
  5129. };
  5130. // Add hover handler
  5131. $(container).hover(
  5132. function() {
  5133. VideoLayout.showDisplayName(container.id, true);
  5134. },
  5135. function() {
  5136. var videoSrc = null;
  5137. if ($('#' + container.id + '>video')
  5138. && $('#' + container.id + '>video').length > 0) {
  5139. videoSrc = RTC.getVideoSrc($('#' + container.id + '>video').get(0));
  5140. }
  5141. // If the video has been "pinned" by the user we want to
  5142. // keep the display name on place.
  5143. if (!VideoLayout.isLargeVideoVisible()
  5144. || videoSrc !== RTC.getVideoSrc($('#largeVideo')[0]))
  5145. VideoLayout.showDisplayName(container.id, false);
  5146. }
  5147. );
  5148. }
  5149. return newElementId;
  5150. };
  5151. /**
  5152. * Removes the remote stream element corresponding to the given stream and
  5153. * parent container.
  5154. *
  5155. * @param stream the stream
  5156. * @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
  5157. * @param container
  5158. */
  5159. my.removeRemoteStreamElement = function (stream, isVideo, container) {
  5160. if (!container)
  5161. return;
  5162. var select = null;
  5163. var removedVideoSrc = null;
  5164. if (isVideo) {
  5165. select = $('#' + container.id + '>video');
  5166. removedVideoSrc = RTC.getVideoSrc(select.get(0));
  5167. }
  5168. else
  5169. select = $('#' + container.id + '>audio');
  5170. // Mark video as removed to cancel waiting loop(if video is removed
  5171. // before has started)
  5172. select.removed = true;
  5173. select.remove();
  5174. var audioCount = $('#' + container.id + '>audio').length;
  5175. var videoCount = $('#' + container.id + '>video').length;
  5176. if (!audioCount && !videoCount) {
  5177. console.log("Remove whole user", container.id);
  5178. if(VideoLayout.connectionIndicators[container.id])
  5179. VideoLayout.connectionIndicators[container.id].remove();
  5180. // Remove whole container
  5181. container.remove();
  5182. UIUtil.playSoundNotification('userLeft');
  5183. VideoLayout.resizeThumbnails();
  5184. }
  5185. if (removedVideoSrc)
  5186. VideoLayout.updateRemovedVideo(removedVideoSrc);
  5187. };
  5188. /**
  5189. * Show/hide peer container for the given resourceJid.
  5190. */
  5191. function showPeerContainer(resourceJid, state) {
  5192. var peerContainer = $('#participant_' + resourceJid);
  5193. if (!peerContainer)
  5194. return;
  5195. var isHide = state === 'hide';
  5196. var resizeThumbnails = false;
  5197. if (!isHide) {
  5198. if (!peerContainer.is(':visible')) {
  5199. resizeThumbnails = true;
  5200. peerContainer.show();
  5201. }
  5202. if (state == 'show')
  5203. {
  5204. // peerContainer.css('-webkit-filter', '');
  5205. var jid = xmpp.findJidFromResource(resourceJid);
  5206. Avatar.showUserAvatar(jid, false);
  5207. }
  5208. else // if (state == 'avatar')
  5209. {
  5210. // peerContainer.css('-webkit-filter', 'grayscale(100%)');
  5211. var jid = xmpp.findJidFromResource(resourceJid);
  5212. Avatar.showUserAvatar(jid, true);
  5213. }
  5214. }
  5215. else if (peerContainer.is(':visible') && isHide)
  5216. {
  5217. resizeThumbnails = true;
  5218. peerContainer.hide();
  5219. if(VideoLayout.connectionIndicators['participant_' + resourceJid])
  5220. VideoLayout.connectionIndicators['participant_' + resourceJid].hide();
  5221. }
  5222. if (resizeThumbnails) {
  5223. VideoLayout.resizeThumbnails();
  5224. }
  5225. // We want to be able to pin a participant from the contact list, even
  5226. // if he's not in the lastN set!
  5227. // ContactList.setClickable(resourceJid, !isHide);
  5228. };
  5229. my.inputDisplayNameHandler = function (name) {
  5230. NicknameHandler.setNickname(name);
  5231. if (!$('#localDisplayName').is(":visible")) {
  5232. if (NicknameHandler.getNickname())
  5233. $('#localDisplayName').text(NicknameHandler.getNickname() + " (me)");
  5234. else
  5235. $('#localDisplayName')
  5236. .text(interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME);
  5237. $('#localDisplayName').show();
  5238. }
  5239. $('#editDisplayName').hide();
  5240. };
  5241. /**
  5242. * Shows/hides the display name on the remote video.
  5243. * @param videoSpanId the identifier of the video span element
  5244. * @param isShow indicates if the display name should be shown or hidden
  5245. */
  5246. my.showDisplayName = function(videoSpanId, isShow) {
  5247. var nameSpan = $('#' + videoSpanId + '>span.displayname').get(0);
  5248. if (isShow) {
  5249. if (nameSpan && nameSpan.innerHTML && nameSpan.innerHTML.length)
  5250. nameSpan.setAttribute("style", "display:inline-block;");
  5251. }
  5252. else {
  5253. if (nameSpan)
  5254. nameSpan.setAttribute("style", "display:none;");
  5255. }
  5256. };
  5257. /**
  5258. * Shows the presence status message for the given video.
  5259. */
  5260. my.setPresenceStatus = function (videoSpanId, statusMsg) {
  5261. if (!$('#' + videoSpanId).length) {
  5262. // No container
  5263. return;
  5264. }
  5265. var statusSpan = $('#' + videoSpanId + '>span.status');
  5266. if (!statusSpan.length) {
  5267. //Add status span
  5268. statusSpan = document.createElement('span');
  5269. statusSpan.className = 'status';
  5270. statusSpan.id = videoSpanId + '_status';
  5271. $('#' + videoSpanId)[0].appendChild(statusSpan);
  5272. statusSpan = $('#' + videoSpanId + '>span.status');
  5273. }
  5274. // Display status
  5275. if (statusMsg && statusMsg.length) {
  5276. $('#' + videoSpanId + '_status').text(statusMsg);
  5277. statusSpan.get(0).setAttribute("style", "display:inline-block;");
  5278. }
  5279. else {
  5280. // Hide
  5281. statusSpan.get(0).setAttribute("style", "display:none;");
  5282. }
  5283. };
  5284. /**
  5285. * Shows a visual indicator for the moderator of the conference.
  5286. */
  5287. my.showModeratorIndicator = function () {
  5288. var isModerator = xmpp.isModerator();
  5289. if (isModerator) {
  5290. var indicatorSpan = $('#localVideoContainer .focusindicator');
  5291. if (indicatorSpan.children().length === 0)
  5292. {
  5293. createModeratorIndicatorElement(indicatorSpan[0]);
  5294. }
  5295. }
  5296. var members = xmpp.getMembers();
  5297. Object.keys(members).forEach(function (jid) {
  5298. if (Strophe.getResourceFromJid(jid) === 'focus') {
  5299. // Skip server side focus
  5300. return;
  5301. }
  5302. var resourceJid = Strophe.getResourceFromJid(jid);
  5303. var videoSpanId = 'participant_' + resourceJid;
  5304. var videoContainer = document.getElementById(videoSpanId);
  5305. if (!videoContainer) {
  5306. console.error("No video container for " + jid);
  5307. return;
  5308. }
  5309. var member = members[jid];
  5310. if (member.role === 'moderator') {
  5311. // Remove menu if peer is moderator
  5312. var menuSpan = $('#' + videoSpanId + '>span.remotevideomenu');
  5313. if (menuSpan.length) {
  5314. removeRemoteVideoMenu(videoSpanId);
  5315. }
  5316. // Show moderator indicator
  5317. var indicatorSpan
  5318. = $('#' + videoSpanId + ' .focusindicator');
  5319. if (!indicatorSpan || indicatorSpan.length === 0) {
  5320. indicatorSpan = document.createElement('span');
  5321. indicatorSpan.className = 'focusindicator';
  5322. videoContainer.appendChild(indicatorSpan);
  5323. createModeratorIndicatorElement(indicatorSpan);
  5324. }
  5325. } else if (isModerator) {
  5326. // We are moderator, but user is not - add menu
  5327. if ($('#remote_popupmenu_' + resourceJid).length <= 0) {
  5328. addRemoteVideoMenu(
  5329. jid,
  5330. document.getElementById('participant_' + resourceJid));
  5331. }
  5332. }
  5333. });
  5334. };
  5335. /**
  5336. * Shows video muted indicator over small videos.
  5337. */
  5338. my.showVideoIndicator = function(videoSpanId, isMuted) {
  5339. var videoMutedSpan = $('#' + videoSpanId + '>span.videoMuted');
  5340. if (isMuted === 'false') {
  5341. if (videoMutedSpan.length > 0) {
  5342. videoMutedSpan.remove();
  5343. }
  5344. }
  5345. else {
  5346. if(videoMutedSpan.length == 0) {
  5347. videoMutedSpan = document.createElement('span');
  5348. videoMutedSpan.className = 'videoMuted';
  5349. $('#' + videoSpanId)[0].appendChild(videoMutedSpan);
  5350. var mutedIndicator = document.createElement('i');
  5351. mutedIndicator.className = 'icon-camera-disabled';
  5352. UIUtil.setTooltip(mutedIndicator,
  5353. "Participant has<br/>stopped the camera.",
  5354. "top");
  5355. videoMutedSpan.appendChild(mutedIndicator);
  5356. }
  5357. VideoLayout.updateMutePosition(videoSpanId);
  5358. }
  5359. };
  5360. my.updateMutePosition = function (videoSpanId) {
  5361. var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
  5362. var connectionIndicator = $('#' + videoSpanId + '>div.connectionindicator');
  5363. var videoMutedSpan = $('#' + videoSpanId + '>span.videoMuted');
  5364. if(connectionIndicator.length > 0
  5365. && connectionIndicator[0].style.display != "none") {
  5366. audioMutedSpan.css({right: "23px"});
  5367. videoMutedSpan.css({right: ((audioMutedSpan.length > 0? 23 : 0) + 30) + "px"});
  5368. }
  5369. else
  5370. {
  5371. audioMutedSpan.css({right: "0px"});
  5372. videoMutedSpan.css({right: (audioMutedSpan.length > 0? 30 : 0) + "px"});
  5373. }
  5374. }
  5375. /**
  5376. * Shows audio muted indicator over small videos.
  5377. * @param {string} isMuted
  5378. */
  5379. my.showAudioIndicator = function(videoSpanId, isMuted) {
  5380. var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
  5381. if (isMuted === 'false') {
  5382. if (audioMutedSpan.length > 0) {
  5383. audioMutedSpan.popover('hide');
  5384. audioMutedSpan.remove();
  5385. }
  5386. }
  5387. else {
  5388. if(audioMutedSpan.length == 0 ) {
  5389. audioMutedSpan = document.createElement('span');
  5390. audioMutedSpan.className = 'audioMuted';
  5391. UIUtil.setTooltip(audioMutedSpan,
  5392. "Participant is muted",
  5393. "top");
  5394. $('#' + videoSpanId)[0].appendChild(audioMutedSpan);
  5395. var mutedIndicator = document.createElement('i');
  5396. mutedIndicator.className = 'icon-mic-disabled';
  5397. audioMutedSpan.appendChild(mutedIndicator);
  5398. }
  5399. VideoLayout.updateMutePosition(videoSpanId);
  5400. }
  5401. };
  5402. /*
  5403. * Shows or hides the audio muted indicator over the local thumbnail video.
  5404. * @param {boolean} isMuted
  5405. */
  5406. my.showLocalAudioIndicator = function(isMuted) {
  5407. VideoLayout.showAudioIndicator('localVideoContainer', isMuted.toString());
  5408. };
  5409. /**
  5410. * Resizes the large video container.
  5411. */
  5412. my.resizeLargeVideoContainer = function () {
  5413. Chat.resizeChat();
  5414. var availableHeight = window.innerHeight;
  5415. var availableWidth = UIUtil.getAvailableVideoWidth();
  5416. if (availableWidth < 0 || availableHeight < 0) return;
  5417. $('#videospace').width(availableWidth);
  5418. $('#videospace').height(availableHeight);
  5419. $('#largeVideoContainer').width(availableWidth);
  5420. $('#largeVideoContainer').height(availableHeight);
  5421. var avatarSize = interfaceConfig.ACTIVE_SPEAKER_AVATAR_SIZE;
  5422. var top = availableHeight / 2 - avatarSize / 4 * 3;
  5423. $('#activeSpeaker').css('top', top);
  5424. VideoLayout.resizeThumbnails();
  5425. };
  5426. /**
  5427. * Resizes thumbnails.
  5428. */
  5429. my.resizeThumbnails = function() {
  5430. var videoSpaceWidth = $('#remoteVideos').width();
  5431. var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);
  5432. var width = thumbnailSize[0];
  5433. var height = thumbnailSize[1];
  5434. // size videos so that while keeping AR and max height, we have a
  5435. // nice fit
  5436. $('#remoteVideos').height(height);
  5437. $('#remoteVideos>span').width(width);
  5438. $('#remoteVideos>span').height(height);
  5439. $('.userAvatar').css('left', (width - height) / 2);
  5440. $(document).trigger("remotevideo.resized", [width, height]);
  5441. };
  5442. /**
  5443. * Enables the dominant speaker UI.
  5444. *
  5445. * @param resourceJid the jid indicating the video element to
  5446. * activate/deactivate
  5447. * @param isEnable indicates if the dominant speaker should be enabled or
  5448. * disabled
  5449. */
  5450. my.enableDominantSpeaker = function(resourceJid, isEnable) {
  5451. var videoSpanId = null;
  5452. var videoContainerId = null;
  5453. if (resourceJid
  5454. === xmpp.myResource()) {
  5455. videoSpanId = 'localVideoWrapper';
  5456. videoContainerId = 'localVideoContainer';
  5457. }
  5458. else {
  5459. videoSpanId = 'participant_' + resourceJid;
  5460. videoContainerId = videoSpanId;
  5461. }
  5462. var displayName = resourceJid;
  5463. var nameSpan = $('#' + videoContainerId + '>span.displayname');
  5464. if (nameSpan.length > 0)
  5465. displayName = nameSpan.html();
  5466. console.log("UI enable dominant speaker",
  5467. displayName,
  5468. resourceJid,
  5469. isEnable);
  5470. videoSpan = document.getElementById(videoContainerId);
  5471. if (!videoSpan) {
  5472. return;
  5473. }
  5474. var video = $('#' + videoSpanId + '>video');
  5475. if (video && video.length > 0) {
  5476. if (isEnable) {
  5477. var isLargeVideoVisible = VideoLayout.isLargeVideoOnTop();
  5478. VideoLayout.showDisplayName(videoContainerId, isLargeVideoVisible);
  5479. if (!videoSpan.classList.contains("dominantspeaker"))
  5480. videoSpan.classList.add("dominantspeaker");
  5481. }
  5482. else {
  5483. VideoLayout.showDisplayName(videoContainerId, false);
  5484. if (videoSpan.classList.contains("dominantspeaker"))
  5485. videoSpan.classList.remove("dominantspeaker");
  5486. }
  5487. Avatar.showUserAvatar(
  5488. xmpp.findJidFromResource(resourceJid));
  5489. }
  5490. };
  5491. /**
  5492. * Calculates the thumbnail size.
  5493. *
  5494. * @param videoSpaceWidth the width of the video space
  5495. */
  5496. my.calculateThumbnailSize = function (videoSpaceWidth) {
  5497. // Calculate the available height, which is the inner window height minus
  5498. // 39px for the header minus 2px for the delimiter lines on the top and
  5499. // bottom of the large video, minus the 36px space inside the remoteVideos
  5500. // container used for highlighting shadow.
  5501. var availableHeight = 100;
  5502. var numvids = $('#remoteVideos>span:visible').length;
  5503. if (localLastNCount && localLastNCount > 0) {
  5504. numvids = Math.min(localLastNCount + 1, numvids);
  5505. }
  5506. // Remove the 3px borders arround videos and border around the remote
  5507. // videos area and the 4 pixels between the local video and the others
  5508. //TODO: Find out where the 4 pixels come from and remove them
  5509. var availableWinWidth = videoSpaceWidth - 2 * 3 * numvids - 70 - 4;
  5510. var availableWidth = availableWinWidth / numvids;
  5511. var aspectRatio = 16.0 / 9.0;
  5512. var maxHeight = Math.min(160, availableHeight);
  5513. availableHeight = Math.min(maxHeight, availableWidth / aspectRatio);
  5514. if (availableHeight < availableWidth / aspectRatio) {
  5515. availableWidth = Math.floor(availableHeight * aspectRatio);
  5516. }
  5517. return [availableWidth, availableHeight];
  5518. };
  5519. /**
  5520. * Updates the remote video menu.
  5521. *
  5522. * @param jid the jid indicating the video for which we're adding a menu.
  5523. * @param isMuted indicates the current mute state
  5524. */
  5525. my.updateRemoteVideoMenu = function(jid, isMuted) {
  5526. var muteMenuItem
  5527. = $('#remote_popupmenu_'
  5528. + Strophe.getResourceFromJid(jid)
  5529. + '>li>a.mutelink');
  5530. var mutedIndicator = "<i class='icon-mic-disabled'></i>";
  5531. if (muteMenuItem.length) {
  5532. var muteLink = muteMenuItem.get(0);
  5533. if (isMuted === 'true') {
  5534. muteLink.innerHTML = mutedIndicator + ' Muted';
  5535. muteLink.className = 'mutelink disabled';
  5536. }
  5537. else {
  5538. muteLink.innerHTML = mutedIndicator + ' Mute';
  5539. muteLink.className = 'mutelink';
  5540. }
  5541. }
  5542. };
  5543. /**
  5544. * Returns the current dominant speaker resource jid.
  5545. */
  5546. my.getDominantSpeakerResourceJid = function () {
  5547. return currentDominantSpeaker;
  5548. };
  5549. /**
  5550. * Returns the corresponding resource jid to the given peer container
  5551. * DOM element.
  5552. *
  5553. * @return the corresponding resource jid to the given peer container
  5554. * DOM element
  5555. */
  5556. my.getPeerContainerResourceJid = function (containerElement) {
  5557. var i = containerElement.id.indexOf('participant_');
  5558. if (i >= 0)
  5559. return containerElement.id.substring(i + 12);
  5560. };
  5561. /**
  5562. * On contact list item clicked.
  5563. */
  5564. $(ContactList).bind('contactclicked', function(event, jid) {
  5565. if (!jid) {
  5566. return;
  5567. }
  5568. var resource = Strophe.getResourceFromJid(jid);
  5569. var videoContainer = $("#participant_" + resource);
  5570. if (videoContainer.length > 0) {
  5571. var videoThumb = $('video', videoContainer).get(0);
  5572. // It is not always the case that a videoThumb exists (if there is
  5573. // no actual video).
  5574. if (videoThumb) {
  5575. if (videoThumb.src && videoThumb.src != '') {
  5576. // We have a video src, great! Let's update the large video
  5577. // now.
  5578. VideoLayout.handleVideoThumbClicked(
  5579. videoThumb.src,
  5580. false,
  5581. Strophe.getResourceFromJid(jid));
  5582. } else {
  5583. // If we don't have a video src for jid, there's absolutely
  5584. // no point in calling handleVideoThumbClicked; Quite
  5585. // simply, it won't work because it needs an src to attach
  5586. // to the large video.
  5587. //
  5588. // Instead, we trigger the pinned endpoint changed event to
  5589. // let the bridge adjust its lastN set for myjid and store
  5590. // the pinned user in the lastNPickupJid variable to be
  5591. // picked up later by the lastN changed event handler.
  5592. lastNPickupJid = jid;
  5593. eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
  5594. Strophe.getResourceFromJid(jid));
  5595. }
  5596. } else if (jid == xmpp.myJid()) {
  5597. $("#localVideoContainer").click();
  5598. }
  5599. }
  5600. });
  5601. /**
  5602. * On audio muted event.
  5603. */
  5604. $(document).bind('audiomuted.muc', function (event, jid, isMuted) {
  5605. /*
  5606. // FIXME: but focus can not mute in this case ? - check
  5607. if (jid === xmpp.myJid()) {
  5608. // The local mute indicator is controlled locally
  5609. return;
  5610. }*/
  5611. var videoSpanId = null;
  5612. if (jid === xmpp.myJid()) {
  5613. videoSpanId = 'localVideoContainer';
  5614. } else {
  5615. VideoLayout.ensurePeerContainerExists(jid);
  5616. videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
  5617. }
  5618. mutedAudios[jid] = isMuted;
  5619. if (xmpp.isModerator()) {
  5620. VideoLayout.updateRemoteVideoMenu(jid, isMuted);
  5621. }
  5622. if (videoSpanId)
  5623. VideoLayout.showAudioIndicator(videoSpanId, isMuted);
  5624. });
  5625. /**
  5626. * On video muted event.
  5627. */
  5628. $(document).bind('videomuted.muc', function (event, jid, value) {
  5629. var isMuted = (value === "true");
  5630. if(!RTC.muteRemoteVideoStream(jid, isMuted))
  5631. return;
  5632. Avatar.showUserAvatar(jid, isMuted);
  5633. var videoSpanId = null;
  5634. if (jid === xmpp.myJid()) {
  5635. videoSpanId = 'localVideoContainer';
  5636. } else {
  5637. VideoLayout.ensurePeerContainerExists(jid);
  5638. videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
  5639. }
  5640. if (videoSpanId)
  5641. VideoLayout.showVideoIndicator(videoSpanId, value);
  5642. });
  5643. /**
  5644. * Display name changed.
  5645. */
  5646. my.onDisplayNameChanged =
  5647. function (jid, displayName, status) {
  5648. if (jid === 'localVideoContainer'
  5649. || jid === xmpp.myJid()) {
  5650. setDisplayName('localVideoContainer',
  5651. displayName);
  5652. } else {
  5653. VideoLayout.ensurePeerContainerExists(jid);
  5654. setDisplayName(
  5655. 'participant_' + Strophe.getResourceFromJid(jid),
  5656. displayName,
  5657. status);
  5658. }
  5659. };
  5660. /**
  5661. * On dominant speaker changed event.
  5662. */
  5663. my.onDominantSpeakerChanged = function (resourceJid) {
  5664. // We ignore local user events.
  5665. if (resourceJid
  5666. === xmpp.myResource())
  5667. return;
  5668. // Update the current dominant speaker.
  5669. if (resourceJid !== currentDominantSpeaker) {
  5670. var oldSpeakerVideoSpanId = "participant_" + currentDominantSpeaker,
  5671. newSpeakerVideoSpanId = "participant_" + resourceJid;
  5672. if($("#" + oldSpeakerVideoSpanId + ">span.displayname").text() ===
  5673. interfaceConfig.DEFAULT_DOMINANT_SPEAKER_DISPLAY_NAME) {
  5674. setDisplayName(oldSpeakerVideoSpanId, null);
  5675. }
  5676. if($("#" + newSpeakerVideoSpanId + ">span.displayname").text() ===
  5677. interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME) {
  5678. setDisplayName(newSpeakerVideoSpanId,
  5679. interfaceConfig.DEFAULT_DOMINANT_SPEAKER_DISPLAY_NAME);
  5680. }
  5681. currentDominantSpeaker = resourceJid;
  5682. } else {
  5683. return;
  5684. }
  5685. // Obtain container for new dominant speaker.
  5686. var container = document.getElementById(
  5687. 'participant_' + resourceJid);
  5688. // Local video will not have container found, but that's ok
  5689. // since we don't want to switch to local video.
  5690. if (container && !focusedVideoInfo)
  5691. {
  5692. var video = container.getElementsByTagName("video");
  5693. // Update the large video if the video source is already available,
  5694. // otherwise wait for the "videoactive.jingle" event.
  5695. if (video.length && video[0].currentTime > 0)
  5696. VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
  5697. }
  5698. };
  5699. /**
  5700. * On last N change event.
  5701. *
  5702. * @param lastNEndpoints the list of last N endpoints
  5703. * @param endpointsEnteringLastN the list currently entering last N
  5704. * endpoints
  5705. */
  5706. my.onLastNEndpointsChanged = function ( lastNEndpoints,
  5707. endpointsEnteringLastN,
  5708. stream) {
  5709. if (lastNCount !== lastNEndpoints.length)
  5710. lastNCount = lastNEndpoints.length;
  5711. lastNEndpointsCache = lastNEndpoints;
  5712. // Say A, B, C, D, E, and F are in a conference and LastN = 3.
  5713. //
  5714. // If LastN drops to, say, 2, because of adaptivity, then E should see
  5715. // thumbnails for A, B and C. A and B are in E's server side LastN set,
  5716. // so E sees them. C is only in E's local LastN set.
  5717. //
  5718. // If F starts talking and LastN = 3, then E should see thumbnails for
  5719. // F, A, B. B gets "ejected" from E's server side LastN set, but it
  5720. // enters E's local LastN ejecting C.
  5721. // Increase the local LastN set size, if necessary.
  5722. if (lastNCount > localLastNCount) {
  5723. localLastNCount = lastNCount;
  5724. }
  5725. // Update the local LastN set preserving the order in which the
  5726. // endpoints appeared in the LastN/local LastN set.
  5727. var nextLocalLastNSet = lastNEndpoints.slice(0);
  5728. for (var i = 0; i < localLastNSet.length; i++) {
  5729. if (nextLocalLastNSet.length >= localLastNCount) {
  5730. break;
  5731. }
  5732. var resourceJid = localLastNSet[i];
  5733. if (nextLocalLastNSet.indexOf(resourceJid) === -1) {
  5734. nextLocalLastNSet.push(resourceJid);
  5735. }
  5736. }
  5737. localLastNSet = nextLocalLastNSet;
  5738. var updateLargeVideo = false;
  5739. // Handle LastN/local LastN changes.
  5740. $('#remoteVideos>span').each(function( index, element ) {
  5741. var resourceJid = VideoLayout.getPeerContainerResourceJid(element);
  5742. var isReceived = true;
  5743. if (resourceJid
  5744. && lastNEndpoints.indexOf(resourceJid) < 0
  5745. && localLastNSet.indexOf(resourceJid) < 0) {
  5746. console.log("Remove from last N", resourceJid);
  5747. showPeerContainer(resourceJid, 'hide');
  5748. isReceived = false;
  5749. } else if (resourceJid
  5750. && $('#participant_' + resourceJid).is(':visible')
  5751. && lastNEndpoints.indexOf(resourceJid) < 0
  5752. && localLastNSet.indexOf(resourceJid) >= 0) {
  5753. showPeerContainer(resourceJid, 'avatar');
  5754. isReceived = false;
  5755. }
  5756. if (!isReceived) {
  5757. // resourceJid has dropped out of the server side lastN set, so
  5758. // it is no longer being received. If resourceJid was being
  5759. // displayed in the large video we have to switch to another
  5760. // user.
  5761. var largeVideoResource = largeVideoState.userResourceJid;
  5762. if (!updateLargeVideo && resourceJid === largeVideoResource) {
  5763. updateLargeVideo = true;
  5764. }
  5765. }
  5766. });
  5767. if (!endpointsEnteringLastN || endpointsEnteringLastN.length < 0)
  5768. endpointsEnteringLastN = lastNEndpoints;
  5769. if (endpointsEnteringLastN && endpointsEnteringLastN.length > 0) {
  5770. endpointsEnteringLastN.forEach(function (resourceJid) {
  5771. var isVisible = $('#participant_' + resourceJid).is(':visible');
  5772. showPeerContainer(resourceJid, 'show');
  5773. if (!isVisible) {
  5774. console.log("Add to last N", resourceJid);
  5775. var jid = xmpp.findJidFromResource(resourceJid);
  5776. var mediaStream = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
  5777. var sel = $('#participant_' + resourceJid + '>video');
  5778. var videoStream = simulcast.getReceivingVideoStream(
  5779. mediaStream.stream);
  5780. RTC.attachMediaStream(sel, videoStream);
  5781. if (lastNPickupJid == mediaStream.peerjid) {
  5782. // Clean up the lastN pickup jid.
  5783. lastNPickupJid = null;
  5784. // Don't fire the events again, they've already
  5785. // been fired in the contact list click handler.
  5786. VideoLayout.handleVideoThumbClicked(
  5787. $(sel).attr('src'),
  5788. false,
  5789. Strophe.getResourceFromJid(mediaStream.peerjid));
  5790. updateLargeVideo = false;
  5791. }
  5792. waitForRemoteVideo(sel, mediaStream.ssrc, mediaStream.stream, resourceJid);
  5793. }
  5794. })
  5795. }
  5796. // The endpoint that was being shown in the large video has dropped out
  5797. // of the lastN set and there was no lastN pickup jid. We need to update
  5798. // the large video now.
  5799. if (updateLargeVideo) {
  5800. var resource, container, src;
  5801. var myResource
  5802. = xmpp.myResource();
  5803. // Find out which endpoint to show in the large video.
  5804. for (var i = 0; i < lastNEndpoints.length; i++) {
  5805. resource = lastNEndpoints[i];
  5806. if (!resource || resource === myResource)
  5807. continue;
  5808. container = $("#participant_" + resource);
  5809. if (container.length == 0)
  5810. continue;
  5811. src = $('video', container).attr('src');
  5812. if (!src)
  5813. continue;
  5814. // videoSrcToSsrc needs to be update for this call to succeed.
  5815. VideoLayout.updateLargeVideo(src);
  5816. break;
  5817. }
  5818. }
  5819. };
  5820. my.onSimulcastLayersChanging = function (endpointSimulcastLayers) {
  5821. endpointSimulcastLayers.forEach(function (esl) {
  5822. var resource = esl.endpoint;
  5823. // if lastN is enabled *and* the endpoint is *not* in the lastN set,
  5824. // then ignore the event (= do not preload anything).
  5825. //
  5826. // The bridge could probably stop sending this message if it's for
  5827. // an endpoint that's not in lastN.
  5828. if (lastNCount != -1
  5829. && (lastNCount < 1 || lastNEndpointsCache.indexOf(resource) === -1)) {
  5830. return;
  5831. }
  5832. var primarySSRC = esl.simulcastLayer.primarySSRC;
  5833. // Get session and stream from primary ssrc.
  5834. var res = simulcast.getReceivingVideoStreamBySSRC(primarySSRC);
  5835. var sid = res.sid;
  5836. var electedStream = res.stream;
  5837. if (sid && electedStream) {
  5838. var msid = simulcast.getRemoteVideoStreamIdBySSRC(primarySSRC);
  5839. console.info([esl, primarySSRC, msid, sid, electedStream]);
  5840. var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
  5841. if (preload) {
  5842. if (largeVideoState.preload)
  5843. {
  5844. $(largeVideoState.preload).remove();
  5845. }
  5846. console.info('Preloading remote video');
  5847. largeVideoState.preload = $('<video autoplay></video>');
  5848. // ssrcs are unique in an rtp session
  5849. largeVideoState.preload_ssrc = primarySSRC;
  5850. RTC.attachMediaStream(largeVideoState.preload, electedStream)
  5851. }
  5852. } else {
  5853. console.error('Could not find a stream or a session.', sid, electedStream);
  5854. }
  5855. });
  5856. };
  5857. /**
  5858. * On simulcast layers changed event.
  5859. */
  5860. my.onSimulcastLayersChanged = function (endpointSimulcastLayers) {
  5861. endpointSimulcastLayers.forEach(function (esl) {
  5862. var resource = esl.endpoint;
  5863. // if lastN is enabled *and* the endpoint is *not* in the lastN set,
  5864. // then ignore the event (= do not change large video/thumbnail
  5865. // SRCs).
  5866. //
  5867. // Note that even if we ignore the "changed" event in this event
  5868. // handler, the bridge must continue sending these events because
  5869. // the simulcast code in simulcast.js uses it to know what's going
  5870. // to be streamed by the bridge when/if the endpoint gets back into
  5871. // the lastN set.
  5872. if (lastNCount != -1
  5873. && (lastNCount < 1 || lastNEndpointsCache.indexOf(resource) === -1)) {
  5874. return;
  5875. }
  5876. var primarySSRC = esl.simulcastLayer.primarySSRC;
  5877. // Get session and stream from primary ssrc.
  5878. var res = simulcast.getReceivingVideoStreamBySSRC(primarySSRC);
  5879. var sid = res.sid;
  5880. var electedStream = res.stream;
  5881. if (sid && electedStream) {
  5882. var msid = simulcast.getRemoteVideoStreamIdBySSRC(primarySSRC);
  5883. console.info('Switching simulcast substream.');
  5884. console.info([esl, primarySSRC, msid, sid, electedStream]);
  5885. var msidParts = msid.split(' ');
  5886. var selRemoteVideo = $(['#', 'remoteVideo_', sid, '_', msidParts[0]].join(''));
  5887. var updateLargeVideo = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC))
  5888. == largeVideoState.userResourceJid);
  5889. var updateFocusedVideoSrc = (focusedVideoInfo && focusedVideoInfo.src && focusedVideoInfo.src != '' &&
  5890. (RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoInfo.src));
  5891. var electedStreamUrl;
  5892. if (largeVideoState.preload_ssrc == primarySSRC)
  5893. {
  5894. RTC.setVideoSrc(selRemoteVideo[0], RTC.getVideoSrc(largeVideoState.preload[0]));
  5895. }
  5896. else
  5897. {
  5898. if (largeVideoState.preload
  5899. && largeVideoState.preload != null) {
  5900. $(largeVideoState.preload).remove();
  5901. }
  5902. largeVideoState.preload_ssrc = 0;
  5903. RTC.attachMediaStream(selRemoteVideo, electedStream);
  5904. }
  5905. var jid = xmpp.getJidFromSSRC(primarySSRC);
  5906. if (updateLargeVideo) {
  5907. VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,
  5908. Strophe.getResourceFromJid(jid));
  5909. }
  5910. if (updateFocusedVideoSrc) {
  5911. focusedVideoInfo.src = RTC.getVideoSrc(selRemoteVideo[0]);
  5912. }
  5913. var videoId;
  5914. if(resource == xmpp.myResource())
  5915. {
  5916. videoId = "localVideoContainer";
  5917. }
  5918. else
  5919. {
  5920. videoId = "participant_" + resource;
  5921. }
  5922. var connectionIndicator = VideoLayout.connectionIndicators[videoId];
  5923. if(connectionIndicator)
  5924. connectionIndicator.updatePopoverData();
  5925. } else {
  5926. console.error('Could not find a stream or a sid.', sid, electedStream);
  5927. }
  5928. });
  5929. };
  5930. /**
  5931. * Updates local stats
  5932. * @param percent
  5933. * @param object
  5934. */
  5935. my.updateLocalConnectionStats = function (percent, object) {
  5936. var resolution = null;
  5937. if(object.resolution !== null)
  5938. {
  5939. resolution = object.resolution;
  5940. object.resolution = resolution[xmpp.myJid()];
  5941. delete resolution[xmpp.myJid()];
  5942. }
  5943. updateStatsIndicator("localVideoContainer", percent, object);
  5944. for(var jid in resolution)
  5945. {
  5946. if(resolution[jid] === null)
  5947. continue;
  5948. var id = 'participant_' + Strophe.getResourceFromJid(jid);
  5949. if(VideoLayout.connectionIndicators[id])
  5950. {
  5951. VideoLayout.connectionIndicators[id].updateResolution(resolution[jid]);
  5952. }
  5953. }
  5954. };
  5955. /**
  5956. * Updates remote stats.
  5957. * @param jid the jid associated with the stats
  5958. * @param percent the connection quality percent
  5959. * @param object the stats data
  5960. */
  5961. my.updateConnectionStats = function (jid, percent, object) {
  5962. var resourceJid = Strophe.getResourceFromJid(jid);
  5963. var videoSpanId = 'participant_' + resourceJid;
  5964. updateStatsIndicator(videoSpanId, percent, object);
  5965. };
  5966. /**
  5967. * Removes the connection
  5968. * @param jid
  5969. */
  5970. my.removeConnectionIndicator = function (jid) {
  5971. if(VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)])
  5972. VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)].remove();
  5973. };
  5974. /**
  5975. * Hides the connection indicator
  5976. * @param jid
  5977. */
  5978. my.hideConnectionIndicator = function (jid) {
  5979. if(VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)])
  5980. VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)].hide();
  5981. };
  5982. /**
  5983. * Hides all the indicators
  5984. */
  5985. my.onStatsStop = function () {
  5986. for(var indicator in VideoLayout.connectionIndicators)
  5987. {
  5988. VideoLayout.connectionIndicators[indicator].hideIndicator();
  5989. }
  5990. };
  5991. my.participantLeft = function (jid) {
  5992. // Unlock large video
  5993. if (focusedVideoInfo && focusedVideoInfo.jid === jid)
  5994. {
  5995. console.info("Focused video owner has left the conference");
  5996. focusedVideoInfo = null;
  5997. }
  5998. }
  5999. return my;
  6000. }(VideoLayout || {}));
  6001. module.exports = VideoLayout;
  6002. },{"../audio_levels/AudioLevels":2,"../avatar/Avatar":5,"../etherpad/Etherpad":6,"../prezi/Prezi":7,"../side_pannels/chat/Chat":10,"../side_pannels/contactlist/ContactList":14,"../util/NicknameHandler":22,"../util/UIUtil":23,"./ConnectionIndicator":24}],26:[function(require,module,exports){
  6003. //var nouns = [
  6004. //];
  6005. var pluralNouns = [
  6006. "Aliens", "Animals", "Antelopes", "Ants", "Apes", "Apples", "Baboons", "Bacteria", "Badgers", "Bananas", "Bats",
  6007. "Bears", "Birds", "Bonobos", "Brides", "Bugs", "Bulls", "Butterflies", "Cheetahs",
  6008. "Cherries", "Chicken", "Children", "Chimps", "Clowns", "Cows", "Creatures", "Dinosaurs", "Dogs", "Dolphins",
  6009. "Donkeys", "Dragons", "Ducks", "Dwarfs", "Eagles", "Elephants", "Elves", "FAIL", "Fathers",
  6010. "Fish", "Flowers", "Frogs", "Fruit", "Fungi", "Galaxies", "Geese", "Goats",
  6011. "Gorillas", "Hedgehogs", "Hippos", "Horses", "Hunters", "Insects", "Kids", "Knights",
  6012. "Lemons", "Lemurs", "Leopards", "LifeForms", "Lions", "Lizards", "Mice", "Monkeys", "Monsters",
  6013. "Mushrooms", "Octopodes", "Oranges", "Orangutans", "Organisms", "Pants", "Parrots", "Penguins",
  6014. "People", "Pigeons", "Pigs", "Pineapples", "Plants", "Potatoes", "Priests", "Rats", "Reptiles", "Reptilians",
  6015. "Rhinos", "Seagulls", "Sheep", "Siblings", "Snakes", "Spaghetti", "Spiders", "Squid", "Squirrels",
  6016. "Stars", "Students", "Teachers", "Tigers", "Tomatoes", "Trees", "Vampires", "Vegetables", "Viruses", "Vulcans",
  6017. "Warewolves", "Weasels", "Whales", "Witches", "Wizards", "Wolves", "Workers", "Worms", "Zebras"
  6018. ];
  6019. //var places = [
  6020. //"Pub", "University", "Airport", "Library", "Mall", "Theater", "Stadium", "Office", "Show", "Gallows", "Beach",
  6021. // "Cemetery", "Hospital", "Reception", "Restaurant", "Bar", "Church", "House", "School", "Square", "Village",
  6022. // "Cinema", "Movies", "Party", "Restroom", "End", "Jail", "PostOffice", "Station", "Circus", "Gates", "Entrance",
  6023. // "Bridge"
  6024. //];
  6025. var verbs = [
  6026. "Abandon", "Adapt", "Advertise", "Answer", "Anticipate", "Appreciate",
  6027. "Approach", "Argue", "Ask", "Bite", "Blossom", "Blush", "Breathe", "Breed", "Bribe", "Burn", "Calculate",
  6028. "Clean", "Code", "Communicate", "Compute", "Confess", "Confiscate", "Conjugate", "Conjure", "Consume",
  6029. "Contemplate", "Crawl", "Dance", "Delegate", "Devour", "Develop", "Differ", "Discuss",
  6030. "Dissolve", "Drink", "Eat", "Elaborate", "Emancipate", "Estimate", "Expire", "Extinguish",
  6031. "Extract", "FAIL", "Facilitate", "Fall", "Feed", "Finish", "Floss", "Fly", "Follow", "Fragment", "Freeze",
  6032. "Gather", "Glow", "Grow", "Hex", "Hide", "Hug", "Hurry", "Improve", "Intersect", "Investigate", "Jinx",
  6033. "Joke", "Jubilate", "Kiss", "Laugh", "Manage", "Meet", "Merge", "Move", "Object", "Observe", "Offer",
  6034. "Paint", "Participate", "Party", "Perform", "Plan", "Pursue", "Pierce", "Play", "Postpone", "Pray", "Proclaim",
  6035. "Question", "Read", "Reckon", "Rejoice", "Represent", "Resize", "Rhyme", "Scream", "Search", "Select", "Share", "Shoot",
  6036. "Shout", "Signal", "Sing", "Skate", "Sleep", "Smile", "Smoke", "Solve", "Spell", "Steer", "Stink",
  6037. "Substitute", "Swim", "Taste", "Teach", "Terminate", "Think", "Type", "Unite", "Vanish", "Worship"
  6038. ];
  6039. var adverbs = [
  6040. "Absently", "Accurately", "Accusingly", "Adorably", "AllTheTime", "Alone", "Always", "Amazingly", "Angrily",
  6041. "Anxiously", "Anywhere", "Appallingly", "Apparently", "Articulately", "Astonishingly", "Badly", "Barely",
  6042. "Beautifully", "Blindly", "Bravely", "Brightly", "Briskly", "Brutally", "Calmly", "Carefully", "Casually",
  6043. "Cautiously", "Cleverly", "Constantly", "Correctly", "Crazily", "Curiously", "Cynically", "Daily",
  6044. "Dangerously", "Deliberately", "Delicately", "Desperately", "Discreetly", "Eagerly", "Easily", "Euphoricly",
  6045. "Evenly", "Everywhere", "Exactly", "Expectantly", "Extensively", "FAIL", "Ferociously", "Fiercely", "Finely",
  6046. "Flatly", "Frequently", "Frighteningly", "Gently", "Gloriously", "Grimly", "Guiltily", "Happily",
  6047. "Hard", "Hastily", "Heroically", "High", "Highly", "Hourly", "Humbly", "Hysterically", "Immensely",
  6048. "Impartially", "Impolitely", "Indifferently", "Intensely", "Jealously", "Jovially", "Kindly", "Lazily",
  6049. "Lightly", "Loudly", "Lovingly", "Loyally", "Magnificently", "Malevolently", "Merrily", "Mightily", "Miserably",
  6050. "Mysteriously", "NOT", "Nervously", "Nicely", "Nowhere", "Objectively", "Obnoxiously", "Obsessively",
  6051. "Obviously", "Often", "Painfully", "Patiently", "Playfully", "Politely", "Poorly", "Precisely", "Promptly",
  6052. "Quickly", "Quietly", "Randomly", "Rapidly", "Rarely", "Recklessly", "Regularly", "Remorsefully", "Responsibly",
  6053. "Rudely", "Ruthlessly", "Sadly", "Scornfully", "Seamlessly", "Seldom", "Selfishly", "Seriously", "Shakily",
  6054. "Sharply", "Sideways", "Silently", "Sleepily", "Slightly", "Slowly", "Slyly", "Smoothly", "Softly", "Solemnly", "Steadily", "Sternly", "Strangely", "Strongly", "Stunningly", "Surely", "Tenderly", "Thoughtfully",
  6055. "Tightly", "Uneasily", "Vanishingly", "Violently", "Warmly", "Weakly", "Wearily", "Weekly", "Weirdly", "Well",
  6056. "Well", "Wickedly", "Wildly", "Wisely", "Wonderfully", "Yearly"
  6057. ];
  6058. var adjectives = [
  6059. "Abominable", "Accurate", "Adorable", "All", "Alleged", "Ancient", "Angry", "Angry", "Anxious", "Appalling",
  6060. "Apparent", "Astonishing", "Attractive", "Awesome", "Baby", "Bad", "Beautiful", "Benign", "Big", "Bitter",
  6061. "Blind", "Blue", "Bold", "Brave", "Bright", "Brisk", "Calm", "Camouflaged", "Casual", "Cautious",
  6062. "Choppy", "Chosen", "Clever", "Cold", "Cool", "Crawly", "Crazy", "Creepy", "Cruel", "Curious", "Cynical",
  6063. "Dangerous", "Dark", "Delicate", "Desperate", "Difficult", "Discreet", "Disguised", "Dizzy",
  6064. "Dumb", "Eager", "Easy", "Edgy", "Electric", "Elegant", "Emancipated", "Enormous", "Euphoric", "Evil",
  6065. "FAIL", "Fast", "Ferocious", "Fierce", "Fine", "Flawed", "Flying", "Foolish", "Foxy",
  6066. "Freezing", "Funny", "Furious", "Gentle", "Glorious", "Golden", "Good", "Green", "Green", "Guilty",
  6067. "Hairy", "Happy", "Hard", "Hasty", "Hazy", "Heroic", "Hostile", "Hot", "Humble", "Humongous",
  6068. "Humorous", "Hysterical", "Idealistic", "Ignorant", "Immense", "Impartial", "Impolite", "Indifferent",
  6069. "Infuriated", "Insightful", "Intense", "Interesting", "Intimidated", "Intriguing", "Jealous", "Jolly", "Jovial",
  6070. "Jumpy", "Kind", "Laughing", "Lazy", "Liquid", "Lonely", "Longing", "Loud", "Loving", "Loyal", "Macabre", "Mad",
  6071. "Magical", "Magnificent", "Malevolent", "Medieval", "Memorable", "Mere", "Merry", "Mighty",
  6072. "Mischievous", "Miserable", "Modified", "Moody", "Most", "Mysterious", "Mystical", "Needy",
  6073. "Nervous", "Nice", "Objective", "Obnoxious", "Obsessive", "Obvious", "Opinionated", "Orange",
  6074. "Painful", "Passionate", "Perfect", "Pink", "Playful", "Poisonous", "Polite", "Poor", "Popular", "Powerful",
  6075. "Precise", "Preserved", "Pretty", "Purple", "Quick", "Quiet", "Random", "Rapid", "Rare", "Real",
  6076. "Reassuring", "Reckless", "Red", "Regular", "Remorseful", "Responsible", "Rich", "Rude", "Ruthless",
  6077. "Sad", "Scared", "Scary", "Scornful", "Screaming", "Selfish", "Serious", "Shady", "Shaky", "Sharp",
  6078. "Shiny", "Shy", "Simple", "Sleepy", "Slow", "Sly", "Small", "Smart", "Smelly", "Smiling", "Smooth",
  6079. "Smug", "Sober", "Soft", "Solemn", "Square", "Square", "Steady", "Strange", "Strong",
  6080. "Stunning", "Subjective", "Successful", "Surly", "Sweet", "Tactful", "Tense",
  6081. "Thoughtful", "Tight", "Tiny", "Tolerant", "Uneasy", "Unique", "Unseen", "Warm", "Weak",
  6082. "Weird", "WellCooked", "Wild", "Wise", "Witty", "Wonderful", "Worried", "Yellow", "Young",
  6083. "Zealous"
  6084. ];
  6085. //var pronouns = [
  6086. //];
  6087. //var conjunctions = [
  6088. //"And", "Or", "For", "Above", "Before", "Against", "Between"
  6089. //];
  6090. /*
  6091. * Maps a string (category name) to the array of words from that category.
  6092. */
  6093. var CATEGORIES =
  6094. {
  6095. //"_NOUN_": nouns,
  6096. "_PLURALNOUN_": pluralNouns,
  6097. //"_PLACE_": places,
  6098. "_VERB_": verbs,
  6099. "_ADVERB_": adverbs,
  6100. "_ADJECTIVE_": adjectives
  6101. //"_PRONOUN_": pronouns,
  6102. //"_CONJUNCTION_": conjunctions,
  6103. };
  6104. var PATTERNS = [
  6105. "_ADJECTIVE__PLURALNOUN__VERB__ADVERB_"
  6106. // BeautifulFungiOrSpaghetti
  6107. //"_ADJECTIVE__PLURALNOUN__CONJUNCTION__PLURALNOUN_",
  6108. // AmazinglyScaryToy
  6109. //"_ADVERB__ADJECTIVE__NOUN_",
  6110. // NeitherTrashNorRifle
  6111. //"Neither_NOUN_Nor_NOUN_",
  6112. //"Either_NOUN_Or_NOUN_",
  6113. // EitherCopulateOrInvestigate
  6114. //"Either_VERB_Or_VERB_",
  6115. //"Neither_VERB_Nor_VERB_",
  6116. //"The_ADJECTIVE__ADJECTIVE__NOUN_",
  6117. //"The_ADVERB__ADJECTIVE__NOUN_",
  6118. //"The_ADVERB__ADJECTIVE__NOUN_s",
  6119. //"The_ADVERB__ADJECTIVE__PLURALNOUN__VERB_",
  6120. // WolvesComputeBadly
  6121. //"_PLURALNOUN__VERB__ADVERB_",
  6122. // UniteFacilitateAndMerge
  6123. //"_VERB__VERB_And_VERB_",
  6124. //NastyWitchesAtThePub
  6125. //"_ADJECTIVE__PLURALNOUN_AtThe_PLACE_",
  6126. ];
  6127. /*
  6128. * Returns a random element from the array 'arr'
  6129. */
  6130. function randomElement(arr)
  6131. {
  6132. return arr[Math.floor(Math.random() * arr.length)];
  6133. }
  6134. /*
  6135. * Returns true if the string 's' contains one of the
  6136. * template strings.
  6137. */
  6138. function hasTemplate(s)
  6139. {
  6140. for (var template in CATEGORIES){
  6141. if (s.indexOf(template) >= 0){
  6142. return true;
  6143. }
  6144. }
  6145. }
  6146. /**
  6147. * Generates new room name.
  6148. */
  6149. var RoomNameGenerator = {
  6150. generateRoomWithoutSeparator: function()
  6151. {
  6152. // Note that if more than one pattern is available, the choice of 'name' won't be random (names from patterns
  6153. // with fewer options will have higher probability of being chosen that names from patterns with more options).
  6154. var name = randomElement(PATTERNS);
  6155. var word;
  6156. while (hasTemplate(name)){
  6157. for (var template in CATEGORIES){
  6158. word = randomElement(CATEGORIES[template]);
  6159. name = name.replace(template, word);
  6160. }
  6161. }
  6162. return name;
  6163. }
  6164. }
  6165. module.exports = RoomNameGenerator;
  6166. },{}],27:[function(require,module,exports){
  6167. var animateTimeout, updateTimeout;
  6168. var RoomNameGenerator = require("./RoomnameGenerator");
  6169. function enter_room()
  6170. {
  6171. var val = $("#enter_room_field").val();
  6172. if(!val) {
  6173. val = $("#enter_room_field").attr("room_name");
  6174. }
  6175. if (val) {
  6176. window.location.pathname = "/" + val;
  6177. }
  6178. }
  6179. function animate(word) {
  6180. var currentVal = $("#enter_room_field").attr("placeholder");
  6181. $("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
  6182. animateTimeout = setTimeout(function() {
  6183. animate(word.substring(1, word.length))
  6184. }, 70);
  6185. }
  6186. function update_roomname()
  6187. {
  6188. var word = RoomNameGenerator.generateRoomWithoutSeparator();
  6189. $("#enter_room_field").attr("room_name", word);
  6190. $("#enter_room_field").attr("placeholder", "");
  6191. clearTimeout(animateTimeout);
  6192. animate(word);
  6193. updateTimeout = setTimeout(update_roomname, 10000);
  6194. }
  6195. function setupWelcomePage()
  6196. {
  6197. $("#videoconference_page").hide();
  6198. $("#domain_name").text(
  6199. window.location.protocol + "//" + window.location.host + "/");
  6200. $("span[name='appName']").text(interfaceConfig.APP_NAME);
  6201. if (interfaceConfig.SHOW_JITSI_WATERMARK) {
  6202. var leftWatermarkDiv
  6203. = $("#welcome_page_header div[class='watermark leftwatermark']");
  6204. if(leftWatermarkDiv && leftWatermarkDiv.length > 0)
  6205. {
  6206. leftWatermarkDiv.css({display: 'block'});
  6207. leftWatermarkDiv.parent().get(0).href
  6208. = interfaceConfig.JITSI_WATERMARK_LINK;
  6209. }
  6210. }
  6211. if (interfaceConfig.SHOW_BRAND_WATERMARK) {
  6212. var rightWatermarkDiv
  6213. = $("#welcome_page_header div[class='watermark rightwatermark']");
  6214. if(rightWatermarkDiv && rightWatermarkDiv.length > 0) {
  6215. rightWatermarkDiv.css({display: 'block'});
  6216. rightWatermarkDiv.parent().get(0).href
  6217. = interfaceConfig.BRAND_WATERMARK_LINK;
  6218. rightWatermarkDiv.get(0).style.backgroundImage
  6219. = "url(images/rightwatermark.png)";
  6220. }
  6221. }
  6222. if (interfaceConfig.SHOW_POWERED_BY) {
  6223. $("#welcome_page_header>a[class='poweredby']")
  6224. .css({display: 'block'});
  6225. }
  6226. $("#enter_room_button").click(function()
  6227. {
  6228. enter_room();
  6229. });
  6230. $("#enter_room_field").keydown(function (event) {
  6231. if (event.keyCode === 13 /* enter */) {
  6232. enter_room();
  6233. }
  6234. });
  6235. if (!(interfaceConfig.GENERATE_ROOMNAMES_ON_WELCOME_PAGE === false)){
  6236. var updateTimeout;
  6237. var animateTimeout;
  6238. $("#reload_roomname").click(function () {
  6239. clearTimeout(updateTimeout);
  6240. clearTimeout(animateTimeout);
  6241. update_roomname();
  6242. });
  6243. $("#reload_roomname").show();
  6244. update_roomname();
  6245. }
  6246. $("#disable_welcome").click(function () {
  6247. window.localStorage.welcomePageDisabled
  6248. = $("#disable_welcome").is(":checked");
  6249. });
  6250. }
  6251. module.exports = setupWelcomePage;
  6252. },{"./RoomnameGenerator":26}],28:[function(require,module,exports){
  6253. // Copyright Joyent, Inc. and other Node contributors.
  6254. //
  6255. // Permission is hereby granted, free of charge, to any person obtaining a
  6256. // copy of this software and associated documentation files (the
  6257. // "Software"), to deal in the Software without restriction, including
  6258. // without limitation the rights to use, copy, modify, merge, publish,
  6259. // distribute, sublicense, and/or sell copies of the Software, and to permit
  6260. // persons to whom the Software is furnished to do so, subject to the
  6261. // following conditions:
  6262. //
  6263. // The above copyright notice and this permission notice shall be included
  6264. // in all copies or substantial portions of the Software.
  6265. //
  6266. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6267. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6268. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  6269. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  6270. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  6271. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  6272. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  6273. function EventEmitter() {
  6274. this._events = this._events || {};
  6275. this._maxListeners = this._maxListeners || undefined;
  6276. }
  6277. module.exports = EventEmitter;
  6278. // Backwards-compat with node 0.10.x
  6279. EventEmitter.EventEmitter = EventEmitter;
  6280. EventEmitter.prototype._events = undefined;
  6281. EventEmitter.prototype._maxListeners = undefined;
  6282. // By default EventEmitters will print a warning if more than 10 listeners are
  6283. // added to it. This is a useful default which helps finding memory leaks.
  6284. EventEmitter.defaultMaxListeners = 10;
  6285. // Obviously not all Emitters should be limited to 10. This function allows
  6286. // that to be increased. Set to zero for unlimited.
  6287. EventEmitter.prototype.setMaxListeners = function(n) {
  6288. if (!isNumber(n) || n < 0 || isNaN(n))
  6289. throw TypeError('n must be a positive number');
  6290. this._maxListeners = n;
  6291. return this;
  6292. };
  6293. EventEmitter.prototype.emit = function(type) {
  6294. var er, handler, len, args, i, listeners;
  6295. if (!this._events)
  6296. this._events = {};
  6297. // If there is no 'error' event listener then throw.
  6298. if (type === 'error') {
  6299. if (!this._events.error ||
  6300. (isObject(this._events.error) && !this._events.error.length)) {
  6301. er = arguments[1];
  6302. if (er instanceof Error) {
  6303. throw er; // Unhandled 'error' event
  6304. }
  6305. throw TypeError('Uncaught, unspecified "error" event.');
  6306. }
  6307. }
  6308. handler = this._events[type];
  6309. if (isUndefined(handler))
  6310. return false;
  6311. if (isFunction(handler)) {
  6312. switch (arguments.length) {
  6313. // fast cases
  6314. case 1:
  6315. handler.call(this);
  6316. break;
  6317. case 2:
  6318. handler.call(this, arguments[1]);
  6319. break;
  6320. case 3:
  6321. handler.call(this, arguments[1], arguments[2]);
  6322. break;
  6323. // slower
  6324. default:
  6325. len = arguments.length;
  6326. args = new Array(len - 1);
  6327. for (i = 1; i < len; i++)
  6328. args[i - 1] = arguments[i];
  6329. handler.apply(this, args);
  6330. }
  6331. } else if (isObject(handler)) {
  6332. len = arguments.length;
  6333. args = new Array(len - 1);
  6334. for (i = 1; i < len; i++)
  6335. args[i - 1] = arguments[i];
  6336. listeners = handler.slice();
  6337. len = listeners.length;
  6338. for (i = 0; i < len; i++)
  6339. listeners[i].apply(this, args);
  6340. }
  6341. return true;
  6342. };
  6343. EventEmitter.prototype.addListener = function(type, listener) {
  6344. var m;
  6345. if (!isFunction(listener))
  6346. throw TypeError('listener must be a function');
  6347. if (!this._events)
  6348. this._events = {};
  6349. // To avoid recursion in the case that type === "newListener"! Before
  6350. // adding it to the listeners, first emit "newListener".
  6351. if (this._events.newListener)
  6352. this.emit('newListener', type,
  6353. isFunction(listener.listener) ?
  6354. listener.listener : listener);
  6355. if (!this._events[type])
  6356. // Optimize the case of one listener. Don't need the extra array object.
  6357. this._events[type] = listener;
  6358. else if (isObject(this._events[type]))
  6359. // If we've already got an array, just append.
  6360. this._events[type].push(listener);
  6361. else
  6362. // Adding the second element, need to change to array.
  6363. this._events[type] = [this._events[type], listener];
  6364. // Check for listener leak
  6365. if (isObject(this._events[type]) && !this._events[type].warned) {
  6366. var m;
  6367. if (!isUndefined(this._maxListeners)) {
  6368. m = this._maxListeners;
  6369. } else {
  6370. m = EventEmitter.defaultMaxListeners;
  6371. }
  6372. if (m && m > 0 && this._events[type].length > m) {
  6373. this._events[type].warned = true;
  6374. console.error('(node) warning: possible EventEmitter memory ' +
  6375. 'leak detected. %d listeners added. ' +
  6376. 'Use emitter.setMaxListeners() to increase limit.',
  6377. this._events[type].length);
  6378. if (typeof console.trace === 'function') {
  6379. // not supported in IE 10
  6380. console.trace();
  6381. }
  6382. }
  6383. }
  6384. return this;
  6385. };
  6386. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  6387. EventEmitter.prototype.once = function(type, listener) {
  6388. if (!isFunction(listener))
  6389. throw TypeError('listener must be a function');
  6390. var fired = false;
  6391. function g() {
  6392. this.removeListener(type, g);
  6393. if (!fired) {
  6394. fired = true;
  6395. listener.apply(this, arguments);
  6396. }
  6397. }
  6398. g.listener = listener;
  6399. this.on(type, g);
  6400. return this;
  6401. };
  6402. // emits a 'removeListener' event iff the listener was removed
  6403. EventEmitter.prototype.removeListener = function(type, listener) {
  6404. var list, position, length, i;
  6405. if (!isFunction(listener))
  6406. throw TypeError('listener must be a function');
  6407. if (!this._events || !this._events[type])
  6408. return this;
  6409. list = this._events[type];
  6410. length = list.length;
  6411. position = -1;
  6412. if (list === listener ||
  6413. (isFunction(list.listener) && list.listener === listener)) {
  6414. delete this._events[type];
  6415. if (this._events.removeListener)
  6416. this.emit('removeListener', type, listener);
  6417. } else if (isObject(list)) {
  6418. for (i = length; i-- > 0;) {
  6419. if (list[i] === listener ||
  6420. (list[i].listener && list[i].listener === listener)) {
  6421. position = i;
  6422. break;
  6423. }
  6424. }
  6425. if (position < 0)
  6426. return this;
  6427. if (list.length === 1) {
  6428. list.length = 0;
  6429. delete this._events[type];
  6430. } else {
  6431. list.splice(position, 1);
  6432. }
  6433. if (this._events.removeListener)
  6434. this.emit('removeListener', type, listener);
  6435. }
  6436. return this;
  6437. };
  6438. EventEmitter.prototype.removeAllListeners = function(type) {
  6439. var key, listeners;
  6440. if (!this._events)
  6441. return this;
  6442. // not listening for removeListener, no need to emit
  6443. if (!this._events.removeListener) {
  6444. if (arguments.length === 0)
  6445. this._events = {};
  6446. else if (this._events[type])
  6447. delete this._events[type];
  6448. return this;
  6449. }
  6450. // emit removeListener for all listeners on all events
  6451. if (arguments.length === 0) {
  6452. for (key in this._events) {
  6453. if (key === 'removeListener') continue;
  6454. this.removeAllListeners(key);
  6455. }
  6456. this.removeAllListeners('removeListener');
  6457. this._events = {};
  6458. return this;
  6459. }
  6460. listeners = this._events[type];
  6461. if (isFunction(listeners)) {
  6462. this.removeListener(type, listeners);
  6463. } else {
  6464. // LIFO order
  6465. while (listeners.length)
  6466. this.removeListener(type, listeners[listeners.length - 1]);
  6467. }
  6468. delete this._events[type];
  6469. return this;
  6470. };
  6471. EventEmitter.prototype.listeners = function(type) {
  6472. var ret;
  6473. if (!this._events || !this._events[type])
  6474. ret = [];
  6475. else if (isFunction(this._events[type]))
  6476. ret = [this._events[type]];
  6477. else
  6478. ret = this._events[type].slice();
  6479. return ret;
  6480. };
  6481. EventEmitter.listenerCount = function(emitter, type) {
  6482. var ret;
  6483. if (!emitter._events || !emitter._events[type])
  6484. ret = 0;
  6485. else if (isFunction(emitter._events[type]))
  6486. ret = 1;
  6487. else
  6488. ret = emitter._events[type].length;
  6489. return ret;
  6490. };
  6491. function isFunction(arg) {
  6492. return typeof arg === 'function';
  6493. }
  6494. function isNumber(arg) {
  6495. return typeof arg === 'number';
  6496. }
  6497. function isObject(arg) {
  6498. return typeof arg === 'object' && arg !== null;
  6499. }
  6500. function isUndefined(arg) {
  6501. return arg === void 0;
  6502. }
  6503. },{}]},{},[1])(1)
  6504. });