-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.html
98 lines (75 loc) · 3.01 KB
/
popup.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
<style>
* { margin:0; padding:0; font-family: arial, sans-serif; font-size: 12px; }
body { min-width:360px; overflow-x:hidden; padding: 10px; }
label { font-weight: bold; }
textarea{ color: #666; border-radius: 10px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) inset; outline: none; border-width: 0; padding: 4px 7px; margin: 0px; width: 100%; }
a { text-decoration: underline; }
a:hover { text-decoration: none; }
.item{ margin-bottom: 15px; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js" type="text/javascript"></script>
<script src="strutil.js" type="text/javascript"></script>
<script src="html-entities.js" type="text/javascript"></script>
<script type="text/javascript">
function unescapeFromString(str, encoding){ return str; }
function escapeToString(str, encoding){ return str; }
function copyToClipboard(id) {
var input = document.getElementById( id );
input.focus();
input.select();
document.execCommand('Copy');
}
function escapeSingleQuoteAndBackSlash(value){
value = value.replace(/\\/g,'\\\\\\\\');
value = value.replace(/\'/g,'\\\\\\\'');
return value;
}
$(function() {
$('textarea').keyup(function() {
var id = $(this).attr('id');
var value = $(this).val();
var _unescape = eval($(this).attr('unescape'));
valueUnescaped = _unescape(value, 'UTF-8');
$('textarea').each(function(index) {
if(id != $(this).attr('id')){
try{
var _escape = eval($(this).attr('escape'));
var valueEscaped = _escape(valueUnescaped, 'UTF-8');
$(this).val(valueEscaped);
} catch(ex){
console.log($(this).attr('id') + ': ' + ex);
}
}
});
});
$('a').click(function(){
copyToClipboard($(this).parent('.item').find('textarea').attr('id'));
});
});
</script>
<body>
<div class="item">
<label for="url">Plain text</label> [<a href="#">copy</a>]
<textarea id="plainText" escape="escapeToString" unescape="unescapeFromString" placeholder="Plain text" rows="3"></textarea>
</div>
<div class="item">
<label for="url">URL</label> [<a href="#">copy</a>]
<textarea id="url" escape="escapeToUrl" unescape="unescapeFromUrl" placeholder="URL" rows="3"></textarea>
</div>
<div class="item">
<label for="url">Base64</label> [<a href="#">copy</a>]
<textarea id="base64" escape="escapeToBase64" unescape="unescapeFromBase64" placeholder="Base64" rows="3"></textarea>
</div>
<div class="item">
<label for="url">UTF-16</label> [<a href="#">copy</a>]
<textarea id="utf-16" escape="escapeToUtf16" unescape="unescapeFromUtf16" placeholder="UTF-16" rows="3"></textarea>
</div>
<div class="item">
<label for="url">HTML</label> [<a href="#">copy</a>]
<textarea id="html" escape="escapeToHtml" unescape="unescapeFromHtml" placeholder="HTML" rows="3"></textarea>
</div>
<div class="item">
<label for="url">Javascript</label> [<a href="#">copy</a>]
<textarea id="js" escape="escape" unescape="unescape" placeholder="Javascript" rows="3"></textarea>
</div>
</body>