<commit_before>var APPKEY = '56a0a88c4407a3cd028ac2fe';
var TOPIC_BULLET = 'bullet';
var TOPIC_LIKE = 'like';
var TOPIC_STAT = 'stat';
var TEXTS = ['♪', '♩', '♭', '♬'];

function init() {
  var player = $('#my-player');
  var bullet = $('#my-comment-stage');
  player.css("width", "100%");
  player.height(player.width() * 9 / 16.0);

  bullet.css("width", "100%");

  var video = $('#live-video');
  video.width(player.width());
  video.height(player.height());
  video.css("display", "block");

  var cm = new CommentManager(document.getElementById('my-comment-stage'));
  cm.init();
  cm.start();

  window.cm = cm;
  window.cm_width = bullet.width();
  window.cm_height = bullet.height();
}

$(document).ready(function() {

  $('#span-status').text('正在连接云巴服务器...');

  window.onresize = init;
  init();

  videojs("live-video", {
    "techOrder": ["flash", "html5"],
    "controls": "false",
    "autoplay": "false",
    "preload": "auto"
  }, function() {
    var player = this;
    player.play();
  });

  // var bullet = {
  //   "mode": 1,
  //   "text": "Hello CommentCoreLibrary",
  //   "color": 0xff0000
  // };

  // cm.send(bullet);

  window.yunba = new Yunba({
    server: 'sock.yunba.io',
    port: 3000,
    appkey: APPKEY
  });

  // 初始化云巴 SDK
  yunba.init(function(success) {
    if (success) {
      var cid = Math.random().toString().substr(2);
      console.log('cid: ' + cid);
      window.alias = cid;

      // 连接云巴服务器
      yunba.connect_by_customid(cid,
        function(success, msg, sessionid) {
          if (success) {
            console.log('sessionid：' + sessionid);

            // 设置收到信息回调函数
            yunba.set_message_cb(yunba_msg_cb);

            // 设置别名
            yunba.set_alias({
              'alias': alias
            }, function(data) {

              // 订阅弹幕 TOPIC
              yunba.subscribe({
                  'topic': TOPIC_BULLET
                },
                function(success, msg) {
                  if (success) {
                    console.log('subscribed');

                    // 订阅点赞 TOPIC
                    yunba.subscribe({
                        'topic': TOPIC_LIKE
                      },
                      function(success, msg) {
                        if (success) {
                          console.log('subscribed');

                          // 订阅统计信息 TOPIC
                          yunba.subscribe({
                              'topic': TOPIC_STAT
                            },
                            function(success, msg) {
                              if (success) {
                                console.log('subscribed');
                                yunba_sub_ok();
                                // msg_notify('success', '连接服务器成功~');
                              } else {
                                console.log(msg);
                                // msg_notify('error', msg);
                              }
                            }
                          );
                        } else {
                          console.log(msg);
                          // msg_notify('error', msg);
                        }
                      }
                    );
                  } else {
                    console.log(msg);
                    // msg_notify('error', msg);
                  }
                }
              );
            });

          } else {
            console.log(msg);
            // msg_notify('error', msg);
          }
        });
    } else {
      console.log('yunba init failed');
      // msg_notify('error', '连接出错，请尝试刷新~');
    }
  });
});

