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

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