Trello - Thenow Trello Extend

扩展trello.com看板的功能

当前为 2016-12-19 提交的版本,查看 最新版本

// Generated by CoffeeScript 1.12.2

/*
// ==UserScript==
// @name         Trello - Thenow Trello Extend
// @namespace    http://ejiasoft.com/
// @version      1.1
// @description  Extend trello.com
// @description:zh-CN 扩展trello.com看板的功能
// @homepageurl  https://github.com/thenow/ThenowTrelloExtend
// @author       thenow
// @run-at       document-end
// @license      MIT license
// @match        http*://*trello.com
// @match        http*://*trello.com/*
// @grant        none
// ==/UserScript==
 */

(function() {
  var curUrl, imgSwitch_click, init, listCardFormat, listFormatInit, listTitleFormat, pageRegex, showCardNum;

  curUrl = window.location.href;

  pageRegex = {
    CardLimit: /\[\d+\]/,
    Category: /{.+}/g,
    User: /`\S+`/g,
    CardCount: /^\d+/,
    Number: /\d+/,
    CardNum: /^#\d+/,
    HomePage: /com[\/]$/
  };

  listCardFormat = function(objCard) {
    var cardTitle, cardUser, cardUserArray, i, len, listCardTitle, trueUser;
    listCardTitle = objCard.find('a.list-card-title');
    cardTitle = listCardTitle.html();
    cardUserArray = cardTitle.match(pageRegex.User);
    if (cardUserArray === null) {
      return;
    }
    for (i = 0, len = cardUserArray.length; i < len; i++) {
      cardUser = cardUserArray[i];
      cardTitle = cardTitle.replace(cardUser, '');
      trueUser = cardUser.replace(/`/g, '');
      cardTitle += "<code>" + trueUser + "</code>";
    }
    return listCardTitle.html(cardTitle);
  };

  listTitleFormat = function(objList) {
    var cardCount, cardLimit, cardLimitInfo, curCardCountP, curListHeader, curListTitle;
    curListHeader = objList.find('div.list-header');
    curListTitle = curListHeader.find('textarea.list-header-name').val();
    cardLimitInfo = pageRegex.CardLimit.exec(curListTitle);
    if (cardLimitInfo === null) {
      return false;
    }
    curCardCountP = curListHeader.find('p.list-header-num-cards');
    cardCount = pageRegex.CardCount.exec(curCardCountP.text())[0];
    cardLimit = pageRegex.Number.exec(cardLimitInfo[0])[0];
    if (cardCount > cardLimit) {
      return objList.css('background', '#903');
    } else if (cardCount === cardLimit) {
      return objList.css('background', '#c93');
    } else {
      return objList.css('background', '#e2e4e6');
    }
  };

  listFormatInit = function() {
    return $('div.list').each(function() {
      listTitleFormat($(this));
      return $(this).find('div.list-card').each(function() {
        return listCardFormat($(this));
      });
    });
  };

  imgSwitch_click = function() {
    var imgSwitch;
    if ($('#btnImgSwitch').length > 0) {
      return;
    }
    imgSwitch = $('<a id="btnImgSwitch" class="board-header-btn board-header-btn-org-name board-header-btn-without-icon"><span class="board-header-btn-text">隐藏/显示图片</span></a>');
    $('div.board-header').append(imgSwitch);
    return imgSwitch.click(function() {
      return $('div.list-card-cover').slideToggle();
    });
  };

  showCardNum = function() {
    return $('span.card-short-id').each(function() {
      var curCardNum;
      curCardNum = $.trim($(this).text());
      return $(this).text(curCardNum + ' ').show();
    });
  };

  init = function() {
    $('p.list-header-num-cards').show();
    showCardNum();
    listFormatInit();
    return imgSwitch_click();
  };

  $(function() {
    return setInterval((function() {
      return init();
    }), 1000);
  });

}).call(this);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址