-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl_builder.html
170 lines (157 loc) · 7.73 KB
/
url_builder.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liquipedia to iCal URL Builder</title>
<meta name="description" content="Create a custom iCal URL for Liquipedia matches with optional filters for competitions and teams.">
<meta name="keywords" content="Liquipedia, iCal, calendar, esports, matches">
<meta name="author" content="snwfdhmp">
<meta property="og:title" content="Liquipedia to iCal URL Builder">
<meta property="og:description" content="Create a custom iCal URL for Liquipedia matches with optional filters for competitions and teams.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://ics.snwfdhmp.com/">
<meta property="og:image" content="https://ics.snwfdhmp.com/og-image.jpg">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Liquipedia to iCal URL Builder">
<meta name="twitter:description" content="Create a custom iCal URL for Liquipedia matches with optional filters for competitions and teams.">
<meta name="twitter:image" content="https://ics.snwfdhmp.com/twitter-image.jpg">
<link rel="canonical" href="https://ics.snwfdhmp.com/">
<script>
function buildUrl() {
const baseUrl = "https://ics.snwfdhmp.com/matches.ics";
const urlRadios = document.getElementsByName("url");
let url = "";
for (const radio of urlRadios) {
if (radio.checked) {
url = radio.value;
break;
}
}
if (url === "custom") {
url = document.getElementById("custom_url").value;
}
const competitionRegex = document.getElementById("competition_regex").value;
const teamsRegex = document.getElementById("teams_regex").value;
const ignoreTbd = document.getElementById("ignore_tbd").checked;
const conditionIsOr = document.getElementById("condition_is_or").checked;
const teamsRegexUseFullnames = document.getElementById("teams_regex_use_fullnames").checked;
let params = new URLSearchParams();
params.append("url", url);
if (competitionRegex) params.append("competition_regex", competitionRegex);
if (teamsRegex) params.append("teams_regex", teamsRegex);
if (ignoreTbd) params.append("ignore_tbd", "true");
if (conditionIsOr) params.append("condition_is_or", "true");
if (teamsRegexUseFullnames) params.append("teams_regex_use_fullnames", "true");
const finalUrl = `${baseUrl}?${params.toString()}`;
document.getElementById("result").href = finalUrl;
document.getElementById("result").textContent = finalUrl;
}
function toggleCustomUrl() {
const customUrlInput = document.getElementById("custom_url");
customUrlInput.disabled = !document.getElementById("custom").checked;
if (document.getElementById("custom").checked) {
customUrlInput.focus();
}
}
// Add event listeners to all form inputs
document.addEventListener('DOMContentLoaded', function() {
const inputs = document.querySelectorAll('input');
inputs.forEach(input => {
input.addEventListener('input', buildUrl);
});
const urlRadios = document.getElementsByName("url");
urlRadios.forEach(radio => {
radio.addEventListener('change', toggleCustomUrl);
});
// Add click event listener to the result link
document.getElementById("result").addEventListener('click', function(e) {
e.preventDefault();
const url = this.href;
navigator.clipboard.writeText(url).then(() => {
alert('URL copied to clipboard!');
}).catch(err => {
console.error('Failed to copy URL: ', err);
});
});
toggleCustomUrl();
buildUrl();
});
</script>
</head>
<style>
body {
background-color: #F9F9F9;
font-family: "Arial";
}
.container {
width: 48em;
margin: 2em auto 0;
background-color: #FFF;
padding: 2em;
border-radius: 32px;
position: relative;
}
.top-left {
position: fixed;
top: 0;
width: 100%;
margin: 0 auto;
text-align: center;
}
.top-left a {
font-size: 0.8em;
color: #336;
text-decoration: underline;
cursor: pointer;
}
.top-left a:hover {
color: #33F;
cursor: pointer;
}
</style>
<body>
<div class="top-left">
<a href="https://github.com/snwfdhmp/liquipedia-to-ical" target="_blank">github.com/snwfdhmp/liquipedia-to-ical</a>
</div>
<div class="container">
<h1>Configure your iCal URL</h1>
<form>
<p><b>Mandatory parameters</b></p>
<label>Game:</label><br>
<input type="radio" id="rocket_league" name="url" value="https://liquipedia.net/rocketleague/Liquipedia:Matches" checked>
<label for="rocket_league">Rocket League</label><br>
<input type="radio" id="league_of_legends" name="url" value="https://liquipedia.net/leagueoflegends/Liquipedia:Matches">
<label for="league_of_legends">League of Legends</label><br>
<input type="radio" id="trackmania" name="url" value="https://liquipedia.net/trackmania/Liquipedia:Matches">
<label for="trackmania">Trackmania</label><br>
<input type="radio" id="valorant" name="url" value="https://liquipedia.net/valorant/Liquipedia:Matches">
<label for="valorant">Valorant</label><br>
<input type="radio" id="cs" name="url" value="https://liquipedia.net/counterstrike/Liquipedia:Matches">
<label for="cs">Counter-Strike</label><br><input type="radio" id="cs" name="url" value="https://liquipedia.net/starcraft2/Liquipedia:Upcoming_and_ongoing_matches">
<label for="cs">Starcraft II</label><br>
<input type="radio" id="overwatch" name="url"
value="https://liquipedia.net/overwatch/Liquipedia:Upcoming_and_ongoing_matches">
<label for="overwatch">Overwatch</label><br>
<input type="radio" id="custom" name="url" value="custom">
<label for="custom">Custom URL:</label>
<input type="url" id="custom_url" placeholder="Enter custom Liquipedia URL" size="64" disabled><br><br>
<p><b>Optional parameters</b></p>
<label for="competition_regex">Competition name should match this:</label>
<input type="text" id="competition_regex" placeholder="eg: Worlds" size="16"><br><br>
<label for="teams_regex">One of the teams name should match this:</label>
<input type="text" id="teams_regex" placeholder="eg: ^(KC|G2)$" size="16"><br><br>
<input type="checkbox" id="teams_regex_use_fullnames">
<label for="teams_regex_use_fullnames">Use team's fullnames for search (ie. "Karmine Corp" instead of "KC")</label><br><br>
<input type="checkbox" id="condition_is_or">
<label for="condition_is_or">Matches only need to validate one of "Competition" or "Teams" regex to be added</label><br><br>
<input type="checkbox" id="ignore_tbd">
<label for="ignore_tbd">Ignore a match if both teams are "To Be Defined"</label><br><br>
</form>
<h2>Your iCal URL:</h2>
<a id="result" href="#" target="_blank" style="word-break: break-all;
white-space: pre-wrap; display: inline-block; max-width: 100%;"></a>
<p><span style="font-size: 0.8em;">(click to copy)</span></p>
</div>
</body>
</html>