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

UI.bundle.js 245KB

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