python英文翻译

Standard

之前在网上下了个mp3格式的英语高频字汇表,带lrc字幕的.
平时没事可以一直开着加深记忆.
不过其字幕没有中文翻译,于是就写了段东西帮它翻译一下.

原字幕文件

[00:00.01]a
[00:01.728]abbreviation
[00:04.128]able
[00:05.976]about
[00:08.16]abroad
[00:09.864]absent-minded
[00:12.336]absorb

用于翻译英文单词的URL返回值
URL = ‘http://dict.cn/ws.php?utf8=true&q=%s’

<?xml version="1.0" encoding="UTF-8" ?>
<dict>
<key>a</key>
<lang>ec</lang>
<audio>http://mp3.dict.cn/mp3.php?q=JIkye</audio>
<pron>&#601;,ei</pron>
<def>art.一(个), 每一(个), 任一(个) </def>
<sent><orig>I have engaged &lt;em&gt;a&lt;/em&gt; room at this hotel.</orig><trans>我已经在这个旅馆里预订了一个房间。</trans></sent>
 
<sent><orig>You should give it &lt;em&gt;a&lt;/em&gt; try.</orig><trans>你应该试一试。</trans></sent>
<sent><orig>I don't care what &lt;em&gt;a&lt;/em&gt; car looks like as long as it gets me from A to B.</orig><trans>我倒不在乎汽车的样子,只要能把我从一处载到另一处就行了。</trans></sent>
</dict>

代码

#!/usr/bin/python
#coding=utf8
 
import urllib
import xml.dom.minidom as xml
 
URL = 'http://dict.cn/ws.php?utf8=true&q=%s'
 
def getText(nodelist):
    rc = ""
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc = rc + node.data
    return rc
 
def translate(word):
    xmls = urllib.urlopen(URL % urllib.quote(word)).read()
    root = xml.parseString(xmls).documentElement
 
    try:
        str = getText(root.getElementsByTagName("def")[0].childNodes)
    except:
        str = "NULL"
    return str.replace('\n','')
 
if __name__ == '__main__':
    r=open('english.lrc')
    wordlist=list( r.read().split('\n') )
    r.close()
 
    w=open('english_new.lrc','a')
 
    i=0
    while i<len(wordlist):
        text = wordlist[i].split(']')[0]+"]"+wordlist[i].split(']')[1] + "  " + translate( wordlist[i].split(']')[1])
        w.writelines(text.encode("utf-8")+'\n\r')
        i=i+1
 
    w.close();

翻译后的字幕

[00:00.01]a  art.一(个), 每一(个), 任一(个) 
[00:01.728]abbreviation  n.缩写 
[00:04.128]able  adj.能够的, 有能力的, 能干的 
[00:05.976]about  prep.关于, 大约, 在 ... 周围 adv.大约, 附近, 到处, 在周围 
[00:08.16]abroad  adv.到国外, 广为流传 adj.在国外, 海外(一般作表语) 
[00:09.864]absent-minded  adj. 心不在焉的
[00:12.336]absorb  vt.吸收, 吸引 ... 的注意, 吞并, 承受

封超过100个连接的IP防DDOS

Standard
#!/bin/sh
/bin/netstat -an|grep ESTABLISHED|awk{print $5}|awk -F: ‘{print $1}|sort|uniq -c|sort -rn|grep -v -E172.10|127.0|awk{if ($2!=null && $1>100) {print $2}}>/tmp/ddosip
for i in $(cat /tmp/ddosip)
do
/sbin/iptables -I INPUT  -p tcp -m tcp -s $i –dport 80 –syn -j REJECT
done

用Curl、socket、file_get_contents提交数据

