-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
72 lines (67 loc) · 1.75 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
<html>
<head>
<title>Title</title>
<style>
</style>
</head>
<body>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
/*
* Minifies a multiline js string.
* Removes comments, trims leading/trailing whitespace,
* and replaces EOLs with a space.
*/
function minify(js) {
var lines = js.split("\n");
$(lines).each(function(idx, line) {
// remove comments
if (line.indexOf("//") != -1) {
line = line.substring(0, line.indexOf("//"));
}
// trim whitespace
line = $.trim(line);
lines[idx] = line;
});
// replace EOLs with a space
return lines.join(" ");
}
$(function() {
$("#submit-button").click(function() {
// get values
var url = $("#url").val();
var js = $("#js").val();
// minify js
var js = minify(js);
// generate url
var href = window.location.href.substring(0, window.location.href.lastIndexOf("/")) +
"/echo.php?" +
"&u=" + escape(url) +
"&js=" + escape(js);
var justJs = "javascript:" + escape(js) + ";void(0);";
$("#echolink").html(href);
$("#javascript").html(justJs);
$("#results").show();
});
});
</script>
<div>
<label>url</label><input id="url" style="min-width: 600px"></input>
</div>
<div>
<label>js</label><textarea id="js" rows="10" cols="100"></textarea>
</div>
<div>
<button id="submit-button">generate</button>
</div>
<div id="results" style="display: none;">
<div>
<label>generated echolink: </label><pre id="echolink"></pre>
</div>
<div>
<label>generated javascript: </label><pre id="javascript"></pre>
</div>
</div>
</body>
</html>