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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="styles/icofont.css">
<link rel="icon" sizes="32x32" href="images/wc-icon-32.png">
<link rel="icon" sizes="48x48" href="images/wc-icon-48.png">
<link rel="icon" sizes="96x96" href="images/wc-icon-96.png">
<link rel="icon" sizes="144x144" href="images/wc-icon-144.png">
<link rel="icon" sizes="288x288" href="images/wc-icon-288.png">
<link rel="stylesheet" type="text/css" href="styles/home/base.css">
<link rel="stylesheet" type="text/css" href="styles/home/desktop.css">
<link rel="stylesheet" type="text/css" href="styles/home/mobile.css">
<link rel="stylesheet" type="text/css" href="styles/input.css">
<link id="theme" rel="stylesheet" type="text/css" href="styles/themes/colors-base.css">
<script src="scripts/gui/input.js"></script>
<script src="scripts/cookie.js"></script>
<script src="scripts/theme.js"></script>
<title>WebCards</title>
</head>
<body>
<div class="content">
<p style="font-size: 30px; font-weight: normal;">Web<span style="color: #0084ff; font-weight: bold;">Cards</span></p>
<div id="options">
</div>
<button id="conn" onclick="connect()">Connect</button>
<div id="themes">
</div>
<div>
<button onclick="addTheme()" style="margin-right: 2px;">Add Theme</button>
<button onclick="remTheme()" style="margin-left: 2px;">Remove Theme</button>
</div>
<div id="prev" class="prev">
</div>
<div style="color: red;">This site uses cookies to store themes and previous servers. That is all.</div>
<div>You may choose to submit user generated data over this site (Such as player name or text chat). This site stores none of that data. Please check with the server owner for privacy policy and/or any legal issue.</div>
<a style="border: none; padding: 0; display: contents; margin: 0;" href="http://vanilla-js.com/"><img style="margin-top: 10px;" src="images/vanilla.png"></a>
</div>
<script>
var prev = Cookies.getCookie("prevAddr");
var prevEl = document.getElementById("prev");
function hasAddr(url) {
let urls = prev.split(",");
for(u of urls)
{
if(u === url)
return true;
}
return false;
}
function addAddr(url) {
if(hasAddr(url))
return;
if(prev != "")
prev = prev + "," + url;
else
prev = url;
Cookies.setYearCookie("prevAddr", prev);
}
function delAddr(el, btn) {
let url = el.innerText;
let urls = prev.split(",");
urls.splice(urls.indexOf(url), 1);
Cookies.setCookie("prevAddr", urls.join());
el.remove();
btn.remove();
prev = Cookies.getCookie("prevAddr");
}
let urls = prev.split(",");
for(let i in urls) {
if(urls[i] == "")
continue;
let a = document.createElement("a");
a.innerText = urls[i];
a.href = "client.html?s=" + urls[i] + "&g=-1";
let b = document.createElement("button");
b.innerText = "X";
b.onclick = delAddr.bind(null, a, b);
prevEl.appendChild(a);
prevEl.append(b);
}
</script>
<script>
const Options = [
{
type: "select",
args: [["wss://", "ws://"], ["WSS", "WS"]],
title: "Protocol"
},
{
type: "text",
args: ["localhost", ""],
title: "Server URL"
},
{
type: "number",
args: [4040],
title: "Server Port"
}
];
const ThemeOptions = [
{
type: "text",
args: ["", ""],
title: "Theme Name"
},
{
type: "text",
args: ["", ""],
title: "Theme URL"
}
];
function changeTheme(e) {
Theme.set(e.target.getValue());
}
var optionsEL = document.getElementById("options");
var options = new Settings(Options);
options.putSettings(optionsEL);
var themeEL = document.getElementById("themes");
var themeOpt = new Settings(ThemeOptions);
themeOpt.putSettings(themeEL);
var themeSelector = MakeInput.selectInput(...BASE_THEMES);
themeEL.appendChild(MakeInput.titleWrap(themeSelector, "Select Theme"));
themeSelector.addEventListener("change", changeTheme);
for(let i = 0; i < Theme.UserThemes[0].length; i++) {
themeSelector.addOption(Theme.UserThemes[0][i], Theme.UserThemes[1][i]);
}
function addTheme() {
let parts = themeOpt.getSettings();
themeSelector.setIndex(themeSelector.addOption(parts[0], parts[1]));
changeTheme({target: themeSelector});
Theme.addUserTheme(parts[0], parts[1]);
}
function remTheme() {
var idx = themeSelector.getIndex();
if (idx < BASE_THEMES[0].length)
return;
themeSelector.removeOption(idx);
themeSelector.setIndex(idx - 1);
changeTheme({target: themeSelector});
Theme.removeUserTheme(idx - BASE_THEMES[0].length);
}
function connect() {
let serverParts = options.getSettings();
let concat = serverParts[0] + serverParts[1] + ":" + serverParts[2];
addAddr(concat);
//c.setAttribute("href", url);
window.location = "client.html?s=" + concat + "&g=-1";
}
</script>
</body>
</html>
|