forked from microsoft/pxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.html
More file actions
188 lines (169 loc) · 8.04 KB
/
script.html
File metadata and controls
188 lines (169 loc) · 8.04 KB
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta charset="UTF-8">
<title>@name@</title>
<!-- @include meta.html -->
<!-- @include scripthead.html -->
<!-- @include targetconfig.html -->
<!-- @include tickevent.html -->
<link rel="alternate" type="application/json+oembed" href="@oembedurl@&format=json" />
<link rel="alternate" type="text/xml+oembed" href="@oembedurl@&format=xml" />
</head>
<body id='root' class='root expandIt share-page'>
<div class="showDesktop page-header">
<div class="ui container">
<div id="page-header-wrapper">
<div class="page-header-item no-grow">
<a href="https://makecode.com/" title="Go to Microsoft MakeCode"
aria-label="Microsoft MakeCode Logo" role="menuitem" target="blank" rel="noopener"
class="ui item logo organization">
<img class="ui logo" src="./static/Microsoft-logo_rgb_c-gray.png"
alt="Microsoft MakeCode Logo">
</a>
<div class="page-header-product">MakeCode</div>
</div>
<div class="page-header-item page-header-spacer"></div>
<div class="page-header-item page-header-content no-grow">
<h2 class="ui item header">@title@</h2>
<a href="/@versionsuff@#pub:@id@" class="ui tiny button">Edit Code</a>
</div>
</div>
</div>
</div>
<!-- @include macros.html -->
<aside id=main-container class=box>
@BODY@
</aside>
<div class="ui main container mainbody script-content">
<iframe id="embed-frame" class="script-embed" src="/@versionsuff@#sandbox:@id@"
sandbox="allow-popups allow-forms allow-scripts allow-same-origin" frameborder="0"></iframe>
<div class="script-bookend">
<div id="abuse-message" class="ui tiny blue message">
<div class="ui grid padded">
<div class="abuse content">
<p>
The content above is provided by a user, and is not endorsed by Microsoft.
<a style='text-decoration:underline' id="abuse" href="#">Report abuse</a> if you think it's
not appropriate.
</p>
</div>
</div>
</div>
<div class="ui small modal" id='abusemodal'>
<div class="header">Report abuse</div>
<div class="content">
<div class="ui form">
<div class="field">
<label>Why do you find it offensive?</label>
<textarea id='abusetext' rows="2"></textarea>
</div>
</div>
</div>
<div class="actions">
<div class="ui ok button violet">
<i class='ui flag icon'></i> Submit
</div>
<div class="ui cancel button">
<i class='ui cancel icon'></i> Cancel
</div>
</div>
</div>
<div class="ui small modal" id='abusedone'>
<div class="header">Report sent</div>
<div class="content">
<p>
Thank you for helping keep Microsoft MakeCode a friendly place!
</p>
</div>
<div class="actions">
<div class="ui ok green button">
<i class='ui trophy icon'></i> OK
</div>
</div>
</div>
<script>
$(function () {
var id = "@id@";
var now = Math.round(Date.now() / 1000);
$(".humantime").each(function () {
$(this).text(
describetime(now, parseInt($(this).data("time")))
)
})
$("#abuse").click(function () {
$("#abusemodal")
.modal({
onApprove: function () {
$.ajax({
type: 'POST',
url: '/api/@id@/abusereports',
data: JSON.stringify({
text: $('#abusetext').val()
}),
success: function () {
$("#abusedone").modal("show");
},
contentType: "application/json",
dataType: 'json'
});
}
})
.modal("show");
})
})
var shareLinkIsApproved = false;
window.pxtTargetConfigPromise
.then(function(targetConfig) {
var approvedShareLinks = targetConfig && targetConfig.shareLinks && targetConfig.shareLinks.approved;
if (approvedShareLinks && approvedShareLinks.indexOf("@id@") >= 0) {
// This share link has been allow listed; remove cookie banner and allow sending of tick events
shareLinkIsApproved = true;
var abuseMessage = document.querySelector("#abuse-message");
if (abuseMessage)
abuseMessage.remove();
window.pxtTickEvent(
'approved.shareurl.loaded',
{ shareurl: "@id@" },
);
}
});
window.addEventListener('message', function (ev) {
if (!shareLinkIsApproved)
return;
var d = ev.data;
if (d.type == "messagepacket" && d.channel == "tick-event" && d.data) {
var unpackedData = "";
for (var i = 0; i < d.data.length; ++i)
unpackedData += String.fromCharCode(d.data[i]);
try {
const data = JSON.parse(unpackedData);
data["shareurl"] = "@id@";
window.pxtTickEvent(
'simulator.user.tick',
data,
);
} catch (e) { /** failed to parse tick from game **/ }
}
});
</script>
</div>
<div class="script-bookend">
<div style="text-align: center;">
<div class="ui container horizontal mini link list">
<!-- <a class="ui item " href="https://makecode.com/contact " target="_blank " rel="noopener ">Contact Us</a> -->
<a class="ui item " href="https://makecode.com/privacy " target="_blank " rel="noopener ">Privacy
& Cookies</a>
<a class="ui item " href="https://makecode.com/termsofuse " target="_blank " rel="noopener "> Terms
Of Use</a>
<a class="ui item " href="https://makecode.com/trademarks " target="_blank "
rel="noopener ">Trademarks</a>
<div class="ui item ">© 2020 Microsoft</div>
</div>
</div>
</div>
@body@
</div>
<!-- @include tracking.html -->
</body>
</html>