Standard
<?php 
/** 
* Socket版本 
* 使用方法: 
* $post_string = "app=socket&version=beta"; 
* request_by_socket('facebook.cn','/restServer.php',$post_string); 
*/ 
function request_by_socket($remote_server,$remote_path,$post_string,$port = 80,$timeout = 30){ 
    $socket = fsockopen($remote_server,$port,$errno,$errstr,$timeout); 
    if (!$socket) die("$errstr($errno)"); 
 
    fwrite($socket,"POST $remote_path HTTP/1.0\r\n"); 
    fwrite($socket,"User-Agent: Socket Example\r\n"); 
    fwrite($socket,"HOST: $remote_server\r\n"); 
    fwrite($socket,"Content-type: application/x-www-form-urlencoded\r\n"); 
    fwrite($socket,"Content-length: ".strlen($post_string)+8."\r\n"); 
    fwrite($socket,"Accept:*/*\r\n"); 
    fwrite($socket,"\r\n"); 
    fwrite($socket,"mypost=$post_string\r\n"); 
    fwrite($socket,"\r\n"); 
 
    $header = ""; 
    while ($str = trim(fgets($socket,4096))) { 
        $header.=$str; 
    } 
    $data = ""; 
    while (!feof($socket)) { 
        $data .= fgets($socket,4096); 
    } 
    return $data; 
}
 
/** 
* Curl版本 
* 使用方法: 
* $post_string = "app=request&version=beta"; 
* request_by_curl('http://facebook.cn/restServer.php',$post_string); 
*/ 
function request_by_curl($remote_server,$post_string){ 
    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL,$remote_server); 
    curl_setopt($ch,CURLOPT_POSTFIELDS,'mypost='.$post_string); 
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
    curl_setopt($ch,CURLOPT_USERAGENT,"CURL Example"); 
    $data = curl_exec($ch); 
    curl_close($ch); 
    return $data; 
}
 
/** 
* 其它版本 
* 使用方法: 
* $post_string = "app=request&version=beta"; 
* request_by_other('http://facebook.cn/restServer.php',$post_string); 
*/ 
function request_by_other($remote_server,$post_string){ 
    $context = array( 
        'http'=>array( 
            'method'=>'POST', 
            'header'=>'Content-type: application/x-www-form-urlencoded'."\r\n". 
                      'User-Agent : POST Example'."\r\n". 
                      'Content-length: '.strlen($post_string)+8, 
            'content'=>'mypost='.$post_string) 
        ); 
    $stream_context = stream_context_create($context); 
    $data = file_get_contents($remote_server,FALSE,$stream_context); 
    return $data; 
}
?>

PHPRPC范例代码

Standard
1
2
3
4
5
6
7
8
//rpc_sayhi.php
require_once('./phprpc/php/phprpc_server.php');
function SayHi($name){
        return 'Hi! '.$name;
}
$phprpc=new PHPRPC_Server();
$phprpc->add('SayHi');
$phprpc->start();
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
/*sayhi.js*/
 $(document).ready(function(){
         $('#submit').click(
                 function(){
                         $('#waiting').show();
                         $('.clear_rs').trigger("click");
                         getRPC();
                 }
         );
         $('.clear_rs').click(
                 function(){
                         $('.clear_rs').hide();
                         $('#hi_name_p').hide('slow');
                 }
         );
 }
 )
 function getRPC(){
         var rpc = new PHPRPC_Client('http://yemaosheng.com/rpc_sayhi.php', ['SayHi']);
                 rpc.SayHi($('#q').val(),function(result){
                      $('#hi_name_p,.clear_rs').show('slow');
                           $('#waiting').hide();
                           $('#hi_name_p').html(result);
                   });
   }
1
2
3
4
5
6
7
8
<! index.html-->
<script src="jquery.js" type="text/javascript"></script>
<script src="phprpc_client.js" type="text/javascript"></script>
<script src="sayhi.js" type="text/javascript"></script>
<input id="q" maxlength="20" name="q" size="20" type="text" />
<input id="submit" maxlength="20" name="submit" size="20" type="button" value="Say Hi!" />
<img id="waiting" style="display:none;" src="http://bawbaw.hu.googlepages.com/indicator.gif" alt="" />  
<input class="clear_rs" style="display:none;" maxlength="20" name="clear_rs2" size="20" type="button" value="Clear" />

PHPRPC官方网站: http://www.phprpc.org

PHP APC文件上传进度条实现范例

