summaryrefslogtreecommitdiff
path: root/app/static/js/main.75ca3e1e.chunk.js
blob: 705cc47fde7f8cd03ddc64ee5dc170506f572ef6 (plain) (blame)
1
2
(this["webpackJsonpbai-radio"]=this["webpackJsonpbai-radio"]||[]).push([[0],{170:function(e,t,a){e.exports=a(303)},175:function(e,t,a){},180:function(e,t,a){},303:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),o=a(28),l=a.n(o),s=(a(175),a(99)),c=a(140),i=a(141),u=a(159),m=a(142),d=a(49),h=a(160),p=a(309),g=a(315),v=a(316),E=a(317),f=a(30),y=a(312),S=a(313),b=a(311),C=a(314),k=(a(176),a(143)),w=a(67),M=a.n(w),I=(a(106),a(180),function(e){var t=e.stream;return r.a.createElement(b.a,null,r.a.createElement(b.a.Item,null,r.a.createElement(b.a.Icon,{name:"users"}),r.a.createElement(b.a.Content,null,r.a.createElement(b.a.Header,null,"Usuarios escuchando: ".concat(t.listeners)))),r.a.createElement(b.a.Item,null,r.a.createElement(b.a.Icon,{name:"clock"}),r.a.createElement(b.a.Content,null,r.a.createElement(b.a.Header,null,"Transmitiendo"," ",r.a.createElement(M.a,{date:t.stream_start,fromNow:!0,locale:"es"})))),r.a.createElement(b.a.Item,null,r.a.createElement(b.a.Icon,{name:"info",verticalAlign:"middle"}),r.a.createElement(b.a.Content,null,r.a.createElement(b.a.Header,null,t.server_name),t.server_description)),r.a.createElement(b.a.Item,null,r.a.createElement(b.a.Icon,{name:"file audio outline",verticalAlign:"middle"}),r.a.createElement(b.a.Content,null,r.a.createElement(b.a.Header,null,2===t.audio_channels?"Stereo":"Mono"),"Bitrate: ".concat(t["ice-bitrate"]," kbps, ").concat(t["ice-samplerate"]," Hz"))),r.a.createElement(b.a.Item,null,r.a.createElement(b.a.Icon,{name:"sound",verticalAlign:"middle"}),r.a.createElement(b.a.Content,null,r.a.createElement(b.a.Header,null,"Canci\xf3n actual"),"".concat(t.artist," - ").concat(t.title))))}),O=new k.w3cwebsocket("wss://radio.bienvenidoainternet.org/daemon/"),H=["grey","red","pink","orange","yellow","green","teal","blue","purple","black"],x=function(e){function t(e){var a;return Object(c.a)(this,t),(a=Object(u.a)(this,Object(m.a)(t).call(this,e))).state={ready:!1,response:{},history:[],chat:[],chatMessage:"",infoUpdate:{},currentSong:"",streamsAvailable:[],multipleSources:!1,selectedStream:0,chatUserCount:0,isChatOnline:!1},a.handleOnChange=a.handleOnChange.bind(Object(d.a)(a)),a.sendMessage=a.sendMessage.bind(Object(d.a)(a)),a}return Object(h.a)(t,e),Object(i.a)(t,[{key:"addMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=new Date;this.setState((function(r){return{chat:[].concat(Object(s.a)(r.chat),[{content:e,color:t,own:a,timestamp:n}]),chatMessage:""}}),(function(){var e=document.getElementById("chatContainer");null!=e&&(e.scrollTop=e.scrollHeight)}))}},{key:"addToHistory",value:function(e){this.setState((function(t){return{history:[].concat(Object(s.a)(t.history),[e])}}))}},{key:"sendMessage",value:function(){var e=this.state,t=e.chatMessage,a=e.selectedStream;O.send("MSG:1:"+a+t),O.send("MSG:1:"+t),this.addMessage(t,"black",!0),this.setState({chatMessage:""})}},{key:"componentWillMount",value:function(){var e=this;O.onopen=function(){e.setState({isChatOnline:!0})},O.onmessage=function(t){e.processChatMessage(t.data)},O.onerror=function(){e.setState({isChatOnline:!1}),e.addMessage("Ha ocurrido un error conect\xe1ndose al chat.","red")}}},{key:"translateColon",value:function(e){return e?e.replace(/%3A/g,":"):""}},{key:"processChatMessage",value:function(e){console.log("<< "+e);var t=e.split(":");switch(t[0]){case"MSG":this.addMessage(this.translateColon(t[2]),H[t[1]]);break;case"WELCOME":this.addMessage("Conectado al chat, "+t[1]);break;case"COUNT":this.setState({chatUserCount:t[1]});break;default:console.log("[Chat] Unsupported command "+t[0])}}},{key:"handleOnChange",value:function(e,t){this.setState({chatMessage:t.value})}},{key:"compareSongs",value:function(){var e=this.state,t=e.currentSong,a=e.multipleSources,n=e.selectedStream,r=e.response,o=a?r.source[n]:r.source;"".concat(o.artist," - ").concat(o.title)!==t&&(this.addToHistory(t),this.setState({currentSong:"".concat(o.artist," - ").concat(o.title)}))}},{key:"updateInfo",value:function(){var e=this,t=this.state,a=t.currentSong,n=t.multipleSources,r=t.selectedStream,o=t.response,l=n?o.source[r]:o.source;""===a&&this.setState({currentSong:"".concat(l.artist," - ").concat(l.title)}),fetch("https://bienvenidoainternet.org:8443/status-json.xsl").then((function(e){return e.json()})).then((function(t){e.setState({response:t.icestats},(function(){var t=e.state.response.source;if(void 0!==t&&Array.isArray(t)){var a=[];t.map((function(e,t){return a.push({key:t,value:t,text:"[".concat(e.listeners,"] ").concat(e.server_name," - ").concat(e.server_description)})})),e.setState({streamsAvailable:a,multipleSources:!0})}else void 0!==t&&e.setState({multipleSources:!1,selectedStream:0});e.compareSongs()}))}))}},{key:"componentDidMount",value:function(){var e=this;fetch("https://bienvenidoainternet.org:8443/status-json.xsl").then((function(e){return e.json()})).then((function(t){return e.setState({response:t.icestats,infoUpdate:setInterval((function(){return e.updateInfo()}),1e4)},(function(){var t=e.state.response.source;if(void 0!==t&&Array.isArray(t)){var a=[];t.map((function(e,t){return a.push({key:t,value:t,text:"[".concat(e.listeners,"] ").concat(e.server_name," - ").concat(e.server_description)})})),console.log(a),e.setState({multipleSources:!0,streamsAvailable:a,ready:!0})}else void 0!==t&&e.setState({multipleSources:!1,selectedStream:0,ready:!0})}))}))}},{key:"render",value:function(){var e=this,t=this.state,a=t.ready,n=t.response,o=t.history,l=t.chat,s=t.chatMessage,c=t.streamsAvailable,i=t.multipleSources,u=t.selectedStream,m=t.chatUserCount,d=t.isChatOnline,h=void 0!==n.source;if(!a)return"Loading";var k=i?n.source[u]:n.source,w=k.listenurl.replace("http://bienvenidoainternet.org:8000","https://bienvenidoainternet.org:8443");return r.a.createElement(p.a,{style:{paddingTop:"50px"}},r.a.createElement(g.a,{style:{padding:"2em"}},r.a.createElement(v.a,{stackable:!0},r.a.createElement(v.a.Row,{columns:2},r.a.createElement(v.a.Column,null,r.a.createElement(E.a,{as:"h2"},r.a.createElement(f.a,{name:"broadcast tower"}),r.a.createElement(E.a.Content,null,"BaiRadio",r.a.createElement(E.a.Subheader,null,a?n.server_id:"Sin informaci\xf3n")))),r.a.createElement(v.a.Column,{floated:"right"},r.a.createElement("audio",{xmlns:"http://www.w3.org/1999/xhtml",controls:"controls",preload:"none",autoPlay:!0,id:"player"},r.a.createElement("source",{src:w,type:"application/ogg"})))),r.a.createElement(v.a.Row,{divided:!0,columns:2},r.a.createElement(v.a.Column,{width:6},h?r.a.createElement(r.a.Fragment,null,i&&r.a.createElement(r.a.Fragment,null,r.a.createElement("label",{className:"dropdownLabel"},"Transmisiones disponibles:"),r.a.createElement(y.a,{defaultValue:0,fluid:!0,selection:!0,options:c,onChange:function(t,a){return e.setState({selectedStream:a.value},(function(){var e=document.getElementById("player");null!==e&&(e.pause(),e.load(),e.play())}))}})),r.a.createElement(E.a,{as:"h3"},"Informaci\xf3n de la transmisi\xf3n"),r.a.createElement(I,{stream:k})):r.a.createElement(S.a,{negative:!0},r.a.createElement(S.a.Header,null,"Oops"),"Actualmente no hay nadie transmitiendo en Bai Radio"),r.a.createElement(E.a,{as:"h3"},"Historial de canciones"),r.a.createElement(b.a,null,o.map((function(e){return r.a.createElement(b.a.Item,null,r.a.createElement(b.a.Icon,{name:"music"}),r.a.createElement(b.a.Content,null,e))})))),r.a.createElement(v.a.Column,{width:10},r.a.createElement(E.a,{as:"h3"},"Chat",r.a.createElement(E.a.Subheader,null,"Usuarios en el chat: ".concat(m))),r.a.createElement("div",{id:"chatContainer",style:{minHeight:"300px",maxHeight:"300px",overflowY:"scroll",overflowWrap:"break-word"}},r.a.createElement(b.a,null,l.map((function(e,t){return r.a.createElement(b.a.Item,{key:t},"[",r.a.createElement(M.a,{format:"HH:mm",date:e.timestamp}),"]"," ",r.a.createElement("span",{className:"ui text ".concat(e.color)},e.content))})))),r.a.createElement(C.a,{fluid:!0,size:"mini",action:{content:"Enviar",onClick:function(){e.sendMessage()},disabled:!d},placeholder:"",value:s,onChange:this.handleOnChange,style:{marginTop:"0.75em"},maxLength:128,onKeyUp:function(){},disabled:!d}))))),r.a.createElement(p.a,{textAlign:"center"},r.a.createElement("span",{className:"ui text grey"},"Bienvenido a Internet 2010 - 2020")))}}]),t}(n.Component);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));l.a.render(r.a.createElement(x,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[170,1,2]]]);
//# sourceMappingURL=main.75ca3e1e.chunk.js.map