Coder Social home page Coder Social logo

不支持显示特殊符号 about uptime-status HOT 5 CLOSED

yb avatar yb commented on July 27, 2024
不支持显示特殊符号

from uptime-status.

Comments (5)

yb avatar yb commented on July 27, 2024 1

HTML 实体符号挺多的,靠 replace 无法从根本解决问题,在最新的 v1.4.0 更新中引入了 htmr 进行转义,已解决这个问题;
谢谢二位提出的 issue!

from uptime-status.

TomsProject avatar TomsProject commented on July 27, 2024

貌似把 uptimerobot.js 的 monitor.friendly_name 内容替换一下就可以了(Chrome 84 可以,其它浏览器没试)

    let name = monitor.friendly_name.replace(/'/gi, "'");
    name = name.replace(/(/gi, "(");
    name = name.replace(/)/gi, ")");
    name = name.replace(/=/gi, "=");
    name = name.replace(/[/gi, "[");
    name = name.replace(/]/gi, "]");
    name = name.replace(/"/gi, '"');
    name = name.replace(/&lt;/gi, "<");
    name = name.replace(/&gt;/gi, ">");

    apps.push({
      id: monitor.id,
      name: name,
      url: monitor.url,
      status: status,
      average: average,
      daily: daily,
      total: total,
    });

// 烂代码,大佬勿喷

from uptime-status.

renbaoshuo avatar renbaoshuo commented on July 27, 2024

我觉得封装成函数更好一些

function convert(str){ 
  str = str.replace(/(\\u)(\w{1,4})/gi, function($0){ 
      return (String.fromCharCode(parseInt((escape($0).replace(/(%5Cu)(\w{1,4})/g,"$2")),16))); 
  }).replace(/(&#x)(\w{1,4});/gi, function($0){ 
      return String.fromCharCode(parseInt(escape($0).replace(/(%26%23x)(\w{1,4})(%3B)/g,"$2"),16)); 
  }).replace(/(&#)(\d{1,6});/gi, function($0){ 
      return String.fromCharCode(parseInt(escape($0).replace(/(%26%23)(\d{1,6})(%3B)/g,"$2"))); 
  }); 
  return str; 
}

方便调用

from uptime-status.

renbaoshuo avatar renbaoshuo commented on July 27, 2024

HTML 实体符号挺多的,靠 replace 无法从根本解决问题,在最新的 v1.4.0 更新中引入了 htmr 进行转义,已解决这个问题;
谢谢二位提出的 issue!

@yb 另外,我稍改了一下页面样式,适配了我所用的主题,页面链接:https://renbaoshuo.github.io/status/ ,且页面下方已经注明版权,请问可以吗?

a1I7iq.png

from uptime-status.

yb avatar yb commented on July 27, 2024

@yb 另外,我稍改了一下页面样式,适配了我所用的主题,页面链接:https://renbaoshuo.github.io/status/ ,且页面下方已经注明版权,请问可以吗?

of course,欢迎使用

from uptime-status.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.