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 212KB

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