-
Notifications
You must be signed in to change notification settings - Fork 2
/
iframe.html
75 lines (61 loc) · 1.97 KB
/
iframe.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
<HTML>
<HEAD>
<SCRIPT type="text/javascript" src="./jquery-1.3.2.min.js"></SCRIPT>
<SCRIPT type="text/javascript" src="./getPath.js"></SCRIPT>
<SCRIPT type="text/javascript" src="./rangy-core-src.js"></SCRIPT>
<SCRIPT type="text/javascript" src="./selectionsaverestore.js"></SCRIPT>
<SCRIPT type="text/javascript" src="./textSelection.js"></SCRIPT>
<STYLE type="text/css">
.tag{
color: cyan;
}
</STYLE>
<SCRIPT type="text/javascript">
$(document).ready(function(){
alert("po");
var shifted =false;
ts = new TextSelector();
$("body").mouseup(function(e){sel = ts.getSelectedText();window.parent.showMessage(JSON.stringify(sel));});
$("html").eq(0).keydown(function(e){
switch (e.keyCode) {
case 16:
shifted = true;
// Return
// Pause();
break;
case 188:
// <
if (shifted) {
sel = ts.getSelectedText();
window.parent.showMessage(JSON.stringify(sel));
kidlen=$(sel.StartParent).children().length;
node = null;
if (kidlen>0){
node = $(sel.StartParent).children().eq(sel.StartChild);
}
else{
node = $(sel.StartParent);
}
output = node.html();
start = output.substring(0,sel.StartOffset);
end = output.substring(sel.StartOffset);
middle = "<span class='tag'><</span>";
node.html(start+middle+end);
}
break;
case 190:
// <
if (shifted) {
}
break;
}
if (e.keyCode!=16){
shifted = false;
}
});
});
</SCRIPT>
</HEAD>
<BODY contenteditable="true">
</BODY>
</HTML>