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


TypeScript snabbdom.thunk函數代碼示例

本文整理匯總了TypeScript中snabbdom.thunk函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript thunk函數的具體用法?TypeScript thunk怎麽用?TypeScript thunk使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: userBox

function userBox(ctrl: Controller) {
  const data = ctrl.getData();
  if (!data.user) return;
  let ratingHtml = data.user.rating;
  if (ctrl.vm.round) {
    let diff = ctrl.vm.round.ratingDiff,
      klass = '';
    if (diff >= 0) {
      diff = '+' + diff;
      if (diff > 0) klass = 'up';
    } else if (diff === 0) diff = '+0';
    else {
      diff = '−' + (-diff);
      klass = 'down';
    }
    ratingHtml += ' <span class="rp ' + klass + '">' + diff + '</span>';
  }
  const hash = ctrl.recentHash();
  return h('div.side_box.rating', [
    h('h2', {
      hook: innerHTML(ctrl.trans('yourPuzzleRatingX', strong(ratingHtml)))
    }),
    h('div', thunk('div.rating_chart.' + hash, ratingChart, [ctrl, hash]))
  ]);
}
開發者ID:ddugovic,項目名稱:lila,代碼行數:25,代碼來源:side.ts

示例2: render

export function render(ctrl: AnalyseCtrl): MaybeVNode {

  if (!ctrl.data.analysis || !ctrl.showComputer() || (ctrl.study && ctrl.study.vm.toolTab() !== 'serverEval')) return;

  // don't cache until the analysis is complete!
  const buster = ctrl.data.analysis.partial ? Math.random() : '';
  const cacheKey = '' + buster + !!ctrl.retro;

  return thunk('div.advice_summary', doRender, [ctrl, cacheKey]);
}
開發者ID:mate-amargo,項目名稱:lila,代碼行數:10,代碼來源:acpl.ts

示例3: main

export function main(ctrl: StudyCtrl): VNode {

  const current = ctrl.currentChapter(),
  data = ctrl.practice!.data;

  return h('div.side_box.study_box', [
    h('div.title', [
      h('i.practice.icon.' + data.study.id),
      h('div.text', [
        h('h1', data.study.name),
        h('em', data.study.desc)
      ])
    ]),
    h('div.list.chapters', {
      hook: bind('click', e => {
        e.preventDefault();
        const target = e.target as HTMLElement;
        const id = (target.parentNode as HTMLElement).getAttribute('data-id') || target.getAttribute('data-id');
        if (id) ctrl.setChapter(id, true);
        return false;
      })
    }, ctrl.chapters.list().map(function(chapter) {
      const loading = ctrl.vm.loading && chapter.id === ctrl.vm.nextChapterId;
      const active = !ctrl.vm.loading && current && current.id === chapter.id;
      const completion = data.completion[chapter.id] ? 'done' : 'ongoing';
      return [
        h('a.elem.chapter', {
          key: chapter.id,
          attrs: {
            href: data.url + '/' + chapter.id,
            'data-id': chapter.id
          },
          class: { active, loading }
        }, [
          h('span.status.' + completion, {
            attrs: {
              'data-icon': ((loading || active) && completion === 'ongoing') ? 'G' : 'E'
            }
          }),
          h('h3', chapter.name)
        ])
      ];
    }).reduce(function(a, b) { return a.concat(b); }, [])),
    h('div.finally', [
      h('a.back', {
        attrs: {
          'data-icon': 'I',
          href: '/practice',
          title: 'More practice'
        }
      }),
      thunk('select.selector', selector, [data])
    ])
  ]);
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:55,代碼來源:studyPracticeView.ts

示例4: render

export function render(ctrl: AnalyseCtrl): MaybeVNode {

  if (!ctrl.data.analysis || !ctrl.showComputer()) return;

  // don't cache until the analysis is complete!
  const firstEval = ctrl.mainline[0].eval;
  const firstKey = firstEval ? firstEval.cp : Math.random();
  const cacheKey = '' + firstKey + !!ctrl.retro;

  return thunk('div.advice_summary', doRender, [ctrl, cacheKey]);
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:11,代碼來源:acpl.ts

示例5: render

export function render(ctrl: AnalyseCtrl): VNode | undefined {

  if (ctrl.studyPractice || ctrl.embed) return;

  if (!ctrl.data.analysis || !ctrl.showComputer() || (ctrl.study && ctrl.study.vm.toolTab() !== 'serverEval'))
    return h('div.analyse__acpl');

  // don't cache until the analysis is complete!
  const buster = ctrl.data.analysis.partial ? Math.random() : '';
  let cacheKey = '' + buster + !!ctrl.retro;
  if (ctrl.study) cacheKey += ctrl.study.data.chapter.id;

  return h('div.analyse__acpl', thunk('div.advice-summary', doRender, [ctrl, cacheKey]));
}
開發者ID:ornicar,項目名稱:lila,代碼行數:14,代碼來源:acpl.ts

示例6: renderLine

function renderLine(ctrl: Ctrl, line: Line) {

  const textNode = renderText(line.t, ctrl.opts.parseMoves);

  if (line.u === 'lichess') return h('li.system', textNode);

  if (line.c) return h('li', [
    h('span', '[' + line.c + ']'),
    textNode
  ]);

  const userNode = thunk('a', line.u, userLink, [line.u]);

  return h('li', {
  }, ctrl.moderation() ? [
    line.u ? lineAction(line.u) : null,
    userNode,
    textNode
  ] : [userNode, textNode]);
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:20,代碼來源:discussion.ts

示例7: userBox

export function userBox(ctrl: Controller) {
  const data = ctrl.getData();
  if (!data.user) return;
  let ratingHtml = data.user.rating;
  if (ctrl.vm.round) {
    let diff = ctrl.vm.round.ratingDiff,
      tag = 'bad';
    if (diff) {
      if (diff > 0) {
        diff = '+' + diff;
        tag = 'good';
      }
      else diff = '−' + (-diff);
      ratingHtml += ` <${tag} class="rp">${diff}</${tag}>`;
    }
  }
  const hash = ctrl.recentHash();
  return h('div.puzzle__side__user', [
    h('h2', {
      hook: innerHTML(ctrl.trans('yourPuzzleRatingX', strong(ratingHtml)))
    }),
    h('div', thunk('div.rating_chart.' + hash, ratingChart, [ctrl, hash]))
  ]);
}
開發者ID:ornicar,項目名稱:lila,代碼行數:24,代碼來源:side.ts

示例8: view

export function view(root: StudyCtrl): VNode {
  const chapter = root.tags.getChapter(),
  tagKey = chapter.tags.map(t => t[1]).join(','),
  key = chapter.id + root.data.name + chapter.name + root.data.likes + tagKey + root.vm.mode.write;
  return thunk('div.undertable_inner.' + chapter.id, doRender, [root, key]);
}
開發者ID:luanlv,項目名稱:lila,代碼行數:6,代碼來源:studyTags.ts

示例9: function

export default function(ctrl) {
  if (!ctrl.getData().user) return;
  return thunk('div.puzzle__history', render, [ctrl, ctrl.recentHash()]);
};
開發者ID:ornicar,項目名稱:lila,代碼行數:4,代碼來源:history.ts


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