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

UI.bundle.js 215KB

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