Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- socket.on('Start_chrono',function(match,timerMatch){
- if (typeof timer[match]!='object') {
- timer[match] = new Timer();
- timer[match].addEventListener('secondsUpdated', () => {
- timeInminutes = timer[match].getTotalTimeValues().minutes +':'+timer[match].getTimeValues().seconds;
- socket.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- socket.broadcast.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- });
- timer[match].start();
- }else{
- timer[match].start();
- }
- });
- socket.on('Pause_chrono',function(match,timerMatch){
- timer[match]=new Timer(timerMatch);
- if ( typeof timer[match]=='object') {
- console.log('pause');
- timer[match].pause();
- timeInminutes = timer[match].getTotalTimeValues().minutes +':'+timer[match].getTimeValues().seconds;
- socket.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- socket.broadcast.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- }
- });
- socket.on('Stop_chrono',function(match,timerMatch){
- timer[match]=new Timer(timerMatch);
- if ( typeof timer[match]=='object') {
- timer[match].stop();
- console.log('stop');
- timeInminutes = timer[match].getTotalTimeValues().minutes +':'+timer[match].getTimeValues().seconds;
- socket.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- socket.broadcast.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- }
- });
- socket.on('Reset_chrono',function(match,timerMatch){
- timer[match]=new Timer(timerMatch);
- if ( typeof timer[match]=='object') {
- timer[match].reset();
- console.log('reset');
- timeInminutes = timer[match].getTotalTimeValues().minutes +':'+timer[match].getTimeValues().seconds;
- socket.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- socket.broadcast.emit('chrono',{match:match,chrono:timeInminutes.toString(),timerMatch:timer[match]});
- }
- });
- var timer;
- function Chrono(type){
- match=<%= match.id %>;
- if (type!="Start") {
- $('#chronostart').show();
- if (typeof timer!='undefined') {
- socket.emit(type+'_chrono',match,timer);
- }else{
- socket.emit(type+'_chrono',match,0);
- }
- }else{
- $('#chronostart').hide();
- if (typeof timer!='undefined') {
- console.log(typeof timer);
- socket.emit(type+'_chrono',match,timer);
- }else{
- console.log(typeof timer);
- socket.emit(type+'_chrono',match,0);
- }
- }
- }
- function UpdateScore(){
- var channel=$('#channel').val();
- var layer=$('#layer').val();
- var template='template';
- var data='<templateData></templateData>';
- socket.emit('Update_data',channel,layer,template,data);
- }
- socket.on('chrono', function(data) {
- if (data.match==<%= match.id %>) {
- timer = data.timerMatch;
- if ($('#basicUsage').val()!=data.chrono) {
- $('#basicUsage').val(data.chrono);
- $('#chronostart').hide();
- }
- UpdateScore();
- }
- })
Add Comment
Please, Sign In to add comment