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

UI.bundle.js 225KB

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