Standard
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
99
100
101
102
103
104
105
106
107
//upload.php (文件上传表单,提交到target.php)
<?php $id = $_GET['id']; ?>
<form enctype="multipart/form-data" id="upload_form" action="target.php" method="POST">
  <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key"  value="<?php echo $id?>"/>
  <input type="file" id="test_file" name="test_file"/><br/>
  <input onclick="window.parent.startProgress(); return true;" type="submit" value="Upload!"/>
</form>
 
//target.php (接收upload.php上传表单提交页面)
<?php 
set_time_limit(600);
if($_SERVER['REQUEST_METHOD']=='POST') {
  move_uploaded_file($_FILES["test_file"]["tmp_name"],
  dirname($_SERVER['SCRIPT_FILENAME'])."/UploadTemp/" . $_FILES["test_file"]["name"]);//UploadTemp文件夹位于此脚本相同目录下
  echo "<p>File uploaded.  Thank you!</p>";
}
 
//getprogress.php (用来得到文件上传状态信息,让js来调用)
<?php
session_start();
if(isset($_GET['progress_key'])) {
  $status = apc_fetch('upload_'.$_GET['progress_key']);
  echo ($status['current']/$status['total'])*100;
}
?>
 
//progress.php (调用getprogress.php和upload.php,显示进度条)
<?php
$id = md5(uniqid(rand(), true));
?>
<html>
<head><title>Upload Example</title></head>
<body>
<script language="javascript">
var xmlHttp;
var proNum=0;
var loop=0;
 
var Try = {
 these: function() {
 var returnValue;
  for (var i = 0; i < arguments.length; i++) {
   var lambda = arguments[i];
   try {
    returnValue = lambda();
    break;
   } catch (e) {}
  }
  return returnValue;
 }
}
 
function createXHR(){
 return Try.these(
  function() {return new XMLHttpRequest()},
  function() {return new ActiveXObject('Msxml2.XMLHTTP')},
  function() {return new ActiveXObject('Microsoft.XMLHTTP')}
 ) || false;
}
 
var xmlHttp;
 
function sendURL() {
 xmlHttp=createXHR();
 var url="getprogress.php?progress_key=<?php echo $id;?>";
 xmlHttp.onreadystatechange = doHttpReadyStateChange;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);  
}
 
function doHttpReadyStateChange() {
 if (xmlHttp.readyState == 4){
  proNum=parseInt(xmlHttp.responseText);
  document.getElementById("progressinner").style.width = proNum+"%";
  document.getElementById("showNum").innerHTML = proNum+"%";
  if ( proNum < 100){
   setTimeout("getProgress()", 100);
  }
 }
}
 
function getProgress(){
 loop++;
 document.getElementById("showNum2").innerHTML = loop;
 sendURL();
}
var interval;
function startProgress(){
 document.getElementById("progressouter").style.display="block";
 setTimeout("getProgress()", 100);
}
</script>
 
<iframe id="theframe" name="theframe"
src="upload.php?id=<?php echo($id); ?>"
style="border: none; height: 100px; width: 400px;" >
</iframe>
<br/><br/>
<div id="progressouter" style=
"width: 500px; height: 20px; border: 6px solid red; display:none;">
<div id="progressinner" style=
"position: relative; height: 20px; background-color: purple; width: 0%; ">
</div>
</div><div id='showNum'></div><br>
<div id='showNum2'></div>
</body>
</html>

常用添加网摘代码 Add Bookmark

Standard
1
2
3
4
5
6
7
8
9
10
11
<a href="javascript:window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent(document.location.href)+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)">QQ书签</a>
 
<a href="#" onClick="javascript:window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title))">Google书签</a>
 
<a href="#" onClick="javascript:window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title))">Yahoo书签</a>
 
<a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:'') : (d.getSelection?d.getSelection():''); void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=28&title='+escape(d.title)+'&url='+escape(d.location.href)+'&desc='+escape(t), 'vivi ','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes')); vivi.focus ();">新浪网摘</a>
 
<a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:'') : (d.getSelection?d.getSelection():''); void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t), 'keyit' ,'scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes')); keyit.focus();">365Key网摘</a>
 
