代码拉取完成,页面将自动刷新
function $(id) {
return document.getElementById(id);
}
$("box").style.height = (window.innerHeight-20) + "px";
var input = $("input");
var output = $("output");
var from = $("from");
var to = $("to");
var num = $("num");
var usage = "Output panel<br><p>Introduction:</p>" +
"<ul>" +
"<li>[Repalce]: The characters of [from] from Input panel will be replaced to [to] and show in this area;</li><br>" +
"<li>[Clear]: First click——Clear Output panel, Second click——Clear Input panel;(if Output panel is empty, it will clear Input panel directly)</li><br>" +
"<li>[InputNumber]: Show the content length of Input and Output;</li><br>" +
"<li>[Swap I/O]: Swap the content of Input and Output;</li><br>" +
"<li>[StripHTML]: Wipe HTML tags of Input and show in this area;</li><br>" +
"<li>use <br> to go to newline</li><br>" +
"</ul>";
output.innerHTML = usage;
function rep() {
output.innerHTML = input.value.replace(new RegExp(from.value, 'g'), to.value);
}
function reverse() {
var buf = "";
if (input.value === "") {
buf = usage;
} else {
buf = input.value;
}
if (output.innerHTML !== usage) {
input.value = output.innerHTML;
} else {
input.value = "";
}
output.innerHTML = buf;
}
function wipe() {
if (output.innerHTML !== "" && output.innerHTML !== usage) {
output.innerHTML = usage;
} else if (input.value !== "") {
input.value = "";
}
}
function stripHTML() {
output.innerHTML = strip(input.value);
}
function showNum() {
num.innerHTML = countChineseCharacters(input) + " Input:" + input.value.length + " Output:" + output.innerText.length;
}
function strip(html) {
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
}
function countChineseCharacters(input) {
var words = input.value;
var W = {};
var iNumWords = 0;
var sNumWords = 0;
var sTotal = 0;
var iTotal = 0;
var eTotal = 0;
var iNum = 0;
var c;
for (i = 0; i < words.length; i++) {
c = words.charAt(i);
if (c.match(/[\u4e00-\u9fa5]/)) {
if (isNaN(W[c])) {
iNumWords++;
W[c] = 1;
}
iTotal++;
}
}
for (i = 0; i < words.length; i++) {
c = words.charAt(i);
if (c.match(/[^\x00-\xff]/)) {
if (isNaN(W[c])) {
sNumWords++;
}
sTotal++;
} else {
eTotal++;
}
if (c.match(/[0-9]/)) {
iNum++;
}
}
return 'Ch:' + iTotal + ' En:' + eTotal + ' Num:' + iNum + ' Ch+Pun:' + sTotal + ' Ch+Num:' + (iTotal + iNum);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。