MCPcopy Index your code
hub / github.com/hoothin/UserScripts / init

Method init

Pagetual/pagetual.user.js:9857–9902  ·  view source on GitHub ↗
(ruleUrl)

Source from the content-addressed store, hash-verified

9855 configCon.appendChild(ruleBarInsertPos);
9856 class Rulebar {
9857 init(ruleUrl) {
9858 let id = ruleUrl.id;
9859 this.ruleUrl = ruleUrl;
9860 this.item = document.createElement("p");
9861 this.item.dataset.id = id;
9862 let url = document.createElement("a");
9863 url.href = ruleUrl.url;
9864 setHTML(url, ruleUrl.url);
9865 url.title = ruleUrl.url;
9866 let up = document.createElement("span");
9867 setHTML(up, "↑ ");
9868 up.title = i18n("sortTitle");
9869 let down = document.createElement("span");
9870 setHTML(down, "↓ ");
9871 down.title = i18n("sortTitle");
9872 let del = document.createElement("span");
9873 setHTML(del, "× ");
9874 up.onclick = e => {
9875 this.moveUp();
9876 };
9877 down.onclick = e => {
9878 this.moveDown();
9879 };
9880 del.onclick = e => {
9881 this.del();
9882 };
9883 this.item.appendChild(up);
9884 this.item.appendChild(down);
9885 this.item.appendChild(del);
9886 this.item.appendChild(url);
9887 if (ruleParser.rules) {
9888 url.style.maxWidth = "calc(100% - 150px)";
9889 url.style.overflow = "hidden";
9890 url.style.display = "inline-block";
9891 url.style.textOverflow = "ellipsis";
9892 url.style.verticalAlign = "bottom";
9893 url.style.whiteSpace = "nowrap";
9894 let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == id ? 1 : 0), 0);
9895 let idSpan = document.createElement("span");
9896 idSpan.style.float = "right";
9897 setHTML(idSpan, `[rules: ${rulesLength}]`);
9898 this.item.appendChild(idSpan);
9899 this.idSpan = idSpan;
9900 }
9901 configCon.insertBefore(this.item, ruleBarInsertPos);
9902 }
9903 updateNum() {
9904 if (ruleParser.rules) {
9905 let rulesLength = ruleParser.rules.reduce((acc, cur) => acc + (cur.from == this.item.dataset.id ? 1 : 0), 0);

Callers 1

initConfigFunction · 0.95

Calls 5

moveUpMethod · 0.95
moveDownMethod · 0.95
delMethod · 0.95
setHTMLFunction · 0.70
i18nFunction · 0.70

Tested by

no test coverage detected