标签 - JAVA
2021
XML基础
XML基础
= content.replace(/]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url content = content.replace(/
.*?<\/pre>/gi, '[代码]') // replace code
    content = content.replace(/.*?<\/code>/gi, '[代码]') // replace code      
    content = content.replace(/<[^>]+>/g, "") // remove html tag

    if (content.length > 150) {
      content = content.substring(0, 150) + '...'
    }
    return content
  },

  generateHtml: (array, ele) => {
    let result = ''

    if (array.length) {
      for (let i = 0; i < array.length; i++) {
        result += '
' if (true && array[i].avatar) { const imgAttr = 'src' result += `${array[i].nick}` } result += `
${array[i].content}
${array[i].nick} /
` } } else { result += '暂无评论' } ele.innerHTML = result window.lazyLoadInstance && window.lazyLoadInstance.update() window.pjax && window.pjax.refresh(ele) }, newestCommentInit: (name, getComment) => { const $dom = document.querySelector('#card-newest-comments .aside-list') if ($dom) { const data = btf.saveToLocal.get(name) if (data) { newestComments.generateHtml(JSON.parse(data), $dom) } else { getComment($dom) } } }, run: (name, getComment) => { newestComments.newestCommentInit(name, getComment) btf.addGlobalFn('pjaxComplete', () => newestComments.newestCommentInit(name, getComment), name) } }