1 <style
>body
{font
-family
:monospace
;padding
:0px
} .r0
{background
-color
:#e9e9e9} ol{list-style-type:none;padding:0px;margin:0px} div{float:left} td{padding:0 3px 0 3px}</style>
4 if (!isset($_POST['data'])){
5 $_POST['data'] = '��YN2)Q(ԯ�Oy�"�?Ƣ<^L(��k�:�]�~��q��1�� 4�R!�l��E�n��\�>?��P�>�?rA.f�Jn��▒r����v^L�,.~<���]�^�tg��"▒,^L�z���a(8�&�hDj�`��Ե����';
6 $_POST['data'] .= '��YN2)Q(ԯ�Oy�"�?Ƣ<^L(��k�:�]�~��q��1�� 4�R!�l��E�n��\�>?��P�>�?rA.f�Jn��▒r����v^L�,.~<���]�^�tg��"▒,^L�z���a(8�&�hDj�`��Ե����';
7 $_POST['data'] .= '��YN2)Q(ԯ�Oy�"�?Ƣ<^L(��k�:�]�~��q��1�� 4�R!�l��E�n��\�>?��P�>�?rA.f�Jn��▒r����v^L�,.~<���]�^�tg��"▒,^L�z���a(8�&�hDj�`��Ե����';
8 $_POST['data'] .= '��YN2)Q(ԯ�Oy�"�?Ƣ<^L(��k�:�]�~��q��1�� 4�R!�l��E�n��\�>?��P�>�?rA.f�Jn��▒r����v^L�,.~<���]�^�tg��"▒,^L�z���a(8�&�hDj�`��Ե����';
9 $_POST['data'] .= '��YN2)Q(ԯ�Oy�"�?Ƣ<^L(��k�:�]�~��q��1�� 4�R!�l��E�n��\�>?��P�>�?rA.f�Jn��▒r����v^L�,.~<���]�^�tg��"▒,^L�z���a(8�&�hDj�`��Ե����';
11 if (isset($_POST['data'])){
12 $_POST['data'] = html_entity_decode($_POST['data'],ENT_NOQUOTES
,'UTF-8');
13 $ret = tohex($_POST['data']);
14 $offset = $hex = $ascii = '';
15 foreach ($ret as $key=>&$arr){
16 $offset .= '<li>'.$arr[0].'</li>';
17 $hex .= '<tr class="r'.($key%2
).'">';
18 foreach ($arr[1] as $k=>&$v){
20 if ($k == 8) $style .= 'padding-left:0.5em;';
21 if ($v == '0d' ||
$v == '0a') $style .= 'background-color:pink;';
22 $hex .= '<td id="c'.($key*16+
$k).'"'.(strlen($style)>0?
' style="'.$style.'"':'').'>'.$v.'</td>';
24 if ($key == 0 && $k < 15) $hex .= '<td style="width:'.((15-$k)*1.65).'em"></td>';
26 $ascii .= '<li class="r'.($key%2
).'">'.str_replace(' ',' ',$arr[2]).'</li>';
28 echo '<div style="font-weight:bold;padding-right:0.5em;"><ol id="offset">',$offset,'</ol></div>';
29 echo '<div><table cellspacing=0>',$hex,'</table></div>';
30 echo '<div style="padding-left:0.3em;"><ol>',$ascii,'</ol></div>';
33 <br style
="clear:both" />
35 <textarea name
="data" rows
="20" cols
="80"></textarea
>
36 <input type
="submit" />
39 function disableSelection(target
){
40 if (typeof target
.onselectstart
!="undefined") //IE route
41 target
.onselectstart
=function(){return false}
42 else if (typeof target
.style
.MozUserSelect
!="undefined") //Firefox route
43 target
.style
.MozUserSelect
="none"
44 else //All other route (ie: Opera)
45 target
.onmousedown
=function(){return false}
46 target
.style
.cursor
= "default"
48 disableSelection(document
.getElementById('offset'));
50 <script src
="jquery.min.js"></script
>
51 <script src
="jquery-ui.min.js"></script
>
53 $
(document
).ready(function(){
54 $
("table tr td").draggable().droppable({
55 accept
: "table tr td",
56 drop
: function(ev
,ui
){
57 //var t = document.getElementById('ascii').createTextRange();
58 //t.move("character", 3); t.moveEnd("character", 16); t.select();
59 alert("dragged from "+$
(ui
.draggable
).attr('id')+
" to "+$
(this
).attr('id'));