<a href="javascript:t=document.title;u=location.href;e=document.selection ? (document.selection.type!='None'?document.selection.createRange().text:'') : (document.getSelection?document.getSelection():''); void(open('http://bookmark.hexun.com/post.aspx?title='+escape(t)+'&url='+escape(u)+'&excerpt='+escape(e), 'HexunBookmark' , 'scrollbars=no,width=600,height=450,left=80,top=80,status=no,resizable=yes'));">和讯网摘</a>

PHP用GD生成验证码

Standard
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
-----------validatecode.php------------
<?
//session_start();
function random($len)
{
$srcstr="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
mt_srand();
$strs="";
for($i=0;$i<$len;$i++){
$strs.=$srcstr[mt_rand(0,35)];
}
return strtoupper($strs);
}
$str=random(4); //随机生成的字符串
//$_SESSION["code"] = $str; 也可以用session来做
setcookie("code", $str, time()+60000, "/", ".yemaosheng.com");
$width = 120; //验证码图片的宽度
$height = 35; //验证码图片的高度
@header("Content-Type:image/png");
 
$im=imagecreate($width,$height);
//背景色
$back=imagecolorallocate($im,0xFF,0xFF,0xFF);
//字体色
$font=imagecolorallocate($im,287,330,347);
//$font_color=imagecolorallocate($im,287,330,347);
$font_color=imagecolorallocate($im,mt_rand(50,120),mt_rand(50,120),mt_rand(50,120));
//绘模糊作用的点
mt_srand();
for($i=0;$i<500;$i++)
{
imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),imagecolorallocate($im,mt_rand(1,255),mt_rand(1,255),mt_rand(1,255)));
}
 
$font_file = $_SERVER['DOCUMENT_ROOT'].'/img/res/font2.ttf';
/*变化文件颜色及角度大小*/
imagettftext($im, mt_rand(15,28), mt_rand(-30,30), 5, 30, $font_color, $font_file, substr($str,0,1));
imagettftext($im, mt_rand(15,28), mt_rand(-30,30), 35, 30, $font_color, $font_file, substr($str,1,1));
imagettftext($im, mt_rand(15,28), mt_rand(-30,30), 65, 30, $font_color, $font_file, substr($str,2,1));
imagettftext($im, mt_rand(15,28), mt_rand(-30,30), 95, 30, $font_color, $font_file, substr($str,3,1));
imagerectangle($im,0,0,$width-1,$height-1,$font); //画边框 int imagerectangle ( resource image, int x1, int y1, int x2, int y2, int col)
imagepng($im);
imagedestroy($im);
?>
-----------html------------
<form name="form1" method="post" action='get.php'>
<input name="validatecode" type="text" value="" /><img src="validatecode.php" />验证码
<input name="submit" type="submit" value="Submit" />
</form>
-----------get.php------------
<?php
if(strtolower($_COOKIE['code'])==strtolower($_POST['validatecode']))
{
echo "ok";
}
?>

PHP分页函数

