-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder.html
More file actions
89 lines (87 loc) · 1.85 KB
/
builder.html
File metadata and controls
89 lines (87 loc) · 1.85 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
<html>
<head>
<title>Bookmarklet Javascript Loader builder</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
//<!--
var pre= [
"javascript:(function(){",
"function l(c,f){",
"var n=document.createElement('script');",
"n.type='text/javascript';",
"n.src=c;",
"var s=document.body;",
"var d=false;",
"n.onload=n.onreadystatechange=",
"function(){",
"if(!d &&(!this.readyState||this.readState=='loaded'",
"||this.readState=='complete')){",
"d=true;",
"f();",
"n.onload=n.onreadystatechange=null;",
"if (s) s.removeChild(n);",
"}",
"};",
"if (s) s.appendChild(n);",
"}",
];
var post=[
"})()"
];
function build_bookmarklet(urls, fn)
{
var result;
var body = [];
var i;
for (i=0; i<urls.length; i++) {
body.push("l('"+urls[i]+"',function(){");
}
body.push(fn+"();");
for (i=0; i<urls.length; i++) {
body.push("});");
}
return pre.join("") + body.join("") + post.join("");
}
function make()
{
var urls = $("textarea[name=urls]").val().split(/\n/);
var call = $("input[name=call]").val();
var link = $("input[name=link]").val();
var bookmarklet = build_bookmarklet(urls, call);
$('#output').attr("href",bookmarklet);
$('#output').html(link);
var html='<a href="'+bookmarklet+'">'+link+'</a>';
$('#output_html').text(html).html();
return false;
}
//-->
</script
</head>
<body>
<form onsubmit="return make()">
<table>
<tr>
<th>Link text:</th>
<td><input id="call" name="link" type="text"></td>
</tr>
<tr>
<th>Urls:</th>
<td><textarea id="urls" name="urls"></textarea></td>
</tr>
<tr>
<th>Callback:</th>
<td><input id="call" name="call" type="text"></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="Generate"></td>
</tr>
</table>
</form>
<div>
<a id="output">my bookmarklet</a>
<div>
<div id="output_html">
</div>
</body>
</html>