當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript path.contains方法代碼示例

本文整理匯總了TypeScript中tree.path.contains方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript path.contains方法的具體用法?TypeScript path.contains怎麽用?TypeScript path.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tree.path的用法示例。


在下文中一共展示了path.contains方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: throttle

 var getDests = throttle(800, function() {
   if (!vm.node.dests && treePath.contains(vm.path, vm.initialPath))
     socket.sendAnaDests({
       fen: vm.node.fen,
       path: vm.path
     });
 });
開發者ID:ddugovic,項目名稱:lila,代碼行數:7,代碼來源:ctrl.ts

示例2: nodeClasses

export function nodeClasses(ctx: Ctx, path: Tree.Path): NodeClasses {
  return {
    active: path === ctx.ctrl.path,
    context_menu: path === ctx.ctrl.contextMenuPath,
    current: path === ctx.currentPath,
    nongame: !ctx.currentPath && !!ctx.ctrl.gamePath && treePath.contains(path, ctx.ctrl.gamePath) && path !== ctx.ctrl.gamePath
  };
}
開發者ID:ddugovic,項目名稱:lila,代碼行數:8,代碼來源:treeView.ts

示例3: h

 return h('lines', nodes.map(n => {
   return retroLine(ctx, n, opts) || h('line', renderMoveAndChildrenOf(ctx, n, {
     parentPath: opts.parentPath,
     isMainline: false,
     withIndex: true,
     truncate: n.comp && !treePath.contains(ctx.ctrl.path, opts.parentPath + n.id) ? 3 : undefined
   }));
 }));
開發者ID:ddugovic,項目名稱:lila,代碼行數:8,代碼來源:inlineView.ts

示例4: nodeClasses

export function nodeClasses(c: AnalyseCtrl, path: Tree.Path): NodeClasses {
  const current = (path === c.initialPath && game.playable(c.data)) || (
    c.retro && c.retro.current() && c.retro.current().prev.path === path
  );
  return {
    active: path === c.path,
    context_menu: path === c.contextMenuPath,
    current,
    nongame: !current && !!c.gamePath && treePath.contains(path, c.gamePath) && path !== c.gamePath
  };
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:11,代碼來源:treeView.ts

示例5: function

  return function() {

    if (vm.mode === 'view') return;
    if (!pathOps.contains(vm.path, vm.initialPath)) return;

    var playedByColor = vm.node.ply % 2 === 1 ? 'white' : 'black';
    if (playedByColor !== puzzle.color) return;

    var nodes = vm.nodeList.slice(pathOps.size(vm.initialPath) + 1).map(function(node) {
      return {
        uci: node.uci,
        castle: node.san.startsWith('O-O')
      };
    });

    var progress = puzzle.lines;
    for (var i in nodes) {
      if (progress[nodes[i].uci]) progress = progress[nodes[i].uci];
      else if (nodes[i].castle) progress = progress[altCastles[nodes[i].uci]] || 'fail';
      else progress = 'fail';
      if (typeof progress === 'string') break;
    }
    if (typeof progress === 'string') {
      vm.node.puzzle = progress;
      return progress;
    }

    var nextKey = Object.keys(progress)[0]
      if (progress[nextKey] === 'win') {
        vm.node.puzzle = 'win';
        return 'win';
      }

      // from here we have a next move

      vm.node.puzzle = 'good';

    var opponentUci = decomposeUci(nextKey);
    var promotion = opponentUci[2] ? sanToRole[opponentUci[2].toUpperCase()] : null;

    var move: any = {
      orig: opponentUci[0],
      dest: opponentUci[1],
      fen: vm.node.fen,
      path: vm.path
    };
    if (promotion) move.promotion = promotion;

    return move;
  };
開發者ID:ornicar,項目名稱:lila,代碼行數:50,代碼來源:moveTest.ts

示例6: first

export function first(ctrl) {
  var toInit = ctrl.vm.path !== ctrl.vm.initialPath && treePath.contains(ctrl.vm.path, ctrl.vm.initialPath);
  ctrl.userJump(
    toInit ? ctrl.vm.initialPath : treePath.root
  );
}
開發者ID:ddugovic,項目名稱:lila,代碼行數:6,代碼來源:control.ts

示例7: last

export function last(ctrl) {
  var toInit = !treePath.contains(ctrl.vm.path, ctrl.vm.initialPath);
  ctrl.userJump(
    toInit ? ctrl.vm.initialPath : treePath.fromNodeList(ctrl.vm.mainline)
  );
}
開發者ID:ddugovic,項目名稱:lila,代碼行數:6,代碼來源:control.ts

示例8: function


//.........這裏部分代碼省略.........
    obj.path = ctrl.path;
    return obj;
  }

  return {
    data,
    form,
    members,
    chapters,
    notif,
    commentForm,
    glyphForm,
    share,
    tags,
    desc,
    vm,
    isUpdatedRecently() {
      return Date.now() - vm.updatedAt < 300 * 1000;
    },
    toggleLike() {
      send("like", {
        liked: !data.liked
      });
    },
    position() {
      return data.position;
    },
    currentChapter,
    isChapterOwner,
    canJumpTo(path: Tree.Path) {
      if (gamebookPlay) return gamebookPlay.canJumpTo(path);
      return data.chapter.conceal === undefined ||
        isChapterOwner() ||
        treePath.contains(ctrl.path, path) || // can always go back
        ctrl.tree.lastMainlineNode(path).ply <= data.chapter.conceal!;
    },
    onJump() {
      chapters.localPaths[vm.chapterId] = ctrl.path;
      if (practice) practice.onJump();
      if (gamebookPlay) gamebookPlay.onJump();
    },
    withPosition,
    setPath(path, node) {
      onSetPath(path);
      setTimeout(() => commentForm.onSetPath(path, node), 100);
    },
    deleteNode(path) {
      makeChange("deleteNode", addChapterId({
        path,
        jumpTo: ctrl.path
      }));
    },
    promote(path, toMainline) {
      makeChange("promote", addChapterId({
        toMainline,
        path
      }));
    },
    setChapter(id, force) {
      if (id === vm.chapterId && !force) return;
      if (!vm.mode.sticky || !makeChange("setChapter", id)) {
        vm.mode.sticky = false;
        if (!vm.behind) vm.behind = 1;
        vm.chapterId = id;
        xhrReload();
      }
開發者ID:lexisvar,項目名稱:lila,代碼行數:67,代碼來源:studyCtrl.ts

示例9: pathContains

function pathContains(ctx, path) {
  return treePath.contains(ctx.ctrl.vm.path, path);
}
開發者ID:ornicar,項目名稱:lila,代碼行數:3,代碼來源:tree.ts

示例10: function

 return function(path: Tree.Path, node: Tree.Node) {
   if (!conceal || (isMainline && conceal.ply >= node.ply)) return null;
   if (treePath.contains(ctrl.path, path)) return null;
   return conceal.owner ? 'conceal' : 'hide';
 };
開發者ID:luanlv,項目名稱:lila,代碼行數:5,代碼來源:view.ts


注:本文中的tree.path.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。