$('#btn-send').click(function() {
  var mode = 1;
  switch ($('#bullet-type').prop('selectedIndex')) {
    case 0:
      mode = 2;
      break;

    case 1:
      mode = 1;
      break;

    case 2:
      mode = 4;
      break;

    case 3:
      mode = 5;
      break;

    case 4:
      mode = 6;
      break;
  }
  var text = $('#bullet-text').val();
  var color = parseInt('0x' + $('#bullet-color').val());

  var bullet = {
    "mode": mode,
    "text": text,
    "color": color
  };
  // console.log(bullet);<commit_msg>Fix duration option<commit_after>var APPKEY = '56a0a88c4407a3cd028ac2fe';
var TOPIC_BULLET = 'bullet';
var TOPIC_LIKE = 'like';
var TOPIC_STAT = 'stat';
var TEXTS = ['♪', '♩', '♭', '♬'];

function init() {
  var player = $('#my-player');
  var bullet = $('#my-comment-stage');
  player.css("width", "100%");
  player.height(player.width() * 9 / 16.0);

  bullet.css("width", "100%");

  var video = $('#live-video');
  video.width(player.width());
  video.height(player.height());
  video.css("display", "block");

  var cm = new CommentManager(document.getElementById('my-comment-stage'));
  cm.init();
  cm.start();

  window.cm = cm;
  window.cm_width = bullet.width();
  window.cm_height = bullet.height();
}

$(document).ready(function() {

  $('#span-status').text('正在连接云巴服务器...');

  window.onresize = init;
  init();

  videojs("live-video", {
    "techOrder": ["flash", "html5"],
    "controls": "false",
    "autoplay": "false",
    "preload": "auto"
  }, function() {
    var player = this;
    player.play();
  });

  // var bullet = {
  //   "mode": 1,
  //   "text": "Hello CommentCoreLibrary",
  //   "color": 0xff0000
  // };

  // cm.send(bullet);

  window.yunba = new Yunba({
    server: 'sock.yunba.io',
    port: 3000,
    appkey: APPKEY
  });

  // 初始化云巴 SDK
  yunba.init(function(success) {
    if (success) {
      var cid = Math.random().toString().substr(2);
      console.log('cid: ' + cid);
      window.alias = cid;

      // 连接云巴服务器
      yunba.connect_by_customid(cid,
        function(success, msg, sessionid) {
          if (success) {
            console.log('sessionid：' + sessionid);

            // 设置收到信息回调函数
            yunba.set_message_cb(yunba_msg_cb);

            // 设置别名
            yunba.set_alias({
              'alias': alias
            }, function(data) {

              // 订阅弹幕 TOPIC
              yunba.subscribe({
                  'topic': TOPIC_BULLET
                },
                function(success, msg) {
                  if (success) {
                    console.log('subscribed');

                    // 订阅点赞 TOPIC
                    yunba.subscribe({
                        'topic': TOPIC_LIKE
                      },
                      function(success, msg) {
                        if (success) {
                          console.log('subscribed');

                          // 订阅统计信息 TOPIC
                          yunba.subscribe({
                              'topic': TOPIC_STAT
                            },
                            function(success, msg) {
                              if (success) {
                                console.log('subscribed');
                                yunba_sub_ok();
                                // msg_notify('success', '连接服务器成功~');
                              } else {
                                console.log(msg);
                                // msg_notify('error', msg);
                              }
                            }
                          );
                        } else {
                          console.log(msg);
                          // msg_notify('error', msg);
                        }
                      }
                    );
                  } else {
                    console.log(msg);
                    // msg_notify('error', msg);
                  }
                }
              );
            });

          } else {
            console.log(msg);
            // msg_notify('error', msg);
          }
        });
    } else {
      console.log('yunba init failed');
      // msg_notify('error', '连接出错，请尝试刷新~');
    }
  });
});

$('#btn-send').click(function() {
  var mode = 1;
  switch ($('#bullet-type').prop('selectedIndex')) {
    case 0:
      mode = 2;
      break;

    case 1:
      mode = 1;
      break;

    case 2:
      mode = 4;
      break;

    case 3:
      mode = 5;
      break;

    case 4:
      mode = 6;
      break;
  }
  var text = $('#bullet-text').val();
  var color = parseInt('0x' + $('#bullet-color').val());
  var dur = parseInt($('#bullet-dur').val());

  var bullet = {
    "mode": mode,
    "text": text,
    "color": color,
    "dur": dur
  };
  // console.log(bullet);
{'fraction_non_alphanumeric': 0.15568862275449102, 'fraction_numerical': 0.011497005988023952, 'mean_word_length': 1.2322908313285217, 'pattern_counts': {'":': 21, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2151519', 'n_tokens_mistral': 2684, 'n_tokens_neox': 2566, 'n_words': 448}