-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.js
121 lines (102 loc) · 2.2 KB
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"use strict";
const tabNames = []; var ifMakePlug = true;
const plug =
{
info: { count: 0 },
infoIni : function(name, ver, author, desc, link)
{
this.info[name] = {};
this.info[name].name = name;
this.info[name].ver = ver;
this.info[name].author = author;
this.info[name].desc = desc;
this.info[name].link = link;
this.info[name].id = this.info.count;
this.info.count++;
},
addButton: (tab, name, func, title) =>
{
if (tab === undefined)
{
return;
}
const button = document.createElement("button");
if (ifMakePlug)
{
button.className = "btnPlug";
}
if (typeof func === "string")
{
if (func.startsWith("menu:"))
{
button.onclick = () => changeMenu(func.slice(5));
}
}
else if (typeof func === "function")
{
button.onclick = () => func();
}
if (title !== undefined)
{
button.title = title;
}
button.appendChild(document.createTextNode(name));
const ele = window[tab.startsWith("menu") ? tab : "tab" + tab];
if (ele !== undefined)
{
ele.appendChild(button);
}
else
{
console.warn(`TILA Plugin: Tab "${tab}" does not exist. Create tab before adding buttons.`);
}
return button.id;
},
addTab: (name, title) =>
{
if (!tabNames.includes(name))
{
const button = document.createElement("button");
const div = document.createElement("div");
button.className = "btnTab";
button.onclick = () => tabSwitch(name);
if (ifMakePlug)
{
button.classList.add("btnPlug");
}
if (title !== undefined)
{
button.title = title;
}
div.id = "tab" + name;
div.style.display = "none";
tabNames.push(name);
button.appendChild(document.createTextNode(name));
tabs.appendChild(button);
topBar.appendChild(div);
return div.id;
}
else
{
console.warn(`TILA Plugin: Tab "${name}" already exists.`);
}
},
addMenu: name =>
{
if (menu[name] === undefined)
{
const div = document.createElement("div");
div.id = "menu" + name;
div.style.display = "none";
masterMenu.appendChild(div);
menu[name] = div;
menu[name].plugin = true;
return div.id;
}
else
{
console.warn(`TILA Plugin: Menu "${name}" already exists.`);
}
}
};
// lemocha - lemocha7.github.io