forked from scratchblocks/scratchblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester-dev.html
159 lines (137 loc) · 4.28 KB
/
tester-dev.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>dev : [scratchblocks]</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<link rel="stylesheet/less" type="text/css" href="scratchblocks2.less">
<script type="text/javascript" src="scratchblocks2.js"></script>
<script type="text/javascript">
less = {
env: "development", // or "production"
fileAsync: false, // load imports async when in a page under
// a file protocol
poll: 1000, // when in watch mode, time in ms between polls
dumpLineNumbers: "all", // or "mediaQuery" or "all"
};
</script>
<script type="text/javascript" src="less.js"></script>
<script type="text/javascript">
$(document).ready(function() {
less.watch();
$("#tester-status").append("<br><br> LESS is now watching the file for \
changes: update the file on disk, and the styles will automatically \
reload here.");
});
</script>
<style type="text/css">
h1 {
font-family: monospace;
}
a {
text-decoration: none;
color: #22f;
}
a:hover {
text-decoration: underline;
}
body {
margin: 1em;
margin-bottom: 100%;
font-family: sans-serif;
}
input, button {
font-size: 1em;
font-family: inherit;
}
textarea {
font-size: 1em;
margin-bottom: 1em;
min-width: 30em;
min-height: 5em; /* DEBUG 15em;*/
}
button {
display: block;
font-size: 1.25em;
margin-bottom: 1em;
border: 1px solid #444;
background: #ccc;
box-shadow: 0 1px 1px #888;
}
a:active, button:active {
position: relative;
top: 1px;
box-shadow: none;
}
#preview {
margin: 1em;
}
#link-url {
width: auto;
min-width: 40em;
cursor: text;
}
label {
font-weight: bold;
cursor: pointer;
}
#me {
font-weight: bold;
}
a {
color: black; /* distracting links */
}
</style>
</head>
<body>
<h1>[scratchblocks]: dev</h1>
<p id="tester-status">Drop <a href="http://lesscss.org/">less.js</a> into the same directory as this file.
You may need to serve this page from a local web server.</p>
<textarea id="code"></textarea>
<button id="render">Render</button>
<pre id="preview" class="blocks"></pre>
<script type="text/javascript">
if(typeof(String.prototype.trim) === "undefined") {
String.prototype.trim = function() {
return String(this).replace(/^\s+|\s+$/g, '');
};
}
code = document.getElementById('code');
preview = document.getElementById('preview');
link_url = document.getElementById('link-url');
link_url_label = document.getElementById('link-url-label');
var oldHash;
function refresh () {
script = code.value;
script = script.replace(/\[\/?scratchblocks\]/gi, ''); // Scratch Forums
script = script.replace(/<\/?scratchblocks>/gi, ''); // Scratch Wiki
script = script.replace(/^position\:[0-9\., ]+/i, ''); // Kurt
script = script.trim();
location.hash = '#'+encodeURIComponent(script);
oldHash = location.hash;
script = script.replace(/&/g, '&');
script = script.replace(/</g, '<');
script = script.replace(/>/g, '>');
script = script.replace(/"/g, '"');
preview.innerHTML = script;
scratchblocks2.parse("pre.blocks");
}
function checkHash() {
if (oldHash != location.hash) {
code.value = decodeURIComponent((location.href.split("#")[1] || ""));
refresh();
}
window.setTimeout(checkHash, 1000);
}
code.value = decodeURIComponent((location.href.split("#")[1] || ""));
checkHash();
document.getElementById('render').onmousedown = refresh;
code.onkeyup = refresh;
code.onblur = refresh;
code.oncopy = code.onpaste = function(e) {
window.setTimeout(refresh, 100);
}
refresh();
</script>
</body>
</html>