• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript chat.ChatCtrl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中chat.ChatCtrl的典型用法代码示例。如果您正苦于以下问题:TypeScript ChatCtrl类的具体用法?TypeScript ChatCtrl怎么用?TypeScript ChatCtrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ChatCtrl类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

export default function(opts: RoundOpts, element: HTMLElement): void {
  const data: RoundData = opts.data;
  li.openInMobileApp(data.game.id);
  let round: RoundApi, chat: ChatCtrl | undefined;
  if (data.tournament) $('body').data('tournament-id', data.tournament.id);
  li.socket = li.StrongSocket(
    data.url.socket,
    data.player.version, {
      options: { name: 'round' },
      params: { userTv: data.userTv && data.userTv.id },
      receive(t: string, d: any) { round.socketReceive(t, d); },
      events: {
        crowd(e: { watchers: number }) {
          $watchers.watchers("set", e.watchers);
        },
        tvSelect(o: any) {
          if (data.tv && data.tv.channel == o.channel) li.reload();
          else $('#tv_channels a.' + o.channel + ' span').html(
            o.player ? [
              o.player.title,
              o.player.name,
              '(' + o.player.rating + ')'
            ].filter(x => x).join('&nbsp') : 'Anonymous');
        },
        end() {
          $.ajax({
            url: [(data.tv ? '/tv/'  + data.tv.channel : ''), data.game.id, data.player.color, 'sides'].join('/'),
            success: function(html) {
              const $html = $(html);
              $('#site_header div.side').replaceWith($html.find('.side'));
              $('#lichess div.crosstable').replaceWith($html.find('.crosstable'));
              li.pubsub.emit('content_loaded')();
              startTournamentClock();
            }
          });
        },
        tourStanding(s: TourPlayer[]) {
          if (opts.chat && opts.chat.plugin && chat) {
            (opts.chat.plugin as TourStandingCtrl).set(s);
            chat.redraw();
          }
        }
      }
    });

  function startTournamentClock() {
    $("div.game_tournament div.clock").each(function(this: HTMLElement) {
      $(this).clock({
        time: parseFloat($(this).data("time"))
      });
    });
  };
  function getPresetGroup(d: RoundData) {
    if (d.player.spectator) return;
    if (d.steps.length < 4) return 'start';
    else if (d.game.status.id >= 30) return 'end';
    return;
  };
  opts.element = element.querySelector('.round') as HTMLElement;
  opts.socketSend = li.socket.send;
  if (!opts.tour && !data.simul) opts.onChange = (d: RoundData) => {
    if (chat) chat.preset.setGroup(getPresetGroup(d));
  };
  opts.crosstableEl = element.querySelector('.crosstable') as HTMLElement;

  let $watchers: JQuery;
  function letsGo() {
    round = (window['LichessRound'] as RoundMain).app(opts);
    if (opts.chat) {
      if (opts.tour) {
        opts.chat.plugin = tourStandingCtrl(opts.tour, opts.i18n.standing);
        opts.chat.alwaysEnabled = true;
      } else if (!data.simul) {
        opts.chat.preset = getPresetGroup(opts.data);
        opts.chat.parseMoves = true;
      }
      li.makeChat('chat', opts.chat, function(c) {
        chat = c;
      });
    }
    $watchers = $('#site_header div.watchers').watchers();
    startTournamentClock();
    $('#now_playing').find('.move_on input').change(function() {
      round.moveOn.toggle();
    }).prop('checked', round.moveOn.get()).on('click', 'a', function() {
      li.hasToReload = true;
      return true;
    });
    $('#now_playing').find('.zen input').change(function() {
      li.loadCss('/assets/stylesheets/zen.css');
      $('body').toggleClass('zen');
    });
    if (location.pathname.lastIndexOf('/round-next/', 0) === 0)
      history.replaceState(null, '', '/' + data.game.id);
    if (!data.player.spectator && data.game.status.id < 25) li.topMenuIntent();
  };
  if (window.navigator.userAgent.indexOf('Trident/') > -1) setTimeout(letsGo, 150);
  else letsGo();
}
开发者ID:lexisvar,项目名称:lila,代码行数:99,代码来源:boot.ts


示例2: function

export default function(opts: RoundOpts): void {
  const li = window.lichess;
  const element = document.querySelector('.round__app') as HTMLElement,
  data: RoundData = opts.data;
  let round: RoundApi, chat: ChatCtrl | undefined;
  if (data.tournament) $('body').data('tournament-id', data.tournament.id);
  li.socket = li.StrongSocket(
    data.url.socket,
    data.player.version, {
      options: { name: 'round' },
      params: { userTv: data.userTv && data.userTv.id },
      receive(t: string, d: any) { round.socketReceive(t, d); },
      events: {
        tvSelect(o: any) {
          if (data.tv && data.tv.channel == o.channel) li.reload();
          else $('.tv-channels .' + o.channel + ' .champion').html(
            o.player ? [
              o.player.title,
              o.player.name,
              '(' + o.player.rating + ')'
            ].filter(x => x).join('&nbsp') : 'Anonymous');
        },
        end() {
          $.ajax({
            url: [(data.tv ? '/tv' : ''), data.game.id, data.player.color, 'sides'].join('/'),
            success: function(html) {
              const $html = $(html), $meta = $html.find('.game__meta');
              $meta.length && $('.game__meta').replaceWith($meta);
              $('.crosstable').replaceWith($html.find('.crosstable'));
              li.pubsub.emit('content_loaded')();
            }
          });
        },
        tourStanding(s: TourPlayer[]) {
          if (opts.chat && opts.chat.plugin && chat) {
            (opts.chat.plugin as TourStandingCtrl).set(s);
            chat.redraw();
          }
        }
      }
    });

  function startTournamentClock() {
    $('.game__tournament .clock').each(function(this: HTMLElement) {
      $(this).clock({
        time: parseFloat($(this).data('time'))
      });
    });
  };
  function getPresetGroup(d: RoundData) {
    if (d.player.spectator) return;
    if (d.steps.length < 4) return 'start';
    else if (d.game.status.id >= 30) return 'end';
    return;
  };
  opts.element = element;
  opts.socketSend = li.socket.send;
  if (!opts.tour && !data.simul) opts.onChange = (d: RoundData) => {
    if (chat) chat.preset.setGroup(getPresetGroup(d));
  };

  round = (window['LichessRound'] as RoundMain).app(opts);
  if (opts.chat) {
    if (opts.tour) {
      opts.chat.plugin = tourStandingCtrl(opts.tour, opts.i18n.standing);
      opts.chat.alwaysEnabled = true;
    } else if (!data.simul) {
      opts.chat.preset = getPresetGroup(opts.data);
      opts.chat.parseMoves = true;
    }
    li.makeChat(opts.chat, function(c) {
      chat = c;
    });
  }
  startTournamentClock();
  $('.round__now-playing .move-on input')
  .change(round.moveOn.toggle)
  .prop('checked', round.moveOn.get())
  .on('click', 'a', function() {
    li.hasToReload = true;
    return true;
  });
  if (location.pathname.lastIndexOf('/round-next/', 0) === 0)
  history.replaceState(null, '', '/' + data.game.id);
  $('#zentog').click(li.pubsub.emit('zen'));
  li.storage.make('reload-round-tabs').listen(li.reload);
}
开发者ID:ornicar,项目名称:lila,代码行数:87,代码来源:boot.ts



注:本文中的chat.ChatCtrl类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cheerio.default函数代码示例发布时间:2022-05-24
下一篇:
TypeScript chartist.Interpolation类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap