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

UI.bundle.js 211KB

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