aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/dingtalk/webview.js
blob: 68de1b62856285de1cf3133f190c31def93ad517 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const _path = _interopRequireDefault(require('path'));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = (Ferdi) => {
  let checkIsRun = false;
  checkHeightAction = () => {
    checkIsRun = true;
    let checkHeight = setInterval(() => {
      let menuPanel = document.getElementById('menu-pannel')
      if (!menuPanel) {
        return
      }
      menuPanel.parentElement.setAttribute('style', 'height:' + (window.outerHeight - 60) + 'px');
      clearInterval(checkHeight);
      checkIsRun = false
    }, 1000)
  }

  checkHeightAction();

  window.addEventListener('resize', () => {
    if (!checkIsRun) {
      checkHeightAction();
    }
  });

  const getMessages = function getMessages() {
    const x = document.querySelectorAll('.unread-num em.ng-binding')
    Ferdi.setBadge(x.length > 0 ? x[0].innerHTML : 0);
  };

  Ferdi.loop(getMessages);

  Ferdi.injectCSS(_path.default.join(__dirname, 'style.css'));
};