import util from '../../common/util.js'
if (!window.less){
  util.loadJS('./lib/less.min.js').catch(e => {
    console.error('less.min.js is missing')
  })
}

var locals = window.locals || {}
locals['contentScript'] = {
  CatalogID: '9191',
  ContentType: 'Article',
  CopyType: '0',
  CopyCatalogID: '',
  TitleStyle: '',
  ShortTitleStyle: '',
  $ConfigProps: 'PrevContent=0__ZVING__NextContent=10333__ZVING__ContentWorkflowInstanceID=297__ZVING__CommentStartTime=2012-07-04&#32;16:33:33__ZVING__CKECommentFlag=N__ZVING__Staticize=N__ZVING__CommentEnable=Y__ZVING__CommentEndTime=',
  Status: '10',
  CommonColors: 'c00000,ff0000,ffc000,ffff00,92d050,00b050,00b0f0,0070c0,002060,7030a0',
  ListShowSubcatalogContent: 'N'
}

locals['articleEditor'] = {
  CatalogID: '9191',
  Format: '',
  InnerCode: '000022000008',
  Pages: '',
  StatusName: '流转中',
  HasEditPriv: 'true',
  ArticleUEEditorImportCSS: '',
  ContentID: '10334',
  ArticleImageWidth: '500',
  ArticleImageHeight: '500',
  ArticleLogoWidth: '120',
  ArticleLogoHeight: '120',
  UserLanguage: 'zh-cn',
  TopFlag: '0',
  Status: '10',
  User_ShowSubTitleAndShortTitle: 'N',
  User_CloseWindowAfterPublish: 'Y',
  defaultImageValue: '',
  AllowAudioType: 'mp3',
  $ConfigProps: 'PrevContent=0__ZVING__NextContent=10333__ZVING__ContentWorkflowInstanceID=300__ZVING__CKECommentFlag=Y__ZVING__CommentStartTime=2012-05-07 15:57:23__ZVING__CommentEndTime=__ZVING__'
}
var map = {}
map['Article.Common'] = '常用'
map['Article.Expanded'] = '扩展'
map['Article.Manipulate'] = '操作'
map['Article.Font'] = '字体'
map['Article.HeadOrParagraph'] = '标题/段落'
map['Article.Display'] = '排版'
map['Article.Insert'] = '插入'
map['Article.Tools'] = '工具'
map['Article.Paragraph'] = '段落'
map['Article.Surround'] = '输入/环绕方式'
map['Article.RowAndCell'] = '表格行与列'
map['Article.Cell'] = '单元格'
map['Contentcore.SetTop'] = '置顶'
map['Contentcore.NeedAddPriv'] = '需要拥有目标栏目的新建文档权限'
map['Contentcore.NeedContentEditPriv'] = '需要拥有目标栏目的编辑文档权限'
map['Article.CheckContentEmpty'] = '文章内容不能为空'
map['Article.CheckTitleEmpty'] = '文章标题不能为空'
map['Article.ConfirmBadWord'] = '内容中存在敏感词，继续保存吗？'
map['Common.Save'] = '保存'
map['Article.ReplaceBadWord'] = '替换保存'
map['Common.Cancel'] = '取消'
map['Article.Processing'] = '正在处理'
map['Comment.OfflineTimeLessReleaseTime'] = '下线时间不能小于发布时间'
map['Article.Version.History'] = '历史版本'
map['Article.CannotPreview'] = '文章尚未保存，不能预览'
map['Article.ConfirmCreateNew'] = '文章尚未保存，确认放弃当前文章并新建文章'
map['Common.BrowserTip'] = '发现弹出窗口被阻止，请更改浏览器设置，以便正常使用本功能!'
map['Article.ChangeCatalog.NoPriv'] = '没有修改此文章所属栏目的权限！'
map['Article.SelectViewCatalog'] = '选择所属栏目'
map['Article.SelectCatalogFirst'] = '请先选择文章所属栏目'
map['Article.NeedAddPriv'] = '需要拥有目标栏目的新建文档权限'
map['Article.LastSaveTime'] = '最后保存时间'
map['Article.AutoSave.Success'] = '文章自动保存成功'
map['Article.OnBeforeUnloadMessage'] = '当前还有未保存的内容，继续操作可能丢失内容。确定要继续此操作吗？'
map['Article.UploadLogoImage'] = '上传文章Logo图片'
map['Contentcore.ImageCutting.Title'] = '图片处理'
map['Contentcore.WaitingTip'] = '请稍等...'
map['Article.Search.Type.Published'] = '已发布'

