Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

UI.bundle.js 211KB

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