-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
129 lines (110 loc) · 4.03 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
<!doctype html>
<html lang="en">
<head>
<title>MTGA Share</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="js/jquery.js"></script>
<script src="js/base64.js"></script>
<script src="js/pako.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/cards.js"></script>
<script src="js/local.js"></script>
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<div class="container">
<div class="row" id='navbar'><div class="col-12 mb-1 mt-1">
<a href="https://github.com/isharacomix/mtgashare" target="_blank" class="btn btn-info btn-sm">Project Page</a>
<a href="https://github.com/isharacomix/mtgashare/issues/new" target="_blank" class="btn btn-danger btn-sm">Report Issue</a>
<a href="#" target="_blank" id="sharebutton" class="btn btn-success btn-sm">Share New Deck/Draft</a>
</div></div>
<div class="row" id='share' style="display: none;">
<div class="col-12">
<div>This tool is designed to share decks and drafts exported from MTGA and MTGO. To share a deck or draft, paste it below, then click the button to get your sharing link. Your sharing link will be extremely long, but most social media sites (such as Mastodon and Twitter) should use their built-in link shortening to a fixed number of characters. If you are sharing on a site without a built-in link sharer (such as Discord), you can create and share a TinyURL instead.</div>
<div class="input-group mb-1 mt-1">
<textarea class="form-control" id="forminput" rows="14" cols="50"></textarea>
</div>
<button class="btn btn-primary" onclick="genLink();">Share</button>
<span id='target'></span>
<span id='target2'></span>
</div>
</div>
<div class="row" id='deckcontainer' style="display: none;">
<div id='deckdata' class="col-12">
</div>
</div>
<div class="row" id='draftcontainer' style="display: none;">
<div id='draftdata' class="col-12">
</div>
</div>
<div class="row" id="footer"><div id='footer' class="col-12">
<br />
<small class="text-muted"><em>mtgashare</em> is unofficial Fan Content permitted under the Fan Content Policy. Not approved/endorsed by Wizards. Portions of the materials used are property of Wizards of the Coast. ©Wizards of the Coast LLC.</small>
</div></div>
</div>
</body>
<script>
var localdata = window.location.href.substring(window.location.href.indexOf("#")+1);
var localmedia = deserialize(localdata)
if (!("draft" in localmedia || "deck" in localmedia))
{
$('#sharebutton').hide();
$('#share').show();
}
if ("draft" in localmedia)
{
$('#draftcontainer').show();
let data = ""
data += visualDraftHTML(localmedia.draft)
data += textualDraftHTML(localmedia.draft)
$('#draftdata').html(data);
}
if ('deck' in localmedia)
{
$('#deckcontainer').show();
let data = ""
data += "<div class='card mb-5 mt-5'>"
data += "<div class='card-header'>"
data += "Deck"
data += "</div>"
data += "<div class='card-body'>"
data += deckHTML(localmedia.deck)
data += "</div>"
data += "</div>"
data += "<div id='vizspoiler' class='card mb-5 mt-5 d-none d-xl-block' >"
data += "<div class='card-header'>"
data += "Visual Spoiler"
data += "</div>"
data += "<div class='card-body'>"
data += visualHTML(localmedia.deck)
data += "</div>"
data += "</div>"
$('#deckdata').html(data);
}
function genLink(){
$("#target").html("")
$("#target2").html("")
let data = $("#forminput").val()
let media = {}
if (data.includes("\nPlayers:"))
{
media = parseDraft(data)
}
else
{
media = parseDeck(data)
}
let dest = ""
if (media != null)
{
dest = serialize(media)
}
if (dest != "")
{
$("#target").html("<a class='btn btn-link' href='#"+dest+"' target='_blank'>Shareable Link</a>")
$("#target2").html("<a class='btn btn-link' href='https://tinyurl.com/create.php?url="+encodeURIComponent(document.location.origin+document.location.pathname+"#"+dest)+"' target='_blank'>Create TinyURL</a>")
}
}
</script>
</html>