map['Contentcore.Del.Confirm2'] = '是否仍然要执行删除操作？'
map['Common.New'] = '新建'
map['Common.PleaseSelectToDeleteRowFirst'] = '请先选择要删除的记录！'
map['Common.ConfirmDelete'] = '确认删除？'
map['Common.DeleteSuccess'] = '删除成功'
map['Contentcore.Catalog.Deleting'] = '正在删除'
map['Common.PleaseSelectRowFirst'] = '请先选择一条记录'
map['Comment.OfflineTimeLessReleaseTime'] = '下线时间不能小于发布时间'
map['Contentcore.WaitingTip'] = '请稍等...'
map['Contentcore.SetTop'] = '置顶'
map['Common.ExecuteSuccess'] = '操作成功'
map['Common.ExecuteFailed'] = '操作失败'
map['Contentcore.SortTip'] = '默认排序下才可能调整顺序，请先切换到默认排序。'
map['Contentcore.Sort'] = '排序'
map['Contentcore.SortWait'] = '正在调整内容顺序...'
map['Contentcore.SelectCatalog'] = '选择栏目'
map['Contentcore.selectcatalogsFirst'] = '请先选择栏目'
map['Common.Delete'] = '删除'
map['Contentcore.Publish'] = '发布'
map['Contentcore.Copy'] = '复制'
map['Contentcore.Catalog.Move'] = '转移'
map['Contentcore.WaitToPublish'] = '待发布'
map['Contentcore.Offline'] = '下线'
map['Contentcore.Recommend'] = '推荐'
map['Contentcore.CancelRecommend'] = '取消推荐'
map['Contentcore.SetHot'] = '设置热点'
map['Contentcore.CancelHot'] = '取消热点'
map['Contentcore.Block.SelectTemplate'] = '选择模板文件'
map['Contentcore.SelectSource'] = '选择来源'
map['Wordmanage.SelectTag'] = '选择tag词'
map['Contentcore.RelaContent'] = '相关内容'
map['Contentcore.ContentLog'] = '操作记录'
map['Contentcore.Endorse'] = '批注'
map['Contentcore.Block.BrowseArticle'] = '选择内容记录'
map['Contentcore.CannotLinkToSelf'] = '不能链接到自身！'
map['Contentcore.CannotLinkToCopyContent'] = '不能链接到原内容！'
map['Contentcore.ExternalURL'] = '外部地址'
map['Contentcore.Title.SiteNotice'] = '注意：当前站点下已经存在相同标题的记录'
map['Contentcore.Title.Notice'] = '注意：当前栏目下已有相同标题的记录'

const Lang = {}
Lang.get = key => {
  return map[key]
}