Standard
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
if(!function_exists(pageft)){
function pageft($totle,$displaypg=20,$url=''){
global $page,$firstcount,$pagenav,$_SERVER;
$GLOBALS["displaypg"]=$displaypg;
if(!$page) { $page=1; }
if(!$url){
$url=$_SERVER["REQUEST_URI"];
}
//URL分析:
$parse_url=parse_url($url);
$url_query=$parse_url["query"]; //单独取出URL的查询字串
if($url_query){
$url_query=ereg_replace("(^|&)page=$page","",$url_query);
//将处理后的URL的查询字串替换原来的URL的查询字串:
$url=str_replace($parse_url["query"],$url_query,$url);
//在URL后加page查询信息,但待赋值:
if($url_query){
$url.="&page";
}else{
$url.="page";
}
}else {
$url.="?page";
}
$lastpg=ceil($totle/$displaypg); //最后页,也是总页数
$page=min($lastpg,$page);
$prepg=$page-1; //上一页
$nextpg=($page==$lastpg ? 0 : $page+1); //下一页
$firstcount=($page-1)*$displaypg;
//开始分页导航条代码:
$pagenav="显示第 <B>".($totle?($firstcount+1):0)."</B>-<B>".min($firstcount+$displaypg,$totle)."</B> 条记录,共 $totle 条记录<BR>";
//如果只有一页则跳出函数:
if($lastpg<=1) return false;
$pagenav.=" <a href='$url=1'>首页</a> ";
if($prepg){
$pagenav.=" <a href='$url=$prepg'>前页</a> ";
}else{
$pagenav.=" 前页 ";
}
if($nextpg){
$pagenav.=" <a href='$url=$nextpg'>后页</a> ";
}else{
$pagenav.=" 后页 ";
}
$pagenav.=" <a href='$url=$lastpg'>尾页</a> ";
//下拉跳转列表,循环列出所有页码:
$pagenav.=" 到第 <select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n";
for($i=1;$i<=$lastpg;$i++){
if($i==$page){
$pagenav.="<option value='$i' selected>$i</option>\n";
}else{
$pagenav.="<option value='$i'>$i</option>\n";
}
}
$pagenav.="</select> 页,共 $lastpg 页";
}
}
 
$sql="SELECT * FROM tb";
//取得总信息数
$result=mysql_query($sql);
$total=mysql_num_rows($result);
//调用pageft(),每页显示10条信息(使用默认的20时,可以省略此参数),使用本页URL(默认,所以省略掉)。
pageft($total,10,"http://www.yemaosheng.com/index");
//现在产生的全局变量就派上用场了:
$result=mysql_query($sql." limit $firstcount,$displaypg");
$i=1;
while($row=mysql_fetch_array($result)){
$array[]=array("index"=>$i,"date"=>$row['date'],"type"=>$row['type'],"value"=>$row['value']);
$i++;
}
$pagenav;//分页导航条代码
$main_smarty->assign('mainlist', $array);
$main_smarty->assign('pagenum', $pagenav);
$main_smarty->display('x.tpl');
 
----------------smarty template x.tpl----------------
<table>
{section name=sec1 loop=$mainlist}
<tr>
<td width="76"><strong>{$mainlist[sec1].index}</strong></td>
<td width="138">{$mainlist[sec1].date}</td>
<td width="274">{$mainlist[sec1].type}</td>
<td width="114">{$mainlist[sec1].value}</td>
</tr>
{/section}
</table>
<center>{$pagenum}</center>

Div Drag 鼠标拖放

