You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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