const article = {
  bodyFontFamily: 'inherit',
  sourceEditorFirst: false,
  // initialContent: contents[0], //初始化编辑器的内容
  wordCount: false, // 关闭字数统计
  minFrameHeight: 350, // 无内容时编辑器的原始高度
  initialFrameWidth: 690, // 初始化编辑器宽度,默认680
  initialFrameHeight: 400, // 初始化编辑器高度,默认400
  initialStyle: 'body{font-size:16px;line-height:1.7;}',
  elementPathEnabled: false, // 关闭elementPath
  autoFloatEnabled: false, // 是否保持toolbar的位置不动,默认true
  iframeCssUrlOuter: locals['articleEditor'].ArticleUEEditorImportCSS !== ''
    ? document.domain + locals['articleEditor'].ArticleUEEditorImportCSS
    : undefined, // 给编辑器内部引入一个css文件
  // catalogID: CatalogID,
  dataType: 'Article',
  dataID: locals['articleEditor'].ContentID,
  imageWidth: locals['articleEditor'].ArticleImageWidth,
  imageHeight: locals['articleEditor'].ArticleImageHeight,
  ArticleLogoWidth: locals['articleEditor'].ArticleLogoWidth,
  ArticleLogoHeight: locals['articleEditor'].ArticleLogoHeight,
  allowAudioType: locals['articleEditor'].AllowAudioType,
  selfCatalog: 'Y',
  lang: locals['articleEditor'].UserLanguage,
  // langPath:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+'lang/'+locals['articleEditor'].UserLanguage+'/'+locals['articleEditor'].UserLanguage+'.js',
  contextPath: window.CONTEXTPATH || '/',
  page: 1,
  toolbars: [
    ['undo', 'redo', 'fullscreen'],
    ['source', 'zcheckwords', 'selectall'],
    ['fontfamily', 'fontsize'],
    ['bold', 'italic', 'underline', 'forecolor', 'backcolor'],
    ['customstyle'],
    ['paragraph'],
    ['justifyleft', 'justifycenter', 'justifyright', 'justifyjustify'],
    ['autotypeset', 'indent'],
    ['link', 'unlink', 'zcomment', 'zimage', 'zvideo', 'zaudio', 'zfile'],
    ['zcontent', 'zcatalog', 'zvote', 'zatverdise', 'zimagegroup', 'zpagebreak', 'zresourceurl'],
    ['touppercase', 'tolowercase', 'strikethrough'],
    ['superscript', 'subscript', 'fontborder'],
    ['insertorderedlist', 'insertunorderedlist'],
    ['rowspacingtop', 'rowspacingbottom', 'lineheight'],
    ['removeformat', 'formatmatch'],
    ['cleardoc', 'searchreplace'],
    ['directionalityltr', 'directionalityrtl', 'zwritingmode', 'zbodyfontfamily'],
    ['imagenone', 'imageleft', 'imageright', 'imagecenter'],
    ['date', 'time', 'map', 'gmap', 'zweiboshow'],
    ['emotion', 'insertframe', 'spechars', 'anchor', 'horizontal'],
    ['inserttable', 'deletetable', 'insertparagraphbeforetable'],
    ['insertrow', 'deleterow', 'insertcol', 'deletecol'],
    ['mergecells', 'mergeright', 'mergedown'],
    ['splittocells', 'splittorows', 'splittocols']
  ],
  renderToolbarBoxHtml: function () {
    // 重写ui.Editor的renderToolbarBoxHtml方法
    return (
      '<div class="zving-toolbarTab">' +
      '<div class="zving-toolbarTab-item item1 current">' +
      Lang.get('Article.Common') +
      '</div>' +
      '<div class="zving-toolbarTab-item item2">' +
      Lang.get('Article.Expanded') +
      '</div>' +
      '</div>' +
      '<div class="zving-toolbarCon">' +
      '<div class="zving-toolbarCon-item" style="display:block;">' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[0].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[1].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Manipulate') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[2].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[3].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Font') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[4].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[5].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.HeadOrParagraph') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[6].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[7].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Display') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[8].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[9].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Insert') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[14].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[15].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Tools') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '</div>' +
      '<div class="zving-toolbarCon-item">' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[10].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[11].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Font') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[12].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[13].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Paragraph') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[16].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[17].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Surround') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[18].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[19].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Insert') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[20].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[21].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.RowAndCell') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '<div class="zving-toolbarCon-item-separate">' +
      '<table border="0" cellpadding="2" cellspacing="0">' +
      '<tr><td>' +
      this.toolbars[22].renderHtml() +
      '</td></tr>' +
      '<tr><td>' +
      this.toolbars[23].renderHtml() +
      '</td></tr>' +
      '<tr><td class="zving-toolbarCon-item-separate-label">' +
      Lang.get('Article.Cell') +
      '</td></tr>' +
      '</table>' +
      '</div>' +
      '</div>' +
      '</div>'
    )
  },
  /**
   * 设置风格颜色
  **/
  parseObject (obj, bgcolor, color) {
    if (this.isGreyColor(bgcolor)) {
      return false
    }
    let that = this
    obj.find('*').each(function () {
      if (this.nodeName === 'HR' || this.nodeName === 'hr') {
        $(this).css('border-color', bgcolor)
        return
      }
      if (this.nodeName === '') {
        return
      }
      if ($(this).data('ct') === 'fix') {
        return
      }
      let bgimg = $(this).css('backgroundImage')
      if (bgimg.substring(0, 24) === '-webkit-linear-gradient(') {
        let colors
        let type
        if (bgimg.substring(0, 30) === '-webkit-linear-gradient(left, ') {
          type = 'left'
          colors = bgimg.substring(30, bgimg.length - 1)
        } else if (bgimg.substring(0, 29) === '-webkit-linear-gradient(top, ') {
          type = 'top'
          colors = bgimg.substring(29, bgimg.length - 1)
        } else if (bgimg.substring(0, 31) === '-webkit-linear-gradient(right, ') {
          type = 'right'
          colors = bgimg.substring(31, bgimg.length - 1)
        } else if (bgimg.substring(0, 32) === '-webkit-linear-gradient(bottom, ') {
          type = 'bottom'
          colors = bgimg.substring(32, bgimg.length - 1)
        }
        if (colors) {
          let colorArr = colors.split('),')
          let textColor, gradientColor, mainColor
          if (that.isLightenColor(bgcolor)) {
            textColor = that.getColor(that.rgb2hex(bgcolor), 'darken', '50%')
            textColor = that.getColor(that.rgb2hex(textColor), 'saturate', '30%')
            gradientColor = that.getColor(that.rgb2hex(bgcolor), 'darken', '10%')
            mainColor = that.getColor(that.rgb2hex(bgcolor), 'saturate', '20%')
          } else {
            textColor = '#FFFFFF'
            that.getColor(that.rgb2hex(bgcolor), 'lighten', '50%')
            gradientColor = that.getColor(that.rgb2hex(bgcolor), 'lighten', '10%')
            mainColor = that.getColor(that.rgb2hex(bgcolor), 'lighten', '5%')
            mainColor = that.getColor(that.rgb2hex(mainColor), 'desaturate', '10%')
            mainColor = that.getColor(that.rgb2hex(mainColor), 'fadein', '20%')
          }
          if (colorArr.length === 3) {
            $(this).css(
              'backgroundImage',
              '-webkit-linear-gradient(' + type + ', ' + mainColor + ', ' + gradientColor + ', ' + mainColor + ')'
            )
            $(this).css('color', textColor)
          } else if (colorArr.length === 2) {
            $(this).css('backgroundImage', '-webkit-linear-gradient(' + type + ', ' + mainColor + ', ' + gradientColor + ')')
            $(this).css('color', textColor)
          }
        }
      }
      let persent = $(this).data('clessp') ? $(this).data('clessp') : '50%'
      let hasSetBgColor = false
      let bgC = $(this).get(0).style.backgroundColor
      if (!bgC || bgC === 'initial' || bgC === 'transparent' || bgC === '') {
        let fc = $(this).get(0).style.color
        if (fc && fc !== '' && fc !== 'inherit' && !that.isGreyColor(fc)) {
          let textColor
          if (that.isLightenColor(bgcolor)) {
            textColor = that.getColor(that.rgb2hex(bgcolor), 'darken', persent)
            $(this).css('color', textColor)
          } else {
            $(this).css('color', bgcolor)
          }
        }
      } else {
        if ($(this).data('bgless')) {
          let bgpersent = $(this).data('bglessp') ? $(this).data('bglessp') : '30%'
          let bgColor
          if ($(this).data('bgless') === 'true' || $(this).data('bgless') === true) {
            if (that.isLightenColor(bgcolor)) {
              bgColor = that.getColor(that.rgb2hex(bgcolor), 'darken', bgpersent)
              bgColor = that.getColor(that.rgb2hex(bgColor), 'saturate', '20%')
            } else {
              bgColor = that.getColor(that.rgb2hex(bgcolor), 'lighten', bgpersent)
            }
          } else {
            bgColor = that.getColor(that.rgb2hex(bgcolor), $(this).data('bgless'), bgpersent)
          }
          let textColor
          if (that.isLightenColor(bgColor)) {
            textColor = that.getColor(that.rgb2hex(bgColor), 'darken', persent)
          } else {
            textColor = color
          }
          hasSetBgColor = true
          $(this).css('backgroundColor', bgColor)
          $(this).css('color', textColor)
        } else if (!that.isGreyColor(bgC)) {
          hasSetBgColor = true
          $(this).css('backgroundColor', bgcolor)
          let textColor
          if (that.isLightenColor(bgcolor)) {
            textColor = that.getColor(that.rgb2hex(bgcolor), 'darken', persent)
          } else {
            textColor = color
          }
          $(this).css('color', textColor)
        } else {
          let fc = $(this).get(0).style.color
          if (fc && fc !== '' && fc !== 'inherit' && !that.isGreyColor(fc)) {
            $(this).css('color', bgcolor)
          }
        }
      }
      if ($(this).data('bcless') || hasSetBgColor) {
        let bcColor
        if (that.isLightenColor(bgcolor) || $(this).data('bcless') === 'darken') {
          let persent = $(this).data('bclessp') ? $(this).data('bclessp') : '5%'
          bcColor = that.getColor(that.rgb2hex(bgcolor), 'darken', persent)
          bcColor = that.getColor(that.rgb2hex(bcColor), 'saturate', '30%')
        } else {
          let persent = $(this).data('bclessp') ? $(this).data('bclessp') : '20%'
          bcColor = that.getColor(that.rgb2hex(bgcolor), 'lighten', persent)
          bcColor = that.getColor(that.rgb2hex(bcColor), 'desaturate', '20%')
          bcColor = that.getColor(that.rgb2hex(bcColor), 'fadein', '20%')
        }
        if (this.style.borderBottomColor || this.style.borderTopColor || this.style.borderLeftColor || this.style.borderRightColor) {
          this.style.borderBottomColor = bcColor
          this.style.borderTopColor = bcColor
          this.style.borderLeftColor = bcColor
          this.style.borderRightColor = bcColor
        } else {
          this.style.borderColor = bcColor
        }
      } else {
        if (this.style.borderBottomColor || this.style.borderTopColor || this.style.borderLeftColor || this.style.borderRightColor) {
          that.setColor(this, 'borderBottomColor', bgcolor)
          that.setColor(this, 'borderTopColor', bgcolor)
          that.setColor(this, 'borderLeftColor', bgcolor)
          that.setColor(this, 'borderRightColor', bgcolor)
        } else {
          that.setColor(this, 'borderColor', bgcolor)
        }
      }
    })
    obj.find('*').each(function () {
      let fc = $(this).css('color')
      $(this).find('*').each(function () {
        let nfc = $(this).css('color')
        if (nfc === fc) {
          $(this).css('color', 'inherit')
        }
      })
    })
    return obj
  },
  getColor (color, type, num) {
    let str = ''
    window.less.render('p{color:' + type + '(' + color + ',' + num + ')}', (err, output) => {
      if (err) {
        return console.error(err)
      }
      str = output.css
      str = str.replace(/\n/g, '').replace(/ /g, '').replace('p{color:', '').replace(';}', '')
    })
    return str
  },
  setColor (obj, colorType, color) {
    let c = $(obj).css(colorType)
    if (c === 'transparent') {
    } else {
      if (!this.isGreyColor(c)) {
        $(obj).css(colorType, color)
      }
    }
  },
  rgb2hex (color) {
    let rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i)
    return rgb && rgb.length === 4
      ? '#' +
          ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) +
          ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) +
          ('0' + parseInt(rgb[3], 10).toString(16)).slice(-2)
      : color
  },
  isLightenColor (color) {
    let c = this.rgb2hex(color)
    let r = '' + c.substring(1, 3)
    let g = '' + c.substring(3, 5)
    let b = '' + c.substring(5, 7)
    if (r > 'C0' && g > 'C0' && b > 'C0') {
      return true
    } else {
      return false
    }
  },
  isGreyColor (color) {
    let c = this.rgb2hex(color)
    let r = '' + c.substring(1, 3)
    let g = '' + c.substring(3, 5)
    let b = '' + c.substring(5, 7)
    if (r === g && g === b) {
      return true
    } else {
      return false
    }
  }
}

export default article