Standard
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<HTML>
<HEAD>
<TITLE> div-drag </TITLE>
<META NAME="Author" C>
<SCRIPT LANGUAGE="JavaScript">
var activeDiv,activeSpan,beforeDiv;
function active(e){
if(e.tagName=="SPAN"){
activeSpan = e;
return;
}
activeDiv = e.cloneNode(true);
document.body.insertBefore(activeDiv);
with(activeDiv.style){
position="absolute";
backgroundColor="yellow";
filter="alpha(opacity=50)";
left=event.x-20;
top=event.y;
}
activeDiv.srcElement=e;
activeDiv.;
}
function releaseDiv(){
if(!activeDiv) return;
document.body.removeChild(activeDiv)
var se = activeDiv.srcElement;
var p = se.parentNode;
activeDiv=null;
if(beforeDiv && beforeDiv==se) return;
if(beforeDiv && beforeDiv.parentNode==activeSpan)
activeSpan.insertBefore(p.removeChild(se),beforeDiv)
else
activeSpan.insertBefore(p.removeChild(se))
 
}
function moveDiv(){
if(!activeDiv) return;
with(activeDiv.style){
left=event.x-20;
top=event.y;
}
}
function before(e){
beforeDiv=e;
}
</SCRIPT>
</HEAD>
<BODY >
<span style="width:30%;height:100%;border:1px solid gray;overflow-y:auto" >
<SCRIPT>//自动生成假数据
for(var i=1;i<3;i++) document.write(" <div style=\"height:200px;cursor:hand;border:1px solid #CCFFFF;background-color:#99FFFF\" onmousedown=\"active(this)\" onmousemove=\"before(this)\"><span style=\"width:100\">"+i+"</span></div>")
</SCRIPT>
</span>
<span style="width:30%;height:100%;border:1px solid gray;overflow-y:auto" >
<SCRIPT>//自动生成假数据
for(var i=4;i<6;i++) document.write(" <div style=\"height:200px;cursor:hand;border:1px solid #CCFFFF;background-color:#FFFFCC\" onmousedown=\"active(this)\" onmousemove=\"before(this)\"><span style=\"width:100\">"+i+"</span></div>")
</SCRIPT>
</span>
<span style="width:30%;height:100%;border:1px solid gray;overflow-y:auto" >
<SCRIPT>//自动生成假数据
for(var i=7;i<9;i++) document.write(" <div style=\"height:200px;cursor:hand;border:1px solid #CCFFFF;background-color:#FFCCFF\" onmousedown=\"active(this)\" onmousemove=\"before(this)\"><span style=\"width:100\">"+i+"</span></div>")
</SCRIPT>
</span>
</BODY>
</HTML>
----------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> div-drag </TITLE>
<META NAME="Author" C>
<SCRIPT LANGUAGE="JavaScript">
var activeDiv,activeSpan,beforeDiv;
function active(e){
if(e.tagName=="SPAN"){
if(!activeDiv) return;
activeSpan = e;
if(activeDiv.srcElement.parentNode!=e)
before(e.lastChild);
return;
}
activeDiv = e.cloneNode(true);
document.body.insertBefore(activeDiv);
with(activeDiv.style){
position="absolute";
backgroundColor="yellow";
filter="alpha(opacity=50)";
left=event.x-20;
top=event.y+2;
}
activeDiv.srcElement=e;
activeDiv.;
activeDiv.;
}
function releaseDiv(){
if(!activeDiv) return;
document.body.removeChild(activeDiv)
var se = activeDiv.srcElement;
var p = se.parentNode;
activeDiv=null;
}
function moveDiv(){
if(!activeDiv) return;
with(activeDiv.style){
left=event.x-20;
top=event.y+2;
}
}
function before(e){
if(!activeDiv || e.nextSibling==activeDiv)return;
if(e!=activeDiv.srcElement)
if(e.nextSibling&&e.nextSibling.parentNode==e.parentNode&&e.nextSibling!=e.parentNode.lastChild)
e.parentNode.insertBefore(activeDiv.srcElement.parentNode.removeChild(activeDiv.srcElement),e.nextSibling)
else
e.parentNode.insertBefore(activeDiv.srcElement.parentNode.removeChild(activeDiv.srcElement))
}
</SCRIPT>
</HEAD>
<BODY >
<span style="width:30%;height:100%;border:1px solid gray;overflow-y:auto" >
<SCRIPT>//自动生成假数据
for(var i=1;i<3;i++) document.write(" <div style=\"height:200px;cursor:hand;border:1px solid #CCFFFF;background-color:#99FFFF\" onmousedown=\"active(this)\" onmousemove=\"before(this)\"><span style=\"width:100\">"+i+"</span></div>")
</SCRIPT>
</span>
<span style="width:30%;height:100%;border:1px solid gray;overflow-y:auto" >
<SCRIPT>//自动生成假数据
for(var i=4;i<6;i++) document.write(" <div style=\"height:200px;cursor:hand;border:1px solid #CCFFFF;background-color:#FFFFCC\" onmousedown=\"active(this)\" onmousemove=\"before(this)\"><span style=\"width:100\">"+i+"</span></div>")
</SCRIPT>
</span>
<span style="width:30%;height:100%;border:1px solid gray;overflow-y:auto" >
<SCRIPT>//自动生成假数据
for(var i=7;i<9;i++) document.write(" <div style=\"height:200px;cursor:hand;border:1px solid #CCFFFF;background-color:#FFCCFF\" onmousedown=\"active(this)\" onmousemove=\"before(this)\"><span style=\"width:100\">"+i+"</span></div>")
</SCRIPT>
</span>
</BODY>
</HTML>