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

UI.bundle.js 245KB

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