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

UI.bundle.js 216KB

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