-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
333 lines (301 loc) · 12.7 KB
/
index.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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!DOCTYPE html>
<html lang="en">
<head>
<title>MTG Deck Showcaser</title>
<meta charset="UTF-8">
<meta name="description" content="An easy to use, login-free, deck sharing website.">
<meta property="og:title" content="MTG Deck Showcaser">
<meta property="og:description" content="An easy to use, login-free, deck sharing website.">
<meta property="og:url" content="https://divran.github.io/mtg-deck-showcaser/">
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/deck-showcaser.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/deck-showcaser.css" rel="stylesheet">
<script src="js/base64-string.js"></script>
<script src="js/lz-string.js"></script>
<script src="js/scryfall-symbology.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-128254022-1"></script>
<!-- Google Analytics is used ONLY to allow me to see the number of users using my site -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-128254022-1');
</script>
</head>
<body>
<div class="modal fade" id="options-modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Options</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<table class="table">
<thead>
<col width="50%">
<col width="50%">
</thead>
<tr>
<td class="options-resolution" data-value="1">
<input type="checkbox">
<label>Standard resolution</label><br>
<small>Standard image resolution <strong>(default)</strong><br>(Changes will take effect on next deck load).</small>
</td>
<td class="options-resolution" data-value="0">
<input type="checkbox">
<label>Low resolution</label><br>
<small>Loads low resolution images instead. Images may be blurry and unreadable, but it will use much less bandwidth.</small>
</td>
</tr>
<tr>
<td class="options-auto-split" data-value="1">
<input type="checkbox">
<label>Enable Auto-split</label><br>
<small>Automatically detects when a column gets too tall, and splits it into two columns. Tries to do it cleverly so you don't end up with a column of only 1 or 2 cards <strong>(default)</strong></small>
</td>
<td class="options-auto-split" data-value="0">
<input type="checkbox">
<label>Disable Auto-split</label><br>
<small>Keeps all categories as single columns, never splits them.<br>(Changes will take effect on next deck load).</small>
</td>
</tr>
<tr>
<td class="options-fullscreen-img" data-value="1">
<input type="checkbox">
<label>Enable fullscreen images</label><br>
<small>When you hover over an image, loads a high-resolution version of the image and displays it fullscreen instead.</small>
</td>
<td class="options-fullscreen-img" data-value="0">
<input type="checkbox">
<label>Disable fullscreen images</label><br>
<small>Default behavior of simply moving the image to the top of the pile of cards on hover <strong>(default)</strong>.<br>(Changes will take effect immediately).</small>
</td>
</tr>
<tr>
<td class="options-hide-basic-grid" data-value="1">
<input type="checkbox">
<label>Hide basic lands in grid</label><br>
<small>When you open grid view, hide all basic lands. <strong>(default)</strong></small>
</td>
<td class="options-hide-basic-grid" data-value="0">
<input type="checkbox">
<label>Show basic lands in grid</label><br>
<small>When you open grid view, show all basic lands.</small>
</td>
</tr>
<tr>
<td class="options-merge-two-faced" data-value="0">
<input type="checkbox">
<label>Separate two-faced</label><br>
<small>In grid text view, two-faced cards are treated as two separate cards. <strong>(default)</strong></small>
</td>
<td class="options-merge-two-faced" data-value="1">
<input type="checkbox">
<label>Combine two-faced</label><br>
<small>In grid text view, two-faced cards are combined into one card similar to split cards.</small>
</td>
</tr>
<tr>
<td class="options-darkmode" data-value="0">
<input type="checkbox">
<label>Light theme</label>
</td>
<td class="options-darkmode" data-value="1">
<input type="checkbox">
<label>Dark theme</label>
</td>
</tr>
</table>
<div class="modal-footer">
<p>
These options are stored in 'localStorage' in your browser (pretty much the same as cookies).
Currently, <span id='options-amount-stored'></span> options are stored in your browser.
Click <a href='#' id='options-delete-stored'>here</a> to delete all stored options and reset them to default.
</p>
</div>
</div>
</div>
</div>
<div class="fullscreen-img" style="display:none;"></div>
<div class="container-fluid">
<div class="center">
<div class="width-limiter">
<div class="card" id="input-card">
<div class="collapse show">
<div class="card-body">
<p>Paste the exported deck data from a source such as MTG Arena into the text box below and click Load.<br>
<small>(Currently only supports MTG Arena format) - (<a href='#' id='how-does-it-work'>How does it work?</a>)</small></p>
<div class='collapse' id="how-does-it-work-collapse">
<div class="center">
<div class='card'>
<div class='card-body'>
<p>This site is 100% clientside - meaning it all runs in your browser and does not have a server or backend of its own. For this reason, all of the deck data is stored inside the URL 'code' that is generated, and nowhere else.</p>
<p>The code parses your decklist and then queries the <a href="https://scryfall.com/">Scryfall API</a> to fetch card images and other information. Next, it does a little bit of ordering by card type and CMC cost, etc, before displaying the cards to you.</p>
<p>The entire source code is available on <a href="https://github.com/Divran/mtg-deck-showcaser">GitHub</a> if you are interested. If you find any bugs, please report them on GitHub as well. Thanks.</p>
<p><small>(Note that if you edit the options away from the defaults, they will be saved in your browser.)</small></p>
</div>
</div>
</div>
</div>
<textarea id="input" class="form-control"></textarea>
<div class="alert alert-danger d-none mt-2 mb-0" id="cant-load-alert">
<strong>
<p>The following cards could not be loaded.
<ul>
<li>They will not be included in the URL, so be sure to fix any issues before closing the page.</li>
<li>Try fixing any spelling mistakes, or specifying a different set for these cards.</li>
<li>Try specifying no set at all to widen the search.</li>
<li>It's possible the Scryfall API hasn't been updated yet, in which case there's nothing we can do except wait.</li>
</ul>
</p>
</strong>
<div id="cant-load-alert-list"></div>
</div>
</div>
</div>
<div class="card-footer">
<div class="float-left d-none alert alert-danger small px-2 py-1 m-0" id="cant-load-alert-header"></div>
<div class="float-right">
<div class="btn btn-info btn-sm options-menu-btn">Options</div>
</div>
<div class="btn btn-primary load-deck-btn">Load deck</div>
<div class="btn btn-sm btn-primary open-input-btn" style="display:none;">Load another deck (or view decklist)</div>
</div>
</div>
<br>
<div id="loading-notification">
Loading...
<div class="loading-notification-box">If it doesn't load in under a minute or two, something may have gone wrong. Make sure your internet connection isn't too slow to load the data+images. If it still doesn't work, please <a href="https://github.com/Divran/mtg-deck-showcaser/issues/new">post an issue on my github</a> and be sure to include the link to the deck.<br>
If you know how to check your browser's console for errors, you may also do so now to confirm whether or not a github issue post is required.
Thank you.</div>
</div>
<div class="card" id="result-card">
<div class="collapse">
<div class="card-body" id="statistics-body"></div>
</div>
<div class="collapse">
<div class="card-body" id="result-body"></div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
// How does it work collapsible
$("#how-does-it-work").click(function(e) {
$("#how-does-it-work-collapse").collapse("toggle");
e.preventDefault();
return true;
});
//options menu
var modal = $("#options-modal");
$(".options-menu-btn").click(function() {
modal.modal("show");
});
var amount = $("#options-amount-stored",modal);
var del = $("#options-delete-stored",modal);
function updateCounter() {
amount.text(localStorage.length);
}
del.click(function(e) {
localStorage.clear();
updateCounter();
loadOptions();
e.preventDefault();
return true;
});
var options = {
"resolution": "1", // 0=low, 1=normal (default: 1)
"auto-split": "1", // 0=no, 1=yes (default: 1)
"fullscreen-img": "0", // 0=no, 1=yes (default:0)
"darkmode": "0", //0=no, 1=yes (default:0)
"hide-basic-grid": "1", // 1=hide basic lads, 0=don't hide basic lands (default: 1)
"merge-two-faced": "0" //0=separate two-faced cards, 1=merge two-faced cards (default:0)
};
// options handled here instead of in showcaser code
var my_options = {
"darkmode": function(val) {
if (val==1) {
$("body").addClass("bg-dark").addClass("text-white");
$(".card").addClass("bg-dark");
$("input, textarea").addClass("form-control-dark");
$("table").addClass("table-dark");
} else {
$("body").removeClass("bg-dark").removeClass("text-white");
$(".card").removeClass("bg-dark");
$("input, textarea").removeClass("form-control-dark");
$("table").removeClass("table-dark");
}
}
}
function loadOptions() {
$.each(options,function(key,def) {
// load default
var val = localStorage.getItem(key) || def;
// check current options
var elem = $(".options-" + key,modal);
elem.removeClass("table-success");
$("input",elem).prop("checked",false);
$.each(elem,function(_,e) {
e = $(e);
if (e.attr("data-value") == val) {
// check myself
$("input",e).prop("checked",true);
e.addClass("table-success");
if (my_options[key]) {
my_options[key](val);
} else {
// set option in showcaser
showcaserOption(key,val);
}
}
});
updateCounter();
// enable clicking
elem.off('click'); // remove old handler
elem.click(function() {
var val = $(this).attr("data-value");
// uncheck all others
elem.removeClass("table-success");
$("input",elem).prop("checked",false);
// check myself
$(this).addClass("table-success");
$("input",$(this)).prop("checked",true);
// save value
if (val == options[key]) {
localStorage.removeItem(key);
} else {
localStorage.setItem(key,val);
}
// update counter
updateCounter();
// set option in showcaser
if (my_options[key]) {
my_options[key](val);
} else {
// set option in showcaser
showcaserOption(key,val);
}
});
});
}
loadOptions();
});
</script>
<div class="credits">
<small>
Made by Divran September 2018, last updated May 2024<br>
Uses Scryfall API at <a href="https://scryfall.com/">https://scryfall.com/</a> for card images/data/pricing/etc.<br>
Source: <a href='https://github.com/Divran/mtg-deck-showcaser'>https://github.com/Divran/mtg-deck-showcaser</a>
</small>
</div>
<!-- include at the end to make the page load faster -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js" integrity="sha512-d9xgZrVZpmmQlfonhQUvTR7lMPtO7NkZMkA0ABN3PHCbKA5nqylQ/yWlFAyY6hYgdF1Qh6nYiuADWwKB4C2WSw==" crossorigin="anonymous"></script>
</body>
</html>