back to es5
This commit is contained in:
parent
ec60742c5d
commit
775a12a69c
@ -61,7 +61,7 @@ editor_table_wrapper = function (editor) {
|
|||||||
var rule = tokenlist.join("-");
|
var rule = tokenlist.join("-");
|
||||||
tokenlist.pop();
|
tokenlist.pop();
|
||||||
var self = tokenlist.join("-");
|
var self = tokenlist.join("-");
|
||||||
var status = tokenPool.check(rule);
|
var status = !!tokenPool[rule];
|
||||||
return /* html */`<tr data-gap="${rule}" data-field="${self}">
|
return /* html */`<tr data-gap="${rule}" data-field="${self}">
|
||||||
<td>----</td>
|
<td>----</td>
|
||||||
<td>----</td>
|
<td>----</td>
|
||||||
@ -359,35 +359,16 @@ editor_table_wrapper = function (editor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenPool = new class {
|
var tokenPool = {};
|
||||||
|
var tokenstyle = document.createElement("style");
|
||||||
|
document.body.appendChild(tokenstyle);
|
||||||
|
|
||||||
constructor() {
|
tokenPoolRender = function() {
|
||||||
this.pool = new Set();
|
var content = "";
|
||||||
this.style = document.createElement("style");
|
Object.keys(tokenPool).forEach(function(k) {
|
||||||
document.body.appendChild(this.style);
|
content += /* CSS */`[data-field|=${k}]{ display: none }`;
|
||||||
}
|
})
|
||||||
|
tokenstyle.innerHTML = content;
|
||||||
add(token) {
|
|
||||||
this.pool.add(token);
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
remove(token) {
|
|
||||||
this.pool.delete(token);
|
|
||||||
this.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
var content = "";
|
|
||||||
this.pool.forEach((k) => {
|
|
||||||
content += /* CSS */`[data-field|=${k}]{ display: none }`;
|
|
||||||
})
|
|
||||||
this.style.innerHTML = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
check(token) {
|
|
||||||
return this.pool.has(token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,12 +377,13 @@ editor_table_wrapper = function (editor) {
|
|||||||
editor_table.prototype.onFoldBtnClick = function (button) {
|
editor_table.prototype.onFoldBtnClick = function (button) {
|
||||||
var tr = button.parentNode.parentNode;
|
var tr = button.parentNode.parentNode;
|
||||||
if (button.dataset.fold == "true") {
|
if (button.dataset.fold == "true") {
|
||||||
tokenPool.remove(tr.dataset.gap);
|
delete tokenPool[tr.dataset.gap];
|
||||||
|
tokenPoolRender();
|
||||||
button.dataset.fold = "false";
|
button.dataset.fold = "false";
|
||||||
button.innerText = "折叠";
|
button.innerText = "折叠";
|
||||||
} else {
|
} else {
|
||||||
var style = document.createElement("style");
|
tokenPool[tr.dataset.gap] = true;
|
||||||
tokenPool.add(tr.dataset.gap);
|
tokenPoolRender();
|
||||||
button.dataset.fold = "true";
|
button.dataset.fold = "true";
|
||||||
button.innerText = "展开";
|
button.innerText = "展开";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user